Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
hrit2773 committed Apr 24, 2024
2 parents 9546232 + 760af70 commit ead9346
Show file tree
Hide file tree
Showing 23 changed files with 393 additions and 210 deletions.
4 changes: 1 addition & 3 deletions cypress/e2e/assets_spec/assets_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,10 @@ describe("Asset", () => {
assetPage.interceptAssetCreation();
assetPage.clickCreateAsset();
assetPage.verifyAssetCreation();

assetSearchPage.typeSearchKeyword("New Test Asset Vital");
assetSearchPage.pressEnter();

assetPage.openCreatedAsset();
assetPage.configureVitalAsset("Host name", "192.168.1.64");
assetPage.configureVitalAsset("Host name", "192.168.1.20");
assetPage.clickConfigureVital();
});

Expand Down
127 changes: 127 additions & 0 deletions cypress/e2e/patient_spec/patient_discharge.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress";
import LoginPage from "../../pageobject/Login/LoginPage";
import { PatientPage } from "../../pageobject/Patient/PatientCreation";
import PatientDischarge from "../../pageobject/Patient/PatientDischarge";
import PatientPrescription from "../../pageobject/Patient/PatientPrescription";

describe("Patient Discharge based on multiple reason", () => {
const loginPage = new LoginPage();
const patientPage = new PatientPage();
const patientDischarge = new PatientDischarge();
const patientPrescription = new PatientPrescription();
const patientDischargeReason1 = "Recovered";
const patientDischargeReason2 = "Referred";
const patientDischargeReason3 = "Expired";
const patientDischargeReason4 = "LAMA";
const patientDischargeAdvice = "Discharge Advice";
const patientMedicine = "ZOLE";
const referringFacility = "Dummy Shifting Center, Ernakulam";
const referringFreetextFacility = "Aster Mims";
const patientDeathCause = "Cause Of Death";
const doctorName = "Custom Doctor";

before(() => {
loginPage.loginAsDisctrictAdmin();
cy.saveLocalStorage();
});

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

it("Discharge a LAMA patient in the consultation", () => {
patientPage.visitPatient("Dummy Patient 12");
patientDischarge.clickDischarge();
patientDischarge.selectDischargeReason(patientDischargeReason4);
cy.submitButton("Confirm Discharge");
cy.verifyNotification("Patient Discharged Successfully");
cy.closeNotification();
// Verify the consultation dashboard reflection
cy.verifyContentPresence("#consultation-buttons", ["LAMA"]);
// verify the discharge information card
cy.verifyContentPresence("#discharge-information", [
patientDischargeReason4,
]);
});

it("Discharge a expired patient in the consultation", () => {
patientPage.visitPatient("Dummy Patient 13");
patientDischarge.clickDischarge();
patientDischarge.selectDischargeReason(patientDischargeReason3);
patientDischarge.typeDischargeNote(patientDeathCause);
patientDischarge.typeDoctorName(doctorName);
cy.submitButton("Confirm Discharge");
cy.verifyNotification("Patient Discharged Successfully");
cy.closeNotification();
// Verify the consultation dashboard reflection
cy.verifyContentPresence("#consultation-buttons", ["EXPIRED"]);
// verify the discharge information card
cy.verifyContentPresence("#discharge-information", [
patientDischargeReason3,
patientDeathCause,
doctorName,
]);
});

it("Discharge patient with referred reason to a facility", () => {
patientPage.visitPatient("Dummy Patient 16");
patientDischarge.clickDischarge();
patientDischarge.selectDischargeReason(patientDischargeReason2);
patientDischarge.typeDischargeNote(patientDischargeAdvice);
// select a registrated facility from dropdown and clear
patientDischarge.typeReferringFacility(referringFacility);
patientDischarge.clickClearButton();
// select a non-registered facility and perform the discharge
patientDischarge.typeReferringFacility(referringFreetextFacility);
cy.wait(2000);
cy.submitButton("Confirm Discharge");
cy.wait(2000);
cy.verifyNotification("Patient Discharged Successfully");
cy.closeNotification();
// Verify the consultation dashboard reflection
cy.verifyContentPresence("#consultation-buttons", ["Referred"]);
// Verify the dashboard and discharge information
cy.verifyContentPresence("#discharge-information", [
patientDischargeReason2,
patientDischargeAdvice,
referringFreetextFacility,
]);
});

it("Discharge a recovered patient with all relevant fields", () => {
patientPage.visitPatient("Dummy Patient 15");
patientDischarge.clickDischarge();
patientDischarge.selectDischargeReason(patientDischargeReason1);
patientDischarge.typeDischargeNote(patientDischargeAdvice);
// Prescribe a medicine for the patient
patientPrescription.clickAddPrescription();
patientPrescription.interceptMedibase();
patientPrescription.selectMedicinebox();
patientPrescription.selectMedicine(patientMedicine);
patientPrescription.enterDosage("4");
patientPrescription.selectDosageFrequency("Twice daily");
cy.submitButton("Submit");
cy.verifyNotification("Medicine prescribed");
cy.wait(2000);
cy.closeNotification();
// submit the discharge pop-up
cy.submitButton("Confirm Discharge");
cy.wait(2000);
cy.verifyNotification("Patient Discharged Successfully");
cy.closeNotification();
// Verify the consultation dashboard reflection
cy.verifyContentPresence("#consultation-buttons", ["Recovered"]);
// Verify the dashboard and discharge information
cy.verifyContentPresence("#discharge-information", [
patientDischargeReason1,
patientDischargeAdvice,
patientMedicine,
]);
});

afterEach(() => {
cy.saveLocalStorage();
});
});
8 changes: 0 additions & 8 deletions cypress/e2e/patient_spec/patient_manage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,6 @@ describe("Patient", () => {
cy.verifyNotification("Medicine prescribed");
});

it("Discharge a patient", () => {
patientPage.visitPatient("Dummy Patient 6");
patientConsultationPage.clickDischargePatient();
patientConsultationPage.selectDischargeReason("Recovered");
patientConsultationPage.addDischargeNotes("Discharge notes");
patientConsultationPage.confirmDischarge();
});

afterEach(() => {
cy.saveLocalStorage();
});
Expand Down
28 changes: 1 addition & 27 deletions cypress/pageobject/Patient/PatientConsultation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class PatientConsultationPage {
cy.get("button").contains("Manage Patient").click();
cy.verifyAndClickElement(
"#consultation-buttons",
"Edit Consultation Details"
"Edit Consultation Details",
);
cy.wait(3000);
}
Expand Down Expand Up @@ -130,30 +130,4 @@ export class PatientConsultationPage {
cy.get("#add_doctor_note_button").click();
cy.wait("@postDoctorNotes").its("response.statusCode").should("eq", 201);
}

clickDischargePatient() {
cy.get("#show-more").scrollIntoView();
cy.get("#show-more").click();
cy.contains("p", "Discharge from CARE").click();
}

selectDischargeReason(reason: string) {
cy.get("#discharge_reason")
.click()
.then(() => {
cy.get("[role='option']").contains(reason).click();
});
}

addDischargeNotes(notes: string) {
cy.get("#discharge_notes").type(notes);
}

confirmDischarge() {
cy.intercept("POST", "**/api/v1/consultation/*/discharge_patient/").as(
"dischargePatient"
);
cy.get("#submit").contains("Confirm Discharge").click();
cy.wait("@dischargePatient").its("response.statusCode").should("eq", 200);
}
}
29 changes: 29 additions & 0 deletions cypress/pageobject/Patient/PatientDischarge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class PatientDischarge {
clickDischarge() {
cy.get("#show-more").scrollIntoView();
cy.verifyAndClickElement("#show-more", "Manage Patient");
cy.verifyAndClickElement("#show-more", "Discharge from CARE");
}

selectDischargeReason(reason: string) {
cy.clickAndSelectOption("#discharge_reason", reason);
}

typeDischargeNote(note: string) {
cy.get("#discharge_notes").type(note);
}

typeReferringFacility(facility: string) {
cy.searchAndSelectOption("#facility-referredto", facility);
}

clickClearButton() {
cy.get("#clear-button").click();
}

typeDoctorName(doctorName: string) {
cy.get("#death_confirmed_by").type(doctorName);
}
}

export default PatientDischarge;
4 changes: 2 additions & 2 deletions src/Components/ABDM/LinkABHANumberModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,12 @@ const ScanABHAQRSection = ({
body: {
patientId,
hidn: abha?.hidn,
phr: abha?.hid,
phr: (abha?.phr ?? abha?.hid) as string,
name: abha?.name,
gender: abha?.gender,
dob: abha?.dob.replace(/\//g, "-"),
address: abha?.address,
"dist name": abha?.district_name,
"dist name": abha?.["dist name"] ?? abha?.district_name,
"state name": abha?.["state name"],
},
});
Expand Down
8 changes: 5 additions & 3 deletions src/Components/ABDM/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,12 @@ export interface ILinkViaQRBody {
export interface ABHAQRContent {
address: string;
distlgd: string;
district_name: string;
district_name?: string;
dob: string;
gender: "M";
hid: string;
gender: "M" | "F" | "O";
hid?: string;
phr?: string;
"dist name"?: string;
hidn: string;
mobile: string;
name: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export const ConsultationUpdatesTab = (props: ConsultationTabProps) => {
"lg:col-span-2"
}`}
>
<div className="px-4 py-5 sm:p-6">
<div className="px-4 py-5 sm:p-6" id="discharge-information">
<h3 className="text-lg font-semibold leading-relaxed text-gray-900">
Discharge Information
</h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@ const LogUpdateCardAttribute = <T extends keyof DailyRoundsModel>({
</div>
);

case "rounds_type":
return (
<div className="flex flex-col items-center gap-2 md:flex-row">
<AttributeLabel attributeKey={attributeKey} />
<span className="text-sm font-semibold text-gray-700">
{(attributeValue as string) === "VENTILATOR"
? "CRITICAL CARE"
: (attributeValue as string)}
</span>
</div>
);

default:
return (
<div className="flex flex-col items-center gap-2 md:flex-row">
Expand Down
34 changes: 18 additions & 16 deletions src/Components/Facility/DischargeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,12 @@ const DischargeModal = ({
}
};

const handleFacilitySelect = (selected: FacilityModel) => {
const handleFacilitySelect = (selected?: FacilityModel) => {
setFacility(selected);
setPreDischargeForm((prev) => ({
...prev,
referred_to: selected.id ?? null,
referred_to_external: !selected.id ? selected.name : null,
referred_to: selected?.id ?? null,
referred_to_external: !selected?.id ? selected?.name : null,
}));
};

Expand Down Expand Up @@ -211,19 +211,21 @@ const DischargeModal = ({
{preDischargeForm.new_discharge_reason ===
DISCHARGE_REASONS.find((i) => i.text == "Referred")?.id && (
<>
<FieldLabel>Referred to</FieldLabel>
<FacilitySelect
name="referred_to"
setSelected={(selected) =>
handleFacilitySelect(selected as FacilityModel)
}
selected={facility ?? null}
showAll
freeText
multiple={false}
errors={errors?.referred_to}
className="mb-4"
/>
<div id="facility-referredto">
<FieldLabel>Referred to</FieldLabel>
<FacilitySelect
name="referred_to"
setSelected={(selected) =>
handleFacilitySelect(selected as FacilityModel | undefined)
}
selected={facility ?? null}
showAll
freeText
multiple={false}
errors={errors?.referred_to}
className="mb-4"
/>
</div>
</>
)}
<TextAreaFormField
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Form/AutoCompleteAsync.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const AutoCompleteAsync = (props: Props) => {
<Combobox.Button className="absolute inset-y-0 right-0 flex items-center pr-2">
<div className="absolute right-0 top-1 mr-2 flex items-center text-lg text-secondary-900">
{hasSelection && !loading && !required && (
<div className="tooltip">
<div className="tooltip" id="clear-button">
<CareIcon
icon="l-times-circle"
className="mb-[-5px] h-4 w-4 text-gray-800 transition-colors duration-200 ease-in-out hover:text-gray-500"
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Form/FormFields/TextFormField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const TextFormField = forwardRef((props: TextFormFieldProps, ref) => {
);
const _trailing =
trailing === trailingFocused ? (
<div className="relative inset-y-0 right-0 flex items-center pr-3">
<div className="absolute inset-y-0 right-0 flex items-center pr-3">
{trailing}
</div>
) : (
Expand Down
Loading

0 comments on commit ead9346

Please sign in to comment.