Skip to content

Commit

Permalink
Merge branch 'develop' into Fix-ohcnetwork#7244-1
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 authored Apr 23, 2024
2 parents ea46df6 + 88e1a0b commit fc27461
Show file tree
Hide file tree
Showing 32 changed files with 481 additions and 221 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/combine.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Combine Dependencies

on: workflow_dispatch

# The minimum permissions required to run this Action
permissions:
contents: write
pull-requests: write
checks: read

jobs:
combine-prs:
runs-on: ubuntu-latest

steps:
- name: Combine dependencies
id: combine-dependencies
uses: github/[email protected]
with:
pr_title: Combined dependencies # The title of the pull request to create
select_label: dependencies # The label which marks PRs that should be combined.
labels: combined-dependencies # Add a label to the combined PR
ci_required: "false" # Whether or not CI should be passing to combine the PR
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
18 changes: 17 additions & 1 deletion src/Components/Facility/FacilityCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
SelectFormField,
} from "../Form/FormFields/SelectFormField";
import { Popover, Transition } from "@headlessui/react";
import { Fragment, lazy, useState } from "react";
import { Fragment, lazy, useEffect, useState } from "react";
import Steps, { Step } from "../Common/Steps";
import {
getPincodeDetails,
Expand Down Expand Up @@ -57,6 +57,7 @@ import request from "../../Utils/request/request.js";
import routes from "../../Redux/api.js";
import useQuery from "../../Utils/request/useQuery.js";
import { RequestResult } from "../../Utils/request/types.js";
import useAuthUser from "../../Common/hooks/useAuthUser";

const Loading = lazy(() => import("../Common/Loading"));

Expand Down Expand Up @@ -159,6 +160,21 @@ export const FacilityCreate = (props: FacilityProps) => {
const headerText = !facilityId ? "Create Facility" : "Update Facility";
const buttonText = !facilityId ? "Save Facility" : "Update Facility";

const authUser = useAuthUser();
useEffect(() => {
if (
authUser &&
authUser.user_type !== "StateAdmin" &&
authUser.user_type !== "DistrictAdmin" &&
authUser.user_type !== "DistrictLabAdmin"
) {
navigate("/facility");
Notification.Error({
msg: "You don't have permission to perform this action. Contact the admin",
});
}
}, [authUser]);

const {
data: districtData,
refetch: districtFetch,
Expand Down
Loading

0 comments on commit fc27461

Please sign in to comment.