@integraciones_doc24/sdk 1.16.28 → 1.16.30

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 (48) hide show
  1. package/README.md +206 -206
  2. package/lib/baseSdk/consultation.d.ts +99 -0
  3. package/lib/baseSdk/consultation.js +23 -0
  4. package/lib/baseSdk/diagnostica.d.ts +54 -54
  5. package/lib/baseSdk/diagnostica.js +82 -82
  6. package/lib/baseSdk/external.d.ts +177 -177
  7. package/lib/baseSdk/external.js +96 -96
  8. package/lib/baseSdk/index.d.ts +2 -2
  9. package/lib/baseSdk/index.js +77 -76
  10. package/lib/baseSdk/user.d.ts +112 -112
  11. package/lib/baseSdk/user.js +136 -136
  12. package/lib/index.d.ts +400 -400
  13. package/lib/index.js +22 -22
  14. package/lib/request/index.d.ts +4 -4
  15. package/lib/request/index.js +32 -32
  16. package/lib/request/token.d.ts +2 -2
  17. package/lib/request/token.js +34 -34
  18. package/lib/request/validation.d.ts +10 -10
  19. package/lib/request/validation.js +28 -28
  20. package/lib/schemas.d.ts +2518 -2518
  21. package/lib/schemas.js +548 -548
  22. package/lib/types.d.ts +170 -170
  23. package/lib/types.js +2 -2
  24. package/lib/userSdk/binah.d.ts +21 -21
  25. package/lib/userSdk/binah.js +20 -20
  26. package/lib/userSdk/chat.d.ts +57 -57
  27. package/lib/userSdk/chat.js +98 -98
  28. package/lib/userSdk/external.d.ts +34 -34
  29. package/lib/userSdk/external.js +72 -72
  30. package/lib/userSdk/index.d.ts +2 -2
  31. package/lib/userSdk/index.js +33 -33
  32. package/lib/userSdk/patients.d.ts +58 -58
  33. package/lib/userSdk/patients.js +89 -89
  34. package/lib/userSdk/schedule.d.ts +58 -58
  35. package/lib/userSdk/schedule.js +89 -89
  36. package/lib/userSdk/specialties.d.ts +19 -19
  37. package/lib/userSdk/specialties.js +48 -48
  38. package/lib/userSdk/videoVisit.d.ts +187 -187
  39. package/lib/userSdk/videoVisit.js +250 -250
  40. package/lib/utils.d.ts +3 -3
  41. package/lib/utils.js +43 -43
  42. package/lib/webhook/index.d.ts +2 -2
  43. package/lib/webhook/index.js +67 -67
  44. package/lib/webhook/responses.d.ts +35 -35
  45. package/lib/webhook/responses.js +42 -42
  46. package/lib/webhook/token.d.ts +2 -2
  47. package/lib/webhook/token.js +23 -23
  48. package/package.json +37 -37
@@ -1,250 +1,250 @@
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
- modaility: 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,
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
- }
140
- : undefined,
141
- finishDate: response.data.fecha_fin && utils_1.parseDateTime(response.data.fecha_fin),
142
- retries: response.data.intentos_conexion,
143
- language: response.data.tag_idioma,
144
- report: {
145
- motive: response.data.motivo,
146
- actualDesease: response.data.enfermedad_actual,
147
- indications: response.data.conducta_terapeutica,
148
- alertSigns: response.data.signos_alerta,
149
- extendedMotive: response.data.motivo_extendido_consulta,
150
- diagnose: response.data.diagnostico.map((d) => ({
151
- description: d.diagnostico,
152
- code: d.codificacion,
153
- })),
154
- medication: response.data.medicacion.map((m) => ({
155
- description: m.detalle_producto,
156
- quantity: m.cantidad,
157
- dose: m.dosificacion,
158
- farmalinkId: m.id_prescripcion_farmalink,
159
- })),
160
- prescription: {
161
- link: response.data.link_receta,
162
- codigo: response.data.codigo_verificacion_receta,
163
- },
164
- inPersonRequired: response.data.presencial_requerida,
165
- referral: {
166
- status: response.data.derivada,
167
- specialtyId: response.data.derivada_id_especialidad,
168
- inPersonRequired: response.data.derivada_presencial_obligatoria,
169
- comments: response.data.derivada_comentarios,
170
- },
171
- },
172
- pdf: {
173
- atention: response.data.pdf_atencion
174
- ? response.data.pdf_atencion
175
- : undefined,
176
- medication: response.data.pdf_medicacion,
177
- images: response.data.pdf_imagenes
178
- ? response.data.pdf_imagenes
179
- : undefined,
180
- otherExams: response.data.pdf_otras
181
- ? response.data.pdf_otras
182
- : undefined,
183
- labs: response.data.pdf_laboratorios
184
- ? response.data.pdf_laboratorios
185
- : undefined,
186
- certificate: response.data.pdf_certificado
187
- ? response.data.pdf_certificado
188
- : undefined,
189
- },
190
- files: response.data.files_atencion.map((f) => ({
191
- name: f.nombre_file,
192
- url: f.file,
193
- })),
194
- };
195
- });
196
- const uploadFileConsultation = validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.uploadFileConsultationParams]), zod_1.any(), async (params) => {
197
- const form = new form_data_1.default();
198
- form.append('vc_token', params.vcToken);
199
- form.append('attached_file', fs_1.default.createReadStream(params.attachedFile));
200
- if (params.fileName)
201
- form.append('file_name', params.fileName);
202
- const response = await makeRequest('POST', '/upload-file-consultation', form);
203
- return response.data;
204
- });
205
- return {
206
- scheduleVideoVisit,
207
- cancelVideoVisit,
208
- getVideoVisit,
209
- getPatientVideoVisitHistory,
210
- getVideoVisitDetails,
211
- getVideoVisitLink,
212
- getActiveVideoVisits,
213
- getCompleteVideoVisitDetails,
214
- uploadFileConsultation,
215
- };
216
- };
217
- exports.getVideoVisitMethods = getVideoVisitMethods;
218
- const mapVideoVisit = (raw) => {
219
- var _a, _b, _c, _d, _e, _f, _g;
220
- return {
221
- id: raw.vc_id,
222
- creationDate: utils_1.parseDateTime(raw.creation_date),
223
- patientId: raw.patient_id,
224
- user: { id: raw.user_id, email: raw.email, phone: raw.phone },
225
- vcToken: raw.vc_token,
226
- appointment: raw.appointment_id
227
- ? {
228
- id: raw.appointment_id,
229
- date: utils_1.parseDateTime(`${raw.appointment_date} ${raw.appointment_time}`, raw.time_zone),
230
- }
231
- : undefined,
232
- videoVisit: raw.video_visit_id
233
- ? { id: raw.video_visit_id, status: raw.video_visit_status }
234
- : undefined,
235
- paymentStatus: (_a = raw.payment_status) !== null && _a !== void 0 ? _a : undefined,
236
- atentionId: (_b = raw.atentionId) !== null && _b !== void 0 ? _b : undefined,
237
- waitingTime: (_c = raw.waiting_time) !== null && _c !== void 0 ? _c : undefined,
238
- address: (_d = raw.direccion) !== null && _d !== void 0 ? _d : undefined,
239
- city: (_e = raw.localidad) !== null && _e !== void 0 ? _e : undefined,
240
- province: (_f = raw.provincia) !== null && _f !== void 0 ? _f : undefined,
241
- modality: (_g = raw.modalidad) !== null && _g !== void 0 ? _g : undefined,
242
- };
243
- };
244
- const mapHistoricalVideoVisit = (raw) => {
245
- return {
246
- ...mapVideoVisit(raw),
247
- professional: raw.professional,
248
- specialty: raw.specialty,
249
- };
250
- };
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
+ }
140
+ : undefined,
141
+ finishDate: response.data.fecha_fin && utils_1.parseDateTime(response.data.fecha_fin),
142
+ retries: response.data.intentos_conexion,
143
+ language: response.data.tag_idioma,
144
+ report: {
145
+ motive: response.data.motivo,
146
+ actualDesease: response.data.enfermedad_actual,
147
+ indications: response.data.conducta_terapeutica,
148
+ alertSigns: response.data.signos_alerta,
149
+ extendedMotive: response.data.motivo_extendido_consulta,
150
+ diagnose: response.data.diagnostico.map((d) => ({
151
+ description: d.diagnostico,
152
+ code: d.codificacion,
153
+ })),
154
+ medication: response.data.medicacion.map((m) => ({
155
+ description: m.detalle_producto,
156
+ quantity: m.cantidad,
157
+ dose: m.dosificacion,
158
+ farmalinkId: m.id_prescripcion_farmalink,
159
+ })),
160
+ prescription: {
161
+ link: response.data.link_receta,
162
+ codigo: response.data.codigo_verificacion_receta,
163
+ },
164
+ inPersonRequired: response.data.presencial_requerida,
165
+ referral: {
166
+ status: response.data.derivada,
167
+ specialtyId: response.data.derivada_id_especialidad,
168
+ inPersonRequired: response.data.derivada_presencial_obligatoria,
169
+ comments: response.data.derivada_comentarios,
170
+ },
171
+ },
172
+ pdf: {
173
+ atention: response.data.pdf_atencion
174
+ ? response.data.pdf_atencion
175
+ : undefined,
176
+ medication: response.data.pdf_medicacion,
177
+ images: response.data.pdf_imagenes
178
+ ? response.data.pdf_imagenes
179
+ : undefined,
180
+ otherExams: response.data.pdf_otras
181
+ ? response.data.pdf_otras
182
+ : undefined,
183
+ labs: response.data.pdf_laboratorios
184
+ ? response.data.pdf_laboratorios
185
+ : undefined,
186
+ certificate: response.data.pdf_certificado
187
+ ? response.data.pdf_certificado
188
+ : undefined,
189
+ },
190
+ files: response.data.files_atencion.map((f) => ({
191
+ name: f.nombre_file,
192
+ url: f.file,
193
+ })),
194
+ };
195
+ });
196
+ const uploadFileConsultation = validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.uploadFileConsultationParams]), zod_1.any(), async (params) => {
197
+ const form = new form_data_1.default();
198
+ form.append('vc_token', params.vcToken);
199
+ form.append('attached_file', fs_1.default.createReadStream(params.attachedFile));
200
+ if (params.fileName)
201
+ form.append('file_name', params.fileName);
202
+ const response = await makeRequest('POST', '/upload-file-consultation', form);
203
+ return response.data;
204
+ });
205
+ return {
206
+ scheduleVideoVisit,
207
+ cancelVideoVisit,
208
+ getVideoVisit,
209
+ getPatientVideoVisitHistory,
210
+ getVideoVisitDetails,
211
+ getVideoVisitLink,
212
+ getActiveVideoVisits,
213
+ getCompleteVideoVisitDetails,
214
+ uploadFileConsultation,
215
+ };
216
+ };
217
+ exports.getVideoVisitMethods = getVideoVisitMethods;
218
+ const mapVideoVisit = (raw) => {
219
+ var _a, _b, _c, _d, _e, _f, _g;
220
+ return {
221
+ id: raw.vc_id,
222
+ creationDate: utils_1.parseDateTime(raw.creation_date),
223
+ patientId: raw.patient_id,
224
+ user: { id: raw.user_id, email: raw.email, phone: raw.phone },
225
+ vcToken: raw.vc_token,
226
+ appointment: raw.appointment_id
227
+ ? {
228
+ id: raw.appointment_id,
229
+ date: utils_1.parseDateTime(`${raw.appointment_date} ${raw.appointment_time}`, raw.time_zone),
230
+ }
231
+ : undefined,
232
+ videoVisit: raw.video_visit_id
233
+ ? { id: raw.video_visit_id, status: raw.video_visit_status }
234
+ : undefined,
235
+ paymentStatus: (_a = raw.payment_status) !== null && _a !== void 0 ? _a : undefined,
236
+ atentionId: (_b = raw.atentionId) !== null && _b !== void 0 ? _b : undefined,
237
+ waitingTime: (_c = raw.waiting_time) !== null && _c !== void 0 ? _c : undefined,
238
+ address: (_d = raw.direccion) !== null && _d !== void 0 ? _d : undefined,
239
+ city: (_e = raw.localidad) !== null && _e !== void 0 ? _e : undefined,
240
+ province: (_f = raw.provincia) !== null && _f !== void 0 ? _f : undefined,
241
+ modality: (_g = raw.modalidad) !== null && _g !== void 0 ? _g : undefined,
242
+ };
243
+ };
244
+ const mapHistoricalVideoVisit = (raw) => {
245
+ return {
246
+ ...mapVideoVisit(raw),
247
+ professional: raw.professional,
248
+ specialty: raw.specialty,
249
+ };
250
+ };
package/lib/utils.d.ts CHANGED
@@ -1,3 +1,3 @@
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 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 normalizeTimezoneOffset: (raw?: string | undefined, defualtTimezone?: number) => string | undefined;
package/lib/utils.js CHANGED
@@ -1,43 +1,43 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeTimezoneOffset = exports.parseDateTime = exports.parseDate = void 0;
4
- const date_fns_1 = require("date-fns");
5
- // import {Doc24} from '.';
6
- const defaultTimeZone = '-03';
7
- const parseDate = (str, timeZone) => exports.parseDateTime(`${str} 00:00:00`, timeZone);
8
- exports.parseDate = parseDate;
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
- exports.parseDateTime = parseDateTime;
11
- const normalizeTimezoneOffset = (raw, defualtTimezone = -3) => {
12
- if (!raw)
13
- return;
14
- if (typeof raw !== 'string') {
15
- throw new Error(`Invalid timezone format: ${raw}`);
16
- }
17
- const match = raw.trim().match(/([+-]?\d+(?:[.,]\d+)?)/);
18
- if (!match) {
19
- throw new Error(`Invalid timezone format: ${raw}`);
20
- }
21
- const numStr = match[1].replace(',', '.');
22
- const rawHours = Number(numStr);
23
- if (Number.isNaN(rawHours)) {
24
- throw new Error(`Invalid numeric timezone value: ${numStr}`);
25
- }
26
- const rawMinutes = Math.round(rawHours * 60);
27
- const argentinaMinutes = Math.round(defualtTimezone * 60);
28
- const targetMinutes = argentinaMinutes + rawMinutes;
29
- const sign = targetMinutes >= 0 ? '+' : '-';
30
- const absMinutes = Math.abs(targetMinutes);
31
- const hh = Math.floor(absMinutes / 60)
32
- .toString()
33
- .padStart(2, '0');
34
- const mm = (absMinutes % 60).toString().padStart(2, '0');
35
- return mm === '00' ? `${sign}${hh}` : `${sign}${hh}:${mm}`;
36
- };
37
- exports.normalizeTimezoneOffset = normalizeTimezoneOffset;
38
- // export const getIdetificationTypeId = (type: Doc24.IdentificationType) => {
39
- // if (type === 'ndi') return 6;
40
- // if (type === 'passport') return 5;
41
- // if (type === 'credential') return 999;
42
- // throw new Error('Invalid identificationType');
43
- // };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeTimezoneOffset = exports.parseDateTime = exports.parseDate = void 0;
4
+ const date_fns_1 = require("date-fns");
5
+ // import {Doc24} from '.';
6
+ const defaultTimeZone = '-03';
7
+ const parseDate = (str, timeZone) => exports.parseDateTime(`${str} 00:00:00`, timeZone);
8
+ exports.parseDate = parseDate;
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
+ exports.parseDateTime = parseDateTime;
11
+ const normalizeTimezoneOffset = (raw, defualtTimezone = -3) => {
12
+ if (!raw)
13
+ return;
14
+ if (typeof raw !== 'string') {
15
+ throw new Error(`Invalid timezone format: ${raw}`);
16
+ }
17
+ const match = raw.trim().match(/([+-]?\d+(?:[.,]\d+)?)/);
18
+ if (!match) {
19
+ throw new Error(`Invalid timezone format: ${raw}`);
20
+ }
21
+ const numStr = match[1].replace(',', '.');
22
+ const rawHours = Number(numStr);
23
+ if (Number.isNaN(rawHours)) {
24
+ throw new Error(`Invalid numeric timezone value: ${numStr}`);
25
+ }
26
+ const rawMinutes = Math.round(rawHours * 60);
27
+ const argentinaMinutes = Math.round(defualtTimezone * 60);
28
+ const targetMinutes = argentinaMinutes + rawMinutes;
29
+ const sign = targetMinutes >= 0 ? '+' : '-';
30
+ const absMinutes = Math.abs(targetMinutes);
31
+ const hh = Math.floor(absMinutes / 60)
32
+ .toString()
33
+ .padStart(2, '0');
34
+ const mm = (absMinutes % 60).toString().padStart(2, '0');
35
+ return mm === '00' ? `${sign}${hh}` : `${sign}${hh}:${mm}`;
36
+ };
37
+ exports.normalizeTimezoneOffset = normalizeTimezoneOffset;
38
+ // export const getIdetificationTypeId = (type: Doc24.IdentificationType) => {
39
+ // if (type === 'ndi') return 6;
40
+ // if (type === 'passport') return 5;
41
+ // if (type === 'credential') return 999;
42
+ // throw new Error('Invalid identificationType');
43
+ // };
@@ -1,2 +1,2 @@
1
- import { Doc24 } from '../types';
2
- export declare const getRequestHandler: (credentials: Doc24.SdkCredentials, baseSdk: Doc24.BaseSdk, eventHandlers: Doc24.Webhook.Events) => Doc24.Webhook.Handler;
1
+ import { Doc24 } from '../types';
2
+ export declare const getRequestHandler: (credentials: Doc24.SdkCredentials, baseSdk: Doc24.BaseSdk, eventHandlers: Doc24.Webhook.Events) => Doc24.Webhook.Handler;