@integraciones_doc24/sdk 1.16.36 → 1.16.37

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.
Files changed (46) hide show
  1. package/README.md +206 -206
  2. package/lib/baseSdk/diagnostica.d.ts +54 -54
  3. package/lib/baseSdk/diagnostica.js +82 -82
  4. package/lib/baseSdk/external.d.ts +177 -177
  5. package/lib/baseSdk/external.js +96 -96
  6. package/lib/baseSdk/index.d.ts +2 -2
  7. package/lib/baseSdk/index.js +77 -77
  8. package/lib/baseSdk/user.d.ts +112 -112
  9. package/lib/baseSdk/user.js +136 -136
  10. package/lib/index.d.ts +400 -400
  11. package/lib/index.js +22 -22
  12. package/lib/request/index.d.ts +4 -4
  13. package/lib/request/index.js +32 -32
  14. package/lib/request/token.d.ts +2 -2
  15. package/lib/request/token.js +34 -34
  16. package/lib/request/validation.d.ts +10 -10
  17. package/lib/request/validation.js +28 -28
  18. package/lib/schemas.d.ts +2703 -2549
  19. package/lib/schemas.js +573 -559
  20. package/lib/types.d.ts +174 -173
  21. package/lib/types.js +2 -2
  22. package/lib/userSdk/binah.d.ts +21 -21
  23. package/lib/userSdk/binah.js +20 -20
  24. package/lib/userSdk/chat.d.ts +57 -57
  25. package/lib/userSdk/chat.js +98 -98
  26. package/lib/userSdk/external.d.ts +34 -34
  27. package/lib/userSdk/external.js +72 -72
  28. package/lib/userSdk/index.d.ts +2 -2
  29. package/lib/userSdk/index.js +33 -33
  30. package/lib/userSdk/patients.d.ts +58 -58
  31. package/lib/userSdk/patients.js +89 -89
  32. package/lib/userSdk/schedule.d.ts +59 -59
  33. package/lib/userSdk/schedule.js +90 -90
  34. package/lib/userSdk/specialties.d.ts +19 -19
  35. package/lib/userSdk/specialties.js +48 -48
  36. package/lib/userSdk/videoVisit.d.ts +225 -196
  37. package/lib/userSdk/videoVisit.js +283 -266
  38. package/lib/utils.d.ts +4 -4
  39. package/lib/utils.js +68 -68
  40. package/lib/webhook/index.d.ts +2 -2
  41. package/lib/webhook/index.js +67 -67
  42. package/lib/webhook/responses.d.ts +35 -35
  43. package/lib/webhook/responses.js +42 -42
  44. package/lib/webhook/token.d.ts +2 -2
  45. package/lib/webhook/token.js +23 -23
  46. package/package.json +37 -37
@@ -1,266 +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
- const path = `/video-visit-records/${vcId}`;
49
- const response = await makeRequest('GET', path);
50
- return {
51
- id: response.data.consultation_id,
52
- status: response.data.status,
53
- paymentStatus: response.data.payment_status,
54
- professional: response.data.professional_id
55
- ? {
56
- id: response.data.professional_id,
57
- fullName: response.data.professional,
58
- }
59
- : undefined,
60
- patient: {
61
- fullName: response.data.patient,
62
- firstAccessDate: response.data.patient_first_access_date &&
63
- utils_1.parseDateTime(response.data.patient_first_access_date),
64
- lastAccessDate: response.data.patient_last_access_date &&
65
- utils_1.parseDateTime(response.data.patient_last_access_date),
66
- },
67
- finishDate: response.data.finish_date &&
68
- utils_1.parseDateTime(response.data.finish_date),
69
- retries: response.data.retries,
70
- language: response.data.language,
71
- appointment: response.data.appointment_id
72
- ? {
73
- id: response.data.appointment_id,
74
- date: utils_1.parseDateTime(`${response.data.appointment_date} ${response.data.appointment_time}`, response.data.time_zone),
75
- }
76
- : null,
77
- report: {
78
- motive: response.data.motive,
79
- actualDesease: response.data.actual_desease,
80
- indications: response.data.indications,
81
- alertSigns: response.data.alert_signs,
82
- extendedMotive: response.data.extended_motive,
83
- diagnose: response.data.diagnose.map((d) => ({
84
- description: d.diagnostico,
85
- code: d.codificacion,
86
- })),
87
- },
88
- pdf: {
89
- atention: response.data.pdf_atention
90
- ? response.data.pdf_atention
91
- : undefined,
92
- medication: response.data.pdf_medication,
93
- images: response.data.pdf_images
94
- ? response.data.pdf_images
95
- : undefined,
96
- otherExams: response.data.pdf_other_exams
97
- ? response.data.pdf_other_exams
98
- : undefined,
99
- labs: response.data.pdf_labs ? response.data.pdf_labs : undefined,
100
- },
101
- files: response.data.files.map((f) => ({
102
- name: f.nombre_file,
103
- url: f.file,
104
- })),
105
- };
106
- });
107
- const getActiveVideoVisits = validation_1.validateFunction(zod_1.tuple([]), zod_1.array(schemas_1.doc24Schemas.activeVideoVisitData), async () => {
108
- const path = '/active-video-visits';
109
- const response = await makeRequest('GET', path);
110
- const consultations = response.data['active-consultations'];
111
- return consultations.map((s) => ({
112
- patientId: s.patient_id,
113
- consultationId: s.consultation_id,
114
- vcToken: s.vc_token,
115
- }));
116
- });
117
- const getVideoVisitLink = validation_1.validateFunction(zod_1.tuple([zod_1.string(), zod_1.number()]), zod_1.string().nullable(), async (vcToken, patientId) => {
118
- const path = `/video-visit-link/${vcToken}/${patientId}`;
119
- const response = await makeRequest('GET', path);
120
- return response.data.link;
121
- });
122
- const getCompleteVideoVisitDetails = validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.completeVideoVisitDetails, async (vcToken) => {
123
- const path = `/consultation/${vcToken}`;
124
- const response = await makeRequest('GET', path);
125
- return {
126
- id: response.data.id_consulta,
127
- status: response.data.estado,
128
- paymentStatus: response.data.estado_pago,
129
- modality: response.data.modalidad,
130
- address: response.data.direccion,
131
- city: response.data.localidad,
132
- province: response.data.provincia,
133
- professional: response.data.id_profesional
134
- ? {
135
- id: response.data.id_profesional,
136
- fullName: response.data.profesional,
137
- specialtyId: response.data.id_especialidad,
138
- specialty: response.data.especialidad,
139
- idPrestadorInterno: response.data.id_prestador_interno != null
140
- ? String(response.data.id_prestador_interno)
141
- : undefined,
142
- }
143
- : undefined,
144
- finishDate: response.data.fecha_fin && utils_1.parseDateTime(response.data.fecha_fin),
145
- retries: response.data.intentos_conexion,
146
- language: response.data.tag_idioma,
147
- report: {
148
- motive: response.data.motivo,
149
- actualDesease: response.data.enfermedad_actual,
150
- indications: response.data.conducta_terapeutica,
151
- alertSigns: response.data.signos_alerta,
152
- extendedMotive: response.data.motivo_extendido_consulta,
153
- diagnose: response.data.diagnostico.map((d) => ({
154
- description: d.diagnostico,
155
- code: d.codificacion,
156
- })),
157
- medication: response.data.medicacion.map((m) => ({
158
- description: m.detalle_producto,
159
- quantity: m.cantidad,
160
- dose: m.dosificacion,
161
- farmalinkId: m.id_prescripcion_farmalink,
162
- })),
163
- prescription: {
164
- link: response.data.link_receta,
165
- codigo: response.data.codigo_verificacion_receta,
166
- },
167
- inPersonRequired: response.data.presencial_requerida,
168
- referral: {
169
- status: response.data.derivada,
170
- specialtyId: response.data.derivada_id_especialidad,
171
- inPersonRequired: response.data.derivada_presencial_obligatoria,
172
- comments: response.data.derivada_comentarios,
173
- },
174
- },
175
- pdf: {
176
- atention: response.data.pdf_atencion
177
- ? response.data.pdf_atencion
178
- : undefined,
179
- medication: response.data.pdf_medicacion,
180
- images: response.data.pdf_imagenes
181
- ? response.data.pdf_imagenes
182
- : undefined,
183
- otherExams: response.data.pdf_otras
184
- ? response.data.pdf_otras
185
- : undefined,
186
- labs: response.data.pdf_laboratorios
187
- ? response.data.pdf_laboratorios
188
- : undefined,
189
- certificate: response.data.pdf_certificado
190
- ? response.data.pdf_certificado
191
- : undefined,
192
- },
193
- files: response.data.files_atencion.map((f) => ({
194
- name: f.nombre_file,
195
- url: f.file,
196
- })),
197
- };
198
- });
199
- const uploadFileConsultation = validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.uploadFileConsultationParams]), schemas_1.doc24Schemas.uploadFileConsultationResponse, async (params) => {
200
- const form = new form_data_1.default();
201
- form.append('vc_token', params.vcToken);
202
- form.append('attached_file', fs_1.default.createReadStream(params.attachedFile));
203
- if (params.fileName)
204
- form.append('file_name', params.fileName);
205
- const response = await makeRequest('POST', '/upload-file-consultation', form);
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
- });
217
- });
218
- return {
219
- scheduleVideoVisit,
220
- cancelVideoVisit,
221
- getVideoVisit,
222
- getPatientVideoVisitHistory,
223
- getVideoVisitDetails,
224
- getVideoVisitLink,
225
- getActiveVideoVisits,
226
- getCompleteVideoVisitDetails,
227
- uploadFileConsultation,
228
- deleteFileConsultation,
229
- };
230
- };
231
- exports.getVideoVisitMethods = getVideoVisitMethods;
232
- const mapVideoVisit = (raw) => {
233
- var _a, _b, _c, _d, _e, _f, _g;
234
- return {
235
- id: raw.vc_id,
236
- creationDate: utils_1.parseDateTime(raw.creation_date),
237
- patientId: raw.patient_id,
238
- user: { id: raw.user_id, email: raw.email, phone: raw.phone },
239
- vcToken: raw.vc_token,
240
- appointment: raw.appointment_id
241
- ? {
242
- id: raw.appointment_id,
243
- date: utils_1.parseDateTime(`${raw.appointment_date} ${raw.appointment_time}`, raw.time_zone),
244
- }
245
- : undefined,
246
- videoVisit: raw.video_visit_id
247
- ? { id: raw.video_visit_id, status: raw.video_visit_status }
248
- : undefined,
249
- paymentStatus: (_a = raw.payment_status) !== null && _a !== void 0 ? _a : undefined,
250
- atentionId: (_b = raw.atentionId) !== null && _b !== void 0 ? _b : undefined,
251
- waitingTime: (_c = raw.waiting_time) !== null && _c !== void 0 ? _c : undefined,
252
- address: (_d = raw.direccion) !== null && _d !== void 0 ? _d : undefined,
253
- city: (_e = raw.localidad) !== null && _e !== void 0 ? _e : undefined,
254
- province: (_f = raw.provincia) !== null && _f !== void 0 ? _f : undefined,
255
- modality: (_g = raw.modalidad) !== null && _g !== void 0 ? _g : undefined,
256
- };
257
- };
258
- const mapHistoricalVideoVisit = (raw) => {
259
- return {
260
- ...mapVideoVisit(raw),
261
- professional: raw.professional,
262
- specialty: raw.specialty,
263
- medications: raw.medications != null ? Boolean(raw.medications) : undefined,
264
- practices: raw.practices != null ? Boolean(raw.practices) : undefined,
265
- };
266
- };
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;