@integraciones_doc24/sdk 1.16.32 → 1.16.34

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.
@@ -17,7 +17,7 @@ const getScheduleMethods = (makeRequest) => {
17
17
  };
18
18
  const path = `/schedule/dates/${patientId}/${JSON.stringify(mappedFilter)}`;
19
19
  const response = await makeRequest('GET', path);
20
- return response.data.available_dates.map((o) => utils_1.parseDate(o.date, o.time_zone));
20
+ return response.data.available_dates.map((o) => utils_1.parseDate(o.date, filter.userTimeZone));
21
21
  };
22
22
  const getSchedule = async (patientId, specialtyId, filter = {}) => {
23
23
  var _a;
@@ -37,7 +37,7 @@ const getScheduleMethods = (makeRequest) => {
37
37
  const response = await makeRequest('GET', path);
38
38
  return response.data.available_appointments.map((a) => ({
39
39
  id: a.id,
40
- date: utils_1.parseDateTime(`${a.date} ${a.hour}`, a.time_zone),
40
+ date: utils_1.parseDateTime(`${a.date} ${a.hour}`, utils_1.getConvertedHourTimeZone(filter.userTimeZone, a.time_zone)),
41
41
  clinicId: a.clinic,
42
42
  professional: {
43
43
  id: a.professional_id,
package/lib/utils.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export declare const parseDate: (str: string, timeZone?: string | null | undefined) => Date;
2
2
  export declare const parseDateTime: (str: string, timeZone?: string | null | undefined) => Date;
3
+ export declare const getConvertedHourTimeZone: (userTimeZone?: string | null | undefined, professionalTimeZone?: string | null | undefined) => string;
3
4
  export declare const normalizeTimezoneOffset: (raw?: string | undefined, defualtTimezone?: number) => string | undefined;
package/lib/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeTimezoneOffset = exports.parseDateTime = exports.parseDate = void 0;
3
+ exports.normalizeTimezoneOffset = exports.getConvertedHourTimeZone = exports.parseDateTime = exports.parseDate = void 0;
4
4
  const date_fns_1 = require("date-fns");
5
5
  // import {Doc24} from '.';
6
6
  const defaultTimeZone = '-03';
@@ -8,6 +8,31 @@ const parseDate = (str, timeZone) => exports.parseDateTime(`${str} 00:00:00`, ti
8
8
  exports.parseDate = parseDate;
9
9
  const parseDateTime = (str, timeZone) => date_fns_1.parse(`${str} ${timeZone !== null && timeZone !== void 0 ? timeZone : defaultTimeZone}`, 'yyyy-MM-dd HH:mm:ss X', new Date());
10
10
  exports.parseDateTime = parseDateTime;
11
+ const offsetToMinutes = (offset) => {
12
+ var _a;
13
+ const match = offset === null || offset === void 0 ? void 0 : offset.trim().match(/^([+-])(\d{1,2}):?(\d{2})?$/);
14
+ if (!match)
15
+ return undefined;
16
+ const minutes = Number(match[2]) * 60 + Number((_a = match[3]) !== null && _a !== void 0 ? _a : 0);
17
+ return match[1] === '-' ? -minutes : minutes;
18
+ };
19
+ const minutesToOffset = (minutes) => {
20
+ const abs = Math.abs(minutes);
21
+ const hh = Math.floor(abs / 60).toString().padStart(2, '0');
22
+ const mm = (abs % 60).toString().padStart(2, '0');
23
+ return `${minutes < 0 ? '-' : '+'}${hh}${mm === '00' ? '' : mm}`;
24
+ };
25
+ // WEH-1702: doc24 convierte la hora local del médico (en `time_zone`) al
26
+ // user_time_zone como si estuviera en -03. Esta es la zona que deshace ese
27
+ // corrimiento. Revertir cuando doc24 convierta desde `time_zone`.
28
+ const getConvertedHourTimeZone = (userTimeZone, professionalTimeZone) => {
29
+ var _a, _b;
30
+ const ar = offsetToMinutes(defaultTimeZone);
31
+ const user = (_a = offsetToMinutes(userTimeZone)) !== null && _a !== void 0 ? _a : ar;
32
+ const professional = (_b = offsetToMinutes(professionalTimeZone)) !== null && _b !== void 0 ? _b : ar;
33
+ return minutesToOffset(user - ar + professional);
34
+ };
35
+ exports.getConvertedHourTimeZone = getConvertedHourTimeZone;
11
36
  const normalizeTimezoneOffset = (raw, defualtTimezone = -3) => {
12
37
  if (!raw)
13
38
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integraciones_doc24/sdk",
3
- "version": "1.16.32",
3
+ "version": "1.16.34",
4
4
  "publishConfig": {
5
5
  "tag": "latest"
6
6
  },
@@ -1,99 +0,0 @@
1
- import { Doc24 } from '../types';
2
- export declare const getConsultationMethods: (url: string, credentials: Doc24.SdkCredentials) => {
3
- getConsultation: (consultationId: number) => Promise<{
4
- pdf_laboratorios?: any;
5
- pdf_otras?: any;
6
- pdf_imagenes?: any;
7
- snapshot_paciente?: any;
8
- snapshot_profesional?: any;
9
- custom_1?: any;
10
- custom_2?: any;
11
- custom_3?: any;
12
- custom_4?: any;
13
- custom_5?: any;
14
- tag_idioma: string;
15
- id_consulta: number;
16
- tipo_consulta: string;
17
- estado: string;
18
- tipo_usuario_cancelacion: string | null;
19
- fecha_cancelacion: string | null;
20
- estado_pago: string;
21
- referencia_mercadopago: string | null;
22
- id_atencion: number;
23
- id_profesional: number;
24
- profesional: string;
25
- modalidad_paciente_turno: string | null;
26
- provincia_consultorio: string | null;
27
- localidad_consultorio: string | null;
28
- domicilio_consultorio: string | null;
29
- marketplace: string;
30
- profesional_matriculas: any[];
31
- info_paciente: {
32
- email?: string | null | undefined;
33
- apellido?: string | null | undefined;
34
- nombre?: string | null | undefined;
35
- genero?: string | null | undefined;
36
- valor_identificacion?: string | null | undefined;
37
- telefono?: string | null | undefined;
38
- id_pais?: string | null | undefined;
39
- provincia?: string | null | undefined;
40
- localidad?: string | null | undefined;
41
- domicilio?: string | null | undefined;
42
- fecha_de_nacimiento?: string | null | undefined;
43
- tag_idioma?: number | null | undefined;
44
- estado_paciente?: number | null | undefined;
45
- fecha_suspension?: string | null | undefined;
46
- fecha_activacion?: string | null | undefined;
47
- fecha_modificacion?: string | null | undefined;
48
- fecha_baja?: string | null | undefined;
49
- id_paciente: number;
50
- id_tipo_de_identificacion: number;
51
- };
52
- fecha_primer_llamado_profesional: string;
53
- fecha_inicio: string;
54
- fecha_primer_acceso_paciente: string;
55
- fecha_ultimo_acceso_paciente: string;
56
- fecha_corte_medico: string;
57
- fecha_fin: string;
58
- intentos_conexion: number;
59
- id_turno: number | null;
60
- fecha_turno_invitacion: string | null;
61
- hora_turno_invitacion: string | null;
62
- firma_profesional: string | null;
63
- id_especialidad: number;
64
- especialidad: string;
65
- motivo: string;
66
- enfermedad_actual: string;
67
- conducta_terapeutica: string;
68
- signos_alerta: string;
69
- motivo_extendido_consulta: string;
70
- presencial_requerida: string;
71
- derivada: string;
72
- derivada_id_especialidad: string | number;
73
- derivada_presencial_obligatoria: string;
74
- derivada_comentarios: string | null;
75
- diagnostico: any[];
76
- practicas: any[];
77
- link_medicacion: any[];
78
- medicacion: any[];
79
- link_receta: string | null;
80
- link_compra: string | null;
81
- identificador_receta: string | null;
82
- codigo_verificacion_receta: string | null;
83
- financiador: string;
84
- registro_custom: any[];
85
- pdf_medicacion: any[];
86
- uploads: any[];
87
- files_atencion: any[];
88
- motivo_cancelacion: string | null;
89
- detalle_cancelacion: string | null;
90
- documentos: string;
91
- id_consultorio: number;
92
- token: string;
93
- tipo_protocolo_seguimiento: string | null;
94
- form_data: {};
95
- ubicacion: string;
96
- link_full: string;
97
- timestamp: string;
98
- } | null>;
99
- };
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getConsultationMethods = void 0;
4
- const zod_1 = require("zod");
5
- const schemas_1 = require("../schemas");
6
- const request_1 = require("../request");
7
- const validation_1 = require("../request/validation");
8
- const getConsultationMethods = (url, credentials) => {
9
- const getConsultation = validation_1.validateFunction(zod_1.tuple([zod_1.number()]), schemas_1.doc24Schemas.consultation, async (consultationId) => {
10
- // Replace /sdk with /api/v2 in the base URL
11
- const apiUrl = url.replace('/sdk', '/api/v2');
12
- const apiRequest = await request_1.getRequestFactory(apiUrl, credentials);
13
- const path = `/consulta/${consultationId}`;
14
- const response = await apiRequest('GET', path);
15
- // Remove pdf_atencion and pdf_certificado from the response
16
- const { pdf_atencion, pdf_certificado, ...attention } = response === null || response === void 0 ? void 0 : response.data;
17
- return attention;
18
- });
19
- return {
20
- getConsultation,
21
- };
22
- };
23
- exports.getConsultationMethods = getConsultationMethods;