Skip to content

Commit

Permalink
v24.25.1 Merge branch 'staging' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
sainak committed Jun 19, 2024
2 parents b1638dd + dccd114 commit d764ee2
Show file tree
Hide file tree
Showing 11 changed files with 114 additions and 40 deletions.
49 changes: 43 additions & 6 deletions cypress/e2e/patient_spec/patient_prescription.cy.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress";
import PatientPrescription from "../../pageobject/Patient/PatientPrescription";
import LoginPage from "../../pageobject/Login/LoginPage";
import { PatientPage } from "../../pageobject/Patient/PatientCreation";

const patientPrescription = new PatientPrescription();
const loginPage = new LoginPage();
const patientPage = new PatientPage();
const medicineName = "DOLO";
const medicineNameOne = "DOLO";
const medicineNameTwo = "FDEP PLUS";
const medicineBaseDosage = "4";
const medicineTargetDosage = "9";
const medicineFrequency = "Twice daily";
const medicineAdministerNote = "Medicine Administration Note";
const medicineIndicator = "Test Indicator";

describe("Patient Medicine Administration", () => {
before(() => {
Expand All @@ -23,14 +26,48 @@ describe("Patient Medicine Administration", () => {
cy.awaitUrl("/patients");
});

it("Add a PRN Prescription medicine | Group Administrate it |", () => {
patientPage.visitPatient("Dummy Patient 6");
patientPrescription.visitMedicineTab();
patientPrescription.visitEditPrescription();
// Add First Medicine
patientPrescription.clickAddPrnPrescriptionButton();
patientPrescription.interceptMedibase();
patientPrescription.selectMedicinebox();
patientPrescription.selectMedicine(medicineNameOne);
patientPrescription.enterDosage(medicineBaseDosage);
patientPrescription.enterIndicator(medicineIndicator);
cy.submitButton("Submit");
cy.verifyNotification("Medicine prescribed");
cy.closeNotification();
// Add Second Medicine
patientPrescription.clickAddPrnPrescriptionButton();
patientPrescription.interceptMedibase();
patientPrescription.selectMedicinebox();
patientPrescription.selectMedicine(medicineNameTwo);
patientPrescription.enterDosage(medicineBaseDosage);
patientPrescription.enterIndicator(medicineIndicator);
cy.submitButton("Submit");
cy.verifyNotification("Medicine prescribed");
cy.closeNotification();
patientPrescription.clickReturnToDashboard();
// Group Administer the PRN Medicine
patientPrescription.visitMedicineTab();
patientPrescription.clickAdministerBulkMedicine();
patientPrescription.clickAllVisibleAdministration();
patientPrescription.clickAdministerSelectedMedicine();
cy.verifyNotification("Medicine(s) administered");
cy.closeNotification();
});

it("Add a new titrated medicine for a patient | Individual Administeration |", () => {
patientPage.visitPatient("Dummy Patient 5");
patientPrescription.visitMedicineTab();
patientPrescription.visitEditPrescription();
patientPrescription.clickAddPrescription();
patientPrescription.interceptMedibase();
patientPrescription.selectMedicinebox();
patientPrescription.selectMedicine(medicineName);
patientPrescription.selectMedicine(medicineNameOne);
patientPrescription.clickTitratedDosage();
patientPrescription.enterDosage(medicineBaseDosage);
patientPrescription.enterTargetDosage(medicineTargetDosage);
Expand All @@ -47,14 +84,14 @@ describe("Patient Medicine Administration", () => {
cy.closeNotification();
// Verify the Reflection on the Medicine
cy.verifyContentPresence("#medicine-preview", [
medicineName,
medicineNameOne,
medicineBaseDosage,
medicineTargetDosage,
]);
patientPrescription.clickReturnToDashboard();
// Go to medicine tab and administer it again
patientPrescription.visitMedicineTab();
cy.verifyAndClickElement("#0", medicineName);
cy.verifyAndClickElement("#0", medicineNameOne);
cy.submitButton("Administer");
patientPrescription.enterAdministerDosage(medicineBaseDosage);
cy.submitButton("Administer Medicine");
Expand All @@ -68,7 +105,7 @@ describe("Patient Medicine Administration", () => {
patientPrescription.clickAddPrescription();
patientPrescription.interceptMedibase();
patientPrescription.selectMedicinebox();
patientPrescription.selectMedicine(medicineName);
patientPrescription.selectMedicine(medicineNameOne);
patientPrescription.enterDosage(medicineBaseDosage);
patientPrescription.selectDosageFrequency(medicineFrequency);
cy.submitButton("Submit");
Expand All @@ -78,7 +115,7 @@ describe("Patient Medicine Administration", () => {
patientPrescription.clickAddPrescription();
patientPrescription.interceptMedibase();
patientPrescription.selectMedicinebox();
patientPrescription.selectMedicine(medicineName);
patientPrescription.selectMedicine(medicineNameOne);
patientPrescription.enterDosage(medicineBaseDosage);
patientPrescription.selectDosageFrequency(medicineFrequency);
cy.submitButton("Submit");
Expand Down
29 changes: 21 additions & 8 deletions cypress/pageobject/Patient/PatientPrescription.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { cy } from "local-cypress";
export class PatientPrescription {
clickAddPrescription() {
cy.get("#add-prescription").scrollIntoView();
Expand All @@ -7,6 +8,10 @@ export class PatientPrescription {
);
}

clickAddPrnPrescriptionButton() {
cy.contains("button", "Add PRN Prescription").click();
}

interceptMedibase() {
cy.intercept("GET", "**/api/v1/medibase/**").as("getMedibase");
}
Expand All @@ -27,6 +32,15 @@ export class PatientPrescription {
cy.verifyAndClickElement("#administer-medicine", "Administer");
}

clickAdministerBulkMedicine() {
cy.get("#bulk-administer").should("be.visible");
cy.get("#bulk-administer").click();
}

clickAllVisibleAdministration() {
cy.get("#should_administer").should("be.visible").click();
}

selectMedicinebox() {
cy.get(
"div#medicine_object input[placeholder='Select'][role='combobox']",
Expand All @@ -41,6 +55,10 @@ export class PatientPrescription {
cy.get("#base_dosage").type(doseAmount, { force: true });
}

enterIndicator(indicator: string) {
cy.get("#indicator").type(indicator);
}

enterAdministerDosage(dosage: string) {
cy.get("#dosage").type(dosage);
}
Expand All @@ -64,14 +82,9 @@ export class PatientPrescription {
);
}

discontinuePreviousPrescription() {
cy.intercept(
"POST",
"**/api/v1/consultation/*/prescriptions/*/discontinue/",
).as("deletePrescription");
cy.get("button").contains("Discontinue").click();
cy.get("#submit").contains("Discontinue").click();
cy.wait("@deletePrescription").its("response.statusCode").should("eq", 200);
clickAdministerSelectedMedicine() {
cy.get("#administer-selected-medicine").should("be.visible");
cy.get("#administer-selected-medicine").click();
}

visitMedicineTab() {
Expand Down
29 changes: 19 additions & 10 deletions src/Components/CriticalCareRecording/Others/DailyRound__General.res
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,28 @@ let symptoms = [
"CONSTIPATION",
"HEAD ACHE",
"BLEEDING",
"DIZZINESS"
];
"DIZZINESS",
]

@react.component
let make = (~others, ~renderOptionalDescription, ~title) => {
<div> {title("Symptoms")} <div className=" flex flex-wrap max-w-full"> {Js.Array.map(id => {
<div className="rounded-full px-4 py-2 bg-gray-400 m-1 text-sm">
{str(symptoms[id - 1])}
</div>
}, Others.additional_symptoms(
others,
))->React.array} </div> {renderOptionalDescription(
let additionalSymptoms = Others.additional_symptoms(others)
<div>
{title("Symptoms")}
<div className="flex flex-wrap max-w-full">
{switch additionalSymptoms {
| Some(symptomsArray) => Js.Array.map(id => {
<div className="rounded-full px-4 py-2 bg-gray-400 m-1 text-sm">
{str(symptoms[id - 1])}
</div>
}, symptomsArray)->React.array
| None => React.null
}}
</div>
{renderOptionalDescription(
"Physical Examination Info",
Others.physical_examination_info(others),
)} {renderOptionalDescription("Other Details", Others.other_details(others))} </div>
)}
{renderOptionalDescription("Other Details", Others.other_details(others))}
</div>
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ type t = {
bilateral_air_entry: option<bool>,
etco2: option<int>,
physical_examination_info: option<string>,
additional_symptoms: array<int>,
additional_symptoms: option<array<int>>,
other_details: option<string>,
other_symptoms: option<string>,
}
Expand All @@ -21,12 +21,12 @@ let make = (
~other_symptoms,
~other_details,
) => {
bilateral_air_entry: bilateral_air_entry,
etco2: etco2,
physical_examination_info: physical_examination_info,
other_details: other_details,
additional_symptoms: additional_symptoms,
other_symptoms: other_symptoms,
bilateral_air_entry,
etco2,
physical_examination_info,
other_details,
additional_symptoms,
other_symptoms,
}

let makeFromJs = dailyRound => {
Expand Down
4 changes: 3 additions & 1 deletion src/Components/Facility/Consultations/DailyRoundsFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ export default function DailyRoundsFilter(props: Props) {
label={t("Round Type")}
options={DailyRoundTypes}
placeholder={t("show_all")}
optionLabel={(o) => t(o)}
optionLabel={(o) =>
o === "DOCTORS_LOG" ? "Progress Note" : t(o)
}
optionValue={(o) => o}
/>
<TextFormField
Expand Down
8 changes: 5 additions & 3 deletions src/Components/Facility/Consultations/DailyRoundsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@ export default function DailyRoundsList({ consultation }: Props) {
);
}

const itemUrl = ["NORMAL", "TELEMEDICINE"].includes(
item.rounds_type as string,
)
const itemUrl = [
"NORMAL",
"TELEMEDICINE",
"DOCTORS_LOG",
].includes(item.rounds_type as string)
? `${consultationUrl}/daily-rounds/${item.id}`
: `${consultationUrl}/daily_rounds/${item.id}`;

Expand Down
1 change: 0 additions & 1 deletion src/Components/Form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ const Form = <T extends FormDetails>({

if (validate) {
const errors = omitBy(validate(state.form), isEmpty) as FormErrors<T>;

if (Object.keys(errors).length) {
dispatch({ type: "set_errors", errors });

Expand Down
3 changes: 3 additions & 0 deletions src/Components/Medicine/EditPrescriptionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ export default function EditPrescriptionForm(props: Props) {

if (success) {
props.onDone(true);
Notification.Success({ msg: "Prescription edited successfully" });
} else {
Notification.Error({ msg: "Failed to edit prescription" });
}
}}
noPadding
Expand Down
6 changes: 5 additions & 1 deletion src/Components/Medicine/MedicineAdministration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,11 @@ export default function MedicineAdministration(props: Props) {
</PrescriptionDetailCard>
))}
<div className="flex justify-end">
<ButtonV2 onClick={handleSubmit} disabled={!selectedCount}>
<ButtonV2
id="administer-selected-medicine"
onClick={handleSubmit}
disabled={!selectedCount}
>
<CareIcon icon="l-syringe" className="text-lg" />
{t("administer_selected_medicines")}{" "}
{selectedCount > 0 && `(${selectedCount})`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default function BulkAdminister({ prescriptions, onDone }: Props) {
return (
<>
<ButtonV2
id="bulk-administer"
ghost
border
onClick={() => setShowBulkAdminister(true)}
Expand Down
10 changes: 7 additions & 3 deletions src/Components/Patient/DailyRounds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ export const DailyRounds = (props: any) => {
review_interval: Number(prevReviewInterval),
};

if (["NORMAL", "TELEMEDICINE"].includes(state.form.rounds_type)) {
if (!["VENTILATOR"].includes(state.form.rounds_type)) {
data = {
...data,
bp: state.form.bp ?? {},
Expand All @@ -342,9 +342,13 @@ export const DailyRounds = (props: any) => {
if (obj) {
dispatch({ type: "set_form", form: initForm });
Notification.Success({
msg: `${obj.rounds_type === "VENTILATOR" ? "Critical Care" : capitalize(obj.rounds_type)} log update details updated successfully`,
msg: `${obj.rounds_type === "DOCTORS_LOG" ? "Progress Notes" : (obj.rounds_type === "VENTILATOR" ? "Critical Care" : capitalize(obj.rounds_type)) + " log update"} details updated successfully`,
});
if (["NORMAL", "TELEMEDICINE"].includes(state.form.rounds_type)) {
if (
["NORMAL", "TELEMEDICINE", "DOCTORS_LOG"].includes(
state.form.rounds_type,
)
) {
navigate(
`/facility/${facilityId}/patient/${patientId}/consultation/${consultationId}`,
);
Expand Down

0 comments on commit d764ee2

Please sign in to comment.