@integraciones_doc24/sdk 0.36.0 → 0.37.1

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.
@@ -0,0 +1,206 @@
1
+ import { RequestMaker } from '../request';
2
+ export declare const getExternalMethods: (makeRequest: RequestMaker) => {
3
+ externalLogin: (params: {
4
+ user: string;
5
+ password: string;
6
+ }) => Promise<{
7
+ firstName: string;
8
+ lastName: string;
9
+ countryId: string;
10
+ gender: "m" | "f";
11
+ phone: string;
12
+ email: string;
13
+ birthday: Date;
14
+ identificationNumber: string;
15
+ }>;
16
+ preExternalEnrollment: (params: ({
17
+ birthdate: Date;
18
+ identificationNumber: string;
19
+ } & {
20
+ phone: string;
21
+ email: string;
22
+ }) | ({
23
+ birthdate: Date;
24
+ identificationNumber: string;
25
+ } & {
26
+ phone?: undefined;
27
+ email: string;
28
+ }) | ({
29
+ birthdate: Date;
30
+ identificationNumber: string;
31
+ } & {
32
+ email?: undefined;
33
+ phone: string;
34
+ })) => Promise<void>;
35
+ externalEnrollment: (params: ({
36
+ birthdate: Date;
37
+ identificationNumber: string;
38
+ } & {
39
+ phone: string;
40
+ email: string;
41
+ } & {
42
+ password: string;
43
+ } & {
44
+ emailCode: string;
45
+ phoneCode: string;
46
+ }) | ({
47
+ birthdate: Date;
48
+ identificationNumber: string;
49
+ } & {
50
+ phone: string;
51
+ email: string;
52
+ } & {
53
+ password: string;
54
+ } & {
55
+ phoneCode?: undefined;
56
+ emailCode: string;
57
+ }) | ({
58
+ birthdate: Date;
59
+ identificationNumber: string;
60
+ } & {
61
+ phone: string;
62
+ email: string;
63
+ } & {
64
+ password: string;
65
+ } & {
66
+ emailCode?: undefined;
67
+ phoneCode: string;
68
+ }) | ({
69
+ birthdate: Date;
70
+ identificationNumber: string;
71
+ } & {
72
+ phone?: undefined;
73
+ email: string;
74
+ } & {
75
+ password: string;
76
+ } & {
77
+ emailCode: string;
78
+ phoneCode: string;
79
+ }) | ({
80
+ birthdate: Date;
81
+ identificationNumber: string;
82
+ } & {
83
+ phone?: undefined;
84
+ email: string;
85
+ } & {
86
+ password: string;
87
+ } & {
88
+ phoneCode?: undefined;
89
+ emailCode: string;
90
+ }) | ({
91
+ birthdate: Date;
92
+ identificationNumber: string;
93
+ } & {
94
+ phone?: undefined;
95
+ email: string;
96
+ } & {
97
+ password: string;
98
+ } & {
99
+ emailCode?: undefined;
100
+ phoneCode: string;
101
+ }) | ({
102
+ birthdate: Date;
103
+ identificationNumber: string;
104
+ } & {
105
+ email?: undefined;
106
+ phone: string;
107
+ } & {
108
+ password: string;
109
+ } & {
110
+ emailCode: string;
111
+ phoneCode: string;
112
+ }) | ({
113
+ birthdate: Date;
114
+ identificationNumber: string;
115
+ } & {
116
+ email?: undefined;
117
+ phone: string;
118
+ } & {
119
+ password: string;
120
+ } & {
121
+ phoneCode?: undefined;
122
+ emailCode: string;
123
+ }) | ({
124
+ birthdate: Date;
125
+ identificationNumber: string;
126
+ } & {
127
+ email?: undefined;
128
+ phone: string;
129
+ } & {
130
+ password: string;
131
+ } & {
132
+ emailCode?: undefined;
133
+ phoneCode: string;
134
+ })) => Promise<{
135
+ firstName: string;
136
+ lastName: string;
137
+ countryId: string;
138
+ gender: "m" | "f";
139
+ phone: string;
140
+ email: string;
141
+ birthday: Date;
142
+ identificationNumber: string;
143
+ }>;
144
+ sendExternalVerificationCode: (params: {
145
+ birthdate: Date;
146
+ channel: "1" | "2";
147
+ identificationNumber: string;
148
+ }) => Promise<void>;
149
+ verifyExternalVerificationCode: (params: {
150
+ code: string;
151
+ birthdate: Date;
152
+ channel: "1" | "2";
153
+ identificationNumber: string;
154
+ }) => Promise<any>;
155
+ externalResetPassword: (params: ({
156
+ birthdate: Date;
157
+ password: string;
158
+ identificationNumber: string;
159
+ } & {
160
+ emailCode: string;
161
+ phoneCode: string;
162
+ }) | ({
163
+ birthdate: Date;
164
+ password: string;
165
+ identificationNumber: string;
166
+ } & {
167
+ phoneCode?: undefined;
168
+ emailCode: string;
169
+ }) | ({
170
+ birthdate: Date;
171
+ password: string;
172
+ identificationNumber: string;
173
+ } & {
174
+ emailCode?: undefined;
175
+ phoneCode: string;
176
+ })) => Promise<any>;
177
+ getExternalStudiesHistoryLink: (patient: {
178
+ identificationType: "DNI";
179
+ identificationValue: string;
180
+ birthdate: Date;
181
+ gender: "m" | "f";
182
+ }) => Promise<string | null>;
183
+ getExternalAppointmentsLink: (identificationValue: string, birthdate: Date) => Promise<string | null>;
184
+ getExternalAppointments: () => Promise<{
185
+ date: Date;
186
+ birthdate: Date;
187
+ appointment: string;
188
+ id: number;
189
+ specialty: string;
190
+ patientName: string;
191
+ clinic: string;
192
+ professionalName: string;
193
+ modality: string;
194
+ }[]>;
195
+ cancelExternalAppointment: (appointmentId: {
196
+ date: Date;
197
+ birthdate: Date;
198
+ appointment: string;
199
+ id: number;
200
+ specialty: string;
201
+ patientName: string;
202
+ clinic: string;
203
+ professionalName: string;
204
+ modality: string;
205
+ }) => Promise<void>;
206
+ };
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getExternalMethods = void 0;
4
+ const date_fns_1 = require("date-fns");
5
+ const zod_1 = require("zod");
6
+ const validation_1 = require("../request/validation");
7
+ const schemas_1 = require("../schemas");
8
+ const utils_1 = require("../utils");
9
+ const getExternalMethods = (makeRequest) => {
10
+ const externalLogin = async ({ user, password, }) => {
11
+ const path = '/external-login';
12
+ const response = await makeRequest('POST', path, { user, password });
13
+ const info = response.data.login_info;
14
+ return {
15
+ firstName: info.firstname,
16
+ lastName: info.lastname,
17
+ countryId: info.country_id,
18
+ birthday: new Date(Date.parse(info.birthdate)),
19
+ identificationNumber: info.identification_number,
20
+ gender: info.gender.toLowerCase(),
21
+ email: info.email,
22
+ phone: info.telephone,
23
+ };
24
+ };
25
+ const preExternalEnrollment = async (params) => {
26
+ const path = '/pre-external-enrollment';
27
+ await makeRequest('POST', path, {
28
+ identification_number: params.identificationNumber,
29
+ birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
30
+ email: params.email,
31
+ telephone: params.phone,
32
+ });
33
+ return;
34
+ };
35
+ const externalEnrollment = async (params) => {
36
+ const path = '/external-enrollment';
37
+ const response = await makeRequest('POST', path, {
38
+ identification_number: params.identificationNumber,
39
+ birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
40
+ email: params.email,
41
+ telephone: params.phone,
42
+ password: params.password,
43
+ email_code: params.emailCode,
44
+ telephone_code: params.phoneCode,
45
+ });
46
+ const info = response.data.info;
47
+ return {
48
+ firstName: info.firstname,
49
+ lastName: info.lastname,
50
+ countryId: info.country_id,
51
+ birthday: new Date(Date.parse(info.birthdate)),
52
+ identificationNumber: info.identification_number,
53
+ gender: info.gender.toLowerCase(),
54
+ email: info.email,
55
+ phone: info.telephone,
56
+ };
57
+ };
58
+ const sendExternalVerificationCode = async (params) => {
59
+ const path = '/send-external-verification-code';
60
+ await makeRequest('POST', path, {
61
+ identification_number: params.identificationNumber,
62
+ birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
63
+ channel: params.channel,
64
+ });
65
+ return;
66
+ };
67
+ const verifyExternalVerificationCode = async (params) => {
68
+ const path = '/verify-external-verification-code';
69
+ const response = await makeRequest('POST', path, {
70
+ identification_number: params.identificationNumber,
71
+ birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
72
+ channel: params.channel,
73
+ code: params.code,
74
+ });
75
+ return response.data;
76
+ };
77
+ const externalResetPassword = async (params) => {
78
+ const path = '/external-reset';
79
+ const response = await makeRequest('POST', path, {
80
+ identification_number: params.identificationNumber,
81
+ birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
82
+ password: params.password,
83
+ email_code: params.emailCode,
84
+ telephone_code: params.phoneCode,
85
+ });
86
+ return response.data;
87
+ };
88
+ const getExternalStudiesHistoryLink = async (patient) => {
89
+ var _a, _b;
90
+ const path = '/history-external-studies';
91
+ const response = await makeRequest('POST', path, {
92
+ patient: mapPatientData(patient),
93
+ });
94
+ return (_b = (_a = response.data.info) === null || _a === void 0 ? void 0 : _a.link) !== null && _b !== void 0 ? _b : null;
95
+ };
96
+ const getExternalAppointmentsLink = async (identificationValue, birthdate) => {
97
+ const path = `/external-appointments-link/${identificationValue}/${date_fns_1.format(birthdate, 'yyyy-MM-dd')}`;
98
+ const response = await makeRequest('GET', path);
99
+ return response.data.link;
100
+ };
101
+ const getExternalAppointments = async () => {
102
+ const path = '/external-appointments';
103
+ const response = await makeRequest('GET', path);
104
+ return response.data.appointments.map((a) => ({
105
+ id: a.appointment_id,
106
+ patientName: a.patient_name,
107
+ birthdate: utils_1.parseDate(a.birthdate),
108
+ appointment: a.appointment,
109
+ clinic: a.clinic,
110
+ professionalName: a.professional,
111
+ date: utils_1.parseDateTime(`${a.day} ${a.hour}:00`),
112
+ specialty: a.specialty,
113
+ modality: a.modality,
114
+ }));
115
+ };
116
+ const cancelExternalAppointment = async (appointment) => {
117
+ const path = `/cancel-external-appointment`;
118
+ await makeRequest('POST', path, {
119
+ appointment_id: appointment.id,
120
+ patient_name: appointment.patientName,
121
+ birthdate: date_fns_1.format(appointment.birthdate, 'yyyy-MM-dd'),
122
+ appointment: appointment.appointment,
123
+ clinic: appointment.clinic,
124
+ professional: appointment.professionalName,
125
+ day: date_fns_1.format(appointment.date, 'yyyy-MM-dd'),
126
+ hour: date_fns_1.format(appointment.date, 'HH:mm'),
127
+ specialty: appointment.specialty,
128
+ modality: appointment.modality,
129
+ });
130
+ return;
131
+ };
132
+ return {
133
+ externalLogin: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalLoginParams]), schemas_1.doc24Schemas.externalLoginResponse, externalLogin),
134
+ preExternalEnrollment: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.preExternalEnrollmentParams]), zod_1.void(), preExternalEnrollment),
135
+ externalEnrollment: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalEnrollmentParams]), schemas_1.doc24Schemas.externalLoginResponse, externalEnrollment),
136
+ sendExternalVerificationCode: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.sendExternalVerificationCodeParams]), zod_1.void(), sendExternalVerificationCode),
137
+ verifyExternalVerificationCode: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.verifyExternalVerificationCodeParams]), zod_1.any(), verifyExternalVerificationCode),
138
+ externalResetPassword: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalResetPasswordParams]), zod_1.any(), externalResetPassword),
139
+ getExternalStudiesHistoryLink: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalPatient]), zod_1.string().nullable(), getExternalStudiesHistoryLink),
140
+ getExternalAppointmentsLink: validation_1.validateFunction(zod_1.tuple([zod_1.string(), zod_1.date()]), zod_1.string().nullable(), getExternalAppointmentsLink),
141
+ getExternalAppointments: validation_1.validateFunction(zod_1.tuple([]), zod_1.array(schemas_1.doc24Schemas.externalAppointment), getExternalAppointments),
142
+ cancelExternalAppointment: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalAppointment]), zod_1.void(), cancelExternalAppointment),
143
+ };
144
+ };
145
+ exports.getExternalMethods = getExternalMethods;
146
+ const mapPatientData = (patient) => {
147
+ return {
148
+ birthdate: date_fns_1.format(patient.birthdate, 'yyyy-MM-dd'),
149
+ id_type: 'dni',
150
+ id_value: patient.identificationValue,
151
+ gender: patient.gender.toLocaleUpperCase(),
152
+ };
153
+ };
package/lib/schemas.d.ts CHANGED
@@ -302,11 +302,15 @@ export declare const doc24Schemas: {
302
302
  language: import("zod").ZodString;
303
303
  details: import("zod").ZodString;
304
304
  extraInfo: import("zod").ZodAny;
305
+ kioskId: import("zod").ZodOptional<import("zod").ZodString>;
306
+ kioskLocation: import("zod").ZodOptional<import("zod").ZodString>;
305
307
  }, {
306
308
  type: import("zod").ZodLiteral<"appointment">;
307
309
  appointmentId: import("zod").ZodUnion<[import("zod").ZodNumber, import("zod").ZodString]>;
308
310
  }>, "strip", import("zod").ZodTypeAny, {
309
311
  extraInfo?: any;
312
+ kioskId?: string | undefined;
313
+ kioskLocation?: string | undefined;
310
314
  type: "appointment";
311
315
  patientId: number;
312
316
  specialtyId: number;
@@ -315,6 +319,8 @@ export declare const doc24Schemas: {
315
319
  appointmentId: string | number;
316
320
  }, {
317
321
  extraInfo?: any;
322
+ kioskId?: string | undefined;
323
+ kioskLocation?: string | undefined;
318
324
  type: "appointment";
319
325
  patientId: number;
320
326
  specialtyId: number;
@@ -327,10 +333,14 @@ export declare const doc24Schemas: {
327
333
  language: import("zod").ZodString;
328
334
  details: import("zod").ZodString;
329
335
  extraInfo: import("zod").ZodAny;
336
+ kioskId: import("zod").ZodOptional<import("zod").ZodString>;
337
+ kioskLocation: import("zod").ZodOptional<import("zod").ZodString>;
330
338
  }, {
331
339
  type: import("zod").ZodLiteral<"instant">;
332
340
  }>, "strip", import("zod").ZodTypeAny, {
333
341
  extraInfo?: any;
342
+ kioskId?: string | undefined;
343
+ kioskLocation?: string | undefined;
334
344
  type: "instant";
335
345
  patientId: number;
336
346
  specialtyId: number;
@@ -338,6 +348,8 @@ export declare const doc24Schemas: {
338
348
  details: string;
339
349
  }, {
340
350
  extraInfo?: any;
351
+ kioskId?: string | undefined;
352
+ kioskLocation?: string | undefined;
341
353
  type: "instant";
342
354
  patientId: number;
343
355
  specialtyId: number;
package/lib/schemas.js CHANGED
@@ -60,6 +60,8 @@ const baseScheduleParameters = zod_1.object({
60
60
  language: zod_1.string(),
61
61
  details: zod_1.string(),
62
62
  extraInfo: zod_1.any(),
63
+ kioskId: zod_1.string().optional(),
64
+ kioskLocation: zod_1.string().optional(),
63
65
  });
64
66
  const appointmentScheduleParameters = baseScheduleParameters.extend({
65
67
  type: zod_1.literal('appointment'),
@@ -2,6 +2,8 @@ import { RequestMaker } from '../request';
2
2
  export declare const getVideoVisitMethods: (makeRequest: RequestMaker) => {
3
3
  scheduleVideoVisit: (params: {
4
4
  extraInfo?: any;
5
+ kioskId?: string | undefined;
6
+ kioskLocation?: string | undefined;
5
7
  type: "appointment";
6
8
  patientId: number;
7
9
  specialtyId: number;
@@ -10,6 +12,8 @@ export declare const getVideoVisitMethods: (makeRequest: RequestMaker) => {
10
12
  appointmentId: string | number;
11
13
  } | {
12
14
  extraInfo?: any;
15
+ kioskId?: string | undefined;
16
+ kioskLocation?: string | undefined;
13
17
  type: "instant";
14
18
  patientId: number;
15
19
  specialtyId: number;
@@ -20,6 +20,8 @@ const getVideoVisitMethods = (makeRequest) => {
20
20
  language: params.language.toUpperCase(),
21
21
  details: params.details,
22
22
  extra_info: params.extraInfo,
23
+ kioskId: params.kioskId,
24
+ kioskLocation: params.kioskLocation,
23
25
  };
24
26
  const response = await makeRequest('POST', '/video-visit', mappedParams);
25
27
  return response.data.vc_token;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integraciones_doc24/sdk",
3
- "version": "0.36.0",
3
+ "version": "0.37.1",
4
4
  "publishConfig": {
5
5
  "tag": "0.x"
6
6
  },