Skip to content

Commit

Permalink
Final PR
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 committed Feb 4, 2024
1 parent 8677232 commit 987f17a
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 27 deletions.
45 changes: 39 additions & 6 deletions cypress/e2e/patient_spec/patient_consultation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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"
Expand All @@ -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");
Expand Down
42 changes: 31 additions & 11 deletions cypress/e2e/patient_spec/patient_registration.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand All @@ -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";
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand Down Expand Up @@ -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();
});
Expand Down
12 changes: 9 additions & 3 deletions cypress/pageobject/Patient/PatientConsultation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down
28 changes: 28 additions & 0 deletions cypress/pageobject/Patient/PatientExternal.ts
Original file line number Diff line number Diff line change
@@ -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;
11 changes: 8 additions & 3 deletions src/Components/ExternalResult/ResultItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,18 @@ export default function ResultItem(props: any) {
<div className="mt-4 overflow-hidden bg-white shadow sm:rounded-lg">
<div className="border-b border-gray-200 px-4 py-5 sm:px-6">
<h3 className="text-lg font-medium leading-6 text-gray-900">
{resultItemData.name} - {resultItemData.age}{" "}
{resultItemData.age_in} | {resultItemData.result}
<span id="external-patient-name">{resultItemData.name}</span> -{" "}
<span>{resultItemData.age}</span>{" "}
<span>{resultItemData.age_in}</span> |{" "}
<span>{resultItemData.result}</span>
</h3>
<p className="mt-1 max-w-2xl text-sm leading-5 text-gray-500">
{t("srf_id")}: {resultItemData.srf_id}
</p>
<p className="mt-1 max-w-2xl text-sm leading-5 text-gray-500">
<p
className="mt-1 max-w-2xl text-sm leading-5 text-gray-500"
id="patient-external-id"
>
{t("care_external_results_id")}: {resultItemData.id}
</p>
{resultItemData.patient_created ? (
Expand Down
5 changes: 4 additions & 1 deletion src/Components/ExternalResult/ResultList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,10 @@ export default function ResultList() {
]}
/>

<div className="min-w-full overflow-hidden overflow-x-auto align-middle shadow sm:rounded-t-lg">
<div
className="min-w-full overflow-hidden overflow-x-auto align-middle shadow sm:rounded-t-lg"
id="external-result-table"
>
<table className="min-w-full divide-y divide-gray-200">
<thead>
<tr>
Expand Down
5 changes: 4 additions & 1 deletion src/Components/Patient/PatientInfoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,10 @@ export default function PatientInfoCard(props: {
</div>
)}

<div className="flex w-full flex-col gap-2 px-4 py-1 lg:w-fit lg:p-6">
<div
className="flex w-full flex-col gap-2 px-4 py-1 lg:w-fit lg:p-6"
id="consultation-buttons"
>
{!!consultation?.discharge_date && (
<div className="flex flex-col items-center justify-center">
<div className="text-sm font-normal leading-5 text-gray-500">
Expand Down
2 changes: 2 additions & 0 deletions src/Components/Patient/PatientRegister.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,7 @@ export const PatientRegister = (props: PatientRegisterProps) => {
/>
</div>
<button
id="submit-importexternalresult-button"
className="btn btn-primary mr-4"
onClick={(e) => {
fetchExtResultData(e, showImport?.field?.("name"));
Expand Down Expand Up @@ -1174,6 +1175,7 @@ export const PatientRegister = (props: PatientRegisterProps) => {
<>
<div className="mb-2 overflow-visible rounded border border-gray-200 p-4">
<ButtonV2
id="import-externalresult-button"
className="flex items-center gap-2"
disabled={
authUser.user_type === "Nurse" ||
Expand Down
4 changes: 2 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default defineConfig({
port: 4000,
proxy: {
"/api": {
target: process.env.CARE_API ?? "http://192.168.0.204:9000/",
target: process.env.CARE_API ?? "https://careapi.ohc.network",
changeOrigin: true,
},
},
Expand All @@ -110,7 +110,7 @@ export default defineConfig({
port: 4000,
proxy: {
"/api": {
target: process.env.CARE_API ?? "http://192.168.0.204:9000/",
target: process.env.CARE_API ?? "https://careapi.ohc.network",
changeOrigin: true,
},
},
Expand Down

0 comments on commit 987f17a

Please sign in to comment.