@integraciones_doc24/sdk 0.39.6 → 0.39.7
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/diagnostica.d.ts +16 -16
- package/lib/baseSdk/diagnostica.js +22 -19
- package/lib/baseSdk/external.d.ts +177 -0
- package/lib/baseSdk/external.js +96 -0
- package/lib/baseSdk/index.js +4 -3
- package/lib/baseSdk/user.d.ts +60 -10
- package/lib/baseSdk/user.js +74 -26
- package/lib/index.d.ts +243 -133
- package/lib/schemas.d.ts +776 -411
- package/lib/schemas.js +152 -136
- package/lib/types.d.ts +35 -9
- package/lib/userSdk/chat.d.ts +2 -2
- package/lib/userSdk/external.d.ts +34 -0
- package/lib/userSdk/external.js +72 -0
- package/lib/userSdk/index.js +3 -0
- package/lib/userSdk/patients.d.ts +30 -16
- package/lib/userSdk/patients.js +35 -14
- package/lib/userSdk/schedule.d.ts +5 -2
- package/lib/userSdk/schedule.js +21 -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 -22
- package/lib/webhook/index.js +1 -0
- package/package.json +1 -1
- package/lib/baseSdk/consultation.d.ts +0 -99
- package/lib/baseSdk/consultation.js +0 -23
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { RequestMaker } from '../request';
|
|
2
2
|
export declare const getDiagnosticaMethods: (makeRequest: RequestMaker) => {
|
|
3
3
|
getDiagnosticaHistory: (patient: {
|
|
4
|
-
|
|
4
|
+
gender?: "m" | "f" | "o" | undefined;
|
|
5
|
+
identificationType: "DNI";
|
|
5
6
|
identificationValue: string;
|
|
6
|
-
gender: "m" | "f";
|
|
7
7
|
}, from: Date, to: Date) => Promise<{
|
|
8
8
|
date: Date;
|
|
9
9
|
location: string;
|
|
@@ -11,22 +11,22 @@ export declare const getDiagnosticaMethods: (makeRequest: RequestMaker) => {
|
|
|
11
11
|
deepLink: string;
|
|
12
12
|
}[]>;
|
|
13
13
|
getDiagnosticaDeepLink: (kiosk: string, user: {
|
|
14
|
-
|
|
14
|
+
gender?: "m" | "f" | "o" | undefined;
|
|
15
15
|
firstName: string;
|
|
16
16
|
lastName: string;
|
|
17
|
-
|
|
18
|
-
identificationType: "dni";
|
|
17
|
+
identificationType: "DNI";
|
|
19
18
|
identificationValue: string;
|
|
20
|
-
gender: "m" | "f";
|
|
21
19
|
phone: string;
|
|
22
20
|
email: string;
|
|
21
|
+
language: string;
|
|
22
|
+
birthday: Date;
|
|
23
23
|
}, patient: {
|
|
24
|
+
gender?: "m" | "f" | "o" | undefined;
|
|
24
25
|
firstName: string;
|
|
25
26
|
lastName: string;
|
|
26
|
-
|
|
27
|
-
identificationType: "dni";
|
|
27
|
+
identificationType: "DNI";
|
|
28
28
|
identificationValue: string;
|
|
29
|
-
|
|
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
|
-
|
|
37
|
+
gender?: "m" | "f" | "o" | undefined;
|
|
38
38
|
firstName: string;
|
|
39
39
|
lastName: string;
|
|
40
|
-
|
|
41
|
-
identificationType: "dni";
|
|
40
|
+
identificationType: "DNI";
|
|
42
41
|
identificationValue: string;
|
|
43
|
-
gender: "m" | "f";
|
|
44
42
|
phone: string;
|
|
45
43
|
email: string;
|
|
44
|
+
language: string;
|
|
45
|
+
birthday: Date;
|
|
46
46
|
}, patient: {
|
|
47
|
+
gender?: "m" | "f" | "o" | undefined;
|
|
47
48
|
firstName: string;
|
|
48
49
|
lastName: string;
|
|
49
|
-
|
|
50
|
-
identificationType: "dni";
|
|
50
|
+
identificationType: "DNI";
|
|
51
51
|
identificationValue: string;
|
|
52
|
-
|
|
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,18 +45,31 @@ 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) => {
|
|
65
|
+
var _a;
|
|
63
66
|
return {
|
|
64
67
|
name: patient.firstName,
|
|
65
68
|
surname: patient.lastName,
|
|
66
69
|
birthday: date_fns_1.format(patient.birthday, 'yyyy-MM-dd'),
|
|
67
70
|
id_type: 'DNI',
|
|
68
71
|
id_value: patient.identificationValue,
|
|
69
|
-
gender: patient.gender.toLocaleUpperCase(),
|
|
72
|
+
gender: (_a = patient.gender) === null || _a === void 0 ? void 0 : _a.toLocaleUpperCase(),
|
|
70
73
|
};
|
|
71
74
|
};
|
|
72
75
|
const mapUserData = (user) => {
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { RequestMaker } from '../request';
|
|
2
|
+
export declare const getExternalMethods: (makeRequest: RequestMaker) => {
|
|
3
|
+
externalLogin: (params: {
|
|
4
|
+
user: string;
|
|
5
|
+
password: string;
|
|
6
|
+
}) => Promise<{
|
|
7
|
+
gender?: "m" | "f" | "o" | undefined;
|
|
8
|
+
firstName: string;
|
|
9
|
+
lastName: string;
|
|
10
|
+
countryId: string;
|
|
11
|
+
phone: string;
|
|
12
|
+
email: string;
|
|
13
|
+
birthday: Date;
|
|
14
|
+
identificationNumber: string;
|
|
15
|
+
}>;
|
|
16
|
+
preExternalEnrollment: (params: ({
|
|
17
|
+
birthdate: Date;
|
|
18
|
+
identificationNumber: string;
|
|
19
|
+
} & {
|
|
20
|
+
phone: string;
|
|
21
|
+
email: string;
|
|
22
|
+
}) | ({
|
|
23
|
+
birthdate: Date;
|
|
24
|
+
identificationNumber: string;
|
|
25
|
+
} & {
|
|
26
|
+
phone?: undefined;
|
|
27
|
+
email: string;
|
|
28
|
+
}) | ({
|
|
29
|
+
birthdate: Date;
|
|
30
|
+
identificationNumber: string;
|
|
31
|
+
} & {
|
|
32
|
+
email?: undefined;
|
|
33
|
+
phone: string;
|
|
34
|
+
})) => Promise<void>;
|
|
35
|
+
externalEnrollment: (params: ({
|
|
36
|
+
birthdate: Date;
|
|
37
|
+
identificationNumber: string;
|
|
38
|
+
} & {
|
|
39
|
+
phone: string;
|
|
40
|
+
email: string;
|
|
41
|
+
} & {
|
|
42
|
+
password: string;
|
|
43
|
+
} & {
|
|
44
|
+
emailCode: string;
|
|
45
|
+
phoneCode: string;
|
|
46
|
+
}) | ({
|
|
47
|
+
birthdate: Date;
|
|
48
|
+
identificationNumber: string;
|
|
49
|
+
} & {
|
|
50
|
+
phone: string;
|
|
51
|
+
email: string;
|
|
52
|
+
} & {
|
|
53
|
+
password: string;
|
|
54
|
+
} & {
|
|
55
|
+
phoneCode?: undefined;
|
|
56
|
+
emailCode: string;
|
|
57
|
+
}) | ({
|
|
58
|
+
birthdate: Date;
|
|
59
|
+
identificationNumber: string;
|
|
60
|
+
} & {
|
|
61
|
+
phone: string;
|
|
62
|
+
email: string;
|
|
63
|
+
} & {
|
|
64
|
+
password: string;
|
|
65
|
+
} & {
|
|
66
|
+
emailCode?: undefined;
|
|
67
|
+
phoneCode: string;
|
|
68
|
+
}) | ({
|
|
69
|
+
birthdate: Date;
|
|
70
|
+
identificationNumber: string;
|
|
71
|
+
} & {
|
|
72
|
+
phone?: undefined;
|
|
73
|
+
email: string;
|
|
74
|
+
} & {
|
|
75
|
+
password: string;
|
|
76
|
+
} & {
|
|
77
|
+
emailCode: string;
|
|
78
|
+
phoneCode: string;
|
|
79
|
+
}) | ({
|
|
80
|
+
birthdate: Date;
|
|
81
|
+
identificationNumber: string;
|
|
82
|
+
} & {
|
|
83
|
+
phone?: undefined;
|
|
84
|
+
email: string;
|
|
85
|
+
} & {
|
|
86
|
+
password: string;
|
|
87
|
+
} & {
|
|
88
|
+
phoneCode?: undefined;
|
|
89
|
+
emailCode: string;
|
|
90
|
+
}) | ({
|
|
91
|
+
birthdate: Date;
|
|
92
|
+
identificationNumber: string;
|
|
93
|
+
} & {
|
|
94
|
+
phone?: undefined;
|
|
95
|
+
email: string;
|
|
96
|
+
} & {
|
|
97
|
+
password: string;
|
|
98
|
+
} & {
|
|
99
|
+
emailCode?: undefined;
|
|
100
|
+
phoneCode: string;
|
|
101
|
+
}) | ({
|
|
102
|
+
birthdate: Date;
|
|
103
|
+
identificationNumber: string;
|
|
104
|
+
} & {
|
|
105
|
+
email?: undefined;
|
|
106
|
+
phone: string;
|
|
107
|
+
} & {
|
|
108
|
+
password: string;
|
|
109
|
+
} & {
|
|
110
|
+
emailCode: string;
|
|
111
|
+
phoneCode: string;
|
|
112
|
+
}) | ({
|
|
113
|
+
birthdate: Date;
|
|
114
|
+
identificationNumber: string;
|
|
115
|
+
} & {
|
|
116
|
+
email?: undefined;
|
|
117
|
+
phone: string;
|
|
118
|
+
} & {
|
|
119
|
+
password: string;
|
|
120
|
+
} & {
|
|
121
|
+
phoneCode?: undefined;
|
|
122
|
+
emailCode: string;
|
|
123
|
+
}) | ({
|
|
124
|
+
birthdate: Date;
|
|
125
|
+
identificationNumber: string;
|
|
126
|
+
} & {
|
|
127
|
+
email?: undefined;
|
|
128
|
+
phone: string;
|
|
129
|
+
} & {
|
|
130
|
+
password: string;
|
|
131
|
+
} & {
|
|
132
|
+
emailCode?: undefined;
|
|
133
|
+
phoneCode: string;
|
|
134
|
+
})) => Promise<{
|
|
135
|
+
gender?: "m" | "f" | "o" | undefined;
|
|
136
|
+
firstName: string;
|
|
137
|
+
lastName: string;
|
|
138
|
+
countryId: string;
|
|
139
|
+
phone: string;
|
|
140
|
+
email: string;
|
|
141
|
+
birthday: Date;
|
|
142
|
+
identificationNumber: string;
|
|
143
|
+
}>;
|
|
144
|
+
sendExternalVerificationCode: (params: {
|
|
145
|
+
birthdate: Date;
|
|
146
|
+
channel: "1" | "2";
|
|
147
|
+
identificationNumber: string;
|
|
148
|
+
}) => Promise<void>;
|
|
149
|
+
verifyExternalVerificationCode: (params: {
|
|
150
|
+
code: string;
|
|
151
|
+
birthdate: Date;
|
|
152
|
+
channel: "1" | "2";
|
|
153
|
+
identificationNumber: string;
|
|
154
|
+
}) => Promise<any>;
|
|
155
|
+
externalResetPassword: (params: ({
|
|
156
|
+
birthdate: Date;
|
|
157
|
+
password: string;
|
|
158
|
+
identificationNumber: string;
|
|
159
|
+
} & {
|
|
160
|
+
emailCode: string;
|
|
161
|
+
phoneCode: string;
|
|
162
|
+
}) | ({
|
|
163
|
+
birthdate: Date;
|
|
164
|
+
password: string;
|
|
165
|
+
identificationNumber: string;
|
|
166
|
+
} & {
|
|
167
|
+
phoneCode?: undefined;
|
|
168
|
+
emailCode: string;
|
|
169
|
+
}) | ({
|
|
170
|
+
birthdate: Date;
|
|
171
|
+
password: string;
|
|
172
|
+
identificationNumber: string;
|
|
173
|
+
} & {
|
|
174
|
+
emailCode?: undefined;
|
|
175
|
+
phoneCode: string;
|
|
176
|
+
})) => Promise<any>;
|
|
177
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getExternalMethods = void 0;
|
|
4
|
+
const date_fns_1 = require("date-fns");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const validation_1 = require("../request/validation");
|
|
7
|
+
const schemas_1 = require("../schemas");
|
|
8
|
+
const getExternalMethods = (makeRequest) => {
|
|
9
|
+
const externalLogin = async ({ user, password, }) => {
|
|
10
|
+
const path = '/external-login';
|
|
11
|
+
const response = await makeRequest('POST', path, { user, password });
|
|
12
|
+
const info = response.data.login_info;
|
|
13
|
+
return {
|
|
14
|
+
firstName: info.firstname,
|
|
15
|
+
lastName: info.lastname,
|
|
16
|
+
countryId: info.country_id,
|
|
17
|
+
birthday: new Date(Date.parse(info.birthdate)),
|
|
18
|
+
identificationNumber: info.identification_number,
|
|
19
|
+
gender: info.gender.toLowerCase(),
|
|
20
|
+
email: info.email,
|
|
21
|
+
phone: info.telephone,
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
const preExternalEnrollment = async (params) => {
|
|
25
|
+
const path = '/pre-external-enrollment';
|
|
26
|
+
await makeRequest('POST', path, {
|
|
27
|
+
identification_number: params.identificationNumber,
|
|
28
|
+
birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
|
|
29
|
+
email: params.email,
|
|
30
|
+
telephone: params.phone,
|
|
31
|
+
});
|
|
32
|
+
return;
|
|
33
|
+
};
|
|
34
|
+
const externalEnrollment = async (params) => {
|
|
35
|
+
const path = '/external-enrollment';
|
|
36
|
+
const response = await makeRequest('POST', path, {
|
|
37
|
+
identification_number: params.identificationNumber,
|
|
38
|
+
birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
|
|
39
|
+
email: params.email,
|
|
40
|
+
telephone: params.phone,
|
|
41
|
+
password: params.password,
|
|
42
|
+
email_code: params.emailCode,
|
|
43
|
+
telephone_code: params.phoneCode,
|
|
44
|
+
});
|
|
45
|
+
const info = response.data.info;
|
|
46
|
+
return {
|
|
47
|
+
firstName: info.firstname,
|
|
48
|
+
lastName: info.lastname,
|
|
49
|
+
countryId: info.country_id,
|
|
50
|
+
birthday: new Date(Date.parse(info.birthdate)),
|
|
51
|
+
identificationNumber: info.identification_number,
|
|
52
|
+
gender: info.gender.toLowerCase(),
|
|
53
|
+
email: info.email,
|
|
54
|
+
phone: info.telephone,
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
const sendExternalVerificationCode = async (params) => {
|
|
58
|
+
const path = '/send-external-verification-code';
|
|
59
|
+
await makeRequest('POST', path, {
|
|
60
|
+
identification_number: params.identificationNumber,
|
|
61
|
+
birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
|
|
62
|
+
channel: params.channel,
|
|
63
|
+
});
|
|
64
|
+
return;
|
|
65
|
+
};
|
|
66
|
+
const verifyExternalVerificationCode = async (params) => {
|
|
67
|
+
const path = '/verify-external-verification-code';
|
|
68
|
+
const response = await makeRequest('POST', path, {
|
|
69
|
+
identification_number: params.identificationNumber,
|
|
70
|
+
birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
|
|
71
|
+
channel: params.channel,
|
|
72
|
+
code: params.code,
|
|
73
|
+
});
|
|
74
|
+
return response.data;
|
|
75
|
+
};
|
|
76
|
+
const externalResetPassword = async (params) => {
|
|
77
|
+
const path = '/external-reset';
|
|
78
|
+
const response = await makeRequest('POST', path, {
|
|
79
|
+
identification_number: params.identificationNumber,
|
|
80
|
+
birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
|
|
81
|
+
password: params.password,
|
|
82
|
+
email_code: params.emailCode,
|
|
83
|
+
telephone_code: params.phoneCode,
|
|
84
|
+
});
|
|
85
|
+
return response.data;
|
|
86
|
+
};
|
|
87
|
+
return {
|
|
88
|
+
externalLogin: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalLoginParams]), schemas_1.doc24Schemas.externalLoginResponse, externalLogin),
|
|
89
|
+
preExternalEnrollment: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.preExternalEnrollmentParams]), zod_1.void(), preExternalEnrollment),
|
|
90
|
+
externalEnrollment: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalEnrollmentParams]), schemas_1.doc24Schemas.externalLoginResponse, externalEnrollment),
|
|
91
|
+
sendExternalVerificationCode: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.sendExternalVerificationCodeParams]), zod_1.void(), sendExternalVerificationCode),
|
|
92
|
+
verifyExternalVerificationCode: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.verifyExternalVerificationCodeParams]), zod_1.any(), verifyExternalVerificationCode),
|
|
93
|
+
externalResetPassword: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalResetPasswordParams]), zod_1.any(), externalResetPassword),
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
exports.getExternalMethods = getExternalMethods;
|
package/lib/baseSdk/index.js
CHANGED
|
@@ -8,16 +8,16 @@ 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
|
|
11
|
+
const external_1 = require("./external");
|
|
12
12
|
const getBaseSdk = async (url, credentials) => {
|
|
13
13
|
const makeRequest = await request_1.getRequestFactory(url, credentials);
|
|
14
14
|
const diagnosticaMethods = diagnostica_1.getDiagnosticaMethods(makeRequest);
|
|
15
|
+
const externalMethods = external_1.getExternalMethods(makeRequest);
|
|
15
16
|
const userMethods = user_1.getUserMethods(makeRequest, url, credentials);
|
|
16
|
-
const consultationMethods = consultation_1.getConsultationMethods(url, credentials);
|
|
17
17
|
const baseSdk = {
|
|
18
18
|
...diagnosticaMethods,
|
|
19
|
+
...externalMethods,
|
|
19
20
|
...userMethods,
|
|
20
|
-
...consultationMethods,
|
|
21
21
|
getProfessional: validation_1.validateFunction(zod_1.tuple([zod_1.number()]), schemas_1.doc24Schemas.professional, async (professionalId) => {
|
|
22
22
|
const path = `/professional/${professionalId}`;
|
|
23
23
|
const response = await makeRequest('GET', path);
|
|
@@ -42,6 +42,7 @@ const getBaseSdk = async (url, credentials) => {
|
|
|
42
42
|
link: raw.resume_link,
|
|
43
43
|
brief: raw.resume_brief,
|
|
44
44
|
},
|
|
45
|
+
consultation_value: raw.consultation_value
|
|
45
46
|
};
|
|
46
47
|
}),
|
|
47
48
|
getAvailableScheduleClinics: validation_1.validateFunction(zod_1.tuple([]), schemas_1.doc24Schemas.availableScheduleClinics, async () => {
|
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
|
+
identificationType?: number | undefined;
|
|
7
|
+
identificationValue?: string | undefined;
|
|
8
|
+
gender?: "m" | "f" | "o" | undefined;
|
|
9
|
+
phone?: string | undefined;
|
|
10
|
+
firstName: string;
|
|
11
|
+
lastName: string;
|
|
12
|
+
countryId: string;
|
|
13
|
+
birthdate: Date;
|
|
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: {
|
|
31
|
+
identificationType?: number | undefined;
|
|
32
|
+
identificationValue?: string | undefined;
|
|
33
|
+
gender?: "m" | "f" | "o" | undefined;
|
|
34
|
+
phone?: string | undefined;
|
|
5
35
|
firstName: string;
|
|
6
36
|
lastName: string;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
gender: "m" | "f";
|
|
10
|
-
phone: string;
|
|
37
|
+
countryId: string;
|
|
38
|
+
birthdate: Date;
|
|
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
|
+
identificationType?: number | undefined;
|
|
48
|
+
identificationValue?: string | undefined;
|
|
49
|
+
gender?: "m" | "f" | "o" | undefined;
|
|
50
|
+
phone?: string | undefined;
|
|
51
|
+
firstName: string;
|
|
52
|
+
lastName: string;
|
|
12
53
|
countryId: string;
|
|
13
54
|
birthdate: Date;
|
|
55
|
+
email: string;
|
|
14
56
|
}) => Promise<any>;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
57
|
+
enroll: (params: {
|
|
58
|
+
gender?: "m" | "f" | "o" | undefined;
|
|
59
|
+
firstName: string;
|
|
60
|
+
lastName: string;
|
|
61
|
+
birthdate: Date;
|
|
62
|
+
email: string;
|
|
63
|
+
identificationNumber: string;
|
|
64
|
+
startDate: Date;
|
|
65
|
+
plan: string;
|
|
66
|
+
}) => Promise<void>;
|
|
67
|
+
getCoverageInfo: (identificationValue: string) => Promise<{
|
|
68
|
+
gender?: "m" | "f" | "o" | undefined;
|
|
18
69
|
firstName: string | null;
|
|
19
70
|
lastName: string | null;
|
|
20
|
-
gender: "m" | "f";
|
|
21
|
-
email: string | null;
|
|
22
71
|
birthdate: Date;
|
|
72
|
+
email: string | null;
|
|
23
73
|
identificationNumber: string;
|
|
24
74
|
plan: string | null;
|
|
25
75
|
financerId: number | null;
|
package/lib/baseSdk/user.js
CHANGED
|
@@ -8,27 +8,90 @@ 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
|
+
var _a;
|
|
13
|
+
const path = '/user';
|
|
14
|
+
const mappedUser = {
|
|
15
|
+
lastname: user.lastName,
|
|
16
|
+
firstname: user.firstName,
|
|
17
|
+
identification_type: user.identificationType,
|
|
18
|
+
identification_value: user.identificationValue,
|
|
19
|
+
birthdate: date_fns_1.format(user.birthdate, 'yyyy-MM-dd'),
|
|
20
|
+
gender: (_a = user.gender) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
|
|
21
|
+
phone: user.phone,
|
|
22
|
+
email: user.email,
|
|
23
|
+
country_id: user.countryId,
|
|
24
|
+
};
|
|
25
|
+
const parsedChannel = channel ? parseInt(channel) : channel;
|
|
26
|
+
const response = await makeRequest('POST', path, {
|
|
27
|
+
user_data: mappedUser,
|
|
28
|
+
channel: parsedChannel,
|
|
29
|
+
code,
|
|
30
|
+
});
|
|
31
|
+
const data = response.data;
|
|
32
|
+
if (data.ask_code)
|
|
33
|
+
return { askCode: true, userInfo: data.user_info };
|
|
34
|
+
return {
|
|
35
|
+
askCode: false,
|
|
36
|
+
userId: response.data.user_id,
|
|
37
|
+
patientId: response.data.patient_id,
|
|
38
|
+
};
|
|
39
|
+
};
|
|
11
40
|
const getUserId = async (user) => {
|
|
41
|
+
var _a;
|
|
42
|
+
const path = '/search-user';
|
|
12
43
|
const mappedUser = {
|
|
13
44
|
lastname: user.lastName,
|
|
14
45
|
firstname: user.firstName,
|
|
15
|
-
identification_type:
|
|
46
|
+
identification_type: user.identificationType,
|
|
16
47
|
identification_value: user.identificationValue,
|
|
17
48
|
birthdate: date_fns_1.format(user.birthdate, 'yyyy-MM-dd'),
|
|
18
|
-
gender: user.gender.toUpperCase(),
|
|
49
|
+
gender: (_a = user.gender) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
|
|
19
50
|
phone: user.phone,
|
|
20
51
|
email: user.email,
|
|
21
52
|
country_id: user.countryId,
|
|
22
53
|
};
|
|
23
|
-
const response = await makeRequest('POST',
|
|
54
|
+
const response = await makeRequest('POST', path, {
|
|
24
55
|
user_data: mappedUser,
|
|
25
56
|
});
|
|
26
57
|
return response.data.user_id;
|
|
27
58
|
};
|
|
28
|
-
const
|
|
59
|
+
const sendVerificationCode = async (params) => {
|
|
60
|
+
const path = '/send-verification-code';
|
|
61
|
+
const mappedParams = {
|
|
62
|
+
identification_type: params.identificationType,
|
|
63
|
+
identification_value: params.identificationValue,
|
|
64
|
+
channel: parseInt(params.channel),
|
|
65
|
+
};
|
|
66
|
+
await makeRequest('POST', path, mappedParams);
|
|
67
|
+
};
|
|
68
|
+
const getUserInstance = async (user) => {
|
|
69
|
+
const userId = typeof user === 'number' ? user : await getUserId(user);
|
|
70
|
+
return userSdk_1.userSdk(url, credentials, userId);
|
|
71
|
+
};
|
|
72
|
+
const enroll = async (params) => {
|
|
73
|
+
var _a;
|
|
74
|
+
const path = `/enrollment`;
|
|
75
|
+
const mappedUser = {
|
|
76
|
+
firstname: params.firstName,
|
|
77
|
+
lastname: params.lastName,
|
|
78
|
+
gender: (_a = params.gender) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
|
|
79
|
+
identification_number: params.identificationNumber,
|
|
80
|
+
birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
|
|
81
|
+
email: params.email,
|
|
82
|
+
plan: params.plan,
|
|
83
|
+
start_date: date_fns_1.format(params.startDate, 'yyyy-MM-dd'),
|
|
84
|
+
};
|
|
85
|
+
await makeRequest('POST', path, {
|
|
86
|
+
user_data: mappedUser,
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
const getCoverageInfo = async (identificationValue) => {
|
|
29
90
|
const path = `/info-coverage/${identificationValue}`;
|
|
30
91
|
const response = await makeRequest('GET', path);
|
|
31
92
|
const raw = response.data.info;
|
|
93
|
+
if (!raw)
|
|
94
|
+
return null;
|
|
32
95
|
const mappedCoverageInfo = {
|
|
33
96
|
financerId: raw.id_financiador,
|
|
34
97
|
defaultAffiliationId: raw.id_afiliacion_default,
|
|
@@ -58,31 +121,16 @@ const getUserMethods = (makeRequest, url, credentials) => {
|
|
|
58
121
|
: null,
|
|
59
122
|
};
|
|
60
123
|
return mappedCoverageInfo;
|
|
61
|
-
}
|
|
124
|
+
};
|
|
62
125
|
return {
|
|
63
|
-
declareUser: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.
|
|
126
|
+
declareUser: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.declareUserParams]), schemas_1.doc24Schemas.declareUserResponse, declareUser),
|
|
127
|
+
getUserId: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.user]), zod_1.number(), getUserId),
|
|
128
|
+
sendVerificationCode: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.sendVerificationCodeParams]), zod_1.void(), sendVerificationCode),
|
|
64
129
|
getUserInstance: validation_1.validateFunction(zod_1.tuple([zod_1.union([schemas_1.doc24Schemas.user, zod_1.number()])]),
|
|
65
130
|
// 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,
|
|
131
|
+
zod_1.any(), getUserInstance),
|
|
132
|
+
enroll: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.enrollmentParams]), zod_1.void(), enroll),
|
|
133
|
+
getCoverageInfo: validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.coverageInfo, getCoverageInfo),
|
|
86
134
|
};
|
|
87
135
|
};
|
|
88
136
|
exports.getUserMethods = getUserMethods;
|