From 1511f695a627ceba0dd4740014d0550889d3e140 Mon Sep 17 00:00:00 2001 From: JavidSumra Date: Tue, 29 Oct 2024 13:32:17 +0530 Subject: [PATCH 01/15] Add Sample Test Request creation --- .env | 2 +- .../sample_test_spec/SampleTestRequest.cy.ts | 40 +++++++++++ cypress/pageobject/Sample/SampleTestCreate.ts | 70 +++++++++++++++++++ src/components/Patient/PatientHome.tsx | 1 + src/components/Patient/PatientInfoCard.tsx | 2 +- src/components/Patient/SampleTest.tsx | 14 +++- src/components/Patient/SampleTestCard.tsx | 1 + 7 files changed, 126 insertions(+), 4 deletions(-) create mode 100644 cypress/e2e/sample_test_spec/SampleTestRequest.cy.ts create mode 100644 cypress/pageobject/Sample/SampleTestCreate.ts diff --git a/.env b/.env index ebc0ebd5be3..634d2314cea 100644 --- a/.env +++ b/.env @@ -7,7 +7,7 @@ REACT_APP_COVER_IMAGE_ALT=https://cdn.ohc.network/care_logo.svg REACT_PUBLIC_URL=https://care.ohc.network # Care API URL without the /api prefix -REACT_CARE_API_URL=https://careapi.ohc.network +REACT_CARE_API_URL=http://127.0.0.1:9000 # Dev envs ESLINT_NO_DEV_ERRORS=true diff --git a/cypress/e2e/sample_test_spec/SampleTestRequest.cy.ts b/cypress/e2e/sample_test_spec/SampleTestRequest.cy.ts new file mode 100644 index 00000000000..91dd71d08d1 --- /dev/null +++ b/cypress/e2e/sample_test_spec/SampleTestRequest.cy.ts @@ -0,0 +1,40 @@ +import { SampleTestPage } from "pageobject/Sample/SampleTestCreate"; + +describe("Sample Test", () => { + const sampleTestPage = new SampleTestPage(); + const smapleTestType = "BA/ETA", + icmrCategory = "Cat 0", + icmrLabel = "Test Icmr Label"; + + before(() => { + cy.loginByApi("devdistrictadmin", "Coronasafe@123"); + cy.saveLocalStorage(); + }); + + beforeEach(() => { + cy.restoreLocalStorage(); + cy.clearLocalStorage(/filters--.+/); + cy.awaitUrl("/patients"); + }); + + it("request for new sample test", () => { + sampleTestPage.visitPatientDashboardPage(); + sampleTestPage.visitSampleRequestPage(); + + // Filling the form fields + sampleTestPage.selectSampleType(smapleTestType); + sampleTestPage.selectIcmrCategory(icmrCategory); + sampleTestPage.typeIcmrLabel(icmrLabel); + + // Submit Form + sampleTestPage.submitForm(); + + // checking for sample request + sampleTestPage.clickOnNotification(); + sampleTestPage.checkRequestHistory(); + }); + + // it("check smaple request on sample page", () => { + // cy.awaitUrl("/sample") + // }) +}); diff --git a/cypress/pageobject/Sample/SampleTestCreate.ts b/cypress/pageobject/Sample/SampleTestCreate.ts new file mode 100644 index 00000000000..04d5722dc9b --- /dev/null +++ b/cypress/pageobject/Sample/SampleTestCreate.ts @@ -0,0 +1,70 @@ +export class SampleTestPage { + sampleTestReportHistory = 0; + patientName = ""; // to search patient in sample page + + visitPatientDashboardPage() { + cy.wait(1000); + cy.get(".patient-stable-ring").should("be.visible"); + cy.get(".patient-stable-ring").first().click(); + cy.get("#patient-name") + .invoke("text") + .then((patientName) => { + // Trim any excess whitespace + this.patientName = patientName.trim(); + }); + cy.get("#patient-details").should("be.visible"); + cy.get("#patient-details").click(); + } + + visitSampleRequestPage() { + cy.get("body").then(($body) => { + if ($body.find("#sample-test-history").length > 0) { + cy.get("#sample-test-history") + .its("length") + .then((count) => { + this.sampleTestReportHistory = count; + }); + } else { + // Element does not exist, set to 0 + this.sampleTestReportHistory = 0; + } + }); + + cy.get("#sample-request-btn").should("be.visible"); + cy.get("#sample-request-btn").click(); + } + + selectSampleType(option: string) { + cy.get("#sample-type").should("be.visible"); + cy.get("#sample-type").click(); + cy.get("[role='option']").contains(option).click(); + } + + selectIcmrCategory(option: string) { + cy.get("#icmr-category").should("be.visible"); + cy.get("#icmr-category").click(); + cy.get("[role='option']").contains(option).click(); + } + + typeIcmrLabel(label: string) { + cy.get("#icmr-label").should("be.visible"); + cy.get("#icmr-label").type(label); + } + + submitForm() { + cy.get("#sample-test-submit-btn").should("be.visible"); + cy.get("#sample-test-submit-btn").click(); + } + + clickOnNotification() { + cy.get(".pnotify-container").should("be.visible"); + cy.get(".pnotify-container").click(); + } + + checkRequestHistory() { + cy.get("#sample-test-history").should( + "have.length", + this.sampleTestReportHistory + 1, + ); + } +} diff --git a/src/components/Patient/PatientHome.tsx b/src/components/Patient/PatientHome.tsx index d95c6d1df21..b172272b2e1 100644 --- a/src/components/Patient/PatientHome.tsx +++ b/src/components/Patient/PatientHome.tsx @@ -1370,6 +1370,7 @@ export const PatientHome = (props: any) => { ) } authorizeFor={NonReadOnlyUsers} + id="sample-request-btn" > diff --git a/src/components/Patient/PatientInfoCard.tsx b/src/components/Patient/PatientInfoCard.tsx index bdc8b0e672d..9372a2dbb41 100644 --- a/src/components/Patient/PatientInfoCard.tsx +++ b/src/components/Patient/PatientInfoCard.tsx @@ -253,7 +253,7 @@ export default function PatientInfoCard(props: { className="mb-2 flex flex-col justify-center text-xl font-semibold capitalize lg:hidden" id="patient-name-consultation" > - {patient.name} + {patient.name}
{formatPatientAge(patient, true)} • {patient.gender}
diff --git a/src/components/Patient/SampleTest.tsx b/src/components/Patient/SampleTest.tsx index 4c158ff7189..6eea1b52f89 100644 --- a/src/components/Patient/SampleTest.tsx +++ b/src/components/Patient/SampleTest.tsx @@ -212,6 +212,7 @@ export const SampleTest = ({ facilityId, patientId }: any) => { options={SAMPLE_TYPE_CHOICES} optionLabel={(option) => option.text} optionValue={(option) => option.id} + id="sample-type" /> {state.form.sample_type === "OTHER TYPE" && ( @@ -226,6 +227,7 @@ export const SampleTest = ({ facilityId, patientId }: any) => { options={ICMR_CATEGORY} optionLabel={(option) => option} optionValue={(option) => option} + id="icmr-category" />

@@ -251,7 +253,11 @@ export const SampleTest = ({ facilityId, patientId }: any) => {

- +
Testing Facility { />
goBack()} /> - +
diff --git a/src/components/Patient/SampleTestCard.tsx b/src/components/Patient/SampleTestCard.tsx index ad54850ea10..44e67276ede 100644 --- a/src/components/Patient/SampleTestCard.tsx +++ b/src/components/Patient/SampleTestCard.tsx @@ -76,6 +76,7 @@ export const SampleTestCard = (props: SampleDetailsProps) => { return (
Date: Fri, 1 Nov 2024 15:16:21 +0530 Subject: [PATCH 02/15] Add TestSuit to request for sample test --- .../sample_test_spec/SampleTestRequest.cy.ts | 22 +++--- cypress/pageobject/Sample/SampleTestCreate.ts | 67 ++++++++++--------- src/components/Patient/SampleViewAdmin.tsx | 2 + 3 files changed, 49 insertions(+), 42 deletions(-) diff --git a/cypress/e2e/sample_test_spec/SampleTestRequest.cy.ts b/cypress/e2e/sample_test_spec/SampleTestRequest.cy.ts index 91dd71d08d1..0fbaae7d971 100644 --- a/cypress/e2e/sample_test_spec/SampleTestRequest.cy.ts +++ b/cypress/e2e/sample_test_spec/SampleTestRequest.cy.ts @@ -2,7 +2,7 @@ import { SampleTestPage } from "pageobject/Sample/SampleTestCreate"; describe("Sample Test", () => { const sampleTestPage = new SampleTestPage(); - const smapleTestType = "BA/ETA", + const sampleTestType = "BA/ETA", icmrCategory = "Cat 0", icmrLabel = "Test Icmr Label"; @@ -14,27 +14,29 @@ describe("Sample Test", () => { beforeEach(() => { cy.restoreLocalStorage(); cy.clearLocalStorage(/filters--.+/); - cy.awaitUrl("/patients"); }); - it("request for new sample test", () => { + it("should request a new sample test", () => { + sampleTestPage.visitPatientPage(); sampleTestPage.visitPatientDashboardPage(); sampleTestPage.visitSampleRequestPage(); - // Filling the form fields - sampleTestPage.selectSampleType(smapleTestType); + // Fill form fields + sampleTestPage.selectSampleType(sampleTestType); sampleTestPage.selectIcmrCategory(icmrCategory); sampleTestPage.typeIcmrLabel(icmrLabel); - // Submit Form + // Submit the form sampleTestPage.submitForm(); - // checking for sample request + // Check for sample request notification and history sampleTestPage.clickOnNotification(); sampleTestPage.checkRequestHistory(); }); - // it("check smaple request on sample page", () => { - // cy.awaitUrl("/sample") - // }) + it("should verify sample request on sample page", () => { + sampleTestPage.visitSamplePage(); + sampleTestPage.searchPatientSample(sampleTestPage.patientName); + sampleTestPage.patientSampleMustExist(); + }); }); diff --git a/cypress/pageobject/Sample/SampleTestCreate.ts b/cypress/pageobject/Sample/SampleTestCreate.ts index 04d5722dc9b..8e59efdbed8 100644 --- a/cypress/pageobject/Sample/SampleTestCreate.ts +++ b/cypress/pageobject/Sample/SampleTestCreate.ts @@ -1,70 +1,73 @@ export class SampleTestPage { sampleTestReportHistory = 0; - patientName = ""; // to search patient in sample page + patientName = ""; // to search for patient in sample page + + visitPatientPage() { + cy.awaitUrl("/patients"); + } visitPatientDashboardPage() { - cy.wait(1000); - cy.get(".patient-stable-ring").should("be.visible"); - cy.get(".patient-stable-ring").first().click(); + cy.get(".patient-stable-ring").first().scrollIntoView(); + cy.get(".patient-stable-ring").should("be.visible").first().click(); cy.get("#patient-name") .invoke("text") .then((patientName) => { - // Trim any excess whitespace this.patientName = patientName.trim(); }); - cy.get("#patient-details").should("be.visible"); - cy.get("#patient-details").click(); + cy.get("#patient-details").should("be.visible").click(); } visitSampleRequestPage() { - cy.get("body").then(($body) => { - if ($body.find("#sample-test-history").length > 0) { - cy.get("#sample-test-history") - .its("length") - .then((count) => { - this.sampleTestReportHistory = count; - }); - } else { - // Element does not exist, set to 0 - this.sampleTestReportHistory = 0; - } - }); - - cy.get("#sample-request-btn").should("be.visible"); - cy.get("#sample-request-btn").click(); + cy.get("#sample-test-history").scrollIntoView(); + cy.get("#sample-test-history") + .its("length") + .then((count) => { + this.sampleTestReportHistory = count || 0; + }); + cy.get("#sample-request-btn").scrollIntoView(); + cy.get("#sample-request-btn").should("be.visible").click(); } selectSampleType(option: string) { - cy.get("#sample-type").should("be.visible"); - cy.get("#sample-type").click(); + cy.get("#sample-type").should("be.visible").click(); cy.get("[role='option']").contains(option).click(); } selectIcmrCategory(option: string) { - cy.get("#icmr-category").should("be.visible"); - cy.get("#icmr-category").click(); + cy.get("#icmr-category").should("be.visible").click(); cy.get("[role='option']").contains(option).click(); } typeIcmrLabel(label: string) { - cy.get("#icmr-label").should("be.visible"); - cy.get("#icmr-label").type(label); + cy.get("#icmr-label").should("be.visible").type(label); } submitForm() { - cy.get("#sample-test-submit-btn").should("be.visible"); - cy.get("#sample-test-submit-btn").click(); + cy.get("#sample-test-submit-btn").scrollIntoView(); + cy.get("#sample-test-submit-btn").should("be.visible").click(); } clickOnNotification() { - cy.get(".pnotify-container").should("be.visible"); - cy.get(".pnotify-container").click(); + cy.get(".pnotify-container").should("be.visible").click(); } checkRequestHistory() { + cy.get("#sample-test-history").scrollIntoView(); cy.get("#sample-test-history").should( "have.length", this.sampleTestReportHistory + 1, ); } + + visitSamplePage() { + cy.awaitUrl("/sample"); + } + + searchPatientSample() { + cy.get("#search_patient_name").should("be.visible").type(this.patientName); + } + + patientSampleMustExist() { + cy.get("#sample-card").should("be.visible"); + } } diff --git a/src/components/Patient/SampleViewAdmin.tsx b/src/components/Patient/SampleViewAdmin.tsx index 5b84059d6bc..c5964b9d296 100644 --- a/src/components/Patient/SampleViewAdmin.tsx +++ b/src/components/Patient/SampleViewAdmin.tsx @@ -146,6 +146,7 @@ export default function SampleViewAdmin() { ? "border-primary-700 bg-primary-100" : "bg-white" }`} + id="sample-card" >
@@ -345,6 +346,7 @@ export default function SampleViewAdmin() {
updateQuery({ [e.name]: e.value })} placeholder="Search patient" From c37f2523ab74015786d04f3548ff2d6bfe313223 Mon Sep 17 00:00:00 2001 From: JavidSumra Date: Fri, 1 Nov 2024 15:23:41 +0530 Subject: [PATCH 03/15] Undo the changes in .env file --- .env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env b/.env index 634d2314cea..ebc0ebd5be3 100644 --- a/.env +++ b/.env @@ -7,7 +7,7 @@ REACT_APP_COVER_IMAGE_ALT=https://cdn.ohc.network/care_logo.svg REACT_PUBLIC_URL=https://care.ohc.network # Care API URL without the /api prefix -REACT_CARE_API_URL=http://127.0.0.1:9000 +REACT_CARE_API_URL=https://careapi.ohc.network # Dev envs ESLINT_NO_DEV_ERRORS=true From 3b731aa8437e9f3c3e799892cb67ef4e90744770 Mon Sep 17 00:00:00 2001 From: JavidSumra Date: Fri, 1 Nov 2024 15:40:33 +0530 Subject: [PATCH 04/15] fix request sample test for button id if exist --- cypress/pageobject/Sample/SampleTestCreate.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/cypress/pageobject/Sample/SampleTestCreate.ts b/cypress/pageobject/Sample/SampleTestCreate.ts index 8e59efdbed8..e7fe05674bd 100644 --- a/cypress/pageobject/Sample/SampleTestCreate.ts +++ b/cypress/pageobject/Sample/SampleTestCreate.ts @@ -18,12 +18,18 @@ export class SampleTestPage { } visitSampleRequestPage() { - cy.get("#sample-test-history").scrollIntoView(); - cy.get("#sample-test-history") - .its("length") - .then((count) => { - this.sampleTestReportHistory = count || 0; - }); + cy.get("body").then(($body) => { + if ($body.find("#sample-test-history").length > 0) { + cy.get("#sample-test-history") + .its("length") + .then((count) => { + this.sampleTestReportHistory = count; + }); + } else { + // Set to 0 if the element does not exist + this.sampleTestReportHistory = 0; + } + }); cy.get("#sample-request-btn").scrollIntoView(); cy.get("#sample-request-btn").should("be.visible").click(); } From e1ffd145a180620214215241f59c48b8a5d87031 Mon Sep 17 00:00:00 2001 From: JavidSumra Date: Tue, 5 Nov 2024 16:43:01 +0530 Subject: [PATCH 05/15] requested changes update --- .../sample_test_spec/SampleTestRequest.cy.ts | 77 +++++++--- cypress/pageobject/Sample/SampleTestCreate.ts | 140 +++++++++++------- src/components/Patient/PatientInfoCard.tsx | 2 +- src/components/Patient/SampleDetails.tsx | 16 +- src/components/Patient/SampleTest.tsx | 19 ++- src/components/Patient/SampleTestCard.tsx | 20 ++- src/components/Patient/SampleViewAdmin.tsx | 7 +- 7 files changed, 196 insertions(+), 85 deletions(-) diff --git a/cypress/e2e/sample_test_spec/SampleTestRequest.cy.ts b/cypress/e2e/sample_test_spec/SampleTestRequest.cy.ts index 0fbaae7d971..83c4ec9623f 100644 --- a/cypress/e2e/sample_test_spec/SampleTestRequest.cy.ts +++ b/cypress/e2e/sample_test_spec/SampleTestRequest.cy.ts @@ -1,13 +1,26 @@ import { SampleTestPage } from "pageobject/Sample/SampleTestCreate"; +import { PatientPage } from "pageobject/Patient/PatientCreation"; +import LoginPage from "pageobject/Login/LoginPage"; describe("Sample Test", () => { const sampleTestPage = new SampleTestPage(); - const sampleTestType = "BA/ETA", - icmrCategory = "Cat 0", - icmrLabel = "Test Icmr Label"; + const patientPage = new PatientPage(); + const loginPage = new LoginPage(); + + const patientName = "Dummy Patient 11"; + const sampleTestType = "BA/ETA"; + const icmrCategory = "Cat 0"; + const icmrLabel = "Test Icmr Label"; + const doctorName = "Dr. John Doe"; + const atypicalDetails = "Patient showing unusual symptoms"; + const diagnosis = "Suspected respiratory infection"; + const etiologyIdentified = "Bacterial infection suspected"; + const differentialDiagnosis = "Possibly a viral infection"; + const fastTrackReason = + "The patient has a high risk of complications and requires immediate testing."; before(() => { - cy.loginByApi("devdistrictadmin", "Coronasafe@123"); + loginPage.loginAsDisctrictAdmin(); cy.saveLocalStorage(); }); @@ -17,26 +30,54 @@ describe("Sample Test", () => { }); it("should request a new sample test", () => { - sampleTestPage.visitPatientPage(); - sampleTestPage.visitPatientDashboardPage(); + // Ensure patient list API is loaded before proceeding + cy.awaitUrl("/patients"); + patientPage.visitPatient(patientName); + cy.verifyAndClickElement("#patient-details", "Patient Details"); + sampleTestPage.interceptPatientDetailsAPI(); + sampleTestPage.verifyPatientDetailsResponse(); + + // Ensure sample request API is loaded sampleTestPage.visitSampleRequestPage(); - // Fill form fields + // Fill form fields using helper functions sampleTestPage.selectSampleType(sampleTestType); sampleTestPage.selectIcmrCategory(icmrCategory); - sampleTestPage.typeIcmrLabel(icmrLabel); + sampleTestPage.fillIcmrLabel(icmrLabel); + sampleTestPage.fillFastTrackReason(fastTrackReason); + sampleTestPage.fillDoctorName(doctorName); + sampleTestPage.fillAtypicalPresentation(atypicalDetails); + sampleTestPage.fillDiagnosis(diagnosis); + sampleTestPage.fillEtiology(etiologyIdentified); + sampleTestPage.fillDiffDiagnosis(differentialDiagnosis); + sampleTestPage.checkHasSari(); + sampleTestPage.checkHasAri(); + sampleTestPage.checkIsUnusualCourse(); - // Submit the form - sampleTestPage.submitForm(); + // Submit the form and verify notification + cy.submitButton("Confirm your request to send sample for testing"); + cy.verifyNotification("Sample test created successfully"); - // Check for sample request notification and history - sampleTestPage.clickOnNotification(); - sampleTestPage.checkRequestHistory(); - }); + // Check the updated request history + sampleTestPage.interceptSampleTestReq(); + sampleTestPage.verifySampleTestReq(); + sampleTestPage.checkRequestHistory(fastTrackReason); + + // Ensure sample page API is loaded before proceeding + cy.awaitUrl("/sample"); - it("should verify sample request on sample page", () => { - sampleTestPage.visitSamplePage(); - sampleTestPage.searchPatientSample(sampleTestPage.patientName); - sampleTestPage.patientSampleMustExist(); + sampleTestPage.searchPatientSample(patientName); + sampleTestPage.interceptGetSampleTestReq(); + sampleTestPage.verifyGetSampleTestReq(); + sampleTestPage.verifyPatientName(patientName); + sampleTestPage.clickOnSampleDetailsBtn(); + sampleTestPage.verifyGetSampleTestReq(); + sampleTestPage.verifyPatientTestDetails( + patientName, + fastTrackReason, + diagnosis, + differentialDiagnosis, + etiologyIdentified, + ); }); }); diff --git a/cypress/pageobject/Sample/SampleTestCreate.ts b/cypress/pageobject/Sample/SampleTestCreate.ts index e7fe05674bd..98cfb7d8fa9 100644 --- a/cypress/pageobject/Sample/SampleTestCreate.ts +++ b/cypress/pageobject/Sample/SampleTestCreate.ts @@ -1,79 +1,115 @@ export class SampleTestPage { - sampleTestReportHistory = 0; - patientName = ""; // to search for patient in sample page + visitSampleRequestPage() { + cy.verifyAndClickElement("#sample-request-btn", "Request Sample Test"); + } - visitPatientPage() { - cy.awaitUrl("/patients"); + selectSampleType(option: string) { + cy.clickAndSelectOption("#sample-type", option); } - visitPatientDashboardPage() { - cy.get(".patient-stable-ring").first().scrollIntoView(); - cy.get(".patient-stable-ring").should("be.visible").first().click(); - cy.get("#patient-name") - .invoke("text") - .then((patientName) => { - this.patientName = patientName.trim(); - }); - cy.get("#patient-details").should("be.visible").click(); + selectIcmrCategory(option: string) { + cy.clickAndSelectOption("#icmr-category", option); } - visitSampleRequestPage() { - cy.get("body").then(($body) => { - if ($body.find("#sample-test-history").length > 0) { - cy.get("#sample-test-history") - .its("length") - .then((count) => { - this.sampleTestReportHistory = count; - }); - } else { - // Set to 0 if the element does not exist - this.sampleTestReportHistory = 0; - } - }); - cy.get("#sample-request-btn").scrollIntoView(); - cy.get("#sample-request-btn").should("be.visible").click(); + fillIcmrLabel(label: string) { + cy.get("#icmr-label").should("be.visible").type(label); } - selectSampleType(option: string) { - cy.get("#sample-type").should("be.visible").click(); - cy.get("[role='option']").contains(option).click(); + fillFastTrackReason(value: string) { + cy.get("#is_fast_track").should("be.visible").check(); + cy.get("#fast_track").should("be.visible").type(value); } - selectIcmrCategory(option: string) { - cy.get("#icmr-category").should("be.visible").click(); - cy.get("[role='option']").contains(option).click(); + fillDoctorName(value: string) { + cy.get("#doctor_name").should("be.visible").type(value); } - typeIcmrLabel(label: string) { - cy.get("#icmr-label").should("be.visible").type(label); + fillAtypicalPresentation(value: string) { + cy.get("#is_atypical_presentation").should("be.visible").check(); + cy.get("#atypical_presentation").should("be.visible").type(value); + } + + fillDiagnosis(value: string) { + cy.get("#diagnosis").should("be.visible").type(value); + } + + fillEtiology(value: string) { + cy.get("#etiology_identified").should("be.visible").type(value); + } + + fillDiffDiagnosis(value: string) { + cy.get("#diff_diagnosis").should("be.visible").type(value); + } + + checkHasSari() { + cy.get("#has_sari").should("be.visible").check(); + } + + checkHasAri() { + cy.get("#has_ari").should("be.visible").check(); + } + + checkIsUnusualCourse() { + cy.get("#is_unusual_course").should("be.visible").check(); + } + + checkRequestHistory(fastTrack: string) { + cy.verifyContentPresence("#sample-test-status", ["Request Submitted"]); + cy.verifyContentPresence("#sample-test-type", ["ba/eta"]); + cy.verifyContentPresence("#sample-test-fast-track", [fastTrack]); + cy.verifyContentPresence("#sample-test-result", ["Awaiting"]); + } + + searchPatientSample(patientName: string) { + cy.get("#search_patient_name").should("be.visible").type(patientName); + } + + verifyPatientName(patientName: string) { + cy.verifyContentPresence("#sample-test-patient-name", [patientName]); + } + + clickOnSampleDetailsBtn() { + cy.get("#sample-details-btn").should("be.visible").first().click(); + } + + verifyPatientTestDetails( + patientName: string, + fastTrackReason: string, + diagnosis: string, + differentialDiagnosis: string, + etiologyIdentified: string, + ) { + cy.verifyContentPresence("#patient_name", [patientName]); + cy.verifyContentPresence("#fast_track_reason", [fastTrackReason]); + cy.verifyContentPresence("#doctor_name", ["Dr John Doe"]); + cy.verifyContentPresence("#diagnosis", [diagnosis]); + cy.verifyContentPresence("#diff_diagnosis", [differentialDiagnosis]); + cy.verifyContentPresence("#etiology_identified", [etiologyIdentified]); } - submitForm() { - cy.get("#sample-test-submit-btn").scrollIntoView(); - cy.get("#sample-test-submit-btn").should("be.visible").click(); + interceptPatientDetailsAPI() { + cy.intercept("GET", "**/api/v1/patient/**").as("patientDetails"); } - clickOnNotification() { - cy.get(".pnotify-container").should("be.visible").click(); + verifyPatientDetailsResponse() { + cy.wait("@patientDetails").its("response.statusCode").should("eq", 200); } - checkRequestHistory() { - cy.get("#sample-test-history").scrollIntoView(); - cy.get("#sample-test-history").should( - "have.length", - this.sampleTestReportHistory + 1, + interceptSampleTestReq() { + cy.intercept("GET", "**/api/v1/patient/*/test_sample/**").as( + "sampleDetails", ); } - visitSamplePage() { - cy.awaitUrl("/sample"); + verifySampleTestReq() { + cy.wait("@sampleDetails").its("response.statusCode").should("eq", 200); } - searchPatientSample() { - cy.get("#search_patient_name").should("be.visible").type(this.patientName); + interceptGetSampleTestReq() { + cy.intercept("GET", "**/api/v1/test_sample/**").as("getSampleTestReq"); } - patientSampleMustExist() { - cy.get("#sample-card").should("be.visible"); + verifyGetSampleTestReq() { + cy.wait("@getSampleTestReq").its("response.statusCode").should("eq", 200); } } diff --git a/src/components/Patient/PatientInfoCard.tsx b/src/components/Patient/PatientInfoCard.tsx index b62546cb9af..f5bae4aba54 100644 --- a/src/components/Patient/PatientInfoCard.tsx +++ b/src/components/Patient/PatientInfoCard.tsx @@ -255,7 +255,7 @@ export default function PatientInfoCard(props: { className="mb-2 flex flex-col justify-center text-xl font-semibold capitalize lg:hidden" id="patient-name-consultation" > - {patient.name} + {patient.name}
{formatPatientAge(patient, true)} • {patient.gender}
diff --git a/src/components/Patient/SampleDetails.tsx b/src/components/Patient/SampleDetails.tsx index d74b83dff67..503bad231d5 100644 --- a/src/components/Patient/SampleDetails.tsx +++ b/src/components/Patient/SampleDetails.tsx @@ -299,7 +299,7 @@ export const SampleDetails = ({ id }: DetailRoute) => {
Patient: - {sampleDetails?.patient_name} + {sampleDetails?.patient_name}
{sampleDetails?.facility_object && (
@@ -324,7 +324,7 @@ export const SampleDetails = ({ id }: DetailRoute) => { Fast track testing reason:{" "} - {sampleDetails.fast_track} + {sampleDetails.fast_track}
)} {sampleDetails?.doctor_name && ( @@ -332,13 +332,15 @@ export const SampleDetails = ({ id }: DetailRoute) => { Doctor's Name:{" "} - {startCase(camelCase(sampleDetails.doctor_name))} + + {startCase(camelCase(sampleDetails.doctor_name))} +
)} {sampleDetails?.diagnosis && (
Diagnosis: - {sampleDetails.diagnosis} + {sampleDetails.diagnosis}
)} {sampleDetails?.diff_diagnosis && ( @@ -346,7 +348,7 @@ export const SampleDetails = ({ id }: DetailRoute) => { Differential diagnosis:{" "} - {sampleDetails?.diff_diagnosis} + {sampleDetails?.diff_diagnosis}
)} {sampleDetails?.etiology_identified && ( @@ -354,7 +356,9 @@ export const SampleDetails = ({ id }: DetailRoute) => { Etiology identified:{" "} - {sampleDetails.etiology_identified} + + {sampleDetails.etiology_identified} +
)}
diff --git a/src/components/Patient/SampleTest.tsx b/src/components/Patient/SampleTest.tsx index 6eea1b52f89..986a76a24f4 100644 --- a/src/components/Patient/SampleTest.tsx +++ b/src/components/Patient/SampleTest.tsx @@ -276,22 +276,29 @@ export const SampleTest = ({ facilityId, patientId }: any) => { />
{state.form.isFastTrack && ( )} - + {state.form.is_atypical_presentation && (
{ />
)} - +
diff --git a/src/components/Patient/SampleTestCard.tsx b/src/components/Patient/SampleTestCard.tsx index 2ea90b4d941..195645a76b8 100644 --- a/src/components/Patient/SampleTestCard.tsx +++ b/src/components/Patient/SampleTestCard.tsx @@ -98,7 +98,10 @@ export const SampleTestCard = (props: SampleDetailsProps) => {
Status{" "}
-
+
{startCase(camelCase(itemData.status))}
@@ -108,7 +111,10 @@ export const SampleTestCard = (props: SampleDetailsProps) => {
Sample Type{" "}
-
+
{(itemData.sample_type !== "OTHER TYPE" ? itemData.sample_type : itemData.sample_type_other @@ -122,7 +128,10 @@ export const SampleTestCard = (props: SampleDetailsProps) => {
Fast-Track{" "}
-
+
{itemData.fast_track}
@@ -133,7 +142,10 @@ export const SampleTestCard = (props: SampleDetailsProps) => {
Result{" "}
-
+
{startCase(camelCase(itemData.result))}
diff --git a/src/components/Patient/SampleViewAdmin.tsx b/src/components/Patient/SampleViewAdmin.tsx index c5964b9d296..9b4da9f258f 100644 --- a/src/components/Patient/SampleViewAdmin.tsx +++ b/src/components/Patient/SampleViewAdmin.tsx @@ -146,12 +146,14 @@ export default function SampleViewAdmin() { ? "border-primary-700 bg-primary-100" : "bg-white" }`} - id="sample-card" >
-
+
{item.patient_name}
@@ -270,6 +272,7 @@ export default function SampleViewAdmin() { )}