@integraciones_doc24/sdk 1.16.41 → 1.16.43
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 +246 -225
- package/lib/baseSdk/diagnostica.d.ts +54 -54
- package/lib/baseSdk/diagnostica.js +82 -82
- package/lib/baseSdk/external.d.ts +177 -177
- package/lib/baseSdk/external.js +96 -96
- package/lib/baseSdk/index.d.ts +2 -2
- package/lib/baseSdk/index.js +80 -80
- package/lib/baseSdk/integrationError.d.ts +16 -16
- package/lib/baseSdk/integrationError.js +33 -33
- package/lib/baseSdk/user.d.ts +115 -115
- package/lib/baseSdk/user.js +136 -136
- package/lib/index.d.ts +416 -416
- package/lib/index.js +22 -22
- package/lib/request/index.d.ts +4 -4
- package/lib/request/index.js +32 -32
- package/lib/request/token.d.ts +2 -2
- package/lib/request/token.js +34 -34
- package/lib/request/validation.d.ts +10 -10
- package/lib/request/validation.js +28 -28
- package/lib/schemas.d.ts +2813 -2825
- package/lib/schemas.js +601 -604
- package/lib/types.d.ts +178 -178
- package/lib/types.js +2 -2
- package/lib/userSdk/binah.d.ts +21 -21
- package/lib/userSdk/binah.js +20 -20
- package/lib/userSdk/chat.d.ts +57 -57
- package/lib/userSdk/chat.js +98 -98
- package/lib/userSdk/external.d.ts +34 -34
- package/lib/userSdk/external.js +72 -72
- package/lib/userSdk/index.d.ts +2 -2
- package/lib/userSdk/index.js +33 -33
- package/lib/userSdk/patients.d.ts +62 -62
- package/lib/userSdk/patients.js +93 -93
- package/lib/userSdk/schedule.d.ts +59 -59
- package/lib/userSdk/schedule.js +90 -90
- package/lib/userSdk/specialties.d.ts +19 -19
- package/lib/userSdk/specialties.js +48 -48
- package/lib/userSdk/videoVisit.d.ts +225 -229
- package/lib/userSdk/videoVisit.js +283 -288
- package/lib/utils.d.ts +4 -4
- package/lib/utils.js +68 -68
- package/lib/webhook/index.d.ts +2 -2
- package/lib/webhook/index.js +67 -67
- package/lib/webhook/responses.d.ts +35 -35
- package/lib/webhook/responses.js +42 -42
- package/lib/webhook/token.d.ts +2 -2
- package/lib/webhook/token.js +23 -23
- package/package.json +37 -37
|
@@ -1,288 +1,283 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getVideoVisitMethods = void 0;
|
|
7
|
-
const zod_1 = require("zod");
|
|
8
|
-
const validation_1 = require("../request/validation");
|
|
9
|
-
const schemas_1 = require("../schemas");
|
|
10
|
-
const utils_1 = require("../utils");
|
|
11
|
-
const fs_1 = __importDefault(require("fs"));
|
|
12
|
-
const form_data_1 = __importDefault(require("form-data"));
|
|
13
|
-
const getVideoVisitMethods = (makeRequest) => {
|
|
14
|
-
const scheduleVideoVisit = validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.scheduleParameters]), zod_1.string(), async (params) => {
|
|
15
|
-
const specificParams = params.type === 'appointment'
|
|
16
|
-
? {
|
|
17
|
-
type: 'P',
|
|
18
|
-
appointment_id: params.appointmentId,
|
|
19
|
-
modality: params.modality || 'A',
|
|
20
|
-
}
|
|
21
|
-
: { type: 'E' };
|
|
22
|
-
const mappedParams = {
|
|
23
|
-
...specificParams,
|
|
24
|
-
patient_id: params.patientId,
|
|
25
|
-
specialty_id: params.specialtyId,
|
|
26
|
-
language: params.language.toUpperCase(),
|
|
27
|
-
details: params.details,
|
|
28
|
-
extra_info: { ...params.extraInfo, modality: params.modality || 'A' },
|
|
29
|
-
};
|
|
30
|
-
const response = await makeRequest('POST', '/video-visit', mappedParams);
|
|
31
|
-
return response.data.vc_token;
|
|
32
|
-
});
|
|
33
|
-
const cancelVideoVisit = validation_1.validateFunction(zod_1.tuple([zod_1.string()]), zod_1.undefined(), async (vcToken) => {
|
|
34
|
-
const path = `/video-visit/${vcToken}`;
|
|
35
|
-
await makeRequest('DELETE', path);
|
|
36
|
-
});
|
|
37
|
-
const getVideoVisit = validation_1.validateFunction(zod_1.tuple([zod_1.string(), zod_1.number()]), schemas_1.doc24Schemas.videoVisit, async (vcToken, patientId) => {
|
|
38
|
-
const path = `/video-visit/${vcToken}/${patientId}`;
|
|
39
|
-
const response = await makeRequest('GET', path);
|
|
40
|
-
return mapVideoVisit(response.data);
|
|
41
|
-
});
|
|
42
|
-
const getPatientVideoVisitHistory = validation_1.validateFunction(zod_1.tuple([zod_1.number()]), zod_1.array(schemas_1.doc24Schemas.historicalVideoVisit), async (patientId) => {
|
|
43
|
-
const path = `/video-visit-history/${patientId}`;
|
|
44
|
-
const response = await makeRequest('GET', path);
|
|
45
|
-
return response.data.map((raw) => mapHistoricalVideoVisit(raw));
|
|
46
|
-
});
|
|
47
|
-
const getVideoVisitDetails = validation_1.validateFunction(zod_1.tuple([zod_1.number()]), schemas_1.doc24Schemas.videoVisitDetails, async (vcId) => {
|
|
48
|
-
var _a;
|
|
49
|
-
const path = `/video-visit-records/${vcId}`;
|
|
50
|
-
const response = await makeRequest('GET', path);
|
|
51
|
-
return {
|
|
52
|
-
id: response.data.consultation_id,
|
|
53
|
-
vcToken: (_a = response.data.vc_token) !== null && _a !== void 0 ? _a : undefined,
|
|
54
|
-
status: response.data.status,
|
|
55
|
-
paymentStatus: response.data.payment_status,
|
|
56
|
-
professional: response.data.professional_id
|
|
57
|
-
? {
|
|
58
|
-
id: response.data.professional_id,
|
|
59
|
-
fullName: response.data.professional,
|
|
60
|
-
}
|
|
61
|
-
: undefined,
|
|
62
|
-
patient: {
|
|
63
|
-
fullName: response.data.patient,
|
|
64
|
-
firstAccessDate: response.data.patient_first_access_date &&
|
|
65
|
-
utils_1.parseDateTime(response.data.patient_first_access_date),
|
|
66
|
-
lastAccessDate: response.data.patient_last_access_date &&
|
|
67
|
-
utils_1.parseDateTime(response.data.patient_last_access_date),
|
|
68
|
-
},
|
|
69
|
-
finishDate: response.data.finish_date &&
|
|
70
|
-
utils_1.parseDateTime(response.data.finish_date),
|
|
71
|
-
retries: response.data.retries,
|
|
72
|
-
language: response.data.language,
|
|
73
|
-
appointment: response.data.appointment_id
|
|
74
|
-
? {
|
|
75
|
-
id: response.data.appointment_id,
|
|
76
|
-
date: utils_1.parseDateTime(`${response.data.appointment_date} ${response.data.appointment_time}`, response.data.time_zone),
|
|
77
|
-
}
|
|
78
|
-
: null,
|
|
79
|
-
report: {
|
|
80
|
-
motive: response.data.motive,
|
|
81
|
-
actualDesease: response.data.actual_desease,
|
|
82
|
-
indications: response.data.indications,
|
|
83
|
-
alertSigns: response.data.alert_signs,
|
|
84
|
-
extendedMotive: response.data.extended_motive,
|
|
85
|
-
diagnose: response.data.diagnose.map((d) => ({
|
|
86
|
-
description: d.diagnostico,
|
|
87
|
-
code: d.codificacion,
|
|
88
|
-
})),
|
|
89
|
-
},
|
|
90
|
-
pdf: {
|
|
91
|
-
atention: response.data.pdf_atention
|
|
92
|
-
? response.data.pdf_atention
|
|
93
|
-
: undefined,
|
|
94
|
-
medication: response.data.pdf_medication,
|
|
95
|
-
images: response.data.pdf_images
|
|
96
|
-
? response.data.pdf_images
|
|
97
|
-
: undefined,
|
|
98
|
-
otherExams: response.data.pdf_other_exams
|
|
99
|
-
? response.data.pdf_other_exams
|
|
100
|
-
: undefined,
|
|
101
|
-
labs: response.data.pdf_labs ? response.data.pdf_labs : undefined,
|
|
102
|
-
},
|
|
103
|
-
files: response.data.files.map((f) => ({
|
|
104
|
-
name: f.nombre_file,
|
|
105
|
-
url: f.file,
|
|
106
|
-
})),
|
|
107
|
-
attachedFiles: mapAttachedFiles(response.data.attached_files),
|
|
108
|
-
};
|
|
109
|
-
});
|
|
110
|
-
const getActiveVideoVisits = validation_1.validateFunction(zod_1.tuple([]), zod_1.array(schemas_1.doc24Schemas.activeVideoVisitData), async () => {
|
|
111
|
-
const path = '/active-video-visits';
|
|
112
|
-
const response = await makeRequest('GET', path);
|
|
113
|
-
const consultations = response.data['active-consultations'];
|
|
114
|
-
return consultations.map((s) => ({
|
|
115
|
-
patientId: s.patient_id,
|
|
116
|
-
consultationId: s.consultation_id,
|
|
117
|
-
vcToken: s.vc_token,
|
|
118
|
-
}));
|
|
119
|
-
});
|
|
120
|
-
const getVideoVisitLink = validation_1.validateFunction(zod_1.tuple([zod_1.string(), zod_1.number()]), zod_1.string().nullable(), async (vcToken, patientId) => {
|
|
121
|
-
const path = `/video-visit-link/${vcToken}/${patientId}`;
|
|
122
|
-
const response = await makeRequest('GET', path);
|
|
123
|
-
return response.data.link;
|
|
124
|
-
});
|
|
125
|
-
const getCompleteVideoVisitDetails = validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.completeVideoVisitDetails, async (vcToken) => {
|
|
126
|
-
const path = `/consultation/${vcToken}`;
|
|
127
|
-
const response = await makeRequest('GET', path);
|
|
128
|
-
return {
|
|
129
|
-
id: response.data.id_consulta,
|
|
130
|
-
status: response.data.estado,
|
|
131
|
-
paymentStatus: response.data.estado_pago,
|
|
132
|
-
modality: response.data.modalidad,
|
|
133
|
-
address: response.data.direccion,
|
|
134
|
-
city: response.data.localidad,
|
|
135
|
-
province: response.data.provincia,
|
|
136
|
-
professional: response.data.id_profesional
|
|
137
|
-
? {
|
|
138
|
-
id: response.data.id_profesional,
|
|
139
|
-
fullName: response.data.profesional,
|
|
140
|
-
specialtyId: response.data.id_especialidad,
|
|
141
|
-
specialty: response.data.especialidad,
|
|
142
|
-
idPrestadorInterno: response.data.id_prestador_interno != null
|
|
143
|
-
? String(response.data.id_prestador_interno)
|
|
144
|
-
: undefined,
|
|
145
|
-
}
|
|
146
|
-
: undefined,
|
|
147
|
-
finishDate: response.data.fecha_fin && utils_1.parseDateTime(response.data.fecha_fin),
|
|
148
|
-
retries: response.data.intentos_conexion,
|
|
149
|
-
language: response.data.tag_idioma,
|
|
150
|
-
report: {
|
|
151
|
-
motive: response.data.motivo,
|
|
152
|
-
actualDesease: response.data.enfermedad_actual,
|
|
153
|
-
indications: response.data.conducta_terapeutica,
|
|
154
|
-
alertSigns: response.data.signos_alerta,
|
|
155
|
-
extendedMotive: response.data.motivo_extendido_consulta,
|
|
156
|
-
diagnose: response.data.diagnostico.map((d) => ({
|
|
157
|
-
description: d.diagnostico,
|
|
158
|
-
code: d.codificacion,
|
|
159
|
-
})),
|
|
160
|
-
medication: response.data.medicacion.map((m) => ({
|
|
161
|
-
description: m.detalle_producto,
|
|
162
|
-
quantity: m.cantidad,
|
|
163
|
-
dose: m.dosificacion,
|
|
164
|
-
farmalinkId: m.id_prescripcion_farmalink,
|
|
165
|
-
})),
|
|
166
|
-
prescription: {
|
|
167
|
-
link: response.data.link_receta,
|
|
168
|
-
codigo: response.data.codigo_verificacion_receta,
|
|
169
|
-
},
|
|
170
|
-
inPersonRequired: response.data.presencial_requerida,
|
|
171
|
-
referral: {
|
|
172
|
-
status: response.data.derivada,
|
|
173
|
-
specialtyId: response.data.derivada_id_especialidad,
|
|
174
|
-
inPersonRequired: response.data.derivada_presencial_obligatoria,
|
|
175
|
-
comments: response.data.derivada_comentarios,
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
pdf: {
|
|
179
|
-
atention: response.data.pdf_atencion
|
|
180
|
-
? response.data.pdf_atencion
|
|
181
|
-
: undefined,
|
|
182
|
-
medication: response.data.pdf_medicacion,
|
|
183
|
-
images: response.data.pdf_imagenes
|
|
184
|
-
? response.data.pdf_imagenes
|
|
185
|
-
: undefined,
|
|
186
|
-
otherExams: response.data.pdf_otras
|
|
187
|
-
? response.data.pdf_otras
|
|
188
|
-
: undefined,
|
|
189
|
-
labs: response.data.pdf_laboratorios
|
|
190
|
-
? response.data.pdf_laboratorios
|
|
191
|
-
: undefined,
|
|
192
|
-
certificate: response.data.pdf_certificado
|
|
193
|
-
? response.data.pdf_certificado
|
|
194
|
-
: undefined,
|
|
195
|
-
},
|
|
196
|
-
files: response.data.files_atencion.map((f) => ({
|
|
197
|
-
name: f.nombre_file,
|
|
198
|
-
url: f.file,
|
|
199
|
-
})),
|
|
200
|
-
attachedFiles: mapAttachedFiles(response.data.attached_files),
|
|
201
|
-
};
|
|
202
|
-
});
|
|
203
|
-
const uploadFileConsultation = validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.uploadFileConsultationParams]), schemas_1.doc24Schemas.uploadFileConsultationResponse, async (params) => {
|
|
204
|
-
const form = new form_data_1.default();
|
|
205
|
-
form.append('vc_token', params.vcToken);
|
|
206
|
-
form.append('attached_file', fs_1.default.createReadStream(params.attachedFile));
|
|
207
|
-
if (params.fileName)
|
|
208
|
-
form.append('file_name', params.fileName);
|
|
209
|
-
const response = await makeRequest('POST', '/upload-file-consultation', form);
|
|
210
|
-
// Unlike most doc24 endpoints, this one is not wrapped in `data`:
|
|
211
|
-
// {status, message, file_id}.
|
|
212
|
-
return {
|
|
213
|
-
fileId: response.file_id != null ? Number(response.file_id) : undefined,
|
|
214
|
-
};
|
|
215
|
-
});
|
|
216
|
-
const deleteFileConsultation = validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.deleteFileConsultationParams]), zod_1.undefined(), async (params) => {
|
|
217
|
-
await makeRequest('DELETE', '/delete-file-consultation', {
|
|
218
|
-
vc_token: params.vcToken,
|
|
219
|
-
file_id: params.fileId,
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
return {
|
|
223
|
-
scheduleVideoVisit,
|
|
224
|
-
cancelVideoVisit,
|
|
225
|
-
getVideoVisit,
|
|
226
|
-
getPatientVideoVisitHistory,
|
|
227
|
-
getVideoVisitDetails,
|
|
228
|
-
getVideoVisitLink,
|
|
229
|
-
getActiveVideoVisits,
|
|
230
|
-
getCompleteVideoVisitDetails,
|
|
231
|
-
uploadFileConsultation,
|
|
232
|
-
deleteFileConsultation,
|
|
233
|
-
};
|
|
234
|
-
};
|
|
235
|
-
exports.getVideoVisitMethods = getVideoVisitMethods;
|
|
236
|
-
const mapVideoVisit = (raw) => {
|
|
237
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
238
|
-
return {
|
|
239
|
-
id: raw.vc_id,
|
|
240
|
-
creationDate: utils_1.parseDateTime(raw.creation_date),
|
|
241
|
-
patientId: raw.patient_id,
|
|
242
|
-
user: { id: raw.user_id, email: raw.email, phone: raw.phone },
|
|
243
|
-
vcToken: raw.vc_token,
|
|
244
|
-
appointment: raw.appointment_id
|
|
245
|
-
? {
|
|
246
|
-
id: raw.appointment_id,
|
|
247
|
-
date: utils_1.parseDateTime(`${raw.appointment_date} ${raw.appointment_time}`, raw.time_zone),
|
|
248
|
-
}
|
|
249
|
-
: undefined,
|
|
250
|
-
videoVisit: raw.video_visit_id
|
|
251
|
-
? { id: raw.video_visit_id, status: raw.video_visit_status }
|
|
252
|
-
: undefined,
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
specialty: raw.specialty,
|
|
285
|
-
medications: raw.medications != null ? Boolean(raw.medications) : undefined,
|
|
286
|
-
practices: raw.practices != null ? Boolean(raw.practices) : undefined,
|
|
287
|
-
};
|
|
288
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getVideoVisitMethods = void 0;
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
const validation_1 = require("../request/validation");
|
|
9
|
+
const schemas_1 = require("../schemas");
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
|
+
const form_data_1 = __importDefault(require("form-data"));
|
|
13
|
+
const getVideoVisitMethods = (makeRequest) => {
|
|
14
|
+
const scheduleVideoVisit = validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.scheduleParameters]), zod_1.string(), async (params) => {
|
|
15
|
+
const specificParams = params.type === 'appointment'
|
|
16
|
+
? {
|
|
17
|
+
type: 'P',
|
|
18
|
+
appointment_id: params.appointmentId,
|
|
19
|
+
modality: params.modality || 'A',
|
|
20
|
+
}
|
|
21
|
+
: { type: 'E' };
|
|
22
|
+
const mappedParams = {
|
|
23
|
+
...specificParams,
|
|
24
|
+
patient_id: params.patientId,
|
|
25
|
+
specialty_id: params.specialtyId,
|
|
26
|
+
language: params.language.toUpperCase(),
|
|
27
|
+
details: params.details,
|
|
28
|
+
extra_info: { ...params.extraInfo, modality: params.modality || 'A' },
|
|
29
|
+
};
|
|
30
|
+
const response = await makeRequest('POST', '/video-visit', mappedParams);
|
|
31
|
+
return response.data.vc_token;
|
|
32
|
+
});
|
|
33
|
+
const cancelVideoVisit = validation_1.validateFunction(zod_1.tuple([zod_1.string()]), zod_1.undefined(), async (vcToken) => {
|
|
34
|
+
const path = `/video-visit/${vcToken}`;
|
|
35
|
+
await makeRequest('DELETE', path);
|
|
36
|
+
});
|
|
37
|
+
const getVideoVisit = validation_1.validateFunction(zod_1.tuple([zod_1.string(), zod_1.number()]), schemas_1.doc24Schemas.videoVisit, async (vcToken, patientId) => {
|
|
38
|
+
const path = `/video-visit/${vcToken}/${patientId}`;
|
|
39
|
+
const response = await makeRequest('GET', path);
|
|
40
|
+
return mapVideoVisit(response.data);
|
|
41
|
+
});
|
|
42
|
+
const getPatientVideoVisitHistory = validation_1.validateFunction(zod_1.tuple([zod_1.number()]), zod_1.array(schemas_1.doc24Schemas.historicalVideoVisit), async (patientId) => {
|
|
43
|
+
const path = `/video-visit-history/${patientId}`;
|
|
44
|
+
const response = await makeRequest('GET', path);
|
|
45
|
+
return response.data.map((raw) => mapHistoricalVideoVisit(raw));
|
|
46
|
+
});
|
|
47
|
+
const getVideoVisitDetails = validation_1.validateFunction(zod_1.tuple([zod_1.number()]), schemas_1.doc24Schemas.videoVisitDetails, async (vcId) => {
|
|
48
|
+
var _a;
|
|
49
|
+
const path = `/video-visit-records/${vcId}`;
|
|
50
|
+
const response = await makeRequest('GET', path);
|
|
51
|
+
return {
|
|
52
|
+
id: response.data.consultation_id,
|
|
53
|
+
vcToken: (_a = response.data.vc_token) !== null && _a !== void 0 ? _a : undefined,
|
|
54
|
+
status: response.data.status,
|
|
55
|
+
paymentStatus: response.data.payment_status,
|
|
56
|
+
professional: response.data.professional_id
|
|
57
|
+
? {
|
|
58
|
+
id: response.data.professional_id,
|
|
59
|
+
fullName: response.data.professional,
|
|
60
|
+
}
|
|
61
|
+
: undefined,
|
|
62
|
+
patient: {
|
|
63
|
+
fullName: response.data.patient,
|
|
64
|
+
firstAccessDate: response.data.patient_first_access_date &&
|
|
65
|
+
utils_1.parseDateTime(response.data.patient_first_access_date),
|
|
66
|
+
lastAccessDate: response.data.patient_last_access_date &&
|
|
67
|
+
utils_1.parseDateTime(response.data.patient_last_access_date),
|
|
68
|
+
},
|
|
69
|
+
finishDate: response.data.finish_date &&
|
|
70
|
+
utils_1.parseDateTime(response.data.finish_date),
|
|
71
|
+
retries: response.data.retries,
|
|
72
|
+
language: response.data.language,
|
|
73
|
+
appointment: response.data.appointment_id
|
|
74
|
+
? {
|
|
75
|
+
id: response.data.appointment_id,
|
|
76
|
+
date: utils_1.parseDateTime(`${response.data.appointment_date} ${response.data.appointment_time}`, response.data.time_zone),
|
|
77
|
+
}
|
|
78
|
+
: null,
|
|
79
|
+
report: {
|
|
80
|
+
motive: response.data.motive,
|
|
81
|
+
actualDesease: response.data.actual_desease,
|
|
82
|
+
indications: response.data.indications,
|
|
83
|
+
alertSigns: response.data.alert_signs,
|
|
84
|
+
extendedMotive: response.data.extended_motive,
|
|
85
|
+
diagnose: response.data.diagnose.map((d) => ({
|
|
86
|
+
description: d.diagnostico,
|
|
87
|
+
code: d.codificacion,
|
|
88
|
+
})),
|
|
89
|
+
},
|
|
90
|
+
pdf: {
|
|
91
|
+
atention: response.data.pdf_atention
|
|
92
|
+
? response.data.pdf_atention
|
|
93
|
+
: undefined,
|
|
94
|
+
medication: response.data.pdf_medication,
|
|
95
|
+
images: response.data.pdf_images
|
|
96
|
+
? response.data.pdf_images
|
|
97
|
+
: undefined,
|
|
98
|
+
otherExams: response.data.pdf_other_exams
|
|
99
|
+
? response.data.pdf_other_exams
|
|
100
|
+
: undefined,
|
|
101
|
+
labs: response.data.pdf_labs ? response.data.pdf_labs : undefined,
|
|
102
|
+
},
|
|
103
|
+
files: response.data.files.map((f) => ({
|
|
104
|
+
name: f.nombre_file,
|
|
105
|
+
url: f.file,
|
|
106
|
+
})),
|
|
107
|
+
attachedFiles: mapAttachedFiles(response.data.attached_files),
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
const getActiveVideoVisits = validation_1.validateFunction(zod_1.tuple([]), zod_1.array(schemas_1.doc24Schemas.activeVideoVisitData), async () => {
|
|
111
|
+
const path = '/active-video-visits';
|
|
112
|
+
const response = await makeRequest('GET', path);
|
|
113
|
+
const consultations = response.data['active-consultations'];
|
|
114
|
+
return consultations.map((s) => ({
|
|
115
|
+
patientId: s.patient_id,
|
|
116
|
+
consultationId: s.consultation_id,
|
|
117
|
+
vcToken: s.vc_token,
|
|
118
|
+
}));
|
|
119
|
+
});
|
|
120
|
+
const getVideoVisitLink = validation_1.validateFunction(zod_1.tuple([zod_1.string(), zod_1.number()]), zod_1.string().nullable(), async (vcToken, patientId) => {
|
|
121
|
+
const path = `/video-visit-link/${vcToken}/${patientId}`;
|
|
122
|
+
const response = await makeRequest('GET', path);
|
|
123
|
+
return response.data.link;
|
|
124
|
+
});
|
|
125
|
+
const getCompleteVideoVisitDetails = validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.completeVideoVisitDetails, async (vcToken) => {
|
|
126
|
+
const path = `/consultation/${vcToken}`;
|
|
127
|
+
const response = await makeRequest('GET', path);
|
|
128
|
+
return {
|
|
129
|
+
id: response.data.id_consulta,
|
|
130
|
+
status: response.data.estado,
|
|
131
|
+
paymentStatus: response.data.estado_pago,
|
|
132
|
+
modality: response.data.modalidad,
|
|
133
|
+
address: response.data.direccion,
|
|
134
|
+
city: response.data.localidad,
|
|
135
|
+
province: response.data.provincia,
|
|
136
|
+
professional: response.data.id_profesional
|
|
137
|
+
? {
|
|
138
|
+
id: response.data.id_profesional,
|
|
139
|
+
fullName: response.data.profesional,
|
|
140
|
+
specialtyId: response.data.id_especialidad,
|
|
141
|
+
specialty: response.data.especialidad,
|
|
142
|
+
idPrestadorInterno: response.data.id_prestador_interno != null
|
|
143
|
+
? String(response.data.id_prestador_interno)
|
|
144
|
+
: undefined,
|
|
145
|
+
}
|
|
146
|
+
: undefined,
|
|
147
|
+
finishDate: response.data.fecha_fin && utils_1.parseDateTime(response.data.fecha_fin),
|
|
148
|
+
retries: response.data.intentos_conexion,
|
|
149
|
+
language: response.data.tag_idioma,
|
|
150
|
+
report: {
|
|
151
|
+
motive: response.data.motivo,
|
|
152
|
+
actualDesease: response.data.enfermedad_actual,
|
|
153
|
+
indications: response.data.conducta_terapeutica,
|
|
154
|
+
alertSigns: response.data.signos_alerta,
|
|
155
|
+
extendedMotive: response.data.motivo_extendido_consulta,
|
|
156
|
+
diagnose: response.data.diagnostico.map((d) => ({
|
|
157
|
+
description: d.diagnostico,
|
|
158
|
+
code: d.codificacion,
|
|
159
|
+
})),
|
|
160
|
+
medication: response.data.medicacion.map((m) => ({
|
|
161
|
+
description: m.detalle_producto,
|
|
162
|
+
quantity: m.cantidad,
|
|
163
|
+
dose: m.dosificacion,
|
|
164
|
+
farmalinkId: m.id_prescripcion_farmalink,
|
|
165
|
+
})),
|
|
166
|
+
prescription: {
|
|
167
|
+
link: response.data.link_receta,
|
|
168
|
+
codigo: response.data.codigo_verificacion_receta,
|
|
169
|
+
},
|
|
170
|
+
inPersonRequired: response.data.presencial_requerida,
|
|
171
|
+
referral: {
|
|
172
|
+
status: response.data.derivada,
|
|
173
|
+
specialtyId: response.data.derivada_id_especialidad,
|
|
174
|
+
inPersonRequired: response.data.derivada_presencial_obligatoria,
|
|
175
|
+
comments: response.data.derivada_comentarios,
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
pdf: {
|
|
179
|
+
atention: response.data.pdf_atencion
|
|
180
|
+
? response.data.pdf_atencion
|
|
181
|
+
: undefined,
|
|
182
|
+
medication: response.data.pdf_medicacion,
|
|
183
|
+
images: response.data.pdf_imagenes
|
|
184
|
+
? response.data.pdf_imagenes
|
|
185
|
+
: undefined,
|
|
186
|
+
otherExams: response.data.pdf_otras
|
|
187
|
+
? response.data.pdf_otras
|
|
188
|
+
: undefined,
|
|
189
|
+
labs: response.data.pdf_laboratorios
|
|
190
|
+
? response.data.pdf_laboratorios
|
|
191
|
+
: undefined,
|
|
192
|
+
certificate: response.data.pdf_certificado
|
|
193
|
+
? response.data.pdf_certificado
|
|
194
|
+
: undefined,
|
|
195
|
+
},
|
|
196
|
+
files: response.data.files_atencion.map((f) => ({
|
|
197
|
+
name: f.nombre_file,
|
|
198
|
+
url: f.file,
|
|
199
|
+
})),
|
|
200
|
+
attachedFiles: mapAttachedFiles(response.data.attached_files),
|
|
201
|
+
};
|
|
202
|
+
});
|
|
203
|
+
const uploadFileConsultation = validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.uploadFileConsultationParams]), schemas_1.doc24Schemas.uploadFileConsultationResponse, async (params) => {
|
|
204
|
+
const form = new form_data_1.default();
|
|
205
|
+
form.append('vc_token', params.vcToken);
|
|
206
|
+
form.append('attached_file', fs_1.default.createReadStream(params.attachedFile));
|
|
207
|
+
if (params.fileName)
|
|
208
|
+
form.append('file_name', params.fileName);
|
|
209
|
+
const response = await makeRequest('POST', '/upload-file-consultation', form);
|
|
210
|
+
// Unlike most doc24 endpoints, this one is not wrapped in `data`:
|
|
211
|
+
// {status, message, file_id}.
|
|
212
|
+
return {
|
|
213
|
+
fileId: response.file_id != null ? Number(response.file_id) : undefined,
|
|
214
|
+
};
|
|
215
|
+
});
|
|
216
|
+
const deleteFileConsultation = validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.deleteFileConsultationParams]), zod_1.undefined(), async (params) => {
|
|
217
|
+
await makeRequest('DELETE', '/delete-file-consultation', {
|
|
218
|
+
vc_token: params.vcToken,
|
|
219
|
+
file_id: params.fileId,
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
return {
|
|
223
|
+
scheduleVideoVisit,
|
|
224
|
+
cancelVideoVisit,
|
|
225
|
+
getVideoVisit,
|
|
226
|
+
getPatientVideoVisitHistory,
|
|
227
|
+
getVideoVisitDetails,
|
|
228
|
+
getVideoVisitLink,
|
|
229
|
+
getActiveVideoVisits,
|
|
230
|
+
getCompleteVideoVisitDetails,
|
|
231
|
+
uploadFileConsultation,
|
|
232
|
+
deleteFileConsultation,
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
exports.getVideoVisitMethods = getVideoVisitMethods;
|
|
236
|
+
const mapVideoVisit = (raw) => {
|
|
237
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
238
|
+
return {
|
|
239
|
+
id: raw.vc_id,
|
|
240
|
+
creationDate: utils_1.parseDateTime(raw.creation_date),
|
|
241
|
+
patientId: raw.patient_id,
|
|
242
|
+
user: { id: raw.user_id, email: raw.email, phone: raw.phone },
|
|
243
|
+
vcToken: raw.vc_token,
|
|
244
|
+
appointment: raw.appointment_id
|
|
245
|
+
? {
|
|
246
|
+
id: raw.appointment_id,
|
|
247
|
+
date: utils_1.parseDateTime(`${raw.appointment_date} ${raw.appointment_time}`, raw.time_zone),
|
|
248
|
+
}
|
|
249
|
+
: undefined,
|
|
250
|
+
videoVisit: raw.video_visit_id
|
|
251
|
+
? { id: raw.video_visit_id, status: raw.video_visit_status }
|
|
252
|
+
: undefined,
|
|
253
|
+
paymentStatus: (_a = raw.payment_status) !== null && _a !== void 0 ? _a : undefined,
|
|
254
|
+
atentionId: (_b = raw.atentionId) !== null && _b !== void 0 ? _b : undefined,
|
|
255
|
+
waitingTime: (_c = raw.waiting_time) !== null && _c !== void 0 ? _c : undefined,
|
|
256
|
+
address: (_d = raw.direccion) !== null && _d !== void 0 ? _d : undefined,
|
|
257
|
+
city: (_e = raw.localidad) !== null && _e !== void 0 ? _e : undefined,
|
|
258
|
+
province: (_f = raw.provincia) !== null && _f !== void 0 ? _f : undefined,
|
|
259
|
+
modality: (_g = raw.modalidad) !== null && _g !== void 0 ? _g : undefined,
|
|
260
|
+
attachedFiles: mapAttachedFiles(raw.attached_files),
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
// `upload_date` is Argentina time without offset: parse with the default -03,
|
|
264
|
+
// never with the brand's `time_zone` (that one is a correction, not the zone).
|
|
265
|
+
const mapAttachedFiles = (raw) => (raw !== null && raw !== void 0 ? raw : []).map((f) => {
|
|
266
|
+
var _a;
|
|
267
|
+
return ({
|
|
268
|
+
fileId: Number(f.file_id),
|
|
269
|
+
fileName: (_a = f.file_name) !== null && _a !== void 0 ? _a : null,
|
|
270
|
+
fileUrl: f.file_url,
|
|
271
|
+
fileType: f.file_type,
|
|
272
|
+
uploadDate: utils_1.parseDateTime(f.upload_date),
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
const mapHistoricalVideoVisit = (raw) => {
|
|
276
|
+
return {
|
|
277
|
+
...mapVideoVisit(raw),
|
|
278
|
+
professional: raw.professional,
|
|
279
|
+
specialty: raw.specialty,
|
|
280
|
+
medications: raw.medications != null ? Boolean(raw.medications) : undefined,
|
|
281
|
+
practices: raw.practices != null ? Boolean(raw.practices) : undefined,
|
|
282
|
+
};
|
|
283
|
+
};
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const parseDate: (str: string, timeZone?: string | null | undefined) => Date;
|
|
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;
|
|
4
|
-
export declare const normalizeTimezoneOffset: (raw?: string | undefined, defualtTimezone?: number) => string | undefined;
|
|
1
|
+
export declare const parseDate: (str: string, timeZone?: string | null | undefined) => Date;
|
|
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;
|
|
4
|
+
export declare const normalizeTimezoneOffset: (raw?: string | undefined, defualtTimezone?: number) => string | undefined;
|