@kenyaemr/esm-express-workflow-app 5.4.3 → 5.4.4-pre.100
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 +7 -12
- package/dist/1074.js +1 -0
- package/dist/1074.js.map +1 -0
- package/dist/12.js +17 -0
- package/dist/12.js.map +1 -0
- package/dist/1311.js +1 -0
- package/dist/1311.js.map +1 -0
- package/dist/1323.js +1 -0
- package/dist/1323.js.map +1 -0
- package/dist/1469.js +1 -0
- package/dist/1469.js.map +1 -0
- package/dist/1506.js +13 -0
- package/dist/1506.js.map +1 -0
- package/dist/1562.js +1 -0
- package/dist/1562.js.map +1 -0
- package/dist/1760.js +1 -0
- package/dist/1760.js.map +1 -0
- package/dist/1780.js +1 -0
- package/dist/1780.js.map +1 -0
- package/dist/1804.js +1 -0
- package/dist/1804.js.map +1 -0
- package/dist/1884.js +1 -0
- package/dist/1884.js.map +1 -0
- package/dist/1972.js +1 -0
- package/dist/1972.js.map +1 -0
- package/dist/1990.js +1 -0
- package/dist/1990.js.map +1 -0
- package/dist/2016.js +1 -0
- package/dist/2016.js.map +1 -0
- package/dist/2024.js +1 -0
- package/dist/2024.js.map +1 -0
- package/dist/2153.js +1 -0
- package/dist/2153.js.map +1 -0
- package/dist/216.js +1 -0
- package/dist/216.js.map +1 -0
- package/dist/2225.js +1 -0
- package/dist/2225.js.map +1 -0
- package/dist/2294.js +1 -0
- package/dist/2294.js.map +1 -0
- package/dist/2345.js +1 -0
- package/dist/2345.js.map +1 -0
- package/dist/2499.js +1 -0
- package/dist/2499.js.map +1 -0
- package/dist/2500.js +1 -0
- package/dist/2500.js.map +1 -0
- package/dist/2586.js +1 -0
- package/dist/2586.js.map +1 -0
- package/dist/2625.js +1 -0
- package/dist/2625.js.map +1 -0
- package/dist/2685.js +1 -0
- package/dist/2685.js.map +1 -0
- package/dist/2809.js +1 -0
- package/dist/2809.js.map +1 -0
- package/dist/2851.js +1 -0
- package/dist/2851.js.map +1 -0
- package/dist/2881.js +1 -0
- package/dist/2881.js.map +1 -0
- package/dist/2948.js +1 -0
- package/dist/2948.js.map +1 -0
- package/dist/2968.js +1 -0
- package/dist/2968.js.map +1 -0
- package/dist/2978.js +1 -0
- package/dist/2978.js.map +1 -0
- package/dist/2998.js +1 -0
- package/dist/2998.js.map +1 -0
- package/dist/3089.js +1 -0
- package/dist/3089.js.map +1 -0
- package/dist/3548.js +1 -0
- package/dist/3548.js.map +1 -0
- package/dist/3567.js +1 -0
- package/dist/3567.js.map +1 -0
- package/dist/3569.js +1 -0
- package/dist/3569.js.map +1 -0
- package/dist/3571.js +1 -0
- package/dist/3571.js.map +1 -0
- package/dist/3691.js +1 -0
- package/dist/3691.js.map +1 -0
- package/dist/3730.js +1 -0
- package/dist/3730.js.map +1 -0
- package/dist/3923.js +1 -0
- package/dist/3923.js.map +1 -0
- package/dist/3963.js +1 -0
- package/dist/3963.js.map +1 -0
- package/dist/4024.js +1 -0
- package/dist/4024.js.map +1 -0
- package/dist/405.js +1 -0
- package/dist/405.js.map +1 -0
- package/dist/4071.js +1 -0
- package/dist/4071.js.map +1 -0
- package/dist/4271.js +1 -0
- package/dist/4271.js.map +1 -0
- package/dist/4296.js +1 -0
- package/dist/4296.js.map +1 -0
- package/dist/4337.js +1 -0
- package/dist/4337.js.map +1 -0
- package/dist/4432.js +1 -0
- package/dist/4432.js.map +1 -0
- package/dist/4581.js +1 -0
- package/dist/4581.js.map +1 -0
- package/dist/4637.js +11 -0
- package/dist/4637.js.map +1 -0
- package/dist/4666.js +1 -0
- package/dist/4666.js.map +1 -0
- package/dist/4680.js +1 -0
- package/dist/4680.js.map +1 -0
- package/dist/4735.js +1 -0
- package/dist/4735.js.map +1 -0
- package/dist/4737.js +1 -0
- package/dist/4737.js.map +1 -0
- package/dist/4744.js +1 -0
- package/dist/4744.js.map +1 -0
- package/dist/4795.js +1 -0
- package/dist/4795.js.map +1 -0
- package/dist/4813.js +2 -0
- package/dist/4813.js.map +1 -0
- package/dist/4818.js +1 -0
- package/dist/4818.js.map +1 -0
- package/dist/4858.js +1 -0
- package/dist/4858.js.map +1 -0
- package/dist/487.js +1 -0
- package/dist/487.js.map +1 -0
- package/dist/4970.js +1 -0
- package/dist/4970.js.map +1 -0
- package/dist/5038.js +1 -0
- package/dist/5038.js.map +1 -0
- package/dist/5202.js +1 -0
- package/dist/5202.js.map +1 -0
- package/dist/5491.js +1 -0
- package/dist/5491.js.map +1 -0
- package/dist/5592.js +1 -0
- package/dist/5592.js.map +1 -0
- package/dist/5669.js +1 -0
- package/dist/5669.js.map +1 -0
- package/dist/586.js +1 -0
- package/dist/586.js.map +1 -0
- package/dist/5932.js +1 -0
- package/dist/5932.js.map +1 -0
- package/dist/5995.js +1 -0
- package/dist/5995.js.map +1 -0
- package/dist/6258.js +1 -0
- package/dist/6258.js.map +1 -0
- package/dist/629.js +1 -0
- package/dist/629.js.map +1 -0
- package/dist/6328.js +1 -0
- package/dist/6328.js.map +1 -0
- package/dist/6355.js +1 -0
- package/dist/6355.js.map +1 -0
- package/dist/6419.js +1 -0
- package/dist/6419.js.map +1 -0
- package/dist/644.js +1 -0
- package/dist/644.js.map +1 -0
- package/dist/6456.js +1 -0
- package/dist/6466.js +3 -0
- package/dist/6466.js.map +1 -0
- package/dist/655.js +1 -0
- package/dist/655.js.map +1 -0
- package/dist/6798.js +66 -0
- package/dist/6798.js.map +1 -0
- package/dist/6910.js +1 -0
- package/dist/6910.js.map +1 -0
- package/dist/6925.js +1 -0
- package/dist/6925.js.map +1 -0
- package/dist/70.js +1 -0
- package/dist/70.js.map +1 -0
- package/dist/7201.js +1 -0
- package/dist/7201.js.map +1 -0
- package/dist/7234.js +1 -0
- package/dist/7234.js.map +1 -0
- package/dist/7261.js +1 -0
- package/dist/7261.js.map +1 -0
- package/dist/7326.js +1 -0
- package/dist/7359.js +1 -0
- package/dist/7487.js +1 -0
- package/dist/7487.js.map +1 -0
- package/dist/7591.js +1 -0
- package/dist/7591.js.map +1 -0
- package/dist/7607.js +1 -0
- package/dist/7701.js +1 -0
- package/dist/7701.js.map +1 -0
- package/dist/7717.js +1 -0
- package/dist/7717.js.map +1 -0
- package/dist/7739.js +1 -0
- package/dist/7739.js.map +1 -0
- package/dist/7788.js +1 -0
- package/dist/7788.js.map +1 -0
- package/dist/7819.js +1 -0
- package/dist/7819.js.map +1 -0
- package/dist/7971.js +1 -0
- package/dist/7971.js.map +1 -0
- package/dist/7983.js +1 -0
- package/dist/7983.js.map +1 -0
- package/dist/807.js +1 -0
- package/dist/807.js.map +1 -0
- package/dist/8159.js +7 -0
- package/dist/8159.js.map +1 -0
- package/dist/8338.js +1 -0
- package/dist/8338.js.map +1 -0
- package/dist/845.js +1 -0
- package/dist/845.js.map +1 -0
- package/dist/8570.js +1 -0
- package/dist/8570.js.map +1 -0
- package/dist/8661.js +1 -0
- package/dist/8661.js.map +1 -0
- package/dist/87.js +1 -0
- package/dist/87.js.map +1 -0
- package/dist/8727.js +1 -0
- package/dist/8766.js +1 -0
- package/dist/8766.js.map +1 -0
- package/dist/8828.js +1 -0
- package/dist/8828.js.map +1 -0
- package/dist/8860.js +1 -0
- package/dist/8860.js.map +1 -0
- package/dist/8911.js +1 -0
- package/dist/8911.js.map +1 -0
- package/dist/8930.js +1 -0
- package/dist/8930.js.map +1 -0
- package/dist/8971.js +1 -0
- package/dist/8971.js.map +1 -0
- package/dist/9124.js +1 -0
- package/dist/9124.js.map +1 -0
- package/dist/9157.js +1 -0
- package/dist/9157.js.map +1 -0
- package/dist/9182.js +1 -0
- package/dist/921.js +1 -0
- package/dist/921.js.map +1 -0
- package/dist/9212.js +1 -0
- package/dist/9212.js.map +1 -0
- package/dist/9255.js +1 -0
- package/dist/9255.js.map +1 -0
- package/dist/9257.js +1 -0
- package/dist/9257.js.map +1 -0
- package/dist/9316.js +1 -0
- package/dist/9316.js.map +1 -0
- package/dist/9333.js +1 -0
- package/dist/9333.js.map +1 -0
- package/dist/9404.js +1 -0
- package/dist/9404.js.map +1 -0
- package/dist/9446.js +1 -0
- package/dist/9446.js.map +1 -0
- package/dist/9447.js +1 -0
- package/dist/9447.js.map +1 -0
- package/dist/9449.js +1 -0
- package/dist/9449.js.map +1 -0
- package/dist/9535.js +1 -0
- package/dist/9535.js.map +1 -0
- package/dist/9606.js +1 -0
- package/dist/9606.js.map +1 -0
- package/dist/973.js +1 -0
- package/dist/973.js.map +1 -0
- package/dist/9845.js +1 -0
- package/dist/9845.js.map +1 -0
- package/dist/kenyaemr-esm-express-workflow-app.js +5 -5
- package/dist/kenyaemr-esm-express-workflow-app.js.buildmanifest.json +3004 -175
- package/dist/kenyaemr-esm-express-workflow-app.js.map +1 -1
- package/dist/main.js +5 -114
- package/dist/main.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +6 -7
- package/rspack.config.js +1 -1
- package/src/components/accounting/index.tsx +11 -10
- package/src/components/admissions/index.tsx +11 -10
- package/src/components/appointments/index.ts +10 -8
- package/src/components/consultation/clinical-encounter/encounter-details.component.tsx +9 -9
- package/src/components/consultation/clinical-encounter/encounter-details.test.tsx +19 -18
- package/src/components/consultation/consultation-context.tsx +19 -0
- package/src/components/consultation/consultation-summary-cards.component.tsx +124 -0
- package/src/components/consultation/consultation.component.tsx +41 -268
- package/src/components/consultation/consultation.resource.ts +67 -24
- package/src/components/consultation/consultation.scss +5 -0
- package/src/components/consultation/consultation.utils.tsx +222 -0
- package/src/components/consultation/dashboard.component.tsx +0 -2
- package/src/components/consultation/index.ts +27 -20
- package/src/components/facility-dashboard/index.tsx +10 -9
- package/src/components/laboratory/index.ts +11 -10
- package/src/components/laboratory/lab-table.component.tsx +22 -8
- package/src/components/laboratory/laboratory-tabs.component.tsx +2 -2
- package/src/components/mch/dashboard.component.tsx +0 -2
- package/src/components/mch/index.tsx +10 -9
- package/src/components/mch/mch.consultation.component.tsx +27 -15
- package/src/components/mch/mch.triage.component.tsx +42 -33
- package/src/components/pharmacy/index.ts +20 -18
- package/src/components/pharmacy/orders/pharmacy-orders.component.tsx +35 -13
- package/src/components/pharmacy/orders/pharmacy-orders.test.tsx +8 -7
- package/src/components/procedures/index.ts +11 -10
- package/src/components/procedures/procedures-table.component.tsx +44 -13
- package/src/components/procedures/procedures-tabs.component.tsx +2 -2
- package/src/components/radiology-and-imaging/index.ts +14 -10
- package/src/components/radiology-and-imaging/radiology-and-imaging-table.component.tsx +35 -15
- package/src/components/radiology-and-imaging/radiology-and-imaging.component.tsx +2 -2
- package/src/components/registration/card/HIE-card/hie-card.component.tsx +32 -44
- package/src/components/registration/card/Local-card/local-card.component.tsx +22 -24
- package/src/components/registration/dependants/dependants.component.tsx +32 -60
- package/src/components/registration/dependants/dependants.resource.ts +79 -50
- package/src/components/registration/helper/index.ts +4 -0
- package/src/components/registration/index.ts +10 -9
- package/src/components/registration/search-bar/search-bar.resource.ts +32 -93
- package/src/components/registration/start-visit-form/hooks/useDefaultFacilityLocation.tsx +15 -0
- package/src/components/registration/start-visit-form/hooks/useDefaultVisitLocation.tsx +24 -0
- package/src/components/registration/start-visit-form/hooks/useOfflineVisitType.tsx +18 -0
- package/src/components/registration/start-visit-form/hooks/useRecommendedVisitTypes.tsx +36 -0
- package/src/components/registration/start-visit-form/hooks/useVisitAttributeType.tsx +102 -0
- package/src/components/registration/start-visit-form/overflow-menu-extension/overflow-menu-item.extension.tsx +55 -0
- package/src/components/registration/start-visit-form/overflow-menu-extension/overflow-menu-item.scss +3 -0
- package/src/components/registration/start-visit-form/start-visit-workspace/base-visit-type.component.tsx +126 -0
- package/src/components/registration/start-visit-form/start-visit-workspace/base-visit-type.scss +75 -0
- package/src/components/registration/start-visit-form/start-visit-workspace/exported-visit-form.workspace.tsx +743 -0
- package/src/components/registration/start-visit-form/start-visit-workspace/location-selector.component.tsx +86 -0
- package/src/components/registration/start-visit-form/start-visit-workspace/recommended-visit-type.component.tsx +32 -0
- package/src/components/registration/start-visit-form/start-visit-workspace/visit-attribute-type.component.tsx +257 -0
- package/src/components/registration/start-visit-form/start-visit-workspace/visit-attribute-type.scss +5 -0
- package/src/components/registration/start-visit-form/start-visit-workspace/visit-date-time.component.tsx +193 -0
- package/src/components/registration/start-visit-form/start-visit-workspace/visit-form.resource.ts +383 -0
- package/src/components/registration/start-visit-form/start-visit-workspace/visit-form.scss +166 -0
- package/src/components/registration/start-visit-form/visit-form-workspace/visit-form.workspace.tsx +55 -0
- package/src/components/reports/index.ts +10 -9
- package/src/components/triage/dashboard.component.tsx +0 -2
- package/src/components/triage/index.ts +10 -9
- package/src/components/triage/triage.component.tsx +92 -42
- package/src/components/triage/triage.resource.ts +56 -50
- package/src/components/triage/triage.scss +6 -0
- package/src/config-schema.ts +91 -0
- package/src/hooks/useServiceQueues.tsx +95 -25
- package/src/index.ts +32 -13
- package/src/routes.json +53 -254
- package/src/shared/orders/OrdersTabs.tsx +8 -3
- package/src/shared/patient-chart/patient-chart.resources.ts +8 -12
- package/src/shared/patient-chart/patient-summary-dashboard/patient-summary-dashboard.component.tsx +1 -2
- package/src/shared/pin-put/pinput.component.test.tsx +7 -6
- package/src/shared/queue/queue-entry/queue-entry-table.component.tsx +99 -88
- package/src/shared/queue/queue-entry/queue-entry-table.scss +4 -0
- package/src/shared/queue/queue-summary-cards.component.tsx +32 -0
- package/src/shared/queue/queue-tab.component.tsx +182 -70
- package/src/shared/queue/queue-tab.scss +1 -0
- package/src/shared/queue/queue-workflow-context.tsx +90 -0
- package/src/shared/tabs/extension-tabs.component.tsx +9 -6
- package/src/shared/utils/index.ts +1 -2
- package/src/types/index.ts +17 -2
- package/translations/am.json +64 -13
- package/translations/en.json +59 -8
- package/translations/sw.json +58 -7
- package/dist/127.js +0 -1
- package/dist/200.js +0 -1
- package/dist/200.js.map +0 -1
- package/dist/24.js +0 -1
- package/dist/24.js.map +0 -1
- package/dist/267.js +0 -1
- package/dist/267.js.map +0 -1
- package/dist/285.js +0 -1
- package/dist/285.js.map +0 -1
- package/dist/329.js +0 -1
- package/dist/329.js.map +0 -1
- package/dist/40.js +0 -1
- package/dist/466.js +0 -1
- package/dist/466.js.map +0 -1
- package/dist/472.js +0 -66
- package/dist/472.js.map +0 -1
- package/dist/490.js +0 -1
- package/dist/490.js.map +0 -1
- package/dist/54.js +0 -1
- package/dist/54.js.map +0 -1
- package/dist/689.js +0 -1
- package/dist/689.js.map +0 -1
- package/dist/697.js +0 -1
- package/dist/697.js.map +0 -1
- package/dist/704.js +0 -1
- package/dist/704.js.map +0 -1
- package/dist/710.js +0 -1
- package/dist/710.js.map +0 -1
- package/dist/729.js +0 -17
- package/dist/729.js.map +0 -1
- package/dist/805.js +0 -37
- package/dist/805.js.map +0 -1
- package/dist/847.js +0 -1
- package/dist/847.js.map +0 -1
- package/dist/85.js +0 -1
- package/dist/85.js.map +0 -1
- package/dist/882.js +0 -1
- package/dist/91.js +0 -1
- package/dist/91.js.map +0 -1
- package/dist/916.js +0 -1
- package/dist/994.js +0 -1
- package/dist/994.js.map +0 -1
- package/dist/998.js +0 -1
- package/dist/998.js.map +0 -1
- package/jest.config.js +0 -3
- package/src/shared/patient-chart/patient-chart.component.tsx +0 -61
- package/src/shared/patient-chart/patient-chart.scss +0 -15
- package/src/shared/patient-chart/useInitialize.ts +0 -24
package/src/components/registration/start-visit-form/start-visit-workspace/visit-form.resource.ts
ADDED
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
import { useMemo, useState } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import type { TFunction } from 'i18next';
|
|
4
|
+
import dayjs from 'dayjs';
|
|
5
|
+
import useSWRImmutable from 'swr/immutable';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import {
|
|
8
|
+
type FetchResponse,
|
|
9
|
+
openmrsFetch,
|
|
10
|
+
restBaseUrl,
|
|
11
|
+
useConfig,
|
|
12
|
+
useConnectivity,
|
|
13
|
+
useEmrConfiguration,
|
|
14
|
+
useFeatureFlag,
|
|
15
|
+
useSession,
|
|
16
|
+
useVisitTypes,
|
|
17
|
+
type Visit,
|
|
18
|
+
} from '@openmrs/esm-framework';
|
|
19
|
+
import { time12HourFormatRegex, type amPm } from '@openmrs/esm-patient-common-lib';
|
|
20
|
+
import { useDefaultVisitLocation } from '../hooks/useDefaultVisitLocation';
|
|
21
|
+
import { useOfflineVisitType } from '../hooks/useOfflineVisitType';
|
|
22
|
+
import { ExpressWorkflowConfig } from '../../../../config-schema';
|
|
23
|
+
|
|
24
|
+
export const visitStatuses = ['new', 'ongoing', 'past'] as const;
|
|
25
|
+
export type VisitStatus = (typeof visitStatuses)[number];
|
|
26
|
+
|
|
27
|
+
export type VisitFormData = {
|
|
28
|
+
visitStatus: VisitStatus;
|
|
29
|
+
visitStartDate: Date;
|
|
30
|
+
visitStartTime: string;
|
|
31
|
+
visitStartTimeFormat: amPm;
|
|
32
|
+
visitStopDate: Date;
|
|
33
|
+
visitStopTime: string;
|
|
34
|
+
visitStopTimeFormat: amPm;
|
|
35
|
+
programType: string;
|
|
36
|
+
visitType: string;
|
|
37
|
+
visitLocation: {
|
|
38
|
+
display?: string;
|
|
39
|
+
uuid?: string;
|
|
40
|
+
};
|
|
41
|
+
visitAttributes: {
|
|
42
|
+
[x: string]: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type FieldError = {
|
|
47
|
+
[key: string]: Array<{ code: string; message: string }>;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type ErrorObject = {
|
|
51
|
+
error: {
|
|
52
|
+
code: string;
|
|
53
|
+
message: string;
|
|
54
|
+
detail: string;
|
|
55
|
+
fieldErrors?: FieldError;
|
|
56
|
+
globalErrors?: Array<{ code: string; message: string }>;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export function extractErrorMessagesFromResponse(errorObject: ErrorObject, t: TFunction) {
|
|
61
|
+
const { fieldErrors, globalErrors, message, code } = errorObject?.error ?? {};
|
|
62
|
+
|
|
63
|
+
if (fieldErrors && Object.keys(fieldErrors).length > 0) {
|
|
64
|
+
return Object.values(fieldErrors)
|
|
65
|
+
.flatMap((errors) => errors.map((error) => error.message))
|
|
66
|
+
.join('\n');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (globalErrors && globalErrors.length > 0) {
|
|
70
|
+
return globalErrors.map((error) => error.message).join('\n');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return message ?? code ?? t('unknownError', 'Unknown error');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function useConditionalVisitTypes() {
|
|
77
|
+
const isOnline = useConnectivity();
|
|
78
|
+
const visitTypesHook = isOnline ? useVisitTypes : useOfflineVisitType;
|
|
79
|
+
return visitTypesHook();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
interface PatientPersonResponse {
|
|
83
|
+
person: {
|
|
84
|
+
birthdate: string | null;
|
|
85
|
+
birthdateEstimated: boolean;
|
|
86
|
+
age: number | null;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const patientPersonCustomRep = 'custom:(person:(birthdate,birthdateEstimated,age))';
|
|
91
|
+
|
|
92
|
+
function parseLocalDate(dateStr: string): Date | null {
|
|
93
|
+
const datePart = dateStr.split('T')[0];
|
|
94
|
+
const parts = datePart.split('-');
|
|
95
|
+
if (parts.length !== 3) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
const [y, m, d] = parts.map(Number);
|
|
99
|
+
return new Date(y, m - 1, d);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function computeEarliestAllowedStartDate(
|
|
103
|
+
birthdate: string | null,
|
|
104
|
+
birthdateEstimated: boolean,
|
|
105
|
+
age: number | null,
|
|
106
|
+
): Date | null {
|
|
107
|
+
if (!birthdate) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const earliest = parseLocalDate(birthdate);
|
|
112
|
+
if (!earliest) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (birthdateEstimated && age != null) {
|
|
117
|
+
const graceYears = Math.max(1, Math.floor(age * 0.5));
|
|
118
|
+
earliest.setFullYear(earliest.getFullYear() - graceYears);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return earliest;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function useEarliestAllowedVisitStartDate(patientUuid: string) {
|
|
125
|
+
const { data, isLoading } = useSWRImmutable<FetchResponse<PatientPersonResponse>>(
|
|
126
|
+
`${restBaseUrl}/patient/${patientUuid}?v=${patientPersonCustomRep}`,
|
|
127
|
+
openmrsFetch,
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
const earliestAllowedStartDate = useMemo(() => {
|
|
131
|
+
if (!data?.data?.person) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
const { birthdate, birthdateEstimated, age } = data.data.person;
|
|
135
|
+
return computeEarliestAllowedStartDate(birthdate, birthdateEstimated, age);
|
|
136
|
+
}, [data]);
|
|
137
|
+
|
|
138
|
+
return { earliestAllowedStartDate, isLoading };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function useAllowOverlappingVisits() {
|
|
142
|
+
const isOnline = useConnectivity();
|
|
143
|
+
const { data, error, isLoading } = useSWRImmutable<FetchResponse<{ value: string }>>(
|
|
144
|
+
isOnline ? `${restBaseUrl}/systemsetting/visits.allowOverlappingVisits?v=custom:(value)` : null,
|
|
145
|
+
openmrsFetch,
|
|
146
|
+
);
|
|
147
|
+
return {
|
|
148
|
+
allowOverlappingVisits: error || !data ? true : (data.data.value ?? 'true').toLowerCase() === 'true',
|
|
149
|
+
isLoading,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface VisitFormCallbacks {
|
|
154
|
+
onVisitCreatedOrUpdated: (visit: Visit) => Promise<any>;
|
|
155
|
+
/**
|
|
156
|
+
* Called BEFORE the visit is saved.
|
|
157
|
+
* Return true to proceed with saving, false to abort.
|
|
158
|
+
* Used by the SHA billing extension to launch the OTP modal before checkin.
|
|
159
|
+
*/
|
|
160
|
+
onBeforeVisitSave?: () => Promise<boolean>;
|
|
161
|
+
/**
|
|
162
|
+
* When true, signals ExportedVisitForm to change the submit button label
|
|
163
|
+
* from "Start Visit" to "Send OTP & Start Visit".
|
|
164
|
+
*/
|
|
165
|
+
isSHAVisit?: boolean;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export function useVisitFormCallbacks() {
|
|
169
|
+
return useState<Map<string, VisitFormCallbacks>>(new Map());
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function createVisitAttribute(visitUuid: string, attributeType: string, value: string) {
|
|
173
|
+
return openmrsFetch(`${restBaseUrl}/visit/${visitUuid}/attribute`, {
|
|
174
|
+
method: 'POST',
|
|
175
|
+
headers: { 'Content-type': 'application/json' },
|
|
176
|
+
body: { attributeType, value },
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export function updateVisitAttribute(visitUuid: string, visitAttributeUuid: string, value: string) {
|
|
181
|
+
return openmrsFetch(`${restBaseUrl}/visit/${visitUuid}/attribute/${visitAttributeUuid}`, {
|
|
182
|
+
method: 'POST',
|
|
183
|
+
headers: { 'Content-type': 'application/json' },
|
|
184
|
+
body: { value },
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export function deleteVisitAttribute(visitUuid: string, visitAttributeUuid: string) {
|
|
189
|
+
return openmrsFetch(`${restBaseUrl}/visit/${visitUuid}/attribute/${visitAttributeUuid}`, {
|
|
190
|
+
method: 'DELETE',
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export function useVisitFormSchemaAndDefaultValues(
|
|
195
|
+
visitToEdit: Visit | undefined,
|
|
196
|
+
earliestAllowedStartDate?: Date | null,
|
|
197
|
+
) {
|
|
198
|
+
const { t } = useTranslation();
|
|
199
|
+
const { visitAttributeTypes, restrictByVisitLocationTag } = useConfig<ExpressWorkflowConfig>();
|
|
200
|
+
const isEmrApiModuleInstalled = useFeatureFlag('emrapi-module');
|
|
201
|
+
const sessionUser = useSession();
|
|
202
|
+
const sessionLocation = sessionUser?.sessionLocation;
|
|
203
|
+
const defaultVisitLocation = useDefaultVisitLocation(
|
|
204
|
+
sessionLocation,
|
|
205
|
+
restrictByVisitLocationTag && isEmrApiModuleInstalled,
|
|
206
|
+
);
|
|
207
|
+
const { emrConfiguration } = useEmrConfiguration();
|
|
208
|
+
|
|
209
|
+
return useMemo(() => {
|
|
210
|
+
const now = new Date();
|
|
211
|
+
|
|
212
|
+
const allEncounterDateTimes = (visitToEdit?.encounters ?? [])
|
|
213
|
+
.map(({ encounterDatetime }) => (encounterDatetime ? Date.parse(encounterDatetime) : null))
|
|
214
|
+
.filter((t): t is number => t !== null);
|
|
215
|
+
|
|
216
|
+
const firstEncounterDateTime: number = allEncounterDateTimes.length ? Math.min(...allEncounterDateTimes) : Infinity;
|
|
217
|
+
const lastEncounterDateTime: number = allEncounterDateTimes.length ? Math.max(...allEncounterDateTimes) : -Infinity;
|
|
218
|
+
|
|
219
|
+
const startDateTime = convertToDateTimeFields(visitToEdit?.startDatetime ?? now);
|
|
220
|
+
const stopDateTime = convertToDateTimeFields(visitToEdit?.stopDatetime ?? now);
|
|
221
|
+
|
|
222
|
+
const visitStatus: VisitStatus =
|
|
223
|
+
visitToEdit == null ? 'new' : visitToEdit.stopDatetime === null ? 'ongoing' : 'past';
|
|
224
|
+
|
|
225
|
+
const defaultValues: Partial<VisitFormData> = {
|
|
226
|
+
visitStatus,
|
|
227
|
+
visitStartDate: startDateTime.date,
|
|
228
|
+
visitStartTime: startDateTime.time,
|
|
229
|
+
visitStartTimeFormat: startDateTime.timeFormat,
|
|
230
|
+
visitStopDate: stopDateTime.date,
|
|
231
|
+
visitStopTime: stopDateTime.time,
|
|
232
|
+
visitStopTimeFormat: stopDateTime.timeFormat,
|
|
233
|
+
visitType: visitToEdit?.visitType?.uuid ?? emrConfiguration?.atFacilityVisitType?.uuid,
|
|
234
|
+
visitLocation: visitToEdit?.location ?? defaultVisitLocation ?? {},
|
|
235
|
+
visitAttributes:
|
|
236
|
+
(visitToEdit?.attributes ?? []).reduce(
|
|
237
|
+
(acc, curr) => ({
|
|
238
|
+
...acc,
|
|
239
|
+
[curr.attributeType.uuid]: typeof curr.value === 'object' ? curr?.value?.uuid : `${curr.value ?? ''}`,
|
|
240
|
+
}),
|
|
241
|
+
{},
|
|
242
|
+
) ?? {},
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
const visitAttributes = (visitAttributeTypes ?? [])?.reduce(
|
|
246
|
+
(acc, { uuid, required }) => ({
|
|
247
|
+
...acc,
|
|
248
|
+
[uuid]: required
|
|
249
|
+
? z.string({ required_error: t('fieldRequired', 'This field is required') })
|
|
250
|
+
: z.string().optional(),
|
|
251
|
+
}),
|
|
252
|
+
{},
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
const visitStatusEnum = z.enum(visitStatuses);
|
|
256
|
+
const visitFormSchema = z
|
|
257
|
+
.object({
|
|
258
|
+
visitStatus: visitToEdit ? visitStatusEnum.exclude(['new']) : visitStatusEnum,
|
|
259
|
+
visitStartDate: z.date().optional(),
|
|
260
|
+
visitStartTime: z.string().regex(time12HourFormatRegex).optional(),
|
|
261
|
+
visitStartTimeFormat: z.enum(['PM', 'AM']).optional(),
|
|
262
|
+
visitStopDate: z.date().optional(),
|
|
263
|
+
visitStopTime: z.string().regex(time12HourFormatRegex).optional(),
|
|
264
|
+
visitStopTimeFormat: z.enum(['PM', 'AM']).optional(),
|
|
265
|
+
programType: z.string().optional(),
|
|
266
|
+
visitType: z.string({ required_error: t('visitTypeRequired', 'Visit type is required') }),
|
|
267
|
+
visitLocation: z.object({
|
|
268
|
+
display: z.string(),
|
|
269
|
+
uuid: z.string({ required_error: t('visitLocationRequired', 'Visit location is required') }),
|
|
270
|
+
}),
|
|
271
|
+
visitAttributes: z.object(visitAttributes),
|
|
272
|
+
})
|
|
273
|
+
.superRefine((data, ctx) => {
|
|
274
|
+
const {
|
|
275
|
+
visitStatus,
|
|
276
|
+
visitStartDate,
|
|
277
|
+
visitStartTime,
|
|
278
|
+
visitStartTimeFormat,
|
|
279
|
+
visitStopDate,
|
|
280
|
+
visitStopTime,
|
|
281
|
+
visitStopTimeFormat,
|
|
282
|
+
} = data;
|
|
283
|
+
|
|
284
|
+
const visitStartDateTime = visitStartDate
|
|
285
|
+
? convertToDate(visitStartDate, visitStartTime ?? '', visitStartTimeFormat ?? 'AM')
|
|
286
|
+
: null;
|
|
287
|
+
|
|
288
|
+
const visitStopDateTime = visitStopDate
|
|
289
|
+
? convertToDate(visitStopDate, visitStopTime ?? '', visitStopTimeFormat ?? 'AM')
|
|
290
|
+
: null;
|
|
291
|
+
|
|
292
|
+
if (visitStatus === 'ongoing' || visitStatus === 'past') {
|
|
293
|
+
if (visitStartDateTime === null) {
|
|
294
|
+
ctx.addIssue({
|
|
295
|
+
code: z.ZodIssueCode.custom,
|
|
296
|
+
message: t('visitStartDateTimeRequired', 'Start date and time are required'),
|
|
297
|
+
path: ['visitStartDate'],
|
|
298
|
+
});
|
|
299
|
+
} else if (earliestAllowedStartDate && visitStartDateTime < earliestAllowedStartDate) {
|
|
300
|
+
ctx.addIssue({
|
|
301
|
+
code: z.ZodIssueCode.custom,
|
|
302
|
+
message: t('visitStartDateBeforeBirthdate', "Start date cannot be before the patient's birth date"),
|
|
303
|
+
path: ['visitStartDate'],
|
|
304
|
+
});
|
|
305
|
+
} else if (visitStartDateTime > now) {
|
|
306
|
+
ctx.addIssue({
|
|
307
|
+
code: z.ZodIssueCode.custom,
|
|
308
|
+
message: t('futureStartTime', 'Start time cannot be in the future'),
|
|
309
|
+
path: ['visitStartTime'],
|
|
310
|
+
});
|
|
311
|
+
} else if (visitStartDateTime.getTime() > firstEncounterDateTime) {
|
|
312
|
+
ctx.addIssue({
|
|
313
|
+
code: z.ZodIssueCode.custom,
|
|
314
|
+
message: t(
|
|
315
|
+
'visitStartDateMustBeBeforeEarliestEncounter',
|
|
316
|
+
'Start time must be on or before {{firstEncounterDatetime}}',
|
|
317
|
+
{
|
|
318
|
+
firstEncounterDatetime: new Date(firstEncounterDateTime).toLocaleString(),
|
|
319
|
+
interpolation: { escapeValue: false },
|
|
320
|
+
},
|
|
321
|
+
),
|
|
322
|
+
path: ['visitStartTime'],
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if (visitStatus === 'past') {
|
|
328
|
+
if (visitStopDateTime === null) {
|
|
329
|
+
ctx.addIssue({
|
|
330
|
+
code: z.ZodIssueCode.custom,
|
|
331
|
+
message: t('endDateTimeRequired', 'End date and time are required'),
|
|
332
|
+
path: ['visitStopDate'],
|
|
333
|
+
});
|
|
334
|
+
} else if (visitStopDateTime > now) {
|
|
335
|
+
ctx.addIssue({
|
|
336
|
+
code: z.ZodIssueCode.custom,
|
|
337
|
+
message: t('futureEndTime', 'End time cannot be in the future'),
|
|
338
|
+
path: ['visitStopTime'],
|
|
339
|
+
});
|
|
340
|
+
} else if (visitStartDateTime && visitStopDateTime < visitStartDateTime) {
|
|
341
|
+
ctx.addIssue({
|
|
342
|
+
code: z.ZodIssueCode.custom,
|
|
343
|
+
message: t('endTimeMustBeAfterStartTime', 'End time must be after start time'),
|
|
344
|
+
path: ['visitStopDate'],
|
|
345
|
+
});
|
|
346
|
+
} else if (visitStopDateTime.getTime() < lastEncounterDateTime) {
|
|
347
|
+
ctx.addIssue({
|
|
348
|
+
code: z.ZodIssueCode.custom,
|
|
349
|
+
message: t(
|
|
350
|
+
'endTimeMustBeAfterMostRecentEncounter',
|
|
351
|
+
'End time must be on or after {{lastEncounterDatetime}}',
|
|
352
|
+
{
|
|
353
|
+
lastEncounterDatetime: new Date(lastEncounterDateTime).toLocaleString(),
|
|
354
|
+
interpolation: { escapeValue: false },
|
|
355
|
+
},
|
|
356
|
+
),
|
|
357
|
+
path: ['visitStopTime'],
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
return { visitFormSchema, defaultValues, firstEncounterDateTime, lastEncounterDateTime };
|
|
364
|
+
}, [t, visitAttributeTypes, visitToEdit, defaultVisitLocation, emrConfiguration, earliestAllowedStartDate]);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export const convertToDate = (date: Date, time12h: string, timeFormat: amPm): Date | null => {
|
|
368
|
+
if (!date || !time12h || !timeFormat) {
|
|
369
|
+
return null;
|
|
370
|
+
}
|
|
371
|
+
const dateStr = dayjs(date).format('YYYY-MM-DD');
|
|
372
|
+
const ret = dayjs(`${dateStr} ${time12h} ${timeFormat}`, 'YYYY-MM-DD hh:mm A');
|
|
373
|
+
return ret.isValid() ? ret.toDate() : null;
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
export const convertToDateTimeFields = (dateTime: dayjs.ConfigType) => {
|
|
377
|
+
const dateTimeDayjs = dayjs(dateTime);
|
|
378
|
+
return {
|
|
379
|
+
date: dateTimeDayjs.startOf('day').toDate(),
|
|
380
|
+
time: dateTimeDayjs.format('hh:mm'),
|
|
381
|
+
timeFormat: dateTimeDayjs.format('A') as amPm,
|
|
382
|
+
};
|
|
383
|
+
};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
@use '@carbon/colors';
|
|
2
|
+
@use '@carbon/layout';
|
|
3
|
+
@use '@carbon/type';
|
|
4
|
+
|
|
5
|
+
.container {
|
|
6
|
+
margin: layout.$spacing-05;
|
|
7
|
+
& section {
|
|
8
|
+
margin: layout.$spacing-03 0 layout.$spacing-03;
|
|
9
|
+
|
|
10
|
+
&:first-of-type {
|
|
11
|
+
margin-top: 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&:last-of-type {
|
|
15
|
+
margin-bottom: 0;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.heading {
|
|
21
|
+
@include type.type-style('heading-03');
|
|
22
|
+
margin: layout.$spacing-05;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.sectionTitle {
|
|
26
|
+
@include type.type-style('heading-compact-02');
|
|
27
|
+
color: colors.$gray-70;
|
|
28
|
+
margin: 0 0 layout.$spacing-03 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.dateTimeSection {
|
|
32
|
+
display: flex;
|
|
33
|
+
margin: layout.$spacing-05 0;
|
|
34
|
+
align-items: center;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.radioButton {
|
|
38
|
+
margin: layout.$spacing-05 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.headerGridRow {
|
|
42
|
+
border-bottom: 0.0625rem solid colors.$gray-20;
|
|
43
|
+
margin: 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.dataGridRow {
|
|
47
|
+
display: grid;
|
|
48
|
+
grid-template-columns: 50% 10% 1fr;
|
|
49
|
+
margin: layout.$spacing-03 layout.$spacing-05;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.form {
|
|
53
|
+
display: flex;
|
|
54
|
+
flex-direction: column;
|
|
55
|
+
justify-content: start;
|
|
56
|
+
height: 100%;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.buttonSet {
|
|
60
|
+
margin-top: auto;
|
|
61
|
+
justify-self: end;
|
|
62
|
+
margin-right: 3rem;
|
|
63
|
+
}
|
|
64
|
+
.button {
|
|
65
|
+
height: layout.$spacing-10;
|
|
66
|
+
display: flex;
|
|
67
|
+
align-content: flex-start;
|
|
68
|
+
align-items: baseline;
|
|
69
|
+
min-width: 50%;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.tablet {
|
|
73
|
+
padding: layout.$spacing-06 layout.$spacing-05;
|
|
74
|
+
background-color: white;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.desktop {
|
|
78
|
+
padding: 0;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@media screen and (max-width: 600px) {
|
|
82
|
+
.dateTimeSection {
|
|
83
|
+
flex-direction: column;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.inlineNotification {
|
|
88
|
+
width: 100%;
|
|
89
|
+
max-width: unset;
|
|
90
|
+
padding: '0';
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.label {
|
|
94
|
+
@include type.type-style('label-01');
|
|
95
|
+
color: colors.$gray-70;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
:global(.omrs-breakpoint-lt-desktop) {
|
|
99
|
+
.container {
|
|
100
|
+
& section {
|
|
101
|
+
display: flex;
|
|
102
|
+
gap: layout.$spacing-10;
|
|
103
|
+
|
|
104
|
+
.sectionTitle {
|
|
105
|
+
flex-basis: 30%;
|
|
106
|
+
min-width: 8rem;
|
|
107
|
+
text-align: left;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.sectionField {
|
|
111
|
+
flex-basis: 70%;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.form {
|
|
117
|
+
height: 100%;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.spinner {
|
|
122
|
+
&:global(.cds--inline-loading) {
|
|
123
|
+
min-height: layout.$spacing-05 !important;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.bodyShort02 {
|
|
128
|
+
@include type.type-style('body-compact-02');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.timePicker {
|
|
132
|
+
display: flex;
|
|
133
|
+
align-items: baseline;
|
|
134
|
+
|
|
135
|
+
:global(.cds--form-requirement) {
|
|
136
|
+
max-width: layout.$spacing-12;
|
|
137
|
+
max-height: 0 !important;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.timePickerSelectError {
|
|
142
|
+
outline: 2px solid colors.$red-50;
|
|
143
|
+
outline-offset: -2px;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.timerPickerError {
|
|
147
|
+
color: colors.$red-60;
|
|
148
|
+
display: flex;
|
|
149
|
+
align-self: flex-end;
|
|
150
|
+
max-width: layout.$spacing-11;
|
|
151
|
+
font-size: layout.$spacing-04;
|
|
152
|
+
margin: 0;
|
|
153
|
+
letter-spacing: 0.02rem;
|
|
154
|
+
line-height: 1.33333;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.timePickerContainer {
|
|
158
|
+
display: flex;
|
|
159
|
+
flex-direction: column;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.datePicker {
|
|
163
|
+
:global(.cds--date-picker-input__wrapper) {
|
|
164
|
+
inline-size: layout.$spacing-13;
|
|
165
|
+
}
|
|
166
|
+
}
|
package/src/components/registration/start-visit-form/visit-form-workspace/visit-form.workspace.tsx
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type KeyedMutator, useSWRConfig } from 'swr';
|
|
3
|
+
import { launchWorkspaceGroup2, useVisit, type Visit } from '@openmrs/esm-framework';
|
|
4
|
+
import {
|
|
5
|
+
invalidateVisitByUuid,
|
|
6
|
+
type PatientWorkspace2DefinitionProps,
|
|
7
|
+
usePatientChartStore,
|
|
8
|
+
} from '@openmrs/esm-patient-common-lib';
|
|
9
|
+
import ExportedVisitForm from '../start-visit-workspace/exported-visit-form.workspace';
|
|
10
|
+
|
|
11
|
+
export interface VisitFormProps {
|
|
12
|
+
openedFrom: string;
|
|
13
|
+
showPatientHeader?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const VisitForm: React.FC<PatientWorkspace2DefinitionProps<VisitFormProps, {}>> = ({
|
|
17
|
+
workspaceProps: { openedFrom, showPatientHeader = false },
|
|
18
|
+
groupProps: { patient, patientUuid, visitContext },
|
|
19
|
+
...rest
|
|
20
|
+
}) => {
|
|
21
|
+
const { mutate: mutateActiveVisit } = useVisit(patientUuid);
|
|
22
|
+
const { mutate: globalMutate } = useSWRConfig();
|
|
23
|
+
const boundMutate = globalMutate as unknown as KeyedMutator<unknown>;
|
|
24
|
+
const { setVisitContext } = usePatientChartStore(patientUuid);
|
|
25
|
+
|
|
26
|
+
const onVisitStarted = (visit: Visit) => {
|
|
27
|
+
const mutateSavedOrUpdatedVisit = () => invalidateVisitByUuid(boundMutate, visit.uuid);
|
|
28
|
+
mutateActiveVisit();
|
|
29
|
+
setVisitContext?.(visit, mutateSavedOrUpdatedVisit);
|
|
30
|
+
|
|
31
|
+
launchWorkspaceGroup2('ewf-patient-chart', {
|
|
32
|
+
patient,
|
|
33
|
+
patientUuid,
|
|
34
|
+
visitContext: visit,
|
|
35
|
+
mutateVisitContext: mutateSavedOrUpdatedVisit,
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<ExportedVisitForm
|
|
41
|
+
{...rest}
|
|
42
|
+
workspaceProps={{
|
|
43
|
+
openedFrom,
|
|
44
|
+
showPatientHeader,
|
|
45
|
+
onVisitStarted,
|
|
46
|
+
patient,
|
|
47
|
+
patientUuid,
|
|
48
|
+
visitContext,
|
|
49
|
+
}}
|
|
50
|
+
groupProps={{}}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default VisitForm;
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getAsyncLifecycle } from '@openmrs/esm-framework';
|
|
2
2
|
|
|
3
3
|
import { moduleName } from '../../constants';
|
|
4
|
-
import { createLeftPanelLink } from '../../shared/dashboard-link/dashboard-link.component';
|
|
5
|
-
import ReportsDashboard from './dashboard.component';
|
|
6
4
|
|
|
7
5
|
const options = {
|
|
8
6
|
featureName: 'express-workflow',
|
|
9
7
|
moduleName,
|
|
10
8
|
};
|
|
11
9
|
|
|
12
|
-
export const reportsDashboard =
|
|
10
|
+
export const reportsDashboard = getAsyncLifecycle(() => import('./dashboard.component'), options);
|
|
13
11
|
// t('reports', 'Reports')
|
|
14
|
-
export const reportsDashboardLink =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
export const reportsDashboardLink = getAsyncLifecycle(
|
|
13
|
+
() =>
|
|
14
|
+
import('../../shared/dashboard-link/dashboard-link.component').then((m) => ({
|
|
15
|
+
default: m.createLeftPanelLink({
|
|
16
|
+
name: 'reports',
|
|
17
|
+
title: 'reports',
|
|
18
|
+
}),
|
|
19
|
+
})),
|
|
19
20
|
options,
|
|
20
21
|
);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { BrowserRouter, Route, Routes } from 'react-router-dom';
|
|
3
3
|
import { spaBasePath } from '../../constants';
|
|
4
|
-
import PatientChart from '../../shared/patient-chart/patient-chart.component';
|
|
5
4
|
import Triage from './triage.component';
|
|
6
5
|
|
|
7
6
|
type TriageDashboardProps = {
|
|
@@ -13,7 +12,6 @@ const TriageDashboard: React.FC<TriageDashboardProps> = ({ dashboardTitle }) =>
|
|
|
13
12
|
<BrowserRouter basename={`${spaBasePath}/triage`}>
|
|
14
13
|
<Routes>
|
|
15
14
|
<Route path="/" element={<Triage dashboardTitle={dashboardTitle} />} />
|
|
16
|
-
<Route path="/:patientUuid" element={<PatientChart navigationPath="triage" />} />
|
|
17
15
|
</Routes>
|
|
18
16
|
</BrowserRouter>
|
|
19
17
|
);
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getAsyncLifecycle } from '@openmrs/esm-framework';
|
|
2
2
|
|
|
3
3
|
import { moduleName } from '../../constants';
|
|
4
|
-
import { createLeftPanelLink } from '../../shared/dashboard-link/dashboard-link.component';
|
|
5
|
-
import TriageDashboard from './dashboard.component';
|
|
6
4
|
|
|
7
5
|
const options = {
|
|
8
6
|
featureName: 'express-workflow',
|
|
9
7
|
moduleName,
|
|
10
8
|
};
|
|
11
9
|
|
|
12
|
-
export const triageDashboard =
|
|
10
|
+
export const triageDashboard = getAsyncLifecycle(() => import('./dashboard.component'), options);
|
|
13
11
|
// t('triage', 'Triage')
|
|
14
|
-
export const triageLeftPanelLink =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
export const triageLeftPanelLink = getAsyncLifecycle(
|
|
13
|
+
() =>
|
|
14
|
+
import('../../shared/dashboard-link/dashboard-link.component').then((m) => ({
|
|
15
|
+
default: m.createLeftPanelLink({
|
|
16
|
+
name: 'triage',
|
|
17
|
+
title: 'triage',
|
|
18
|
+
}),
|
|
19
|
+
})),
|
|
19
20
|
options,
|
|
20
21
|
);
|