@integraciones_doc24/sdk 0.26.0 → 0.27.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 +1 -0
- package/lib/baseSdk.js +18 -0
- package/lib/index.d.ts +19 -4
- package/lib/schemas.d.ts +89 -18
- package/lib/schemas.js +18 -4
- package/lib/types.d.ts +2 -0
- package/lib/userSdk/videoVisit.d.ts +4 -4
- package/lib/webhook/index.js +12 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -68,6 +68,7 @@ type SdkParams = {
|
|
|
68
68
|
type BaseSdk = {
|
|
69
69
|
getUserInstance: (user: User) => Promise<UserSdk>;
|
|
70
70
|
getProfessional: (professionalId: number) => Promise<Professional>;
|
|
71
|
+
getAvailableScheduleClinics: () => Promise<AvailableScheduleClinics>
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
type RequestHandlerParams = {
|
package/lib/baseSdk.js
CHANGED
|
@@ -61,6 +61,24 @@ const getBaseSdk = async (url, credentials) => {
|
|
|
61
61
|
},
|
|
62
62
|
};
|
|
63
63
|
}),
|
|
64
|
+
getAvailableScheduleClinics: validation_1.validateFunction(zod_1.tuple([]), schemas_1.doc24Schemas.availableScheduleClinics, async () => {
|
|
65
|
+
const path = `/schedule/clinics`;
|
|
66
|
+
const response = await makeRequest('GET', path);
|
|
67
|
+
const mapSpeciality = (s) => ({
|
|
68
|
+
id: s.id_especialidad,
|
|
69
|
+
description: s.especialidad,
|
|
70
|
+
});
|
|
71
|
+
const mapped = {
|
|
72
|
+
specialties: response.data.specialties.map(mapSpeciality),
|
|
73
|
+
professionals: response.data.professionals.map((p) => ({
|
|
74
|
+
id: p.id_profesional,
|
|
75
|
+
fullName: p.denominacion,
|
|
76
|
+
clinicId: p.id_consultorio,
|
|
77
|
+
specialties: p.especialidades.map(mapSpeciality),
|
|
78
|
+
})),
|
|
79
|
+
};
|
|
80
|
+
return mapped;
|
|
81
|
+
}),
|
|
64
82
|
};
|
|
65
83
|
return baseSdk;
|
|
66
84
|
};
|
package/lib/index.d.ts
CHANGED
|
@@ -36,14 +36,14 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
|
|
|
36
36
|
gender: "m" | "f";
|
|
37
37
|
phone: string;
|
|
38
38
|
email: string;
|
|
39
|
-
matriculation: {
|
|
40
|
-
number: string;
|
|
41
|
-
type: string;
|
|
42
|
-
}[];
|
|
43
39
|
specialties: {
|
|
44
40
|
id: number;
|
|
45
41
|
description: string;
|
|
46
42
|
}[];
|
|
43
|
+
matriculation: {
|
|
44
|
+
number: string;
|
|
45
|
+
type: string;
|
|
46
|
+
}[];
|
|
47
47
|
degree: string;
|
|
48
48
|
languages: string[];
|
|
49
49
|
resume: {
|
|
@@ -51,5 +51,20 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
|
|
|
51
51
|
brief: string;
|
|
52
52
|
};
|
|
53
53
|
}>;
|
|
54
|
+
getAvailableScheduleClinics: () => Promise<{
|
|
55
|
+
specialties: {
|
|
56
|
+
id: number;
|
|
57
|
+
description: string;
|
|
58
|
+
}[];
|
|
59
|
+
professionals: {
|
|
60
|
+
id: number;
|
|
61
|
+
fullName: string;
|
|
62
|
+
clinicId: number;
|
|
63
|
+
specialties: {
|
|
64
|
+
id: number;
|
|
65
|
+
description: string;
|
|
66
|
+
}[];
|
|
67
|
+
}[];
|
|
68
|
+
}>;
|
|
54
69
|
}>;
|
|
55
70
|
export type { Doc24 } from './types';
|
package/lib/schemas.d.ts
CHANGED
|
@@ -179,6 +179,77 @@ export declare const doc24Schemas: {
|
|
|
179
179
|
};
|
|
180
180
|
atentions: number;
|
|
181
181
|
}>;
|
|
182
|
+
availableScheduleClinics: import("zod").ZodObject<{
|
|
183
|
+
specialties: import("zod").ZodArray<import("zod").ZodObject<{
|
|
184
|
+
id: import("zod").ZodNumber;
|
|
185
|
+
description: import("zod").ZodString;
|
|
186
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
187
|
+
id: number;
|
|
188
|
+
description: string;
|
|
189
|
+
}, {
|
|
190
|
+
id: number;
|
|
191
|
+
description: string;
|
|
192
|
+
}>, "many">;
|
|
193
|
+
professionals: import("zod").ZodArray<import("zod").ZodObject<{
|
|
194
|
+
id: import("zod").ZodNumber;
|
|
195
|
+
fullName: import("zod").ZodString;
|
|
196
|
+
clinicId: import("zod").ZodNumber;
|
|
197
|
+
specialties: import("zod").ZodArray<import("zod").ZodObject<{
|
|
198
|
+
id: import("zod").ZodNumber;
|
|
199
|
+
description: import("zod").ZodString;
|
|
200
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
201
|
+
id: number;
|
|
202
|
+
description: string;
|
|
203
|
+
}, {
|
|
204
|
+
id: number;
|
|
205
|
+
description: string;
|
|
206
|
+
}>, "many">;
|
|
207
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
208
|
+
id: number;
|
|
209
|
+
fullName: string;
|
|
210
|
+
clinicId: number;
|
|
211
|
+
specialties: {
|
|
212
|
+
id: number;
|
|
213
|
+
description: string;
|
|
214
|
+
}[];
|
|
215
|
+
}, {
|
|
216
|
+
id: number;
|
|
217
|
+
fullName: string;
|
|
218
|
+
clinicId: number;
|
|
219
|
+
specialties: {
|
|
220
|
+
id: number;
|
|
221
|
+
description: string;
|
|
222
|
+
}[];
|
|
223
|
+
}>, "many">;
|
|
224
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
225
|
+
specialties: {
|
|
226
|
+
id: number;
|
|
227
|
+
description: string;
|
|
228
|
+
}[];
|
|
229
|
+
professionals: {
|
|
230
|
+
id: number;
|
|
231
|
+
fullName: string;
|
|
232
|
+
clinicId: number;
|
|
233
|
+
specialties: {
|
|
234
|
+
id: number;
|
|
235
|
+
description: string;
|
|
236
|
+
}[];
|
|
237
|
+
}[];
|
|
238
|
+
}, {
|
|
239
|
+
specialties: {
|
|
240
|
+
id: number;
|
|
241
|
+
description: string;
|
|
242
|
+
}[];
|
|
243
|
+
professionals: {
|
|
244
|
+
id: number;
|
|
245
|
+
fullName: string;
|
|
246
|
+
clinicId: number;
|
|
247
|
+
specialties: {
|
|
248
|
+
id: number;
|
|
249
|
+
description: string;
|
|
250
|
+
}[];
|
|
251
|
+
}[];
|
|
252
|
+
}>;
|
|
182
253
|
scheduleFilter: import("zod").ZodObject<{
|
|
183
254
|
professionalId: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
184
255
|
offset: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
@@ -258,16 +329,16 @@ export declare const doc24Schemas: {
|
|
|
258
329
|
patientId: import("zod").ZodNumber;
|
|
259
330
|
user: import("zod").ZodObject<{
|
|
260
331
|
id: import("zod").ZodNumber;
|
|
261
|
-
email: import("zod").ZodString
|
|
262
|
-
phone: import("zod").ZodString
|
|
332
|
+
email: import("zod").ZodNullable<import("zod").ZodString>;
|
|
333
|
+
phone: import("zod").ZodNullable<import("zod").ZodString>;
|
|
263
334
|
}, "strip", import("zod").ZodTypeAny, {
|
|
264
335
|
id: number;
|
|
265
|
-
phone: string;
|
|
266
|
-
email: string;
|
|
336
|
+
phone: string | null;
|
|
337
|
+
email: string | null;
|
|
267
338
|
}, {
|
|
268
339
|
id: number;
|
|
269
|
-
phone: string;
|
|
270
|
-
email: string;
|
|
340
|
+
phone: string | null;
|
|
341
|
+
email: string | null;
|
|
271
342
|
}>;
|
|
272
343
|
vcToken: import("zod").ZodString;
|
|
273
344
|
appointment: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
@@ -308,8 +379,8 @@ export declare const doc24Schemas: {
|
|
|
308
379
|
creationDate: Date;
|
|
309
380
|
user: {
|
|
310
381
|
id: number;
|
|
311
|
-
phone: string;
|
|
312
|
-
email: string;
|
|
382
|
+
phone: string | null;
|
|
383
|
+
email: string | null;
|
|
313
384
|
};
|
|
314
385
|
vcToken: string;
|
|
315
386
|
}, {
|
|
@@ -328,8 +399,8 @@ export declare const doc24Schemas: {
|
|
|
328
399
|
creationDate: Date;
|
|
329
400
|
user: {
|
|
330
401
|
id: number;
|
|
331
|
-
phone: string;
|
|
332
|
-
email: string;
|
|
402
|
+
phone: string | null;
|
|
403
|
+
email: string | null;
|
|
333
404
|
};
|
|
334
405
|
vcToken: string;
|
|
335
406
|
}>;
|
|
@@ -587,14 +658,14 @@ export declare const doc24Schemas: {
|
|
|
587
658
|
gender: "m" | "f";
|
|
588
659
|
phone: string;
|
|
589
660
|
email: string;
|
|
590
|
-
matriculation: {
|
|
591
|
-
number: string;
|
|
592
|
-
type: string;
|
|
593
|
-
}[];
|
|
594
661
|
specialties: {
|
|
595
662
|
id: number;
|
|
596
663
|
description: string;
|
|
597
664
|
}[];
|
|
665
|
+
matriculation: {
|
|
666
|
+
number: string;
|
|
667
|
+
type: string;
|
|
668
|
+
}[];
|
|
598
669
|
degree: string;
|
|
599
670
|
languages: string[];
|
|
600
671
|
resume: {
|
|
@@ -610,14 +681,14 @@ export declare const doc24Schemas: {
|
|
|
610
681
|
gender: "m" | "f";
|
|
611
682
|
phone: string;
|
|
612
683
|
email: string;
|
|
613
|
-
matriculation: {
|
|
614
|
-
number: string;
|
|
615
|
-
type: string;
|
|
616
|
-
}[];
|
|
617
684
|
specialties: {
|
|
618
685
|
id: number;
|
|
619
686
|
description: string;
|
|
620
687
|
}[];
|
|
688
|
+
matriculation: {
|
|
689
|
+
number: string;
|
|
690
|
+
type: string;
|
|
691
|
+
}[];
|
|
621
692
|
degree: string;
|
|
622
693
|
languages: string[];
|
|
623
694
|
resume: {
|
package/lib/schemas.js
CHANGED
|
@@ -43,18 +43,27 @@ const appointment = zod_1.object({
|
|
|
43
43
|
professionalId: zod_1.number(),
|
|
44
44
|
date: zod_1.date(),
|
|
45
45
|
});
|
|
46
|
-
const
|
|
46
|
+
const availableScheduleClinics = zod_1.object({
|
|
47
|
+
specialties: specialty.array(),
|
|
48
|
+
professionals: zod_1.object({
|
|
49
|
+
id: zod_1.number(),
|
|
50
|
+
fullName: zod_1.string(),
|
|
51
|
+
clinicId: zod_1.number(),
|
|
52
|
+
specialties: specialty.array(),
|
|
53
|
+
}).array(),
|
|
54
|
+
});
|
|
55
|
+
const baseScheduleParameters = zod_1.object({
|
|
47
56
|
patientId: zod_1.number(),
|
|
48
57
|
specialtyId: zod_1.number(),
|
|
49
58
|
language: zod_1.string(),
|
|
50
59
|
details: zod_1.string(),
|
|
51
60
|
extraInfo: zod_1.any(),
|
|
52
61
|
});
|
|
53
|
-
const appointmentScheduleParameters =
|
|
62
|
+
const appointmentScheduleParameters = baseScheduleParameters.extend({
|
|
54
63
|
type: zod_1.literal('appointment'),
|
|
55
64
|
appointmentId: zod_1.number().or(zod_1.string()),
|
|
56
65
|
});
|
|
57
|
-
const instantScheduleParameters =
|
|
66
|
+
const instantScheduleParameters = baseScheduleParameters.extend({
|
|
58
67
|
type: zod_1.literal('instant'),
|
|
59
68
|
});
|
|
60
69
|
const chatroomAvailabilityFilter = zod_1.object({
|
|
@@ -114,6 +123,7 @@ exports.doc24Schemas = {
|
|
|
114
123
|
specialty,
|
|
115
124
|
scheduleAvailabilityFilter,
|
|
116
125
|
availableAppointment,
|
|
126
|
+
availableScheduleClinics,
|
|
117
127
|
scheduleFilter: zod_1.object({
|
|
118
128
|
professionalId: zod_1.number().optional(),
|
|
119
129
|
offset: zod_1.number().optional(),
|
|
@@ -131,7 +141,11 @@ exports.doc24Schemas = {
|
|
|
131
141
|
id: zod_1.number().nullable(),
|
|
132
142
|
creationDate: zod_1.date(),
|
|
133
143
|
patientId: zod_1.number(),
|
|
134
|
-
user: zod_1.object({
|
|
144
|
+
user: zod_1.object({
|
|
145
|
+
id: zod_1.number(),
|
|
146
|
+
email: zod_1.string().nullable(),
|
|
147
|
+
phone: zod_1.string().nullable(),
|
|
148
|
+
}),
|
|
135
149
|
vcToken: zod_1.string(),
|
|
136
150
|
appointment: zod_1.object({
|
|
137
151
|
id: zod_1.number(),
|
package/lib/types.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare namespace Doc24 {
|
|
|
9
9
|
type Specialty = TypeOf<typeof doc24Schemas.specialty>;
|
|
10
10
|
type ScheduleAvailabilityFilter = TypeOf<typeof doc24Schemas.scheduleAvailabilityFilter>;
|
|
11
11
|
type AvailableAppointment = TypeOf<typeof doc24Schemas.availableAppointment>;
|
|
12
|
+
type AvailableScheduleClinics = TypeOf<typeof doc24Schemas.availableScheduleClinics>;
|
|
12
13
|
type ScheduleFilter = TypeOf<typeof doc24Schemas.scheduleFilter>;
|
|
13
14
|
type ScheduleParameters = TypeOf<typeof doc24Schemas.scheduleParameters>;
|
|
14
15
|
type VideoVisit = TypeOf<typeof doc24Schemas.videoVisit>;
|
|
@@ -26,6 +27,7 @@ export declare namespace Doc24 {
|
|
|
26
27
|
declareUser: (user: User) => Promise<number>;
|
|
27
28
|
getUserInstance: (user: User | number) => Promise<UserSdk>;
|
|
28
29
|
getProfessional: (professionalId: number) => Promise<Professional>;
|
|
30
|
+
getAvailableScheduleClinics: () => Promise<AvailableScheduleClinics>;
|
|
29
31
|
};
|
|
30
32
|
type UserSdk = {
|
|
31
33
|
declarePatient: (patient: Patient) => Promise<number>;
|
|
@@ -33,8 +33,8 @@ export declare const getVideoVisitMethods: (makeRequest: RequestMaker) => {
|
|
|
33
33
|
creationDate: Date;
|
|
34
34
|
user: {
|
|
35
35
|
id: number;
|
|
36
|
-
phone: string;
|
|
37
|
-
email: string;
|
|
36
|
+
phone: string | null;
|
|
37
|
+
email: string | null;
|
|
38
38
|
};
|
|
39
39
|
vcToken: string;
|
|
40
40
|
}>;
|
|
@@ -54,8 +54,8 @@ export declare const getVideoVisitMethods: (makeRequest: RequestMaker) => {
|
|
|
54
54
|
creationDate: Date;
|
|
55
55
|
user: {
|
|
56
56
|
id: number;
|
|
57
|
-
phone: string;
|
|
58
|
-
email: string;
|
|
57
|
+
phone: string | null;
|
|
58
|
+
email: string | null;
|
|
59
59
|
};
|
|
60
60
|
vcToken: string;
|
|
61
61
|
}[]>;
|
package/lib/webhook/index.js
CHANGED
|
@@ -9,46 +9,46 @@ const getRequestHandler = (credentials, baseSdk, eventHandlers) => async (reques
|
|
|
9
9
|
if (!tokenPayload)
|
|
10
10
|
return responses_1.unauthorizedErrorResponse();
|
|
11
11
|
const body = request.body;
|
|
12
|
-
const error = handleEvent(body, baseSdk, eventHandlers);
|
|
12
|
+
const error = await handleEvent(body, baseSdk, eventHandlers);
|
|
13
13
|
if (error)
|
|
14
14
|
return responses_1.unexpectedErrorResponse(error);
|
|
15
15
|
return responses_1.successResponse();
|
|
16
16
|
return responses_1.notFoundErrorResponse();
|
|
17
17
|
};
|
|
18
18
|
exports.getRequestHandler = getRequestHandler;
|
|
19
|
-
const handleEvent = (body, _baseSdk, eventHandlers) => {
|
|
19
|
+
const handleEvent = async (body, _baseSdk, eventHandlers) => {
|
|
20
20
|
var _a, _b, _c, _d;
|
|
21
21
|
const date = utils_1.parseDateTime(body.fecha_estado);
|
|
22
22
|
if (body.tipo === 'consulta')
|
|
23
23
|
return (_a = eventHandlers.onConsultationStatusChange) === null || _a === void 0 ? void 0 : _a.call(eventHandlers, {
|
|
24
|
-
id: body.id_consulta_virtual,
|
|
25
|
-
invitationId: body.id_invitacion,
|
|
24
|
+
id: Number(body.id_consulta_virtual),
|
|
25
|
+
invitationId: Number(body.id_invitacion),
|
|
26
26
|
status: body.id_estado,
|
|
27
27
|
changeDate: date,
|
|
28
28
|
vcToken: body.vc_token,
|
|
29
|
-
patientId: body.id_paciente,
|
|
29
|
+
patientId: body.id_paciente !== undefined ? Number(body.id_paciente) : undefined,
|
|
30
30
|
});
|
|
31
31
|
if (body.tipo === 'invitacion')
|
|
32
32
|
return (_b = eventHandlers.onInvitationStatusChange) === null || _b === void 0 ? void 0 : _b.call(eventHandlers, {
|
|
33
33
|
status: body.id_estado,
|
|
34
34
|
changeDate: date,
|
|
35
35
|
vcToken: body.vc_token,
|
|
36
|
-
appointmentId: body.id_turno,
|
|
37
|
-
patientId: body.id_persona,
|
|
38
|
-
professionalId: body.id_profesional
|
|
36
|
+
appointmentId: Number(body.id_turno),
|
|
37
|
+
patientId: Number(body.id_persona),
|
|
38
|
+
professionalId: Number(body.id_profesional),
|
|
39
39
|
});
|
|
40
40
|
if (body.tipo === 'turno')
|
|
41
41
|
return (_c = eventHandlers.onAppointmentStatusChange) === null || _c === void 0 ? void 0 : _c.call(eventHandlers, {
|
|
42
|
-
id: body.id_turno,
|
|
42
|
+
id: Number(body.id_turno),
|
|
43
43
|
status: body.id_estado,
|
|
44
44
|
changeDate: date,
|
|
45
45
|
});
|
|
46
46
|
if (body.tipo === 'chat')
|
|
47
47
|
return (_d = eventHandlers.onChatUpdate) === null || _d === void 0 ? void 0 : _d.call(eventHandlers, {
|
|
48
|
-
id: body.id_consulta_chat,
|
|
48
|
+
id: Number(body.id_consulta_chat),
|
|
49
49
|
status: body.estado_chat === 'A' ? 'active' : 'ended',
|
|
50
|
-
patientId: body.id_paciente,
|
|
51
|
-
professionalId: body.id_profesional,
|
|
50
|
+
patientId: Number(body.id_paciente),
|
|
51
|
+
professionalId: Number(body.id_profesional),
|
|
52
52
|
date,
|
|
53
53
|
});
|
|
54
54
|
return 'message_not_understood';
|