@openmrs/esm-patient-orders-app 11.3.1-patch.9064 → 11.3.1-patch.9310
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/.turbo/turbo-build.log +22 -24
- package/dist/1253.js +1 -0
- package/dist/1253.js.map +1 -0
- package/dist/1268.js +2 -0
- package/dist/1268.js.map +1 -0
- package/dist/3685.js +1 -1
- package/dist/375.js +1 -0
- package/dist/375.js.map +1 -0
- package/dist/4055.js +1 -1
- package/dist/4300.js +1 -1
- package/dist/4341.js +1 -0
- package/dist/4341.js.map +1 -0
- package/dist/4687.js +1 -0
- package/dist/4687.js.map +1 -0
- package/dist/4937.js +1 -1
- package/dist/4937.js.map +1 -1
- package/dist/5670.js +1 -1
- package/dist/5670.js.map +1 -1
- package/dist/6336.js +1 -0
- package/dist/6336.js.map +1 -0
- package/dist/6364.js +1 -0
- package/dist/6364.js.map +1 -0
- package/dist/6411.js +1 -1
- package/dist/6473.js +1 -0
- package/dist/6473.js.map +1 -0
- package/dist/6542.js +1 -1
- package/dist/7657.js +2 -0
- package/dist/7657.js.map +1 -0
- package/dist/8154.js +1 -1
- package/dist/8154.js.map +1 -1
- package/dist/8416.js +1 -0
- package/dist/8416.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/openmrs-esm-patient-orders-app.js +1 -1
- package/dist/openmrs-esm-patient-orders-app.js.buildmanifest.json +228 -200
- package/dist/openmrs-esm-patient-orders-app.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +3 -3
- package/src/api/api.ts +16 -30
- package/src/components/order-details-table.component.tsx +58 -35
- package/src/index.ts +12 -9
- package/src/lab-results/{lab-results-form.component.tsx → exported-lab-results-form.workspace.tsx} +68 -67
- package/src/lab-results/lab-results-form-field.component.tsx +8 -5
- package/src/lab-results/lab-results-form.test.tsx +23 -21
- package/src/lab-results/lab-results-form.workspace.tsx +25 -0
- package/src/lab-results/print-results/print-modal/print-results-modal.tsx +5 -1
- package/src/order-basket/exported-order-basket.workspace.tsx +54 -0
- package/src/order-basket/general-order-type/{orderable-concept-search/orderable-concept-search.workspace.tsx → add-general-order/add-general-order.component.tsx} +89 -80
- package/src/order-basket/general-order-type/add-general-order/add-general-order.workspace.tsx +35 -0
- package/src/order-basket/general-order-type/add-general-order/exported-add-general-order.workspace.tsx +32 -0
- package/src/order-basket/general-order-type/{orderable-concept-search → add-general-order}/search-results.component.tsx +21 -15
- package/src/order-basket/general-order-type/general-order-form/general-order-form.component.tsx +70 -23
- package/src/order-basket/general-order-type/{general-order-type.component.tsx → general-order-panel.component.tsx} +25 -42
- package/src/order-basket/general-order-type/resources.ts +3 -2
- package/src/order-basket/order-basket.component.tsx +213 -0
- package/src/order-basket/order-basket.workspace.tsx +35 -229
- package/src/order-basket-action-button/order-basket-action-button.component.tsx +35 -0
- package/src/order-basket-action-button/order-basket-action-button.test.tsx +28 -61
- package/src/order-cancellation-form/cancel-order-form.component.tsx +82 -85
- package/src/routes.json +19 -27
- package/src/utils/index.ts +15 -3
- package/translations/en.json +4 -10
- package/translations/fr.json +5 -5
- package/dist/1571.js +0 -1
- package/dist/1571.js.map +0 -1
- package/dist/2537.js +0 -1
- package/dist/2537.js.map +0 -1
- package/dist/2981.js +0 -2
- package/dist/2981.js.map +0 -1
- package/dist/4918.js +0 -1
- package/dist/4918.js.map +0 -1
- package/dist/6783.js +0 -2
- package/dist/6783.js.map +0 -1
- package/dist/7202.js +0 -1
- package/dist/7202.js.map +0 -1
- package/dist/8625.js +0 -1
- package/dist/8625.js.map +0 -1
- package/dist/8803.js +0 -1
- package/dist/8803.js.map +0 -1
- package/dist/8960.js +0 -1
- package/dist/8960.js.map +0 -1
- package/src/order-basket-action-button/order-basket-action-button.extension.tsx +0 -23
- /package/dist/{6783.js.LICENSE.txt → 1268.js.LICENSE.txt} +0 -0
- /package/dist/{2981.js.LICENSE.txt → 7657.js.LICENSE.txt} +0 -0
- /package/src/order-basket/general-order-type/{orderable-concept-search → add-general-order}/orderable-concept-search.scss +0 -0
- /package/src/order-basket/general-order-type/{orderable-concept-search → add-general-order}/search-results.scss +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
type OrderBasketItem,
|
|
4
|
+
type OrderBasketWindowProps,
|
|
5
|
+
type PatientWorkspace2DefinitionProps,
|
|
6
|
+
} from '@openmrs/esm-patient-common-lib';
|
|
7
|
+
import AddGeneralOrder from './add-general-order.component';
|
|
8
|
+
|
|
9
|
+
interface OrderableConceptSearchWorkspaceProps {
|
|
10
|
+
order: OrderBasketItem;
|
|
11
|
+
orderTypeUuid: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* This workspace displays the drug order form for adding or editing a general order.
|
|
16
|
+
*/
|
|
17
|
+
const AddGeneralOrderWorkspace: React.FC<
|
|
18
|
+
PatientWorkspace2DefinitionProps<OrderableConceptSearchWorkspaceProps, OrderBasketWindowProps>
|
|
19
|
+
> = ({
|
|
20
|
+
workspaceProps: { order: initialOrder, orderTypeUuid },
|
|
21
|
+
groupProps: { patient, visitContext, mutateVisitContext },
|
|
22
|
+
closeWorkspace,
|
|
23
|
+
}) => {
|
|
24
|
+
return (
|
|
25
|
+
<AddGeneralOrder
|
|
26
|
+
initialOrder={initialOrder}
|
|
27
|
+
orderTypeUuid={orderTypeUuid}
|
|
28
|
+
patient={patient}
|
|
29
|
+
visitContext={visitContext}
|
|
30
|
+
closeWorkspace={closeWorkspace}
|
|
31
|
+
/>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default AddGeneralOrderWorkspace;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type Workspace2DefinitionProps } from '@openmrs/esm-framework';
|
|
3
|
+
import { type ExportedOrderBasketWindowProps, type OrderBasketItem } from '@openmrs/esm-patient-common-lib';
|
|
4
|
+
import AddGeneralOrder from './add-general-order.component';
|
|
5
|
+
|
|
6
|
+
interface OrderableConceptSearchWorkspaceProps {
|
|
7
|
+
order: OrderBasketItem;
|
|
8
|
+
orderTypeUuid: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* This workspace displays the drug order form for adding or editing a general order.
|
|
13
|
+
*/
|
|
14
|
+
const ExportedAddGeneralOrderWorkspace: React.FC<
|
|
15
|
+
Workspace2DefinitionProps<OrderableConceptSearchWorkspaceProps, ExportedOrderBasketWindowProps, {}>
|
|
16
|
+
> = ({
|
|
17
|
+
workspaceProps: { order: initialOrder, orderTypeUuid },
|
|
18
|
+
windowProps: { patient, visitContext },
|
|
19
|
+
closeWorkspace,
|
|
20
|
+
}) => {
|
|
21
|
+
return (
|
|
22
|
+
<AddGeneralOrder
|
|
23
|
+
initialOrder={initialOrder}
|
|
24
|
+
orderTypeUuid={orderTypeUuid}
|
|
25
|
+
patient={patient}
|
|
26
|
+
visitContext={visitContext}
|
|
27
|
+
closeWorkspace={closeWorkspace}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default ExportedAddGeneralOrderWorkspace;
|
|
@@ -4,12 +4,12 @@ import { ShoppingCartArrowUp } from '@carbon/react/icons';
|
|
|
4
4
|
import { Tile, Button, SkeletonText, ButtonSkeleton } from '@carbon/react';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
import {
|
|
7
|
+
type Workspace2DefinitionProps,
|
|
7
8
|
ArrowRightIcon,
|
|
8
|
-
type DefaultWorkspaceProps,
|
|
9
9
|
ShoppingCartArrowDownIcon,
|
|
10
10
|
useLayoutType,
|
|
11
11
|
useSession,
|
|
12
|
-
|
|
12
|
+
type Visit,
|
|
13
13
|
} from '@openmrs/esm-framework';
|
|
14
14
|
import {
|
|
15
15
|
useOrderBasket,
|
|
@@ -27,7 +27,9 @@ interface OrderableConceptSearchResultsProps {
|
|
|
27
27
|
cancelOrder: () => void;
|
|
28
28
|
orderableConceptSets: Array<string>;
|
|
29
29
|
orderTypeUuid: string;
|
|
30
|
-
closeWorkspace:
|
|
30
|
+
closeWorkspace: Workspace2DefinitionProps['closeWorkspace'];
|
|
31
|
+
patient: fhir.Patient;
|
|
32
|
+
visit: Visit;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
const OrderableConceptSearchResults: React.FC<OrderableConceptSearchResultsProps> = ({
|
|
@@ -38,6 +40,8 @@ const OrderableConceptSearchResults: React.FC<OrderableConceptSearchResultsProps
|
|
|
38
40
|
orderableConceptSets,
|
|
39
41
|
orderTypeUuid,
|
|
40
42
|
closeWorkspace,
|
|
43
|
+
patient,
|
|
44
|
+
visit,
|
|
41
45
|
}) => {
|
|
42
46
|
const { t } = useTranslation();
|
|
43
47
|
const isTablet = useLayoutType() === 'tablet';
|
|
@@ -89,6 +93,8 @@ const OrderableConceptSearchResults: React.FC<OrderableConceptSearchResultsProps
|
|
|
89
93
|
concept={concept}
|
|
90
94
|
orderTypeUuid={orderTypeUuid}
|
|
91
95
|
closeWorkspace={closeWorkspace}
|
|
96
|
+
patient={patient}
|
|
97
|
+
visit={visit}
|
|
92
98
|
/>
|
|
93
99
|
))}
|
|
94
100
|
</div>
|
|
@@ -153,7 +159,9 @@ interface TestTypeSearchResultItemProps {
|
|
|
153
159
|
concept: OrderableConcept;
|
|
154
160
|
openOrderForm: (searchResult: OrderBasketItem) => void;
|
|
155
161
|
orderTypeUuid: string;
|
|
156
|
-
closeWorkspace:
|
|
162
|
+
closeWorkspace: Workspace2DefinitionProps['closeWorkspace'];
|
|
163
|
+
patient: fhir.Patient;
|
|
164
|
+
visit: Visit;
|
|
157
165
|
}
|
|
158
166
|
|
|
159
167
|
const TestTypeSearchResultItem: React.FC<TestTypeSearchResultItemProps> = ({
|
|
@@ -161,11 +169,13 @@ const TestTypeSearchResultItem: React.FC<TestTypeSearchResultItemProps> = ({
|
|
|
161
169
|
openOrderForm,
|
|
162
170
|
orderTypeUuid,
|
|
163
171
|
closeWorkspace,
|
|
172
|
+
patient,
|
|
173
|
+
visit,
|
|
164
174
|
}) => {
|
|
165
175
|
const { t } = useTranslation();
|
|
166
176
|
const isTablet = useLayoutType() === 'tablet';
|
|
167
177
|
const session = useSession();
|
|
168
|
-
const { orders, setOrders } = useOrderBasket<OrderBasketItem>(orderTypeUuid, prepOrderPostData);
|
|
178
|
+
const { orders, setOrders } = useOrderBasket<OrderBasketItem>(patient, orderTypeUuid, prepOrderPostData);
|
|
169
179
|
|
|
170
180
|
const orderAlreadyInBasket = useMemo(
|
|
171
181
|
() => orders?.some((order) => order.concept.uuid === concept.uuid),
|
|
@@ -173,22 +183,18 @@ const TestTypeSearchResultItem: React.FC<TestTypeSearchResultItemProps> = ({
|
|
|
173
183
|
);
|
|
174
184
|
|
|
175
185
|
const createOrderBasketItem = useCallback(
|
|
176
|
-
(testType: OrderableConcept) => {
|
|
177
|
-
return createEmptyOrder(testType, session.currentProvider?.uuid);
|
|
186
|
+
(testType: OrderableConcept, visit: Visit) => {
|
|
187
|
+
return createEmptyOrder(testType, session.currentProvider?.uuid, visit);
|
|
178
188
|
},
|
|
179
189
|
[session.currentProvider.uuid],
|
|
180
190
|
);
|
|
181
191
|
|
|
182
192
|
const addToBasket = useCallback(() => {
|
|
183
|
-
const orderBasketItem = createOrderBasketItem(concept);
|
|
193
|
+
const orderBasketItem = createOrderBasketItem(concept, visit);
|
|
184
194
|
orderBasketItem.isOrderIncomplete = true;
|
|
185
195
|
setOrders([...orders, orderBasketItem]);
|
|
186
|
-
closeWorkspace({
|
|
187
|
-
|
|
188
|
-
onWorkspaceClose: () => launchWorkspace('order-basket'),
|
|
189
|
-
closeWorkspaceGroup: false,
|
|
190
|
-
});
|
|
191
|
-
}, [orders, setOrders, createOrderBasketItem, concept, closeWorkspace]);
|
|
196
|
+
closeWorkspace({ discardUnsavedChanges: true });
|
|
197
|
+
}, [orders, setOrders, createOrderBasketItem, concept, closeWorkspace, visit]);
|
|
192
198
|
|
|
193
199
|
const removeFromBasket = useCallback(() => {
|
|
194
200
|
setOrders(orders.filter((order) => order?.concept?.uuid !== concept?.uuid));
|
|
@@ -227,7 +233,7 @@ const TestTypeSearchResultItem: React.FC<TestTypeSearchResultItemProps> = ({
|
|
|
227
233
|
<Button
|
|
228
234
|
kind="ghost"
|
|
229
235
|
renderIcon={(props: ComponentProps<typeof ArrowRightIcon>) => <ArrowRightIcon size={16} {...props} />}
|
|
230
|
-
onClick={() => openOrderForm(createOrderBasketItem(concept))}
|
|
236
|
+
onClick={() => openOrderForm(createOrderBasketItem(concept, visit))}
|
|
231
237
|
>
|
|
232
238
|
{t('goToDrugOrderForm', 'Order form')}
|
|
233
239
|
</Button>
|
package/src/order-basket/general-order-type/general-order-form/general-order-form.component.tsx
CHANGED
|
@@ -19,11 +19,12 @@ import { zodResolver } from '@hookform/resolvers/zod';
|
|
|
19
19
|
import { z } from 'zod';
|
|
20
20
|
import {
|
|
21
21
|
priorityOptions,
|
|
22
|
-
type DefaultPatientWorkspaceProps,
|
|
23
22
|
type OrderBasketItem,
|
|
24
23
|
type OrderUrgency,
|
|
25
24
|
useOrderBasket,
|
|
26
25
|
useOrderType,
|
|
26
|
+
postOrder,
|
|
27
|
+
useMutatePatientOrders,
|
|
27
28
|
} from '@openmrs/esm-patient-common-lib';
|
|
28
29
|
import {
|
|
29
30
|
useLayoutType,
|
|
@@ -31,36 +32,40 @@ import {
|
|
|
31
32
|
useConfig,
|
|
32
33
|
ExtensionSlot,
|
|
33
34
|
OpenmrsDatePicker,
|
|
34
|
-
|
|
35
|
+
type Workspace2DefinitionProps,
|
|
36
|
+
showSnackbar,
|
|
37
|
+
useAbortController,
|
|
35
38
|
} from '@openmrs/esm-framework';
|
|
36
39
|
import { ordersEqual, prepOrderPostData } from '../resources';
|
|
37
40
|
import { type ConfigObject } from '../../../config-schema';
|
|
38
41
|
import styles from './general-order-form.scss';
|
|
39
42
|
|
|
40
|
-
export interface OrderFormProps
|
|
43
|
+
export interface OrderFormProps {
|
|
41
44
|
initialOrder: OrderBasketItem;
|
|
42
45
|
orderTypeUuid: string;
|
|
43
|
-
|
|
46
|
+
closeWorkspace: Workspace2DefinitionProps['closeWorkspace'];
|
|
47
|
+
setHasUnsavedChanges: (hasUnsavedChanges: boolean) => void;
|
|
48
|
+
patient: fhir.Patient;
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
// Designs:
|
|
47
52
|
// https://app.zeplin.io/project/60d5947dd636aebbd63dce4c/screen/640b06c440ee3f7af8747620
|
|
48
53
|
// https://app.zeplin.io/project/60d5947dd636aebbd63dce4c/screen/640b06d286e0aa7b0316db4a
|
|
49
54
|
export function OrderForm({
|
|
55
|
+
patient,
|
|
50
56
|
initialOrder,
|
|
51
|
-
closeWorkspace,
|
|
52
|
-
closeWorkspaceWithSavedChanges,
|
|
53
|
-
promptBeforeClosing,
|
|
54
57
|
orderTypeUuid,
|
|
58
|
+
closeWorkspace,
|
|
59
|
+
setHasUnsavedChanges,
|
|
55
60
|
}: OrderFormProps) {
|
|
56
61
|
const { t } = useTranslation();
|
|
57
62
|
const isTablet = useLayoutType() === 'tablet';
|
|
58
63
|
const session = useSession();
|
|
59
|
-
const
|
|
60
|
-
const { orders, setOrders } = useOrderBasket<OrderBasketItem>(orderTypeUuid, prepOrderPostData);
|
|
64
|
+
const { orders, setOrders, clearOrders } = useOrderBasket<OrderBasketItem>(patient, orderTypeUuid, prepOrderPostData);
|
|
61
65
|
const [showErrorNotification, setShowErrorNotification] = useState(false);
|
|
62
66
|
const { orderType } = useOrderType(orderTypeUuid);
|
|
63
67
|
const config = useConfig<ConfigObject>();
|
|
68
|
+
const { mutate: mutateOrders } = useMutatePatientOrders(patient.id);
|
|
64
69
|
|
|
65
70
|
const OrderFormSchema = useMemo(
|
|
66
71
|
() =>
|
|
@@ -107,7 +112,7 @@ export function OrderForm({
|
|
|
107
112
|
return menu?.item?.value?.toLowerCase().includes(menu?.inputValue?.toLowerCase());
|
|
108
113
|
}, []);
|
|
109
114
|
|
|
110
|
-
const
|
|
115
|
+
const saveOrderToBasket = useCallback(
|
|
111
116
|
(data: OrderBasketItem) => {
|
|
112
117
|
const finalizedOrder: OrderBasketItem = {
|
|
113
118
|
...initialOrder,
|
|
@@ -130,22 +135,55 @@ export function OrderForm({
|
|
|
130
135
|
|
|
131
136
|
setOrders(newOrders);
|
|
132
137
|
|
|
133
|
-
|
|
134
|
-
onWorkspaceClose: () => launchWorkspace('order-basket'),
|
|
135
|
-
closeWorkspaceGroup: false,
|
|
136
|
-
});
|
|
138
|
+
closeWorkspace({ discardUnsavedChanges: true });
|
|
137
139
|
},
|
|
138
|
-
[orders, setOrders, session?.currentProvider?.uuid,
|
|
140
|
+
[orders, setOrders, session?.currentProvider?.uuid, initialOrder, closeWorkspace],
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
const submitDrugOrderToServer = useCallback(
|
|
144
|
+
(data: OrderBasketItem) => {
|
|
145
|
+
const finalizedOrder: OrderBasketItem = {
|
|
146
|
+
...initialOrder,
|
|
147
|
+
...data,
|
|
148
|
+
};
|
|
149
|
+
finalizedOrder.orderer = session.currentProvider.uuid;
|
|
150
|
+
|
|
151
|
+
postOrder(prepOrderPostData(finalizedOrder, patient.id, finalizedOrder?.encounterUuid))
|
|
152
|
+
.then(() => {
|
|
153
|
+
clearOrders();
|
|
154
|
+
mutateOrders();
|
|
155
|
+
showSnackbar({
|
|
156
|
+
isLowContrast: false,
|
|
157
|
+
kind: 'success',
|
|
158
|
+
title: t('successSavingDrugOrder', 'Order saved'),
|
|
159
|
+
});
|
|
160
|
+
closeWorkspace({ discardUnsavedChanges: true });
|
|
161
|
+
})
|
|
162
|
+
.catch((error) => {
|
|
163
|
+
showSnackbar({
|
|
164
|
+
isLowContrast: false,
|
|
165
|
+
kind: 'error',
|
|
166
|
+
title: t('errorSavingDrugOrder', 'Error saving order'),
|
|
167
|
+
subtitle: error,
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
},
|
|
171
|
+
[clearOrders, closeWorkspace, initialOrder, mutateOrders, patient.id, session.currentProvider.uuid, t],
|
|
139
172
|
);
|
|
140
173
|
|
|
141
174
|
const cancelOrder = useCallback(() => {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
175
|
+
closeWorkspace().then((didClose: boolean) => {
|
|
176
|
+
if (didClose) {
|
|
177
|
+
setOrders(orders.filter((order) => order.concept.uuid !== defaultValues.concept.conceptUuid));
|
|
178
|
+
}
|
|
146
179
|
});
|
|
147
180
|
}, [closeWorkspace, orders, setOrders, defaultValues]);
|
|
148
181
|
|
|
182
|
+
const closeModifyOrderWorkspace = useCallback(() => {
|
|
183
|
+
clearOrders();
|
|
184
|
+
closeWorkspace();
|
|
185
|
+
}, [clearOrders, closeWorkspace]);
|
|
186
|
+
|
|
149
187
|
const onError = (errors: FieldErrors<OrderBasketItem>) => {
|
|
150
188
|
if (errors) {
|
|
151
189
|
setShowErrorNotification(true);
|
|
@@ -163,14 +201,18 @@ export function OrderForm({
|
|
|
163
201
|
};
|
|
164
202
|
|
|
165
203
|
useEffect(() => {
|
|
166
|
-
|
|
167
|
-
}, [isDirty,
|
|
204
|
+
setHasUnsavedChanges(isDirty);
|
|
205
|
+
}, [isDirty, setHasUnsavedChanges]);
|
|
168
206
|
|
|
169
207
|
const responsiveSize = isTablet ? 'lg' : 'sm';
|
|
170
208
|
|
|
171
209
|
return (
|
|
172
210
|
<>
|
|
173
|
-
<Form
|
|
211
|
+
<Form
|
|
212
|
+
className={styles.orderForm}
|
|
213
|
+
onSubmit={handleSubmit(initialOrder?.action == 'REVISE' ? submitDrugOrderToServer : saveOrderToBasket, onError)}
|
|
214
|
+
id="drugOrderForm"
|
|
215
|
+
>
|
|
174
216
|
<div className={styles.form}>
|
|
175
217
|
<ExtensionSlot name="top-of-lab-order-form-slot" state={{ order: initialOrder }} />
|
|
176
218
|
<Grid className={styles.gridRow}>
|
|
@@ -293,7 +335,12 @@ export function OrderForm({
|
|
|
293
335
|
<ButtonSet
|
|
294
336
|
className={classNames(styles.buttonSet, isTablet ? styles.tabletButtonSet : styles.desktopButtonSet)}
|
|
295
337
|
>
|
|
296
|
-
<Button
|
|
338
|
+
<Button
|
|
339
|
+
className={styles.button}
|
|
340
|
+
kind="secondary"
|
|
341
|
+
onClick={initialOrder?.action == 'REVISE' ? closeModifyOrderWorkspace : cancelOrder}
|
|
342
|
+
size="xl"
|
|
343
|
+
>
|
|
297
344
|
{t('discard', 'Discard')}
|
|
298
345
|
</Button>
|
|
299
346
|
<Button className={styles.button} kind="primary" size="xl" type="submit">
|
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
import React, { type ComponentProps, useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import { Button, Tile } from '@carbon/react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
import {
|
|
5
|
-
AddIcon,
|
|
6
|
-
ChevronDownIcon,
|
|
7
|
-
ChevronUpIcon,
|
|
8
|
-
type DefaultWorkspaceProps,
|
|
9
|
-
MaybeIcon,
|
|
10
|
-
useLayoutType,
|
|
11
|
-
launchWorkspace,
|
|
12
|
-
} from '@openmrs/esm-framework';
|
|
4
|
+
import { AddIcon, ChevronDownIcon, ChevronUpIcon, MaybeIcon, useLayoutType } from '@openmrs/esm-framework';
|
|
13
5
|
import { useTranslation } from 'react-i18next';
|
|
14
6
|
import { type OrderBasketItem, useOrderBasket, useOrderType } from '@openmrs/esm-patient-common-lib';
|
|
15
7
|
import { type OrderTypeDefinition } from '../../config-schema';
|
|
@@ -18,15 +10,29 @@ import OrderBasketItemTile from './order-basket-item-tile.component';
|
|
|
18
10
|
import styles from './general-order-panel.scss';
|
|
19
11
|
|
|
20
12
|
interface GeneralOrderTypeProps extends OrderTypeDefinition {
|
|
21
|
-
|
|
13
|
+
patient: fhir.Patient;
|
|
14
|
+
orderTypeUuid: string;
|
|
15
|
+
launchGeneralOrderForm(orderTypeUuid: string, order?: OrderBasketItem): void;
|
|
22
16
|
}
|
|
23
17
|
|
|
24
|
-
|
|
18
|
+
/**
|
|
19
|
+
* The extension is slotted into order-basket-slot in the main Order Basket workspace by default.
|
|
20
|
+
* It renders the "Add +" button for general orders, and lists pending general orders in the order basket.
|
|
21
|
+
*
|
|
22
|
+
* Designs: https://app.zeplin.io/project/60d59321e8100b0324762e05/screen/62c6bb9500e7671a618efa56
|
|
23
|
+
*/
|
|
24
|
+
const GeneralOrderPanel: React.FC<GeneralOrderTypeProps> = ({
|
|
25
|
+
patient,
|
|
26
|
+
orderTypeUuid,
|
|
27
|
+
label,
|
|
28
|
+
icon,
|
|
29
|
+
launchGeneralOrderForm,
|
|
30
|
+
}) => {
|
|
25
31
|
const { t } = useTranslation();
|
|
26
32
|
const isTablet = useLayoutType() === 'tablet';
|
|
27
33
|
const { orderType, isLoadingOrderType } = useOrderType(orderTypeUuid);
|
|
28
34
|
|
|
29
|
-
const { orders, setOrders } = useOrderBasket<OrderBasketItem>(orderTypeUuid, prepOrderPostData);
|
|
35
|
+
const { orders, setOrders } = useOrderBasket<OrderBasketItem>(patient, orderTypeUuid, prepOrderPostData);
|
|
30
36
|
const [isExpanded, setIsExpanded] = useState(orders.length > 0);
|
|
31
37
|
const {
|
|
32
38
|
incompleteOrderBasketItems,
|
|
@@ -64,29 +70,6 @@ const GeneralOrderType: React.FC<GeneralOrderTypeProps> = ({ orderTypeUuid, clos
|
|
|
64
70
|
};
|
|
65
71
|
}, [orders]);
|
|
66
72
|
|
|
67
|
-
const openConceptSearch = () => {
|
|
68
|
-
closeWorkspace({
|
|
69
|
-
ignoreChanges: true,
|
|
70
|
-
onWorkspaceClose: () =>
|
|
71
|
-
launchWorkspace('orderable-concept-workspace', {
|
|
72
|
-
orderTypeUuid,
|
|
73
|
-
}),
|
|
74
|
-
closeWorkspaceGroup: false,
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const openOrderForm = (order: OrderBasketItem) => {
|
|
79
|
-
closeWorkspace({
|
|
80
|
-
ignoreChanges: true,
|
|
81
|
-
onWorkspaceClose: () =>
|
|
82
|
-
launchWorkspace('orderable-concept-workspace', {
|
|
83
|
-
order,
|
|
84
|
-
orderTypeUuid,
|
|
85
|
-
}),
|
|
86
|
-
closeWorkspaceGroup: false,
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
|
|
90
73
|
const removeOrder = useCallback(
|
|
91
74
|
(order: OrderBasketItem) => {
|
|
92
75
|
const newOrders = [...orders];
|
|
@@ -119,7 +102,7 @@ const GeneralOrderType: React.FC<GeneralOrderTypeProps> = ({ orderTypeUuid, clos
|
|
|
119
102
|
kind="ghost"
|
|
120
103
|
renderIcon={(props: ComponentProps<typeof AddIcon>) => <AddIcon size={16} {...props} />}
|
|
121
104
|
iconDescription={t('addMedication', 'Add medication')}
|
|
122
|
-
onClick={
|
|
105
|
+
onClick={() => launchGeneralOrderForm(orderTypeUuid)}
|
|
123
106
|
size={isTablet ? 'md' : 'sm'}
|
|
124
107
|
>
|
|
125
108
|
{t('add', 'Add')}
|
|
@@ -147,7 +130,7 @@ const GeneralOrderType: React.FC<GeneralOrderTypeProps> = ({ orderTypeUuid, clos
|
|
|
147
130
|
<OrderBasketItemTile
|
|
148
131
|
key={`incomplete-${order.action}-${order.concept?.uuid}-${index}`}
|
|
149
132
|
orderBasketItem={order}
|
|
150
|
-
onItemClick={() =>
|
|
133
|
+
onItemClick={() => launchGeneralOrderForm(orderTypeUuid, order)}
|
|
151
134
|
onRemoveClick={() => removeOrder(order)}
|
|
152
135
|
/>
|
|
153
136
|
))}
|
|
@@ -159,7 +142,7 @@ const GeneralOrderType: React.FC<GeneralOrderTypeProps> = ({ orderTypeUuid, clos
|
|
|
159
142
|
<OrderBasketItemTile
|
|
160
143
|
key={`new-${order.action}-${order.concept?.uuid}-${index}`}
|
|
161
144
|
orderBasketItem={order}
|
|
162
|
-
onItemClick={() =>
|
|
145
|
+
onItemClick={() => launchGeneralOrderForm(orderTypeUuid, order)}
|
|
163
146
|
onRemoveClick={() => removeOrder(order)}
|
|
164
147
|
/>
|
|
165
148
|
))}
|
|
@@ -172,7 +155,7 @@ const GeneralOrderType: React.FC<GeneralOrderTypeProps> = ({ orderTypeUuid, clos
|
|
|
172
155
|
<OrderBasketItemTile
|
|
173
156
|
key={`renewed-${item.action}-${item.concept?.uuid}-${index}`}
|
|
174
157
|
orderBasketItem={item}
|
|
175
|
-
onItemClick={() =>
|
|
158
|
+
onItemClick={() => launchGeneralOrderForm(orderTypeUuid, item)}
|
|
176
159
|
onRemoveClick={() => removeOrder(item)}
|
|
177
160
|
/>
|
|
178
161
|
))}
|
|
@@ -185,7 +168,7 @@ const GeneralOrderType: React.FC<GeneralOrderTypeProps> = ({ orderTypeUuid, clos
|
|
|
185
168
|
<OrderBasketItemTile
|
|
186
169
|
key={`revised-${item.action}-${item.concept?.uuid}-${index}`}
|
|
187
170
|
orderBasketItem={item}
|
|
188
|
-
onItemClick={() =>
|
|
171
|
+
onItemClick={() => launchGeneralOrderForm(orderTypeUuid, item)}
|
|
189
172
|
onRemoveClick={() => removeOrder(item)}
|
|
190
173
|
/>
|
|
191
174
|
))}
|
|
@@ -198,7 +181,7 @@ const GeneralOrderType: React.FC<GeneralOrderTypeProps> = ({ orderTypeUuid, clos
|
|
|
198
181
|
<OrderBasketItemTile
|
|
199
182
|
key={`discontinued-${item.action}-${item.concept?.uuid}-${index}`}
|
|
200
183
|
orderBasketItem={item}
|
|
201
|
-
onItemClick={() =>
|
|
184
|
+
onItemClick={() => launchGeneralOrderForm(orderTypeUuid, item)}
|
|
202
185
|
onRemoveClick={() => removeOrder(item)}
|
|
203
186
|
/>
|
|
204
187
|
))}
|
|
@@ -210,4 +193,4 @@ const GeneralOrderType: React.FC<GeneralOrderTypeProps> = ({ orderTypeUuid, clos
|
|
|
210
193
|
);
|
|
211
194
|
};
|
|
212
195
|
|
|
213
|
-
export default
|
|
196
|
+
export default GeneralOrderPanel;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toOmrsIsoString } from '@openmrs/esm-framework';
|
|
1
|
+
import { toOmrsIsoString, type Visit } from '@openmrs/esm-framework';
|
|
2
2
|
import {
|
|
3
3
|
type OrderBasketItem,
|
|
4
4
|
priorityOptions,
|
|
@@ -7,13 +7,14 @@ import {
|
|
|
7
7
|
type OrderableConcept,
|
|
8
8
|
} from '@openmrs/esm-patient-common-lib';
|
|
9
9
|
|
|
10
|
-
export function createEmptyOrder(concept: OrderableConcept, orderer: string): OrderBasketItem {
|
|
10
|
+
export function createEmptyOrder(concept: OrderableConcept, orderer: string, visit: Visit): OrderBasketItem {
|
|
11
11
|
return {
|
|
12
12
|
action: 'NEW',
|
|
13
13
|
urgency: priorityOptions[0].value as OrderUrgency,
|
|
14
14
|
display: concept.display,
|
|
15
15
|
concept,
|
|
16
16
|
orderer,
|
|
17
|
+
visit,
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
|