Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

O3-1713: Order basket drug search implemented with SWR #922

Merged
merged 16 commits into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
439 changes: 155 additions & 284 deletions __mocks__/medication.mock.ts

Large diffs are not rendered by default.

25 changes: 1 addition & 24 deletions packages/esm-patient-medications-app/src/api/api.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import useSWR from 'swr';
import useSWRImmutable from 'swr/immutable';
import {
FetchResponse,
openmrsFetch,
Session,
useConfig,
OpenmrsResource,
showNotification,
useSession,
} from '@openmrs/esm-framework';
import { FetchResponse, openmrsFetch, Session, useConfig, OpenmrsResource, useSession } from '@openmrs/esm-framework';
import { OrderPost, PatientMedicationFetchResponse } from '../types/order';
import { ConfigObject } from '../config-schema';
import { useEffect, useMemo } from 'react';
Expand Down Expand Up @@ -52,15 +44,6 @@ export function getPatientEncounterId(patientUuid: string, abortController: Abor
});
}

export function getDrugByName(drugName: string, abortController?: AbortController) {
return openmrsFetch(
`/ws/rest/v1/drug?q=${drugName}&v=custom:(uuid,display,name,strength,dosageForm:(display,uuid),concept)`,
{
signal: abortController?.signal,
},
);
}

export function useDurationUnits(durationUnitsConcept) {
const url = `/ws/rest/v1/concept/${durationUnitsConcept}?v=custom:(answers:(uuid,display))`;
const { data, error } = useSWRImmutable<FetchResponse<{ answers: Array<OpenmrsResource> }>, Error>(
Expand Down Expand Up @@ -89,12 +72,6 @@ export function getMedicationByUuid(abortController: AbortController, orderUuid:
);
}

export function getOrderTemplatesByDrug(drugUuid: string, abortController?: AbortController) {
return openmrsFetch(`/ws/rest/v1/ordertemplates/orderTemplate?drug=${drugUuid}&retired=${false}`, {
signal: abortController?.signal,
});
}

export function useCurrentOrderBasketEncounter(patientUuid: string) {
const [nowDateString] = new Date().toISOString().split('T');
const sessionObject = useSession();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Drug } from '../types/order';

export interface DrugOrderTemplate {
uuid: string;
name: string;
drug: Drug;
template: OrderTemplate;
Expand Down
154 changes: 0 additions & 154 deletions packages/esm-patient-medications-app/src/order-basket/drug-search.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ export default function MedicationOrderForm({ initialOrderBasketItem, onSign, on
dosage: value ? parseFloat(value) : 0,
});
}}
min={0}
hideSteppers
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ export default function OrderBasketItemTile({ orderBasketItem, onItemClick, onRe
<br />
{orderBasketItem.isFreeTextDosage ? (
<>
<span className={styles.drugName}>{orderBasketItem.drug.concept.display}</span>
<span className={styles.drugName}>{orderBasketItem.drug?.display}</span>
<span className={styles.dosageInfo}> &mdash; {orderBasketItem.freeTextDosage}</span>
</>
) : (
<>
<span className={styles.drugName}>{orderBasketItem.drug.concept.display}</span>
<span className={styles.drugName}>{orderBasketItem.drug?.display}</span>
<span className={styles.dosageInfo}>
{' '}
&mdash; {orderBasketItem.drug.strength} &mdash; {orderBasketItem.drug.dosageForm.display}
Expand Down

This file was deleted.

Loading