Skip to content

Commit

Permalink
Transfer functionality of a patient
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 committed Feb 3, 2024
1 parent 647bb7a commit 8677232
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 13 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/patient_spec/patient_consultation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe("Patient Creation with consultation", () => {
cy.awaitUrl("/patients");
});

it("Create a New consultation to existing patient", () => {
it("Create a patient with consultation in combination OP + Admission + All Fields", () => {
patientPage.interceptFacilities();
patientPage.visitConsultationPage();
patientPage.verifyStatusCode();
Expand Down
47 changes: 37 additions & 10 deletions cypress/e2e/patient_spec/patient_registration.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
emergency_phone_number,
phone_number,
} from "../../pageobject/constants";
import PatientTransfer from "../../pageobject/Patient/PatientTransfer";
const yearOfBirth = "2001";

const calculateAge = () => {
Expand All @@ -17,6 +18,7 @@ describe("Patient Creation with consultation", () => {
const loginPage = new LoginPage();
const patientPage = new PatientPage();
const facilityPage = new FacilityPage();
const patientTransfer = new PatientTransfer();
const age = calculateAge();
const patientDateOfBirth = "01012001";
const patientOneName = "Patient With No Consultation";
Expand All @@ -43,6 +45,9 @@ 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";

before(() => {
loginPage.loginAsDisctrictAdmin();
Expand All @@ -55,6 +60,16 @@ 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();
Expand Down Expand Up @@ -210,19 +225,31 @@ describe("Patient Creation with consultation", () => {
it("Patient Registration using the transfer with no consultation", () => {
// transfer the patient and no consulation
patientPage.createPatient();
patientPage.selectFacility("Dummy Shifting Center");
patientPage.selectFacility(patientTransferFacility);
patientPage.patientformvisibility();
// cancel and go to patient detail page and verify transferred facility name
});

it("Patient Registration using External Result Import", () => {
// copy the patient external ID from external results
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("Dummy Shifting Center");
patientPage.selectFacility(patientTransferFacility);
patientPage.patientformvisibility();
// import the result and create a new patient

// verify the patient is successfully created
patientPage.typePatientPhoneNumber(patientTransferPhoneNumber);
patientTransfer.clickAdmitPatientRecordButton();
patientTransfer.clickTransferPopupContinueButton();
patientTransfer.clickTransferPatientNameList(patientTransferName);
patientTransfer.clickTransferPatientDob(patientDateOfBirth);
patientTransfer.clickTransferSubmitButton();
patientTransfer.verifyFacilityErrorMessage();
});

afterEach(() => {
Expand Down
63 changes: 63 additions & 0 deletions cypress/pageobject/Patient/PatientTransfer.ts
Original file line number Diff line number Diff line change
@@ -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;
1 change: 1 addition & 0 deletions src/Components/Facility/DuplicatePatientDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const DuplicatePatientDialog = (props: Props) => {
label={`Cancel ${isNew ? "Registration" : "Update"}`}
/>
<Submit
id="submit-continue-button"
onClick={() => handleOk(action)}
disabled={!action}
label="Continue"
Expand Down
2 changes: 2 additions & 0 deletions src/Components/Facility/TransferPatientDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ const TransferPatientDialog = (props: Props) => {
<div>
<DateFormField
required
id="dateofbirth-transferform"
name="date_of_birth"
label="Date of birth"
value={getDate(state.form.date_of_birth)}
Expand All @@ -191,6 +192,7 @@ const TransferPatientDialog = (props: Props) => {
<div className="flex flex-col justify-between gap-2 pt-4 md:flex-row">
<Cancel onClick={handleCancel} disabled={isLoading} />
<Submit
id="submit-transferpatient"
disabled={isLoading}
onClick={handleSubmit}
label="Transfer Suspect / Patient"
Expand Down
1 change: 1 addition & 0 deletions src/Components/Patient/PatientHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,7 @@ export const PatientHome = (props: any) => {
</div>
<div>
<ButtonV2
id="patient-allow-transfer"
className="mt-4 w-full"
disabled={
!consultationListData ||
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 ?? "https://careapi.ohc.network",
target: process.env.CARE_API ?? "http://192.168.0.204:9000/",
changeOrigin: true,
},
},
Expand All @@ -110,7 +110,7 @@ export default defineConfig({
port: 4000,
proxy: {
"/api": {
target: process.env.CARE_API ?? "https://careapi.ohc.network",
target: process.env.CARE_API ?? "http://192.168.0.204:9000/",
changeOrigin: true,
},
},
Expand Down

0 comments on commit 8677232

Please sign in to comment.