@integraciones_doc24/sdk 1.15.6 → 1.15.8
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 +2 -2
- package/lib/baseSdk/index.js +3 -0
- package/lib/baseSdk/user.d.ts +60 -10
- package/lib/baseSdk/user.js +74 -26
- package/lib/index.d.ts +242 -37
- package/lib/schemas.d.ts +770 -85
- package/lib/schemas.js +152 -41
- package/lib/types.d.ts +39 -8
- package/lib/userSdk/chat.d.ts +2 -2
- package/lib/userSdk/external.d.ts +1 -1
- package/lib/userSdk/external.js +2 -1
- 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 +8 -3
- package/lib/userSdk/schedule.js +25 -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/userSdk/schedule.js
CHANGED
|
@@ -7,16 +7,24 @@ const validation_1 = require("../request/validation");
|
|
|
7
7
|
const schemas_1 = require("../schemas");
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
9
|
const getScheduleMethods = (makeRequest) => {
|
|
10
|
-
const getScheduleDates =
|
|
10
|
+
const getScheduleDates = async (patientId, filter = {}) => {
|
|
11
|
+
var _a;
|
|
11
12
|
const mappedFilter = {
|
|
12
13
|
specialty_id: filter.specialtyId,
|
|
13
14
|
professional_id: filter.professionalId,
|
|
15
|
+
language: (_a = filter.language) !== null && _a !== void 0 ? _a : 'ES',
|
|
14
16
|
};
|
|
15
17
|
const path = `/schedule/dates/${patientId}/${JSON.stringify(mappedFilter)}`;
|
|
16
18
|
const response = await makeRequest('GET', path);
|
|
17
|
-
return response.data.available_dates.map((o) =>
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
return response.data.available_dates.map((o) => {
|
|
20
|
+
return {
|
|
21
|
+
appointmentDate: utils_1.parseDate(o.date, o.time_zone),
|
|
22
|
+
consultation_value: o.consultation_value
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
const getSchedule = async (patientId, specialtyId, filter = {}) => {
|
|
27
|
+
var _a;
|
|
20
28
|
const mappedFilter = {
|
|
21
29
|
id_professional: filter.professionalId,
|
|
22
30
|
offset: filter.offset,
|
|
@@ -25,12 +33,13 @@ const getScheduleMethods = (makeRequest) => {
|
|
|
25
33
|
date: filter.date && date_fns_1.format(filter.date, 'yyyy-MM-dd'),
|
|
26
34
|
start_hour: filter.startHour,
|
|
27
35
|
finish_hour: filter.finishHour,
|
|
36
|
+
language: (_a = filter.language) !== null && _a !== void 0 ? _a : 'ES',
|
|
28
37
|
};
|
|
29
38
|
const path = `/schedule/availability/${patientId}/${specialtyId}/${JSON.stringify(mappedFilter)}`;
|
|
30
39
|
const response = await makeRequest('GET', path);
|
|
31
40
|
return response.data.available_appointments.map((a) => ({
|
|
32
41
|
id: a.id,
|
|
33
|
-
date: utils_1.parseDateTime(`${a.date} ${a.hour}
|
|
42
|
+
date: utils_1.parseDateTime(`${a.date} ${a.hour}`, a.time_zone),
|
|
34
43
|
clinicId: a.clinic,
|
|
35
44
|
professional: {
|
|
36
45
|
id: a.professional_id,
|
|
@@ -47,30 +56,30 @@ const getScheduleMethods = (makeRequest) => {
|
|
|
47
56
|
ranking: a.ranking,
|
|
48
57
|
length: a.length,
|
|
49
58
|
}));
|
|
50
|
-
}
|
|
51
|
-
const getAppointment =
|
|
59
|
+
};
|
|
60
|
+
const getAppointment = async (appointmentId) => {
|
|
52
61
|
const path = `/appointment/${appointmentId}`;
|
|
53
62
|
const response = await makeRequest('GET', path);
|
|
54
63
|
return {
|
|
55
64
|
id: response.data.id,
|
|
56
65
|
professionalId: response.data.professional_id,
|
|
57
|
-
date: utils_1.parseDateTime(`${response.data.date} ${response.data.hour}
|
|
66
|
+
date: utils_1.parseDateTime(`${response.data.date} ${response.data.hour}`, response.data.time_zone),
|
|
58
67
|
};
|
|
59
|
-
}
|
|
60
|
-
const getAppointmentByVcToken =
|
|
68
|
+
};
|
|
69
|
+
const getAppointmentByVcToken = async (vcToken) => {
|
|
61
70
|
const path = `/appointmentByToken/${vcToken}`;
|
|
62
71
|
const response = await makeRequest('GET', path);
|
|
63
72
|
return {
|
|
64
73
|
id: response.data.id,
|
|
65
74
|
professionalId: response.data.professional_id,
|
|
66
|
-
date: utils_1.parseDateTime(`${response.data.date} ${response.data.hour}
|
|
75
|
+
date: utils_1.parseDateTime(`${response.data.date} ${response.data.hour}`, response.data.time_zone),
|
|
67
76
|
};
|
|
68
|
-
}
|
|
77
|
+
};
|
|
69
78
|
return {
|
|
70
|
-
getSchedule,
|
|
71
|
-
getScheduleDates,
|
|
72
|
-
getAppointment,
|
|
73
|
-
getAppointmentByVcToken,
|
|
79
|
+
getSchedule: validation_1.validateFunction(zod_1.tuple([zod_1.number(), zod_1.number(), schemas_1.doc24Schemas.scheduleFilter.optional()]), zod_1.array(schemas_1.doc24Schemas.availableAppointment), getSchedule),
|
|
80
|
+
getScheduleDates: validation_1.validateFunction(zod_1.tuple([zod_1.number(), schemas_1.doc24Schemas.scheduleAvailabilityFilter]), zod_1.array(zod_1.object({ appointmentDate: zod_1.date(), consultation_value: zod_1.number().optional().nullish() })), getScheduleDates),
|
|
81
|
+
getAppointment: validation_1.validateFunction(zod_1.tuple([zod_1.number()]), schemas_1.doc24Schemas.appointment, getAppointment),
|
|
82
|
+
getAppointmentByVcToken: validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.appointment, getAppointmentByVcToken),
|
|
74
83
|
};
|
|
75
84
|
};
|
|
76
85
|
exports.getScheduleMethods = getScheduleMethods;
|
|
@@ -32,9 +32,9 @@ export declare const getVideoVisitMethods: (makeRequest: RequestMaker) => {
|
|
|
32
32
|
patientId: number;
|
|
33
33
|
creationDate: Date;
|
|
34
34
|
user: {
|
|
35
|
-
id: number;
|
|
36
35
|
phone: string | null;
|
|
37
36
|
email: string | null;
|
|
37
|
+
id: number;
|
|
38
38
|
};
|
|
39
39
|
vcToken: string;
|
|
40
40
|
}>;
|
|
@@ -51,13 +51,15 @@ export declare const getVideoVisitMethods: (makeRequest: RequestMaker) => {
|
|
|
51
51
|
atentionId?: number | undefined;
|
|
52
52
|
id: number | null;
|
|
53
53
|
patientId: number;
|
|
54
|
+
professional: string;
|
|
54
55
|
creationDate: Date;
|
|
55
56
|
user: {
|
|
56
|
-
id: number;
|
|
57
57
|
phone: string | null;
|
|
58
58
|
email: string | null;
|
|
59
|
+
id: number;
|
|
59
60
|
};
|
|
60
61
|
vcToken: string;
|
|
62
|
+
specialty: string;
|
|
61
63
|
}[]>;
|
|
62
64
|
getVideoVisitDetails: (vcId: number) => Promise<{
|
|
63
65
|
professional?: {
|
|
@@ -33,10 +33,10 @@ const getVideoVisitMethods = (makeRequest) => {
|
|
|
33
33
|
const response = await makeRequest('GET', path);
|
|
34
34
|
return mapVideoVisit(response.data);
|
|
35
35
|
});
|
|
36
|
-
const getPatientVideoVisitHistory = validation_1.validateFunction(zod_1.tuple([zod_1.number()]), zod_1.array(schemas_1.doc24Schemas.
|
|
36
|
+
const getPatientVideoVisitHistory = validation_1.validateFunction(zod_1.tuple([zod_1.number()]), zod_1.array(schemas_1.doc24Schemas.historicalVideoVisit), async (patientId) => {
|
|
37
37
|
const path = `/video-visit-history/${patientId}`;
|
|
38
38
|
const response = await makeRequest('GET', path);
|
|
39
|
-
return response.data.map((raw) =>
|
|
39
|
+
return response.data.map((raw) => mapHistoricalVideoVisit(raw));
|
|
40
40
|
});
|
|
41
41
|
const getVideoVisitDetails = validation_1.validateFunction(zod_1.tuple([zod_1.number()]), schemas_1.doc24Schemas.videoVisitDetails, async (vcId) => {
|
|
42
42
|
const path = `/video-visit-records/${vcId}`;
|
|
@@ -65,7 +65,7 @@ const getVideoVisitMethods = (makeRequest) => {
|
|
|
65
65
|
appointment: response.data.appointment_id
|
|
66
66
|
? {
|
|
67
67
|
id: response.data.appointment_id,
|
|
68
|
-
date: utils_1.parseDateTime(`${response.data.appointment_date} ${response.data.appointment_time}
|
|
68
|
+
date: utils_1.parseDateTime(`${response.data.appointment_date} ${response.data.appointment_time}`, response.data.time_zone),
|
|
69
69
|
}
|
|
70
70
|
: null,
|
|
71
71
|
report: {
|
|
@@ -135,7 +135,7 @@ const mapVideoVisit = (raw) => {
|
|
|
135
135
|
appointment: raw.appointment_id
|
|
136
136
|
? {
|
|
137
137
|
id: raw.appointment_id,
|
|
138
|
-
date: utils_1.parseDateTime(`${raw.appointment_date} ${raw.appointment_time}
|
|
138
|
+
date: utils_1.parseDateTime(`${raw.appointment_date} ${raw.appointment_time}`, raw.time_zone),
|
|
139
139
|
}
|
|
140
140
|
: undefined,
|
|
141
141
|
videoVisit: raw.video_visit_id
|
|
@@ -145,3 +145,10 @@ const mapVideoVisit = (raw) => {
|
|
|
145
145
|
atentionId: (_b = raw.atentionId) !== null && _b !== void 0 ? _b : undefined,
|
|
146
146
|
};
|
|
147
147
|
};
|
|
148
|
+
const mapHistoricalVideoVisit = (raw) => {
|
|
149
|
+
return {
|
|
150
|
+
...mapVideoVisit(raw),
|
|
151
|
+
professional: raw.professional,
|
|
152
|
+
specialty: raw.specialty,
|
|
153
|
+
};
|
|
154
|
+
};
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const parseDateTime: (str: string) => Date;
|
|
4
|
-
export declare const getIndetificationTypeId: (type: Doc24.IdentificationType) => 1 | 6 | 5 | 999 | 1000 | 9 | 7;
|
|
1
|
+
export declare const parseDate: (str: string, timeZone?: string | null | undefined) => Date;
|
|
2
|
+
export declare const parseDateTime: (str: string, timeZone?: string | null | undefined) => Date;
|
package/lib/utils.js
CHANGED
|
@@ -1,27 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.parseDateTime = exports.parseDate = void 0;
|
|
4
4
|
const date_fns_1 = require("date-fns");
|
|
5
|
-
|
|
6
|
-
const
|
|
5
|
+
// import {Doc24} from '.';
|
|
6
|
+
const defaultTimeZone = '-03';
|
|
7
|
+
const parseDate = (str, timeZone) => exports.parseDateTime(`${str} 00:00:00`, timeZone);
|
|
7
8
|
exports.parseDate = parseDate;
|
|
8
|
-
const parseDateTime = (str) => date_fns_1.parse(`${str} ${timeZone}`, 'yyyy-MM-dd HH:mm:ss X', new Date());
|
|
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());
|
|
9
10
|
exports.parseDateTime = parseDateTime;
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return 5;
|
|
17
|
-
if (type === 'credential')
|
|
18
|
-
return 999;
|
|
19
|
-
if (type === 'nn')
|
|
20
|
-
return 1000;
|
|
21
|
-
if (type === 'cpf')
|
|
22
|
-
return 9;
|
|
23
|
-
if (type === 'rg')
|
|
24
|
-
return 7;
|
|
25
|
-
throw new Error('Invalid identificationType');
|
|
26
|
-
};
|
|
27
|
-
exports.getIndetificationTypeId = getIndetificationTypeId;
|
|
11
|
+
// export const getIdetificationTypeId = (type: Doc24.IdentificationType) => {
|
|
12
|
+
// if (type === 'ndi') return 6;
|
|
13
|
+
// if (type === 'passport') return 5;
|
|
14
|
+
// if (type === 'credential') return 999;
|
|
15
|
+
// throw new Error('Invalid identificationType');
|
|
16
|
+
// };
|
package/lib/webhook/index.js
CHANGED
|
@@ -41,6 +41,7 @@ const handleEvent = async (body, _baseSdk, eventHandlers) => {
|
|
|
41
41
|
return (_c = eventHandlers.onAppointmentStatusChange) === null || _c === void 0 ? void 0 : _c.call(eventHandlers, {
|
|
42
42
|
id: Number(body.id_turno),
|
|
43
43
|
status: body.id_estado,
|
|
44
|
+
vcToken: body.vc_token,
|
|
44
45
|
changeDate: date,
|
|
45
46
|
});
|
|
46
47
|
if (body.tipo === 'chat')
|