@openmrs/esm-patient-common-lib 7.0.2-pre.3834 → 7.0.2-pre.3855
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrs/esm-patient-common-lib",
|
|
3
|
-
"version": "7.0.2-pre.
|
|
3
|
+
"version": "7.0.2-pre.3855",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "Library for common patient chart components",
|
|
6
6
|
"browser": "dist/openmrs-esm-patient-common-lib.js",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"react": "18.x",
|
|
39
39
|
"single-spa": "6.x"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "24d36b0f125ad2a5220058375f232e6ad029a3b9"
|
|
42
42
|
}
|
package/src/orders/postOrders.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { openmrsFetch } from '@openmrs/esm-framework';
|
|
1
|
+
import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
|
|
2
2
|
import { getPatientUuidFromUrl } from '../get-patient-uuid-from-url';
|
|
3
3
|
import { type OrderBasketStore, orderBasketStore } from './store';
|
|
4
4
|
import { type OrderBasketItem, type OrderPost } from './types';
|
|
@@ -26,7 +26,7 @@ export async function postOrders(encounterUuid: string, abortController: AbortCo
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
function postOrder(body: OrderPost, abortController?: AbortController) {
|
|
29
|
-
return openmrsFetch(
|
|
29
|
+
return openmrsFetch(`${restBaseUrl}/order`, {
|
|
30
30
|
method: 'POST',
|
|
31
31
|
signal: abortController?.signal,
|
|
32
32
|
headers: { 'Content-Type': 'application/json' },
|
package/src/orders/types.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type OpenmrsResource } from '@openmrs/esm-framework';
|
|
2
2
|
|
|
3
|
+
export type OrderAction = 'NEW' | 'REVISE' | 'DISCONTINUE' | 'RENEW';
|
|
4
|
+
|
|
3
5
|
export interface OrderBasketItem {
|
|
4
|
-
action
|
|
6
|
+
action?: OrderAction;
|
|
5
7
|
display: string;
|
|
6
8
|
uuid?: string;
|
|
7
9
|
orderer?: string;
|
|
@@ -19,7 +21,7 @@ export interface OrderBasketItem {
|
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
export interface OrderPost {
|
|
22
|
-
action?:
|
|
24
|
+
action?: OrderAction;
|
|
23
25
|
patient?: string;
|
|
24
26
|
careSetting?: string;
|
|
25
27
|
orderer?: string;
|
|
@@ -53,7 +55,7 @@ export interface PatientOrderFetchResponse {
|
|
|
53
55
|
|
|
54
56
|
export interface Order {
|
|
55
57
|
uuid: string;
|
|
56
|
-
action:
|
|
58
|
+
action: OrderAction;
|
|
57
59
|
asNeeded: boolean;
|
|
58
60
|
asNeededCondition?: string;
|
|
59
61
|
autoExpireDate: string;
|
|
@@ -122,6 +124,7 @@ export interface Order {
|
|
|
122
124
|
clinicalHistory: string;
|
|
123
125
|
numberOfRepeats: string;
|
|
124
126
|
type: string;
|
|
127
|
+
labReferenceNumber?: string;
|
|
125
128
|
}
|
|
126
129
|
|
|
127
130
|
export interface OrderTypeFetchResponse {
|
|
@@ -145,3 +148,39 @@ export interface Drug {
|
|
|
145
148
|
}
|
|
146
149
|
|
|
147
150
|
export type PostDataPrepFunction = (order: OrderBasketItem, patientUuid: string, encounterUuid: string) => OrderPost;
|
|
151
|
+
|
|
152
|
+
// Adopted from @openmrs/esm-patient-medications-app package. We should consider maintaining a single shared types file
|
|
153
|
+
export interface DrugOrderBasketItem extends OrderBasketItem {
|
|
154
|
+
drug: Drug;
|
|
155
|
+
unit: any;
|
|
156
|
+
commonMedicationName: string;
|
|
157
|
+
dosage: number;
|
|
158
|
+
frequency: any;
|
|
159
|
+
route: any;
|
|
160
|
+
quantityUnits: any;
|
|
161
|
+
patientInstructions: string;
|
|
162
|
+
asNeeded: boolean;
|
|
163
|
+
asNeededCondition: string;
|
|
164
|
+
startDate: Date | string;
|
|
165
|
+
durationUnit: any;
|
|
166
|
+
duration: number | null;
|
|
167
|
+
pillsDispensed: number;
|
|
168
|
+
numRefills: number;
|
|
169
|
+
indication: string;
|
|
170
|
+
isFreeTextDosage: boolean;
|
|
171
|
+
freeTextDosage: string;
|
|
172
|
+
previousOrder?: string;
|
|
173
|
+
template?: any;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export interface LabOrderBasketItem extends OrderBasketItem {
|
|
177
|
+
testType?: {
|
|
178
|
+
label: string;
|
|
179
|
+
conceptUuid: string;
|
|
180
|
+
};
|
|
181
|
+
labReferenceNumber?: string;
|
|
182
|
+
urgency?: string;
|
|
183
|
+
instructions?: string;
|
|
184
|
+
previousOrder?: string;
|
|
185
|
+
orderReason?: string;
|
|
186
|
+
}
|
package/src/orders/useOrders.ts
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import useSWR, {
|
|
2
|
-
import { type FetchResponse, openmrsFetch } from '@openmrs/esm-framework';
|
|
1
|
+
import useSWR, { useSWRConfig } from 'swr';
|
|
2
|
+
import { type FetchResponse, openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
|
|
3
3
|
import { useCallback, useMemo } from 'react';
|
|
4
4
|
import { type OrderTypeFetchResponse, type PatientOrderFetchResponse } from '@openmrs/esm-patient-common-lib';
|
|
5
5
|
|
|
6
6
|
export const careSettingUuid = '6f0c9a92-6f24-11e3-af88-005056821db0';
|
|
7
7
|
|
|
8
|
-
export
|
|
9
|
-
|
|
8
|
+
export const drugCustomRepresentation =
|
|
9
|
+
'custom:(uuid,dosingType,orderNumber,accessionNumber,' +
|
|
10
|
+
'patient:ref,action,careSetting:ref,previousOrder:ref,dateActivated,scheduledDate,dateStopped,autoExpireDate,' +
|
|
11
|
+
'orderType:ref,encounter:ref,orderer:(uuid,display,person:(display)),orderReason,orderReasonNonCoded,orderType,urgency,instructions,' +
|
|
12
|
+
'commentToFulfiller,drug:(uuid,display,strength,dosageForm:(display,uuid),concept),dose,doseUnits:ref,' +
|
|
13
|
+
'frequency:ref,asNeeded,asNeededCondition,quantity,quantityUnits:ref,numRefills,dosingInstructions,' +
|
|
14
|
+
'duration,durationUnits:ref,route:ref,brandName,dispenseAsWritten)';
|
|
15
|
+
|
|
16
|
+
export function usePatientOrders(patientUuid: string, status?: 'ACTIVE' | 'any', orderType?: string) {
|
|
17
|
+
const { mutate } = useSWRConfig();
|
|
18
|
+
const baseOrdersUrl = `${restBaseUrl}/order?patient=${patientUuid}&careSetting=${careSettingUuid}&v=full&status=${status}`;
|
|
10
19
|
const ordersUrl = orderType ? `${baseOrdersUrl}&orderType=${orderType}` : baseOrdersUrl;
|
|
11
20
|
|
|
12
21
|
const { data, error, isLoading, isValidating } = useSWR<FetchResponse<PatientOrderFetchResponse>, Error>(
|
|
@@ -15,7 +24,10 @@ export function usePatientOrders(patientUuid: string, status: 'ACTIVE' | 'any',
|
|
|
15
24
|
);
|
|
16
25
|
|
|
17
26
|
const mutateOrders = useCallback(
|
|
18
|
-
() =>
|
|
27
|
+
() =>
|
|
28
|
+
mutate((key) => {
|
|
29
|
+
return typeof key === 'string' && key.startsWith(`${restBaseUrl}/order?patient=${patientUuid}`);
|
|
30
|
+
}, data),
|
|
19
31
|
[patientUuid],
|
|
20
32
|
);
|
|
21
33
|
|
|
@@ -37,7 +49,7 @@ export function usePatientOrders(patientUuid: string, status: 'ACTIVE' | 'any',
|
|
|
37
49
|
}
|
|
38
50
|
|
|
39
51
|
export function useOrderTypes() {
|
|
40
|
-
const orderTypesUrl =
|
|
52
|
+
const orderTypesUrl = `${restBaseUrl}/ordertype`;
|
|
41
53
|
const { data, error, isLoading, isValidating } = useSWR<FetchResponse<OrderTypeFetchResponse>, Error>(
|
|
42
54
|
orderTypesUrl,
|
|
43
55
|
openmrsFetch,
|
|
@@ -50,3 +62,7 @@ export function useOrderTypes() {
|
|
|
50
62
|
isValidating,
|
|
51
63
|
};
|
|
52
64
|
}
|
|
65
|
+
|
|
66
|
+
export function getDrugOrderByUuid(orderUuid: string) {
|
|
67
|
+
return openmrsFetch(`${restBaseUrl}/order/${orderUuid}?v=${drugCustomRepresentation}`);
|
|
68
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import useSWR from 'swr';
|
|
2
|
-
import { openmrsFetch } from '@openmrs/esm-framework';
|
|
2
|
+
import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
4
|
import { type PatientProgram } from '../types';
|
|
5
5
|
import uniqBy from 'lodash-es/uniqBy';
|
|
@@ -7,7 +7,7 @@ const customRepresentation = `custom:(uuid,display,program,dateEnrolled,dateComp
|
|
|
7
7
|
|
|
8
8
|
export const useActivePatientEnrollment = (patientUuid: string) => {
|
|
9
9
|
const { data, error, isLoading } = useSWR<{ data: { results: Array<PatientProgram> } }>(
|
|
10
|
-
|
|
10
|
+
`${restBaseUrl}/programenrollment?patient=${patientUuid}&v=${customRepresentation}`,
|
|
11
11
|
openmrsFetch,
|
|
12
12
|
);
|
|
13
13
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import useSWRImmutable from 'swr/immutable';
|
|
2
|
-
import { type FetchResponse, openmrsFetch } from '@openmrs/esm-framework';
|
|
2
|
+
import { type FetchResponse, openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
4
|
|
|
5
5
|
export function useSystemVisitSetting() {
|
|
6
6
|
const { data, isLoading, error } = useSWRImmutable<FetchResponse<{ value: 'true' | 'false' }>, Error>(
|
|
7
|
-
|
|
7
|
+
`${restBaseUrl}/systemsetting/visits.enabled?v=custom:(value)`,
|
|
8
8
|
openmrsFetch,
|
|
9
9
|
);
|
|
10
10
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import useSWRImmutable from 'swr/immutable';
|
|
2
|
-
import { openmrsFetch } from '@openmrs/esm-framework';
|
|
2
|
+
import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
|
|
3
3
|
|
|
4
4
|
export function useVitalsConceptMetadata() {
|
|
5
5
|
const customRepresentation =
|
|
6
6
|
'custom:(setMembers:(uuid,display,hiNormal,hiAbsolute,hiCritical,lowNormal,lowAbsolute,lowCritical,units))';
|
|
7
7
|
|
|
8
|
-
const apiUrl =
|
|
8
|
+
const apiUrl = `${restBaseUrl}/concept/?q=VITALS SIGNS&v=${customRepresentation}`;
|
|
9
9
|
|
|
10
10
|
const { data, error, isLoading } = useSWRImmutable<{ data: VitalsConceptMetadataResponse }, Error>(
|
|
11
11
|
apiUrl,
|