@kenyaemr/esm-admin-app 5.4.4-pre.26 → 5.4.4-pre.265
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 +5 -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/1201.js +1 -0
- package/dist/1201.js.map +1 -0
- package/dist/1242.js +1 -0
- package/dist/1242.js.map +1 -0
- package/dist/1311.js +1 -0
- package/dist/1311.js.map +1 -0
- package/dist/1462.js +1 -0
- package/dist/1462.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/1718.js +1 -0
- package/dist/1718.js.map +1 -0
- package/dist/1722.js +1 -0
- package/dist/1722.js.map +1 -0
- package/dist/1772.js +1 -0
- package/dist/1772.js.map +1 -0
- package/dist/1889.js +1 -0
- package/dist/1889.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/2080.js +1 -0
- package/dist/2080.js.map +1 -0
- package/dist/2096.js +1 -0
- package/dist/2096.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/2270.js +1 -0
- package/dist/2270.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/2402.js +1 -0
- package/dist/2402.js.map +1 -0
- package/dist/2500.js +1 -0
- package/dist/2500.js.map +1 -0
- package/dist/251.js +1 -0
- package/dist/251.js.map +1 -0
- package/dist/257.js +1 -0
- package/dist/257.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/2652.js +1 -0
- package/dist/2652.js.map +1 -0
- package/dist/2685.js +1 -0
- package/dist/2685.js.map +1 -0
- package/dist/2948.js +1 -0
- package/dist/2948.js.map +1 -0
- package/dist/3089.js +1 -0
- package/dist/3089.js.map +1 -0
- package/dist/3190.js +1 -0
- package/dist/3190.js.map +1 -0
- package/dist/3224.js +1 -0
- package/dist/3224.js.map +1 -0
- package/dist/3366.js +1 -0
- package/dist/3366.js.map +1 -0
- package/dist/3548.js +1 -0
- package/dist/3548.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/3775.js +1 -0
- package/dist/3775.js.map +1 -0
- package/dist/3816.js +1 -0
- package/dist/3816.js.map +1 -0
- package/dist/3852.js +1 -0
- package/dist/3852.js.map +1 -0
- package/dist/3906.js +1 -0
- package/dist/3906.js.map +1 -0
- package/dist/3963.js +1 -0
- package/dist/3963.js.map +1 -0
- package/dist/4047.js +1 -0
- package/dist/4047.js.map +1 -0
- package/dist/405.js +1 -0
- package/dist/405.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/4584.js +1 -0
- package/dist/4584.js.map +1 -0
- package/dist/4735.js +1 -0
- package/dist/4735.js.map +1 -0
- package/dist/4744.js +1 -0
- package/dist/4744.js.map +1 -0
- package/dist/4813.js +2 -0
- package/dist/4813.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/5202.js +1 -0
- package/dist/5202.js.map +1 -0
- package/dist/5294.js +1 -0
- package/dist/5294.js.map +1 -0
- package/dist/545.js +1 -0
- package/dist/545.js.map +1 -0
- package/dist/552.js +1 -0
- package/dist/552.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/5884.js +1 -0
- package/dist/5884.js.map +1 -0
- package/dist/5940.js +1 -0
- package/dist/5940.js.map +1 -0
- package/dist/6092.js +1 -0
- package/dist/6092.js.map +1 -0
- package/dist/6155.js +1 -0
- package/dist/6155.js.map +1 -0
- package/dist/6178.js +1 -0
- package/dist/6178.js.map +1 -0
- package/dist/6399.js +1 -0
- package/dist/6399.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/6492.js +1 -0
- package/dist/6492.js.map +1 -0
- package/dist/6676.js +1 -0
- package/dist/6676.js.map +1 -0
- package/dist/6800.js +1 -0
- package/dist/6800.js.map +1 -0
- package/dist/6976.js +1 -0
- package/dist/6976.js.map +1 -0
- package/dist/7005.js +1 -0
- package/dist/7005.js.map +1 -0
- package/dist/7201.js +1 -0
- package/dist/7201.js.map +1 -0
- package/dist/7210.js +1 -0
- package/dist/7210.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/7463.js +1 -0
- package/dist/7463.js.map +1 -0
- package/dist/7528.js +1 -0
- package/dist/7528.js.map +1 -0
- package/dist/7607.js +1 -0
- package/dist/7717.js +1 -0
- package/dist/7717.js.map +1 -0
- package/dist/7737.js +1 -0
- package/dist/7737.js.map +1 -0
- package/dist/7739.js +1 -0
- package/dist/7739.js.map +1 -0
- package/dist/7765.js +1 -0
- package/dist/7765.js.map +1 -0
- package/dist/7820.js +1 -0
- package/dist/7820.js.map +1 -0
- package/dist/7844.js +1 -0
- package/dist/7844.js.map +1 -0
- package/dist/7866.js +1 -0
- package/dist/7866.js.map +1 -0
- package/dist/7916.js +1 -0
- package/dist/7916.js.map +1 -0
- package/dist/7971.js +1 -0
- package/dist/7971.js.map +1 -0
- package/dist/8159.js +7 -0
- package/dist/8159.js.map +1 -0
- package/dist/8244.js +1 -0
- package/dist/8244.js.map +1 -0
- package/dist/8262.js +1 -0
- package/dist/8262.js.map +1 -0
- package/dist/8376.js +1 -0
- package/dist/8376.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/87.js +1 -0
- package/dist/87.js.map +1 -0
- package/dist/8727.js +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/9036.js +1 -0
- package/dist/9036.js.map +1 -0
- package/dist/9124.js +1 -0
- package/dist/9124.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/9404.js +1 -0
- package/dist/9404.js.map +1 -0
- package/dist/9406.js +1 -0
- package/dist/9406.js.map +1 -0
- package/dist/9446.js +1 -0
- package/dist/9446.js.map +1 -0
- package/dist/9449.js +1 -0
- package/dist/9449.js.map +1 -0
- package/dist/9566.js +5 -0
- package/dist/9566.js.map +1 -0
- package/dist/9641.js +1 -0
- package/dist/9641.js.map +1 -0
- package/dist/9711.js +1 -0
- package/dist/9711.js.map +1 -0
- package/dist/9801.js +1 -0
- package/dist/9801.js.map +1 -0
- package/dist/9835.js +11 -0
- package/dist/9835.js.map +1 -0
- package/dist/kenyaemr-esm-admin-app.js +5 -5
- package/dist/kenyaemr-esm-admin-app.js.buildmanifest.json +2649 -154
- package/dist/kenyaemr-esm-admin-app.js.map +1 -1
- package/dist/main.js +5 -31
- package/dist/main.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +5 -7
- package/rspack.config.js +1 -1
- package/src/components/facility-setup/constant/index.ts +3 -0
- package/src/components/facility-setup/facility-info.component.tsx +247 -108
- package/src/components/facility-setup/facility-info.scss +136 -55
- package/src/components/facility-setup/facility-setup.component.tsx +2 -2
- package/src/components/facility-setup/header/header.component.tsx +4 -10
- package/src/components/facility-setup/header/header.scss +3 -9
- package/src/components/facility-setup/shared/custom-info.component.tsx +9 -0
- package/src/components/facility-setup/shared/custom-section-card.component.tsx +10 -0
- package/src/components/facility-setup/shared/custom-status-tag.component.tsx +22 -0
- package/src/components/facility-setup/type/index.ts +61 -0
- package/src/components/facility-setup/useFacilityRegistry.ts +29 -0
- package/src/components/hook/healthWorkerRegistry.ts +78 -0
- package/src/components/hook/useProfessionalRegistryEnums.ts +59 -0
- package/src/components/locations/forms/add-location/add-location.workspace.tsx +96 -95
- package/src/components/locations/forms/search-location/search-location.workspace.tsx +90 -85
- package/src/components/locations/tables/locations-table.component.tsx +117 -121
- package/src/components/modal/hwr-confirmation.modal.scss +80 -4
- package/src/components/modal/hwr-confirmation.modal.tsx +118 -128
- package/src/components/modal/hwr-sync.modal.tsx +194 -106
- package/src/components/users/manage-users/manage-user-role-scope/user-role-scope-workspace/user-role-scope.workspace.tsx +13 -13
- package/src/components/users/manage-users/user-details/user-detail.scss +168 -39
- package/src/components/users/manage-users/user-details/user-details.component.tsx +130 -122
- package/src/components/users/manage-users/user-list/user-list.component.tsx +22 -9
- package/src/components/users/manage-users/user-management.workspace.scss +233 -95
- package/src/components/users/manage-users/user-management.workspace.tsx +800 -687
- package/src/components/users/userManagementFormSchema.tsx +17 -8
- package/src/config-schema.ts +48 -68
- package/src/index.ts +55 -30
- package/src/left-pannel-link.component.tsx +5 -3
- package/src/root.component.tsx +11 -13
- package/src/routes.json +40 -40
- package/src/types/index.ts +29 -1
- package/translations/am.json +158 -13
- package/translations/en.json +158 -13
- package/translations/fr.json +193 -47
- package/translations/sw.json +158 -13
- package/tsconfig.json +1 -1
- package/dist/127.js +0 -1
- package/dist/267.js +0 -1
- package/dist/267.js.map +0 -1
- package/dist/281.js +0 -15
- package/dist/281.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 -1
- package/dist/472.js.map +0 -1
- package/dist/478.js +0 -1
- package/dist/478.js.map +0 -1
- package/dist/585.js +0 -1
- package/dist/585.js.map +0 -1
- package/dist/630.js +0 -1
- package/dist/630.js.map +0 -1
- package/dist/675.js +0 -1
- package/dist/675.js.map +0 -1
- package/dist/689.js +0 -1
- package/dist/689.js.map +0 -1
- package/dist/706.js +0 -27
- package/dist/706.js.map +0 -1
- package/dist/729.js +0 -17
- package/dist/729.js.map +0 -1
- package/dist/774.js +0 -1
- package/dist/774.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/998.js +0 -1
- package/dist/998.js.map +0 -1
- package/jest.config.js +0 -8
- package/src/components/facility-setup/card.component.tsx +0 -16
- package/src/components/facility-setup/facility-setup.resource.tsx +0 -7
- package/src/components/hook/healthWorkerAdapter.ts +0 -213
- package/src/components/hook/useFacilityInfo.tsx +0 -37
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import { FetchResponse, makeUrl, openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
|
|
2
|
-
import { HWR_API_NO_CREDENTIALS, PROVIDER_NOT_FOUND, RESOURCE_NOT_FOUND, UNKNOWN } from '../../constants';
|
|
3
|
-
import { CustomHIEPractitionerResponse, PractitionerResponse } from '../../types';
|
|
4
|
-
import { useState } from 'react';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Unified response type that can handle both FHIR and custom HIE formats
|
|
8
|
-
*/
|
|
9
|
-
export interface UnifiedHealthWorkerResponse {
|
|
10
|
-
fhirFormat: boolean;
|
|
11
|
-
data: PractitionerResponse | CustomHIEPractitionerResponse;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Adapter to normalize health worker data based on response format
|
|
16
|
-
*/
|
|
17
|
-
export class HealthWorkerAdapter {
|
|
18
|
-
/**
|
|
19
|
-
* Extracts common practitioner information from either response format
|
|
20
|
-
*/
|
|
21
|
-
static normalize(response: UnifiedHealthWorkerResponse): NormalizedPractitioner {
|
|
22
|
-
if (response.fhirFormat) {
|
|
23
|
-
return this.normalizeFHIRResponse(response.data as PractitionerResponse);
|
|
24
|
-
} else {
|
|
25
|
-
return this.normalizeCustomResponse(response.data as CustomHIEPractitionerResponse);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
private static normalizeFHIRResponse(data: PractitionerResponse): NormalizedPractitioner {
|
|
30
|
-
const resource = data.entry?.[0]?.resource;
|
|
31
|
-
if (!resource) {
|
|
32
|
-
throw new Error('Invalid FHIR response: No resource found');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const name = resource.name?.[0];
|
|
36
|
-
const identifierByType = (code: string) =>
|
|
37
|
-
resource.identifier?.find((id) => id.type?.coding?.[0]?.code === code)?.value;
|
|
38
|
-
|
|
39
|
-
const primaryQualification = resource.qualification?.[0];
|
|
40
|
-
const licenseExtension = primaryQualification?.extension?.find(
|
|
41
|
-
(ext) => ext.url.includes('license') || ext.url.includes('registration'),
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
id: resource.id,
|
|
46
|
-
fullName: name?.text || '',
|
|
47
|
-
firstName: name?.text?.split(' ')[0] || '',
|
|
48
|
-
middleName: name?.text?.split(' ')[1] || '',
|
|
49
|
-
lastName: name?.text?.split(' ')[2] || name?.text?.split(' ')[1] || '',
|
|
50
|
-
gender: resource.gender || '',
|
|
51
|
-
registrationId: identifierByType('registration') || '',
|
|
52
|
-
externalReferenceId: identifierByType('license') || '',
|
|
53
|
-
nationalId: identifierByType('national_id') || '',
|
|
54
|
-
passportNumber: identifierByType('passport') || '',
|
|
55
|
-
licenseNumber: identifierByType('license') || '',
|
|
56
|
-
licensingBody: licenseExtension?.valueCoding?.display || '',
|
|
57
|
-
specialty: primaryQualification?.code?.coding?.[0]?.display || '',
|
|
58
|
-
qualification: primaryQualification?.code?.coding?.[0]?.display || '',
|
|
59
|
-
phoneNumber: resource.telecom?.find((t) => t.system === 'phone')?.value || '',
|
|
60
|
-
email: resource.telecom?.find((t) => t.system === 'email')?.value || '',
|
|
61
|
-
licenseStartDate: primaryQualification?.period?.start || '',
|
|
62
|
-
licenseEndDate: primaryQualification?.period?.end || '',
|
|
63
|
-
isActive: resource.active,
|
|
64
|
-
providerUniqueIdentifier: resource.id,
|
|
65
|
-
status: resource.active ? 'active' : 'inactive',
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
private static normalizeCustomResponse(data: CustomHIEPractitionerResponse): NormalizedPractitioner {
|
|
70
|
-
const { membership, licenses, contacts, identifiers, professional_details } = data.message;
|
|
71
|
-
|
|
72
|
-
const mostRecentLicense = licenses
|
|
73
|
-
?.filter((l) => l.license_end)
|
|
74
|
-
.sort((a, b) => new Date(b.license_end).getTime() - new Date(a.license_end).getTime())[0];
|
|
75
|
-
|
|
76
|
-
return {
|
|
77
|
-
id: membership.id,
|
|
78
|
-
fullName: membership.full_name,
|
|
79
|
-
firstName: membership.first_name,
|
|
80
|
-
middleName: membership.middle_name,
|
|
81
|
-
lastName: membership.last_name,
|
|
82
|
-
gender: membership.gender,
|
|
83
|
-
registrationId: membership.registration_id,
|
|
84
|
-
externalReferenceId: membership.external_reference_id,
|
|
85
|
-
nationalId: identifiers.identification_number,
|
|
86
|
-
passportNumber: '',
|
|
87
|
-
licenseNumber: membership.external_reference_id,
|
|
88
|
-
licensingBody: membership.licensing_body,
|
|
89
|
-
specialty: membership.specialty || professional_details?.specialty,
|
|
90
|
-
qualification: professional_details?.educational_qualifications || membership.specialty,
|
|
91
|
-
phoneNumber: contacts.phone,
|
|
92
|
-
email: contacts.email,
|
|
93
|
-
licenseStartDate: mostRecentLicense?.license_start || '',
|
|
94
|
-
licenseEndDate: mostRecentLicense?.license_end || '',
|
|
95
|
-
isActive: membership.is_active === 1,
|
|
96
|
-
providerUniqueIdentifier: membership.id,
|
|
97
|
-
status: membership.status,
|
|
98
|
-
professionalCadre: professional_details?.professional_cadre,
|
|
99
|
-
practiceType: professional_details?.practice_type,
|
|
100
|
-
licenses: licenses,
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Type guard to check if response is FHIR format
|
|
106
|
-
*/
|
|
107
|
-
static isFHIRFormat(response: any): response is PractitionerResponse {
|
|
108
|
-
return response.resourceType === 'Bundle' || (response.entry && Array.isArray(response.entry));
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Normalized practitioner data structure
|
|
114
|
-
*/
|
|
115
|
-
export interface NormalizedPractitioner {
|
|
116
|
-
id: string;
|
|
117
|
-
fullName: string;
|
|
118
|
-
firstName: string;
|
|
119
|
-
middleName: string;
|
|
120
|
-
lastName: string;
|
|
121
|
-
gender: string;
|
|
122
|
-
registrationId: string;
|
|
123
|
-
externalReferenceId: string;
|
|
124
|
-
nationalId: string;
|
|
125
|
-
passportNumber: string;
|
|
126
|
-
licenseNumber: string;
|
|
127
|
-
licensingBody: string;
|
|
128
|
-
specialty: string;
|
|
129
|
-
qualification: string;
|
|
130
|
-
phoneNumber: string;
|
|
131
|
-
email: string;
|
|
132
|
-
licenseStartDate: string;
|
|
133
|
-
licenseEndDate: string;
|
|
134
|
-
isActive: boolean;
|
|
135
|
-
providerUniqueIdentifier: string;
|
|
136
|
-
status: string;
|
|
137
|
-
professionalCadre?: string;
|
|
138
|
-
practiceType?: string;
|
|
139
|
-
licenses?: Array<{
|
|
140
|
-
id: string;
|
|
141
|
-
external_reference_id: string;
|
|
142
|
-
license_type: string;
|
|
143
|
-
license_start: string;
|
|
144
|
-
license_end: string;
|
|
145
|
-
}>;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Search for health care worker with automatic format detection
|
|
150
|
-
*/
|
|
151
|
-
export const searchHealthCareWork = async (
|
|
152
|
-
identifierType: string,
|
|
153
|
-
identifierNumber: string,
|
|
154
|
-
regulator: string,
|
|
155
|
-
): Promise<UnifiedHealthWorkerResponse> => {
|
|
156
|
-
const url = `${restBaseUrl}/kenyaemr/practitionersearch?identifierType=${identifierType}&identifierNumber=${identifierNumber}®ulator=${regulator}`;
|
|
157
|
-
|
|
158
|
-
const response = await fetch(makeUrl(url));
|
|
159
|
-
|
|
160
|
-
if (!response.ok) {
|
|
161
|
-
if (response.status === 401) {
|
|
162
|
-
throw new Error(HWR_API_NO_CREDENTIALS);
|
|
163
|
-
} else if (response.status === 404) {
|
|
164
|
-
throw new Error(RESOURCE_NOT_FOUND);
|
|
165
|
-
}
|
|
166
|
-
throw new Error(UNKNOWN);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
const responseData = await response.json();
|
|
170
|
-
|
|
171
|
-
// Check for error in response
|
|
172
|
-
if (responseData?.issue) {
|
|
173
|
-
throw new Error(PROVIDER_NOT_FOUND);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// Determine format based on fhirFormat flag or structure
|
|
177
|
-
const isFhir = responseData.fhirFormat === true || HealthWorkerAdapter.isFHIRFormat(responseData);
|
|
178
|
-
|
|
179
|
-
return {
|
|
180
|
-
fhirFormat: isFhir,
|
|
181
|
-
data: responseData,
|
|
182
|
-
};
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Hook for searching health care worker with normalized data
|
|
187
|
-
*/
|
|
188
|
-
export const useHealthWorkerSearch = () => {
|
|
189
|
-
const [isSearching, setIsSearching] = useState(false);
|
|
190
|
-
const [error, setError] = useState<string | null>(null);
|
|
191
|
-
|
|
192
|
-
const search = async (
|
|
193
|
-
identifierType: string,
|
|
194
|
-
identifierNumber: string,
|
|
195
|
-
regulator: string,
|
|
196
|
-
): Promise<NormalizedPractitioner | null> => {
|
|
197
|
-
try {
|
|
198
|
-
setIsSearching(true);
|
|
199
|
-
setError(null);
|
|
200
|
-
|
|
201
|
-
const response = await searchHealthCareWork(identifierType, identifierNumber, regulator);
|
|
202
|
-
return HealthWorkerAdapter.normalize(response);
|
|
203
|
-
} catch (err) {
|
|
204
|
-
const errorMessage = err instanceof Error ? err.message : UNKNOWN;
|
|
205
|
-
setError(errorMessage);
|
|
206
|
-
return null;
|
|
207
|
-
} finally {
|
|
208
|
-
setIsSearching(false);
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
return { search, isSearching, error };
|
|
213
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { FetchResponse, openmrsFetch, restBaseUrl, useSession } from '@openmrs/esm-framework';
|
|
2
|
-
import useSWR from 'swr';
|
|
3
|
-
import { DefaultFacility, SHAFacility } from '../../types';
|
|
4
|
-
|
|
5
|
-
export function useShaFacilityInfo(shouldSynchronize: boolean = false) {
|
|
6
|
-
const { authenticated } = useSession();
|
|
7
|
-
const url = `${restBaseUrl}/kenyaemr/sha-facility-status?synchronize=${shouldSynchronize}`;
|
|
8
|
-
|
|
9
|
-
const { data, isLoading, error, mutate } = useSWR<FetchResponse<SHAFacility>>(
|
|
10
|
-
authenticated ? url : null,
|
|
11
|
-
openmrsFetch,
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
isLoading,
|
|
16
|
-
shaFacility: data?.data,
|
|
17
|
-
error,
|
|
18
|
-
mutate,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const useLocalFacilityInfo = () => {
|
|
23
|
-
const url = `${restBaseUrl}/kenyaemr/default-facility`;
|
|
24
|
-
const { authenticated } = useSession();
|
|
25
|
-
|
|
26
|
-
const { data, isLoading, error, mutate } = useSWR<FetchResponse<DefaultFacility>>(
|
|
27
|
-
authenticated ? url : null,
|
|
28
|
-
openmrsFetch,
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
isLoading,
|
|
33
|
-
localFacility: data?.data,
|
|
34
|
-
error,
|
|
35
|
-
mutate,
|
|
36
|
-
};
|
|
37
|
-
};
|