@ampath/esm-dha-workflow-app 4.0.0-next.4 → 4.0.0-next.5

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.
Files changed (39) hide show
  1. package/dist/109.js +2 -0
  2. package/dist/{731.js.LICENSE.txt → 109.js.LICENSE.txt} +3 -3
  3. package/dist/109.js.map +1 -0
  4. package/dist/161.js +1 -0
  5. package/dist/161.js.map +1 -0
  6. package/dist/32.js +2 -0
  7. package/dist/32.js.map +1 -0
  8. package/dist/324.js +2 -0
  9. package/dist/324.js.LICENSE.txt +9 -0
  10. package/dist/324.js.map +1 -0
  11. package/dist/70.js +1 -1
  12. package/dist/91.js +1 -1
  13. package/dist/91.js.map +1 -1
  14. package/dist/main.js +1 -1
  15. package/dist/main.js.map +1 -1
  16. package/dist/openmrs-esm-home-app.js +1 -1
  17. package/dist/openmrs-esm-home-app.js.buildmanifest.json +114 -87
  18. package/dist/openmrs-esm-home-app.js.map +1 -1
  19. package/dist/routes.json +1 -1
  20. package/package.json +1 -1
  21. package/src/registry/client-details/client-details.tsx +40 -0
  22. package/src/registry/modal/client-details-modal/client-details-modal.scss +28 -0
  23. package/src/registry/modal/client-details-modal/client-details-modal.tsx +72 -0
  24. package/src/registry/modal/otp-verification-modal/otp-verification-modal.scss +6 -0
  25. package/src/registry/modal/otp-verification-modal/otp-verification-modal.tsx +172 -0
  26. package/src/registry/payment-details/payment-options/payment-options.tsx +21 -0
  27. package/src/registry/registry.component.scss +58 -0
  28. package/src/registry/registry.component.tsx +240 -2
  29. package/src/registry/registry.resource.ts +58 -0
  30. package/src/registry/types/index.ts +160 -0
  31. package/src/registry/utils/hie-adapter.ts +56 -0
  32. package/src/registry/utils/mask-data.ts +21 -0
  33. package/dist/561.js +0 -2
  34. package/dist/561.js.map +0 -1
  35. package/dist/731.js +0 -2
  36. package/dist/731.js.map +0 -1
  37. package/dist/819.js +0 -1
  38. package/dist/819.js.map +0 -1
  39. /package/dist/{561.js.LICENSE.txt → 32.js.LICENSE.txt} +0 -0
@@ -0,0 +1,58 @@
1
+ import {
2
+ type ClientRegistrySearchRequest,
3
+ type RequestCustomOtpDto,
4
+ type RequestCustomOtpResponse,
5
+ type ValidateCustomOtpResponse,
6
+ type ValidateHieCustomOtpDto,
7
+ } from './types';
8
+
9
+ const HIE_BASE_URL = 'https://staging.ampath.or.ke/hie';
10
+
11
+ export type ClientRegistrySearchResponse = any[];
12
+
13
+ async function postJson<T>(url: string, payload: unknown): Promise<T> {
14
+ const response = await fetch(url, {
15
+ method: 'POST',
16
+ headers: { 'Content-Type': 'application/json' },
17
+ body: JSON.stringify(payload),
18
+ });
19
+
20
+ if (!response.ok) {
21
+ const errorText = await response.text();
22
+ throw new Error(`Request failed with ${response.status}: ${errorText}`);
23
+ }
24
+
25
+ return response.json() as Promise<T>;
26
+ }
27
+
28
+ export async function requestCustomOtp(payload: RequestCustomOtpDto): Promise<RequestCustomOtpResponse> {
29
+ const url = `${HIE_BASE_URL}/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 url = `${HIE_BASE_URL}/client/validate-custom-otp`;
40
+ const formattedPayload = {
41
+ sessionId: payload.sessionId,
42
+ otp: payload.otp,
43
+ locationUuid: payload.locationUuid,
44
+ };
45
+ return postJson<ValidateCustomOtpResponse>(url, formattedPayload);
46
+ }
47
+
48
+ export async function fetchClientRegistryData(
49
+ payload: ClientRegistrySearchRequest,
50
+ ): Promise<ClientRegistrySearchResponse> {
51
+ const url = `${HIE_BASE_URL}/client/search`;
52
+ const formattedPayload = {
53
+ identificationNumber: payload.identificationNumber,
54
+ identificationType: payload.identificationType,
55
+ locationUuid: payload.locationUuid,
56
+ };
57
+ return postJson<ClientRegistrySearchResponse>(url, formattedPayload);
58
+ }
@@ -0,0 +1,160 @@
1
+ export type IdentifierType = 'National ID' | 'Alien ID' | 'Passport' | 'Mandate Number' | 'Refugee ID';
2
+
3
+ export const IDENTIFIER_TYPES: IdentifierType[] = [
4
+ 'National ID',
5
+ 'Alien ID',
6
+ 'Passport',
7
+ 'Mandate Number',
8
+ 'Refugee ID',
9
+ ];
10
+
11
+ export interface ValidateCustomOtpResponse {
12
+ message: string;
13
+ isValid?: boolean;
14
+ }
15
+
16
+ export type ClientRegistrySearchRequest = {
17
+ identificationNumber: string | number;
18
+ identificationType: string;
19
+ locationUuid: string;
20
+ };
21
+
22
+ export interface RequestCustomOtpResponse {
23
+ message: string;
24
+ sessionId: string;
25
+ maskedPhone: string;
26
+ }
27
+
28
+ export interface ValidateHieCustomOtpDto {
29
+ sessionId: string;
30
+ otp: number | string;
31
+ locationUuid: string;
32
+ }
33
+
34
+ export interface ValidateCustomOtpResponse {
35
+ message: string;
36
+ isValid?: boolean;
37
+ }
38
+
39
+ export type RequestCustomOtpDto = {
40
+ identificationNumber: string | number;
41
+ identificationType: string;
42
+ locationUuid: string;
43
+ };
44
+
45
+ export interface RequestCustomOtpResponse {
46
+ message: string;
47
+ sessionId: string;
48
+ maskedPhone: string;
49
+ }
50
+
51
+ export interface ValidateHieCustomOtpDto {
52
+ sessionId: string;
53
+ otp: number | string;
54
+ locationUuid: string;
55
+ }
56
+
57
+ export enum HieIdentificationType {
58
+ NationalID = 'National ID',
59
+ SHANumber = 'SHA Number',
60
+ HouseholdNumber = 'Household Number',
61
+ RefugeeID = 'Refugee ID',
62
+ AlienID = 'Alien ID',
63
+ MandateNumber = 'Mandate Number',
64
+ Cr = 'id',
65
+ TemporaryDependantID = 'Temporary Dependant ID',
66
+ }
67
+
68
+ export interface HieIdentifications {
69
+ identification_number: string;
70
+ identification_type: HieIdentificationType;
71
+ }
72
+
73
+ export interface HieDependant {
74
+ date_added: string;
75
+ relationship: string;
76
+ total: number;
77
+ result: HieClient[];
78
+ }
79
+
80
+ export interface AlternateContact {
81
+ contact_type: string;
82
+ contact_id: string;
83
+ contact_name: string;
84
+ relationship: string;
85
+ remarks: string;
86
+ }
87
+
88
+ export interface HieClient {
89
+ resourceType: string;
90
+ id: string;
91
+ meta: {
92
+ versionId: string;
93
+ creationTime: string;
94
+ lastUpdated: string;
95
+ source: string;
96
+ };
97
+ originSystem: {
98
+ system: string;
99
+ record_id: string;
100
+ };
101
+ title: string;
102
+ first_name: string;
103
+ middle_name: string;
104
+ last_name: string;
105
+ gender: string;
106
+ date_of_birth: string;
107
+ place_of_birth: string;
108
+ person_with_disability: number;
109
+ citizenship: string;
110
+ kra_pin: string;
111
+ preferred_primary_care_network: string;
112
+ employment_type: string;
113
+ domestic_worker_type: string;
114
+ civil_status: string;
115
+ identification_type: HieIdentificationType;
116
+ identification_number: string;
117
+ other_identifications: HieIdentifications[];
118
+ dependants: HieDependant[];
119
+ is_alive: number;
120
+ deceased_datetime: string;
121
+ phone: string;
122
+ biometrics_verified: number;
123
+ biometrics_score: number;
124
+ email: string;
125
+ country: string;
126
+ county: string;
127
+ sub_county: string;
128
+ ward: string;
129
+ village_estate: string;
130
+ building_house_no: string;
131
+ latitude: string;
132
+ longitude: string;
133
+ province_state_country: string;
134
+ zip_code: string;
135
+ identification_residence: string;
136
+ employer_name: string;
137
+ employer_pin: string;
138
+ disability_category: string;
139
+ disability_subcategory: string;
140
+ disability_cause: string;
141
+ in_lawful_custody: string;
142
+ admission_remand_number: string;
143
+ document_uploads: any[];
144
+ alternative_contacts: AlternateContact[];
145
+ gross_income: number;
146
+ gross_income_currency: string;
147
+ postal_address: string;
148
+ estimated_contribution: number;
149
+ estimated_annual_contribution: number;
150
+ city: string;
151
+ id_serial: string;
152
+ learning_institution_code: string;
153
+ learning_institution_name: string;
154
+ grade_level: string;
155
+ admission_number: string;
156
+ expected_year_of_graduation: string;
157
+ unconfirmed_dependants: HieDependant[];
158
+ is_agent: number;
159
+ agent_id: string;
160
+ }
@@ -0,0 +1,56 @@
1
+ import { type HieIdentifications, type HieClient } from '../types';
2
+
3
+ const clientDatailsFields = [
4
+ 'id',
5
+ 'other_identifications',
6
+ 'first_name',
7
+ 'middle_name',
8
+ 'last_name',
9
+ 'gender',
10
+ 'date_of_birth',
11
+ 'is_alive',
12
+ 'deceased_datetime',
13
+ 'phone',
14
+ 'email',
15
+ 'civil_status',
16
+ 'place_of_birth',
17
+ 'citizenship',
18
+ 'country',
19
+ 'county',
20
+ 'sub_county',
21
+ 'ward',
22
+ 'village_estate',
23
+ 'longitude',
24
+ 'latitude',
25
+ 'identification_type',
26
+ ];
27
+
28
+ export function generateHieClientDetails(hieClient: HieClient) {
29
+ let data = {};
30
+ Object.keys(hieClient)
31
+ .filter((key) => {
32
+ return clientDatailsFields.includes(key);
33
+ })
34
+ .forEach((key) => {
35
+ if (key === 'other_identifications') {
36
+ const otherIds = generateOtherIdentifications(hieClient[key]);
37
+ data = {
38
+ ...data,
39
+ ...otherIds,
40
+ };
41
+ } else if (key === 'identification_type') {
42
+ data[hieClient['identification_type']] = hieClient.identification_number;
43
+ } else {
44
+ const value = hieClient[key];
45
+ data[key] = value;
46
+ }
47
+ });
48
+ return data;
49
+ }
50
+ function generateOtherIdentifications(hieIdentifications: HieIdentifications[]) {
51
+ const other = {};
52
+ hieIdentifications.forEach((id) => {
53
+ other[id.identification_type] = id.identification_number;
54
+ });
55
+ return other;
56
+ }
@@ -0,0 +1,21 @@
1
+ export const maskValue = (value: string): string => {
2
+ let arrValue = value.split('');
3
+ for (let i = 0; i < value.length; i++) {
4
+ if (i % 2 === 0) {
5
+ arrValue[i] = '*';
6
+ }
7
+ }
8
+ const maskedValue = arrValue.join('');
9
+ return maskedValue;
10
+ };
11
+
12
+ export const maskExceptFirstAndLast = (value: string): string => {
13
+ let arrValue = value.split('');
14
+ for (let i = 0; i < value.length; i++) {
15
+ if (!(i == 0 || i === value.length - 1)) {
16
+ arrValue[i] = '*';
17
+ }
18
+ }
19
+ const maskedValue = arrValue.join('');
20
+ return maskedValue;
21
+ };