@openmrs/esm-patient-medications-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 +13 -13
- package/dist/1022.js +1 -1
- package/dist/1022.js.map +1 -1
- package/dist/1918.js +1 -0
- package/dist/1918.js.map +1 -0
- package/dist/2102.js +1 -0
- package/dist/2102.js.map +1 -0
- package/dist/4138.js +1 -0
- package/dist/4138.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/4953.js +1 -1
- package/dist/4953.js.map +1 -1
- package/dist/8437.js +1 -1
- package/dist/8437.js.map +1 -1
- package/dist/8812.js +1 -1
- package/dist/8812.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/openmrs-esm-patient-medications-app.js +1 -1
- package/dist/openmrs-esm-patient-medications-app.js.buildmanifest.json +117 -68
- package/dist/routes.json +1 -1
- package/package.json +2 -2
- package/src/active-medications/active-medications.component.tsx +8 -2
- package/src/active-medications/active-medications.test.tsx +6 -9
- package/src/add-drug-order/add-drug-order.component.tsx +165 -0
- package/src/add-drug-order/add-drug-order.test.tsx +23 -15
- package/src/add-drug-order/add-drug-order.workspace.tsx +25 -118
- package/src/add-drug-order/drug-order-form.component.tsx +389 -387
- package/src/add-drug-order/drug-order-form.resource.ts +1 -2
- package/src/add-drug-order/drug-search/drug-search-combobox.component.tsx +7 -6
- package/src/add-drug-order/drug-search/drug-search-combobox.test.tsx +1 -1
- package/src/add-drug-order/drug-search/drug-search.component.tsx +9 -11
- package/src/add-drug-order/drug-search/drug-search.resource.tsx +10 -3
- package/src/add-drug-order/drug-search/helpers.ts +1 -1
- package/src/add-drug-order/drug-search/order-basket-search-results.component.tsx +32 -17
- package/src/add-drug-order/exported-add-drug-order.workspace.tsx +28 -0
- package/src/add-drug-order/fill-prescription-form.workspace.tsx +4 -5
- package/src/api/api.ts +7 -3
- package/src/api/order-config.ts +3 -3
- package/src/components/medications-details-table.component.tsx +55 -16
- package/src/drug-order-basket-panel/drug-order-basket-panel.extension.tsx +16 -42
- package/src/drug-order-basket-panel/drug-order-basket-panel.test.tsx +6 -6
- package/src/drug-order-basket-panel/order-basket-item-tile.component.tsx +1 -1
- package/src/index.ts +5 -1
- package/src/medications-summary/medications-summary.component.tsx +2 -2
- package/src/routes.json +7 -7
- package/translations/en.json +2 -0
- package/dist/7151.js +0 -1
- package/dist/7151.js.map +0 -1
- package/dist/8803.js +0 -1
- package/dist/8803.js.map +0 -1
- package/src/types.ts +0 -75
|
@@ -4,10 +4,9 @@ import { useTranslation } from 'react-i18next';
|
|
|
4
4
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { parseDate, useConfig } from '@openmrs/esm-framework';
|
|
7
|
+
import { type Drug, type DrugOrderBasketItem } from '@openmrs/esm-patient-common-lib';
|
|
7
8
|
import { careSettingUuid, useRequireOutpatientQuantity } from '../api';
|
|
8
9
|
import { type ConfigObject } from '../config-schema';
|
|
9
|
-
import { type DrugOrderBasketItem } from '../types';
|
|
10
|
-
import { type Drug } from '@openmrs/esm-patient-common-lib';
|
|
11
10
|
|
|
12
11
|
export function useDrugOrderForm(initialOrderBasketItem: DrugOrderBasketItem, defaultPrescribingProviderUuid: string) {
|
|
13
12
|
const medicationOrderFormSchema = useCreateMedicationOrderFormSchema();
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { ComboBox } from '@carbon/react';
|
|
2
|
-
import { useConfig, useDebounce } from '@openmrs/esm-framework';
|
|
2
|
+
import { useConfig, useDebounce, type Visit } from '@openmrs/esm-framework';
|
|
3
|
+
import { type DrugOrderBasketItem } from '@openmrs/esm-patient-common-lib';
|
|
3
4
|
import React, { useMemo, useState } from 'react';
|
|
4
5
|
import { getTemplateOrderBasketItem, useDrugSearch, useDrugTemplates } from './drug-search.resource';
|
|
5
|
-
import { type DrugOrderBasketItem } from '../../types';
|
|
6
6
|
import { type ConfigObject } from '../../config-schema';
|
|
7
7
|
import { useTranslation } from 'react-i18next';
|
|
8
8
|
|
|
9
9
|
interface DrugSearchComboBoxProps {
|
|
10
10
|
setSelectedDrugItem(drug: DrugOrderBasketItem);
|
|
11
|
+
visit: Visit;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
/**
|
|
@@ -16,7 +17,7 @@ interface DrugSearchComboBoxProps {
|
|
|
16
17
|
* This extension is currently not used anywhere in the patient-medications-app, but
|
|
17
18
|
* is used by other apps (ex: dispensing) for selecting drugs.
|
|
18
19
|
*/
|
|
19
|
-
const DrugSearchComboBox: React.FC<DrugSearchComboBoxProps> = ({ setSelectedDrugItem }) => {
|
|
20
|
+
const DrugSearchComboBox: React.FC<DrugSearchComboBoxProps> = ({ setSelectedDrugItem, visit }) => {
|
|
20
21
|
const { daysDurationUnit } = useConfig<ConfigObject>();
|
|
21
22
|
const { t } = useTranslation();
|
|
22
23
|
const [drugSearchTerm, setDrugSearchTerm] = useState('');
|
|
@@ -27,12 +28,12 @@ const DrugSearchComboBox: React.FC<DrugSearchComboBoxProps> = ({ setSelectedDrug
|
|
|
27
28
|
return drugs?.flatMap((drug) => {
|
|
28
29
|
const templates = templateByDrugUuid.get(drug.uuid);
|
|
29
30
|
if (templates?.length > 0) {
|
|
30
|
-
return templates.map((template) => getTemplateOrderBasketItem(drug, daysDurationUnit, template));
|
|
31
|
+
return templates.map((template) => getTemplateOrderBasketItem(drug, visit, daysDurationUnit, template));
|
|
31
32
|
} else {
|
|
32
|
-
return [getTemplateOrderBasketItem(drug, daysDurationUnit)];
|
|
33
|
+
return [getTemplateOrderBasketItem(drug, visit, daysDurationUnit)];
|
|
33
34
|
}
|
|
34
35
|
});
|
|
35
|
-
}, [drugs, templateByDrugUuid, daysDurationUnit]);
|
|
36
|
+
}, [drugs, templateByDrugUuid, daysDurationUnit, visit]);
|
|
36
37
|
|
|
37
38
|
return (
|
|
38
39
|
<ComboBox
|
|
@@ -52,5 +52,5 @@ describe('DrugSearchComboBox', () => {
|
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
function renderDrugSearchComboBox() {
|
|
55
|
-
render(<DrugSearchComboBox setSelectedDrugItem={mockSetSelectedDrugItem} />);
|
|
55
|
+
render(<DrugSearchComboBox setSelectedDrugItem={mockSetSelectedDrugItem} visit={null} />);
|
|
56
56
|
}
|
|
@@ -5,21 +5,23 @@ import {
|
|
|
5
5
|
useConfig,
|
|
6
6
|
useDebounce,
|
|
7
7
|
ResponsiveWrapper,
|
|
8
|
-
closeWorkspace,
|
|
9
8
|
useLayoutType,
|
|
10
|
-
|
|
9
|
+
type Workspace2DefinitionProps,
|
|
10
|
+
type Visit,
|
|
11
11
|
} from '@openmrs/esm-framework';
|
|
12
|
+
import { type DrugOrderBasketItem } from '@openmrs/esm-patient-common-lib';
|
|
12
13
|
import { type ConfigObject } from '../../config-schema';
|
|
13
|
-
import { type DrugOrderBasketItem } from '../../types';
|
|
14
14
|
import OrderBasketSearchResults from './order-basket-search-results.component';
|
|
15
15
|
import styles from './order-basket-search.scss';
|
|
16
16
|
|
|
17
17
|
export interface DrugSearchProps {
|
|
18
18
|
openOrderForm: (searchResult: DrugOrderBasketItem) => void;
|
|
19
|
+
closeWorkspace: Workspace2DefinitionProps['closeWorkspace'];
|
|
19
20
|
patient: fhir.Patient;
|
|
21
|
+
visit: Visit;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
export default function DrugSearch({ openOrderForm, patient }: DrugSearchProps) {
|
|
24
|
+
export default function DrugSearch({ closeWorkspace, openOrderForm, patient, visit }: DrugSearchProps) {
|
|
23
25
|
const { t } = useTranslation();
|
|
24
26
|
const isTablet = useLayoutType() === 'tablet';
|
|
25
27
|
const [searchTerm, setSearchTerm] = useState('');
|
|
@@ -27,12 +29,6 @@ export default function DrugSearch({ openOrderForm, patient }: DrugSearchProps)
|
|
|
27
29
|
const debouncedSearchTerm = useDebounce(searchTerm, debounceDelayInMs ?? 300);
|
|
28
30
|
const searchInputRef = useRef(null);
|
|
29
31
|
|
|
30
|
-
const cancelDrugOrder = useCallback(() => {
|
|
31
|
-
closeWorkspace('add-drug-order', {
|
|
32
|
-
onWorkspaceClose: () => launchWorkspace('order-basket'),
|
|
33
|
-
});
|
|
34
|
-
}, []);
|
|
35
|
-
|
|
36
32
|
const handleSearchTermChange = useCallback(
|
|
37
33
|
(event: React.ChangeEvent<HTMLInputElement>) => {
|
|
38
34
|
setSearchTerm(event.target.value ?? '');
|
|
@@ -59,14 +55,16 @@ export default function DrugSearch({ openOrderForm, patient }: DrugSearchProps)
|
|
|
59
55
|
</ResponsiveWrapper>
|
|
60
56
|
<OrderBasketSearchResults
|
|
61
57
|
searchTerm={debouncedSearchTerm}
|
|
58
|
+
closeWorkspace={closeWorkspace}
|
|
62
59
|
openOrderForm={openOrderForm}
|
|
63
60
|
focusAndClearSearchInput={focusAndClearSearchInput}
|
|
64
61
|
patient={patient}
|
|
62
|
+
visit={visit}
|
|
65
63
|
/>
|
|
66
64
|
{isTablet && (
|
|
67
65
|
<div className={styles.separatorContainer}>
|
|
68
66
|
<p className={styles.separator}>{t('or', 'or')}</p>
|
|
69
|
-
<Button iconDescription="Return to order basket" kind="ghost" onClick={
|
|
67
|
+
<Button iconDescription="Return to order basket" kind="ghost" onClick={() => closeWorkspace()}>
|
|
70
68
|
{t('returnToOrderBasket', 'Return to order basket')}
|
|
71
69
|
</Button>
|
|
72
70
|
</div>
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import useSWRImmutable from 'swr/immutable';
|
|
3
|
-
import { type FetchResponse, openmrsFetch, restBaseUrl, useFeatureFlag } from '@openmrs/esm-framework';
|
|
4
|
-
import
|
|
5
|
-
|
|
3
|
+
import { type FetchResponse, openmrsFetch, restBaseUrl, useFeatureFlag, type Visit } from '@openmrs/esm-framework';
|
|
4
|
+
import {
|
|
5
|
+
type Drug,
|
|
6
|
+
type DrugOrderBasketItem,
|
|
7
|
+
type DrugOrderTemplate,
|
|
8
|
+
type OrderTemplate,
|
|
9
|
+
} from '@openmrs/esm-patient-common-lib';
|
|
6
10
|
|
|
7
11
|
export interface DrugSearchResult {
|
|
8
12
|
uuid: string;
|
|
@@ -136,6 +140,7 @@ export function getDefault(template: OrderTemplate, prop: string) {
|
|
|
136
140
|
|
|
137
141
|
export function getTemplateOrderBasketItem(
|
|
138
142
|
drug: DrugSearchResult,
|
|
143
|
+
visit: Visit,
|
|
139
144
|
configDefaultDurationConcept?: {
|
|
140
145
|
uuid: string;
|
|
141
146
|
display: string;
|
|
@@ -184,6 +189,7 @@ export function getTemplateOrderBasketItem(
|
|
|
184
189
|
valueCoded: drug?.dosageForm?.uuid,
|
|
185
190
|
}
|
|
186
191
|
: null,
|
|
192
|
+
visit,
|
|
187
193
|
}
|
|
188
194
|
: {
|
|
189
195
|
action: 'NEW',
|
|
@@ -223,5 +229,6 @@ export function getTemplateOrderBasketItem(
|
|
|
223
229
|
valueCoded: drug?.dosageForm?.uuid,
|
|
224
230
|
}
|
|
225
231
|
: null,
|
|
232
|
+
visit,
|
|
226
233
|
};
|
|
227
234
|
}
|
|
@@ -3,15 +3,15 @@ import classNames from 'classnames';
|
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import { Button, ButtonSkeleton, SkeletonText, Tile } from '@carbon/react';
|
|
5
5
|
import { ShoppingCartArrowUp } from '@carbon/react/icons';
|
|
6
|
-
import { useOrderBasket } from '@openmrs/esm-patient-common-lib';
|
|
6
|
+
import { type DrugOrderBasketItem, useOrderBasket } from '@openmrs/esm-patient-common-lib';
|
|
7
7
|
import {
|
|
8
8
|
ArrowRightIcon,
|
|
9
|
-
closeWorkspace,
|
|
10
9
|
ShoppingCartArrowDownIcon,
|
|
11
10
|
useConfig,
|
|
12
11
|
useLayoutType,
|
|
13
12
|
UserHasAccess,
|
|
14
|
-
|
|
13
|
+
type Visit,
|
|
14
|
+
type Workspace2DefinitionProps,
|
|
15
15
|
} from '@openmrs/esm-framework';
|
|
16
16
|
import { type ConfigObject } from '../../config-schema';
|
|
17
17
|
import { prepMedicationOrderPostData, useActivePatientOrders } from '../../api/api';
|
|
@@ -22,20 +22,23 @@ import {
|
|
|
22
22
|
useDrugSearch,
|
|
23
23
|
useDrugTemplate,
|
|
24
24
|
} from './drug-search.resource';
|
|
25
|
-
import type { DrugOrderBasketItem } from '../../types';
|
|
26
25
|
import styles from './order-basket-search-results.scss';
|
|
27
26
|
|
|
28
27
|
export interface OrderBasketSearchResultsProps {
|
|
29
28
|
patient: fhir.Patient;
|
|
30
29
|
searchTerm: string;
|
|
30
|
+
closeWorkspace: Workspace2DefinitionProps['closeWorkspace'];
|
|
31
31
|
openOrderForm: (searchResult: DrugOrderBasketItem) => void;
|
|
32
32
|
focusAndClearSearchInput: () => void;
|
|
33
|
+
visit: Visit;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
interface DrugSearchResultItemProps {
|
|
36
37
|
patient: fhir.Patient;
|
|
37
38
|
drug: DrugSearchResult;
|
|
38
39
|
openOrderForm: (searchResult: DrugOrderBasketItem) => void;
|
|
40
|
+
visit: Visit;
|
|
41
|
+
closeWorkspace: Workspace2DefinitionProps['closeWorkspace'];
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
export default function OrderBasketSearchResults({
|
|
@@ -43,6 +46,8 @@ export default function OrderBasketSearchResults({
|
|
|
43
46
|
openOrderForm,
|
|
44
47
|
focusAndClearSearchInput,
|
|
45
48
|
patient,
|
|
49
|
+
visit,
|
|
50
|
+
closeWorkspace,
|
|
46
51
|
}: OrderBasketSearchResultsProps) {
|
|
47
52
|
const { t } = useTranslation();
|
|
48
53
|
const isTablet = useLayoutType() === 'tablet';
|
|
@@ -109,14 +114,27 @@ export default function OrderBasketSearchResults({
|
|
|
109
114
|
</div>
|
|
110
115
|
<div className={styles.resultsContainer}>
|
|
111
116
|
{drugs?.map((drug) => (
|
|
112
|
-
<DrugSearchResultItem
|
|
117
|
+
<DrugSearchResultItem
|
|
118
|
+
key={drug.uuid}
|
|
119
|
+
patient={patient}
|
|
120
|
+
drug={drug}
|
|
121
|
+
openOrderForm={openOrderForm}
|
|
122
|
+
visit={visit}
|
|
123
|
+
closeWorkspace={closeWorkspace}
|
|
124
|
+
/>
|
|
113
125
|
))}
|
|
114
126
|
</div>
|
|
115
127
|
</div>
|
|
116
128
|
);
|
|
117
129
|
}
|
|
118
130
|
|
|
119
|
-
const DrugSearchResultItem: React.FC<DrugSearchResultItemProps> = ({
|
|
131
|
+
const DrugSearchResultItem: React.FC<DrugSearchResultItemProps> = ({
|
|
132
|
+
patient,
|
|
133
|
+
drug,
|
|
134
|
+
openOrderForm,
|
|
135
|
+
visit,
|
|
136
|
+
closeWorkspace,
|
|
137
|
+
}) => {
|
|
120
138
|
const isTablet = useLayoutType() === 'tablet';
|
|
121
139
|
const { orders, setOrders } = useOrderBasket<DrugOrderBasketItem>(
|
|
122
140
|
patient,
|
|
@@ -126,14 +144,14 @@ const DrugSearchResultItem: React.FC<DrugSearchResultItemProps> = ({ patient, dr
|
|
|
126
144
|
const patientUuid = patient.id;
|
|
127
145
|
const { data: activeOrders, isLoading: isLoadingActiveOrders } = useActivePatientOrders(patientUuid);
|
|
128
146
|
const drugAlreadyInBasket = useMemo(
|
|
129
|
-
() => orders?.some((order) => ordersEqual(order, getTemplateOrderBasketItem(drug))),
|
|
130
|
-
[orders, drug],
|
|
147
|
+
() => orders?.some((order) => ordersEqual(order, getTemplateOrderBasketItem(drug, visit))),
|
|
148
|
+
[orders, drug, visit],
|
|
131
149
|
);
|
|
132
150
|
// TODO: use the backend instead of this to determine whether the drug formulation can be ordered
|
|
133
151
|
// See: https://openmrs.atlassian.net/browse/RESTWS-1003
|
|
134
152
|
const drugAlreadyPrescribed = useMemo(
|
|
135
153
|
() => activeOrders?.some((order) => order?.drug?.uuid === drug?.uuid),
|
|
136
|
-
[activeOrders, drug],
|
|
154
|
+
[activeOrders, drug?.uuid],
|
|
137
155
|
);
|
|
138
156
|
|
|
139
157
|
const { templates, error: fetchingDrugOrderTemplatesError } = useDrugTemplate(drug?.uuid);
|
|
@@ -142,9 +160,9 @@ const DrugSearchResultItem: React.FC<DrugSearchResultItemProps> = ({ patient, dr
|
|
|
142
160
|
const drugItemTemplateOptions: Array<DrugOrderBasketItem> = useMemo(
|
|
143
161
|
() =>
|
|
144
162
|
templates?.length
|
|
145
|
-
? templates.map((template) => getTemplateOrderBasketItem(drug, config?.daysDurationUnit, template))
|
|
146
|
-
: [getTemplateOrderBasketItem(drug, config?.daysDurationUnit)],
|
|
147
|
-
[templates, drug, config?.daysDurationUnit],
|
|
163
|
+
? templates.map((template) => getTemplateOrderBasketItem(drug, visit, config?.daysDurationUnit, template))
|
|
164
|
+
: [getTemplateOrderBasketItem(drug, visit, config?.daysDurationUnit)],
|
|
165
|
+
[templates, drug, config?.daysDurationUnit, visit],
|
|
148
166
|
);
|
|
149
167
|
|
|
150
168
|
const addToBasket = useCallback(
|
|
@@ -152,12 +170,9 @@ const DrugSearchResultItem: React.FC<DrugSearchResultItemProps> = ({ patient, dr
|
|
|
152
170
|
// Directly adding the order to basket should be marked as incomplete
|
|
153
171
|
searchResult.isOrderIncomplete = true;
|
|
154
172
|
setOrders([...orders, searchResult]);
|
|
155
|
-
closeWorkspace(
|
|
156
|
-
ignoreChanges: true,
|
|
157
|
-
onWorkspaceClose: () => launchWorkspace('order-basket'),
|
|
158
|
-
});
|
|
173
|
+
closeWorkspace();
|
|
159
174
|
},
|
|
160
|
-
[orders, setOrders],
|
|
175
|
+
[orders, setOrders, closeWorkspace],
|
|
161
176
|
);
|
|
162
177
|
|
|
163
178
|
const removeFromBasket = useCallback(
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type Workspace2DefinitionProps } from '@openmrs/esm-framework';
|
|
3
|
+
import { type ExportedOrderBasketWindowProps, type DrugOrderBasketItem } from '@openmrs/esm-patient-common-lib';
|
|
4
|
+
import AddDrugOrder from './add-drug-order.component';
|
|
5
|
+
|
|
6
|
+
export interface AddDrugOrderWorkspaceAdditionalProps {
|
|
7
|
+
order: DrugOrderBasketItem;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* This workspace is meant for use outside the patient chart
|
|
12
|
+
* @see add-drug-order.workspace.tsx
|
|
13
|
+
*/
|
|
14
|
+
export default function ExportedAddDrugOrderWorkspace({
|
|
15
|
+
workspaceProps: { order: initialOrder },
|
|
16
|
+
windowProps: { patient, patientUuid, visitContext },
|
|
17
|
+
closeWorkspace,
|
|
18
|
+
}: Workspace2DefinitionProps<AddDrugOrderWorkspaceAdditionalProps, ExportedOrderBasketWindowProps, {}>) {
|
|
19
|
+
return (
|
|
20
|
+
<AddDrugOrder
|
|
21
|
+
initialOrder={initialOrder}
|
|
22
|
+
patient={patient}
|
|
23
|
+
patientUuid={patientUuid}
|
|
24
|
+
visitContext={visitContext}
|
|
25
|
+
closeWorkspace={closeWorkspace}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
|
-
import { useTranslation } from 'react-i18next';
|
|
3
2
|
import {
|
|
4
3
|
type ConfigObject,
|
|
5
4
|
type DefaultWorkspaceProps,
|
|
@@ -8,10 +7,10 @@ import {
|
|
|
8
7
|
useSession,
|
|
9
8
|
useVisit,
|
|
10
9
|
} from '@openmrs/esm-framework';
|
|
11
|
-
import { type EncounterPost, postEncounter } from '@openmrs/esm-patient-common-lib';
|
|
12
|
-
import { type DrugOrderBasketItem } from '../types';
|
|
10
|
+
import { type DrugOrderBasketItem, type EncounterPost, postEncounter } from '@openmrs/esm-patient-common-lib';
|
|
13
11
|
import { prepMedicationOrderPostData } from '../api';
|
|
14
12
|
import DrugOrderForm from './drug-order-form.component';
|
|
13
|
+
import { useTranslation } from 'react-i18next';
|
|
15
14
|
|
|
16
15
|
export interface FillPrescriptionFormProps extends DefaultWorkspaceProps {
|
|
17
16
|
patient: fhir.Patient;
|
|
@@ -95,15 +94,15 @@ const FillPrescriptionForm: React.FC<FillPrescriptionFormProps> = ({
|
|
|
95
94
|
}
|
|
96
95
|
return (
|
|
97
96
|
<DrugOrderForm
|
|
98
|
-
patientUuid={patientUuid}
|
|
99
97
|
initialOrderBasketItem={{ action: 'NEW' } as DrugOrderBasketItem}
|
|
100
98
|
patient={patient}
|
|
101
99
|
onSave={submitDrugOrder}
|
|
102
100
|
saveButtonText={t('fillPrescription', 'Fill prescription')}
|
|
103
101
|
onCancel={closeWorkspace}
|
|
104
|
-
promptBeforeClosing={promptBeforeClosing}
|
|
105
102
|
allowSelectingPrescribingClinician={true}
|
|
103
|
+
visitContext={activeVisit}
|
|
106
104
|
allowSelectingDrug={true}
|
|
105
|
+
workspaceTitle={t('fillPrescription', 'Fill prescription')}
|
|
107
106
|
/>
|
|
108
107
|
);
|
|
109
108
|
};
|
package/src/api/api.ts
CHANGED
|
@@ -2,16 +2,20 @@ import { useCallback, useMemo } from 'react';
|
|
|
2
2
|
import useSWR, { useSWRConfig } from 'swr';
|
|
3
3
|
import useSWRImmutable from 'swr/immutable';
|
|
4
4
|
import { openmrsFetch, restBaseUrl, useConfig, useOpenmrsFetchAll, type FetchResponse } from '@openmrs/esm-framework';
|
|
5
|
-
import type {
|
|
5
|
+
import type {
|
|
6
|
+
DrugOrderBasketItem,
|
|
7
|
+
DrugOrderPost,
|
|
8
|
+
PatientOrderFetchResponse,
|
|
9
|
+
Order,
|
|
10
|
+
} from '@openmrs/esm-patient-common-lib';
|
|
6
11
|
import { type ConfigObject } from '../config-schema';
|
|
7
|
-
import { type DrugOrderBasketItem } from '../types';
|
|
8
12
|
|
|
9
13
|
export const careSettingUuid = '6f0c9a92-6f24-11e3-af88-005056821db0';
|
|
10
14
|
|
|
11
15
|
const customRepresentation =
|
|
12
16
|
'custom:(uuid,dosingType,orderNumber,accessionNumber,' +
|
|
13
17
|
'patient:ref,action,careSetting:ref,previousOrder:ref,dateActivated,scheduledDate,dateStopped,autoExpireDate,' +
|
|
14
|
-
'orderType:ref,encounter:
|
|
18
|
+
'orderType:ref,encounter:(uuid,display,visit),orderer:(uuid,display,person:(display)),orderReason,orderReasonNonCoded,orderType,urgency,instructions,' +
|
|
15
19
|
'commentToFulfiller,fulfillerStatus,drug:(uuid,display,strength,dosageForm:(display,uuid),concept),dose,doseUnits:ref,' +
|
|
16
20
|
'frequency:ref,asNeeded,asNeededCondition,quantity,quantityUnits:ref,numRefills,dosingInstructions,' +
|
|
17
21
|
'duration,durationUnits:ref,route:ref,brandName,dispenseAsWritten)';
|
package/src/api/order-config.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
|
|
2
|
-
import { useMemo } from 'react';
|
|
3
|
-
import useSWRImmutable from 'swr/immutable';
|
|
4
2
|
import {
|
|
5
3
|
type DosingUnit,
|
|
6
4
|
type DurationUnit,
|
|
7
5
|
type MedicationFrequency,
|
|
8
6
|
type MedicationRoute,
|
|
9
7
|
type QuantityUnit,
|
|
10
|
-
} from '
|
|
8
|
+
} from '@openmrs/esm-patient-common-lib';
|
|
9
|
+
import { useMemo } from 'react';
|
|
10
|
+
import useSWRImmutable from 'swr/immutable';
|
|
11
11
|
|
|
12
12
|
export interface ConceptName {
|
|
13
13
|
uuid: string;
|
|
@@ -21,10 +21,15 @@ import {
|
|
|
21
21
|
import {
|
|
22
22
|
CardHeader,
|
|
23
23
|
compare,
|
|
24
|
+
type DrugOrderBasketItem,
|
|
24
25
|
PatientChartPagination,
|
|
25
26
|
type Order,
|
|
26
27
|
useLaunchWorkspaceRequiringVisit,
|
|
27
28
|
useOrderBasket,
|
|
29
|
+
type PatientWorkspaceGroupProps,
|
|
30
|
+
invalidateVisitByUuid,
|
|
31
|
+
invalidateVisitAndEncounterData,
|
|
32
|
+
type OrderBasketWindowProps,
|
|
28
33
|
} from '@openmrs/esm-patient-common-lib';
|
|
29
34
|
import {
|
|
30
35
|
AddIcon,
|
|
@@ -36,14 +41,16 @@ import {
|
|
|
36
41
|
useLayoutType,
|
|
37
42
|
usePagination,
|
|
38
43
|
UserIcon,
|
|
44
|
+
launchWorkspace2,
|
|
45
|
+
type Encounter,
|
|
39
46
|
} from '@openmrs/esm-framework';
|
|
40
47
|
import { useTranslation } from 'react-i18next';
|
|
41
48
|
import { useReactToPrint } from 'react-to-print';
|
|
42
|
-
import { type AddDrugOrderWorkspaceAdditionalProps } from '../add-drug-order/add-drug-order.workspace';
|
|
43
|
-
import { type DrugOrderBasketItem } from '../types';
|
|
44
49
|
import { type ConfigObject } from '../config-schema';
|
|
45
50
|
import PrintComponent from '../print/print.component';
|
|
46
51
|
import styles from './medications-details-table.scss';
|
|
52
|
+
import { useSWRConfig } from 'swr';
|
|
53
|
+
import { type AddDrugOrderWorkspaceProps } from '../add-drug-order/add-drug-order.workspace';
|
|
47
54
|
|
|
48
55
|
export interface MedicationsDetailsTableProps {
|
|
49
56
|
isValidating?: boolean;
|
|
@@ -69,7 +76,6 @@ const MedicationsDetailsTable: React.FC<MedicationsDetailsTableProps> = ({
|
|
|
69
76
|
const pageSize = 5;
|
|
70
77
|
const { t } = useTranslation();
|
|
71
78
|
const launchOrderBasket = useLaunchWorkspaceRequiringVisit(patient.id, 'order-basket');
|
|
72
|
-
const launchAddDrugOrder = useLaunchWorkspaceRequiringVisit(patient.id, 'add-drug-order');
|
|
73
79
|
const config = useConfig<ConfigObject>();
|
|
74
80
|
const showPrintButton = config.showPrintButton;
|
|
75
81
|
const contentToPrintRef = useRef(null);
|
|
@@ -251,7 +257,7 @@ const MedicationsDetailsTable: React.FC<MedicationsDetailsTableProps> = ({
|
|
|
251
257
|
kind="ghost"
|
|
252
258
|
renderIcon={(props: ComponentProps<typeof AddIcon>) => <AddIcon size={16} {...props} />}
|
|
253
259
|
iconDescription="Launch order basket"
|
|
254
|
-
onClick={
|
|
260
|
+
onClick={() => launchOrderBasket({}, { encounterUuid: '' })}
|
|
255
261
|
>
|
|
256
262
|
{t('add', 'Add')}
|
|
257
263
|
</Button>
|
|
@@ -298,14 +304,13 @@ const MedicationsDetailsTable: React.FC<MedicationsDetailsTableProps> = ({
|
|
|
298
304
|
{!isPrinting && (
|
|
299
305
|
<TableCell className="cds--table-column-menu">
|
|
300
306
|
<OrderBasketItemActions
|
|
307
|
+
patient={patient}
|
|
301
308
|
showDiscontinueButton={showDiscontinueButton}
|
|
302
309
|
showModifyButton={showModifyButton}
|
|
303
310
|
showReorderButton={showReorderButton}
|
|
304
311
|
medication={medications[rowIndex]}
|
|
305
312
|
items={orders}
|
|
306
313
|
setItems={setOrders}
|
|
307
|
-
openOrderBasket={launchOrderBasket}
|
|
308
|
-
openDrugOrderForm={launchAddDrugOrder}
|
|
309
314
|
/>
|
|
310
315
|
</TableCell>
|
|
311
316
|
)}
|
|
@@ -337,27 +342,39 @@ function InfoTooltip({ orderer }: { orderer: string }) {
|
|
|
337
342
|
}
|
|
338
343
|
|
|
339
344
|
function OrderBasketItemActions({
|
|
345
|
+
patient,
|
|
340
346
|
showDiscontinueButton,
|
|
341
347
|
showModifyButton,
|
|
342
348
|
showReorderButton,
|
|
343
349
|
medication,
|
|
344
350
|
items,
|
|
345
351
|
setItems,
|
|
346
|
-
openOrderBasket,
|
|
347
|
-
openDrugOrderForm,
|
|
348
352
|
}: {
|
|
353
|
+
patient: fhir.Patient;
|
|
349
354
|
showDiscontinueButton: boolean;
|
|
350
355
|
showModifyButton: boolean;
|
|
351
356
|
showReorderButton: boolean;
|
|
352
357
|
medication: Order;
|
|
353
358
|
items: Array<DrugOrderBasketItem>;
|
|
354
359
|
setItems: (items: Array<DrugOrderBasketItem>) => void;
|
|
355
|
-
openOrderBasket: () => void;
|
|
356
|
-
openDrugOrderForm: (additionalProps?: AddDrugOrderWorkspaceAdditionalProps) => void;
|
|
357
360
|
}) {
|
|
361
|
+
const { mutate: globalMutate } = useSWRConfig();
|
|
358
362
|
const { t } = useTranslation();
|
|
359
363
|
const isTablet = useLayoutType() === 'tablet';
|
|
360
364
|
const alreadyInBasket = items.some((x) => x.uuid === medication.uuid);
|
|
365
|
+
|
|
366
|
+
const workspaceGroupProps: PatientWorkspaceGroupProps = useMemo(
|
|
367
|
+
() => ({
|
|
368
|
+
patient,
|
|
369
|
+
patientUuid: patient.id,
|
|
370
|
+
visitContext: medication.encounter.visit,
|
|
371
|
+
mutateVisitContext: () => {
|
|
372
|
+
invalidateVisitByUuid(globalMutate, medication.encounter.visit?.uuid);
|
|
373
|
+
invalidateVisitAndEncounterData(globalMutate, patient.id);
|
|
374
|
+
},
|
|
375
|
+
}),
|
|
376
|
+
[patient, medication, globalMutate],
|
|
377
|
+
);
|
|
361
378
|
const handleDiscontinueClick = useCallback(() => {
|
|
362
379
|
setItems([
|
|
363
380
|
...items,
|
|
@@ -403,10 +420,17 @@ function OrderBasketItemActions({
|
|
|
403
420
|
value: medication.quantityUnits?.display,
|
|
404
421
|
valueCoded: medication.quantityUnits?.uuid,
|
|
405
422
|
},
|
|
423
|
+
encounterUuid: medication.encounter?.uuid,
|
|
424
|
+
visit: medication.encounter?.visit,
|
|
406
425
|
},
|
|
407
426
|
]);
|
|
408
|
-
|
|
409
|
-
|
|
427
|
+
launchWorkspace2<{}, OrderBasketWindowProps, PatientWorkspaceGroupProps>(
|
|
428
|
+
'order-basket',
|
|
429
|
+
{},
|
|
430
|
+
{ encounterUuid: medication.encounter.uuid },
|
|
431
|
+
workspaceGroupProps,
|
|
432
|
+
);
|
|
433
|
+
}, [items, setItems, medication, workspaceGroupProps]);
|
|
410
434
|
|
|
411
435
|
const handleModifyClick = useCallback(() => {
|
|
412
436
|
const newItem: DrugOrderBasketItem = {
|
|
@@ -451,10 +475,18 @@ function OrderBasketItemActions({
|
|
|
451
475
|
value: medication.quantityUnits?.display,
|
|
452
476
|
valueCoded: medication.quantityUnits?.uuid,
|
|
453
477
|
},
|
|
478
|
+
encounterUuid: medication.encounter?.uuid,
|
|
479
|
+
visit: medication.encounter?.visit,
|
|
454
480
|
};
|
|
455
481
|
setItems([...items, newItem]);
|
|
456
|
-
|
|
457
|
-
|
|
482
|
+
|
|
483
|
+
launchWorkspace2<AddDrugOrderWorkspaceProps, OrderBasketWindowProps, PatientWorkspaceGroupProps>(
|
|
484
|
+
'add-drug-order',
|
|
485
|
+
{ order: newItem },
|
|
486
|
+
{ encounterUuid: medication.encounter.uuid },
|
|
487
|
+
workspaceGroupProps,
|
|
488
|
+
);
|
|
489
|
+
}, [items, setItems, medication, workspaceGroupProps]);
|
|
458
490
|
|
|
459
491
|
const handleReorderClick = useCallback(() => {
|
|
460
492
|
setItems([
|
|
@@ -501,10 +533,17 @@ function OrderBasketItemActions({
|
|
|
501
533
|
value: medication.quantityUnits?.display,
|
|
502
534
|
valueCoded: medication.quantityUnits?.uuid,
|
|
503
535
|
},
|
|
536
|
+
encounterUuid: medication.encounter?.uuid,
|
|
537
|
+
visit: medication.encounter?.visit,
|
|
504
538
|
},
|
|
505
539
|
]);
|
|
506
|
-
|
|
507
|
-
|
|
540
|
+
launchWorkspace2<{}, OrderBasketWindowProps, PatientWorkspaceGroupProps>(
|
|
541
|
+
'order-basket',
|
|
542
|
+
{},
|
|
543
|
+
{ encounterUuid: medication.encounter.uuid },
|
|
544
|
+
workspaceGroupProps,
|
|
545
|
+
);
|
|
546
|
+
}, [items, setItems, medication, workspaceGroupProps]);
|
|
508
547
|
|
|
509
548
|
return (
|
|
510
549
|
<OverflowMenu aria-label="Actions menu" selectorPrimaryFocus={'#modify'} flipped size={isTablet ? 'lg' : 'md'}>
|