From ed99a2cfa9ea287756947e394a2f55ab68c7b2f9 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Mon, 5 Feb 2024 16:44:33 +0530 Subject: [PATCH] New Cypress Test | Patient Transfer and Patient Data Import From External Result | Patient Module (#7165) * first draft * first draft * Transfer functionality of a patient * Final PR * refactor few code * refactor cypress policy file * revert vite configuration --- .../patient_spec/patient_consultation.cy.ts | 104 +++++++++++ ..._crud.cy.ts => patient_registration.cy.ts} | 173 +++++++++++------- .../pageobject/Patient/PatientConsultation.ts | 12 +- cypress/pageobject/Patient/PatientCreation.ts | 99 ---------- cypress/pageobject/Patient/PatientExternal.ts | 28 +++ .../pageobject/Patient/PatientInsurance.ts | 32 ++++ .../Patient/PatientMedicalHistory.ts | 59 ++++++ cypress/pageobject/Patient/PatientTransfer.ts | 63 +++++++ src/Components/ExternalResult/ResultItem.tsx | 11 +- src/Components/ExternalResult/ResultList.tsx | 5 +- .../Facility/DuplicatePatientDialog.tsx | 1 + .../Facility/TransferPatientDialog.tsx | 2 + src/Components/Patient/PatientHome.tsx | 1 + src/Components/Patient/PatientInfoCard.tsx | 5 +- src/Components/Patient/PatientRegister.tsx | 2 + 15 files changed, 420 insertions(+), 177 deletions(-) create mode 100644 cypress/e2e/patient_spec/patient_consultation.cy.ts rename cypress/e2e/patient_spec/{patient_crud.cy.ts => patient_registration.cy.ts} (55%) create mode 100644 cypress/pageobject/Patient/PatientExternal.ts create mode 100644 cypress/pageobject/Patient/PatientInsurance.ts create mode 100644 cypress/pageobject/Patient/PatientMedicalHistory.ts create mode 100644 cypress/pageobject/Patient/PatientTransfer.ts diff --git a/cypress/e2e/patient_spec/patient_consultation.cy.ts b/cypress/e2e/patient_spec/patient_consultation.cy.ts new file mode 100644 index 00000000000..9b3248d6656 --- /dev/null +++ b/cypress/e2e/patient_spec/patient_consultation.cy.ts @@ -0,0 +1,104 @@ +import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress"; +import LoginPage from "../../pageobject/Login/LoginPage"; +import { PatientPage } from "../../pageobject/Patient/PatientCreation"; +import { PatientConsultationPage } from "../../pageobject/Patient/PatientConsultation"; +import { + emergency_phone_number, + phone_number, +} from "../../pageobject/constants"; +import FacilityPage from "../../pageobject/Facility/FacilityCreation"; +import PatientMedicalHistory from "../../pageobject/Patient/PatientMedicalHistory"; + +describe("Patient Creation with consultation", () => { + const patientConsultationPage = new PatientConsultationPage(); + const loginPage = new LoginPage(); + const patientPage = new PatientPage(); + const facilityPage = new FacilityPage(); + const patientMedicalHistory = new PatientMedicalHistory(); + const patientDateOfBirth = "01012001"; + const patientOneName = "Patient With Consultation"; + const patientOneGender = "Male"; + const patientOneAddress = "Test Patient Address"; + const patientOnePincode = "682001"; + const patientOneState = "Kerala"; + const patientOneDistrict = "Ernakulam"; + const patientOneLocalbody = "Aluva"; + const patientOneWard = "4"; + const patientOneBloodGroup = "O+"; + + before(() => { + loginPage.loginAsDisctrictAdmin(); + cy.saveLocalStorage(); + }); + + beforeEach(() => { + cy.restoreLocalStorage(); + cy.clearLocalStorage(/filters--.+/); + cy.awaitUrl("/patients"); + }); + + it("Create a patient with consultation", () => { + patientPage.createPatient(); + patientPage.selectFacility("Dummy Facility 40"); + patientPage.patientformvisibility(); + 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); + patientMedicalHistory.clickNoneMedicialHistory(); + patientPage.selectPatientBloodGroup(patientOneBloodGroup); + patientPage.clickCreatePatient(); + patientPage.verifyPatientIsCreated(); + patientConsultationPage.fillIllnessHistory("history"); + patientConsultationPage.selectConsultationStatus( + "Outpatient/Emergency Room" + ); + patientConsultationPage.selectSymptoms("ASYMPTOMATIC"); + + patientConsultationPage.enterConsultationDetails( + "Stable", + "Examination details and Clinical conditions", + "70", + "170", + "IP007", + "generalnote", + "Dev Doctor" + ); + patientConsultationPage.submitConsultation(); + + // Below code for the prescription module only present while creating a new consultation + patientConsultationPage.clickAddPrescription(); + patientConsultationPage.interceptMediaBase(); + patientConsultationPage.selectMedicinebox(); + patientConsultationPage.waitForMediabaseStatusCode(); + patientConsultationPage.prescribefirstMedicine(); + patientConsultationPage.enterDosage("3"); + patientConsultationPage.selectDosageFrequency("Twice daily"); + patientConsultationPage.submitPrescriptionAndReturn(); + patientConsultationPage.verifyConsultationPatientName(patientOneName); + }); + + it("Edit created consultation to existing patient", () => { + // temporary fixing, whole file will be refactored soon + cy.get("[data-cy='patient']").first().click(); + patientConsultationPage.clickEditConsultationButton(); + patientConsultationPage.fillIllnessHistory("editted"); + patientConsultationPage.updateSymptoms("FEVER"); + patientConsultationPage.setSymptomsDate("01082023"); + patientConsultationPage.updateConsultation(); + patientConsultationPage.verifySuccessNotification( + "Consultation updated successfully" + ); + }); + + afterEach(() => { + cy.saveLocalStorage(); + }); +}); diff --git a/cypress/e2e/patient_spec/patient_crud.cy.ts b/cypress/e2e/patient_spec/patient_registration.cy.ts similarity index 55% rename from cypress/e2e/patient_spec/patient_crud.cy.ts rename to cypress/e2e/patient_spec/patient_registration.cy.ts index 156a0d4fe5f..1dce2c7c6f7 100644 --- a/cypress/e2e/patient_spec/patient_crud.cy.ts +++ b/cypress/e2e/patient_spec/patient_registration.cy.ts @@ -2,11 +2,15 @@ import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress"; import LoginPage from "../../pageobject/Login/LoginPage"; import { PatientPage } from "../../pageobject/Patient/PatientCreation"; import FacilityPage from "../../pageobject/Facility/FacilityCreation"; -import { PatientConsultationPage } from "../../pageobject/Patient/PatientConsultation"; import { emergency_phone_number, phone_number, } from "../../pageobject/constants"; +import PatientTransfer from "../../pageobject/Patient/PatientTransfer"; +import PatientExternal from "../../pageobject/Patient/PatientExternal"; +import PatientInsurance from "../../pageobject/Patient/PatientInsurance"; +import PatientMedicalHistory from "../../pageobject/Patient/PatientMedicalHistory"; + const yearOfBirth = "2001"; const calculateAge = () => { @@ -17,9 +21,13 @@ const calculateAge = () => { describe("Patient Creation with consultation", () => { const loginPage = new LoginPage(); const patientPage = new PatientPage(); - const patientConsultationPage = new PatientConsultationPage(); const facilityPage = new FacilityPage(); + const patientTransfer = new PatientTransfer(); + const patientExternal = new PatientExternal(); + const patientInsurance = new PatientInsurance(); + const patientMedicalHistory = new PatientMedicalHistory(); const age = calculateAge(); + const patientFacility = "Dummy Facility 40"; const patientDateOfBirth = "01012001"; const patientOneName = "Patient With No Consultation"; const patientOneGender = "Male"; @@ -45,6 +53,10 @@ describe("Patient Creation with consultation", () => { const patientOneSecondPolicyId = "policy name 02"; const patientOneSecondInsurerId = "insurer id 02"; const patientOneSecondInsurerName = "insurer name 02"; + const patientTransferPhoneNumber = "9849511866"; + const patientTransferFacility = "Dummy Shifting Center"; + const patientTransferName = "Dummy Patient 10"; + const patientExternalName = "Patient 20"; before(() => { loginPage.loginAsDisctrictAdmin(); @@ -60,7 +72,7 @@ describe("Patient Creation with 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(patientFacility); patientPage.patientformvisibility(); // Patient Details page patientPage.typePatientPhoneNumber(phone_number); @@ -75,16 +87,18 @@ describe("Patient Creation with consultation", () => { 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); + patientMedicalHistory.typePatientPresentHealth(patientOnePresentHealth); + patientMedicalHistory.typePatientOngoingMedication( + patientOneOngoingMedication + ); + patientMedicalHistory.typeMedicalHistory(2, "Diabetes"); + patientMedicalHistory.typeMedicalHistory(3, "Heart Disease"); + patientMedicalHistory.typeMedicalHistory(4, "HyperTension"); + patientMedicalHistory.typeMedicalHistory(5, "Kidney Diseases"); + patientMedicalHistory.typeMedicalHistory(6, "Lung Diseases/Asthma"); + patientMedicalHistory.typeMedicalHistory(7, "Cancer"); + patientMedicalHistory.typeMedicalHistory(8, "Other"); + patientMedicalHistory.typePatientAllergies(patientOneAllergies); patientPage.selectPatientBloodGroup(patientOneBloodGroup); patientPage.clickCreatePatient(); patientPage.verifyPatientIsCreated(); @@ -101,7 +115,7 @@ describe("Patient Creation with consultation", () => { yearOfBirth, patientOneBloodGroup ); - patientPage.verifyPatientMedicalDetails( + patientMedicalHistory.verifyPatientMedicalDetails( patientOnePresentHealth, patientOneOngoingMedication, patientOneAllergies, @@ -130,39 +144,47 @@ describe("Patient Creation with consultation", () => { patientPage.clickPatientAntenatalStatusYes(); patientPage.selectPatientBloodGroup(patientOneUpdatedBloodGroup); // Edit the patient consultation , select none medical history and multiple health ID - patientPage.clickNoneMedicialHistory(); - patientPage.clickAddInsruanceDetails(); - patientPage.typeSubscriberId( + patientMedicalHistory.clickNoneMedicialHistory(); + patientInsurance.clickAddInsruanceDetails(); + patientInsurance.typePatientInsuranceDetail( patientOneFirstInsuranceId, + "subscriber_id", patientOneFirstSubscriberId ); - patientPage.typePolicyId( + patientInsurance.typePatientInsuranceDetail( patientOneFirstInsuranceId, + "policy_id", patientOneFirstPolicyId ); - patientPage.typeInsurerId( + patientInsurance.typePatientInsuranceDetail( patientOneFirstInsuranceId, + "insurer_id", patientOneFirstInsurerId ); - patientPage.typeInsurerName( + patientInsurance.typePatientInsuranceDetail( patientOneFirstInsuranceId, + "insurer_name", patientOneFirstInsurerName ); - patientPage.clickAddInsruanceDetails(); - patientPage.typeSubscriberId( + patientInsurance.clickAddInsruanceDetails(); + patientInsurance.typePatientInsuranceDetail( patientOneSecondInsuranceId, + "subscriber_id", patientOneSecondSubscriberId ); - patientPage.typePolicyId( + patientInsurance.typePatientInsuranceDetail( patientOneSecondInsuranceId, + "policy_id", patientOneSecondPolicyId ); - patientPage.typeInsurerId( + patientInsurance.typePatientInsuranceDetail( patientOneSecondInsuranceId, + "insurer_id", patientOneSecondInsurerId ); - patientPage.typeInsurerName( + patientInsurance.typePatientInsuranceDetail( patientOneSecondInsuranceId, + "insurer_name", patientOneSecondInsurerName ); patientPage.clickUpdatePatient(); @@ -181,27 +203,27 @@ describe("Patient Creation with consultation", () => { patientOneUpdatedBloodGroup ); // Verify No medical history - patientPage.verifyNoSymptosPresent("Diabetes"); + patientMedicalHistory.verifyNoSymptosPresent("Diabetes"); // verify insurance details and dedicatd page cy.get("[data-testid=patient-details]") .contains(patientOneFirstSubscriberId) .scrollIntoView(); cy.wait(2000); - patientPage.verifyPatientPolicyDetails( + patientInsurance.verifyPatientPolicyDetails( patientOneFirstSubscriberId, patientOneFirstPolicyId, patientOneFirstInsurerId, patientOneFirstInsurerName ); - patientPage.clickPatientInsuranceViewDetail(); + patientInsurance.clickPatientInsuranceViewDetail(); cy.wait(3000); - patientPage.verifyPatientPolicyDetails( + patientInsurance.verifyPatientPolicyDetails( patientOneFirstSubscriberId, patientOneFirstPolicyId, patientOneFirstInsurerId, patientOneFirstInsurerName ); - patientPage.verifyPatientPolicyDetails( + patientInsurance.verifyPatientPolicyDetails( patientOneSecondSubscriberId, patientOneSecondPolicyId, patientOneSecondInsurerId, @@ -209,48 +231,59 @@ describe("Patient Creation with consultation", () => { ); }); - it("Create a New consultation to existing patient", () => { - patientPage.interceptFacilities(); - patientPage.visitConsultationPage(); - patientPage.verifyStatusCode(); - patientConsultationPage.fillIllnessHistory("history"); - patientConsultationPage.selectConsultationStatus( - "Outpatient/Emergency Room" - ); - patientConsultationPage.selectSymptoms("ASYMPTOMATIC"); - - patientConsultationPage.enterConsultationDetails( - "Stable", - "Examination details and Clinical conditions", - "70", - "170", - "IP007", - "generalnote", - "Dev Doctor" - ); - patientConsultationPage.submitConsultation(); - - // Below code for the prescription module only present while creating a new consultation - patientConsultationPage.clickAddPrescription(); - patientConsultationPage.interceptMediaBase(); - patientConsultationPage.selectMedicinebox(); - patientConsultationPage.waitForMediabaseStatusCode(); - patientConsultationPage.prescribefirstMedicine(); - patientConsultationPage.enterDosage("3"); - patientConsultationPage.selectDosageFrequency("Twice daily"); - patientConsultationPage.submitPrescriptionAndReturn(); + it("Patient Registration using the transfer with no consultation", () => { + // transfer the patient and no consulation + patientPage.createPatient(); + patientPage.selectFacility(patientTransferFacility); + patientPage.patientformvisibility(); + patientPage.typePatientPhoneNumber(patientTransferPhoneNumber); + patientTransfer.clickAdmitPatientRecordButton(); + patientTransfer.clickTransferPopupContinueButton(); + patientTransfer.clickTransferPatientNameList(patientTransferName); + patientTransfer.clickTransferPatientDob(patientDateOfBirth); + patientTransfer.clickTransferSubmitButton(); + patientTransfer.verifyFacilitySuccessfullMessage(); + patientTransfer.clickConsultationCancelButton(); + cy.wait(3000); + // allow the transfer button of a patient + patientTransfer.clickAllowPatientTransferButton(); + // Verify the patient error message for the same facility + cy.awaitUrl("/patients"); + patientPage.createPatient(); + patientPage.selectFacility(patientTransferFacility); + patientPage.patientformvisibility(); + patientPage.typePatientPhoneNumber(patientTransferPhoneNumber); + patientTransfer.clickAdmitPatientRecordButton(); + patientTransfer.clickTransferPopupContinueButton(); + patientTransfer.clickTransferPatientNameList(patientTransferName); + patientTransfer.clickTransferPatientDob(patientDateOfBirth); + patientTransfer.clickTransferSubmitButton(); + patientTransfer.verifyFacilityErrorMessage(); }); - it("Edit created consultation to existing patient", () => { - patientPage.visitPatientUrl(); - patientConsultationPage.visitEditConsultationPage(); - patientConsultationPage.fillIllnessHistory("editted"); - patientConsultationPage.updateSymptoms("FEVER"); - patientConsultationPage.setSymptomsDate("01082023"); - patientConsultationPage.updateConsultation(); - patientConsultationPage.verifySuccessNotification( - "Consultation updated successfully" - ); + it("Patient Registration using External Result Import", () => { + // copy the patient external ID from external results + cy.awaitUrl("/external_results"); + patientExternal.verifyExternalListPatientName(patientExternalName); + patientExternal.verifyExternalIdVisible(); + // cypress have a limitation to work only asynchronously + // import the result and create a new patient + let extractedId = ""; + cy.get("#patient-external-id") + .invoke("text") + .then((text) => { + extractedId = text.split("Care external results ID: ")[1]; + cy.log(`Extracted Care external results ID: ${extractedId}`); + cy.awaitUrl("/patients"); + patientPage.createPatient(); + patientPage.selectFacility(patientFacility); + patientPage.patientformvisibility(); + patientExternal.clickImportFromExternalResultsButton(); + patientExternal.typeCareExternalResultId(extractedId); + patientExternal.clickImportPatientData(); + }); + // verify the patient is successfully created + patientExternal.verifyExternalPatientName(patientExternalName); }); afterEach(() => { diff --git a/cypress/pageobject/Patient/PatientConsultation.ts b/cypress/pageobject/Patient/PatientConsultation.ts index 8570b2b8e7a..76724d85017 100644 --- a/cypress/pageobject/Patient/PatientConsultation.ts +++ b/cypress/pageobject/Patient/PatientConsultation.ts @@ -17,6 +17,10 @@ export class PatientConsultationPage { }); } + verifyConsultationPatientName(patientName: string) { + cy.get("#patient-name-consultation").should("contain", patientName); + } + fillIllnessHistory(history: string) { cy.wait(5000); cy.get("#history_of_present_illness").scrollIntoView(); @@ -145,9 +149,11 @@ export class PatientConsultationPage { cy.wait("@submitPrescription").its("response.statusCode").should("eq", 201); } - visitEditConsultationPage() { - cy.get("#view_consulation_updates").click(); - cy.get("button").contains("Edit Consultation Details").click(); + clickEditConsultationButton() { + cy.get("#consultation-buttons").scrollIntoView(); + cy.get("#consultation-buttons") + .contains("Edit Consultation Details") + .click(); } setSymptomsDate(date: string) { diff --git a/cypress/pageobject/Patient/PatientCreation.ts b/cypress/pageobject/Patient/PatientCreation.ts index 0cf8abd4afa..07d87e024a1 100644 --- a/cypress/pageobject/Patient/PatientCreation.ts +++ b/cypress/pageobject/Patient/PatientCreation.ts @@ -72,18 +72,6 @@ export class PatientPage { .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(); } @@ -92,48 +80,10 @@ export class PatientPage { 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() @@ -229,55 +179,6 @@ export class PatientPage { }); } - 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 - ); - } - visitUpdatePatientUrl() { cy.visit(patient_url + "/update"); } diff --git a/cypress/pageobject/Patient/PatientExternal.ts b/cypress/pageobject/Patient/PatientExternal.ts new file mode 100644 index 00000000000..138c212a377 --- /dev/null +++ b/cypress/pageobject/Patient/PatientExternal.ts @@ -0,0 +1,28 @@ +class PatientExternal { + verifyExternalListPatientName(patientName: string) { + cy.get("#external-result-table").contains(patientName).click(); + } + + verifyExternalIdVisible() { + cy.get("#patient-external-id").contains("Care external results ID"); + } + + clickImportFromExternalResultsButton() { + cy.get("#import-externalresult-button").click(); + } + + typeCareExternalResultId(externalId) { + cy.get("#care-external-results-id").scrollIntoView(); + cy.get("#care-external-results-id").should("be.visible"); + cy.get("#care-external-results-id").type(externalId); + } + + clickImportPatientData() { + cy.get("#submit-importexternalresult-button").click(); + } + + verifyExternalPatientName(patientName: string) { + cy.get("#name", { timeout: 10000 }).should("have.value", patientName); + } +} +export default PatientExternal; diff --git a/cypress/pageobject/Patient/PatientInsurance.ts b/cypress/pageobject/Patient/PatientInsurance.ts new file mode 100644 index 00000000000..be4c25c5535 --- /dev/null +++ b/cypress/pageobject/Patient/PatientInsurance.ts @@ -0,0 +1,32 @@ +class PatientInsurance { + typePatientInsuranceDetail( + containerId: string, + fieldId: string, + value: string + ) { + cy.get(`#${containerId}`).within(() => { + cy.get(`#${fieldId}`).click().type(value); + }); + } + + clickPatientInsuranceViewDetail() { + cy.get("#insurance-view-details").scrollIntoView(); + cy.get("#insurance-view-details").click(); + } + + clickAddInsruanceDetails() { + cy.get("[data-testid=add-insurance-button]").click(); + } + + 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); + }); + } +} + +export default PatientInsurance; diff --git a/cypress/pageobject/Patient/PatientMedicalHistory.ts b/cypress/pageobject/Patient/PatientMedicalHistory.ts new file mode 100644 index 00000000000..1c9b733f3ba --- /dev/null +++ b/cypress/pageobject/Patient/PatientMedicalHistory.ts @@ -0,0 +1,59 @@ +class PatientMedicalHistory { + typePatientOngoingMedication(ongoingMedication: string) { + cy.get("#ongoing_medication").click().type(ongoingMedication); + } + + typePatientPresentHealth(presentHealth: string) { + cy.get("#present_health").click().type(presentHealth); + } + + typePatientAllergies(allergies: string) { + cy.get("#allergies").click().type(allergies); + } + + typeMedicalHistory(index, text) { + cy.get(`#medical_history_check_${index}`).click(); + cy.get(`#medical_history_${index}`).click().type(text); + } + + clickNoneMedicialHistory() { + cy.get("[name=medical_history_check_1]").scrollIntoView(); + cy.get("[name=medical_history_check_1]").check(); + } + + 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); + }); + } + + verifyNoSymptosPresent(patientSymptoms1: string) { + cy.get("[data-testid=patient-details]").should( + "not.contain", + patientSymptoms1 + ); + } +} + +export default PatientMedicalHistory; diff --git a/cypress/pageobject/Patient/PatientTransfer.ts b/cypress/pageobject/Patient/PatientTransfer.ts new file mode 100644 index 00000000000..293490a8bdd --- /dev/null +++ b/cypress/pageobject/Patient/PatientTransfer.ts @@ -0,0 +1,63 @@ +class PatientTransfer { + clickAdmitPatientRecordButton() { + cy.get("#transfer").click(); + } + + clickTransferPopupContinueButton() { + cy.get("#submit-continue-button").click(); + } + + clickTransferPatientNameList(facilityName: string) { + cy.get("#patient").click(); + cy.get("li[role=option]").contains(facilityName).click(); + } + + clickTransferPatientDob(dateOfBirth: string) { + cy.get("#dateofbirth-transferform").scrollIntoView(); + cy.get("#dateofbirth-transferform").should("be.visible").click(); + cy.get("#date-input").click().type(dateOfBirth); + } + + clickTransferSubmitButton() { + cy.get("#submit-transferpatient").click(); + } + + clickConsultationCancelButton() { + cy.get("#cancel").scrollIntoView(); + cy.get("#cancel").click(); + } + + clickAllowPatientTransferButton() { + cy.get("#patient-allow-transfer").click(); + } + + verifyFacilitySuccessfullMessage() { + cy.get(".pnotify") + .should("exist") + .within(() => { + cy.get(".pnotify-text") + .invoke("text") + .then((text) => { + expect(text.trim()).to.match( + /^Patient Dummy Patient 10 \(Male\) transferred successfully$/i + ); + }); + }); + } + + verifyFacilityErrorMessage() { + cy.get(".pnotify") + .should("exist") + .within(() => { + cy.get(".pnotify-text") + .invoke("text") + .then((text) => { + expect(text).to.match( + /Patient - Patient transfer cannot be completed because the patient has an active consultation in the same facility/ + ); + }); + }); + } +} + +export default PatientTransfer; diff --git a/src/Components/ExternalResult/ResultItem.tsx b/src/Components/ExternalResult/ResultItem.tsx index 47363e02ce1..0954f704176 100644 --- a/src/Components/ExternalResult/ResultItem.tsx +++ b/src/Components/ExternalResult/ResultItem.tsx @@ -77,13 +77,18 @@ export default function ResultItem(props: any) {

- {resultItemData.name} - {resultItemData.age}{" "} - {resultItemData.age_in} | {resultItemData.result} + {resultItemData.name} -{" "} + {resultItemData.age}{" "} + {resultItemData.age_in} |{" "} + {resultItemData.result}

{t("srf_id")}: {resultItemData.srf_id}

-

+

{t("care_external_results_id")}: {resultItemData.id}

{resultItemData.patient_created ? ( diff --git a/src/Components/ExternalResult/ResultList.tsx b/src/Components/ExternalResult/ResultList.tsx index f644c2b54e0..82a49e3a8e3 100644 --- a/src/Components/ExternalResult/ResultList.tsx +++ b/src/Components/ExternalResult/ResultList.tsx @@ -318,7 +318,10 @@ export default function ResultList() { ]} /> -
+
diff --git a/src/Components/Facility/DuplicatePatientDialog.tsx b/src/Components/Facility/DuplicatePatientDialog.tsx index 46eb4e2dd7a..7a36beac685 100644 --- a/src/Components/Facility/DuplicatePatientDialog.tsx +++ b/src/Components/Facility/DuplicatePatientDialog.tsx @@ -119,6 +119,7 @@ const DuplicatePatientDialog = (props: Props) => { label={`Cancel ${isNew ? "Registration" : "Update"}`} /> handleOk(action)} disabled={!action} label="Continue" diff --git a/src/Components/Facility/TransferPatientDialog.tsx b/src/Components/Facility/TransferPatientDialog.tsx index e6133279a9e..259d497f684 100644 --- a/src/Components/Facility/TransferPatientDialog.tsx +++ b/src/Components/Facility/TransferPatientDialog.tsx @@ -175,6 +175,7 @@ const TransferPatientDialog = (props: Props) => {
{
{
)} -
+
{!!consultation?.discharge_date && (
diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx index ce63d5019de..2f18ef36dbb 100644 --- a/src/Components/Patient/PatientRegister.tsx +++ b/src/Components/Patient/PatientRegister.tsx @@ -1126,6 +1126,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { />