@integraciones_doc24/sdk 0.35.0 → 0.35.1
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/lib/baseSdk/index.js +5 -1
- package/lib/lib/baseSdk/index.d.ts +57 -10
- package/lib/lib/baseSdk/user.d.ts +16 -5
- package/lib/lib/baseSdk/user.js +67 -25
- package/lib/lib/index.d.ts +44 -16
- package/lib/lib/lib/baseSdk/diagnostica.d.ts +6 -0
- package/lib/lib/lib/baseSdk/diagnostica.js +79 -0
- package/lib/lib/lib/baseSdk/index.d.ts +51 -0
- package/lib/lib/lib/baseSdk/index.js +66 -0
- package/lib/lib/lib/baseSdk/user.d.ts +9 -0
- package/lib/lib/lib/baseSdk/user.js +130 -0
- package/lib/lib/lib/index.d.ts +168 -0
- package/lib/lib/lib/index.js +22 -0
- package/lib/lib/lib/lib/baseSdk/diagnostica.d.ts +6 -0
- package/lib/lib/lib/lib/baseSdk/diagnostica.js +79 -0
- package/lib/lib/lib/lib/baseSdk/index.d.ts +14 -0
- package/lib/lib/lib/lib/baseSdk/index.js +66 -0
- package/lib/lib/lib/lib/baseSdk/user.d.ts +9 -0
- package/lib/lib/lib/lib/baseSdk/user.js +130 -0
- package/lib/lib/lib/lib/index.d.ts +58 -0
- package/lib/lib/lib/lib/index.js +22 -0
- package/lib/lib/lib/lib/request/index.d.ts +2 -0
- package/lib/lib/lib/lib/request/index.js +26 -0
- package/lib/lib/lib/lib/request/token.d.ts +2 -0
- package/lib/lib/lib/lib/request/token.js +34 -0
- package/lib/lib/lib/lib/request/validation.d.ts +10 -0
- package/lib/lib/lib/lib/request/validation.js +28 -0
- package/lib/lib/lib/lib/schemas.d.ts +1334 -0
- package/lib/lib/lib/lib/schemas.js +325 -0
- package/lib/lib/lib/lib/test.d.ts +1 -0
- package/lib/lib/lib/lib/test.js +55 -0
- package/lib/lib/lib/lib/types.d.ts +1 -0
- package/lib/lib/lib/lib/types.js +2 -0
- package/lib/lib/lib/lib/userSdk/chat.d.ts +9 -0
- package/lib/lib/lib/lib/userSdk/chat.js +98 -0
- package/lib/lib/lib/lib/userSdk/index.d.ts +24 -0
- package/lib/lib/lib/lib/userSdk/index.js +27 -0
- package/lib/lib/lib/lib/userSdk/patients.d.ts +5 -0
- package/lib/lib/lib/lib/userSdk/patients.js +55 -0
- package/lib/lib/lib/lib/userSdk/schedule.d.ts +7 -0
- package/lib/lib/lib/lib/userSdk/schedule.js +76 -0
- package/lib/lib/lib/lib/userSdk/specialties.d.ts +4 -0
- package/lib/lib/lib/lib/userSdk/specialties.js +19 -0
- package/lib/lib/lib/lib/userSdk/videoVisit.d.ts +10 -0
- package/lib/lib/lib/lib/userSdk/videoVisit.js +147 -0
- package/lib/lib/lib/lib/utils.d.ts +4 -0
- package/lib/lib/lib/lib/utils.js +19 -0
- package/lib/lib/lib/lib/webhook/index.d.ts +8 -0
- package/lib/lib/lib/lib/webhook/index.js +55 -0
- package/lib/lib/lib/lib/webhook/responses.d.ts +36 -0
- package/lib/lib/lib/lib/webhook/responses.js +42 -0
- package/lib/lib/lib/lib/webhook/token.d.ts +2 -0
- package/lib/lib/lib/lib/webhook/token.js +23 -0
- package/lib/lib/lib/request/index.d.ts +2 -0
- package/lib/lib/lib/request/index.js +26 -0
- package/lib/lib/lib/request/token.d.ts +2 -0
- package/lib/lib/lib/request/token.js +34 -0
- package/lib/lib/lib/request/validation.d.ts +10 -0
- package/lib/lib/lib/request/validation.js +28 -0
- package/lib/lib/lib/schemas.d.ts +1334 -0
- package/lib/lib/lib/schemas.js +325 -0
- package/lib/lib/lib/src/baseSdk/diagnostica.d.ts +6 -0
- package/lib/lib/lib/src/baseSdk/diagnostica.js +79 -0
- package/lib/lib/lib/src/baseSdk/index.d.ts +51 -0
- package/lib/lib/lib/src/baseSdk/index.js +66 -0
- package/lib/lib/lib/src/baseSdk/user.d.ts +9 -0
- package/lib/lib/lib/src/baseSdk/user.js +130 -0
- package/lib/lib/lib/src/index.d.ts +169 -0
- package/lib/lib/lib/src/index.js +22 -0
- package/lib/lib/lib/src/request/index.d.ts +2 -0
- package/lib/lib/lib/src/request/index.js +26 -0
- package/lib/lib/lib/src/request/token.d.ts +2 -0
- package/lib/lib/lib/src/request/token.js +34 -0
- package/lib/lib/lib/src/request/validation.d.ts +10 -0
- package/lib/lib/lib/src/request/validation.js +28 -0
- package/lib/lib/lib/src/schemas.d.ts +1340 -0
- package/lib/lib/lib/src/schemas.js +325 -0
- package/lib/lib/lib/src/types.d.ts +1 -0
- package/lib/lib/lib/src/types.js +2 -0
- package/lib/lib/lib/src/userSdk/chat.d.ts +9 -0
- package/lib/lib/lib/src/userSdk/chat.js +98 -0
- package/lib/lib/lib/src/userSdk/index.d.ts +102 -0
- package/lib/lib/lib/src/userSdk/index.js +27 -0
- package/lib/lib/lib/src/userSdk/patients.d.ts +5 -0
- package/lib/lib/lib/src/userSdk/patients.js +55 -0
- package/lib/lib/lib/src/userSdk/schedule.d.ts +7 -0
- package/lib/lib/lib/src/userSdk/schedule.js +76 -0
- package/lib/lib/lib/src/userSdk/specialties.d.ts +4 -0
- package/lib/lib/lib/src/userSdk/specialties.js +19 -0
- package/lib/lib/lib/src/userSdk/videoVisit.d.ts +10 -0
- package/lib/lib/lib/src/userSdk/videoVisit.js +147 -0
- package/lib/lib/lib/src/utils.d.ts +4 -0
- package/lib/lib/lib/src/utils.js +19 -0
- package/lib/lib/lib/src/webhook/index.d.ts +8 -0
- package/lib/lib/lib/src/webhook/index.js +55 -0
- package/lib/lib/lib/src/webhook/responses.d.ts +36 -0
- package/lib/lib/lib/src/webhook/responses.js +42 -0
- package/lib/lib/lib/src/webhook/token.d.ts +2 -0
- package/lib/lib/lib/src/webhook/token.js +23 -0
- package/lib/lib/lib/test.d.ts +1 -0
- package/lib/lib/lib/test.js +55 -0
- package/lib/lib/lib/types.d.ts +1 -0
- package/lib/lib/lib/types.js +2 -0
- package/lib/lib/lib/userSdk/chat.d.ts +9 -0
- package/lib/lib/lib/userSdk/chat.js +98 -0
- package/lib/lib/lib/userSdk/index.d.ts +102 -0
- package/lib/lib/lib/userSdk/index.js +27 -0
- package/lib/lib/lib/userSdk/patients.d.ts +5 -0
- package/lib/lib/lib/userSdk/patients.js +55 -0
- package/lib/lib/lib/userSdk/schedule.d.ts +7 -0
- package/lib/lib/lib/userSdk/schedule.js +76 -0
- package/lib/lib/lib/userSdk/specialties.d.ts +4 -0
- package/lib/lib/lib/userSdk/specialties.js +19 -0
- package/lib/lib/lib/userSdk/videoVisit.d.ts +10 -0
- package/lib/lib/lib/userSdk/videoVisit.js +147 -0
- package/lib/lib/lib/utils.d.ts +4 -0
- package/lib/lib/lib/utils.js +19 -0
- package/lib/lib/lib/webhook/index.d.ts +8 -0
- package/lib/lib/lib/webhook/index.js +55 -0
- package/lib/lib/lib/webhook/responses.d.ts +36 -0
- package/lib/lib/lib/webhook/responses.js +42 -0
- package/lib/lib/lib/webhook/token.d.ts +2 -0
- package/lib/lib/lib/webhook/token.js +23 -0
- package/lib/lib/schemas.d.ts +256 -60
- package/lib/lib/schemas.js +33 -2
- package/lib/lib/src/baseSdk/diagnostica.d.ts +11 -0
- package/lib/lib/src/baseSdk/diagnostica.js +79 -0
- package/lib/lib/src/baseSdk/index.d.ts +162 -0
- package/lib/lib/src/baseSdk/index.js +66 -0
- package/lib/lib/src/baseSdk/user.d.ts +41 -0
- package/lib/lib/src/baseSdk/user.js +130 -0
- package/lib/lib/src/index.d.ts +183 -0
- package/lib/lib/src/index.js +22 -0
- package/lib/lib/src/request/index.d.ts +2 -0
- package/lib/lib/src/request/index.js +26 -0
- package/lib/lib/src/request/token.d.ts +2 -0
- package/lib/lib/src/request/token.js +34 -0
- package/lib/lib/src/request/validation.d.ts +10 -0
- package/lib/lib/src/request/validation.js +28 -0
- package/lib/lib/src/schemas.d.ts +1340 -0
- package/lib/lib/src/schemas.js +325 -0
- package/lib/lib/src/types.d.ts +1 -0
- package/lib/lib/src/types.js +2 -0
- package/lib/lib/src/userSdk/chat.d.ts +9 -0
- package/lib/lib/src/userSdk/chat.js +98 -0
- package/lib/lib/src/userSdk/index.d.ts +241 -0
- package/lib/lib/src/userSdk/index.js +27 -0
- package/lib/lib/src/userSdk/patients.d.ts +13 -0
- package/lib/lib/src/userSdk/patients.js +55 -0
- package/lib/lib/src/userSdk/schedule.d.ts +15 -0
- package/lib/lib/src/userSdk/schedule.js +76 -0
- package/lib/lib/src/userSdk/specialties.d.ts +4 -0
- package/lib/lib/src/userSdk/specialties.js +19 -0
- package/lib/lib/src/userSdk/videoVisit.d.ts +72 -0
- package/lib/lib/src/userSdk/videoVisit.js +147 -0
- package/lib/lib/src/utils.d.ts +4 -0
- package/lib/lib/src/utils.js +19 -0
- package/lib/lib/src/webhook/index.d.ts +8 -0
- package/lib/lib/src/webhook/index.js +55 -0
- package/lib/lib/src/webhook/responses.d.ts +36 -0
- package/lib/lib/src/webhook/responses.js +42 -0
- package/lib/lib/src/webhook/token.d.ts +2 -0
- package/lib/lib/src/webhook/token.js +23 -0
- package/lib/lib/userSdk/index.d.ts +25 -5
- package/lib/lib/userSdk/patients.d.ts +10 -1
- package/lib/lib/userSdk/patients.js +34 -6
- package/lib/lib/userSdk/videoVisit.d.ts +1 -1
- package/lib/lib/utils.d.ts +1 -1
- package/lib/lib/utils.js +3 -3
- package/lib/src/baseSdk/diagnostica.d.ts +6 -6
- package/lib/src/baseSdk/user.d.ts +52 -4
- package/lib/src/baseSdk/user.js +67 -25
- package/lib/src/index.d.ts +45 -16
- package/lib/src/schemas.d.ts +226 -30
- package/lib/src/schemas.js +33 -2
- package/lib/src/types.d.ts +10 -2
- package/lib/src/userSdk/chat.d.ts +1 -1
- package/lib/src/userSdk/patients.d.ts +23 -2
- package/lib/src/userSdk/patients.js +34 -6
- package/lib/src/userSdk/videoVisit.d.ts +2 -2
- package/lib/src/utils.d.ts +1 -1
- package/lib/src/utils.js +3 -3
- package/lib/test.js +2 -36
- package/package.json +4 -1
- package/lib/baseSdk/external.d.ts +0 -28
- package/lib/baseSdk/external.js +0 -73
- package/lib/lib/baseSdk/external.d.ts +0 -15
- package/lib/lib/baseSdk/external.js +0 -73
- package/lib/lib/userSdk/sarasas.d.ts +0 -6
- package/lib/lib/userSdk/sarasas.js +0 -13
- package/lib/userSdk/sarasas.d.ts +0 -6
- package/lib/userSdk/sarasas.js +0 -13
|
@@ -25,9 +25,9 @@ export function userSdk(url: any, credentials: any, userId: any): Promise<{
|
|
|
25
25
|
getPatientChats: (patientId: number) => Promise<{
|
|
26
26
|
id: number;
|
|
27
27
|
patient: {
|
|
28
|
-
id: number;
|
|
29
28
|
firstName: string;
|
|
30
29
|
lastName: string;
|
|
30
|
+
id: number;
|
|
31
31
|
};
|
|
32
32
|
professional: {
|
|
33
33
|
id: number;
|
|
@@ -87,9 +87,9 @@ export function userSdk(url: any, credentials: any, userId: any): Promise<{
|
|
|
87
87
|
patientId: number;
|
|
88
88
|
creationDate: Date;
|
|
89
89
|
user: {
|
|
90
|
-
id: number;
|
|
91
90
|
phone: string | null;
|
|
92
91
|
email: string | null;
|
|
92
|
+
id: number;
|
|
93
93
|
};
|
|
94
94
|
vcToken: string;
|
|
95
95
|
}>;
|
|
@@ -108,9 +108,9 @@ export function userSdk(url: any, credentials: any, userId: any): Promise<{
|
|
|
108
108
|
patientId: number;
|
|
109
109
|
creationDate: Date;
|
|
110
110
|
user: {
|
|
111
|
-
id: number;
|
|
112
111
|
phone: string | null;
|
|
113
112
|
email: string | null;
|
|
113
|
+
id: number;
|
|
114
114
|
};
|
|
115
115
|
vcToken: string;
|
|
116
116
|
}[]>;
|
|
@@ -208,13 +208,33 @@ export function userSdk(url: any, credentials: any, userId: any): Promise<{
|
|
|
208
208
|
id: number;
|
|
209
209
|
description: string;
|
|
210
210
|
}[]>;
|
|
211
|
-
declarePatient: (
|
|
211
|
+
declarePatient: (params: {
|
|
212
|
+
code?: string | undefined;
|
|
213
|
+
channel?: "1" | "2" | undefined;
|
|
214
|
+
patient: {
|
|
215
|
+
firstName: string;
|
|
216
|
+
lastName: string;
|
|
217
|
+
identificationType: "ndi" | "passport" | "credential";
|
|
218
|
+
identificationValue: string;
|
|
219
|
+
countryId: string;
|
|
220
|
+
birthdate: Date;
|
|
221
|
+
gender: "m" | "f";
|
|
222
|
+
};
|
|
223
|
+
}) => Promise<{
|
|
224
|
+
patientId: number | null;
|
|
225
|
+
userInfo: {
|
|
226
|
+
phone: string;
|
|
227
|
+
email: string;
|
|
228
|
+
};
|
|
229
|
+
askCode: boolean;
|
|
230
|
+
}>;
|
|
231
|
+
getPatientId: (patient: {
|
|
212
232
|
firstName: string;
|
|
213
233
|
lastName: string;
|
|
214
234
|
identificationType: "ndi" | "passport" | "credential";
|
|
215
235
|
identificationValue: string;
|
|
216
|
-
gender: "m" | "f";
|
|
217
236
|
countryId: string;
|
|
218
237
|
birthdate: Date;
|
|
238
|
+
gender: "m" | "f";
|
|
219
239
|
}) => Promise<number>;
|
|
220
240
|
}>;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
export var __esModule: boolean;
|
|
2
2
|
export function getPatientMethods(makeRequest: any): {
|
|
3
|
-
declarePatient: (
|
|
3
|
+
declarePatient: (params_0?: {
|
|
4
|
+
patient: any;
|
|
5
|
+
channel: any;
|
|
6
|
+
code: any;
|
|
7
|
+
}) => Promise<{
|
|
8
|
+
patientId: any;
|
|
9
|
+
userInfo: any;
|
|
10
|
+
askCode: any;
|
|
11
|
+
}>;
|
|
12
|
+
getPatientId: (patient?: any) => Promise<any>;
|
|
4
13
|
};
|
|
@@ -7,21 +7,49 @@ const validation_1 = require("../request/validation");
|
|
|
7
7
|
const schemas_1 = require("../schemas");
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
9
|
const getPatientMethods = (makeRequest) => {
|
|
10
|
-
const declarePatient =
|
|
10
|
+
const declarePatient = async ({ patient, channel, code, }) => {
|
|
11
|
+
const path = '/patient';
|
|
11
12
|
const mappedPatient = {
|
|
12
13
|
lastname: patient.lastName,
|
|
13
14
|
firstname: patient.firstName,
|
|
14
|
-
identification_type: utils_1.
|
|
15
|
+
identification_type: utils_1.getIdetificationTypeId(patient.identificationType),
|
|
15
16
|
identification_value: patient.identificationValue,
|
|
16
17
|
birthdate: date_fns_1.format(patient.birthdate, 'yyyy-MM-dd'),
|
|
17
18
|
gender: patient.gender.toUpperCase(),
|
|
18
19
|
country_id: patient.countryId,
|
|
19
20
|
};
|
|
20
|
-
const
|
|
21
|
+
const parsedChannel = channel ? parseInt(channel) : channel;
|
|
22
|
+
const response = await makeRequest('POST', path, {
|
|
21
23
|
user_data: mappedPatient,
|
|
24
|
+
channel: parsedChannel,
|
|
25
|
+
code,
|
|
22
26
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
const mappedResponse = {
|
|
28
|
+
patientId: response.data.patient_id,
|
|
29
|
+
userInfo: response.data.user_info,
|
|
30
|
+
askCode: response.data.ask_code,
|
|
31
|
+
};
|
|
32
|
+
return mappedResponse;
|
|
33
|
+
};
|
|
34
|
+
const getPatientId = async (patient) => {
|
|
35
|
+
const path = '/patient';
|
|
36
|
+
const mappedPatient = {
|
|
37
|
+
lastname: patient.lastName,
|
|
38
|
+
firstname: patient.firstName,
|
|
39
|
+
identification_type: utils_1.getIdetificationTypeId(patient.identificationType),
|
|
40
|
+
identification_value: patient.identificationValue,
|
|
41
|
+
birthdate: date_fns_1.format(patient.birthdate, 'yyyy-MM-dd'),
|
|
42
|
+
gender: patient.gender.toUpperCase(),
|
|
43
|
+
country_id: patient.countryId,
|
|
44
|
+
};
|
|
45
|
+
const response = await makeRequest('POST', path, {
|
|
46
|
+
user_data: mappedPatient,
|
|
47
|
+
});
|
|
48
|
+
return response.data.user_id;
|
|
49
|
+
};
|
|
50
|
+
return {
|
|
51
|
+
declarePatient: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.declarePatientParams]), schemas_1.doc24Schemas.declarePatientResponse, declarePatient),
|
|
52
|
+
getPatientId: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.patient]), zod_1.number(), getPatientId),
|
|
53
|
+
};
|
|
26
54
|
};
|
|
27
55
|
exports.getPatientMethods = getPatientMethods;
|
package/lib/lib/utils.d.ts
CHANGED
package/lib/lib/utils.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getIdetificationTypeId = exports.parseDateTime = exports.parseDate = void 0;
|
|
4
4
|
const date_fns_1 = require("date-fns");
|
|
5
5
|
const timeZone = '-03';
|
|
6
6
|
const parseDate = (str) => exports.parseDateTime(`${str} 00:00:00`);
|
|
7
7
|
exports.parseDate = parseDate;
|
|
8
8
|
const parseDateTime = (str) => date_fns_1.parse(`${str} ${timeZone}`, 'yyyy-MM-dd HH:mm:ss X', new Date());
|
|
9
9
|
exports.parseDateTime = parseDateTime;
|
|
10
|
-
const
|
|
10
|
+
const getIdetificationTypeId = (type) => {
|
|
11
11
|
if (type === 'ndi')
|
|
12
12
|
return 6;
|
|
13
13
|
if (type === 'passport')
|
|
@@ -16,4 +16,4 @@ const getIndetificationTypeId = (type) => {
|
|
|
16
16
|
return 999;
|
|
17
17
|
throw new Error('Invalid identificationType');
|
|
18
18
|
};
|
|
19
|
-
exports.
|
|
19
|
+
exports.getIdetificationTypeId = getIdetificationTypeId;
|
|
@@ -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
|
-
birthday: Date;
|
|
18
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
|
-
birthday: Date;
|
|
27
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
|
-
birthday: Date;
|
|
41
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
|
-
birthday: Date;
|
|
50
49
|
identificationType: "dni";
|
|
51
50
|
identificationValue: string;
|
|
52
51
|
gender: "m" | "f";
|
|
52
|
+
birthday: Date;
|
|
53
53
|
}) => Promise<void>;
|
|
54
54
|
};
|
|
@@ -1,25 +1,73 @@
|
|
|
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: "ndi" | "passport" | "credential";
|
|
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
|
+
patientId: number | null;
|
|
21
|
+
userInfo: {
|
|
22
|
+
phone: string;
|
|
23
|
+
email: string;
|
|
24
|
+
};
|
|
25
|
+
askCode: boolean;
|
|
26
|
+
userId: number;
|
|
27
|
+
}>;
|
|
28
|
+
getUserId: (user: {
|
|
5
29
|
firstName: string;
|
|
6
30
|
lastName: string;
|
|
7
31
|
identificationType: "ndi" | "passport" | "credential";
|
|
8
32
|
identificationValue: string;
|
|
33
|
+
countryId: string;
|
|
34
|
+
birthdate: Date;
|
|
9
35
|
gender: "m" | "f";
|
|
10
36
|
phone: string;
|
|
11
37
|
email: string;
|
|
38
|
+
}) => Promise<number>;
|
|
39
|
+
sendVerificationCode: (params: {
|
|
40
|
+
identificationType: "ndi" | "passport" | "credential";
|
|
41
|
+
identificationValue: string;
|
|
42
|
+
channel: "1" | "2";
|
|
43
|
+
}) => Promise<any>;
|
|
44
|
+
getUserInstance: (user: number | {
|
|
45
|
+
firstName: string;
|
|
46
|
+
lastName: string;
|
|
47
|
+
identificationType: "ndi" | "passport" | "credential";
|
|
48
|
+
identificationValue: string;
|
|
12
49
|
countryId: string;
|
|
13
50
|
birthdate: Date;
|
|
51
|
+
gender: "m" | "f";
|
|
52
|
+
phone: string;
|
|
53
|
+
email: string;
|
|
14
54
|
}) => Promise<any>;
|
|
15
|
-
|
|
16
|
-
|
|
55
|
+
enroll: (params: {
|
|
56
|
+
firstName: string;
|
|
57
|
+
lastName: string;
|
|
58
|
+
birthdate: Date;
|
|
59
|
+
gender: "m" | "f";
|
|
60
|
+
email: string;
|
|
61
|
+
startDate: Date;
|
|
62
|
+
identificationNumber: string;
|
|
63
|
+
plan: string;
|
|
64
|
+
}) => Promise<void>;
|
|
17
65
|
getConverageInfo: (identificationValue: string) => Promise<{
|
|
18
66
|
firstName: string | null;
|
|
19
67
|
lastName: string | null;
|
|
68
|
+
birthdate: Date;
|
|
20
69
|
gender: "m" | "f";
|
|
21
70
|
email: string | null;
|
|
22
|
-
birthdate: Date;
|
|
23
71
|
identificationNumber: string;
|
|
24
72
|
plan: string | null;
|
|
25
73
|
financerId: number | null;
|
package/lib/src/baseSdk/user.js
CHANGED
|
@@ -8,11 +8,39 @@ 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: utils_1.getIdetificationTypeId(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 mappedResponse = {
|
|
31
|
+
userId: response.data.user_id,
|
|
32
|
+
patientId: response.data.patient_id,
|
|
33
|
+
userInfo: response.data.user_info,
|
|
34
|
+
askCode: response.data.ask_code,
|
|
35
|
+
};
|
|
36
|
+
return mappedResponse;
|
|
37
|
+
};
|
|
11
38
|
const getUserId = async (user) => {
|
|
39
|
+
const path = '/user';
|
|
12
40
|
const mappedUser = {
|
|
13
41
|
lastname: user.lastName,
|
|
14
42
|
firstname: user.firstName,
|
|
15
|
-
identification_type: utils_1.
|
|
43
|
+
identification_type: utils_1.getIdetificationTypeId(user.identificationType),
|
|
16
44
|
identification_value: user.identificationValue,
|
|
17
45
|
birthdate: date_fns_1.format(user.birthdate, 'yyyy-MM-dd'),
|
|
18
46
|
gender: user.gender.toUpperCase(),
|
|
@@ -20,12 +48,41 @@ const getUserMethods = (makeRequest, url, credentials) => {
|
|
|
20
48
|
email: user.email,
|
|
21
49
|
country_id: user.countryId,
|
|
22
50
|
};
|
|
23
|
-
const response = await makeRequest('POST',
|
|
51
|
+
const response = await makeRequest('POST', path, {
|
|
24
52
|
user_data: mappedUser,
|
|
25
53
|
});
|
|
26
54
|
return response.data.user_id;
|
|
27
55
|
};
|
|
28
|
-
const
|
|
56
|
+
const sendVerificationCode = async (params) => {
|
|
57
|
+
const path = '/send-verification-code';
|
|
58
|
+
const mappedParams = {
|
|
59
|
+
identification_type: utils_1.getIdetificationTypeId(params.identificationType),
|
|
60
|
+
identification_value: params.identificationValue,
|
|
61
|
+
channel: parseInt(params.channel),
|
|
62
|
+
};
|
|
63
|
+
await makeRequest('POST', path, mappedParams);
|
|
64
|
+
};
|
|
65
|
+
const getUserInstance = async (user) => {
|
|
66
|
+
const userId = typeof user === 'number' ? user : await getUserId(user);
|
|
67
|
+
return userSdk_1.userSdk(url, credentials, userId);
|
|
68
|
+
};
|
|
69
|
+
const enroll = async (params) => {
|
|
70
|
+
const path = `/enrollment`;
|
|
71
|
+
const mappedUser = {
|
|
72
|
+
firstname: params.firstName,
|
|
73
|
+
lastname: params.lastName,
|
|
74
|
+
gender: params.gender.toUpperCase(),
|
|
75
|
+
identification_number: params.identificationNumber,
|
|
76
|
+
birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
|
|
77
|
+
email: params.email,
|
|
78
|
+
plan: params.plan,
|
|
79
|
+
start_date: date_fns_1.format(params.startDate, 'yyyy-MM-dd'),
|
|
80
|
+
};
|
|
81
|
+
await makeRequest('POST', path, {
|
|
82
|
+
user_data: mappedUser,
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
const getConverageInfo = async (identificationValue) => {
|
|
29
86
|
const path = `/info-coverage/${identificationValue}`;
|
|
30
87
|
const response = await makeRequest('GET', path);
|
|
31
88
|
const raw = response.data.info;
|
|
@@ -58,31 +115,16 @@ const getUserMethods = (makeRequest, url, credentials) => {
|
|
|
58
115
|
: null,
|
|
59
116
|
};
|
|
60
117
|
return mappedCoverageInfo;
|
|
61
|
-
}
|
|
118
|
+
};
|
|
62
119
|
return {
|
|
63
|
-
declareUser: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.
|
|
120
|
+
declareUser: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.declareUserParams]), schemas_1.doc24Schemas.declareUserResponse, declareUser),
|
|
121
|
+
getUserId: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.user]), zod_1.number(), getUserId),
|
|
122
|
+
sendVerificationCode: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.sendVerificationCodeParams]), zod_1.void(), sendVerificationCode),
|
|
64
123
|
getUserInstance: validation_1.validateFunction(zod_1.tuple([zod_1.union([schemas_1.doc24Schemas.user, zod_1.number()])]),
|
|
65
124
|
// 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,
|
|
125
|
+
zod_1.any(), getUserInstance),
|
|
126
|
+
enroll: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.enrollmentParams]), zod_1.void(), enroll),
|
|
127
|
+
getConverageInfo: validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.coverageInfo, getConverageInfo),
|
|
86
128
|
};
|
|
87
129
|
};
|
|
88
130
|
exports.getUserMethods = getUserMethods;
|
package/lib/src/index.d.ts
CHANGED
|
@@ -5,37 +5,61 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
|
|
|
5
5
|
eventHandlers: Doc24.Webhook.Events;
|
|
6
6
|
baseAddress: string;
|
|
7
7
|
}) => Promise<Doc24.Webhook.Handler>;
|
|
8
|
-
declareUser: (
|
|
8
|
+
declareUser: (params: {
|
|
9
|
+
user: {
|
|
10
|
+
firstName: string;
|
|
11
|
+
lastName: string;
|
|
12
|
+
identificationType: "ndi" | "passport" | "credential";
|
|
13
|
+
identificationValue: string;
|
|
14
|
+
countryId: string;
|
|
15
|
+
birthdate: Date;
|
|
16
|
+
gender: "m" | "f";
|
|
17
|
+
phone: string;
|
|
18
|
+
email: string;
|
|
19
|
+
};
|
|
20
|
+
} & {
|
|
21
|
+
code?: string | undefined;
|
|
22
|
+
channel?: "1" | "2" | undefined;
|
|
23
|
+
}) => Promise<{
|
|
24
|
+
patientId: number | null;
|
|
25
|
+
userInfo: {
|
|
26
|
+
phone: string;
|
|
27
|
+
email: string;
|
|
28
|
+
};
|
|
29
|
+
askCode: boolean;
|
|
30
|
+
userId: number;
|
|
31
|
+
}>;
|
|
32
|
+
getUserId: (user: {
|
|
9
33
|
firstName: string;
|
|
10
34
|
lastName: string;
|
|
11
35
|
identificationType: "ndi" | "passport" | "credential";
|
|
12
36
|
identificationValue: string;
|
|
37
|
+
countryId: string;
|
|
38
|
+
birthdate: Date;
|
|
13
39
|
gender: "m" | "f";
|
|
14
40
|
phone: string;
|
|
15
41
|
email: string;
|
|
16
|
-
countryId: string;
|
|
17
|
-
birthdate: Date;
|
|
18
42
|
}) => Promise<number>;
|
|
19
43
|
getUserInstance: (user: number | {
|
|
20
44
|
firstName: string;
|
|
21
45
|
lastName: string;
|
|
22
46
|
identificationType: "ndi" | "passport" | "credential";
|
|
23
47
|
identificationValue: string;
|
|
48
|
+
countryId: string;
|
|
49
|
+
birthdate: Date;
|
|
24
50
|
gender: "m" | "f";
|
|
25
51
|
phone: string;
|
|
26
52
|
email: string;
|
|
27
|
-
countryId: string;
|
|
28
|
-
birthdate: Date;
|
|
29
53
|
}) => Promise<Doc24.UserSdk>;
|
|
30
54
|
getProfessional: (professionalId: number) => Promise<{
|
|
31
|
-
id: number;
|
|
32
|
-
logoUrl: string;
|
|
33
55
|
firstName: string;
|
|
34
56
|
lastName: string;
|
|
57
|
+
birthdate: Date;
|
|
35
58
|
gender: "m" | "f";
|
|
36
59
|
phone: string | null;
|
|
37
60
|
email: string;
|
|
38
|
-
|
|
61
|
+
id: number;
|
|
62
|
+
logoUrl: string;
|
|
39
63
|
specialties: {
|
|
40
64
|
id: number;
|
|
41
65
|
description: string;
|
|
@@ -73,9 +97,9 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
|
|
|
73
97
|
enroll: (params: {
|
|
74
98
|
firstName: string;
|
|
75
99
|
lastName: string;
|
|
100
|
+
birthdate: Date;
|
|
76
101
|
gender: "m" | "f";
|
|
77
102
|
email: string;
|
|
78
|
-
birthdate: Date;
|
|
79
103
|
startDate: Date;
|
|
80
104
|
identificationNumber: string;
|
|
81
105
|
plan: string;
|
|
@@ -83,9 +107,9 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
|
|
|
83
107
|
getConverageInfo: (identificationValue: string) => Promise<{
|
|
84
108
|
firstName: string | null;
|
|
85
109
|
lastName: string | null;
|
|
110
|
+
birthdate: Date;
|
|
86
111
|
gender: "m" | "f";
|
|
87
112
|
email: string | null;
|
|
88
|
-
birthdate: Date;
|
|
89
113
|
identificationNumber: string;
|
|
90
114
|
plan: string | null;
|
|
91
115
|
financerId: number | null;
|
|
@@ -104,6 +128,11 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
|
|
|
104
128
|
authorizationCode: string | null;
|
|
105
129
|
authorizationCodeExpiration: Date | null;
|
|
106
130
|
} | null>;
|
|
131
|
+
sendVerificationCode: (params: {
|
|
132
|
+
identificationType: "ndi" | "passport" | "credential";
|
|
133
|
+
identificationValue: string;
|
|
134
|
+
channel: "1" | "2";
|
|
135
|
+
}) => Promise<any>;
|
|
107
136
|
getDiagnosticaHistory: (patient: {
|
|
108
137
|
identificationType: "ndi" | "passport" | "credential";
|
|
109
138
|
identificationValue: string;
|
|
@@ -115,22 +144,22 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
|
|
|
115
144
|
deepLink: string;
|
|
116
145
|
}[]>;
|
|
117
146
|
getDiagnosticaDeepLink: (kiosk: string, user: {
|
|
118
|
-
language: string;
|
|
119
147
|
firstName: string;
|
|
120
148
|
lastName: string;
|
|
121
|
-
birthday: Date;
|
|
122
149
|
identificationType: "dni";
|
|
123
150
|
identificationValue: string;
|
|
124
151
|
gender: "m" | "f";
|
|
125
152
|
phone: string;
|
|
126
153
|
email: string;
|
|
154
|
+
language: string;
|
|
155
|
+
birthday: Date;
|
|
127
156
|
}, patient: {
|
|
128
157
|
firstName: string;
|
|
129
158
|
lastName: string;
|
|
130
|
-
birthday: Date;
|
|
131
159
|
identificationType: "dni";
|
|
132
160
|
identificationValue: string;
|
|
133
161
|
gender: "m" | "f";
|
|
162
|
+
birthday: Date;
|
|
134
163
|
}) => Promise<{
|
|
135
164
|
forwardingRequired: true;
|
|
136
165
|
deepLink: string;
|
|
@@ -138,22 +167,22 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
|
|
|
138
167
|
forwardingRequired: false;
|
|
139
168
|
}>;
|
|
140
169
|
getDiagnosticaAccess: (kiosk: string, user: {
|
|
141
|
-
language: string;
|
|
142
170
|
firstName: string;
|
|
143
171
|
lastName: string;
|
|
144
|
-
birthday: Date;
|
|
145
172
|
identificationType: "dni";
|
|
146
173
|
identificationValue: string;
|
|
147
174
|
gender: "m" | "f";
|
|
148
175
|
phone: string;
|
|
149
176
|
email: string;
|
|
177
|
+
language: string;
|
|
178
|
+
birthday: Date;
|
|
150
179
|
}, patient: {
|
|
151
180
|
firstName: string;
|
|
152
181
|
lastName: string;
|
|
153
|
-
birthday: Date;
|
|
154
182
|
identificationType: "dni";
|
|
155
183
|
identificationValue: string;
|
|
156
184
|
gender: "m" | "f";
|
|
185
|
+
birthday: Date;
|
|
157
186
|
}) => Promise<void>;
|
|
158
187
|
}>;
|
|
159
188
|
export type { Doc24 } from './types';
|