Skip to content

Commit

Permalink
Duplicate medicine (#7764)
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 authored May 6, 2024
1 parent 2846100 commit ca4040e
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 20 deletions.
15 changes: 0 additions & 15 deletions cypress/e2e/patient_spec/patient_manage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress";
import LoginPage from "../../pageobject/Login/LoginPage";
import { PatientConsultationPage } from "../../pageobject/Patient/PatientConsultation";
import { PatientPage } from "../../pageobject/Patient/PatientCreation";
import PatientPrescription from "../../pageobject/Patient/PatientPrescription";

describe("Patient", () => {
const loginPage = new LoginPage();
const patientPage = new PatientPage();
const patientConsultationPage = new PatientConsultationPage();
const patientPrescription = new PatientPrescription();

before(() => {
loginPage.loginAsDisctrictAdmin();
Expand Down Expand Up @@ -45,19 +43,6 @@ describe("Patient", () => {
cy.verifyNotification("Note added successfully");
});

it("Edit prescription for an already created patient", () => {
patientPage.visitPatient("Dummy Patient 4");
patientPrescription.visitEditPrescriptionPage();
patientPrescription.clickAddPrescription();
patientPrescription.interceptMedibase();
patientPrescription.selectMedicinebox();
patientPrescription.selectMedicine("DOLO");
patientPrescription.enterDosage("4");
patientPrescription.selectDosageFrequency("Twice daily");
cy.submitButton("Submit");
cy.verifyNotification("Medicine prescribed");
});

afterEach(() => {
cy.saveLocalStorage();
});
Expand Down
49 changes: 49 additions & 0 deletions cypress/e2e/patient_spec/patient_prescription.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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();

describe("Patient Medicine Administration", () => {
before(() => {
loginPage.loginAsDisctrictAdmin();
cy.saveLocalStorage();
});

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

it("Add a new medicine for a patient and verify the duplicate medicine validation", () => {
patientPage.visitPatient("Dummy Patient 4");
patientPrescription.visitMedicineTab();
patientPrescription.clickAddPrescription();
patientPrescription.interceptMedibase();
patientPrescription.selectMedicinebox();
patientPrescription.selectMedicine("DOLO");
patientPrescription.enterDosage("4");
patientPrescription.selectDosageFrequency("Twice daily");
cy.submitButton("Submit");
cy.verifyNotification("Medicine prescribed");
cy.closeNotification();
// verify the duplicate medicine error message
patientPrescription.clickAddPrescription();
patientPrescription.interceptMedibase();
patientPrescription.selectMedicinebox();
patientPrescription.selectMedicine("DOLO");
patientPrescription.enterDosage("4");
patientPrescription.selectDosageFrequency("Twice daily");
cy.submitButton("Submit");
cy.verifyNotification(
"Medicine - This medicine is already prescribed to this patient. Please discontinue the existing prescription to prescribe again.",
);
});

afterEach(() => {
cy.saveLocalStorage();
});
});
10 changes: 5 additions & 5 deletions cypress/pageobject/Patient/PatientPrescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ export class PatientPrescription {
selectMedicine(medicine: string) {
cy.searchAndSelectOption(
"div#medicine_object input[placeholder='Select'][role='combobox']",
medicine
medicine,
);
}

selectMedicinebox() {
cy.get(
"div#medicine_object input[placeholder='Select'][role='combobox']"
"div#medicine_object input[placeholder='Select'][role='combobox']",
).click();
}

Expand All @@ -37,21 +37,21 @@ export class PatientPrescription {
clickReturnToDashboard() {
cy.verifyAndClickElement(
"[data-testid='return-to-patient-dashboard']",
"Return to Patient Dashboard"
"Return to Patient Dashboard",
);
}

discontinuePreviousPrescription() {
cy.intercept(
"POST",
"**/api/v1/consultation/*/prescriptions/*/discontinue/"
"**/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);
}

visitEditPrescriptionPage() {
visitMedicineTab() {
cy.get("#consultation_tab_nav").scrollIntoView();
cy.get("#consultation_tab_nav").contains("Medicines").click();
cy.get("a[href='prescriptions']").first().click();
Expand Down

0 comments on commit ca4040e

Please sign in to comment.