@ampath/esm-patient-registration-app 9.2.0-next.18 → 9.2.0-next.19
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/2523.js +1 -0
- package/dist/2523.js.map +1 -0
- package/dist/6583.js +1 -0
- package/dist/6583.js.map +1 -0
- package/dist/7821.js +1 -1
- package/dist/8414.js +1 -1
- package/dist/8414.js.map +1 -1
- package/dist/9853.js +1 -0
- package/dist/9853.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/openmrs-esm-patient-registration-app.js.buildmanifest.json +76 -76
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/patient-registration/client-registry/client-registry-search.component.tsx +13 -4
- package/src/patient-registration/client-registry/existing-client/client-dependants-comparison/client-dependants-comparison.component.tsx +26 -0
- package/src/patient-registration/client-registry/existing-client/client-dependants-comparison/dependant-comparison-rows.component.tsx +153 -0
- package/src/patient-registration/client-registry/existing-client/client-details-comparison/client-details-comparison.component.tsx +181 -0
- package/src/patient-registration/client-registry/existing-client/client-details-comparison/comparison-table-row.component.tsx +42 -0
- package/src/patient-registration/client-registry/existing-client/client-registry-verification-tag.component.tsx +54 -0
- package/src/patient-registration/client-registry/existing-client/existing-client-tab.component.tsx +85 -0
- package/src/patient-registration/client-registry/existing-client/existing-client.resource.ts +78 -0
- package/src/patient-registration/client-registry/existing-client/mapper-utils.ts +419 -0
- package/src/patient-registration/client-registry/existing-client/types/index.ts +185 -0
- package/src/patient-registration/client-registry/{client-dependants → new-client/client-dependants}/list/client-depandants.component.tsx +1 -1
- package/src/patient-registration/client-registry/{client-details → new-client/client-details}/client-details.tsx +2 -2
- package/src/patient-registration/client-registry/new-client/new-client-tab.component.tsx +30 -0
- package/src/patient-registration/client-registry/types/index.ts +10 -0
- package/src/patient-registration/patient-registration.component.tsx +1 -0
- package/src/widgets/client-registry-verification.modal.tsx +13 -0
- package/dist/4395.js +0 -1
- package/dist/4395.js.map +0 -1
- package/dist/6741.js +0 -1
- package/dist/6741.js.map +0 -1
- package/dist/8882.js +0 -1
- package/dist/8882.js.map +0 -1
|
@@ -298,6 +298,31 @@
|
|
|
298
298
|
"hash": "a8b5c0ea2ff5d96f",
|
|
299
299
|
"childrenByOrder": {}
|
|
300
300
|
},
|
|
301
|
+
{
|
|
302
|
+
"rendered": true,
|
|
303
|
+
"initial": false,
|
|
304
|
+
"entry": false,
|
|
305
|
+
"recorded": false,
|
|
306
|
+
"reason": "split chunk (cache group: default)",
|
|
307
|
+
"size": 149526,
|
|
308
|
+
"sizes": {
|
|
309
|
+
"javascript": 149526
|
|
310
|
+
},
|
|
311
|
+
"names": [],
|
|
312
|
+
"idHints": [],
|
|
313
|
+
"runtime": [
|
|
314
|
+
"@ampath/esm-patient-registration-app",
|
|
315
|
+
"main"
|
|
316
|
+
],
|
|
317
|
+
"files": [
|
|
318
|
+
"2523.js"
|
|
319
|
+
],
|
|
320
|
+
"auxiliaryFiles": [
|
|
321
|
+
"2523.js.map"
|
|
322
|
+
],
|
|
323
|
+
"hash": "bb0f4d90b804432e",
|
|
324
|
+
"childrenByOrder": {}
|
|
325
|
+
},
|
|
301
326
|
{
|
|
302
327
|
"rendered": true,
|
|
303
328
|
"initial": false,
|
|
@@ -578,30 +603,6 @@
|
|
|
578
603
|
"hash": "93419d8f25067437",
|
|
579
604
|
"childrenByOrder": {}
|
|
580
605
|
},
|
|
581
|
-
{
|
|
582
|
-
"rendered": true,
|
|
583
|
-
"initial": false,
|
|
584
|
-
"entry": false,
|
|
585
|
-
"recorded": false,
|
|
586
|
-
"size": 53431,
|
|
587
|
-
"sizes": {
|
|
588
|
-
"javascript": 53431
|
|
589
|
-
},
|
|
590
|
-
"names": [],
|
|
591
|
-
"idHints": [],
|
|
592
|
-
"runtime": [
|
|
593
|
-
"@ampath/esm-patient-registration-app",
|
|
594
|
-
"main"
|
|
595
|
-
],
|
|
596
|
-
"files": [
|
|
597
|
-
"4395.js"
|
|
598
|
-
],
|
|
599
|
-
"auxiliaryFiles": [
|
|
600
|
-
"4395.js.map"
|
|
601
|
-
],
|
|
602
|
-
"hash": "3c7d9adcd5a22b91",
|
|
603
|
-
"childrenByOrder": {}
|
|
604
|
-
},
|
|
605
606
|
{
|
|
606
607
|
"rendered": true,
|
|
607
608
|
"initial": false,
|
|
@@ -955,9 +956,9 @@
|
|
|
955
956
|
"initial": false,
|
|
956
957
|
"entry": false,
|
|
957
958
|
"recorded": false,
|
|
958
|
-
"size":
|
|
959
|
+
"size": 3883,
|
|
959
960
|
"sizes": {
|
|
960
|
-
"javascript":
|
|
961
|
+
"javascript": 3883
|
|
961
962
|
},
|
|
962
963
|
"names": [],
|
|
963
964
|
"idHints": [],
|
|
@@ -966,10 +967,12 @@
|
|
|
966
967
|
"main"
|
|
967
968
|
],
|
|
968
969
|
"files": [
|
|
969
|
-
"
|
|
970
|
+
"6583.js"
|
|
970
971
|
],
|
|
971
|
-
"auxiliaryFiles": [
|
|
972
|
-
|
|
972
|
+
"auxiliaryFiles": [
|
|
973
|
+
"6583.js.map"
|
|
974
|
+
],
|
|
975
|
+
"hash": "bf48d4479083b76f",
|
|
973
976
|
"childrenByOrder": {}
|
|
974
977
|
},
|
|
975
978
|
{
|
|
@@ -977,26 +980,21 @@
|
|
|
977
980
|
"initial": false,
|
|
978
981
|
"entry": false,
|
|
979
982
|
"recorded": false,
|
|
980
|
-
"
|
|
981
|
-
"size": 80564,
|
|
983
|
+
"size": 6547,
|
|
982
984
|
"sizes": {
|
|
983
|
-
"javascript":
|
|
985
|
+
"javascript": 6547
|
|
984
986
|
},
|
|
985
987
|
"names": [],
|
|
986
|
-
"idHints": [
|
|
987
|
-
"vendors"
|
|
988
|
-
],
|
|
988
|
+
"idHints": [],
|
|
989
989
|
"runtime": [
|
|
990
990
|
"@ampath/esm-patient-registration-app",
|
|
991
991
|
"main"
|
|
992
992
|
],
|
|
993
993
|
"files": [
|
|
994
|
-
"
|
|
995
|
-
],
|
|
996
|
-
"auxiliaryFiles": [
|
|
997
|
-
"6687.js.map"
|
|
994
|
+
"6679.js"
|
|
998
995
|
],
|
|
999
|
-
"
|
|
996
|
+
"auxiliaryFiles": [],
|
|
997
|
+
"hash": "6a2dc2d473cfe02a",
|
|
1000
998
|
"childrenByOrder": {}
|
|
1001
999
|
},
|
|
1002
1000
|
{
|
|
@@ -1004,23 +1002,26 @@
|
|
|
1004
1002
|
"initial": false,
|
|
1005
1003
|
"entry": false,
|
|
1006
1004
|
"recorded": false,
|
|
1007
|
-
"
|
|
1005
|
+
"reason": "split chunk (cache group: defaultVendors)",
|
|
1006
|
+
"size": 80564,
|
|
1008
1007
|
"sizes": {
|
|
1009
|
-
"javascript":
|
|
1008
|
+
"javascript": 80564
|
|
1010
1009
|
},
|
|
1011
1010
|
"names": [],
|
|
1012
|
-
"idHints": [
|
|
1011
|
+
"idHints": [
|
|
1012
|
+
"vendors"
|
|
1013
|
+
],
|
|
1013
1014
|
"runtime": [
|
|
1014
1015
|
"@ampath/esm-patient-registration-app",
|
|
1015
1016
|
"main"
|
|
1016
1017
|
],
|
|
1017
1018
|
"files": [
|
|
1018
|
-
"
|
|
1019
|
+
"6687.js"
|
|
1019
1020
|
],
|
|
1020
1021
|
"auxiliaryFiles": [
|
|
1021
|
-
"
|
|
1022
|
+
"6687.js.map"
|
|
1022
1023
|
],
|
|
1023
|
-
"hash": "
|
|
1024
|
+
"hash": "09088578b9bade84",
|
|
1024
1025
|
"childrenByOrder": {}
|
|
1025
1026
|
},
|
|
1026
1027
|
{
|
|
@@ -1210,9 +1211,9 @@
|
|
|
1210
1211
|
"initial": false,
|
|
1211
1212
|
"entry": false,
|
|
1212
1213
|
"recorded": false,
|
|
1213
|
-
"size":
|
|
1214
|
+
"size": 145351,
|
|
1214
1215
|
"sizes": {
|
|
1215
|
-
"javascript":
|
|
1216
|
+
"javascript": 145351
|
|
1216
1217
|
},
|
|
1217
1218
|
"names": [],
|
|
1218
1219
|
"idHints": [],
|
|
@@ -1225,7 +1226,7 @@
|
|
|
1225
1226
|
"auxiliaryFiles": [
|
|
1226
1227
|
"7821.js.map"
|
|
1227
1228
|
],
|
|
1228
|
-
"hash": "
|
|
1229
|
+
"hash": "1e98f0254f77d833",
|
|
1229
1230
|
"childrenByOrder": {}
|
|
1230
1231
|
},
|
|
1231
1232
|
{
|
|
@@ -1298,9 +1299,9 @@
|
|
|
1298
1299
|
"initial": false,
|
|
1299
1300
|
"entry": false,
|
|
1300
1301
|
"recorded": false,
|
|
1301
|
-
"size":
|
|
1302
|
+
"size": 1240,
|
|
1302
1303
|
"sizes": {
|
|
1303
|
-
"javascript":
|
|
1304
|
+
"javascript": 1240
|
|
1304
1305
|
},
|
|
1305
1306
|
"names": [],
|
|
1306
1307
|
"idHints": [],
|
|
@@ -1314,7 +1315,7 @@
|
|
|
1314
1315
|
"auxiliaryFiles": [
|
|
1315
1316
|
"8414.js.map"
|
|
1316
1317
|
],
|
|
1317
|
-
"hash": "
|
|
1318
|
+
"hash": "ab4e9ca64444c78d",
|
|
1318
1319
|
"childrenByOrder": {}
|
|
1319
1320
|
},
|
|
1320
1321
|
{
|
|
@@ -1368,10 +1369,10 @@
|
|
|
1368
1369
|
"initial": true,
|
|
1369
1370
|
"entry": true,
|
|
1370
1371
|
"recorded": false,
|
|
1371
|
-
"size":
|
|
1372
|
+
"size": 2686905,
|
|
1372
1373
|
"sizes": {
|
|
1373
1374
|
"consume-shared": 168,
|
|
1374
|
-
"javascript":
|
|
1375
|
+
"javascript": 2664369,
|
|
1375
1376
|
"share-init": 336,
|
|
1376
1377
|
"runtime": 22032
|
|
1377
1378
|
},
|
|
@@ -1388,7 +1389,7 @@
|
|
|
1388
1389
|
"auxiliaryFiles": [
|
|
1389
1390
|
"main.js.map"
|
|
1390
1391
|
],
|
|
1391
|
-
"hash": "
|
|
1392
|
+
"hash": "4fdab53d48aa6f52",
|
|
1392
1393
|
"childrenByOrder": {}
|
|
1393
1394
|
},
|
|
1394
1395
|
{
|
|
@@ -1396,10 +1397,9 @@
|
|
|
1396
1397
|
"initial": false,
|
|
1397
1398
|
"entry": false,
|
|
1398
1399
|
"recorded": false,
|
|
1399
|
-
"
|
|
1400
|
-
"size": 116185,
|
|
1400
|
+
"size": 6145,
|
|
1401
1401
|
"sizes": {
|
|
1402
|
-
"javascript":
|
|
1402
|
+
"javascript": 6145
|
|
1403
1403
|
},
|
|
1404
1404
|
"names": [],
|
|
1405
1405
|
"idHints": [],
|
|
@@ -1408,12 +1408,10 @@
|
|
|
1408
1408
|
"main"
|
|
1409
1409
|
],
|
|
1410
1410
|
"files": [
|
|
1411
|
-
"
|
|
1412
|
-
],
|
|
1413
|
-
"auxiliaryFiles": [
|
|
1414
|
-
"8882.js.map"
|
|
1411
|
+
"9214.js"
|
|
1415
1412
|
],
|
|
1416
|
-
"
|
|
1413
|
+
"auxiliaryFiles": [],
|
|
1414
|
+
"hash": "557d45dd8b80aac2",
|
|
1417
1415
|
"childrenByOrder": {}
|
|
1418
1416
|
},
|
|
1419
1417
|
{
|
|
@@ -1421,9 +1419,9 @@
|
|
|
1421
1419
|
"initial": false,
|
|
1422
1420
|
"entry": false,
|
|
1423
1421
|
"recorded": false,
|
|
1424
|
-
"size":
|
|
1422
|
+
"size": 6573,
|
|
1425
1423
|
"sizes": {
|
|
1426
|
-
"javascript":
|
|
1424
|
+
"javascript": 6573
|
|
1427
1425
|
},
|
|
1428
1426
|
"names": [],
|
|
1429
1427
|
"idHints": [],
|
|
@@ -1432,10 +1430,10 @@
|
|
|
1432
1430
|
"main"
|
|
1433
1431
|
],
|
|
1434
1432
|
"files": [
|
|
1435
|
-
"
|
|
1433
|
+
"9538.js"
|
|
1436
1434
|
],
|
|
1437
1435
|
"auxiliaryFiles": [],
|
|
1438
|
-
"hash": "
|
|
1436
|
+
"hash": "834a8b67aa62ebba",
|
|
1439
1437
|
"childrenByOrder": {}
|
|
1440
1438
|
},
|
|
1441
1439
|
{
|
|
@@ -1443,9 +1441,9 @@
|
|
|
1443
1441
|
"initial": false,
|
|
1444
1442
|
"entry": false,
|
|
1445
1443
|
"recorded": false,
|
|
1446
|
-
"size":
|
|
1444
|
+
"size": 6021,
|
|
1447
1445
|
"sizes": {
|
|
1448
|
-
"javascript":
|
|
1446
|
+
"javascript": 6021
|
|
1449
1447
|
},
|
|
1450
1448
|
"names": [],
|
|
1451
1449
|
"idHints": [],
|
|
@@ -1454,10 +1452,10 @@
|
|
|
1454
1452
|
"main"
|
|
1455
1453
|
],
|
|
1456
1454
|
"files": [
|
|
1457
|
-
"
|
|
1455
|
+
"9569.js"
|
|
1458
1456
|
],
|
|
1459
1457
|
"auxiliaryFiles": [],
|
|
1460
|
-
"hash": "
|
|
1458
|
+
"hash": "4d989f532c63737b",
|
|
1461
1459
|
"childrenByOrder": {}
|
|
1462
1460
|
},
|
|
1463
1461
|
{
|
|
@@ -1465,9 +1463,9 @@
|
|
|
1465
1463
|
"initial": false,
|
|
1466
1464
|
"entry": false,
|
|
1467
1465
|
"recorded": false,
|
|
1468
|
-
"size":
|
|
1466
|
+
"size": 680853,
|
|
1469
1467
|
"sizes": {
|
|
1470
|
-
"javascript":
|
|
1468
|
+
"javascript": 680853
|
|
1471
1469
|
},
|
|
1472
1470
|
"names": [],
|
|
1473
1471
|
"idHints": [],
|
|
@@ -1476,10 +1474,12 @@
|
|
|
1476
1474
|
"main"
|
|
1477
1475
|
],
|
|
1478
1476
|
"files": [
|
|
1479
|
-
"
|
|
1477
|
+
"9853.js"
|
|
1480
1478
|
],
|
|
1481
|
-
"auxiliaryFiles": [
|
|
1482
|
-
|
|
1479
|
+
"auxiliaryFiles": [
|
|
1480
|
+
"9853.js.map"
|
|
1481
|
+
],
|
|
1482
|
+
"hash": "57b9558dff0bf2e9",
|
|
1483
1483
|
"childrenByOrder": {}
|
|
1484
1484
|
},
|
|
1485
1485
|
{
|
package/dist/routes.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":">=2.2.0"},"pages":[{"component":"root","route":"patient-registration","online":true,"offline":true},{"component":"editPatient","routeRegex":"patient\\/([a-zA-Z0-9\\-]+)\\/edit","online":true,"offline":true}],"extensions":[{"component":"addPatientLink","name":"add-patient-action","slot":"top-nav-actions-slot","online":true,"offline":true,"order":30},{"component":"patientPhotoExtension","name":"patient-photo-widget","slot":"patient-photo-slot","online":true,"offline":true},{"component":"editPatientDetailsButton","name":"edit-patient-details-button","slot":"patient-actions-slot","online":true,"offline":true},{"component":"editPatientDetailsButton","name":"edit-patient-details-button","slot":"patient-search-actions-slot","online":true,"offline":true},{"component":"clientRegistryVerificationTag","name":"client-registry-verification-tag","slot":"patient-banner-tags-slot","online":true,"offline":true}],"modals":[{"name":"cancel-patient-edit-modal","component":"cancelPatientEditModal"},{"name":"delete-identifier-confirmation-modal","component":"deleteIdentifierConfirmationModal"},{"name":"client-registry-verification-modal","component":"clientRegistryVerificationModal"}],"version":"9.2.0-next.
|
|
1
|
+
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":">=2.2.0"},"pages":[{"component":"root","route":"patient-registration","online":true,"offline":true},{"component":"editPatient","routeRegex":"patient\\/([a-zA-Z0-9\\-]+)\\/edit","online":true,"offline":true}],"extensions":[{"component":"addPatientLink","name":"add-patient-action","slot":"top-nav-actions-slot","online":true,"offline":true,"order":30},{"component":"patientPhotoExtension","name":"patient-photo-widget","slot":"patient-photo-slot","online":true,"offline":true},{"component":"editPatientDetailsButton","name":"edit-patient-details-button","slot":"patient-actions-slot","online":true,"offline":true},{"component":"editPatientDetailsButton","name":"edit-patient-details-button","slot":"patient-search-actions-slot","online":true,"offline":true},{"component":"clientRegistryVerificationTag","name":"client-registry-verification-tag","slot":"patient-banner-tags-slot","online":true,"offline":true}],"modals":[{"name":"cancel-patient-edit-modal","component":"cancelPatientEditModal"},{"name":"delete-identifier-confirmation-modal","component":"deleteIdentifierConfirmationModal"},{"name":"client-registry-verification-modal","component":"clientRegistryVerificationModal"}],"version":"9.2.0-next.19"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -63,6 +63,6 @@ export const deleteIdentifierConfirmationModal = getAsyncLifecycle(
|
|
|
63
63
|
);
|
|
64
64
|
|
|
65
65
|
export const clientRegistryVerificationTag = getAsyncLifecycle(
|
|
66
|
-
() => import('./patient-registration/client-registry-
|
|
66
|
+
() => import('./patient-registration/client-registry/existing-client/client-registry-verification-tag.component'),
|
|
67
67
|
options,
|
|
68
68
|
);
|
|
@@ -18,14 +18,17 @@ import { useFormikContext } from 'formik';
|
|
|
18
18
|
import styles from './client-registry-search.scss';
|
|
19
19
|
import { requestCustomOtp, validateCustomOtp, fetchClientRegistryData } from './client-registry.resource';
|
|
20
20
|
import { applyClientRegistryMapping } from './map-client-registry-to-form-utils';
|
|
21
|
-
import ClientDetails from './client-details/client-details';
|
|
21
|
+
import ClientDetails from './new-client/client-details/client-details';
|
|
22
22
|
import { type HieClient } from './types';
|
|
23
|
-
import ClientDependantList from './client-dependants/list/client-depandants.component';
|
|
23
|
+
import ClientDependantList from './new-client/client-dependants/list/client-depandants.component';
|
|
24
|
+
import NewClientTab from './new-client/new-client-tab.component';
|
|
25
|
+
import ExistingClientTab from './existing-client/existing-client-tab.component';
|
|
24
26
|
|
|
25
27
|
export interface ClientRegistryLookupSectionProps {
|
|
26
28
|
onClientVerified?: () => void;
|
|
27
29
|
onModalClose: () => void;
|
|
28
30
|
open: boolean;
|
|
31
|
+
isNewClient: boolean;
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
export type IdentifierType = 'National ID' | 'Alien ID' | 'Passport' | 'Mandate Number' | 'Refugee ID';
|
|
@@ -42,6 +45,7 @@ const ClientRegistryLookupSection: React.FC<ClientRegistryLookupSectionProps> =
|
|
|
42
45
|
onClientVerified,
|
|
43
46
|
open,
|
|
44
47
|
onModalClose,
|
|
48
|
+
isNewClient = true,
|
|
45
49
|
}) => {
|
|
46
50
|
const { setFieldValue } = useFormikContext<any>();
|
|
47
51
|
const [identifierType, setIdentifierType] = useState<IdentifierType>('National ID');
|
|
@@ -294,7 +298,12 @@ const ClientRegistryLookupSection: React.FC<ClientRegistryLookupSectionProps> =
|
|
|
294
298
|
|
|
295
299
|
{otpVerified && client ? (
|
|
296
300
|
<div className="clientDataSection">
|
|
297
|
-
|
|
301
|
+
{isNewClient ? (
|
|
302
|
+
<NewClientTab client={client} useHieData={useHieData} />
|
|
303
|
+
) : (
|
|
304
|
+
<ExistingClientTab hieClient={client} />
|
|
305
|
+
)}
|
|
306
|
+
{/* <Tabs>
|
|
298
307
|
<TabList contained>
|
|
299
308
|
<Tab>Patient</Tab>
|
|
300
309
|
<Tab>Dependants</Tab>
|
|
@@ -306,7 +315,7 @@ const ClientRegistryLookupSection: React.FC<ClientRegistryLookupSectionProps> =
|
|
|
306
315
|
</TabPanel>
|
|
307
316
|
</TabPanels>
|
|
308
317
|
</Tabs>
|
|
309
|
-
<Button onClick={useHieData}>Use Data</Button>
|
|
318
|
+
<Button onClick={useHieData}>Use Data</Button> */}
|
|
310
319
|
</div>
|
|
311
320
|
) : (
|
|
312
321
|
<></>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Accordion } from '@carbon/react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { type ClientDependantsComparisonProps } from '../types';
|
|
4
|
+
import ClientDependantComparisonRows from './dependant-comparison-rows.component';
|
|
5
|
+
|
|
6
|
+
const ClientDependantsComparison: React.FC<ClientDependantsComparisonProps> = ({
|
|
7
|
+
hieDependants,
|
|
8
|
+
amrsClient,
|
|
9
|
+
patientRelationships,
|
|
10
|
+
}) => {
|
|
11
|
+
return (
|
|
12
|
+
<div>
|
|
13
|
+
<Accordion size="lg">
|
|
14
|
+
{hieDependants.map((dependant) => (
|
|
15
|
+
<ClientDependantComparisonRows
|
|
16
|
+
hieDependant={dependant}
|
|
17
|
+
amrsClient={amrsClient}
|
|
18
|
+
patientRelationships={patientRelationships}
|
|
19
|
+
/>
|
|
20
|
+
))}
|
|
21
|
+
</Accordion>
|
|
22
|
+
</div>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default ClientDependantsComparison;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { AccordionItem, Row, Column, Select, SelectItem, Button } from '@carbon/react';
|
|
2
|
+
import { showSnackbar } from '@openmrs/esm-framework';
|
|
3
|
+
import React, { useState } from 'react';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { createPerson, createRelationship, fetchAmrsPersonData } from '../existing-client.resource';
|
|
6
|
+
import {
|
|
7
|
+
patientObjFields,
|
|
8
|
+
mapFieldValue,
|
|
9
|
+
getPatientAttributes,
|
|
10
|
+
personSyncFields,
|
|
11
|
+
nameFields,
|
|
12
|
+
addressFields,
|
|
13
|
+
getPatientRelationshipPayload,
|
|
14
|
+
} from '../mapper-utils';
|
|
15
|
+
import { type AmrsClient, type ClientDependantComparisonRowsProps } from '../types';
|
|
16
|
+
import { type HieDependant } from '../../types';
|
|
17
|
+
import ClientDetailsComparison from '../client-details-comparison/client-details-comparison.component';
|
|
18
|
+
|
|
19
|
+
const ClientDependantComparisonRows: React.FC<ClientDependantComparisonRowsProps> = ({
|
|
20
|
+
hieDependant,
|
|
21
|
+
patientRelationships,
|
|
22
|
+
amrsClient,
|
|
23
|
+
}) => {
|
|
24
|
+
const { t } = useTranslation();
|
|
25
|
+
const [amrsRelationExists, setAmrsRelationExists] = useState(false);
|
|
26
|
+
const [amrsDependantData, setAmrsDependantData] = useState<AmrsClient>();
|
|
27
|
+
const [selectedRelationship, setSelectedRelationship] = useState('');
|
|
28
|
+
|
|
29
|
+
const handleCreateDependant = async (dependantBody: HieDependant) => {
|
|
30
|
+
try {
|
|
31
|
+
const syncFields = {};
|
|
32
|
+
patientObjFields.forEach((field) => {
|
|
33
|
+
let fieldArr = mapFieldValue(field, dependantBody.result[0], amrsClient);
|
|
34
|
+
const hieFieldValue = fieldArr[1];
|
|
35
|
+
syncFields[field] = hieFieldValue;
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// Person
|
|
39
|
+
const patientPayload = {};
|
|
40
|
+
const names = {};
|
|
41
|
+
const addresses = {};
|
|
42
|
+
const otherFields = {};
|
|
43
|
+
const attributes = getPatientAttributes(dependantBody.result[0]);
|
|
44
|
+
Object.entries(syncFields).forEach(([k, v]) => {
|
|
45
|
+
if (personSyncFields.includes(k)) {
|
|
46
|
+
// names
|
|
47
|
+
if (nameFields.includes(k)) {
|
|
48
|
+
names[k] = v;
|
|
49
|
+
}
|
|
50
|
+
// addresses
|
|
51
|
+
else if (addressFields.includes(k)) {
|
|
52
|
+
if (v) {
|
|
53
|
+
addresses[k] = v;
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
otherFields[k] = v;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.assign(
|
|
61
|
+
patientPayload,
|
|
62
|
+
otherFields,
|
|
63
|
+
{ addresses: [addresses] },
|
|
64
|
+
{ names: [names] },
|
|
65
|
+
{ attributes: attributes },
|
|
66
|
+
);
|
|
67
|
+
const response = await createPerson(patientPayload);
|
|
68
|
+
if (response && response.data) {
|
|
69
|
+
showSnackbar({
|
|
70
|
+
kind: 'success',
|
|
71
|
+
title: 'Dependant created successfully.',
|
|
72
|
+
});
|
|
73
|
+
const relationshipPayload = getPatientRelationshipPayload(
|
|
74
|
+
amrsClient,
|
|
75
|
+
dependantBody.relationship,
|
|
76
|
+
response.data.uuid,
|
|
77
|
+
);
|
|
78
|
+
await createRelationship(relationshipPayload);
|
|
79
|
+
showSnackbar({
|
|
80
|
+
kind: 'success',
|
|
81
|
+
title: 'Dependant relationship created successfully.',
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
} catch (err) {
|
|
85
|
+
showSnackbar({
|
|
86
|
+
kind: 'error',
|
|
87
|
+
title: 'Error syncing patient data.',
|
|
88
|
+
subtitle: JSON.stringify(err),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const handleSelectAmrsDependant = async (e: any) => {
|
|
94
|
+
const uuid = e.target.value;
|
|
95
|
+
if (!uuid) {
|
|
96
|
+
setAmrsRelationExists(false);
|
|
97
|
+
setAmrsDependantData(null);
|
|
98
|
+
}
|
|
99
|
+
const response = await fetchAmrsPersonData(uuid);
|
|
100
|
+
if (response && response.data) {
|
|
101
|
+
setAmrsRelationExists(true);
|
|
102
|
+
setAmrsDependantData((prev) => ({ ...prev, person: response.data }));
|
|
103
|
+
} else {
|
|
104
|
+
setAmrsRelationExists(false);
|
|
105
|
+
setAmrsDependantData(null);
|
|
106
|
+
const relationshipUuid = patientRelationships.find((v) => v.relatedPersonUuid === uuid);
|
|
107
|
+
if (relationshipUuid && relationshipUuid.relationshipType) {
|
|
108
|
+
setSelectedRelationship(relationshipUuid.relationshipType);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const getDependantName = () => {
|
|
114
|
+
const name = hieDependant.result[0];
|
|
115
|
+
return `${name.first_name} ${name.middle_name} ${name.last_name} (${hieDependant.relationship})`;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<>
|
|
120
|
+
<AccordionItem title={getDependantName()}>
|
|
121
|
+
<Row>
|
|
122
|
+
<Column>
|
|
123
|
+
<Select labelText={t('amrsDependants', 'AMRS dependants')} onChange={handleSelectAmrsDependant}>
|
|
124
|
+
<SelectItem text={t('selectAmrsRelation', 'Select AMRS relation')} value="" />
|
|
125
|
+
{patientRelationships.map((relationship) => (
|
|
126
|
+
<SelectItem
|
|
127
|
+
text={`${relationship.display} (${relationship.relationshipType})`}
|
|
128
|
+
value={relationship.relatedPerson.uuid}
|
|
129
|
+
/>
|
|
130
|
+
))}
|
|
131
|
+
</Select>
|
|
132
|
+
</Column>
|
|
133
|
+
{!amrsRelationExists ? (
|
|
134
|
+
<Column>
|
|
135
|
+
<Button onClick={() => handleCreateDependant(hieDependant)}>
|
|
136
|
+
{t('createDependant', 'Create dependant in AMRS')}
|
|
137
|
+
</Button>
|
|
138
|
+
</Column>
|
|
139
|
+
) : null}
|
|
140
|
+
</Row>
|
|
141
|
+
<Row>
|
|
142
|
+
<ClientDetailsComparison
|
|
143
|
+
hieClient={hieDependant.result[0]}
|
|
144
|
+
amrsClient={amrsDependantData}
|
|
145
|
+
fromDependant={true}
|
|
146
|
+
/>
|
|
147
|
+
</Row>
|
|
148
|
+
</AccordionItem>
|
|
149
|
+
</>
|
|
150
|
+
);
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export default ClientDependantComparisonRows;
|