@openmrs/esm-patient-common-lib 8.2.1-pre.5761 → 8.2.1-pre.5783
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/orders/useOrders.ts +5 -4
package/package.json
CHANGED
package/src/orders/useOrders.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { useCallback, useMemo } from 'react';
|
|
1
2
|
import useSWR, { useSWRConfig } from 'swr';
|
|
2
3
|
import { type FetchResponse, openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
|
|
3
|
-
import { useCallback, useMemo } from 'react';
|
|
4
4
|
import { type OrderTypeFetchResponse, type PatientOrderFetchResponse } from '@openmrs/esm-patient-common-lib';
|
|
5
5
|
|
|
6
|
+
export type Status = 'ACTIVE' | 'any';
|
|
6
7
|
export const careSettingUuid = '6f0c9a92-6f24-11e3-af88-005056821db0';
|
|
7
8
|
|
|
8
9
|
export const drugCustomRepresentation =
|
|
@@ -13,7 +14,7 @@ export const drugCustomRepresentation =
|
|
|
13
14
|
'frequency:ref,asNeeded,asNeededCondition,quantity,quantityUnits:ref,numRefills,dosingInstructions,' +
|
|
14
15
|
'duration,durationUnits:ref,route:ref,brandName,dispenseAsWritten)';
|
|
15
16
|
|
|
16
|
-
export function usePatientOrders(patientUuid: string, status?:
|
|
17
|
+
export function usePatientOrders(patientUuid: string, status?: Status, orderType?: string) {
|
|
17
18
|
const { mutate } = useSWRConfig();
|
|
18
19
|
const baseOrdersUrl = `${restBaseUrl}/order?patient=${patientUuid}&careSetting=${careSettingUuid}&v=full&status=${status}`;
|
|
19
20
|
const ordersUrl = orderType ? `${baseOrdersUrl}&orderType=${orderType}` : baseOrdersUrl;
|
|
@@ -26,7 +27,7 @@ export function usePatientOrders(patientUuid: string, status?: 'ACTIVE' | 'any',
|
|
|
26
27
|
const mutateOrders = useCallback(
|
|
27
28
|
() =>
|
|
28
29
|
mutate((key) => typeof key === 'string' && key.startsWith(`${restBaseUrl}/order?patient=${patientUuid}`), data),
|
|
29
|
-
[
|
|
30
|
+
[data, mutate, patientUuid],
|
|
30
31
|
);
|
|
31
32
|
|
|
32
33
|
const orders = useMemo(
|
|
@@ -54,7 +55,7 @@ export function useOrderTypes() {
|
|
|
54
55
|
);
|
|
55
56
|
|
|
56
57
|
return {
|
|
57
|
-
data: data?.data?.results,
|
|
58
|
+
data: data?.data?.results ?? null,
|
|
58
59
|
error,
|
|
59
60
|
isLoading,
|
|
60
61
|
isValidating,
|