Skip to content

Commit

Permalink
fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
shivankacker committed May 22, 2024
2 parents 0d82bcd + a9530a9 commit 2e97a63
Show file tree
Hide file tree
Showing 57 changed files with 1,125 additions and 1,030 deletions.
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@

## Reporting a Vulnerability

Please create a ticket at https://support.coronasafe.network
Please create an issue at https://github.com/coronasafe/care_fe/issues/new
6 changes: 3 additions & 3 deletions cypress/e2e/patient_spec/patient_consultation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe("Patient Consultation in multiple combination", () => {
);
patientConsultationPage.typePatientWeight(patientWeight);
patientConsultationPage.typePatientHeight(patientHeight);
patientConsultationPage.selectPatientCategory("Stable");
patientConsultationPage.selectPatientCategory("Mild");
// icd 11 - 4 diagnosis with one principal
patientConsultationPage.selectPatientDiagnosis(
diagnosis1,
Expand Down Expand Up @@ -236,7 +236,7 @@ describe("Patient Consultation in multiple combination", () => {
// Asymptomatic
cy.searchAndSelectOption("#symptoms", "ASYMPTOMATIC");
// Abnormal category
patientConsultationPage.selectPatientCategory("Abnormal");
patientConsultationPage.selectPatientCategory("Moderate");
patientConsultationPage.selectPatientSuggestion("Domiciliary Care");
// one ICD-11 diagnosis
patientConsultationPage.selectPatientDiagnosis(
Expand Down Expand Up @@ -299,7 +299,7 @@ describe("Patient Consultation in multiple combination", () => {
"SORE THROAT",
]);
// Stable category
patientConsultationPage.selectPatientCategory("Stable");
patientConsultationPage.selectPatientCategory("Mild");
// Date of symptoms
patientConsultationPage.selectSymptomsDate(
"#symptoms_onset_date",
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/patient_spec/patient_logupdate.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => {
const patientPage = new PatientPage();
const patientLogupdate = new PatientLogupdate();
const domicilaryPatient = "Dummy Patient 11";
const patientCategory = "Abnormal";
const patientCategory = "Moderate";
const additionalSymptoms = "ASYMPTOMATIC";
const physicalExamination = "physical examination details";
const otherExamination = "Other";
Expand Down
56 changes: 50 additions & 6 deletions cypress/e2e/patient_spec/patient_prescription.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import { PatientPage } from "../../pageobject/Patient/PatientCreation";
const patientPrescription = new PatientPrescription();
const loginPage = new LoginPage();
const patientPage = new PatientPage();
const medicineName = "DOLO";
const medicineBaseDosage = "4";
const medicineTargetDosage = "9";
const medicineFrequency = "Twice daily";
const medicineAdministerNote = "Medicine Administration Note";

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

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.clickTitratedDosage();
patientPrescription.enterDosage(medicineBaseDosage);
patientPrescription.enterTargetDosage(medicineTargetDosage);
patientPrescription.selectDosageFrequency(medicineFrequency);
cy.submitButton("Submit");
cy.verifyNotification("Medicine prescribed");
cy.closeNotification();
// Administer the medicine in edit form
patientPrescription.clickAdministerButton();
patientPrescription.enterAdministerDosage(medicineBaseDosage);
patientPrescription.enterAdministerNotes(medicineAdministerNote);
cy.submitButton("Administer Medicine");
cy.verifyNotification("Medicine(s) administered");
cy.closeNotification();
// Verify the Reflection on the Medicine
cy.verifyContentPresence("#medicine-preview", [
medicineName,
medicineBaseDosage,
medicineTargetDosage,
]);
patientPrescription.clickReturnToDashboard();
// Go to medicine tab and administer it again
patientPrescription.visitMedicineTab();
cy.verifyAndClickElement("#0", medicineName);
cy.submitButton("Administer");
patientPrescription.enterAdministerDosage(medicineBaseDosage);
cy.submitButton("Administer Medicine");
cy.verifyNotification("Medicine(s) administered");
});

it("Add a new medicine for a patient and verify the duplicate medicine validation", () => {
patientPage.visitPatient("Dummy Patient 4");
patientPrescription.visitMedicineTab();
patientPrescription.visitEditPrescription();
patientPrescription.clickAddPrescription();
patientPrescription.interceptMedibase();
patientPrescription.selectMedicinebox();
patientPrescription.selectMedicine("DOLO");
patientPrescription.enterDosage("4");
patientPrescription.selectDosageFrequency("Twice daily");
patientPrescription.selectMedicine(medicineName);
patientPrescription.enterDosage(medicineBaseDosage);
patientPrescription.selectDosageFrequency(medicineFrequency);
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");
patientPrescription.selectMedicine(medicineName);
patientPrescription.enterDosage(medicineBaseDosage);
patientPrescription.selectDosageFrequency(medicineFrequency);
cy.submitButton("Submit");
cy.verifyNotification(
"Medicine - This medicine is already prescribed to this patient. Please discontinue the existing prescription to prescribe again.",
Expand Down
7 changes: 2 additions & 5 deletions cypress/e2e/shifting_spec/filter.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe("Shifting section filter", () => {
shiftingPage.filterByFacility(
"Dummy Shifting",
"Dummy Shifting",
"District"
"District",
);

shiftingPage.facilityAssignedBadge().should("exist");
Expand All @@ -32,13 +32,10 @@ describe("Shifting section filter", () => {
"ASC Created Date",
"yes",
"yes",
"POSITIVE",
"no",
"MODERATE",
"9999999999"
"9999999999",
);

shiftingPage.diseaseStatusBadge().should("exist");
shiftingPage.orderingBadge().should("exist");
shiftingPage.breathlessnessLevelBadge().should("exist");
shiftingPage.phoneNumberBadge().should("exist");
Expand Down
34 changes: 30 additions & 4 deletions cypress/pageobject/Patient/PatientPrescription.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
export class PatientPrescription {
clickAddPrescription() {
cy.contains("button", "Add Prescription Medication")
.should("be.visible")
.click();
cy.get("#add-prescription").scrollIntoView();
cy.verifyAndClickElement(
"#add-prescription",
"Add Prescription Medication",
);
}

interceptMedibase() {
Expand All @@ -16,6 +18,15 @@ export class PatientPrescription {
);
}

clickTitratedDosage() {
cy.get("#titrated-dosage").click();
}

clickAdministerButton() {
cy.get("#administer-medicine").should("be.visible");
cy.verifyAndClickElement("#administer-medicine", "Administer");
}

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

enterAdministerDosage(dosage: string) {
cy.get("#dosage").type(dosage);
}

enterAdministerNotes(notes: string) {
cy.get("#administration_notes").type(notes);
}

enterTargetDosage(targetDosage: string) {
cy.get("#target_dosage").type(targetDosage, { force: true });
}

selectDosageFrequency(frequency: string) {
cy.clickAndSelectOption("#frequency", frequency);
}
Expand All @@ -54,7 +77,10 @@ export class PatientPrescription {
visitMedicineTab() {
cy.get("#consultation_tab_nav").scrollIntoView();
cy.get("#consultation_tab_nav").contains("Medicines").click();
cy.get("a[href='prescriptions']").first().click();
}

visitEditPrescription() {
cy.get("#edit-prescription").click();
}
}
export default PatientPrescription;
18 changes: 3 additions & 15 deletions cypress/pageobject/Shift/ShiftFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ class ShiftingPage {
return cy.get("#is-up-shift");
}

diseaseStatusInput() {
return cy.get("#disease-status");
}

isAntenatalInput() {
return cy.get("#is-antenatal");
}
Expand Down Expand Up @@ -63,10 +59,6 @@ class ShiftingPage {
return cy.get("[data-testid='Current facility']");
}

diseaseStatusBadge() {
return cy.get("[data-testid='Disease status']");
}

orderingBadge() {
return cy.get("[data-testid='Ordering']");
}
Expand Down Expand Up @@ -98,7 +90,7 @@ class ShiftingPage {
filterByFacility(
origin_facility: string,
assigned_facility: string,
assigned_to: string
assigned_to: string,
) {
this.originFacilityInput().click().type(origin_facility);
cy.get("[role='option']").contains(origin_facility).click();
Expand All @@ -116,10 +108,9 @@ class ShiftingPage {
ordering: string,
emergency: string,
is_up_shift: string,
disease_status: string,
is_antenatal: string,
breathlessness_level: string,
patient_phone_number: string
patient_phone_number: string,
) {
this.orderingInput().click();
cy.get("[role='option']").contains(ordering).click();
Expand All @@ -130,9 +121,6 @@ class ShiftingPage {
this.isUpShiftInput().click();
cy.get("[role='option']").contains(is_up_shift).click();

this.diseaseStatusInput().click();
cy.get("[role='option']").contains(disease_status).click();

this.isAntenatalInput().click();
cy.get("[role='option']").contains(is_antenatal).click();

Expand All @@ -148,7 +136,7 @@ class ShiftingPage {
created_date_start: string,
created_date_end: string,
modified_date_start: string,
modified_date_end: string
modified_date_end: string,
) {
this.createdDateStartInput().click();
cy.get("[id^='headlessui-popover-panel-'] .care-l-angle-left-b")
Expand Down
20 changes: 20 additions & 0 deletions src/CAREUI/misc/AuthorizedChild.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { ReactNode } from "react";
import useAuthUser from "../../Common/hooks/useAuthUser";
import { useIsAuthorized } from "../../Common/hooks/useIsAuthorized";
import useSlug from "../../Common/hooks/useSlug";
import { AuthorizedForCB } from "../../Utils/AuthorizeFor";

interface Props {
Expand All @@ -12,3 +15,20 @@ const AuthorizedChild = (props: Props) => {
};

export default AuthorizedChild;

export const AuthorizedForConsultationRelatedActions = (props: {
children: ReactNode;
}) => {
const me = useAuthUser();
const facilityId = useSlug("facility");

if (
me.home_facility_object?.id === facilityId ||
me.user_type === "DistrictAdmin" ||
me.user_type === "StateAdmin"
) {
return props.children;
}

return null;
};
12 changes: 11 additions & 1 deletion src/CAREUI/misc/PaginatedList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createContext, useContext, useState } from "react";
import { createContext, useContext, useEffect, useState } from "react";
import { PaginatedResponse, QueryRoute } from "../../Utils/request/types";
import useQuery, { QueryOptions } from "../../Utils/request/useQuery";
import ButtonV2, {
Expand Down Expand Up @@ -33,6 +33,9 @@ function useContextualized<TItem>() {
interface Props<TItem> extends QueryOptions<PaginatedResponse<TItem>> {
route: QueryRoute<PaginatedResponse<TItem>>;
perPage?: number;
queryCB?: (
query: ReturnType<typeof useQuery<PaginatedResponse<TItem>>>,
) => void;
children: (
ctx: PaginatedListContext<TItem>,
query: ReturnType<typeof useQuery<PaginatedResponse<TItem>>>,
Expand All @@ -43,6 +46,7 @@ export default function PaginatedList<TItem extends object>({
children,
route,
perPage = DEFAULT_PER_PAGE_LIMIT,
queryCB,
...queryOptions
}: Props<TItem>) {
const [currentPage, setPage] = useState(1);
Expand All @@ -57,6 +61,12 @@ export default function PaginatedList<TItem extends object>({

const items = query.data?.results ?? [];

useEffect(() => {
if (queryCB) {
queryCB(query);
}
}, [query]);

return (
<context.Provider
value={{ ...query, items, perPage, currentPage, setPage }}
Expand Down
11 changes: 2 additions & 9 deletions src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,8 @@ export const PATIENT_CATEGORIES: {
twClass: string;
}[] = [
{ id: "Comfort", text: "Comfort Care", twClass: "patient-comfort" },
{ id: "Stable", text: "Stable", twClass: "patient-stable" },
{ id: "Moderate", text: "Abnormal", twClass: "patient-abnormal" },
{ id: "Stable", text: "Mild", twClass: "patient-stable" },
{ id: "Moderate", text: "Moderate", twClass: "patient-abnormal" },
{ id: "Critical", text: "Critical", twClass: "patient-critical" },
];

Expand Down Expand Up @@ -470,13 +470,6 @@ export const SAMPLE_FLOW_RULES = {
RECEIVED_AT_LAB: ["COMPLETED"],
};

export const DISEASE_STATUS = [
"POSITIVE",
"SUSPECTED",
"NEGATIVE",
"RECOVERED",
];

export const TEST_TYPE = [
"UNK",
"ANTIGEN",
Expand Down
1 change: 0 additions & 1 deletion src/Common/hooks/useMSEplayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ export const useMSEMediaPlayer = ({
const ws = wsRef.current;
ws.binaryType = "arraybuffer";
ws.onopen = function (_event) {
console.log("Connected to ws");
onSuccess && onSuccess(undefined);
};
ws.onmessage = function (event) {
Expand Down
Loading

0 comments on commit 2e97a63

Please sign in to comment.