diff --git a/cypress/e2e/patient_spec/patient_prescription.cy.ts b/cypress/e2e/patient_spec/patient_prescription.cy.ts index 6bb3fc82f37..c7a7cd9aba4 100644 --- a/cypress/e2e/patient_spec/patient_prescription.cy.ts +++ b/cypress/e2e/patient_spec/patient_prescription.cy.ts @@ -26,6 +26,43 @@ describe("Patient Medicine Administration", () => { cy.awaitUrl("/patients"); }); + it("Add a new medicine | Verify the Edit and Discontinue Medicine workflow |", () => { + patientPage.visitPatient("Dummy Patient 9"); + patientPrescription.visitMedicineTab(); + patientPrescription.visitEditPrescription(); + // Add a normal Medicine to the patient + patientPrescription.clickAddPrescription(); + patientPrescription.interceptMedibase(); + patientPrescription.selectMedicinebox(); + patientPrescription.selectMedicine(medicineNameOne); + patientPrescription.enterDosage(medicineBaseDosage); + patientPrescription.selectDosageFrequency(medicineFrequency); + cy.submitButton("Submit"); + cy.verifyNotification("Medicine prescribed"); + cy.closeNotification(); + // Edit the existing medicine & Verify they are properly moved to discontinue position + patientPrescription.clickReturnToDashboard(); + patientPrescription.visitMedicineTab(); + cy.verifyAndClickElement("#0", medicineNameOne); + cy.verifyContentPresence("#submit", ["Discontinue"]); // To verify the pop-up is open + cy.submitButton("Edit"); + patientPrescription.enterDosage(medicineTargetDosage); + cy.submitButton("Submit"); + cy.verifyNotification("Prescription edited successfully"); + cy.closeNotification(); + // Discontinue a medicine & Verify the notification + cy.verifyAndClickElement("#0", medicineNameOne); + cy.submitButton("Discontinue"); + patientPrescription.enterDiscontinueReason("Medicine is been discontinued"); + cy.submitButton("Discontinue"); + cy.verifyNotification("Prescription discontinued"); + cy.closeNotification(); + // verify the discontinue medicine view + cy.verifyContentPresence("#discontinued-medicine", [ + "discontinued prescription(s)", + ]); + }); + it("Add a PRN Prescription medicine | Group Administrate it |", () => { patientPage.visitPatient("Dummy Patient 6"); patientPrescription.visitMedicineTab(); diff --git a/cypress/pageobject/Patient/PatientPrescription.ts b/cypress/pageobject/Patient/PatientPrescription.ts index 50f072f1d9b..8e006465e08 100644 --- a/cypress/pageobject/Patient/PatientPrescription.ts +++ b/cypress/pageobject/Patient/PatientPrescription.ts @@ -52,6 +52,8 @@ export class PatientPrescription { } enterDosage(doseAmount: string) { + cy.get("#base_dosage").clear({ force: true }); + cy.get("#base_dosage").click({ force: true }); cy.get("#base_dosage").type(doseAmount, { force: true }); } @@ -59,6 +61,11 @@ export class PatientPrescription { cy.get("#indicator").type(indicator); } + enterDiscontinueReason(reason: string) { + cy.wait(2000); + cy.get("#discontinuedReason").type(reason); + } + enterAdministerDosage(dosage: string) { cy.get("#dosage").type(dosage); } diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index b710e310bfb..45a3cde3245 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -112,6 +112,7 @@ Cypress.Commands.add("clearAllFilters", () => { }); Cypress.Commands.add("submitButton", (buttonText = "Submit") => { + cy.get("button[type='submit']").contains(buttonText).scrollIntoView(); cy.get("button[type='submit']").contains(buttonText).click(); }); diff --git a/src/Components/Medicine/MedicineAdministrationSheet/index.tsx b/src/Components/Medicine/MedicineAdministrationSheet/index.tsx index 59d3976d763..29431fefdf9 100644 --- a/src/Components/Medicine/MedicineAdministrationSheet/index.tsx +++ b/src/Components/Medicine/MedicineAdministrationSheet/index.tsx @@ -150,6 +150,7 @@ const MedicineAdministrationSheet = ({ readonly, is_prn }: Props) => { {!!discontinuedCount && (