Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Cypress Test Suite for Sample Test Request Workflow #8977

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions cypress/e2e/sample_test_spec/SampleTestRequest.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
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 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(() => {
loginPage.loginAsDisctrictAdmin();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix the typo in method name loginAsDisctrictAdmin.

The method name loginAsDisctrictAdmin contains a typo. It should be loginAsDistrictAdmin.

Apply this diff to correct the typo:

- loginPage.loginAsDisctrictAdmin();
+ loginPage.loginAsDistrictAdmin();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
loginPage.loginAsDisctrictAdmin();
loginPage.loginAsDistrictAdmin();

cy.saveLocalStorage();
});

beforeEach(() => {
cy.restoreLocalStorage();
cy.clearLocalStorage(/filters--.+/);
});

it("should request a new sample test", () => {
// Ensure patient list API is loaded before proceeding
cy.awaitUrl("/patients");
patientPage.visitPatient(patientName);
cy.verifyAndClickElement("#patient-details", "Patient Details");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cy.verifyAndClickElement("#patient-details", "Patient Details");
cy.verifyAndClickElement("#patient-details", "Patient Details");
  • reusable the clickPatientDetails() function in the PatientConsultation.ts

sampleTestPage.interceptPatientDetailsAPI();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sampleTestPage.interceptPatientDetailsAPI();
sampleTestPage.interceptPatientDetailsAPI();
  • what are you verifying here, in between the intercept trigger and response verification, there is no action been executed

sampleTestPage.verifyPatientDetailsResponse();

// Ensure sample request API is loaded
sampleTestPage.visitSampleRequestPage();
Copy link
Member

@nihal467 nihal467 Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • before this line, reuse the function to click patient details function
  • after that only add this line, where you are clicking the request sample request page button
  • make sure once the sample request page is loaded, add a cy.intercept and verify the API response to ensure the page is fully loaded before your next line of test is executed

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add API intercept to ensure the sample request page has fully loaded.

To ensure that the sample request page is fully loaded before interacting with it, consider adding a cy.intercept for the sample request API and waiting for its response.

Apply this diff to implement the intercept:

// Ensure sample request API is loaded
+ sampleTestPage.interceptSampleRequestAPI();
  sampleTestPage.visitSampleRequestPage();
+ sampleTestPage.waitForSampleRequestResponse();

If these methods are not available, you can use:

// Ensure sample request API is loaded
+ cy.intercept('GET', '/api/v1/sample/*').as('getSampleRequest');
  sampleTestPage.visitSampleRequestPage();
+ cy.wait('@getSampleRequest');

Committable suggestion skipped: line range outside the PR's diff.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like the ai review suggested, there is API verification is missing


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • As mentioned in the last review to remove unused line, why are you still keeping the space

// Fill form fields using helper functions
sampleTestPage.selectSampleType(sampleTestType);
sampleTestPage.selectIcmrCategory(icmrCategory);
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();

Copy link
Member

@nihal467 nihal467 Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
  • remove unwanted spaces
  • input values to all the fields in the form not only the mandatory columns

// Submit the form and verify notification
cy.submitButton("Confirm your request to send sample for testing");
cy.verifyNotification("Sample test created successfully");

// Check the updated request history
sampleTestPage.interceptSampleTestReq();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sampleTestPage.interceptSampleTestReq();
sampleTestPage.interceptSampleTestReq();
  • as mention on above comment, there is no action after the intercept is triggered, make necessary changes, personally understand why intercept are being used before implementing it

sampleTestPage.verifySampleTestReq();
sampleTestPage.checkRequestHistory(fastTrackReason);

// Ensure sample page API is loaded before proceeding
cy.awaitUrl("/sample");

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add API intercept to ensure the sample page data is loaded before proceeding.

To make sure that the sample page data is fully loaded before performing actions like searching, add a cy.intercept and wait for the response.

Apply this diff to include the intercept:

// Ensure sample page API is loaded before proceeding
+ cy.intercept('GET', '/api/v1/sample/*').as('getSamples');
  cy.awaitUrl("/sample");
+ cy.wait('@getSamples');
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
cy.awaitUrl("/sample");
// Ensure sample page API is loaded before proceeding
cy.intercept('GET', '/api/v1/sample/*').as('getSamples');
cy.awaitUrl("/sample");
cy.wait('@getSamples');

sampleTestPage.searchPatientSample(patientName);
sampleTestPage.interceptGetSampleTestReq();
sampleTestPage.verifyGetSampleTestReq();
sampleTestPage.verifyPatientName(patientName);
sampleTestPage.clickOnSampleDetailsBtn();
sampleTestPage.verifyGetSampleTestReq();
sampleTestPage.verifyPatientTestDetails(
patientName,
fastTrackReason,
diagnosis,
differentialDiagnosis,
etiologyIdentified,
);
});
});
115 changes: 115 additions & 0 deletions cypress/pageobject/Sample/SampleTestCreate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
export class SampleTestPage {
visitSampleRequestPage() {
cy.verifyAndClickElement("#sample-request-btn", "Request Sample Test");
}

selectSampleType(option: string) {
cy.clickAndSelectOption("#sample-type", option);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add input validation for parameters in interaction methods

To enhance robustness, consider adding input validation to ensure that the option parameter is defined before using it in selectSampleType.

Apply this diff to add input validation:

  selectSampleType(option: string) {
+   if (!option) {
+     throw new Error('Option is required for selectSampleType');
+   }
    cy.clickAndSelectOption("#sample-type", option);
  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
selectSampleType(option: string) {
cy.clickAndSelectOption("#sample-type", option);
}
selectSampleType(option: string) {
if (!option) {
throw new Error('Option is required for selectSampleType');
}
cy.clickAndSelectOption("#sample-type", option);
}


selectIcmrCategory(option: string) {
cy.clickAndSelectOption("#icmr-category", option);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add input validation for parameters in interaction methods

Similarly, validate the option parameter in selectIcmrCategory to prevent potential runtime errors.

Apply this diff:

  selectIcmrCategory(option: string) {
+   if (!option) {
+     throw new Error('Option is required for selectIcmrCategory');
+   }
    cy.clickAndSelectOption("#icmr-category", option);
  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
selectIcmrCategory(option: string) {
cy.clickAndSelectOption("#icmr-category", option);
}
selectIcmrCategory(option: string) {
if (!option) {
throw new Error('Option is required for selectIcmrCategory');
}
cy.clickAndSelectOption("#icmr-category", option);
}


fillIcmrLabel(label: string) {
cy.get("#icmr-label").should("be.visible").type(label);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Validate input parameter before using in fillIcmrLabel

Ensure the label parameter is not empty to avoid unexpected behavior.

Apply this diff:

  fillIcmrLabel(label: string) {
+   if (!label) {
+     throw new Error('Label is required for fillIcmrLabel');
+   }
    cy.get("#icmr-label").should("be.visible").type(label);
  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fillIcmrLabel(label: string) {
cy.get("#icmr-label").should("be.visible").type(label);
}
fillIcmrLabel(label: string) {
if (!label) {
throw new Error('Label is required for fillIcmrLabel');
}
cy.get("#icmr-label").should("be.visible").type(label);
}


fillFastTrackReason(value: string) {
cy.get("#is_fast_track").should("be.visible").check();
cy.get("#fast_track").should("be.visible").type(value);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add input validation to fillFastTrackReason

Validate the value parameter to ensure the method functions correctly.

Apply this diff:

  fillFastTrackReason(value: string) {
+   if (!value) {
+     throw new Error('Value is required for fillFastTrackReason');
+   }
    cy.get("#is_fast_track").should("be.visible").check();
    cy.get("#fast_track").should("be.visible").type(value);
  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fillFastTrackReason(value: string) {
cy.get("#is_fast_track").should("be.visible").check();
cy.get("#fast_track").should("be.visible").type(value);
}
fillFastTrackReason(value: string) {
if (!value) {
throw new Error('Value is required for fillFastTrackReason');
}
cy.get("#is_fast_track").should("be.visible").check();
cy.get("#fast_track").should("be.visible").type(value);
}


fillDoctorName(value: string) {
cy.get("#doctor_name").should("be.visible").type(value);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Validate input in fillDoctorName

To prevent errors, check that value is provided before typing.

Apply this diff:

  fillDoctorName(value: string) {
+   if (!value) {
+     throw new Error('Doctor name is required for fillDoctorName');
+   }
    cy.get("#doctor_name").should("be.visible").type(value);
  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fillDoctorName(value: string) {
cy.get("#doctor_name").should("be.visible").type(value);
}
fillDoctorName(value: string) {
if (!value) {
throw new Error('Doctor name is required for fillDoctorName');
}
cy.get("#doctor_name").should("be.visible").type(value);
}


fillAtypicalPresentation(value: string) {
cy.get("#is_atypical_presentation").should("be.visible").check();
cy.get("#atypical_presentation").should("be.visible").type(value);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add parameter validation in fillAtypicalPresentation

Ensure value is defined to avoid issues during form filling.

Apply this diff:

  fillAtypicalPresentation(value: string) {
+   if (!value) {
+     throw new Error('Value is required for fillAtypicalPresentation');
+   }
    cy.get("#is_atypical_presentation").should("be.visible").check();
    cy.get("#atypical_presentation").should("be.visible").type(value);
  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fillAtypicalPresentation(value: string) {
cy.get("#is_atypical_presentation").should("be.visible").check();
cy.get("#atypical_presentation").should("be.visible").type(value);
}
fillAtypicalPresentation(value: string) {
if (!value) {
throw new Error('Value is required for fillAtypicalPresentation');
}
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);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Validate value parameter in fillDiagnosis

Add a check to ensure value is provided.

Apply this diff:

  fillDiagnosis(value: string) {
+   if (!value) {
+     throw new Error('Diagnosis value is required for fillDiagnosis');
+   }
    cy.get("#diagnosis").should("be.visible").type(value);
  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fillDiagnosis(value: string) {
cy.get("#diagnosis").should("be.visible").type(value);
}
fillDiagnosis(value: string) {
if (!value) {
throw new Error('Diagnosis value is required for fillDiagnosis');
}
cy.get("#diagnosis").should("be.visible").type(value);
}


fillEtiology(value: string) {
cy.get("#etiology_identified").should("be.visible").type(value);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add input validation to fillEtiology

Check that value is not empty before typing.

Apply this diff:

  fillEtiology(value: string) {
+   if (!value) {
+     throw new Error('Etiology value is required for fillEtiology');
+   }
    cy.get("#etiology_identified").should("be.visible").type(value);
  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fillEtiology(value: string) {
cy.get("#etiology_identified").should("be.visible").type(value);
}
fillEtiology(value: string) {
if (!value) {
throw new Error('Etiology value is required for fillEtiology');
}
cy.get("#etiology_identified").should("be.visible").type(value);
}


fillDiffDiagnosis(value: string) {
cy.get("#diff_diagnosis").should("be.visible").type(value);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Validate value parameter in fillDiffDiagnosis

Ensure value is provided to prevent potential errors.

Apply this diff:

  fillDiffDiagnosis(value: string) {
+   if (!value) {
+     throw new Error('Differential diagnosis value is required for fillDiffDiagnosis');
+   }
    cy.get("#diff_diagnosis").should("be.visible").type(value);
  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fillDiffDiagnosis(value: string) {
cy.get("#diff_diagnosis").should("be.visible").type(value);
}
fillDiffDiagnosis(value: string) {
if (!value) {
throw new Error('Differential diagnosis value is required for fillDiffDiagnosis');
}
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"]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cy.verifyContentPresence("#sample-test-status", ["Request Submitted"]);
cy.verifyContentPresence("#sample-test-status", ["Request Submitted"]);
  • why are keeping these hardcoded value inside the function, keep it in the test file, make it reusable, checkrequesthistory function will not be having same content all the time

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"]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cy.verifyContentPresence("#doctor_name", ["Dr John Doe"]);
cy.verifyContentPresence("#doctor_name", ["Dr John Doe"]);
  • dont use hardcoded values, its not necessary next time someone using this function will have patient card of dr john

cy.verifyContentPresence("#diagnosis", [diagnosis]);
cy.verifyContentPresence("#diff_diagnosis", [differentialDiagnosis]);
cy.verifyContentPresence("#etiology_identified", [etiologyIdentified]);
}

interceptPatientDetailsAPI() {
cy.intercept("GET", "**/api/v1/patient/**").as("patientDetails");
}

verifyPatientDetailsResponse() {
cy.wait("@patientDetails").its("response.statusCode").should("eq", 200);
}

interceptSampleTestReq() {
cy.intercept("GET", "**/api/v1/patient/*/test_sample/**").as(
"sampleDetails",
);
}

verifySampleTestReq() {
cy.wait("@sampleDetails").its("response.statusCode").should("eq", 200);
}

interceptGetSampleTestReq() {
cy.intercept("GET", "**/api/v1/test_sample/**").as("getSampleTestReq");
}

verifyGetSampleTestReq() {
cy.wait("@getSampleTestReq").its("response.statusCode").should("eq", 200);
}
}
1 change: 1 addition & 0 deletions src/components/Patient/PatientHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1370,6 +1370,7 @@ export const PatientHome = (props: any) => {
)
}
authorizeFor={NonReadOnlyUsers}
id="sample-request-btn"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Both instances of "Request Sample Test" should have test identifiers for consistency

The codebase has two instances of "Request Sample Test":

  • One in a ButtonV2 component that correctly has the id="sample-request-btn" attribute
  • Another in a <p> tag that lacks a test identifier

For consistent test automation, consider adding a test identifier to the <p> tag instance as well.

🔗 Analysis chain

LGTM! Test identifier added for Cypress automation.

The addition of the id attribute for the sample test request button aligns well with the PR objectives and follows good testing practices.

Let's verify if similar buttons in the desktop view also need test identifiers:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other sample test related buttons in the file
rg --type tsx "Request Sample Test" -B 2 -A 2

Length of output: 75


Script:

#!/bin/bash
# Search for other sample test related buttons in the file, using ripgrep without file type filter
rg "Request Sample Test" -B 2 -A 2

Length of output: 856


Script:

#!/bin/bash
# Let's check if these other instances have test identifiers
rg -B 5 -A 5 "Request Sample Test" src/components/Patient/PatientHome.tsx

Length of output: 909

>
<span className="flex w-full items-center justify-start gap-2">
<CareIcon icon="l-medkit" className="text-xl" />
Expand Down
16 changes: 10 additions & 6 deletions src/components/Patient/SampleDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ export const SampleDetails = ({ id }: DetailRoute) => {
</div>
<div>
<span className="font-semibold leading-relaxed">Patient: </span>
{sampleDetails?.patient_name}
<span id="patient_name">{sampleDetails?.patient_name}</span>
</div>
{sampleDetails?.facility_object && (
<div>
Expand All @@ -324,37 +324,41 @@ export const SampleDetails = ({ id }: DetailRoute) => {
<span className="font-semibold leading-relaxed">
Fast track testing reason:{" "}
</span>
{sampleDetails.fast_track}
<span id="fast_track_reason">{sampleDetails.fast_track}</span>
</div>
)}
{sampleDetails?.doctor_name && (
<div className="capitalize md:col-span-2">
<span className="font-semibold leading-relaxed">
Doctor&apos;s Name:{" "}
</span>
{startCase(camelCase(sampleDetails.doctor_name))}
<span id="doctor_name">
{startCase(camelCase(sampleDetails.doctor_name))}
</span>
</div>
)}
{sampleDetails?.diagnosis && (
<div className="md:col-span-2">
<span className="font-semibold leading-relaxed">Diagnosis: </span>
{sampleDetails.diagnosis}
<span id="diagnosis">{sampleDetails.diagnosis}</span>
</div>
)}
{sampleDetails?.diff_diagnosis && (
<div className="md:col-span-2">
<span className="font-semibold leading-relaxed">
Differential diagnosis:{" "}
</span>
{sampleDetails?.diff_diagnosis}
<span id="diff_diagnosis">{sampleDetails?.diff_diagnosis}</span>
</div>
)}
{sampleDetails?.etiology_identified && (
<div className="md:col-span-2">
<span className="font-semibold leading-relaxed">
Etiology identified:{" "}
</span>
{sampleDetails.etiology_identified}
<span id="etiology_identified">
{sampleDetails.etiology_identified}
</span>
</div>
)}
<div>
Expand Down
33 changes: 29 additions & 4 deletions src/components/Patient/SampleTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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" && (
Expand All @@ -226,6 +227,7 @@ export const SampleTest = ({ facilityId, patientId }: any) => {
options={ICMR_CATEGORY}
optionLabel={(option) => option}
optionValue={(option) => option}
id="icmr-category"
/>
<div className="mb-6 flex flex-col gap-1">
<p className="font-medium">
Expand All @@ -251,7 +253,11 @@ export const SampleTest = ({ facilityId, patientId }: any) => {
</span>
</div>

<TextFormField {...field("icmr_label", "ICMR Label")} required />
<TextFormField
{...field("icmr_label", "ICMR Label")}
required
id="icmr-label"
/>
<div className="mb-6 w-full flex-none">
<FieldLabel>Testing Facility</FieldLabel>
<FacilitySelect
Expand All @@ -270,22 +276,29 @@ export const SampleTest = ({ facilityId, patientId }: any) => {
/>
</div>
<CheckBoxFormField
id="is_fast_track"
{...field("isFastTrack", "Is fast-track testing required?")}
/>
{state.form.isFastTrack && (
<TextAreaFormField
id="fast_track"
{...field("fast_track", "Reasons for fast-track testing")}
required
/>
)}

<TextFormField {...field("doctor_name", "Doctor's Name")} />
<TextFormField
id="doctor_name"
{...field("doctor_name", "Doctor's Name")}
/>
<CheckBoxFormField
id="is_atypical_presentation"
{...field("is_atypical_presentation", "Is atypical presentation?")}
/>
{state.form.is_atypical_presentation && (
<div>
<TextAreaFormField
id="atypical_presentation"
{...field(
"atypical_presentation",
"Atypical presentation details",
Expand All @@ -294,26 +307,38 @@ export const SampleTest = ({ facilityId, patientId }: any) => {
/>
</div>
)}
<TextAreaFormField {...field("diagnosis", "Diagnosis")} />
<TextAreaFormField
id="diagnosis"
{...field("diagnosis", "Diagnosis")}
/>
<TextAreaFormField
id="etiology_identified"
{...field("etiology_identified", "Etiology identified")}
/>
<TextAreaFormField
id="diff_diagnosis"
{...field("diff_diagnosis", "Differential diagnosis")}
/>

<CheckBoxFormField
id="has_sari"
{...field("has_sari", "Has SARI (Severe Acute Respiratory illness)?")}
/>
<CheckBoxFormField
id="has_ari"
{...field("has_ari", "Has ARI (Acute Respiratory illness)?")}
/>
<CheckBoxFormField
id="is_unusual_course"
{...field("is_unusual_course", "Is unusual course?")}
/>
<div className="mt-4 flex flex-col justify-end gap-2 lg:flex-row">
<Cancel onClick={() => goBack()} />
<Submit onClick={handleSubmit} label={buttonText} />
<Submit
onClick={handleSubmit}
label={buttonText}
id="sample-test-submit-btn"
/>
</div>
</form>
</Page>
Expand Down
Loading
Loading