@integraciones_doc24/sdk 0.39.11 → 0.40.0

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.
@@ -46,15 +46,15 @@ const getUserMethods = (makeRequest, url, credentials) => {
46
46
  mobilePhone: raw.telefono_movil,
47
47
  company: raw.empresa,
48
48
  email: raw.email,
49
- dischargeDate: raw.fecha_alta ? utils_1.parseDateTime(raw.fecha_alta) : null,
50
- leavingDate: raw.fecha_baja ? utils_1.parseDateTime(raw.fecha_baja) : null,
49
+ dischargeDate: raw.fecha_alta ? utils_1.parseDateTimeTzAR(raw.fecha_alta) : null,
50
+ leavingDate: raw.fecha_baja ? utils_1.parseDateTimeTzAR(raw.fecha_baja) : null,
51
51
  identificacion_tributaria: raw.identificacion_tributaria,
52
52
  deregistrationDate: raw.fecha_baja_padron
53
- ? utils_1.parseDateTime(raw.fecha_baja_padron)
53
+ ? utils_1.parseDateTimeTzAR(raw.fecha_baja_padron)
54
54
  : null,
55
55
  authorizationCode: raw.codigo_autorizacion,
56
56
  authorizationCodeExpiration: raw.codigo_autorizacion_vencimiento
57
- ? utils_1.parseDateTime(raw.codigo_autorizacion_vencimiento)
57
+ ? utils_1.parseDateTimeTzAR(raw.codigo_autorizacion_vencimiento)
58
58
  : null,
59
59
  };
60
60
  return mappedCoverageInfo;
@@ -11,6 +11,7 @@ const debugRequest = debug_1.default('doc24Sdk:request');
11
11
  const getRequestFactory = async (url, credentials, userId) => {
12
12
  const makeRequest = async (method, path, body) => {
13
13
  const token = await token_1.getToken(credentials, body ? JSON.stringify(body) : undefined, userId);
14
+ console.log('TOKEN', token);
14
15
  const fullUrl = url + path;
15
16
  const result = await axios_1.default({
16
17
  method,
package/lib/schemas.d.ts CHANGED
@@ -279,6 +279,7 @@ export declare const doc24Schemas: {
279
279
  date: import("zod").ZodOptional<import("zod").ZodDate>;
280
280
  startHour: import("zod").ZodOptional<import("zod").ZodString>;
281
281
  finishHour: import("zod").ZodOptional<import("zod").ZodString>;
282
+ userTimeZone: import("zod").ZodOptional<import("zod").ZodString>;
282
283
  }, "strip", import("zod").ZodTypeAny, {
283
284
  date?: Date | undefined;
284
285
  professionalId?: number | undefined;
@@ -287,6 +288,7 @@ export declare const doc24Schemas: {
287
288
  weekDay?: number | undefined;
288
289
  startHour?: string | undefined;
289
290
  finishHour?: string | undefined;
291
+ userTimeZone?: string | undefined;
290
292
  }, {
291
293
  date?: Date | undefined;
292
294
  professionalId?: number | undefined;
@@ -295,6 +297,7 @@ export declare const doc24Schemas: {
295
297
  weekDay?: number | undefined;
296
298
  startHour?: string | undefined;
297
299
  finishHour?: string | undefined;
300
+ userTimeZone?: string | undefined;
298
301
  }>;
299
302
  scheduleParameters: import("zod").ZodUnion<[import("zod").ZodObject<import("zod").extendShape<{
300
303
  patientId: import("zod").ZodNumber;
package/lib/schemas.js CHANGED
@@ -299,6 +299,7 @@ exports.doc24Schemas = {
299
299
  date: zod_1.date().optional(),
300
300
  startHour: zod_1.string().optional(),
301
301
  finishHour: zod_1.string().optional(),
302
+ userTimeZone: zod_1.string().optional(),
302
303
  }),
303
304
  scheduleParameters: zod_1.union([
304
305
  appointmentScheduleParameters,
@@ -42,21 +42,21 @@ const getChatMethods = (makeRequest) => {
42
42
  chatRoomId: c.chatroom_id,
43
43
  status: c.status,
44
44
  paymentStatus: c.payment_status,
45
- startDate: utils_1.parseDateTime(c.start_date),
46
- lastEventDate: utils_1.parseDateTime(c.fecha_ultimo_evento),
47
- closureDate: c.closure_date && utils_1.parseDateTime(c.closure_date),
45
+ startDate: utils_1.parseDateTimeTzAR(c.start_date),
46
+ lastEventDate: utils_1.parseDateTimeTzAR(c.fecha_ultimo_evento),
47
+ closureDate: c.closure_date && utils_1.parseDateTimeTzAR(c.closure_date),
48
48
  patient: {
49
49
  id: c.patient_id,
50
50
  firstName: c.patient_name,
51
51
  lastName: c.patient_lastname,
52
52
  },
53
- patientLastPost: c.patient_last_post && utils_1.parseDateTime(c.patient_last_post),
53
+ patientLastPost: c.patient_last_post && utils_1.parseDateTimeTzAR(c.patient_last_post),
54
54
  professional: {
55
55
  id: c.professional_id,
56
56
  fullName: c.professional,
57
57
  logoUrl: c.logo,
58
58
  },
59
- professionalLastPost: c.professional_last_post && utils_1.parseDateTime(c.professional_last_post),
59
+ professionalLastPost: c.professional_last_post && utils_1.parseDateTimeTzAR(c.professional_last_post),
60
60
  specialty: {
61
61
  id: c.specialty_id,
62
62
  description: c.specialty,
@@ -69,7 +69,7 @@ const getChatMethods = (makeRequest) => {
69
69
  return JSON.parse(response.data.posts).map((p) => ({
70
70
  id: p.post_id,
71
71
  message: p.post,
72
- date: utils_1.parseDateTime(p.post_date),
72
+ date: utils_1.parseDateTimeTzAR(p.post_date),
73
73
  userType: p.user_type === 'P' ? 'patient' : 'professional',
74
74
  }));
75
75
  });
@@ -8,6 +8,7 @@ export declare const getScheduleMethods: (makeRequest: RequestMaker) => {
8
8
  weekDay?: number | undefined;
9
9
  startHour?: string | undefined;
10
10
  finishHour?: string | undefined;
11
+ userTimeZone?: string | undefined;
11
12
  } | undefined) => Promise<{
12
13
  length?: number | null | undefined;
13
14
  ranking?: unknown;
@@ -28,10 +28,12 @@ const getScheduleMethods = (makeRequest) => {
28
28
  user_time_zone: filter.userTimeZone,
29
29
  };
30
30
  const path = `/schedule/availability/${patientId}/${specialtyId}/${JSON.stringify(mappedFilter)}`;
31
+ console.log(path);
31
32
  const response = await makeRequest('GET', path);
33
+ console.log(response.data);
32
34
  return response.data.available_appointments.map((a) => ({
33
35
  id: a.id,
34
- date: utils_1.parseDateTime(`${a.date} ${a.hour}`),
36
+ date: utils_1.parseDateTime(`${a.date} ${a.hour}`, a.time_zone),
35
37
  clinicId: a.clinic,
36
38
  professional: {
37
39
  id: a.professional_id,
@@ -55,7 +57,7 @@ const getScheduleMethods = (makeRequest) => {
55
57
  return {
56
58
  id: response.data.id,
57
59
  professionalId: response.data.professional_id,
58
- date: utils_1.parseDateTime(`${response.data.date} ${response.data.hour}`),
60
+ date: utils_1.parseDateTimeTzAR(`${response.data.date} ${response.data.hour}`),
59
61
  };
60
62
  });
61
63
  const getAppointmentByVcToken = validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.appointment, async (vcToken) => {
@@ -64,7 +66,7 @@ const getScheduleMethods = (makeRequest) => {
64
66
  return {
65
67
  id: response.data.id,
66
68
  professionalId: response.data.professional_id,
67
- date: utils_1.parseDateTime(`${response.data.date} ${response.data.hour}`),
69
+ date: utils_1.parseDateTimeTzAR(`${response.data.date} ${response.data.hour}`),
68
70
  };
69
71
  });
70
72
  return {
@@ -54,18 +54,18 @@ const getVideoVisitMethods = (makeRequest) => {
54
54
  patient: {
55
55
  fullName: response.data.patient,
56
56
  firstAccessDate: response.data.patient_first_access_date &&
57
- utils_1.parseDateTime(response.data.patient_first_access_date),
57
+ utils_1.parseDateTimeTzAR(response.data.patient_first_access_date),
58
58
  lastAccessDate: response.data.patient_last_access_date &&
59
- utils_1.parseDateTime(response.data.patient_last_access_date),
59
+ utils_1.parseDateTimeTzAR(response.data.patient_last_access_date),
60
60
  },
61
61
  finishDate: response.data.finish_date &&
62
- utils_1.parseDateTime(response.data.finish_date),
62
+ utils_1.parseDateTimeTzAR(response.data.finish_date),
63
63
  retries: response.data.retries,
64
64
  language: response.data.language,
65
65
  appointment: response.data.appointment_id
66
66
  ? {
67
67
  id: response.data.appointment_id,
68
- date: utils_1.parseDateTime(`${response.data.appointment_date} ${response.data.appointment_time}`),
68
+ date: utils_1.parseDateTimeTzAR(`${response.data.appointment_date} ${response.data.appointment_time}`),
69
69
  }
70
70
  : null,
71
71
  report: {
@@ -128,14 +128,14 @@ const mapVideoVisit = (raw) => {
128
128
  var _a, _b;
129
129
  return {
130
130
  id: raw.vc_id,
131
- creationDate: utils_1.parseDateTime(raw.creation_date),
131
+ creationDate: utils_1.parseDateTimeTzAR(raw.creation_date),
132
132
  patientId: raw.patient_id,
133
133
  user: { id: raw.user_id, email: raw.email, phone: raw.phone },
134
134
  vcToken: raw.vc_token,
135
135
  appointment: raw.appointment_id
136
136
  ? {
137
137
  id: raw.appointment_id,
138
- date: utils_1.parseDateTime(`${raw.appointment_date} ${raw.appointment_time}`),
138
+ date: utils_1.parseDateTimeTzAR(`${raw.appointment_date} ${raw.appointment_time}`),
139
139
  }
140
140
  : undefined,
141
141
  videoVisit: raw.video_visit_id
package/lib/utils.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Doc24 } from '.';
2
2
  export declare const parseDate: (str: string) => Date;
3
- export declare const parseDateTime: (str: string) => Date;
3
+ export declare const parseDateTime: (str: string, timeZone: string) => Date;
4
+ export declare const parseDateTimeTzAR: (str: string) => Date;
4
5
  export declare const getIndetificationTypeId: (type: Doc24.IdentificationType) => 1 | 6 | 5 | 999 | 1000 | 9 | 7;
package/lib/utils.js CHANGED
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getIndetificationTypeId = exports.parseDateTime = exports.parseDate = void 0;
3
+ exports.getIndetificationTypeId = exports.parseDateTimeTzAR = exports.parseDateTime = exports.parseDate = void 0;
4
4
  const date_fns_1 = require("date-fns");
5
- const timeZone = '-03';
6
- const parseDate = (str) => exports.parseDateTime(`${str} 00:00:00`);
5
+ // const timeZone = '-03';
6
+ const parseDate = (str) => exports.parseDateTime(`${str} 00:00:00`, '-03');
7
7
  exports.parseDate = parseDate;
8
- const parseDateTime = (str) => date_fns_1.parse(`${str} ${timeZone}`, 'yyyy-MM-dd HH:mm:ss X', new Date());
8
+ const parseDateTime = (str, timeZone) => date_fns_1.parse(`${str} ${timeZone}`, 'yyyy-MM-dd HH:mm:ss X', new Date());
9
9
  exports.parseDateTime = parseDateTime;
10
+ const parseDateTimeTzAR = (str) => date_fns_1.parse(`${str} -03`, 'yyyy-MM-dd HH:mm:ss X', new Date());
11
+ exports.parseDateTimeTzAR = parseDateTimeTzAR;
10
12
  const getIndetificationTypeId = (type) => {
11
13
  if (type === 'dni')
12
14
  return 1;
@@ -18,7 +18,7 @@ const getRequestHandler = (credentials, baseSdk, eventHandlers) => async (reques
18
18
  exports.getRequestHandler = getRequestHandler;
19
19
  const handleEvent = async (body, _baseSdk, eventHandlers) => {
20
20
  var _a, _b, _c, _d;
21
- const date = utils_1.parseDateTime(body.fecha_estado);
21
+ const date = utils_1.parseDateTimeTzAR(body.fecha_estado);
22
22
  if (body.tipo === 'consulta')
23
23
  return (_a = eventHandlers.onConsultationStatusChange) === null || _a === void 0 ? void 0 : _a.call(eventHandlers, {
24
24
  id: Number(body.id_consulta_virtual),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integraciones_doc24/sdk",
3
- "version": "0.39.11",
3
+ "version": "0.40.0",
4
4
  "publishConfig": {
5
5
  "tag": "0.x"
6
6
  },