From 987f17a14f5fb3fffbd909b85c45fa01ba78f76c Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Sun, 4 Feb 2024 22:59:46 +0530 Subject: [PATCH] Final PR --- .../patient_spec/patient_consultation.cy.ts | 45 ++++++++++++++++--- .../patient_spec/patient_registration.cy.ts | 42 ++++++++++++----- .../pageobject/Patient/PatientConsultation.ts | 12 +++-- cypress/pageobject/Patient/PatientExternal.ts | 28 ++++++++++++ src/Components/ExternalResult/ResultItem.tsx | 11 +++-- src/Components/ExternalResult/ResultList.tsx | 5 ++- src/Components/Patient/PatientInfoCard.tsx | 5 ++- src/Components/Patient/PatientRegister.tsx | 2 + vite.config.ts | 4 +- 9 files changed, 127 insertions(+), 27 deletions(-) create mode 100644 cypress/pageobject/Patient/PatientExternal.ts diff --git a/cypress/e2e/patient_spec/patient_consultation.cy.ts b/cypress/e2e/patient_spec/patient_consultation.cy.ts index 502324cfc38..96aa0412f1f 100644 --- a/cypress/e2e/patient_spec/patient_consultation.cy.ts +++ b/cypress/e2e/patient_spec/patient_consultation.cy.ts @@ -2,11 +2,27 @@ 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"; describe("Patient Creation with consultation", () => { const patientConsultationPage = new PatientConsultationPage(); const loginPage = new LoginPage(); const patientPage = new PatientPage(); + const facilityPage = new FacilityPage(); + 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(); @@ -19,10 +35,25 @@ describe("Patient Creation with consultation", () => { cy.awaitUrl("/patients"); }); - it("Create a patient with consultation in combination OP + Admission + All Fields", () => { - patientPage.interceptFacilities(); - patientPage.visitConsultationPage(); - patientPage.verifyStatusCode(); + 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); + patientPage.clickNoneMedicialHistory(); + patientPage.selectPatientBloodGroup(patientOneBloodGroup); + patientPage.clickCreatePatient(); + patientPage.verifyPatientIsCreated(); patientConsultationPage.fillIllnessHistory("history"); patientConsultationPage.selectConsultationStatus( "Outpatient/Emergency Room" @@ -49,11 +80,13 @@ describe("Patient Creation with consultation", () => { patientConsultationPage.enterDosage("3"); patientConsultationPage.selectDosageFrequency("Twice daily"); patientConsultationPage.submitPrescriptionAndReturn(); + patientConsultationPage.verifyConsultationPatientName(patientOneName); }); it("Edit created consultation to existing patient", () => { - patientPage.visitPatientUrl(); - patientConsultationPage.visitEditConsultationPage(); + // 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"); diff --git a/cypress/e2e/patient_spec/patient_registration.cy.ts b/cypress/e2e/patient_spec/patient_registration.cy.ts index 1f645b16139..490b34b4dc7 100644 --- a/cypress/e2e/patient_spec/patient_registration.cy.ts +++ b/cypress/e2e/patient_spec/patient_registration.cy.ts @@ -7,6 +7,8 @@ import { phone_number, } from "../../pageobject/constants"; import PatientTransfer from "../../pageobject/Patient/PatientTransfer"; +import PatientExternal from "../../pageobject/Patient/PatientExternal"; + const yearOfBirth = "2001"; const calculateAge = () => { @@ -19,7 +21,9 @@ describe("Patient Creation with consultation", () => { const patientPage = new PatientPage(); const facilityPage = new FacilityPage(); const patientTransfer = new PatientTransfer(); + const patientExternal = new PatientExternal(); const age = calculateAge(); + const patientFacility = "Dummy Facility 40"; const patientDateOfBirth = "01012001"; const patientOneName = "Patient With No Consultation"; const patientOneGender = "Male"; @@ -48,6 +52,7 @@ describe("Patient Creation with consultation", () => { const patientTransferPhoneNumber = "9849511866"; const patientTransferFacility = "Dummy Shifting Center"; const patientTransferName = "Dummy Patient 10"; + const patientExternalName = "Patient 20"; before(() => { loginPage.loginAsDisctrictAdmin(); @@ -60,20 +65,10 @@ describe("Patient Creation with consultation", () => { cy.awaitUrl("/patients"); }); - it("Patient Registration using External Result Import", () => { - // copy the patient external ID from external results - patientPage.createPatient(); - patientPage.selectFacility("Dummy Shifting Center"); - patientPage.patientformvisibility(); - // import the result and create a new patient - - // verify the patient is successfully created - }); - 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); @@ -252,6 +247,31 @@ describe("Patient Creation with consultation", () => { patientTransfer.verifyFacilityErrorMessage(); }); + 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(() => { cy.saveLocalStorage(); }); 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/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/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/Patient/PatientInfoCard.tsx b/src/Components/Patient/PatientInfoCard.tsx index a23117a3803..c9d4aac916d 100644 --- a/src/Components/Patient/PatientInfoCard.tsx +++ b/src/Components/Patient/PatientInfoCard.tsx @@ -373,7 +373,10 @@ export default function PatientInfoCard(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) => { />