@ampath/esm-patient-registration-app 6.0.1-pre.225 → 6.0.1-pre.229

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/routes.json CHANGED
@@ -1 +1 @@
1
- {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":"^2.24.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},{"component":"cancelPatientEditModal","name":"cancel-patient-edit-modal","online":true,"offline":true},{"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":"deleteIdentifierConfirmationModal","name":"delete-identifier-confirmation-modal","online":true,"offline":true},{"component":"emptyClientRegistryModal","name":"empty-client-registry-modal","online":true,"offline":true},{"component":"confirmClientRegistryModal","name":"confirm-client-registry-modal","online":true,"offline":true}],"version":"6.0.1-pre.225"}
1
+ {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":"^2.24.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},{"component":"cancelPatientEditModal","name":"cancel-patient-edit-modal","online":true,"offline":true},{"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":"deleteIdentifierConfirmationModal","name":"delete-identifier-confirmation-modal","online":true,"offline":true},{"component":"emptyClientRegistryModal","name":"empty-client-registry-modal","online":true,"offline":true},{"component":"confirmClientRegistryModal","name":"confirm-client-registry-modal","online":true,"offline":true}],"version":"6.0.1-pre.229"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ampath/esm-patient-registration-app",
3
- "version": "6.0.1-pre.225",
3
+ "version": "6.0.1-pre.229",
4
4
  "description": "Patient registration microfrontend for the OpenMRS SPA",
5
5
  "browser": "dist/ampath-esm-patient-registration-app.js",
6
6
  "main": "src/index.ts",
@@ -170,7 +170,7 @@ async function postToRegistry(
170
170
  }
171
171
 
172
172
  export const useFacilityName = (facilityCode) => {
173
- const apiUrl = `/ws/rest/v1/amrscore/facilityName?facilityCode=${facilityCode}`;
173
+ const apiUrl = `/ws/rest/v1/amrs/facilityName?facilityCode=${facilityCode}`;
174
174
  const { data, error, isLoading } = useSWRImmutable<FetchResponse>(apiUrl, openmrsFetch);
175
175
 
176
176
  return {
@@ -0,0 +1,236 @@
1
+ [
2
+ {
3
+ "name": "Mombasa",
4
+ "code": 1,
5
+ "capital": "Mombasa City"
6
+ },
7
+ {
8
+ "name": "Kwale",
9
+ "code": 2,
10
+ "capital": "Kwale"
11
+ },
12
+ {
13
+ "name": "Kilifi",
14
+ "code": 3,
15
+ "capital": "Kilifi"
16
+ },
17
+ {
18
+ "name": "Tana River",
19
+ "code": 4,
20
+ "capital": "Hola"
21
+ },
22
+ {
23
+ "name": "Lamu",
24
+ "code": 5,
25
+ "capital": "Lamu"
26
+ },
27
+ {
28
+ "name": "Taita taveta",
29
+ "code": 6,
30
+ "capital": "Voi"
31
+ },
32
+ {
33
+ "name": "Garissa",
34
+ "code": 7,
35
+ "capital": "Garissa"
36
+ },
37
+ {
38
+ "name": "Wajir",
39
+ "code": 8,
40
+ "capital": "Wajir"
41
+ },
42
+ {
43
+ "name": "Mandera",
44
+ "code": 9,
45
+ "capital": "Mandera"
46
+ },
47
+ {
48
+ "name": "Marsabit",
49
+ "code": 10,
50
+ "capital": "Marsabit"
51
+ },
52
+ {
53
+ "name": "Isiolo",
54
+ "code": 11,
55
+ "capital": "Isiolo"
56
+ },
57
+ {
58
+ "name": "Meru",
59
+ "code": 12,
60
+ "capital": "Meru"
61
+ },
62
+ {
63
+ "name": "Tharaka nithi",
64
+ "code": 13,
65
+ "capital": "Chuka"
66
+ },
67
+ {
68
+ "name": "Embu",
69
+ "code": 14,
70
+ "capital": "Embu"
71
+ },
72
+ {
73
+ "name": "Kitui",
74
+ "code": 15,
75
+ "capital": "Kitui"
76
+ },
77
+ {
78
+ "name": "Machakos",
79
+ "code": 16,
80
+ "capital": "Machakos"
81
+ },
82
+ {
83
+ "name": "Makueni",
84
+ "code": 17,
85
+ "capital": "Wote"
86
+ },
87
+ {
88
+ "name": "Nyandarua",
89
+ "code": 18,
90
+ "capital": "Ol Kalou"
91
+ },
92
+ {
93
+ "name": "Nyeri",
94
+ "code": 19,
95
+ "capital": "Nyeri"
96
+ },
97
+ {
98
+ "name": "Kirinyaga",
99
+ "code": 20,
100
+ "capital": "Kerugoya/Kutus"
101
+ },
102
+ {
103
+ "name": "Murang'a",
104
+ "code": 21,
105
+ "capital": "Murang'a"
106
+ },
107
+ {
108
+ "name": "Kiambu",
109
+ "code": 22,
110
+ "capital": "Kiambu"
111
+ },
112
+ {
113
+ "name": "Turkana",
114
+ "code": 23,
115
+ "capital": "Lodwar"
116
+ },
117
+ {
118
+ "name": "West pokot",
119
+ "code": 24,
120
+ "capital": "Kapenguria"
121
+ },
122
+ {
123
+ "name": "Samburu",
124
+ "code": 25,
125
+ "capital": "Maralal"
126
+ },
127
+ {
128
+ "name": "Trans nzoia",
129
+ "code": 26,
130
+ "capital": "Kitale"
131
+ },
132
+ {
133
+ "name": "Uasin gishu",
134
+ "code": 27,
135
+ "capital": "Eldoret"
136
+ },
137
+ {
138
+ "name": "Elgeyo marakwet",
139
+ "code": 28,
140
+ "capital": "Iten"
141
+ },
142
+ {
143
+ "name": "Nandi",
144
+ "code": 29,
145
+ "capital": "Kapsabet"
146
+ },
147
+ {
148
+ "name": "Baringo",
149
+ "code": 30,
150
+ "capital": "Kabarnet"
151
+ },
152
+ {
153
+ "name": "Laikipia",
154
+ "code": 31,
155
+ "capital": "Rumuruti"
156
+ },
157
+ {
158
+ "name": "Nakuru",
159
+ "code": 32,
160
+ "capital": "Nakuru"
161
+ },
162
+ {
163
+ "name": "Narok",
164
+ "code": 33,
165
+ "capital": "Narok"
166
+ },
167
+ {
168
+ "name": "Kajiado",
169
+ "code": 34
170
+ },
171
+ {
172
+ "name": "Kericho",
173
+ "code": 35,
174
+ "capital": "Kericho"
175
+ },
176
+ {
177
+ "name": "Bomet",
178
+ "code": 36,
179
+ "capital": "Bomet"
180
+ },
181
+ {
182
+ "name": "Kakamega",
183
+ "code": 37,
184
+ "capital": "Kakamega"
185
+ },
186
+ {
187
+ "name": "Vihiga",
188
+ "code": 38,
189
+ "capital": "Vihiga"
190
+ },
191
+ {
192
+ "name": "Bungoma",
193
+ "code": 39,
194
+ "capital": "Bungoma"
195
+ },
196
+ {
197
+ "name": "Busia",
198
+ "code": 40,
199
+ "capital": "Busia"
200
+ },
201
+ {
202
+ "name": "Siaya",
203
+ "code": 41,
204
+ "capital": "Siaya"
205
+ },
206
+ {
207
+ "name": "Kisumu",
208
+ "code": 42,
209
+ "capital": "Kisumu"
210
+ },
211
+ {
212
+ "name": "Homa bay",
213
+ "code": 43,
214
+ "capital": "Homa Bay"
215
+ },
216
+ {
217
+ "name": "Migori",
218
+ "code": 44,
219
+ "capital": "Migori"
220
+ },
221
+ {
222
+ "name": "Kisii",
223
+ "code": 45,
224
+ "capital": "Kisii"
225
+ },
226
+ {
227
+ "name": "Nyamira",
228
+ "code": 46,
229
+ "capital": "Nyamira"
230
+ },
231
+ {
232
+ "name": "Nairobi",
233
+ "code": 47,
234
+ "capital": "Nairobi City"
235
+ }
236
+ ]
@@ -0,0 +1,11 @@
1
+ export const countries = [
2
+ { name: 'Kenya', initials: 'KE' },
3
+ { name: 'Uganda', initials: 'UG' },
4
+ { name: 'Tanzania', initials: 'TZ' },
5
+ ];
6
+
7
+ export const verificationIdentifierTypes = [
8
+ { name: 'National ID', value: 'national-id' },
9
+ { name: 'Passport', value: 'passport' },
10
+ { name: 'Birth certificate number', value: 'birth-certificate' },
11
+ ];
@@ -0,0 +1,181 @@
1
+ import { type FetchResponse, openmrsFetch, showNotification, showToast, showSnackbar } from '@openmrs/esm-framework';
2
+ import { generateNUPIPayload, handleClientRegistryResponse } from './patient-verification-utils';
3
+ import useSWR from 'swr';
4
+ import useSWRImmutable from 'swr/immutable';
5
+ import {
6
+ type ConceptAnswers,
7
+ type ConceptResponse,
8
+ type FormValues,
9
+ } from '../patient-registration/patient-registration.types';
10
+
11
+ export function searchClientRegistry(
12
+ identifierType: string,
13
+ searchTerm: string,
14
+ token: string,
15
+ countryCode: string = 'KE',
16
+ ) {
17
+ const url = `https://afyakenyaapi.health.go.ke/partners/registry/search/${countryCode}/${identifierType}/${searchTerm}`;
18
+ return fetch(url, { headers: { Authorization: `Bearer ${token}` } }).then((r) => r.json());
19
+ }
20
+
21
+ export function savePatientToClientRegistry(formValues: FormValues) {
22
+ const createdRegistryPatient = generateNUPIPayload(formValues);
23
+ return fetch(`https://afyakenyaapi.health.go.ke/partners/registry`, {
24
+ headers: { Authorization: `Bearer ${formValues.token}`, 'Content-Type': 'application/json' },
25
+ method: 'POST',
26
+ body: JSON.stringify(createdRegistryPatient),
27
+ });
28
+ }
29
+
30
+ export async function handleSavePatientToClientRegistry(
31
+ formValues: FormValues,
32
+ setValues: (values: FormValues, shouldValidate?: boolean) => void,
33
+ inEditMode: boolean,
34
+ ) {
35
+ const mode = inEditMode ? 'edit' : 'new';
36
+ switch (mode) {
37
+ case 'edit': {
38
+ try {
39
+ const searchResponse = await searchClientRegistry(
40
+ 'national-id',
41
+ formValues.identifiers['nationalId'].identifierValue,
42
+ formValues.token,
43
+ );
44
+
45
+ // if client does not exists post client to registry
46
+ if (searchResponse?.clientExists === false) {
47
+ postToRegistry(formValues, setValues);
48
+ }
49
+ } catch (error) {
50
+ showSnackbar({
51
+ title: 'Client registry error',
52
+ subtitle: `${error}`,
53
+ timeoutInMs: 10000,
54
+ kind: 'error',
55
+ isLowContrast: true,
56
+ });
57
+ }
58
+ return;
59
+ }
60
+ case 'new': {
61
+ postToRegistry(formValues, setValues);
62
+ }
63
+ }
64
+ }
65
+
66
+ export function useConceptAnswers(conceptUuid: string): { data: Array<ConceptAnswers>; isLoading: boolean } {
67
+ const { data, error, isLoading } = useSWR<FetchResponse<ConceptResponse>, Error>(
68
+ `/ws/rest/v1/concept/${conceptUuid}`,
69
+ openmrsFetch,
70
+ );
71
+ if (error) {
72
+ showToast({
73
+ title: error.name,
74
+ description: error.message,
75
+ kind: 'error',
76
+ });
77
+ }
78
+ return { data: data?.data?.answers ?? [], isLoading };
79
+ }
80
+
81
+ const urlencoded = new URLSearchParams();
82
+ // urlencoded.append('client_id', 'palladium.partner.client');
83
+ // urlencoded.append('client_secret', '28f95b2a');
84
+ // urlencoded.append('grant_type', 'client_credentials');
85
+ // urlencoded.append('scope', 'DHP.Gateway DHP.Partners');
86
+
87
+ urlencoded.append('client_id', 'ampath.partner.client');
88
+ urlencoded.append('client_secret', '3ae8a7f6');
89
+ urlencoded.append('grant_type', 'client_credentials');
90
+ urlencoded.append('scope', 'DHP.Gateway DHP.Partners');
91
+
92
+ const swrFetcher = async (url) => {
93
+ const res = await fetch(url, {
94
+ method: 'POST',
95
+ body: urlencoded,
96
+ redirect: 'follow',
97
+ });
98
+
99
+ // If the status code is not in the range 200-299,
100
+ // we still try to parse and throw it.
101
+ if (!res.ok) {
102
+ const error = new Error('An error occurred while fetching the data.') as any;
103
+ // Attach extra info to the error object.
104
+ error.info = await res.json();
105
+ error.status = res.status;
106
+ throw error;
107
+ }
108
+
109
+ return res.json();
110
+ };
111
+
112
+ export function useGlobalProperties() {
113
+ const { data, isLoading, error } = useSWRImmutable(
114
+ `https://afyakenyaidentityapi.health.go.ke/connect/token`,
115
+ swrFetcher,
116
+ { refreshInterval: 864000 },
117
+ );
118
+ return { data: data, isLoading, error };
119
+ }
120
+
121
+ async function postToRegistry(
122
+ formValues: FormValues,
123
+ setValues: (values: FormValues, shouldValidate?: boolean) => void,
124
+ ) {
125
+ try {
126
+ const clientRegistryResponse = await savePatientToClientRegistry(formValues);
127
+ if (clientRegistryResponse.ok) {
128
+ const savedValues = await clientRegistryResponse.json();
129
+ const nupiIdentifier = {
130
+ ['nationalUniquePatientIdentifier']: {
131
+ identifierTypeUuid: 'cba702b9-4664-4b43-83f1-9ab473cbd64d',
132
+ identifierName: 'National Unique Patient Identifier (NUPI)',
133
+ identifierValue: savedValues['clientNumber'],
134
+ initialValue: savedValues['clientNumber'],
135
+ identifierUuid: undefined,
136
+ selectedSource: { uuid: '', name: '' },
137
+ preferred: false,
138
+ required: false,
139
+ },
140
+ };
141
+ setValues({ ...formValues, identifiers: { ...formValues.identifiers, ...nupiIdentifier } });
142
+ showToast({
143
+ title: 'Posted patient to client registry successfully',
144
+ description: `The patient has been saved to client registry`,
145
+ kind: 'success',
146
+ });
147
+ } else {
148
+ const responseError = await clientRegistryResponse.json();
149
+ const errorMessage = Object.values(responseError.errors ?? {})
150
+ .map((error: any) => error.join())
151
+ .toString();
152
+ setValues({
153
+ ...formValues,
154
+ attributes: {
155
+ ...formValues.attributes,
156
+ ['5553d509-f03a-4982-8e16-0d6f3d70fb8b']: 'Failed validation',
157
+ ['d8f4d295-3f31-47ec-b377-825bd38820b2']: 'Failed',
158
+ },
159
+ });
160
+ showNotification({
161
+ title: responseError.title,
162
+ description: errorMessage,
163
+ kind: 'warning',
164
+ millis: 150000,
165
+ });
166
+ }
167
+ } catch (error) {
168
+ showNotification({ kind: 'error', title: 'NUPI Post failed', description: JSON.stringify(error) });
169
+ }
170
+ }
171
+
172
+ export const useFacilityName = (facilityCode) => {
173
+ const apiUrl = `/ws/rest/v1/amrs/facilityName?facilityCode=${facilityCode}`;
174
+ const { data, error, isLoading } = useSWRImmutable<FetchResponse>(apiUrl, openmrsFetch);
175
+
176
+ return {
177
+ facilityName: data ? data?.data : null,
178
+ isLoading: isLoading,
179
+ isError: error,
180
+ };
181
+ };
@@ -0,0 +1,179 @@
1
+ import { showModal } from '@openmrs/esm-framework';
2
+ import { type FormikProps } from 'formik';
3
+ import { type ClientRegistryPatient, type RegistryPatient } from './verification-types';
4
+ import counties from './assets/counties.json';
5
+ import { type FormValues } from '../patient-registration/patient-registration.types';
6
+ import { capitalize } from 'lodash-es';
7
+
8
+ export function handleClientRegistryResponse(
9
+ clientResponse: ClientRegistryPatient,
10
+ props: FormikProps<FormValues>,
11
+ searchTerm: string,
12
+ ) {
13
+ if (clientResponse?.clientExists === false) {
14
+ const nupiIdentifiers = {
15
+ ['nationalId']: {
16
+ initialValue: searchTerm,
17
+ identifierUuid: undefined,
18
+ selectedSource: { uuid: '', name: '' },
19
+ preferred: false,
20
+ required: false,
21
+ identifierTypeUuid: '58a47054-1359-11df-a1f1-0026b9348838',
22
+ identifierName: 'Kenyan National ID Number',
23
+ identifierValue: searchTerm,
24
+ },
25
+ };
26
+ const dispose = showModal('empty-client-registry-modal', {
27
+ onConfirm: () => {
28
+ props.setValues({ ...props.values, identifiers: { ...props.values.identifiers, ...nupiIdentifiers } });
29
+ dispose();
30
+ },
31
+ close: () => dispose(),
32
+ });
33
+ }
34
+
35
+ if (clientResponse?.clientExists) {
36
+ const {
37
+ client: {
38
+ middleName,
39
+ lastName,
40
+ firstName,
41
+ contact,
42
+ country,
43
+ countyOfBirth,
44
+ residence,
45
+ identifications,
46
+ gender,
47
+ dateOfBirth,
48
+ isAlive,
49
+ clientNumber,
50
+ educationLevel,
51
+ occupation,
52
+ maritalStatus,
53
+ },
54
+ } = clientResponse;
55
+
56
+ const nupiIdentifiers = {
57
+ ['nationalId']: {
58
+ initialValue: identifications !== undefined && identifications[0]?.identificationNumber,
59
+ identifierUuid: undefined,
60
+ selectedSource: { uuid: '', name: '' },
61
+ preferred: false,
62
+ required: false,
63
+ identifierTypeUuid: '58a47054-1359-11df-a1f1-0026b9348838',
64
+ identifierName: 'Kenyan National ID Number',
65
+ identifierValue: identifications !== undefined && identifications[0]?.identificationNumber,
66
+ },
67
+
68
+ ['nationalUniquePatientIdentifier']: {
69
+ identifierTypeUuid: 'cba702b9-4664-4b43-83f1-9ab473cbd64d',
70
+ identifierName: 'National Unique Patient Identifier (NUPI)',
71
+ identifierValue: clientNumber,
72
+ initialValue: clientNumber,
73
+ identifierUuid: undefined,
74
+ selectedSource: { uuid: '', name: '' },
75
+ preferred: false,
76
+ required: false,
77
+ },
78
+ };
79
+
80
+ const dispose = showModal('confirm-client-registry-modal', {
81
+ onConfirm: () => {
82
+ props.setValues({
83
+ ...props.values,
84
+ familyName: lastName,
85
+ middleName: middleName,
86
+ givenName: firstName,
87
+ gender: clientResponse.client.gender,
88
+ birthdate: new Date(dateOfBirth),
89
+ isDead: !isAlive,
90
+ attributes: {
91
+ '72a759a8-1359-11df-a1f1-0026b9348838': contact?.primaryPhone,
92
+ 'b0a08406-09c0-4f8b-8cb5-b22b6d4a8e46': contact?.secondaryPhone,
93
+ '2f65dbcb-3e58-45a3-8be7-fd1dc9aa0faa': contact?.emailAddress ?? '',
94
+ },
95
+ address: {
96
+ address1: residence?.address,
97
+ address2: '',
98
+ address4: capitalize(residence?.ward ?? ''),
99
+ cityVillage: residence?.village,
100
+ stateProvince: capitalize(residence?.subCounty ?? ''),
101
+ countyDistrict: counties.find((county) => county.code === parseInt(residence?.county))?.name,
102
+ country: 'Kenya',
103
+ postalCode: residence?.address,
104
+ },
105
+ identifiers: { ...props.values.identifiers, ...nupiIdentifiers },
106
+ obs: {
107
+ 'a899a9f2-1350-11df-a1f1-0026b9348838':
108
+ props.values.concepts.find((concept) =>
109
+ concept.display?.toLowerCase()?.includes(clientResponse.client.maritalStatus?.toLowerCase()),
110
+ )?.uuid ?? '',
111
+ 'a89e48ae-1350-11df-a1f1-0026b9348838':
112
+ props.values.concepts.find((concept) =>
113
+ concept.display?.toLowerCase()?.includes(clientResponse.client.educationLevel?.toLowerCase()),
114
+ )?.uuid ?? '',
115
+ 'a8a0a00e-1350-11df-a1f1-0026b9348838':
116
+ clientResponse.client.occupation === undefined || clientResponse.client.occupation === null
117
+ ? 'a899e0ac-1350-11df-a1f1-0026b9348838'
118
+ : props.values.concepts.find(
119
+ (concept) => concept.display?.toLowerCase() === clientResponse.client.occupation?.toLowerCase(),
120
+ )?.uuid ?? 'a8aaf3e2-1350-11df-a1f1-0026b9348838',
121
+ },
122
+ });
123
+ dispose();
124
+ },
125
+ close: () => dispose(),
126
+ patient: clientResponse.client,
127
+ });
128
+ }
129
+ }
130
+
131
+ export function generateNUPIPayload(formValues: FormValues): RegistryPatient {
132
+ const educationLevel = formValues.concepts.find(
133
+ (concept) => concept.uuid === formValues.obs['a89e48ae-1350-11df-a1f1-0026b9348838'],
134
+ );
135
+ const occupation = formValues.concepts.find(
136
+ (concept) => concept.uuid === formValues.obs['a8a0a00e-1350-11df-a1f1-0026b9348838'],
137
+ );
138
+ const maritalStatus = formValues.concepts.find(
139
+ (concept) => concept.uuid === formValues.obs['a899a9f2-1350-11df-a1f1-0026b9348838'],
140
+ );
141
+
142
+ let createRegistryPatient: RegistryPatient = {
143
+ firstName: formValues?.givenName,
144
+ middleName: formValues?.middleName,
145
+ lastName: formValues?.familyName,
146
+ gender: formValues?.gender === 'Male' ? 'male' : 'female',
147
+ dateOfBirth: new Date(formValues.birthdate).toISOString(),
148
+ isAlive: !formValues.isDead,
149
+ residence: {
150
+ county: `0${counties.find((county) => county.name.includes(formValues.address['countyDistrict']))?.code}`,
151
+ subCounty: formValues.address['stateProvince']?.toLocaleLowerCase(),
152
+ ward: formValues.address['address4']?.toLocaleLowerCase(),
153
+ village: formValues.address['cityVillage'],
154
+ landmark: formValues.address['address2'],
155
+ address: formValues.address['postalCode'],
156
+ },
157
+ nextOfKins: [],
158
+ contact: {
159
+ primaryPhone: formValues.attributes['72a759a8-1359-11df-a1f1-0026b9348838'],
160
+ secondaryPhone: formValues.attributes['b0a08406-09c0-4f8b-8cb5-b22b6d4a8e46'],
161
+ emailAddress: formValues.attributes['2f65dbcb-3e58-45a3-8be7-fd1dc9aa0faa'],
162
+ },
163
+ country: 'KE',
164
+ countyOfBirth: `0${counties.find((county) => county.name.includes(formValues.address['countyDistrict']))?.code}`,
165
+ educationLevel: educationLevel?.display?.toLowerCase() ?? '',
166
+ religion: '',
167
+ occupation: occupation?.display?.toLowerCase() ?? '',
168
+ maritalStatus: maritalStatus?.display?.toLowerCase() ?? '',
169
+ originFacilityKmflCode: '',
170
+ nascopCCCNumber: '',
171
+ identifications: [
172
+ {
173
+ identificationType: 'national-id',
174
+ identificationNumber: formValues.identifiers['nationalId']?.identifierValue,
175
+ },
176
+ ],
177
+ };
178
+ return createRegistryPatient;
179
+ }