@openmrs/esm-patient-orders-app 11.3.1-pre.9452 → 11.3.1-pre.9455
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 +14 -14
- package/dist/1253.js +1 -0
- package/dist/1253.js.map +1 -0
- package/dist/375.js +1 -0
- package/dist/375.js.map +1 -0
- package/dist/4300.js +1 -1
- package/dist/4341.js +1 -0
- package/dist/4341.js.map +1 -0
- package/dist/4558.js +1 -0
- package/dist/4558.js.map +1 -0
- package/dist/5937.js +1 -0
- package/dist/5937.js.map +1 -0
- package/dist/6473.js +1 -0
- package/dist/6473.js.map +1 -0
- package/dist/6483.js +1 -0
- package/dist/6483.js.map +1 -0
- package/dist/8376.js +1 -0
- package/dist/8376.js.map +1 -0
- package/dist/8389.js +1 -0
- package/dist/8389.js.map +1 -0
- package/dist/8416.js +1 -0
- package/dist/8416.js.map +1 -0
- package/dist/8894.js +1 -0
- package/dist/8894.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 +230 -107
- package/dist/openmrs-esm-patient-orders-app.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +2 -2
- package/src/api/api.ts +0 -25
- package/src/components/order-details-table.component.tsx +53 -40
- package/src/index.ts +19 -11
- package/src/lab-results/{lab-results-form.component.tsx → exported-lab-results-form.workspace.tsx} +105 -108
- package/src/lab-results/lab-results-form.test.tsx +24 -38
- package/src/lab-results/lab-results-form.workspace.tsx +26 -0
- package/src/order-basket/exported-order-basket.workspace.tsx +59 -0
- package/src/order-basket/general-order-type/{orderable-concept-search/orderable-concept-search.workspace.tsx → add-general-order/add-general-order.component.tsx} +78 -83
- package/src/order-basket/general-order-type/add-general-order/add-general-order.workspace.tsx +38 -0
- package/src/order-basket/general-order-type/add-general-order/exported-add-general-order.workspace.tsx +35 -0
- package/src/order-basket/general-order-type/{orderable-concept-search → add-general-order}/search-results.component.tsx +15 -14
- package/src/order-basket/general-order-type/general-order-form/general-order-form.component.tsx +71 -25
- package/src/order-basket/general-order-type/{general-order-type.component.tsx → general-order-panel.component.tsx} +23 -41
- 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 +42 -252
- 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 +27 -36
- package/src/routes.json +17 -25
- package/src/utils/index.ts +15 -3
- package/translations/en.json +4 -20
- package/dist/1571.js +0 -1
- package/dist/1571.js.map +0 -1
- package/dist/2717.js +0 -1
- package/dist/2717.js.map +0 -1
- package/dist/4937.js +0 -1
- package/dist/4937.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 -31
- package/src/order-cancellation-form/cancel-order-form.component.tsx +0 -180
- package/src/order-cancellation-form/cancel-order-form.scss +0 -87
- package/src/order-cancellation-form/cancel-order.resource.tsx +0 -15
- /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
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
|
-
import dayjs from 'dayjs';
|
|
3
|
-
import { Controller, useForm } from 'react-hook-form';
|
|
4
|
-
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import { z } from 'zod';
|
|
6
|
-
import { zodResolver } from '@hookform/resolvers/zod';
|
|
7
|
-
import { Button, TextArea, ButtonSet, Column, Form, InlineNotification, Stack, InlineLoading } from '@carbon/react';
|
|
8
|
-
import { OpenmrsDatePicker, showSnackbar, useLayoutType } from '@openmrs/esm-framework';
|
|
9
|
-
import { type DefaultPatientWorkspaceProps, usePatientOrders, type Order } from '@openmrs/esm-patient-common-lib';
|
|
10
|
-
import { cancelOrder } from './cancel-order.resource';
|
|
11
|
-
import styles from './cancel-order-form.scss';
|
|
12
|
-
|
|
13
|
-
interface OrderCancellationFormProps extends DefaultPatientWorkspaceProps {
|
|
14
|
-
order: Order;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const OrderCancellationForm: React.FC<OrderCancellationFormProps> = ({
|
|
18
|
-
order,
|
|
19
|
-
patientUuid,
|
|
20
|
-
closeWorkspace,
|
|
21
|
-
promptBeforeClosing,
|
|
22
|
-
}) => {
|
|
23
|
-
const { t } = useTranslation();
|
|
24
|
-
const isTablet = useLayoutType() === 'tablet';
|
|
25
|
-
const [showErrorNotification, setShowErrorNotification] = useState(false);
|
|
26
|
-
const { mutate } = usePatientOrders(patientUuid);
|
|
27
|
-
|
|
28
|
-
const cancelOrderSchema = useMemo(() => {
|
|
29
|
-
return z.object({
|
|
30
|
-
cancellationDate: z
|
|
31
|
-
.date({
|
|
32
|
-
required_error: t('cancellationDateRequired', 'Cancellation date is required'),
|
|
33
|
-
})
|
|
34
|
-
.refine((date) => date >= dayjs().startOf('day').toDate(), {
|
|
35
|
-
message: t('dateCannotBeBeforeToday', 'Date cannot be before today'),
|
|
36
|
-
}),
|
|
37
|
-
reasonForCancellation: z.string({
|
|
38
|
-
required_error: t('reasonForCancellationRequired', 'Reason for cancellation is required'),
|
|
39
|
-
}),
|
|
40
|
-
});
|
|
41
|
-
}, [t]);
|
|
42
|
-
|
|
43
|
-
type CancelOrderFormData = z.infer<typeof cancelOrderSchema>;
|
|
44
|
-
|
|
45
|
-
const {
|
|
46
|
-
control,
|
|
47
|
-
handleSubmit,
|
|
48
|
-
formState: { errors, isDirty, isSubmitting },
|
|
49
|
-
} = useForm<CancelOrderFormData>({
|
|
50
|
-
mode: 'all',
|
|
51
|
-
resolver: zodResolver(cancelOrderSchema),
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
function onError(err) {
|
|
55
|
-
if (err?.oneFieldRequired) {
|
|
56
|
-
setShowErrorNotification(true);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
useEffect(() => {
|
|
61
|
-
promptBeforeClosing(() => isDirty);
|
|
62
|
-
}, [isDirty, promptBeforeClosing]);
|
|
63
|
-
|
|
64
|
-
const cancelOrderRequest = useCallback(
|
|
65
|
-
(data: CancelOrderFormData) => {
|
|
66
|
-
const formData = data;
|
|
67
|
-
setShowErrorNotification(false);
|
|
68
|
-
|
|
69
|
-
const payload = {
|
|
70
|
-
fulfillerStatus: 'DECLINED',
|
|
71
|
-
fulfillerComment: formData.reasonForCancellation,
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
cancelOrder(order, payload).then(
|
|
75
|
-
(res) => {
|
|
76
|
-
closeWorkspace();
|
|
77
|
-
mutate();
|
|
78
|
-
|
|
79
|
-
showSnackbar({
|
|
80
|
-
title: t('orderCancelled', 'Order cancelled'),
|
|
81
|
-
kind: 'success',
|
|
82
|
-
subtitle: t('successfullyCancelledOrder', 'Order {{orderNumber}} has been cancelled successfully', {
|
|
83
|
-
orderNumber: order?.orderNumber,
|
|
84
|
-
}),
|
|
85
|
-
});
|
|
86
|
-
},
|
|
87
|
-
(err) => {
|
|
88
|
-
showSnackbar({
|
|
89
|
-
isLowContrast: true,
|
|
90
|
-
title: t('errorCancellingOrder', 'Error cancelling order'),
|
|
91
|
-
kind: 'error',
|
|
92
|
-
subtitle: err?.message,
|
|
93
|
-
});
|
|
94
|
-
},
|
|
95
|
-
);
|
|
96
|
-
},
|
|
97
|
-
[closeWorkspace, mutate, order, t],
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
return (
|
|
101
|
-
<Form className={styles.form}>
|
|
102
|
-
<div className={styles.grid}>
|
|
103
|
-
<Stack>
|
|
104
|
-
<section>
|
|
105
|
-
<h4 className={styles.orderDisplay}>{order?.display}</h4>
|
|
106
|
-
</section>
|
|
107
|
-
<section>
|
|
108
|
-
<Controller
|
|
109
|
-
name="cancellationDate"
|
|
110
|
-
control={control}
|
|
111
|
-
render={({ field, fieldState }) => (
|
|
112
|
-
<div className={styles.row}>
|
|
113
|
-
<OpenmrsDatePicker
|
|
114
|
-
{...field}
|
|
115
|
-
id="cancellationDate"
|
|
116
|
-
minDate={dayjs().startOf('day')}
|
|
117
|
-
labelText={t('cancellationDate', 'Cancellation date')}
|
|
118
|
-
invalid={Boolean(fieldState?.error?.message)}
|
|
119
|
-
invalidText={fieldState?.error?.message}
|
|
120
|
-
/>
|
|
121
|
-
</div>
|
|
122
|
-
)}
|
|
123
|
-
/>
|
|
124
|
-
</section>
|
|
125
|
-
<section>
|
|
126
|
-
<Controller
|
|
127
|
-
name="reasonForCancellation"
|
|
128
|
-
control={control}
|
|
129
|
-
render={({ field: { onChange, value } }) => (
|
|
130
|
-
<div className={styles.row}>
|
|
131
|
-
<TextArea
|
|
132
|
-
type="text"
|
|
133
|
-
id="reasonForCancellation"
|
|
134
|
-
labelText={t('reasonForCancellation', 'Reason for cancellation')}
|
|
135
|
-
value={value}
|
|
136
|
-
onChange={(evt) => onChange(evt.target.value)}
|
|
137
|
-
invalid={!!errors['reasonForCancellation']}
|
|
138
|
-
invalidText={!!errors['reasonForCancellation'] && errors['reasonForCancellation'].message}
|
|
139
|
-
/>
|
|
140
|
-
</div>
|
|
141
|
-
)}
|
|
142
|
-
/>
|
|
143
|
-
</section>
|
|
144
|
-
</Stack>
|
|
145
|
-
</div>
|
|
146
|
-
|
|
147
|
-
{showErrorNotification && (
|
|
148
|
-
<Column className={styles.errorContainer}>
|
|
149
|
-
<InlineNotification
|
|
150
|
-
lowContrast
|
|
151
|
-
title={t('error', 'Error')}
|
|
152
|
-
subtitle={t('pleaseFillRequiredFields', 'Please fill all the required fields') + '.'}
|
|
153
|
-
onClose={() => setShowErrorNotification(false)}
|
|
154
|
-
/>
|
|
155
|
-
</Column>
|
|
156
|
-
)}
|
|
157
|
-
|
|
158
|
-
<ButtonSet className={isTablet ? styles.tablet : styles.desktop}>
|
|
159
|
-
<Button className={styles.button} kind="secondary" onClick={() => closeWorkspace()}>
|
|
160
|
-
{t('discard', 'Discard')}
|
|
161
|
-
</Button>
|
|
162
|
-
<Button
|
|
163
|
-
className={styles.button}
|
|
164
|
-
kind="primary"
|
|
165
|
-
onClick={handleSubmit(cancelOrderRequest, onError)}
|
|
166
|
-
disabled={isSubmitting}
|
|
167
|
-
type="submit"
|
|
168
|
-
>
|
|
169
|
-
{isSubmitting ? (
|
|
170
|
-
<InlineLoading description={t('saving', 'Saving') + '...'} />
|
|
171
|
-
) : (
|
|
172
|
-
t('saveAndClose', 'Save and close')
|
|
173
|
-
)}
|
|
174
|
-
</Button>
|
|
175
|
-
</ButtonSet>
|
|
176
|
-
</Form>
|
|
177
|
-
);
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
export default OrderCancellationForm;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
@use '@carbon/layout';
|
|
2
|
-
@use '@carbon/type';
|
|
3
|
-
@use '@openmrs/esm-styleguide/src/vars' as *;
|
|
4
|
-
|
|
5
|
-
.productiveHeading03 {
|
|
6
|
-
@include type.type-style('heading-03');
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.title {
|
|
10
|
-
@extend .productiveHeading03;
|
|
11
|
-
margin: 0 layout.$spacing-03 layout.$spacing-03 0;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.orderDisplay {
|
|
15
|
-
margin-bottom: layout.$spacing-05;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.danger {
|
|
19
|
-
color: $danger;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.button {
|
|
23
|
-
height: layout.$spacing-10;
|
|
24
|
-
display: flex;
|
|
25
|
-
align-content: flex-start;
|
|
26
|
-
align-items: baseline;
|
|
27
|
-
min-width: 50%;
|
|
28
|
-
|
|
29
|
-
:global(.cds--inline-loading) {
|
|
30
|
-
min-height: layout.$spacing-05 !important;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
:global(.cds--inline-loading__text) {
|
|
34
|
-
font-size: unset !important;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.tablet {
|
|
39
|
-
padding: layout.$spacing-06 layout.$spacing-05;
|
|
40
|
-
background-color: $ui-02;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.desktop {
|
|
44
|
-
padding: 0;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.form {
|
|
48
|
-
display: flex;
|
|
49
|
-
flex-direction: column;
|
|
50
|
-
justify-content: space-between;
|
|
51
|
-
height: 100%;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
:global(.omrs-breakpoint-lt-desktop) .form {
|
|
55
|
-
background-color: #ededed;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
:global(.omrs-breakpoint-gt-tablet) .form {
|
|
59
|
-
background-color: $ui-02;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.grid {
|
|
63
|
-
margin: layout.$spacing-05;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.row {
|
|
67
|
-
margin: layout.$spacing-03 0 0;
|
|
68
|
-
display: flex;
|
|
69
|
-
flex-flow: row wrap;
|
|
70
|
-
gap: layout.$spacing-05;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.spacer {
|
|
74
|
-
margin-top: layout.$spacing-05;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.noteInput {
|
|
78
|
-
width: 100%;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.errorNotification {
|
|
82
|
-
margin: layout.$spacing-03 0;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
.errorContainer {
|
|
86
|
-
margin: layout.$spacing-05;
|
|
87
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
|
|
2
|
-
import { type Order } from '@openmrs/esm-patient-common-lib';
|
|
3
|
-
|
|
4
|
-
export function cancelOrder(order: Order, requestBody: any) {
|
|
5
|
-
const ac = new AbortController();
|
|
6
|
-
|
|
7
|
-
return openmrsFetch(`${restBaseUrl}/order/${order.uuid}/fulfillerdetails/`, {
|
|
8
|
-
method: 'POST',
|
|
9
|
-
headers: {
|
|
10
|
-
'Content-Type': 'application/json',
|
|
11
|
-
},
|
|
12
|
-
body: requestBody,
|
|
13
|
-
signal: ac.signal,
|
|
14
|
-
});
|
|
15
|
-
}
|
|
File without changes
|
|
File without changes
|