@integraciones_doc24/sdk 0.39.1 → 0.39.2

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.
@@ -7,16 +7,19 @@ const validation_1 = require("../request/validation");
7
7
  const schemas_1 = require("../schemas");
8
8
  const utils_1 = require("../utils");
9
9
  const getScheduleMethods = (makeRequest) => {
10
- const getScheduleDates = validation_1.validateFunction(zod_1.tuple([zod_1.number(), schemas_1.doc24Schemas.scheduleAvailabilityFilter]), zod_1.array(zod_1.date()), async (patientId, filter = {}) => {
10
+ const getScheduleDates = async (patientId, filter = {}) => {
11
+ var _a;
11
12
  const mappedFilter = {
12
13
  specialty_id: filter.specialtyId,
13
14
  professional_id: filter.professionalId,
15
+ language: (_a = filter.language) !== null && _a !== void 0 ? _a : 'ES',
14
16
  };
15
17
  const path = `/schedule/dates/${patientId}/${JSON.stringify(mappedFilter)}`;
16
18
  const response = await makeRequest('GET', path);
17
- return response.data.available_dates.map((o) => utils_1.parseDate(o.date));
18
- });
19
- const getSchedule = validation_1.validateFunction(zod_1.tuple([zod_1.number(), zod_1.number(), schemas_1.doc24Schemas.scheduleFilter.optional()]), zod_1.array(schemas_1.doc24Schemas.availableAppointment), async (patientId, specialtyId, filter = {}) => {
19
+ return response.data.available_dates.map((o) => utils_1.parseDate(o.date, o.time_zone));
20
+ };
21
+ const getSchedule = async (patientId, specialtyId, filter = {}) => {
22
+ var _a;
20
23
  const mappedFilter = {
21
24
  id_professional: filter.professionalId,
22
25
  offset: filter.offset,
@@ -25,12 +28,13 @@ const getScheduleMethods = (makeRequest) => {
25
28
  date: filter.date && date_fns_1.format(filter.date, 'yyyy-MM-dd'),
26
29
  start_hour: filter.startHour,
27
30
  finish_hour: filter.finishHour,
31
+ language: (_a = filter.language) !== null && _a !== void 0 ? _a : 'ES',
28
32
  };
29
33
  const path = `/schedule/availability/${patientId}/${specialtyId}/${JSON.stringify(mappedFilter)}`;
30
34
  const response = await makeRequest('GET', path);
31
35
  return response.data.available_appointments.map((a) => ({
32
36
  id: a.id,
33
- date: utils_1.parseDateTime(`${a.date} ${a.hour}`),
37
+ date: utils_1.parseDateTime(`${a.date} ${a.hour}`, a.time_zone),
34
38
  clinicId: a.clinic,
35
39
  professional: {
36
40
  id: a.professional_id,
@@ -47,30 +51,30 @@ const getScheduleMethods = (makeRequest) => {
47
51
  ranking: a.ranking,
48
52
  length: a.length,
49
53
  }));
50
- });
51
- const getAppointment = validation_1.validateFunction(zod_1.tuple([zod_1.number()]), schemas_1.doc24Schemas.appointment, async (appointmentId) => {
54
+ };
55
+ const getAppointment = async (appointmentId) => {
52
56
  const path = `/appointment/${appointmentId}`;
53
57
  const response = await makeRequest('GET', path);
54
58
  return {
55
59
  id: response.data.id,
56
60
  professionalId: response.data.professional_id,
57
- date: utils_1.parseDateTime(`${response.data.date} ${response.data.hour}`),
61
+ date: utils_1.parseDateTime(`${response.data.date} ${response.data.hour}`, response.data.time_zone),
58
62
  };
59
- });
60
- const getAppointmentByVcToken = validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.appointment, async (vcToken) => {
63
+ };
64
+ const getAppointmentByVcToken = async (vcToken) => {
61
65
  const path = `/appointmentByToken/${vcToken}`;
62
66
  const response = await makeRequest('GET', path);
63
67
  return {
64
68
  id: response.data.id,
65
69
  professionalId: response.data.professional_id,
66
- date: utils_1.parseDateTime(`${response.data.date} ${response.data.hour}`),
70
+ date: utils_1.parseDateTime(`${response.data.date} ${response.data.hour}`, response.data.time_zone),
67
71
  };
68
- });
72
+ };
69
73
  return {
70
- getSchedule,
71
- getScheduleDates,
72
- getAppointment,
73
- getAppointmentByVcToken,
74
+ getSchedule: validation_1.validateFunction(zod_1.tuple([zod_1.number(), zod_1.number(), schemas_1.doc24Schemas.scheduleFilter.optional()]), zod_1.array(schemas_1.doc24Schemas.availableAppointment), getSchedule),
75
+ getScheduleDates: validation_1.validateFunction(zod_1.tuple([zod_1.number(), schemas_1.doc24Schemas.scheduleAvailabilityFilter]), zod_1.array(zod_1.date()), getScheduleDates),
76
+ getAppointment: validation_1.validateFunction(zod_1.tuple([zod_1.number()]), schemas_1.doc24Schemas.appointment, getAppointment),
77
+ getAppointmentByVcToken: validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.appointment, getAppointmentByVcToken),
74
78
  };
75
79
  };
76
80
  exports.getScheduleMethods = getScheduleMethods;
@@ -32,9 +32,9 @@ export declare const getVideoVisitMethods: (makeRequest: RequestMaker) => {
32
32
  patientId: number;
33
33
  creationDate: Date;
34
34
  user: {
35
- id: number;
36
35
  phone: string | null;
37
36
  email: string | null;
37
+ id: number;
38
38
  };
39
39
  vcToken: string;
40
40
  }>;
@@ -51,13 +51,15 @@ export declare const getVideoVisitMethods: (makeRequest: RequestMaker) => {
51
51
  atentionId?: number | undefined;
52
52
  id: number | null;
53
53
  patientId: number;
54
+ professional: string;
54
55
  creationDate: Date;
55
56
  user: {
56
- id: number;
57
57
  phone: string | null;
58
58
  email: string | null;
59
+ id: number;
59
60
  };
60
61
  vcToken: string;
62
+ specialty: string;
61
63
  }[]>;
62
64
  getVideoVisitDetails: (vcId: number) => Promise<{
63
65
  professional?: {
@@ -33,10 +33,10 @@ const getVideoVisitMethods = (makeRequest) => {
33
33
  const response = await makeRequest('GET', path);
34
34
  return mapVideoVisit(response.data);
35
35
  });
36
- const getPatientVideoVisitHistory = validation_1.validateFunction(zod_1.tuple([zod_1.number()]), zod_1.array(schemas_1.doc24Schemas.videoVisit), async (patientId) => {
36
+ const getPatientVideoVisitHistory = validation_1.validateFunction(zod_1.tuple([zod_1.number()]), zod_1.array(schemas_1.doc24Schemas.historicalVideoVisit), async (patientId) => {
37
37
  const path = `/video-visit-history/${patientId}`;
38
38
  const response = await makeRequest('GET', path);
39
- return response.data.map((raw) => mapVideoVisit(raw));
39
+ return response.data.map((raw) => mapHistoricalVideoVisit(raw));
40
40
  });
41
41
  const getVideoVisitDetails = validation_1.validateFunction(zod_1.tuple([zod_1.number()]), schemas_1.doc24Schemas.videoVisitDetails, async (vcId) => {
42
42
  const path = `/video-visit-records/${vcId}`;
@@ -65,7 +65,7 @@ const getVideoVisitMethods = (makeRequest) => {
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.parseDateTime(`${response.data.appointment_date} ${response.data.appointment_time}`, response.data.time_zone),
69
69
  }
70
70
  : null,
71
71
  report: {
@@ -135,7 +135,7 @@ const mapVideoVisit = (raw) => {
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.parseDateTime(`${raw.appointment_date} ${raw.appointment_time}`, raw.time_zone),
139
139
  }
140
140
  : undefined,
141
141
  videoVisit: raw.video_visit_id
@@ -145,3 +145,10 @@ const mapVideoVisit = (raw) => {
145
145
  atentionId: (_b = raw.atentionId) !== null && _b !== void 0 ? _b : undefined,
146
146
  };
147
147
  };
148
+ const mapHistoricalVideoVisit = (raw) => {
149
+ return {
150
+ ...mapVideoVisit(raw),
151
+ professional: raw.professional,
152
+ specialty: raw.specialty,
153
+ };
154
+ };
package/lib/utils.d.ts CHANGED
@@ -1,4 +1,2 @@
1
- import { Doc24 } from '.';
2
- export declare const parseDate: (str: string) => Date;
3
- export declare const parseDateTime: (str: string) => Date;
4
- export declare const getIndetificationTypeId: (type: Doc24.IdentificationType) => 1 | 6 | 5 | 999 | 1000;
1
+ export declare const parseDate: (str: string, timeZone?: string | null | undefined) => Date;
2
+ export declare const parseDateTime: (str: string, timeZone?: string | null | undefined) => Date;
package/lib/utils.js CHANGED
@@ -1,23 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getIndetificationTypeId = exports.parseDateTime = exports.parseDate = void 0;
3
+ 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
+ // import {Doc24} from '.';
6
+ const defaultTimeZone = '-03';
7
+ const parseDate = (str, timeZone) => exports.parseDateTime(`${str} 00:00:00`, timeZone);
7
8
  exports.parseDate = parseDate;
8
- const parseDateTime = (str) => date_fns_1.parse(`${str} ${timeZone}`, 'yyyy-MM-dd HH:mm:ss X', new Date());
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());
9
10
  exports.parseDateTime = parseDateTime;
10
- const getIndetificationTypeId = (type) => {
11
- if (type === 'dni')
12
- return 1;
13
- if (type === 'ndi')
14
- return 6;
15
- if (type === 'passport')
16
- return 5;
17
- if (type === 'credential')
18
- return 999;
19
- if (type === 'nn')
20
- return 1000;
21
- throw new Error('Invalid identificationType');
22
- };
23
- exports.getIndetificationTypeId = getIndetificationTypeId;
11
+ // export const getIdetificationTypeId = (type: Doc24.IdentificationType) => {
12
+ // if (type === 'ndi') return 6;
13
+ // if (type === 'passport') return 5;
14
+ // if (type === 'credential') return 999;
15
+ // throw new Error('Invalid identificationType');
16
+ // };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integraciones_doc24/sdk",
3
- "version": "0.39.1",
3
+ "version": "0.39.2",
4
4
  "publishConfig": {
5
5
  "tag": "0.x"
6
6
  },
package/lib/test.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare const test: () => Promise<void>;
package/lib/test.js DELETED
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.test = void 0;
4
- const _1 = require(".");
5
- const test = async () => {
6
- const baseSdk = await _1.doc24Sdk({
7
- url: 'https://tapi.doc24.com.ar/ws/sdk',
8
- credentials: {
9
- iss: 'Diagnostica',
10
- key: 'gS2J78V0Zw8XiZJPGC9RS8TlECgqM2TmVtOzNAZbqputgmtc',
11
- },
12
- });
13
- const userId = await baseSdk.getUserInstance({
14
- firstName: '-',
15
- lastName: '-',
16
- identificationType: 'nn',
17
- identificationValue: 'jhYuPe9wu8WmSUroB4tLq8',
18
- // identificationValue: '6511a9d659bbdfce7385dfda',
19
- countryId: 'AR',
20
- birthdate: new Date('2023-09-25'),
21
- gender: 'm',
22
- phone: '',
23
- email: 'nomail@diagnostica.com.ar',
24
- });
25
- console.log(userId.userId);
26
- // const userSdk = await baseSdk.getUserInstance(20892);
27
- // const res = await userSdk.updatePatient(
28
- // {
29
- // identificationType: 'nn',
30
- // identificationValue: 'jhYuPe9wu8WmSUroB4tLq8',
31
- // },
32
- // {
33
- // firstName: 'Test',
34
- // lastName: 'Emergency',
35
- // identificationType: 'dni',
36
- // identificationValue: '37972512',
37
- // countryId: 'AR',
38
- // birthdate: new Date(),
39
- // gender: 'm',
40
- // },
41
- // );
42
- // console.log(res);
43
- };
44
- exports.test = test;
45
- exports.test();