Skip to content

Commit

Permalink
Merge branch 'develop' into fix-ohcnetwork#7333
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 authored Apr 2, 2024
2 parents f1d83c0 + e305049 commit 7766a62
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 111 deletions.
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 @@ -35,7 +35,7 @@ describe("Patient Consultation in multiple combination", () => {
const procedureName = "Procedure No 1";
const patientWeight = "70";
const patientHeight = "170";
const medicineOne = "DOLO";
const medicineOne = "DOLOLUP";
const patientIpNumber = Math.random().toString(36).substring(7);

before(() => {
Expand Down Expand Up @@ -99,13 +99,13 @@ describe("Patient Consultation in multiple combination", () => {
cy.verifyNotification("Consultation created successfully");
// Below code for the prescription module only present while creating a new consultation
patientPrescription.clickAddPrescription();
patientPrescription.interceptMediaBase();
patientPrescription.interceptMedibase();
patientPrescription.selectMedicinebox();
patientPrescription.waitForMediabaseStatusCode();
patientPrescription.selectMedicine(medicineOne);
patientPrescription.enterDosage("3");
patientPrescription.selectDosageFrequency("Twice daily");
cy.submitButton("Submit");
cy.wait(2000);
cy.verifyNotification("Medicine prescribed");
patientPrescription.clickReturnToDashboard();
// Verify the data's across the dashboard
Expand Down
3 changes: 1 addition & 2 deletions cypress/e2e/patient_spec/patient_manage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ describe("Patient", () => {
patientPage.visitPatient("Dummy Patient 4");
patientPrescription.visitEditPrescriptionPage();
patientPrescription.clickAddPrescription();
patientPrescription.interceptMediaBase();
patientPrescription.interceptMedibase();
patientPrescription.selectMedicinebox();
patientPrescription.waitForMediabaseStatusCode();
patientPrescription.selectMedicine("DOLO");
patientPrescription.enterDosage("4");
patientPrescription.selectDosageFrequency("Twice daily");
Expand Down
8 changes: 4 additions & 4 deletions cypress/pageobject/Patient/PatientPrescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export class PatientPrescription {
.click();
}

interceptMediaBase() {
cy.intercept("GET", "**/api/v1/medibase/**").as("getMediaBase");
interceptMedibase() {
cy.intercept("GET", "**/api/v1/medibase/**").as("getMedibase");
}

selectMedicine(medicine: string) {
Expand All @@ -22,8 +22,8 @@ export class PatientPrescription {
).click();
}

waitForMediabaseStatusCode() {
cy.wait("@getMediaBase").its("response.statusCode").should("eq", 200);
waitForMedibaseStatusCode() {
cy.wait("@getMedibase").its("response.statusCode").should("eq", 200);
}

enterDosage(doseAmount: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import {
CreateDiagnosis,
ICD11DiagnosisModel,
} from "../types";
import { useAsyncOptions } from "../../../Common/hooks/useAsyncOptions";
import { listICD11Diagnosis } from "../../../Redux/actions";
import ConditionVerificationStatusMenu from "../ConditionVerificationStatusMenu";
import { classNames } from "../../../Utils/utils";
import { classNames, mergeQueryOptions } from "../../../Utils/utils";
import useQuery from "../../../Utils/request/useQuery";
import routes from "../../../Redux/api";

interface AddICD11DiagnosisProps {
className?: string;
Expand All @@ -24,8 +24,7 @@ export default function AddICD11Diagnosis(props: AddICD11DiagnosisProps) {
const [adding, setAdding] = useState(false);
const hasError = !!props.disallowed.find((d) => d?.id === selected?.id);

const { fetchOptions, isLoading, options } =
useAsyncOptions<ICD11DiagnosisModel>("id");
const { data, loading, refetch } = useQuery(routes.listICD11Diagnosis);

const handleAdd = async (status: CreateDiagnosis["verification_status"]) => {
if (!selected) return;
Expand Down Expand Up @@ -56,11 +55,15 @@ export default function AddICD11Diagnosis(props: AddICD11DiagnosisProps) {
placeholder={t("search_icd11_placeholder")}
value={selected}
onChange={(e) => setSelected(e.value)}
options={options(selected ? [selected] : undefined)}
options={mergeQueryOptions(
selected ? [selected] : [],
data ?? [],
(obj) => obj.id
)}
optionLabel={(option) => option.label}
optionValue={(option) => option}
onQuery={(query) => fetchOptions(listICD11Diagnosis({ query }))}
isLoading={isLoading}
onQuery={(query) => refetch({ query: { query } })}
isLoading={loading}
error={hasError ? t("diagnosis_already_added") : undefined}
/>
<ConditionVerificationStatusMenu
Expand Down
23 changes: 13 additions & 10 deletions src/Components/Medicine/MedibaseAutocompleteFormField.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
import { useEffect, useState } from "react";
import { useState } from "react";
import Switch from "../../CAREUI/interactive/Switch";
import { useAsyncOptions } from "../../Common/hooks/useAsyncOptions";
import { listMedibaseMedicines } from "../../Redux/actions";
import { Autocomplete } from "../Form/FormFields/Autocomplete";
import FormField from "../Form/FormFields/FormField";
import {
FormFieldBaseProps,
useFormFieldPropsResolver,
} from "../Form/FormFields/Utils";
import { MedibaseMedicine } from "./models";
import useQuery from "../../Utils/request/useQuery";
import routes from "../../Redux/api";
import { mergeQueryOptions } from "../../Utils/utils";

export default function MedibaseAutocompleteFormField(
props: FormFieldBaseProps<MedibaseMedicine>
) {
const field = useFormFieldPropsResolver(props);
const { isLoading, options, fetchOptions } =
useAsyncOptions<MedibaseMedicine>("id");

const [query, setQuery] = useState("");
const [type, setType] = useState<MedibaseMedicine["type"]>();

useEffect(() => {
fetchOptions(listMedibaseMedicines(query, type));
}, [query, type]);
const { data, loading } = useQuery(routes.listMedibaseMedicines, {
query: { query, type },
});

return (
<FormField
Expand All @@ -49,7 +48,11 @@ export default function MedibaseAutocompleteFormField(
value={field.value}
required
onChange={field.handleChange}
options={options(field.value && !query && [field.value])}
options={mergeQueryOptions(
field.value && !query ? [field.value] : [],
data ?? [],
(obj) => obj.id
)}
optionLabel={(option) => option.name.toUpperCase()}
optionDescription={(option) => <OptionDescription medicine={option} />}
optionValue={(option) => option}
Expand All @@ -61,7 +64,7 @@ export default function MedibaseAutocompleteFormField(
)
}
onQuery={setQuery}
isLoading={isLoading}
isLoading={loading}
/>
</FormField>
);
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Resource/ResourceDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default function ResourceDetails(props: { id: string }) {
const ApprovalLetter = (data: any) => {
return (
<div id="section-to-print" className="print bg-white">
<div className="mx-20 p-4">
<div className="mx-4 p-2 lg:mx-20 ">
<div className="mt-6 text-center text-xl font-bold">
APPROVAL LETTER
</div>
Expand Down
82 changes: 0 additions & 82 deletions src/Redux/actions.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import { HCXClaimModel, HCXPolicyModel } from "../Components/HCX/models";
import { MedibaseMedicine } from "../Components/Medicine/models";
import { fireRequest } from "./fireRequest";

// Facility
export const getUserList = (params: object, key?: string) => {
return fireRequest("userList", [], params, null, key);
};

export const getAnyFacility = (id: number | string, key?: string) => {
return fireRequest("getAnyFacility", [], {}, { id: id }, key);
};

export const getFacilityUsers = (id: string, params?: object) => {
return fireRequest(
"getFacilityUsers",
Expand Down Expand Up @@ -68,9 +63,6 @@ export const getAllPatient = (params: object, altKey: string) => {
export const getPatient = (pathParam: object) => {
return fireRequest("getPatient", [], {}, pathParam);
};
export const patchPatient = (params: object, pathParam: object) => {
return fireRequest("patchPatient", [], params, pathParam);
};

// District/State/Local body/ward
export const getDistrictByName = (params: object) => {
Expand Down Expand Up @@ -145,80 +137,6 @@ export const externalResultList = (params: object, altKey: string) => {
return fireRequest("externalResultList", [], params, null, altKey);
};

export const externalResult = (pathParam: object) => {
return fireRequest("externalResult", [], {}, pathParam);
};

// Investigation

export const listInvestigations = (
params: object,
altKey = "listInvestigations"
) => {
return fireRequest("listInvestigations", [], params, null, altKey);
};

export const listInvestigationGroups = (params: object) => {
return fireRequest("listInvestigationGroups", [], params);
};

export const createInvestigation = (
params: object,
consultation_external_id: string
) => {
return fireRequest("createInvestigation", [], params, {
consultation_external_id: consultation_external_id,
});
};

export const getInvestigationSessions = (
params: object,
consultation_external_id: string
) => {
return fireRequest("getInvestigationSessions", [], params, {
consultation_external_id: consultation_external_id,
});
};

export const getInvestigation = (
params: object,
consultation_external_id: string
) => {
return fireRequest("getInvestigation", [], params, {
consultation_external_id: consultation_external_id,
});
};

export const getPatientInvestigation = (
params: object,
patient_external_id: string
) => {
return fireRequest("getPatientInvestigation", [], params, {
patient_external_id: patient_external_id,
});
};

export const editInvestigation = (
params: object,
consultation_external_id: string
) => {
return fireRequest("editInvestigation", [], params, {
consultation_external_id: consultation_external_id,
});
};

// ICD11
export const listICD11Diagnosis = (params: object) => {
return fireRequest("listICD11Diagnosis", [], params, null);
};
// Medibase
export const listMedibaseMedicines = (
query: string,
type?: MedibaseMedicine["type"]
) => {
return fireRequest("listMedibaseMedicines", [], { query, type });
};

// Resource
export const downloadResourceRequests = (params: object) => {
return fireRequest("downloadResourceRequests", [], params);
Expand Down
3 changes: 2 additions & 1 deletion src/Redux/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ import {
StateModel,
WardModel,
} from "../Components/Facility/models";
import { Prescription } from "../Components/Medicine/models";
import { MedibaseMedicine, Prescription } from "../Components/Medicine/models";
import {
NotificationData,
PNconfigData,
Expand Down Expand Up @@ -1120,6 +1120,7 @@ const routes = {
// Medibase
listMedibaseMedicines: {
path: "/api/v1/medibase/",
TRes: Type<MedibaseMedicine[]>(),
},

// Resource
Expand Down

0 comments on commit 7766a62

Please sign in to comment.