@ampath/esm-dha-workflow-app 4.0.0-next.4 → 4.0.0-next.40
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/dist/104.js +2 -0
- package/dist/104.js.LICENSE.txt +9 -0
- package/dist/104.js.map +1 -0
- package/dist/15.js +1 -0
- package/dist/15.js.map +1 -0
- package/dist/246.js +2 -0
- package/dist/246.js.LICENSE.txt +54 -0
- package/dist/246.js.map +1 -0
- package/dist/327.js +1 -0
- package/dist/327.js.map +1 -0
- package/dist/339.js +1 -0
- package/dist/339.js.map +1 -0
- package/dist/701.js +1 -0
- package/dist/701.js.map +1 -0
- package/dist/709.js +1 -0
- package/dist/709.js.map +1 -0
- package/dist/710.js +2 -0
- package/dist/710.js.map +1 -0
- package/dist/729.js +1 -0
- package/dist/729.js.map +1 -0
- package/dist/752.js +1 -0
- package/dist/752.js.map +1 -0
- package/dist/833.js +1 -0
- package/dist/833.js.map +1 -0
- package/dist/91.js +1 -1
- package/dist/91.js.map +1 -1
- package/dist/93.js +1 -0
- package/dist/93.js.map +1 -0
- package/dist/esm-dha-workflow-app.js +1 -0
- package/dist/{openmrs-esm-home-app.js.buildmanifest.json → esm-dha-workflow-app.js.buildmanifest.json} +293 -54
- package/dist/{openmrs-esm-home-app.js.map → esm-dha-workflow-app.js.map} +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +3 -3
- package/src/accounting/accounting.component.tsx +13 -0
- package/src/appointments/appointments.component.tsx +13 -0
- package/src/bookings/daily/daily-bookings.component.scss +38 -0
- package/src/bookings/daily/daily-bookings.component.tsx +138 -0
- package/src/bookings/daily/daily-bookings.resource.ts +27 -0
- package/src/bookings/daily/filters/daily-bookings-filter.component.scss +15 -0
- package/src/bookings/daily/filters/daily-bookings-filter.component.tsx +80 -0
- package/src/bookings/daily/patient-list/daily-bookings-patient-list.component.tsx +97 -0
- package/src/bookings/types/index.ts +68 -0
- package/src/config-schema.ts +132 -32
- package/src/dashboard/dashboard.component.scss +7 -0
- package/src/dashboard/dashboard.component.tsx +63 -0
- package/src/dashboard/overview/overview.component.scss +70 -0
- package/src/dashboard/overview/overview.component.tsx +107 -0
- package/src/dashboard/patient-list/patient-list.component.tsx +41 -0
- package/src/hooks/useActions.ts +165 -0
- package/src/index.ts +23 -2
- package/src/laboratory/laboratory.component.tsx +13 -0
- package/src/left-panel/left-panel.component.tsx +20 -0
- package/src/left-panel/left-panel.scss +42 -0
- package/src/mch/queues/consultation/mch-consultation.tsx +18 -0
- package/src/mch/queues/triage/mch-triage.tsx +15 -0
- package/src/modals/sign-off-modal.scss +7 -0
- package/src/modals/sign-off-modal.tsx +52 -0
- package/src/pharmacy/pharmacy.component.tsx +13 -0
- package/src/registry/client-details/client-details.tsx +40 -0
- package/src/registry/modal/client-details-modal/client-details-modal.scss +28 -0
- package/src/registry/modal/client-details-modal/client-details-modal.tsx +81 -0
- package/src/registry/modal/otp-verification-modal/otp-verification-modal.scss +31 -0
- package/src/registry/modal/otp-verification-modal/otp-verification-modal.tsx +186 -0
- package/src/registry/modal/send-to-triage/send-to-triage.modal.scss +34 -0
- package/src/registry/modal/send-to-triage/send-to-triage.modal.tsx +302 -0
- package/src/registry/payment-details/payment-options/payment-options.tsx +21 -0
- package/src/registry/registry.component.scss +83 -0
- package/src/registry/registry.component.tsx +397 -2
- package/src/registry/registry.resource.ts +60 -0
- package/src/registry/types/index.ts +309 -0
- package/src/registry/utils/error-handler.ts +37 -0
- package/src/registry/utils/format-dependant-display-data.ts +8 -0
- package/src/registry/utils/hie-adapter.ts +56 -0
- package/src/registry/utils/hie-client-adapter.ts +309 -0
- package/src/registry/utils/mask-data.ts +21 -0
- package/src/resources/hie-amrs-automatic-registration.service.ts +16 -0
- package/src/resources/identifier-types.ts +27 -0
- package/src/resources/patient-resource.ts +62 -0
- package/src/resources/patient-search.resource.ts +22 -0
- package/src/resources/queue.resource.ts +60 -0
- package/src/resources/visit.resource.ts +38 -0
- package/src/root.component.tsx +40 -30
- package/src/root.scss +5 -9
- package/src/routes.json +43 -4
- package/src/service-queues/action-button.component.tsx +34 -0
- package/src/service-queues/action-overflow-menu-item.component.tsx +34 -0
- package/src/service-queues/consultation/consultation.component.scss +7 -0
- package/src/service-queues/consultation/consultation.component.tsx +15 -0
- package/src/service-queues/metrics/metrics-cards/attended-patients.extension.tsx +38 -0
- package/src/service-queues/metrics/metrics-cards/metrics-card.component.tsx +86 -0
- package/src/service-queues/metrics/metrics-cards/metrics-card.scss +106 -0
- package/src/service-queues/metrics/metrics-cards/waiting-patients.extension.tsx +34 -0
- package/src/service-queues/metrics/metrics-container.component.tsx +23 -0
- package/src/service-queues/metrics/metrics-container.scss +36 -0
- package/src/service-queues/metrics/metrics.resource.ts +65 -0
- package/src/service-queues/modals/move/move-patient.component.scss +35 -0
- package/src/service-queues/modals/move/move-patient.component.tsx +138 -0
- package/src/service-queues/modals/serve/serve-patient.comppnent.scss +0 -0
- package/src/service-queues/modals/serve/serve-patient.comppnent.tsx +80 -0
- package/src/service-queues/modals/sign-off/sign-off.modal.scss +0 -0
- package/src/service-queues/modals/sign-off/sign-off.modal.tsx +79 -0
- package/src/service-queues/modals/transition/transition-patient.component.scss +0 -0
- package/src/service-queues/modals/transition/transition-patient.component.tsx +122 -0
- package/src/service-queues/queue-list/queue-list.component.scss +19 -0
- package/src/service-queues/queue-list/queue-list.component.tsx +169 -0
- package/src/service-queues/queue-room.component.tsx +39 -0
- package/src/service-queues/room/room.component.tsx +58 -0
- package/src/service-queues/service-queue/service-queue.component.scss +14 -0
- package/src/service-queues/service-queue/service-queue.component.tsx +245 -0
- package/src/service-queues/service-queue/stats/stat-card/stat-card.component.scss +10 -0
- package/src/service-queues/service-queue/stats/stat-card/stat-card.component.tsx +23 -0
- package/src/service-queues/service-queue/stats/stat-details/stat-details.component.scss +7 -0
- package/src/service-queues/service-queue/stats/stat-details/stat-details.component.tsx +34 -0
- package/src/service-queues/service-queue.scss +27 -0
- package/src/service-queues/service-queue.tsx +31 -0
- package/src/service-queues/service-queues.resource.ts +177 -0
- package/src/service-queues/service.resource.ts +28 -0
- package/src/shared/constants/civil-status.ts +29 -0
- package/src/shared/constants/concepts.ts +30 -0
- package/src/shared/constants/index.ts +1 -0
- package/src/shared/constants/person-attributes.ts +33 -0
- package/src/shared/services/location.resource.ts +9 -0
- package/src/shared/ui/otp-input/otp-input.component.scss +14 -0
- package/src/shared/ui/otp-input/otp-input.component.tsx +90 -0
- package/src/shared/ui/timer/timer.component.scss +5 -0
- package/src/shared/ui/timer/timer.component.tsx +40 -0
- package/src/shared/utils/get-base-url.ts +17 -0
- package/src/side-nav-menu/nav-link-config.ts +82 -0
- package/src/side-nav-menu/nav-links.tsx +31 -11
- package/src/triage/metrics/attended-patients.extension.tsx +42 -0
- package/src/triage/metrics/metrics.scss +36 -0
- package/src/triage/metrics/triage-metrics.component.tsx +21 -0
- package/src/triage/metrics/waiting-patients.extension.tsx +39 -0
- package/src/triage/room/room.scss +29 -0
- package/src/triage/triage.component.tsx +15 -0
- package/src/triage/triage.resource.ts +19 -0
- package/src/triage/types.ts +16 -0
- package/src/types/types.ts +128 -0
- package/dist/561.js +0 -2
- package/dist/561.js.map +0 -1
- package/dist/70.js +0 -1
- package/dist/70.js.map +0 -1
- package/dist/731.js +0 -2
- package/dist/731.js.LICENSE.txt +0 -39
- package/dist/731.js.map +0 -1
- package/dist/819.js +0 -1
- package/dist/819.js.map +0 -1
- package/dist/openmrs-esm-home-app.js +0 -1
- package/src/boxes/extensions/blue-box.component.tsx +0 -15
- package/src/boxes/extensions/box.scss +0 -23
- package/src/boxes/extensions/brand-box.component.tsx +0 -15
- package/src/boxes/extensions/red-box.component.tsx +0 -15
- package/src/boxes/slot/boxes.component.tsx +0 -25
- package/src/boxes/slot/boxes.scss +0 -29
- package/src/greeter/greeter.component.tsx +0 -42
- package/src/greeter/greeter.scss +0 -20
- package/src/greeter/greeter.test.tsx +0 -28
- package/src/patient-getter/patient-getter.component.tsx +0 -40
- package/src/patient-getter/patient-getter.resource.ts +0 -39
- package/src/patient-getter/patient-getter.scss +0 -16
- package/src/patient-getter/patient-getter.test.tsx +0 -40
- package/src/resources/resources.component.tsx +0 -56
- package/src/resources/resources.scss +0 -68
- /package/dist/{561.js.LICENSE.txt → 710.js.LICENSE.txt} +0 -0
|
@@ -1,7 +1,402 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
Button,
|
|
3
|
+
Dropdown,
|
|
4
|
+
InlineLoading,
|
|
5
|
+
RadioButton,
|
|
6
|
+
RadioButtonGroup,
|
|
7
|
+
Table,
|
|
8
|
+
TableBody,
|
|
9
|
+
TableCell,
|
|
10
|
+
TableHead,
|
|
11
|
+
TableHeader,
|
|
12
|
+
TableRow,
|
|
13
|
+
TextInput,
|
|
14
|
+
} from '@carbon/react';
|
|
15
|
+
import React, { useState } from 'react';
|
|
16
|
+
import styles from './registry.component.scss';
|
|
17
|
+
import { type HieClient, IDENTIFIER_TYPES, type IdentifierType, type RequestCustomOtpDto } from './types';
|
|
18
|
+
import { fetchClientRegistryData } from './registry.resource';
|
|
19
|
+
import { type Patient, showSnackbar, useSession } from '@openmrs/esm-framework';
|
|
20
|
+
import OtpVerificationModal from './modal/otp-verification-modal/otp-verification-modal';
|
|
21
|
+
import { maskExceptFirstAndLast, maskValue } from './utils/mask-data';
|
|
22
|
+
import ClientDetailsModal from './modal/client-details-modal/client-details-modal';
|
|
23
|
+
import { searchPatientByCrNumber } from '../resources/patient-search.resource';
|
|
24
|
+
import SendToTriageModal from './modal/send-to-triage/send-to-triage.modal';
|
|
25
|
+
import { useNavigate } from 'react-router-dom';
|
|
26
|
+
import { formatDependantDisplayData } from './utils/format-dependant-display-data';
|
|
27
|
+
import { registerHieClientInAmrs } from '../resources/hie-amrs-automatic-registration.service';
|
|
28
|
+
import { getErrorMessages } from './utils/error-handler';
|
|
29
|
+
import Timer from '../shared/ui/timer/timer.component';
|
|
30
|
+
|
|
2
31
|
interface RegistryComponentProps {}
|
|
3
32
|
const RegistryComponent: React.FC<RegistryComponentProps> = () => {
|
|
4
|
-
|
|
33
|
+
const [identifierType, setIdentifierType] = useState<IdentifierType>('National ID');
|
|
34
|
+
const [identifierValue, setIdentifierValue] = useState('');
|
|
35
|
+
const [loading, setLoading] = useState<boolean>(false);
|
|
36
|
+
const [principal, setPrincipal] = useState<HieClient>();
|
|
37
|
+
const [selectedDependant, setSelectedDependant] = useState<HieClient>();
|
|
38
|
+
const [amrsPatients, setAmrsPatients] = useState<Patient[]>([]);
|
|
39
|
+
const [selectedPatient, setSelectedPatient] = useState<string>('principal');
|
|
40
|
+
const [displayOtpModal, setDisplayOtpModal] = useState<boolean>(false);
|
|
41
|
+
const [displayClientDetailsModal, setDisplayClientDetailsModal] = useState<boolean>(false);
|
|
42
|
+
const [displaytriageModal, setDisplaytriageModal] = useState<boolean>(false);
|
|
43
|
+
const [requestCustomOtpDto, setRequestCustomOtpDto] = useState<RequestCustomOtpDto>();
|
|
44
|
+
const session = useSession();
|
|
45
|
+
const locationUuid = session.sessionLocation.uuid;
|
|
46
|
+
const navigate = useNavigate();
|
|
47
|
+
|
|
48
|
+
const handleSearchPatient = async () => {
|
|
49
|
+
setLoading(true);
|
|
50
|
+
try {
|
|
51
|
+
const payload = {
|
|
52
|
+
identificationNumber: identifierValue,
|
|
53
|
+
identificationType: identifierType,
|
|
54
|
+
locationUuid,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
if (!isValidCustomSmsPayload(payload)) return false;
|
|
58
|
+
|
|
59
|
+
setRequestCustomOtpDto(payload);
|
|
60
|
+
|
|
61
|
+
const result = await fetchClientRegistryData(payload);
|
|
62
|
+
const patients = Array.isArray(result) ? result : [];
|
|
63
|
+
|
|
64
|
+
if (patients.length === 0) {
|
|
65
|
+
handleCancel();
|
|
66
|
+
throw new Error('No matching patient found in Client Registry.');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const patient = patients[0];
|
|
70
|
+
setPrincipal(patient);
|
|
71
|
+
showAlert('success', 'Client Data Loaded', 'Patient fetched successfully');
|
|
72
|
+
} catch (err: any) {
|
|
73
|
+
const errorMessage = err.message || 'Failed to fetch client data';
|
|
74
|
+
handleCancel();
|
|
75
|
+
showAlert('error', 'Fetch Failed', errorMessage);
|
|
76
|
+
} finally {
|
|
77
|
+
setLoading(false);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const isValidCustomSmsPayload = (payload: RequestCustomOtpDto): boolean => {
|
|
81
|
+
if (!payload.identificationNumber) {
|
|
82
|
+
showAlert('error', 'Please enter a valid identification number', '');
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
if (!payload.identificationType) {
|
|
86
|
+
showAlert('error', 'Please enter a valid identification type', '');
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
if (!payload.locationUuid) {
|
|
90
|
+
showAlert('error', 'No default location selected', '');
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
return true;
|
|
94
|
+
};
|
|
95
|
+
const showAlert = (alertType: 'error' | 'success', title: string, subtitle: string) => {
|
|
96
|
+
showSnackbar({
|
|
97
|
+
kind: alertType,
|
|
98
|
+
title: title,
|
|
99
|
+
subtitle: subtitle,
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
const handleSelectedPatient = (sp: string) => {
|
|
103
|
+
setSelectedPatient(sp);
|
|
104
|
+
};
|
|
105
|
+
const handleOtpVerification = () => {
|
|
106
|
+
setDisplayOtpModal(true);
|
|
107
|
+
};
|
|
108
|
+
const handleModelClose = () => {
|
|
109
|
+
setDisplayOtpModal(false);
|
|
110
|
+
};
|
|
111
|
+
const onClientDetailsModalClose = () => {
|
|
112
|
+
setDisplayClientDetailsModal(false);
|
|
113
|
+
};
|
|
114
|
+
const handleClientDetailsSubmit = () => {
|
|
115
|
+
return;
|
|
116
|
+
};
|
|
117
|
+
const handleEmergencyRegistration = () => {
|
|
118
|
+
window.location.href = `${window.spaBase}/patient-registration`;
|
|
119
|
+
};
|
|
120
|
+
const handleManualRegistration = () => {
|
|
121
|
+
setDisplaytriageModal(false);
|
|
122
|
+
handleEmergencyRegistration();
|
|
123
|
+
};
|
|
124
|
+
const handleSendClientToTriage = async (crId: string) => {
|
|
125
|
+
onClientDetailsModalClose();
|
|
126
|
+
const resp = await searchPatientByCrNumber(crId);
|
|
127
|
+
if (resp.totalCount > 0) {
|
|
128
|
+
showAlert(
|
|
129
|
+
'success',
|
|
130
|
+
`${resp.totalCount} ${resp.totalCount > 0 ? 'Patients' : 'Patient'} found in the system with ${crId}`,
|
|
131
|
+
'',
|
|
132
|
+
);
|
|
133
|
+
setAmrsPatients(resp.results);
|
|
134
|
+
setDisplaytriageModal(true);
|
|
135
|
+
} else {
|
|
136
|
+
showAlert('error', 'Patient not found in the system', '');
|
|
137
|
+
setAmrsPatients([]);
|
|
138
|
+
setDisplaytriageModal(true);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
const onSendToTriageModalClose = (modalCloseResp?: { success: boolean }) => {
|
|
142
|
+
setDisplaytriageModal(false);
|
|
143
|
+
if (modalCloseResp && modalCloseResp.success) {
|
|
144
|
+
navigate('/triage');
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
const handleSendToTriageModalSubmit = () => {};
|
|
148
|
+
const getPatient = (): HieClient => {
|
|
149
|
+
if (selectedPatient === 'principal') {
|
|
150
|
+
return principal;
|
|
151
|
+
} else if (selectedPatient === 'dependants') {
|
|
152
|
+
return selectedDependant;
|
|
153
|
+
} else {
|
|
154
|
+
return principal;
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
const handleSelectedDependant = (dependantId: string) => {
|
|
158
|
+
const dependants = principal.dependants;
|
|
159
|
+
if (dependants.length > 0) {
|
|
160
|
+
const dependant = dependants.find((d) => {
|
|
161
|
+
return d.result[0].id === dependantId;
|
|
162
|
+
});
|
|
163
|
+
if (dependant) {
|
|
164
|
+
setSelectedDependant(dependant.result[0] as unknown as HieClient);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
const createAmrsPatient = async () => {
|
|
169
|
+
const patient = getPatient();
|
|
170
|
+
if (!patient) {
|
|
171
|
+
showAlert('error', 'Principal or dependant not selected', '');
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
try {
|
|
175
|
+
const resp = await registerHieClientInAmrs(patient, locationUuid);
|
|
176
|
+
if (resp) {
|
|
177
|
+
showAlert('success', 'Patient created succesfully', '');
|
|
178
|
+
setAmrsPatients([resp]);
|
|
179
|
+
}
|
|
180
|
+
} catch (e) {
|
|
181
|
+
const errorResp = e['responseBody'] ?? e.message;
|
|
182
|
+
showAlert('error', 'Error Creating Patient', '');
|
|
183
|
+
const errors = getErrorMessages(errorResp);
|
|
184
|
+
if (errors && errors.length > 0) {
|
|
185
|
+
for (let error of errors) {
|
|
186
|
+
showAlert('error', error, '');
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
const handleCancel = () => {
|
|
192
|
+
setPrincipal(null);
|
|
193
|
+
setSelectedDependant(null);
|
|
194
|
+
setAmrsPatients([]);
|
|
195
|
+
setSelectedPatient(null);
|
|
196
|
+
setIdentifierValue('');
|
|
197
|
+
setIdentifierType('National ID');
|
|
198
|
+
setDisplayClientDetailsModal(false);
|
|
199
|
+
setDisplayOtpModal(false);
|
|
200
|
+
setDisplaytriageModal(false);
|
|
201
|
+
setSelectedPatient('principal');
|
|
202
|
+
};
|
|
203
|
+
const handleOtpSuccessfullVerification = () => {
|
|
204
|
+
setDisplayOtpModal(false);
|
|
205
|
+
setDisplayClientDetailsModal(true);
|
|
206
|
+
};
|
|
207
|
+
const registerOnAfyaYangu = () => {
|
|
208
|
+
window.open('https://afyayangu.go.ke/', '_blank');
|
|
209
|
+
};
|
|
210
|
+
return (
|
|
211
|
+
<>
|
|
212
|
+
<div className={styles.registryLayout}>
|
|
213
|
+
<div className={styles.mainContent}>
|
|
214
|
+
<div className={styles.registryHeader}>
|
|
215
|
+
<h4>Client Registry</h4>
|
|
216
|
+
<p>Please enter identification number to begin</p>
|
|
217
|
+
</div>
|
|
218
|
+
<div className={styles.registryContent}>
|
|
219
|
+
<div className={styles.formRow}>
|
|
220
|
+
<div className={styles.formControl}>
|
|
221
|
+
<Dropdown
|
|
222
|
+
id="identifier-type-dropdown"
|
|
223
|
+
label="Identifier Type"
|
|
224
|
+
titleText="Select Identifier Type"
|
|
225
|
+
items={IDENTIFIER_TYPES}
|
|
226
|
+
selectedItem={identifierType}
|
|
227
|
+
onChange={({ selectedItem }) => setIdentifierType(selectedItem as IdentifierType)}
|
|
228
|
+
/>
|
|
229
|
+
</div>
|
|
230
|
+
|
|
231
|
+
<div className={styles.formControl}>
|
|
232
|
+
<TextInput
|
|
233
|
+
id="identifier-value"
|
|
234
|
+
labelText={`${identifierType} Value`}
|
|
235
|
+
value={identifierValue}
|
|
236
|
+
onChange={(e) => setIdentifierValue(e.target.value)}
|
|
237
|
+
placeholder={`Enter ${identifierType.toLowerCase()} value`}
|
|
238
|
+
/>
|
|
239
|
+
</div>
|
|
240
|
+
</div>
|
|
241
|
+
<div className={styles.formRow}>
|
|
242
|
+
<div className={styles.formControl}>
|
|
243
|
+
<div className={styles.formBtn}>
|
|
244
|
+
<Button
|
|
245
|
+
className={styles.registrySearchBtn}
|
|
246
|
+
kind="primary"
|
|
247
|
+
onClick={handleSearchPatient}
|
|
248
|
+
disabled={loading}
|
|
249
|
+
>
|
|
250
|
+
{loading ? <InlineLoading description="Searching..." /> : 'Search'}
|
|
251
|
+
</Button>
|
|
252
|
+
<Button className={styles.registrySearchBtn} kind="secondary" onClick={handleEmergencyRegistration}>
|
|
253
|
+
Emergency Registration
|
|
254
|
+
</Button>
|
|
255
|
+
<Button className={styles.registrySearchBtn} kind="tertiary" onClick={registerOnAfyaYangu}>
|
|
256
|
+
Register on Afya Yangu
|
|
257
|
+
</Button>
|
|
258
|
+
</div>
|
|
259
|
+
</div>
|
|
260
|
+
</div>
|
|
261
|
+
{principal ? (
|
|
262
|
+
<div className={styles.formRow}>
|
|
263
|
+
<div className={styles.hieData}>
|
|
264
|
+
<div className={styles.selectionHeader}>
|
|
265
|
+
<h5>Please select one patient and request patient to share the OTP sent</h5>
|
|
266
|
+
</div>
|
|
267
|
+
<div className={styles.patientSelect}>
|
|
268
|
+
<div className={styles.patientSelectRadio}>
|
|
269
|
+
<RadioButtonGroup
|
|
270
|
+
defaultSelected="principal"
|
|
271
|
+
legendText="Patient"
|
|
272
|
+
onChange={(v) => handleSelectedPatient(v as string)}
|
|
273
|
+
name="radio-button-default-group"
|
|
274
|
+
>
|
|
275
|
+
<RadioButton id="principal" labelText="Principal" value="principal" />
|
|
276
|
+
<RadioButton id="dependants" labelText="Dependants" value="dependants" />
|
|
277
|
+
</RadioButtonGroup>
|
|
278
|
+
</div>
|
|
279
|
+
<div className={styles.patientConfirmSelection}>
|
|
280
|
+
<div className={styles.btnContainer}>
|
|
281
|
+
<Button kind="primary" onClick={handleOtpVerification}>
|
|
282
|
+
{' '}
|
|
283
|
+
Confirm
|
|
284
|
+
</Button>
|
|
285
|
+
</div>
|
|
286
|
+
<div className={styles.btnContainer}>
|
|
287
|
+
<Button kind="secondary" onClick={handleCancel}>
|
|
288
|
+
Cancel
|
|
289
|
+
</Button>
|
|
290
|
+
</div>
|
|
291
|
+
</div>
|
|
292
|
+
</div>
|
|
293
|
+
<div className={styles.principalDependantSection}>
|
|
294
|
+
{selectedPatient === 'principal' ? (
|
|
295
|
+
<>
|
|
296
|
+
<Table>
|
|
297
|
+
<TableHead>
|
|
298
|
+
<TableRow>
|
|
299
|
+
<TableHeader>Name</TableHeader>
|
|
300
|
+
<TableHeader>CR</TableHeader>
|
|
301
|
+
<TableHeader>Phone No</TableHeader>
|
|
302
|
+
<TableHeader>ID No</TableHeader>
|
|
303
|
+
</TableRow>
|
|
304
|
+
</TableHead>
|
|
305
|
+
<TableBody>
|
|
306
|
+
<TableRow>
|
|
307
|
+
<TableCell>
|
|
308
|
+
{principal.first_name} {maskExceptFirstAndLast(principal.middle_name)}{' '}
|
|
309
|
+
{maskExceptFirstAndLast(principal.last_name)}
|
|
310
|
+
</TableCell>
|
|
311
|
+
<TableCell>{maskValue(principal.id)}</TableCell>
|
|
312
|
+
<TableCell>{maskValue(principal.phone)}</TableCell>
|
|
313
|
+
<TableCell>{maskValue(principal.identification_number)}</TableCell>
|
|
314
|
+
</TableRow>
|
|
315
|
+
</TableBody>
|
|
316
|
+
</Table>
|
|
317
|
+
</>
|
|
318
|
+
) : (
|
|
319
|
+
<></>
|
|
320
|
+
)}
|
|
321
|
+
{selectedPatient === 'dependants' ? (
|
|
322
|
+
<>
|
|
323
|
+
<RadioButtonGroup
|
|
324
|
+
defaultSelected=""
|
|
325
|
+
helperText=""
|
|
326
|
+
invalidText=""
|
|
327
|
+
legendText=""
|
|
328
|
+
name="dependant-group"
|
|
329
|
+
onChange={(dependantId) => handleSelectedDependant(dependantId as string)}
|
|
330
|
+
>
|
|
331
|
+
{principal.dependants.map((d) => {
|
|
332
|
+
const dependant = d.result[0];
|
|
333
|
+
const relationship = d.relationship;
|
|
334
|
+
return (
|
|
335
|
+
<RadioButton
|
|
336
|
+
id={dependant.id}
|
|
337
|
+
labelText={formatDependantDisplayData(dependant, relationship)}
|
|
338
|
+
value={dependant.id}
|
|
339
|
+
/>
|
|
340
|
+
);
|
|
341
|
+
})}
|
|
342
|
+
</RadioButtonGroup>
|
|
343
|
+
</>
|
|
344
|
+
) : (
|
|
345
|
+
<></>
|
|
346
|
+
)}
|
|
347
|
+
|
|
348
|
+
{displayOtpModal ? (
|
|
349
|
+
<OtpVerificationModal
|
|
350
|
+
requestCustomOtpDto={requestCustomOtpDto}
|
|
351
|
+
phoneNumber={principal.phone}
|
|
352
|
+
open={displayOtpModal}
|
|
353
|
+
onModalClose={handleModelClose}
|
|
354
|
+
onOtpSuccessfullVerification={handleOtpSuccessfullVerification}
|
|
355
|
+
/>
|
|
356
|
+
) : (
|
|
357
|
+
<></>
|
|
358
|
+
)}
|
|
359
|
+
|
|
360
|
+
{principal && displayClientDetailsModal ? (
|
|
361
|
+
<>
|
|
362
|
+
<ClientDetailsModal
|
|
363
|
+
client={getPatient()}
|
|
364
|
+
open={displayClientDetailsModal}
|
|
365
|
+
onModalClose={onClientDetailsModalClose}
|
|
366
|
+
onSubmit={handleClientDetailsSubmit}
|
|
367
|
+
onSendClientToTriage={handleSendClientToTriage}
|
|
368
|
+
/>{' '}
|
|
369
|
+
</>
|
|
370
|
+
) : (
|
|
371
|
+
<></>
|
|
372
|
+
)}
|
|
373
|
+
|
|
374
|
+
{principal && displaytriageModal ? (
|
|
375
|
+
<>
|
|
376
|
+
<SendToTriageModal
|
|
377
|
+
client={getPatient()}
|
|
378
|
+
patients={amrsPatients}
|
|
379
|
+
open={displaytriageModal}
|
|
380
|
+
onModalClose={onSendToTriageModalClose}
|
|
381
|
+
onSubmit={handleSendToTriageModalSubmit}
|
|
382
|
+
onCreateAmrsPatient={createAmrsPatient}
|
|
383
|
+
onManualRegistration={handleManualRegistration}
|
|
384
|
+
/>
|
|
385
|
+
</>
|
|
386
|
+
) : (
|
|
387
|
+
<></>
|
|
388
|
+
)}
|
|
389
|
+
</div>
|
|
390
|
+
</div>
|
|
391
|
+
</div>
|
|
392
|
+
) : (
|
|
393
|
+
<></>
|
|
394
|
+
)}
|
|
395
|
+
</div>
|
|
396
|
+
</div>
|
|
397
|
+
</div>
|
|
398
|
+
</>
|
|
399
|
+
);
|
|
5
400
|
};
|
|
6
401
|
|
|
7
402
|
export default RegistryComponent;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { getHieBaseUrl } from '../shared/utils/get-base-url';
|
|
2
|
+
import {
|
|
3
|
+
type ClientRegistrySearchRequest,
|
|
4
|
+
type RequestCustomOtpDto,
|
|
5
|
+
type RequestCustomOtpResponse,
|
|
6
|
+
type ValidateCustomOtpResponse,
|
|
7
|
+
type ValidateHieCustomOtpDto,
|
|
8
|
+
} from './types';
|
|
9
|
+
|
|
10
|
+
export type ClientRegistrySearchResponse = any[];
|
|
11
|
+
|
|
12
|
+
async function postJson<T>(url: string, payload: unknown): Promise<T> {
|
|
13
|
+
const response = await fetch(url, {
|
|
14
|
+
method: 'POST',
|
|
15
|
+
headers: { 'Content-Type': 'application/json' },
|
|
16
|
+
body: JSON.stringify(payload),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
if (!response.ok) {
|
|
20
|
+
const errorText = await response.text();
|
|
21
|
+
throw new Error(`Request failed with ${response.status}: ${errorText}`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return response.json() as Promise<T>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function requestCustomOtp(payload: RequestCustomOtpDto): Promise<RequestCustomOtpResponse> {
|
|
28
|
+
const hieBaseUrl = await getHieBaseUrl();
|
|
29
|
+
const url = `${hieBaseUrl}/client/send-custom-otp`;
|
|
30
|
+
const formattedPayload = {
|
|
31
|
+
identificationNumber: payload.identificationNumber,
|
|
32
|
+
identificationType: payload.identificationType,
|
|
33
|
+
locationUuid: payload.locationUuid,
|
|
34
|
+
};
|
|
35
|
+
return postJson<RequestCustomOtpResponse>(url, formattedPayload);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function validateCustomOtp(payload: ValidateHieCustomOtpDto): Promise<ValidateCustomOtpResponse> {
|
|
39
|
+
const hieBaseUrl = await getHieBaseUrl();
|
|
40
|
+
const url = `${hieBaseUrl}/client/validate-custom-otp`;
|
|
41
|
+
const formattedPayload = {
|
|
42
|
+
sessionId: payload.sessionId,
|
|
43
|
+
otp: payload.otp,
|
|
44
|
+
locationUuid: payload.locationUuid,
|
|
45
|
+
};
|
|
46
|
+
return postJson<ValidateCustomOtpResponse>(url, formattedPayload);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export async function fetchClientRegistryData(
|
|
50
|
+
payload: ClientRegistrySearchRequest,
|
|
51
|
+
): Promise<ClientRegistrySearchResponse> {
|
|
52
|
+
const hieBaseUrl = await getHieBaseUrl();
|
|
53
|
+
const url = `${hieBaseUrl}/client/search`;
|
|
54
|
+
const formattedPayload = {
|
|
55
|
+
identificationNumber: payload.identificationNumber,
|
|
56
|
+
identificationType: payload.identificationType,
|
|
57
|
+
locationUuid: payload.locationUuid,
|
|
58
|
+
};
|
|
59
|
+
return postJson<ClientRegistrySearchResponse>(url, formattedPayload);
|
|
60
|
+
}
|