@integraciones_doc24/sdk 1.16.33 → 1.16.35
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/schemas.d.ts +17 -0
- package/lib/schemas.js +7 -0
- package/lib/types.d.ts +4 -1
- package/lib/userSdk/schedule.js +3 -8
- package/lib/userSdk/videoVisit.d.ts +7 -1
- package/lib/userSdk/videoVisit.js +15 -6
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +26 -1
- package/package.json +1 -1
package/lib/schemas.d.ts
CHANGED
|
@@ -2510,6 +2510,23 @@ export declare const doc24Schemas: {
|
|
|
2510
2510
|
vcToken: string;
|
|
2511
2511
|
attachedFile: string;
|
|
2512
2512
|
}>;
|
|
2513
|
+
uploadFileConsultationResponse: import("zod").ZodObject<{
|
|
2514
|
+
fileId: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
2515
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
2516
|
+
fileId?: number | undefined;
|
|
2517
|
+
}, {
|
|
2518
|
+
fileId?: number | undefined;
|
|
2519
|
+
}>;
|
|
2520
|
+
deleteFileConsultationParams: import("zod").ZodObject<{
|
|
2521
|
+
vcToken: import("zod").ZodString;
|
|
2522
|
+
fileId: import("zod").ZodNumber;
|
|
2523
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
2524
|
+
vcToken: string;
|
|
2525
|
+
fileId: number;
|
|
2526
|
+
}, {
|
|
2527
|
+
vcToken: string;
|
|
2528
|
+
fileId: number;
|
|
2529
|
+
}>;
|
|
2513
2530
|
healthQuizParams: import("zod").ZodObject<{
|
|
2514
2531
|
patientId: import("zod").ZodNumber;
|
|
2515
2532
|
quiz: import("zod").ZodRecord<import("zod").ZodAny>;
|
package/lib/schemas.js
CHANGED
|
@@ -542,6 +542,13 @@ exports.doc24Schemas = {
|
|
|
542
542
|
attachedFile: zod_1.string(),
|
|
543
543
|
fileName: zod_1.string().optional(),
|
|
544
544
|
}),
|
|
545
|
+
uploadFileConsultationResponse: zod_1.object({
|
|
546
|
+
fileId: zod_1.number().optional(),
|
|
547
|
+
}),
|
|
548
|
+
deleteFileConsultationParams: zod_1.object({
|
|
549
|
+
vcToken: zod_1.string(),
|
|
550
|
+
fileId: zod_1.number(),
|
|
551
|
+
}),
|
|
545
552
|
healthQuizParams: zod_1.object({
|
|
546
553
|
patientId: zod_1.number(),
|
|
547
554
|
quiz: zod_1.record(zod_1.any()),
|
package/lib/types.d.ts
CHANGED
|
@@ -51,6 +51,8 @@ export declare namespace Doc24 {
|
|
|
51
51
|
type BinahWellnessResponse = TypeOf<typeof doc24Schemas.binahWellnessResponse>;
|
|
52
52
|
type ProfessionalsBySpecialtyFilter = TypeOf<typeof doc24Schemas.professionalsBySpecialtyFilter>;
|
|
53
53
|
type UploadFileConsultationParams = TypeOf<typeof doc24Schemas.uploadFileConsultationParams>;
|
|
54
|
+
type UploadFileConsultationResponse = TypeOf<typeof doc24Schemas.uploadFileConsultationResponse>;
|
|
55
|
+
type DeleteFileConsultationParams = TypeOf<typeof doc24Schemas.deleteFileConsultationParams>;
|
|
54
56
|
type HealthQuizParams = TypeOf<typeof doc24Schemas.healthQuizParams>;
|
|
55
57
|
type BaseSdk = {
|
|
56
58
|
declareUser: (params: DeclareUserParams) => Promise<DeclareUserResponse>;
|
|
@@ -103,7 +105,8 @@ export declare namespace Doc24 {
|
|
|
103
105
|
submitHealthQuiz: (params: HealthQuizParams) => Promise<void>;
|
|
104
106
|
userId: number;
|
|
105
107
|
getBinahWellnessLink: (body: BinahWellnessGetLinkParams) => Promise<BinahWellnessResponse>;
|
|
106
|
-
uploadFileConsultation: (params: UploadFileConsultationParams) => Promise<
|
|
108
|
+
uploadFileConsultation: (params: UploadFileConsultationParams) => Promise<UploadFileConsultationResponse>;
|
|
109
|
+
deleteFileConsultation: (params: DeleteFileConsultationParams) => Promise<void>;
|
|
107
110
|
};
|
|
108
111
|
namespace Webhook {
|
|
109
112
|
type StatusChangeEventStatus = 'S' | 'C' | 'F' | 'A' | 'D' | 'L';
|
package/lib/userSdk/schedule.js
CHANGED
|
@@ -17,9 +17,6 @@ const getScheduleMethods = (makeRequest) => {
|
|
|
17
17
|
};
|
|
18
18
|
const path = `/schedule/dates/${patientId}/${JSON.stringify(mappedFilter)}`;
|
|
19
19
|
const response = await makeRequest('GET', path);
|
|
20
|
-
// Doc24 devuelve fecha/hora en el user_time_zone enviado (o en -03 si no
|
|
21
|
-
// se envía). `time_zone` de la respuesta es el de la marca, no el de la
|
|
22
|
-
// hora: no usarlo para parsear.
|
|
23
20
|
return response.data.available_dates.map((o) => utils_1.parseDate(o.date, filter.userTimeZone));
|
|
24
21
|
};
|
|
25
22
|
const getSchedule = async (patientId, specialtyId, filter = {}) => {
|
|
@@ -40,7 +37,7 @@ const getScheduleMethods = (makeRequest) => {
|
|
|
40
37
|
const response = await makeRequest('GET', path);
|
|
41
38
|
return response.data.available_appointments.map((a) => ({
|
|
42
39
|
id: a.id,
|
|
43
|
-
date: utils_1.parseDateTime(`${a.date} ${a.hour}`, filter.userTimeZone),
|
|
40
|
+
date: utils_1.parseDateTime(`${a.date} ${a.hour}`, utils_1.getConvertedHourTimeZone(filter.userTimeZone, a.time_zone)),
|
|
44
41
|
clinicId: a.clinic,
|
|
45
42
|
professional: {
|
|
46
43
|
id: a.professional_id,
|
|
@@ -71,8 +68,7 @@ const getScheduleMethods = (makeRequest) => {
|
|
|
71
68
|
return {
|
|
72
69
|
id: response.data.id,
|
|
73
70
|
professionalId: response.data.professional_id,
|
|
74
|
-
|
|
75
|
-
date: utils_1.parseDateTime(`${response.data.date} ${response.data.hour}`),
|
|
71
|
+
date: utils_1.parseDateTime(`${response.data.date} ${response.data.hour}`, response.data.time_zone),
|
|
76
72
|
};
|
|
77
73
|
};
|
|
78
74
|
const getAppointmentByVcToken = async (vcToken) => {
|
|
@@ -81,8 +77,7 @@ const getScheduleMethods = (makeRequest) => {
|
|
|
81
77
|
return {
|
|
82
78
|
id: response.data.id,
|
|
83
79
|
professionalId: response.data.professional_id,
|
|
84
|
-
|
|
85
|
-
date: utils_1.parseDateTime(`${response.data.date} ${response.data.hour}`),
|
|
80
|
+
date: utils_1.parseDateTime(`${response.data.date} ${response.data.hour}`, response.data.time_zone),
|
|
86
81
|
};
|
|
87
82
|
};
|
|
88
83
|
return {
|
|
@@ -184,5 +184,11 @@ export declare const getVideoVisitMethods: (makeRequest: RequestMaker) => {
|
|
|
184
184
|
fileName?: string | undefined;
|
|
185
185
|
vcToken: string;
|
|
186
186
|
attachedFile: string;
|
|
187
|
-
}) => Promise<
|
|
187
|
+
}) => Promise<{
|
|
188
|
+
fileId?: number | undefined;
|
|
189
|
+
}>;
|
|
190
|
+
deleteFileConsultation: (params: {
|
|
191
|
+
vcToken: string;
|
|
192
|
+
fileId: number;
|
|
193
|
+
}) => Promise<void>;
|
|
188
194
|
};
|
|
@@ -71,8 +71,7 @@ const getVideoVisitMethods = (makeRequest) => {
|
|
|
71
71
|
appointment: response.data.appointment_id
|
|
72
72
|
? {
|
|
73
73
|
id: response.data.appointment_id,
|
|
74
|
-
|
|
75
|
-
date: utils_1.parseDateTime(`${response.data.appointment_date} ${response.data.appointment_time}`),
|
|
74
|
+
date: utils_1.parseDateTime(`${response.data.appointment_date} ${response.data.appointment_time}`, response.data.time_zone),
|
|
76
75
|
}
|
|
77
76
|
: null,
|
|
78
77
|
report: {
|
|
@@ -197,14 +196,24 @@ const getVideoVisitMethods = (makeRequest) => {
|
|
|
197
196
|
})),
|
|
198
197
|
};
|
|
199
198
|
});
|
|
200
|
-
const uploadFileConsultation = validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.uploadFileConsultationParams]),
|
|
199
|
+
const uploadFileConsultation = validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.uploadFileConsultationParams]), schemas_1.doc24Schemas.uploadFileConsultationResponse, async (params) => {
|
|
201
200
|
const form = new form_data_1.default();
|
|
202
201
|
form.append('vc_token', params.vcToken);
|
|
203
202
|
form.append('attached_file', fs_1.default.createReadStream(params.attachedFile));
|
|
204
203
|
if (params.fileName)
|
|
205
204
|
form.append('file_name', params.fileName);
|
|
206
205
|
const response = await makeRequest('POST', '/upload-file-consultation', form);
|
|
207
|
-
|
|
206
|
+
// Unlike most doc24 endpoints, this one is not wrapped in `data`:
|
|
207
|
+
// {status, message, file_id}.
|
|
208
|
+
return {
|
|
209
|
+
fileId: response.file_id != null ? Number(response.file_id) : undefined,
|
|
210
|
+
};
|
|
211
|
+
});
|
|
212
|
+
const deleteFileConsultation = validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.deleteFileConsultationParams]), zod_1.undefined(), async (params) => {
|
|
213
|
+
await makeRequest('DELETE', '/delete-file-consultation', {
|
|
214
|
+
vc_token: params.vcToken,
|
|
215
|
+
file_id: params.fileId,
|
|
216
|
+
});
|
|
208
217
|
});
|
|
209
218
|
return {
|
|
210
219
|
scheduleVideoVisit,
|
|
@@ -216,6 +225,7 @@ const getVideoVisitMethods = (makeRequest) => {
|
|
|
216
225
|
getActiveVideoVisits,
|
|
217
226
|
getCompleteVideoVisitDetails,
|
|
218
227
|
uploadFileConsultation,
|
|
228
|
+
deleteFileConsultation,
|
|
219
229
|
};
|
|
220
230
|
};
|
|
221
231
|
exports.getVideoVisitMethods = getVideoVisitMethods;
|
|
@@ -230,8 +240,7 @@ const mapVideoVisit = (raw) => {
|
|
|
230
240
|
appointment: raw.appointment_id
|
|
231
241
|
? {
|
|
232
242
|
id: raw.appointment_id,
|
|
233
|
-
|
|
234
|
-
date: utils_1.parseDateTime(`${raw.appointment_date} ${raw.appointment_time}`),
|
|
243
|
+
date: utils_1.parseDateTime(`${raw.appointment_date} ${raw.appointment_time}`, raw.time_zone),
|
|
235
244
|
}
|
|
236
245
|
: undefined,
|
|
237
246
|
videoVisit: raw.video_visit_id
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare const parseDate: (str: string, timeZone?: string | null | undefined) => Date;
|
|
2
2
|
export declare const parseDateTime: (str: string, timeZone?: string | null | undefined) => Date;
|
|
3
|
+
export declare const getConvertedHourTimeZone: (userTimeZone?: string | null | undefined, professionalTimeZone?: string | null | undefined) => string;
|
|
3
4
|
export declare const normalizeTimezoneOffset: (raw?: string | undefined, defualtTimezone?: number) => string | undefined;
|
package/lib/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeTimezoneOffset = exports.parseDateTime = exports.parseDate = void 0;
|
|
3
|
+
exports.normalizeTimezoneOffset = exports.getConvertedHourTimeZone = exports.parseDateTime = exports.parseDate = void 0;
|
|
4
4
|
const date_fns_1 = require("date-fns");
|
|
5
5
|
// import {Doc24} from '.';
|
|
6
6
|
const defaultTimeZone = '-03';
|
|
@@ -8,6 +8,31 @@ const parseDate = (str, timeZone) => exports.parseDateTime(`${str} 00:00:00`, ti
|
|
|
8
8
|
exports.parseDate = parseDate;
|
|
9
9
|
const parseDateTime = (str, timeZone) => date_fns_1.parse(`${str} ${timeZone !== null && timeZone !== void 0 ? timeZone : defaultTimeZone}`, 'yyyy-MM-dd HH:mm:ss X', new Date());
|
|
10
10
|
exports.parseDateTime = parseDateTime;
|
|
11
|
+
const offsetToMinutes = (offset) => {
|
|
12
|
+
var _a;
|
|
13
|
+
const match = offset === null || offset === void 0 ? void 0 : offset.trim().match(/^([+-])(\d{1,2}):?(\d{2})?$/);
|
|
14
|
+
if (!match)
|
|
15
|
+
return undefined;
|
|
16
|
+
const minutes = Number(match[2]) * 60 + Number((_a = match[3]) !== null && _a !== void 0 ? _a : 0);
|
|
17
|
+
return match[1] === '-' ? -minutes : minutes;
|
|
18
|
+
};
|
|
19
|
+
const minutesToOffset = (minutes) => {
|
|
20
|
+
const abs = Math.abs(minutes);
|
|
21
|
+
const hh = Math.floor(abs / 60).toString().padStart(2, '0');
|
|
22
|
+
const mm = (abs % 60).toString().padStart(2, '0');
|
|
23
|
+
return `${minutes < 0 ? '-' : '+'}${hh}${mm === '00' ? '' : mm}`;
|
|
24
|
+
};
|
|
25
|
+
// WEH-1702: doc24 convierte la hora local del médico (en `time_zone`) al
|
|
26
|
+
// user_time_zone como si estuviera en -03. Esta es la zona que deshace ese
|
|
27
|
+
// corrimiento. Revertir cuando doc24 convierta desde `time_zone`.
|
|
28
|
+
const getConvertedHourTimeZone = (userTimeZone, professionalTimeZone) => {
|
|
29
|
+
var _a, _b;
|
|
30
|
+
const ar = offsetToMinutes(defaultTimeZone);
|
|
31
|
+
const user = (_a = offsetToMinutes(userTimeZone)) !== null && _a !== void 0 ? _a : ar;
|
|
32
|
+
const professional = (_b = offsetToMinutes(professionalTimeZone)) !== null && _b !== void 0 ? _b : ar;
|
|
33
|
+
return minutesToOffset(user - ar + professional);
|
|
34
|
+
};
|
|
35
|
+
exports.getConvertedHourTimeZone = getConvertedHourTimeZone;
|
|
11
36
|
const normalizeTimezoneOffset = (raw, defualtTimezone = -3) => {
|
|
12
37
|
if (!raw)
|
|
13
38
|
return;
|