@integraciones_doc24/sdk 1.14.4 → 1.15.0
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/README.md +7 -3
- package/lib/baseSdk/diagnostica.d.ts +11 -11
- package/lib/baseSdk/diagnostica.js +20 -18
- package/lib/baseSdk/external.d.ts +0 -29
- package/lib/baseSdk/external.js +0 -57
- package/lib/baseSdk/index.js +3 -0
- package/lib/baseSdk/user.d.ts +56 -6
- package/lib/baseSdk/user.js +70 -25
- package/lib/index.d.ts +230 -25
- package/lib/schemas.d.ts +738 -56
- package/lib/schemas.js +149 -37
- package/lib/test.js +7 -15
- package/lib/types.d.ts +34 -7
- package/lib/userSdk/chat.d.ts +2 -2
- package/lib/userSdk/external.d.ts +32 -0
- package/lib/userSdk/external.js +69 -0
- package/lib/userSdk/index.js +3 -0
- package/lib/userSdk/patients.d.ts +28 -14
- package/lib/userSdk/patients.js +31 -12
- package/lib/userSdk/schedule.d.ts +4 -2
- package/lib/userSdk/schedule.js +20 -16
- package/lib/userSdk/videoVisit.d.ts +4 -2
- package/lib/userSdk/videoVisit.js +11 -4
- package/lib/utils.d.ts +2 -4
- package/lib/utils.js +11 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -110,11 +110,13 @@ export type BaseSdk = {
|
|
|
110
110
|
params: VerifyExternalVerificationCodeParams,
|
|
111
111
|
) => Promise<any>;
|
|
112
112
|
externalResetPassword: (params: ExternalResetPasswordParams) => Promise<any>;
|
|
113
|
-
getExternalStudiesHistoryLink: (
|
|
113
|
+
getExternalStudiesHistoryLink: (
|
|
114
|
+
patient: ExternalPatient,
|
|
115
|
+
) => Promise<string | null>;
|
|
114
116
|
getExternalAppointmentsLink: (
|
|
115
117
|
identificationValue: string,
|
|
116
118
|
birthdate: Date,
|
|
117
|
-
) => Promise<string>;
|
|
119
|
+
) => Promise<string | null>;
|
|
118
120
|
getExternalAppointments: () => Promise<ExternalAppointment[]>;
|
|
119
121
|
cancelExternalAppointment: (
|
|
120
122
|
appointmentId: ExternalAppointment,
|
|
@@ -181,7 +183,9 @@ export type UserSdk = {
|
|
|
181
183
|
vcToken: string,
|
|
182
184
|
patientId: number,
|
|
183
185
|
) => Promise<string | null>;
|
|
184
|
-
getPatientVideoVisitHistory: (
|
|
186
|
+
getPatientVideoVisitHistory: (
|
|
187
|
+
patientId: number,
|
|
188
|
+
) => Promise<HistoricalVideoVisit[]>;
|
|
185
189
|
getActiveVideoVisits: () => Promise<ActiveVideoVisitData[]>;
|
|
186
190
|
getAvailableChatrooms: (
|
|
187
191
|
patientId: number,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RequestMaker } from '../request';
|
|
2
2
|
export declare const getDiagnosticaMethods: (makeRequest: RequestMaker) => {
|
|
3
3
|
getDiagnosticaHistory: (patient: {
|
|
4
|
-
identificationType: "
|
|
4
|
+
identificationType: "DNI";
|
|
5
5
|
identificationValue: string;
|
|
6
6
|
gender: "m" | "f";
|
|
7
7
|
}, from: Date, to: Date) => Promise<{
|
|
@@ -11,22 +11,22 @@ export declare const getDiagnosticaMethods: (makeRequest: RequestMaker) => {
|
|
|
11
11
|
deepLink: string;
|
|
12
12
|
}[]>;
|
|
13
13
|
getDiagnosticaDeepLink: (kiosk: string, user: {
|
|
14
|
-
language: string;
|
|
15
14
|
firstName: string;
|
|
16
15
|
lastName: string;
|
|
17
|
-
|
|
18
|
-
identificationType: "dni";
|
|
16
|
+
identificationType: "DNI";
|
|
19
17
|
identificationValue: string;
|
|
20
18
|
gender: "m" | "f";
|
|
21
19
|
phone: string;
|
|
22
20
|
email: string;
|
|
21
|
+
language: string;
|
|
22
|
+
birthday: Date;
|
|
23
23
|
}, patient: {
|
|
24
24
|
firstName: string;
|
|
25
25
|
lastName: string;
|
|
26
|
-
|
|
27
|
-
identificationType: "dni";
|
|
26
|
+
identificationType: "DNI";
|
|
28
27
|
identificationValue: string;
|
|
29
28
|
gender: "m" | "f";
|
|
29
|
+
birthday: Date;
|
|
30
30
|
}) => Promise<{
|
|
31
31
|
forwardingRequired: true;
|
|
32
32
|
deepLink: string;
|
|
@@ -34,21 +34,21 @@ export declare const getDiagnosticaMethods: (makeRequest: RequestMaker) => {
|
|
|
34
34
|
forwardingRequired: false;
|
|
35
35
|
}>;
|
|
36
36
|
getDiagnosticaAccess: (kiosk: string, user: {
|
|
37
|
-
language: string;
|
|
38
37
|
firstName: string;
|
|
39
38
|
lastName: string;
|
|
40
|
-
|
|
41
|
-
identificationType: "dni";
|
|
39
|
+
identificationType: "DNI";
|
|
42
40
|
identificationValue: string;
|
|
43
41
|
gender: "m" | "f";
|
|
44
42
|
phone: string;
|
|
45
43
|
email: string;
|
|
44
|
+
language: string;
|
|
45
|
+
birthday: Date;
|
|
46
46
|
}, patient: {
|
|
47
47
|
firstName: string;
|
|
48
48
|
lastName: string;
|
|
49
|
-
|
|
50
|
-
identificationType: "dni";
|
|
49
|
+
identificationType: "DNI";
|
|
51
50
|
identificationValue: string;
|
|
52
51
|
gender: "m" | "f";
|
|
52
|
+
birthday: Date;
|
|
53
53
|
}) => Promise<void>;
|
|
54
54
|
};
|
|
@@ -6,14 +6,12 @@ const zod_1 = require("zod");
|
|
|
6
6
|
const validation_1 = require("../request/validation");
|
|
7
7
|
const schemas_1 = require("../schemas");
|
|
8
8
|
const getDiagnosticaMethods = (makeRequest) => {
|
|
9
|
-
const getDiagnosticaHistory =
|
|
9
|
+
const getDiagnosticaHistory = async (patient, from, to) => {
|
|
10
10
|
const path = '/history-diagnostica';
|
|
11
11
|
const response = await makeRequest('POST', path, {
|
|
12
12
|
patient: {
|
|
13
13
|
gender: patient.gender,
|
|
14
|
-
id_type: patient.identificationType
|
|
15
|
-
? 'DNI'
|
|
16
|
-
: patient.identificationType,
|
|
14
|
+
id_type: patient.identificationType,
|
|
17
15
|
id_value: patient.identificationValue,
|
|
18
16
|
},
|
|
19
17
|
dateFrom: from.toISOString(),
|
|
@@ -26,12 +24,8 @@ const getDiagnosticaMethods = (makeRequest) => {
|
|
|
26
24
|
exams: i.exams,
|
|
27
25
|
deepLink: i.deeplink,
|
|
28
26
|
}));
|
|
29
|
-
}
|
|
30
|
-
const getDiagnosticaDeepLink =
|
|
31
|
-
zod_1.string(),
|
|
32
|
-
schemas_1.doc24Schemas.diagnosticaUser,
|
|
33
|
-
schemas_1.doc24Schemas.diagnosticaPatient,
|
|
34
|
-
]), schemas_1.doc24Schemas.diagnosticaDeepLinkResponse, async (kiosk, user, patient) => {
|
|
27
|
+
};
|
|
28
|
+
const getDiagnosticaDeepLink = async (kiosk, user, patient) => {
|
|
35
29
|
const path = '/deeplink-diagnostica';
|
|
36
30
|
const response = await makeRequest('POST', path, {
|
|
37
31
|
kiosk,
|
|
@@ -42,12 +36,8 @@ const getDiagnosticaMethods = (makeRequest) => {
|
|
|
42
36
|
if (data.forwarding_required)
|
|
43
37
|
return { forwardingRequired: true, deepLink: data.deeplink };
|
|
44
38
|
return { forwardingRequired: false };
|
|
45
|
-
}
|
|
46
|
-
const getDiagnosticaAccess =
|
|
47
|
-
zod_1.string(),
|
|
48
|
-
schemas_1.doc24Schemas.diagnosticaUser,
|
|
49
|
-
schemas_1.doc24Schemas.diagnosticaPatient,
|
|
50
|
-
]), zod_1.void(), async (kiosk, user, patient) => {
|
|
39
|
+
};
|
|
40
|
+
const getDiagnosticaAccess = async (kiosk, user, patient) => {
|
|
51
41
|
const path = '/access-diagnostica';
|
|
52
42
|
await makeRequest('POST', path, {
|
|
53
43
|
kiosk,
|
|
@@ -55,8 +45,20 @@ const getDiagnosticaMethods = (makeRequest) => {
|
|
|
55
45
|
patient: mapPatientData(patient),
|
|
56
46
|
});
|
|
57
47
|
return;
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
getDiagnosticaHistory: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.diagnosticaPatientFilter, zod_1.date(), zod_1.date()]), schemas_1.doc24Schemas.diagnosticaHistoryAppointment.array(), getDiagnosticaHistory),
|
|
51
|
+
getDiagnosticaDeepLink: validation_1.validateFunction(zod_1.tuple([
|
|
52
|
+
zod_1.string(),
|
|
53
|
+
schemas_1.doc24Schemas.diagnosticaUser,
|
|
54
|
+
schemas_1.doc24Schemas.diagnosticaPatient,
|
|
55
|
+
]), schemas_1.doc24Schemas.diagnosticaDeepLinkResponse, getDiagnosticaDeepLink),
|
|
56
|
+
getDiagnosticaAccess: validation_1.validateFunction(zod_1.tuple([
|
|
57
|
+
zod_1.string(),
|
|
58
|
+
schemas_1.doc24Schemas.diagnosticaUser,
|
|
59
|
+
schemas_1.doc24Schemas.diagnosticaPatient,
|
|
60
|
+
]), zod_1.void(), getDiagnosticaAccess),
|
|
61
|
+
};
|
|
60
62
|
};
|
|
61
63
|
exports.getDiagnosticaMethods = getDiagnosticaMethods;
|
|
62
64
|
const mapPatientData = (patient) => {
|
|
@@ -174,33 +174,4 @@ export declare const getExternalMethods: (makeRequest: RequestMaker) => {
|
|
|
174
174
|
emailCode?: undefined;
|
|
175
175
|
phoneCode: string;
|
|
176
176
|
})) => Promise<any>;
|
|
177
|
-
getExternalStudiesHistoryLink: (patient: {
|
|
178
|
-
identificationType: "DNI";
|
|
179
|
-
identificationValue: string;
|
|
180
|
-
birthdate: Date;
|
|
181
|
-
gender: "m" | "f";
|
|
182
|
-
}) => Promise<string | null>;
|
|
183
|
-
getExternalAppointmentsLink: (identificationValue: string, birthdate: Date) => Promise<string | null>;
|
|
184
|
-
getExternalAppointments: () => Promise<{
|
|
185
|
-
date: Date;
|
|
186
|
-
birthdate: Date;
|
|
187
|
-
appointment: string;
|
|
188
|
-
id: number;
|
|
189
|
-
specialty: string;
|
|
190
|
-
patientName: string;
|
|
191
|
-
clinic: string;
|
|
192
|
-
professionalName: string;
|
|
193
|
-
modality: string;
|
|
194
|
-
}[]>;
|
|
195
|
-
cancelExternalAppointment: (appointmentId: {
|
|
196
|
-
date: Date;
|
|
197
|
-
birthdate: Date;
|
|
198
|
-
appointment: string;
|
|
199
|
-
id: number;
|
|
200
|
-
specialty: string;
|
|
201
|
-
patientName: string;
|
|
202
|
-
clinic: string;
|
|
203
|
-
professionalName: string;
|
|
204
|
-
modality: string;
|
|
205
|
-
}) => Promise<void>;
|
|
206
177
|
};
|
package/lib/baseSdk/external.js
CHANGED
|
@@ -5,7 +5,6 @@ const date_fns_1 = require("date-fns");
|
|
|
5
5
|
const zod_1 = require("zod");
|
|
6
6
|
const validation_1 = require("../request/validation");
|
|
7
7
|
const schemas_1 = require("../schemas");
|
|
8
|
-
const utils_1 = require("../utils");
|
|
9
8
|
const getExternalMethods = (makeRequest) => {
|
|
10
9
|
const externalLogin = async ({ user, password, }) => {
|
|
11
10
|
const path = '/external-login';
|
|
@@ -85,50 +84,6 @@ const getExternalMethods = (makeRequest) => {
|
|
|
85
84
|
});
|
|
86
85
|
return response.data;
|
|
87
86
|
};
|
|
88
|
-
const getExternalStudiesHistoryLink = async (patient) => {
|
|
89
|
-
var _a, _b;
|
|
90
|
-
const path = '/history-external-studies';
|
|
91
|
-
const response = await makeRequest('POST', path, {
|
|
92
|
-
patient: mapPatientData(patient),
|
|
93
|
-
});
|
|
94
|
-
return (_b = (_a = response.data.info) === null || _a === void 0 ? void 0 : _a.link) !== null && _b !== void 0 ? _b : null;
|
|
95
|
-
};
|
|
96
|
-
const getExternalAppointmentsLink = async (identificationValue, birthdate) => {
|
|
97
|
-
const path = `/external-appointments-link/${identificationValue}/${date_fns_1.format(birthdate, 'yyyy-MM-dd')}`;
|
|
98
|
-
const response = await makeRequest('GET', path);
|
|
99
|
-
return response.data.link;
|
|
100
|
-
};
|
|
101
|
-
const getExternalAppointments = async () => {
|
|
102
|
-
const path = '/external-appointments';
|
|
103
|
-
const response = await makeRequest('GET', path);
|
|
104
|
-
return response.data.appointments.map((a) => ({
|
|
105
|
-
id: a.appointment_id,
|
|
106
|
-
patientName: a.patient_name,
|
|
107
|
-
birthdate: utils_1.parseDate(a.birthdate),
|
|
108
|
-
appointment: a.appointment,
|
|
109
|
-
clinic: a.clinic,
|
|
110
|
-
professionalName: a.professional,
|
|
111
|
-
date: utils_1.parseDateTime(`${a.day} ${a.hour}:00`),
|
|
112
|
-
specialty: a.specialty,
|
|
113
|
-
modality: a.modality,
|
|
114
|
-
}));
|
|
115
|
-
};
|
|
116
|
-
const cancelExternalAppointment = async (appointment) => {
|
|
117
|
-
const path = `/cancel-external-appointment`;
|
|
118
|
-
await makeRequest('POST', path, {
|
|
119
|
-
appointment_id: appointment.id,
|
|
120
|
-
patient_name: appointment.patientName,
|
|
121
|
-
birthdate: date_fns_1.format(appointment.birthdate, 'yyyy-MM-dd'),
|
|
122
|
-
appointment: appointment.appointment,
|
|
123
|
-
clinic: appointment.clinic,
|
|
124
|
-
professional: appointment.professionalName,
|
|
125
|
-
day: date_fns_1.format(appointment.date, 'yyyy-MM-dd'),
|
|
126
|
-
hour: date_fns_1.format(appointment.date, 'HH:mm'),
|
|
127
|
-
specialty: appointment.specialty,
|
|
128
|
-
modality: appointment.modality,
|
|
129
|
-
});
|
|
130
|
-
return;
|
|
131
|
-
};
|
|
132
87
|
return {
|
|
133
88
|
externalLogin: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalLoginParams]), schemas_1.doc24Schemas.externalLoginResponse, externalLogin),
|
|
134
89
|
preExternalEnrollment: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.preExternalEnrollmentParams]), zod_1.void(), preExternalEnrollment),
|
|
@@ -136,18 +91,6 @@ const getExternalMethods = (makeRequest) => {
|
|
|
136
91
|
sendExternalVerificationCode: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.sendExternalVerificationCodeParams]), zod_1.void(), sendExternalVerificationCode),
|
|
137
92
|
verifyExternalVerificationCode: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.verifyExternalVerificationCodeParams]), zod_1.any(), verifyExternalVerificationCode),
|
|
138
93
|
externalResetPassword: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalResetPasswordParams]), zod_1.any(), externalResetPassword),
|
|
139
|
-
getExternalStudiesHistoryLink: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalPatient]), zod_1.string().nullable(), getExternalStudiesHistoryLink),
|
|
140
|
-
getExternalAppointmentsLink: validation_1.validateFunction(zod_1.tuple([zod_1.string(), zod_1.date()]), zod_1.string().nullable(), getExternalAppointmentsLink),
|
|
141
|
-
getExternalAppointments: validation_1.validateFunction(zod_1.tuple([]), zod_1.array(schemas_1.doc24Schemas.externalAppointment), getExternalAppointments),
|
|
142
|
-
cancelExternalAppointment: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalAppointment]), zod_1.void(), cancelExternalAppointment),
|
|
143
94
|
};
|
|
144
95
|
};
|
|
145
96
|
exports.getExternalMethods = getExternalMethods;
|
|
146
|
-
const mapPatientData = (patient) => {
|
|
147
|
-
return {
|
|
148
|
-
birthdate: date_fns_1.format(patient.birthdate, 'yyyy-MM-dd'),
|
|
149
|
-
id_type: 'dni',
|
|
150
|
-
id_value: patient.identificationValue,
|
|
151
|
-
gender: patient.gender.toLocaleUpperCase(),
|
|
152
|
-
};
|
|
153
|
-
};
|
package/lib/baseSdk/index.js
CHANGED
|
@@ -8,12 +8,15 @@ const schemas_1 = require("../schemas");
|
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
9
|
const diagnostica_1 = require("./diagnostica");
|
|
10
10
|
const user_1 = require("./user");
|
|
11
|
+
const external_1 = require("./external");
|
|
11
12
|
const getBaseSdk = async (url, credentials) => {
|
|
12
13
|
const makeRequest = await request_1.getRequestFactory(url, credentials);
|
|
13
14
|
const diagnosticaMethods = diagnostica_1.getDiagnosticaMethods(makeRequest);
|
|
15
|
+
const externalMethods = external_1.getExternalMethods(makeRequest);
|
|
14
16
|
const userMethods = user_1.getUserMethods(makeRequest, url, credentials);
|
|
15
17
|
const baseSdk = {
|
|
16
18
|
...diagnosticaMethods,
|
|
19
|
+
...externalMethods,
|
|
17
20
|
...userMethods,
|
|
18
21
|
getProfessional: validation_1.validateFunction(zod_1.tuple([zod_1.number()]), schemas_1.doc24Schemas.professional, async (professionalId) => {
|
|
19
22
|
const path = `/professional/${professionalId}`;
|
package/lib/baseSdk/user.d.ts
CHANGED
|
@@ -1,25 +1,75 @@
|
|
|
1
1
|
import { RequestMaker } from '../request';
|
|
2
2
|
import { Doc24 } from '../types';
|
|
3
3
|
export declare const getUserMethods: (makeRequest: RequestMaker, url: string, credentials: Doc24.SdkCredentials) => {
|
|
4
|
-
declareUser: (
|
|
4
|
+
declareUser: (params: {
|
|
5
|
+
user: {
|
|
6
|
+
firstName: string;
|
|
7
|
+
lastName: string;
|
|
8
|
+
identificationType: number;
|
|
9
|
+
identificationValue: string;
|
|
10
|
+
countryId: string;
|
|
11
|
+
birthdate: Date;
|
|
12
|
+
gender: "m" | "f";
|
|
13
|
+
phone: string;
|
|
14
|
+
email: string;
|
|
15
|
+
};
|
|
16
|
+
} & {
|
|
17
|
+
code?: string | undefined;
|
|
18
|
+
channel?: "1" | "2" | undefined;
|
|
19
|
+
}) => Promise<{
|
|
20
|
+
askCode: true;
|
|
21
|
+
userInfo: {
|
|
22
|
+
phone: string;
|
|
23
|
+
email: string;
|
|
24
|
+
};
|
|
25
|
+
} | {
|
|
26
|
+
patientId: number | null;
|
|
27
|
+
askCode: false;
|
|
28
|
+
userId: number;
|
|
29
|
+
}>;
|
|
30
|
+
getUserId: (user: {
|
|
5
31
|
firstName: string;
|
|
6
32
|
lastName: string;
|
|
7
|
-
identificationType:
|
|
33
|
+
identificationType: number;
|
|
8
34
|
identificationValue: string;
|
|
35
|
+
countryId: string;
|
|
36
|
+
birthdate: Date;
|
|
9
37
|
gender: "m" | "f";
|
|
10
38
|
phone: string;
|
|
11
39
|
email: string;
|
|
40
|
+
}) => Promise<number>;
|
|
41
|
+
sendVerificationCode: (params: {
|
|
42
|
+
identificationType: number;
|
|
43
|
+
identificationValue: string;
|
|
44
|
+
channel: "1" | "2";
|
|
45
|
+
}) => Promise<void>;
|
|
46
|
+
getUserInstance: (user: number | {
|
|
47
|
+
firstName: string;
|
|
48
|
+
lastName: string;
|
|
49
|
+
identificationType: number;
|
|
50
|
+
identificationValue: string;
|
|
12
51
|
countryId: string;
|
|
13
52
|
birthdate: Date;
|
|
53
|
+
gender: "m" | "f";
|
|
54
|
+
phone: string;
|
|
55
|
+
email: string;
|
|
14
56
|
}) => Promise<any>;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
57
|
+
enroll: (params: {
|
|
58
|
+
firstName: string;
|
|
59
|
+
lastName: string;
|
|
60
|
+
birthdate: Date;
|
|
61
|
+
gender: "m" | "f";
|
|
62
|
+
email: string;
|
|
63
|
+
identificationNumber: string;
|
|
64
|
+
startDate: Date;
|
|
65
|
+
plan: string;
|
|
66
|
+
}) => Promise<void>;
|
|
67
|
+
getCoverageInfo: (identificationValue: string) => Promise<{
|
|
18
68
|
firstName: string | null;
|
|
19
69
|
lastName: string | null;
|
|
70
|
+
birthdate: Date;
|
|
20
71
|
gender: "m" | "f";
|
|
21
72
|
email: string | null;
|
|
22
|
-
birthdate: Date;
|
|
23
73
|
identificationNumber: string;
|
|
24
74
|
plan: string | null;
|
|
25
75
|
financerId: number | null;
|
package/lib/baseSdk/user.js
CHANGED
|
@@ -8,11 +8,40 @@ const schemas_1 = require("../schemas");
|
|
|
8
8
|
const userSdk_1 = require("../userSdk");
|
|
9
9
|
const utils_1 = require("../utils");
|
|
10
10
|
const getUserMethods = (makeRequest, url, credentials) => {
|
|
11
|
+
const declareUser = async ({ user, channel, code, }) => {
|
|
12
|
+
const path = '/user';
|
|
13
|
+
const mappedUser = {
|
|
14
|
+
lastname: user.lastName,
|
|
15
|
+
firstname: user.firstName,
|
|
16
|
+
identification_type: user.identificationType,
|
|
17
|
+
identification_value: user.identificationValue,
|
|
18
|
+
birthdate: date_fns_1.format(user.birthdate, 'yyyy-MM-dd'),
|
|
19
|
+
gender: user.gender.toUpperCase(),
|
|
20
|
+
phone: user.phone,
|
|
21
|
+
email: user.email,
|
|
22
|
+
country_id: user.countryId,
|
|
23
|
+
};
|
|
24
|
+
const parsedChannel = channel ? parseInt(channel) : channel;
|
|
25
|
+
const response = await makeRequest('POST', path, {
|
|
26
|
+
user_data: mappedUser,
|
|
27
|
+
channel: parsedChannel,
|
|
28
|
+
code,
|
|
29
|
+
});
|
|
30
|
+
const data = response.data;
|
|
31
|
+
if (data.ask_code)
|
|
32
|
+
return { askCode: true, userInfo: data.user_info };
|
|
33
|
+
return {
|
|
34
|
+
askCode: false,
|
|
35
|
+
userId: response.data.user_id,
|
|
36
|
+
patientId: response.data.patient_id,
|
|
37
|
+
};
|
|
38
|
+
};
|
|
11
39
|
const getUserId = async (user) => {
|
|
40
|
+
const path = '/search-user';
|
|
12
41
|
const mappedUser = {
|
|
13
42
|
lastname: user.lastName,
|
|
14
43
|
firstname: user.firstName,
|
|
15
|
-
identification_type:
|
|
44
|
+
identification_type: user.identificationType,
|
|
16
45
|
identification_value: user.identificationValue,
|
|
17
46
|
birthdate: date_fns_1.format(user.birthdate, 'yyyy-MM-dd'),
|
|
18
47
|
gender: user.gender.toUpperCase(),
|
|
@@ -20,15 +49,46 @@ const getUserMethods = (makeRequest, url, credentials) => {
|
|
|
20
49
|
email: user.email,
|
|
21
50
|
country_id: user.countryId,
|
|
22
51
|
};
|
|
23
|
-
const response = await makeRequest('POST',
|
|
52
|
+
const response = await makeRequest('POST', path, {
|
|
24
53
|
user_data: mappedUser,
|
|
25
54
|
});
|
|
26
55
|
return response.data.user_id;
|
|
27
56
|
};
|
|
28
|
-
const
|
|
57
|
+
const sendVerificationCode = async (params) => {
|
|
58
|
+
const path = '/send-verification-code';
|
|
59
|
+
const mappedParams = {
|
|
60
|
+
identification_type: params.identificationType,
|
|
61
|
+
identification_value: params.identificationValue,
|
|
62
|
+
channel: parseInt(params.channel),
|
|
63
|
+
};
|
|
64
|
+
await makeRequest('POST', path, mappedParams);
|
|
65
|
+
};
|
|
66
|
+
const getUserInstance = async (user) => {
|
|
67
|
+
const userId = typeof user === 'number' ? user : await getUserId(user);
|
|
68
|
+
return userSdk_1.userSdk(url, credentials, userId);
|
|
69
|
+
};
|
|
70
|
+
const enroll = async (params) => {
|
|
71
|
+
const path = `/enrollment`;
|
|
72
|
+
const mappedUser = {
|
|
73
|
+
firstname: params.firstName,
|
|
74
|
+
lastname: params.lastName,
|
|
75
|
+
gender: params.gender.toUpperCase(),
|
|
76
|
+
identification_number: params.identificationNumber,
|
|
77
|
+
birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
|
|
78
|
+
email: params.email,
|
|
79
|
+
plan: params.plan,
|
|
80
|
+
start_date: date_fns_1.format(params.startDate, 'yyyy-MM-dd'),
|
|
81
|
+
};
|
|
82
|
+
await makeRequest('POST', path, {
|
|
83
|
+
user_data: mappedUser,
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
const getCoverageInfo = async (identificationValue) => {
|
|
29
87
|
const path = `/info-coverage/${identificationValue}`;
|
|
30
88
|
const response = await makeRequest('GET', path);
|
|
31
89
|
const raw = response.data.info;
|
|
90
|
+
if (!raw)
|
|
91
|
+
return null;
|
|
32
92
|
const mappedCoverageInfo = {
|
|
33
93
|
financerId: raw.id_financiador,
|
|
34
94
|
defaultAffiliationId: raw.id_afiliacion_default,
|
|
@@ -58,31 +118,16 @@ const getUserMethods = (makeRequest, url, credentials) => {
|
|
|
58
118
|
: null,
|
|
59
119
|
};
|
|
60
120
|
return mappedCoverageInfo;
|
|
61
|
-
}
|
|
121
|
+
};
|
|
62
122
|
return {
|
|
63
|
-
declareUser: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.
|
|
123
|
+
declareUser: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.declareUserParams]), schemas_1.doc24Schemas.declareUserResponse, declareUser),
|
|
124
|
+
getUserId: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.user]), zod_1.number(), getUserId),
|
|
125
|
+
sendVerificationCode: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.sendVerificationCodeParams]), zod_1.void(), sendVerificationCode),
|
|
64
126
|
getUserInstance: validation_1.validateFunction(zod_1.tuple([zod_1.union([schemas_1.doc24Schemas.user, zod_1.number()])]),
|
|
65
127
|
// TODO: validate?
|
|
66
|
-
zod_1.any(),
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}),
|
|
70
|
-
enroll: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.enrollmentParams]), zod_1.void(), async (params) => {
|
|
71
|
-
const path = `/enrollment`;
|
|
72
|
-
await makeRequest('POST', path, {
|
|
73
|
-
user_data: {
|
|
74
|
-
firstname: params.firstName,
|
|
75
|
-
lastname: params.lastName,
|
|
76
|
-
gender: params.gender.toUpperCase(),
|
|
77
|
-
identification_number: params.identificationNumber,
|
|
78
|
-
birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
|
|
79
|
-
email: params.email,
|
|
80
|
-
plan: params.plan,
|
|
81
|
-
start_date: date_fns_1.format(params.startDate, 'yyyy-MM-dd'),
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
}),
|
|
85
|
-
getConverageInfo,
|
|
128
|
+
zod_1.any(), getUserInstance),
|
|
129
|
+
enroll: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.enrollmentParams]), zod_1.void(), enroll),
|
|
130
|
+
getCoverageInfo: validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.coverageInfo, getCoverageInfo),
|
|
86
131
|
};
|
|
87
132
|
};
|
|
88
133
|
exports.getUserMethods = getUserMethods;
|