diff --git a/cypress/e2e/patient_spec/patient_crud.cy.ts b/cypress/e2e/patient_spec/patient_crud.cy.ts index 38eec604758..156a0d4fe5f 100644 --- a/cypress/e2e/patient_spec/patient_crud.cy.ts +++ b/cypress/e2e/patient_spec/patient_crud.cy.ts @@ -1,7 +1,6 @@ import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress"; import LoginPage from "../../pageobject/Login/LoginPage"; import { PatientPage } from "../../pageobject/Patient/PatientCreation"; -import { UpdatePatientPage } from "../../pageobject/Patient/PatientUpdate"; import FacilityPage from "../../pageobject/Facility/FacilityCreation"; import { PatientConsultationPage } from "../../pageobject/Patient/PatientConsultation"; import { @@ -18,9 +17,34 @@ const calculateAge = () => { describe("Patient Creation with consultation", () => { const loginPage = new LoginPage(); const patientPage = new PatientPage(); - const updatePatientPage = new UpdatePatientPage(); const patientConsultationPage = new PatientConsultationPage(); const facilityPage = new FacilityPage(); + const age = calculateAge(); + const patientDateOfBirth = "01012001"; + const patientOneName = "Patient With No Consultation"; + const patientOneGender = "Male"; + const patientOneUpdatedGender = "Female"; + const patientOneAddress = "Test Patient Address"; + const patientOnePincode = "682001"; + const patientOneState = "Kerala"; + const patientOneDistrict = "Ernakulam"; + const patientOneLocalbody = "Aluva"; + const patientOneWard = "4"; + const patientOnePresentHealth = "Present Health Condition"; + const patientOneOngoingMedication = "Ongoing Medication"; + const patientOneAllergies = "Allergies"; + const patientOneBloodGroup = "O+"; + const patientOneUpdatedBloodGroup = "AB+"; + const patientOneFirstInsuranceId = "insurance-details-0"; + const patientOneFirstSubscriberId = "member id 01"; + const patientOneFirstPolicyId = "policy name 01"; + const patientOneFirstInsurerId = "insurer id 01"; + const patientOneFirstInsurerName = "insurer name 01"; + const patientOneSecondInsuranceId = "insurance-details-1"; + const patientOneSecondSubscriberId = "member id 02"; + const patientOneSecondPolicyId = "policy name 02"; + const patientOneSecondInsurerId = "insurer id 02"; + const patientOneSecondInsurerName = "insurer name 02"; before(() => { loginPage.loginAsDisctrictAdmin(); @@ -33,88 +57,161 @@ describe("Patient Creation with consultation", () => { cy.awaitUrl("/patients"); }); - it("Create a new patient with no consultation", () => { + it("Create a new patient with all field in registration form and no consultation", () => { + // patient details with all the available fields except covid patientPage.createPatient(); - patientPage.selectFacility("dummy facility 40"); + patientPage.selectFacility("Dummy Facility 40"); patientPage.patientformvisibility(); - patientPage.enterPatientDetails( - phone_number, - emergency_phone_number, - "Test E2E User", - "Male", - "Test Patient Address", - "682001", - "O+", - "01012001" - ); - facilityPage.selectStateOnPincode("Kerala"); - facilityPage.selectDistrictOnPincode("Ernakulam"); - facilityPage.selectLocalBody("Aluva"); - facilityPage.selectWard("4"); + // Patient Details page + patientPage.typePatientPhoneNumber(phone_number); + patientPage.typePatientEmergencyNumber(emergency_phone_number); + patientPage.typePatientDateOfBirth(patientDateOfBirth); + patientPage.typePatientName(patientOneName); + patientPage.selectPatientGender(patientOneGender); + patientPage.typePatientAddress(patientOneAddress); + facilityPage.fillPincode(patientOnePincode); + facilityPage.selectStateOnPincode(patientOneState); + facilityPage.selectDistrictOnPincode(patientOneDistrict); + facilityPage.selectLocalBody(patientOneLocalbody); + facilityPage.selectWard(patientOneWard); + // Patient Medical History + patientPage.typePatientPresentHealth(patientOnePresentHealth); + patientPage.typePatientOngoingMedication(patientOneOngoingMedication); + patientPage.typeMedicalHistory(2, "Diabetes"); + patientPage.typeMedicalHistory(3, "Heart Disease"); + patientPage.typeMedicalHistory(4, "HyperTension"); + patientPage.typeMedicalHistory(5, "Kidney Diseases"); + patientPage.typeMedicalHistory(6, "Lung Diseases/Asthma"); + patientPage.typeMedicalHistory(7, "Cancer"); + patientPage.typeMedicalHistory(8, "Other"); + patientPage.typePatientAllergies(patientOneAllergies); + patientPage.selectPatientBloodGroup(patientOneBloodGroup); patientPage.clickCreatePatient(); - patientPage.verifyPatientIsCreated(); - patientPage.saveCreatedPatientUrl(); - }); - - it("Patient Detail verification post registration", () => { - patientPage.interceptFacilities(); - patientPage.visitCreatedPatient(); - patientPage.verifyStatusCode(); - const age = calculateAge(); - patientPage.verifyPatientDetails( + // Verify the patient details + patientPage.clickCancelButton(); + cy.wait(3000); + patientPage.savePatientUrl(); + patientPage.verifyPatientDashboardDetails( + patientOneGender, age, - "Test E2E User", + patientOneName, phone_number, emergency_phone_number, yearOfBirth, - "O+" + patientOneBloodGroup ); + patientPage.verifyPatientMedicalDetails( + patientOnePresentHealth, + patientOneOngoingMedication, + patientOneAllergies, + "Diabetes", + "Heart Disease", + "HyperTension", + "Kidney Diseases", + "Lung Diseases/Asthma", + "Cancer", + "Other" + ); + // verify its presence in the patient detail page + cy.visit("/patients"); + patientPage.typePatientNameList(patientOneName); + patientPage.verifyPatientNameList(patientOneName); }); - it("Edit the patient details", () => { + it("Edit the patient details with no consultation and verify", () => { patientPage.interceptFacilities(); patientPage.visitUpdatePatientUrl(); patientPage.verifyStatusCode(); patientPage.patientformvisibility(); - updatePatientPage.enterPatientDetails( - "Test E2E User Edited", - "O+", + // change the gender to female and input data to related changed field + cy.wait(3000); + patientPage.selectPatientGender(patientOneUpdatedGender); + patientPage.clickPatientAntenatalStatusYes(); + patientPage.selectPatientBloodGroup(patientOneUpdatedBloodGroup); + // Edit the patient consultation , select none medical history and multiple health ID + patientPage.clickNoneMedicialHistory(); + patientPage.clickAddInsruanceDetails(); + patientPage.typeSubscriberId( + patientOneFirstInsuranceId, + patientOneFirstSubscriberId + ); + patientPage.typePolicyId( + patientOneFirstInsuranceId, + patientOneFirstPolicyId + ); + patientPage.typeInsurerId( + patientOneFirstInsuranceId, + patientOneFirstInsurerId + ); + patientPage.typeInsurerName( + patientOneFirstInsuranceId, + patientOneFirstInsurerName + ); + patientPage.clickAddInsruanceDetails(); + patientPage.typeSubscriberId( + patientOneSecondInsuranceId, + patientOneSecondSubscriberId + ); + patientPage.typePolicyId( + patientOneSecondInsuranceId, + patientOneSecondPolicyId + ); + patientPage.typeInsurerId( + patientOneSecondInsuranceId, + patientOneSecondInsurerId + ); + patientPage.typeInsurerName( + patientOneSecondInsuranceId, + patientOneSecondInsurerName + ); + patientPage.clickUpdatePatient(); + cy.wait(3000); + patientPage.verifyPatientUpdated(); + patientPage.visitPatientUrl(); + // Verify Female Gender change reflection, No Medical History and Insurance Details + cy.wait(5000); + patientPage.verifyPatientDashboardDetails( + patientOneUpdatedGender, + age, + patientOneName, phone_number, emergency_phone_number, - "Test Patient Address Edited", - "Severe Cough", - "Paracetamol", - "Dust", - ["2 months ago", "1 month ago"], - "SUB123", - "P123", - "GICOFINDIA", - "GICOFINDIA" - ); - updatePatientPage.clickUpdatePatient(); - - updatePatientPage.verifyPatientUpdated(); - updatePatientPage.saveUpdatedPatientUrl(); - }); - - it("Patient Detail verification post edit", () => { - patientPage.interceptFacilities(); - updatePatientPage.visitUpdatedPatient(); - patientPage.verifyStatusCode(); - - updatePatientPage.verifyPatientDetails( - "Test E2E User Edited", - phone_number, - "Severe Cough", - "Paracetamol", - "Dust" + yearOfBirth, + patientOneUpdatedBloodGroup + ); + // Verify No medical history + patientPage.verifyNoSymptosPresent("Diabetes"); + // verify insurance details and dedicatd page + cy.get("[data-testid=patient-details]") + .contains(patientOneFirstSubscriberId) + .scrollIntoView(); + cy.wait(2000); + patientPage.verifyPatientPolicyDetails( + patientOneFirstSubscriberId, + patientOneFirstPolicyId, + patientOneFirstInsurerId, + patientOneFirstInsurerName + ); + patientPage.clickPatientInsuranceViewDetail(); + cy.wait(3000); + patientPage.verifyPatientPolicyDetails( + patientOneFirstSubscriberId, + patientOneFirstPolicyId, + patientOneFirstInsurerId, + patientOneFirstInsurerName + ); + patientPage.verifyPatientPolicyDetails( + patientOneSecondSubscriberId, + patientOneSecondPolicyId, + patientOneSecondInsurerId, + patientOneSecondInsurerName ); }); it("Create a New consultation to existing patient", () => { patientPage.interceptFacilities(); - updatePatientPage.visitConsultationPage(); + patientPage.visitConsultationPage(); patientPage.verifyStatusCode(); patientConsultationPage.fillIllnessHistory("history"); patientConsultationPage.selectConsultationStatus( @@ -145,7 +242,7 @@ describe("Patient Creation with consultation", () => { }); it("Edit created consultation to existing patient", () => { - updatePatientPage.visitUpdatedPatient(); + patientPage.visitPatientUrl(); patientConsultationPage.visitEditConsultationPage(); patientConsultationPage.fillIllnessHistory("editted"); patientConsultationPage.updateSymptoms("FEVER"); diff --git a/cypress/pageobject/Patient/PatientCreation.ts b/cypress/pageobject/Patient/PatientCreation.ts index 4e2f92ac040..0cf8abd4afa 100644 --- a/cypress/pageobject/Patient/PatientCreation.ts +++ b/cypress/pageobject/Patient/PatientCreation.ts @@ -24,7 +24,7 @@ export class PatientPage { cy.get("input[name='facilities']") .type(facilityName) .then(() => { - cy.get("[role='option']").first().click(); + cy.get("[role='option']").contains(facilityName).click(); }); cy.get("button").should("contain", "Select"); cy.get("button").get("#submit").click(); @@ -38,34 +38,115 @@ export class PatientPage { cy.wait("@createPatient").its("response.statusCode").should("eq", 200); } - enterPatientDetails( - phoneNumber: string, - emergencyPhoneNumber: string, - patientName: string, - gender: string, - address: string, - pincode: string, - bloodGroup: string, - dateOfBirth: string - ) { - cy.get("#phone_number-div").type(phoneNumber); - cy.get("#emergency_phone_number-div").type(emergencyPhoneNumber); + verifyPatientNameList(patientName: string) { + cy.get("#patient-name-list").contains(patientName); + } + + typePatientPhoneNumber(phoneNumber: string) { + cy.get("#phone_number-div").click().type(phoneNumber); + } + + typePatientEmergencyNumber(phoneNumber: string) { + cy.get("#emergency_phone_number-div").click().type(phoneNumber); + } + + typePatientDateOfBirth(dateOfBirth: string) { + cy.get("#date_of_birth").scrollIntoView(); cy.get("#date_of_birth").should("be.visible").click(); cy.get("#date-input").click().type(dateOfBirth); - cy.get("[data-testid=name] input").type(patientName); + } + + typePatientName(patientName: string) { + cy.get("[data-testid=name] input").click().type(patientName); + } + + typePatientNameList(patientName: string) { + cy.get("#name").click().type(patientName); + } + + typePatientAddress(address: string) { + cy.get("[data-testid=current-address] textarea") + .click() + .clear() + .click() + .type(address); + } + + typePatientPresentHealth(presentHealth: string) { + cy.get("#present_health").click().type(presentHealth); + } + + typePatientOngoingMedication(ongoingMedication: string) { + cy.get("#ongoing_medication").click().type(ongoingMedication); + } + + typePatientAllergies(allergies: string) { + cy.get("#allergies").click().type(allergies); + } + + clickPermanentAddress() { + cy.get("[data-testid=permanent-address] input").check(); + } + + clickPatientAntenatalStatusYes() { + cy.get("#is_antenatal-0").click(); + } + + clickAddInsruanceDetails() { + cy.get("[data-testid=add-insurance-button]").click(); + } + + typeSubscriberId(id: string, subscriberId: string) { + cy.get(`#${id}`).within(() => { + cy.get("#subscriber_id").clear().type(subscriberId); + }); + } + + typePolicyId(id: string, policyid: string) { + cy.get(`#${id}`).within(() => { + cy.get("#policy_id").click().type(policyid); + }); + } + + typeInsurerId(id: string, insurerid: string) { + cy.get(`#${id}`).within(() => { + cy.get("#insurer_id").click().type(insurerid); + }); + } + + typeInsurerName(id: string, insurername: string) { + cy.get(`#${id}`).within(() => { + cy.get("#insurer_name").click().type(insurername); + }); + } + + clickNoneMedicialHistory() { + cy.get("[name=medical_history_check_1]").scrollIntoView(); + cy.get("[name=medical_history_check_1]").check(); + } + + clickCancelButton() { + cy.get("#cancel").click(); + } + + typeMedicalHistory(index, text) { + cy.get(`#medical_history_check_${index}`).click(); + cy.get(`#medical_history_${index}`).click().type(text); + } + + selectPatientGender(gender: string) { cy.get("[data-testid=Gender] button") .click() .then(() => { cy.get("[role='option']").contains(gender).click(); }); - cy.get("[data-testid=current-address] textarea").type(address); - cy.get("[data-testid=permanent-address] input").check(); - cy.get("#pincode").type(pincode); - cy.get("[name=medical_history_check_1]").check(); - cy.get("[data-testid=blood-group] button") + } + + selectPatientBloodGroup(bloodgroup: string) { + cy.get("#blood_group") .click() .then(() => { - cy.get("[role='option']").contains(bloodGroup).click(); + cy.get("[role='option']").contains(bloodgroup).click(); }); } @@ -80,40 +161,125 @@ export class PatientPage { cy.url().should("include", "/patient"); } - saveCreatedPatientUrl() { + savePatientUrl() { cy.url().then((url) => { - cy.log(url); - patient_url = url.split("/").slice(0, -1).join("/"); - cy.log(patient_url); + patient_url = url; }); } - visitCreatedPatient() { - cy.awaitUrl(patient_url); + visitPatientUrl() { + cy.visit(patient_url); + } + + visitConsultationPage() { + cy.visit(patient_url + "/consultation"); + } + + clickUpdatePatient() { + cy.intercept("PUT", "**/api/v1/patient/**").as("updatePatient"); + cy.get("button").get("[data-testid=submit-button]").click(); + cy.wait("@updatePatient").its("response.statusCode").should("eq", 200); + } + + verifyPatientUpdated() { + cy.url().should("include", "/patient"); + } + + verifyPatientPhoneNumber(phoneNumber: string) { + cy.get("[data-testid=patient-dashboard]").should("contain", phoneNumber); } - verifyPatientDetails( - age: number, - patientName: string, - phoneNumber: string, - emergencyPhoneNumber: string, - yearOfBirth: string, - bloodGroup: string + verifyPatientDashboardDetails( + gender, + age, + patientName, + phoneNumber, + emergencyPhoneNumber, + yearOfBirth, + bloodGroup ) { cy.url().should("include", "/facility/"); - cy.get("[data-testid=patient-dashboard]").should("contain", age); - cy.get("[data-testid=patient-dashboard]").should("contain", patientName); - cy.get("[data-testid=patient-dashboard]").should("contain", phoneNumber); - cy.get("[data-testid=patient-dashboard]").should( - "contain", - emergencyPhoneNumber + cy.get("[data-testid=patient-dashboard]").then(($dashboard) => { + expect($dashboard).to.contain(gender); + expect($dashboard).to.contain(age); + expect($dashboard).to.contain(patientName); + expect($dashboard).to.contain(phoneNumber); + expect($dashboard).to.contain(emergencyPhoneNumber); + expect($dashboard).to.contain(yearOfBirth); + expect($dashboard).to.contain(bloodGroup); + }); + } + + verifyPatientLocationDetails( + patientAddress, + patientPincode, + patientState, + patientDistrict, + patientLocalbody, + patientWard + ) { + cy.get("[data-testid=patient-details]").then(($dashboard) => { + cy.url().should("include", "/facility/"); + expect($dashboard).to.contain(patientAddress); + expect($dashboard).to.contain(patientPincode); + expect($dashboard).to.contain(patientState); + expect($dashboard).to.contain(patientDistrict); + expect($dashboard).to.contain(patientLocalbody); + expect($dashboard).to.contain(patientWard); + }); + } + + verifyPatientMedicalDetails( + patientPresentHealth, + patientOngoingMedication, + patientAllergies, + patientSymptoms1, + patientSymptoms2, + patientSymptoms3, + patientSymptoms4, + patientSymptoms5, + patientSymptoms6, + patientSymptoms7 + ) { + cy.get("[data-testid=patient-details]").then(($dashboard) => { + cy.url().should("include", "/facility/"); + expect($dashboard).to.contain(patientPresentHealth); + expect($dashboard).to.contain(patientOngoingMedication); + expect($dashboard).to.contain(patientAllergies); + expect($dashboard).to.contain(patientSymptoms1); + expect($dashboard).to.contain(patientSymptoms2); + expect($dashboard).to.contain(patientSymptoms3); + expect($dashboard).to.contain(patientSymptoms4); + expect($dashboard).to.contain(patientSymptoms5); + expect($dashboard).to.contain(patientSymptoms6); + expect($dashboard).to.contain(patientSymptoms7); + }); + } + + verifyPatientPolicyDetails(subscriberId, policyId, insurerId, insurerName) { + cy.get("[data-testid=patient-details]").then(($dashboard) => { + cy.url().should("include", "/facility/"); + expect($dashboard).to.contain(subscriberId); + expect($dashboard).to.contain(policyId); + expect($dashboard).to.contain(insurerId); + expect($dashboard).to.contain(insurerName); + }); + } + + clickPatientInsuranceViewDetail() { + cy.get("#insurance-view-details").scrollIntoView(); + cy.get("#insurance-view-details").click(); + } + + verifyNoSymptosPresent(patientSymptoms1: string) { + cy.get("[data-testid=patient-details]").should( + "not.contain", + patientSymptoms1 ); - cy.get("[data-testid=patient-dashboard]").should("contain", yearOfBirth); - cy.get("[data-testid=patient-dashboard]").should("contain", bloodGroup); } visitUpdatePatientUrl() { - cy.awaitUrl(patient_url + "/update"); + cy.visit(patient_url + "/update"); } interceptFacilities() { diff --git a/cypress/pageobject/Patient/PatientUpdate.ts b/cypress/pageobject/Patient/PatientUpdate.ts deleted file mode 100644 index b26ef678679..00000000000 --- a/cypress/pageobject/Patient/PatientUpdate.ts +++ /dev/null @@ -1,97 +0,0 @@ -let patient_url = ""; - -export class UpdatePatientPage { - enterPatientDetails( - patientName: string, - bloodGroup: string, - phoneNumber: string, - emergencyPhoneNumber: string, - address: string, - currentHealthCondition: string, - ongoingMedication: string, - allergies: string, - medicalHistory: string[], - subscriberId: string, - policyId: string, - insuranceId: string, - insuranceName: string - ) { - cy.wait(10000); - cy.get("#address").scrollIntoView(); - cy.get("#address").should("be.visible"); - cy.get("#address").type(address); - cy.get("[data-testid=name] input").clear(); - cy.get("[data-testid=name] input").type(patientName); - cy.get("#phone_number-div").clear(); - cy.get("#phone_number-div").type("+91").type(phoneNumber); - cy.get("#emergency_phone_number-div").clear(); - cy.get("#emergency_phone_number-div") - .type("+91") - .type(emergencyPhoneNumber); - cy.get("#present_health").type(currentHealthCondition); - cy.get("#ongoing_medication").type(ongoingMedication); - cy.get("#allergies").type(allergies); - cy.get("[name=medical_history_check_1]").uncheck(); - cy.get("[name=medical_history_check_2]").check(); - cy.get("#medical_history_2").type(medicalHistory[0]); - cy.get("[name=medical_history_check_3]").check(); - cy.get("#medical_history_3").type(medicalHistory[1]); - cy.get("button").get("[data-testid=add-insurance-button]").click(); - cy.get("#subscriber_id").type(subscriberId); - cy.get("#policy_id").type(policyId); - cy.get("#insurer_id").type(insuranceId); - cy.get("#insurer_name").type(insuranceName); - cy.get("[data-testid=blood-group] button") - .click() - .then(() => { - cy.get("[role='option']").contains(bloodGroup).click(); - }); - } - - clickUpdatePatient() { - cy.intercept("PUT", "**/api/v1/patient/**").as("updatePatient"); - cy.get("button").get("[data-testid=submit-button]").click(); - cy.wait("@updatePatient").its("response.statusCode").should("eq", 200); - } - - verifyPatientUpdated() { - cy.url().should("include", "/patient"); - } - - saveUpdatedPatientUrl() { - cy.url().then((url) => { - cy.log(url); - patient_url = url.split("/").slice(0, -1).join("/"); - cy.log(patient_url); - }); - } - - visitUpdatedPatient() { - cy.awaitUrl(patient_url); - } - - verifyPatientDetails( - patientName: string, - phoneNumber: string, - presentHealth: string, - ongoingMedication: string, - allergies: string - ) { - cy.url().should("include", "/facility/"); - cy.get("[data-testid=patient-dashboard]").should("contain", patientName); - cy.get("[data-testid=patient-dashboard]").should("contain", phoneNumber); - cy.get("[data-testid=patient-present-health]").should( - "contain", - presentHealth - ); - cy.get("[data-testid=patient-ongoing-medication]").should( - "contain", - ongoingMedication - ); - cy.get("[data-testid=patient-allergies]").should("contain", allergies); - } - - visitConsultationPage() { - cy.visit(patient_url + "/consultation"); - } -} diff --git a/package-lock.json b/package-lock.json index 4c3e964a7c8..648fd35ae1d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24608,4 +24608,4 @@ } } } -} +} \ No newline at end of file diff --git a/src/Components/HCX/InsuranceDetailsBuilder.tsx b/src/Components/HCX/InsuranceDetailsBuilder.tsx index 5482c48149f..36713e317a2 100644 --- a/src/Components/HCX/InsuranceDetailsBuilder.tsx +++ b/src/Components/HCX/InsuranceDetailsBuilder.tsx @@ -55,23 +55,27 @@ export default function InsuranceDetailsBuilder(props: Props) { return ( -
+
+
); } diff --git a/src/Components/Patient/InsuranceDetailsCard.tsx b/src/Components/Patient/InsuranceDetailsCard.tsx index b928ce7bffd..41cfede9f3a 100644 --- a/src/Components/Patient/InsuranceDetailsCard.tsx +++ b/src/Components/Patient/InsuranceDetailsCard.tsx @@ -54,6 +54,7 @@ export const InsuranceDetialsCard = (props: InsuranceDetails) => {
{ navigate( `/facility/${data.patient_object?.facility_object?.id}/patient/${data.patient_object?.id}/insurance`