@integraciones_doc24/sdk 0.39.11 → 0.41.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.
@@ -1,7 +1,7 @@
1
1
  import { RequestMaker } from '../request';
2
2
  export declare const getDiagnosticaMethods: (makeRequest: RequestMaker) => {
3
3
  getDiagnosticaHistory: (patient: {
4
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
4
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
5
5
  identificationValue: string;
6
6
  gender: "m" | "f";
7
7
  }, from: Date, to: Date) => Promise<{
@@ -0,0 +1,177 @@
1
+ import { RequestMaker } from '../request';
2
+ export declare const getExternalMethods: (makeRequest: RequestMaker) => {
3
+ externalLogin: (params: {
4
+ user: string;
5
+ password: string;
6
+ }) => Promise<{
7
+ gender?: "m" | "f" | "o" | undefined;
8
+ firstName: string;
9
+ lastName: string;
10
+ countryId: string;
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
+ gender?: "m" | "f" | "o" | undefined;
136
+ firstName: string;
137
+ lastName: string;
138
+ countryId: string;
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
+ };
@@ -0,0 +1,96 @@
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 getExternalMethods = (makeRequest) => {
9
+ const externalLogin = async ({ user, password, }) => {
10
+ const path = '/external-login';
11
+ const response = await makeRequest('POST', path, { user, password });
12
+ const info = response.data.login_info;
13
+ return {
14
+ firstName: info.firstname,
15
+ lastName: info.lastname,
16
+ countryId: info.country_id,
17
+ birthday: new Date(Date.parse(info.birthdate)),
18
+ identificationNumber: info.identification_number,
19
+ gender: info.gender.toLowerCase(),
20
+ email: info.email,
21
+ phone: info.telephone,
22
+ };
23
+ };
24
+ const preExternalEnrollment = async (params) => {
25
+ const path = '/pre-external-enrollment';
26
+ await makeRequest('POST', path, {
27
+ identification_number: params.identificationNumber,
28
+ birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
29
+ email: params.email,
30
+ telephone: params.phone,
31
+ });
32
+ return;
33
+ };
34
+ const externalEnrollment = async (params) => {
35
+ const path = '/external-enrollment';
36
+ const response = await makeRequest('POST', path, {
37
+ identification_number: params.identificationNumber,
38
+ birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
39
+ email: params.email,
40
+ telephone: params.phone,
41
+ password: params.password,
42
+ email_code: params.emailCode,
43
+ telephone_code: params.phoneCode,
44
+ });
45
+ const info = response.data.info;
46
+ return {
47
+ firstName: info.firstname,
48
+ lastName: info.lastname,
49
+ countryId: info.country_id,
50
+ birthday: new Date(Date.parse(info.birthdate)),
51
+ identificationNumber: info.identification_number,
52
+ gender: info.gender.toLowerCase(),
53
+ email: info.email,
54
+ phone: info.telephone,
55
+ };
56
+ };
57
+ const sendExternalVerificationCode = async (params) => {
58
+ const path = '/send-external-verification-code';
59
+ await makeRequest('POST', path, {
60
+ identification_number: params.identificationNumber,
61
+ birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
62
+ channel: params.channel,
63
+ });
64
+ return;
65
+ };
66
+ const verifyExternalVerificationCode = async (params) => {
67
+ const path = '/verify-external-verification-code';
68
+ const response = await makeRequest('POST', path, {
69
+ identification_number: params.identificationNumber,
70
+ birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
71
+ channel: params.channel,
72
+ code: params.code,
73
+ });
74
+ return response.data;
75
+ };
76
+ const externalResetPassword = async (params) => {
77
+ const path = '/external-reset';
78
+ const response = await makeRequest('POST', path, {
79
+ identification_number: params.identificationNumber,
80
+ birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
81
+ password: params.password,
82
+ email_code: params.emailCode,
83
+ telephone_code: params.phoneCode,
84
+ });
85
+ return response.data;
86
+ };
87
+ return {
88
+ externalLogin: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalLoginParams]), schemas_1.doc24Schemas.externalLoginResponse, externalLogin),
89
+ preExternalEnrollment: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.preExternalEnrollmentParams]), zod_1.void(), preExternalEnrollment),
90
+ externalEnrollment: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalEnrollmentParams]), schemas_1.doc24Schemas.externalLoginResponse, externalEnrollment),
91
+ sendExternalVerificationCode: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.sendExternalVerificationCodeParams]), zod_1.void(), sendExternalVerificationCode),
92
+ verifyExternalVerificationCode: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.verifyExternalVerificationCodeParams]), zod_1.any(), verifyExternalVerificationCode),
93
+ externalResetPassword: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalResetPasswordParams]), zod_1.any(), externalResetPassword),
94
+ };
95
+ };
96
+ exports.getExternalMethods = getExternalMethods;
@@ -4,7 +4,7 @@ export declare const getUserMethods: (makeRequest: RequestMaker, url: string, cr
4
4
  declareUser: (user: {
5
5
  firstName: string;
6
6
  lastName: string;
7
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
7
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
8
8
  identificationValue: string;
9
9
  gender: "m" | "f";
10
10
  phone: string;
@@ -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;
package/lib/index.d.ts CHANGED
@@ -8,7 +8,7 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
8
8
  declareUser: (user: {
9
9
  firstName: string;
10
10
  lastName: string;
11
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
11
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
12
12
  identificationValue: string;
13
13
  gender: "m" | "f";
14
14
  phone: string;
@@ -19,7 +19,7 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
19
19
  getUserInstance: (user: number | {
20
20
  firstName: string;
21
21
  lastName: string;
22
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
22
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
23
23
  identificationValue: string;
24
24
  gender: "m" | "f";
25
25
  phone: string;
@@ -201,7 +201,7 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
201
201
  timestamp: string;
202
202
  } | null>;
203
203
  getDiagnosticaHistory: (patient: {
204
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
204
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
205
205
  identificationValue: string;
206
206
  gender: "m" | "f";
207
207
  }, from: Date, to: Date) => Promise<{
package/lib/schemas.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export declare const doc24Schemas: {
2
- identificationType: import("zod").ZodEnum<["dni", "ndi", "passport", "credential", "nn", "cpf", "rg"]>;
2
+ identificationType: import("zod").ZodEnum<["dni", "ndi", "passport", "credential", "nn", "cpf", "rg", "rut", "cuit"]>;
3
3
  sdkCredentials: import("zod").ZodObject<{
4
4
  iss: import("zod").ZodString;
5
5
  key: import("zod").ZodString;
@@ -38,7 +38,7 @@ export declare const doc24Schemas: {
38
38
  user: import("zod").ZodObject<import("zod").extendShape<{
39
39
  firstName: import("zod").ZodString;
40
40
  lastName: import("zod").ZodString;
41
- identificationType: import("zod").ZodEnum<["dni", "ndi", "passport", "credential", "nn", "cpf", "rg"]>;
41
+ identificationType: import("zod").ZodEnum<["dni", "ndi", "passport", "credential", "nn", "cpf", "rg", "rut", "cuit"]>;
42
42
  identificationValue: import("zod").ZodString;
43
43
  countryId: import("zod").ZodString;
44
44
  birthdate: import("zod").ZodDate;
@@ -49,7 +49,7 @@ export declare const doc24Schemas: {
49
49
  }>, "strip", import("zod").ZodTypeAny, {
50
50
  firstName: string;
51
51
  lastName: string;
52
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
52
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
53
53
  identificationValue: string;
54
54
  gender: "m" | "f";
55
55
  phone: string;
@@ -59,7 +59,7 @@ export declare const doc24Schemas: {
59
59
  }, {
60
60
  firstName: string;
61
61
  lastName: string;
62
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
62
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
63
63
  identificationValue: string;
64
64
  gender: "m" | "f";
65
65
  phone: string;
@@ -70,7 +70,7 @@ export declare const doc24Schemas: {
70
70
  patient: import("zod").ZodObject<{
71
71
  firstName: import("zod").ZodString;
72
72
  lastName: import("zod").ZodString;
73
- identificationType: import("zod").ZodEnum<["dni", "ndi", "passport", "credential", "nn", "cpf", "rg"]>;
73
+ identificationType: import("zod").ZodEnum<["dni", "ndi", "passport", "credential", "nn", "cpf", "rg", "rut", "cuit"]>;
74
74
  identificationValue: import("zod").ZodString;
75
75
  countryId: import("zod").ZodString;
76
76
  birthdate: import("zod").ZodDate;
@@ -78,7 +78,7 @@ export declare const doc24Schemas: {
78
78
  }, "strip", import("zod").ZodTypeAny, {
79
79
  firstName: string;
80
80
  lastName: string;
81
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
81
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
82
82
  identificationValue: string;
83
83
  gender: "m" | "f";
84
84
  countryId: string;
@@ -86,7 +86,7 @@ export declare const doc24Schemas: {
86
86
  }, {
87
87
  firstName: string;
88
88
  lastName: string;
89
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
89
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
90
90
  identificationValue: string;
91
91
  gender: "m" | "f";
92
92
  countryId: string;
@@ -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;
@@ -1271,14 +1274,14 @@ export declare const doc24Schemas: {
1271
1274
  }>;
1272
1275
  diagnosticaPatientFilter: import("zod").ZodObject<{
1273
1276
  gender: import("zod").ZodEnum<["m", "f"]>;
1274
- identificationType: import("zod").ZodEnum<["dni", "ndi", "passport", "credential", "nn", "cpf", "rg"]>;
1277
+ identificationType: import("zod").ZodEnum<["dni", "ndi", "passport", "credential", "nn", "cpf", "rg", "rut", "cuit"]>;
1275
1278
  identificationValue: import("zod").ZodString;
1276
1279
  }, "strip", import("zod").ZodTypeAny, {
1277
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
1280
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
1278
1281
  identificationValue: string;
1279
1282
  gender: "m" | "f";
1280
1283
  }, {
1281
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
1284
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
1282
1285
  identificationValue: string;
1283
1286
  gender: "m" | "f";
1284
1287
  }>;
@@ -1439,13 +1442,13 @@ export declare const doc24Schemas: {
1439
1442
  authorizationCodeExpiration: Date | null;
1440
1443
  }>>;
1441
1444
  oldIdentificaiton: import("zod").ZodObject<{
1442
- identificationType: import("zod").ZodEnum<["dni", "ndi", "passport", "credential", "nn", "cpf", "rg"]>;
1445
+ identificationType: import("zod").ZodEnum<["dni", "ndi", "passport", "credential", "nn", "cpf", "rg", "rut", "cuit"]>;
1443
1446
  identificationValue: import("zod").ZodString;
1444
1447
  }, "strip", import("zod").ZodTypeAny, {
1445
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
1448
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
1446
1449
  identificationValue: string;
1447
1450
  }, {
1448
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
1451
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
1449
1452
  identificationValue: string;
1450
1453
  }>;
1451
1454
  };
package/lib/schemas.js CHANGED
@@ -11,6 +11,8 @@ const identificationType = zod_1.enum([
11
11
  'nn',
12
12
  'cpf',
13
13
  'rg',
14
+ 'rut',
15
+ 'cuit',
14
16
  ]);
15
17
  const sdkCredentials = zod_1.object({ iss: zod_1.string(), key: zod_1.string() });
16
18
  const basePersonData = zod_1.object({
@@ -299,6 +301,7 @@ exports.doc24Schemas = {
299
301
  date: zod_1.date().optional(),
300
302
  startHour: zod_1.string().optional(),
301
303
  finishHour: zod_1.string().optional(),
304
+ userTimeZone: zod_1.string().optional(),
302
305
  }),
303
306
  scheduleParameters: zod_1.union([
304
307
  appointmentScheduleParameters,
@@ -0,0 +1,21 @@
1
+ import { RequestMaker } from '../request';
2
+ export declare const getBinahWellnessMethods: (makeRequest: RequestMaker) => {
3
+ getBinahWellnessLink: (body: {
4
+ patientId: number;
5
+ socket: {
6
+ device: string;
7
+ provider: string;
8
+ socketUrl: string;
9
+ callbackUrl: string;
10
+ socketAuthToken: string;
11
+ };
12
+ }) => Promise<{
13
+ data: {
14
+ info: {
15
+ link: string;
16
+ };
17
+ timestamp: string;
18
+ };
19
+ signature: string;
20
+ }>;
21
+ };
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBinahWellnessMethods = void 0;
4
+ const zod_1 = require("zod");
5
+ const schemas_1 = require("../schemas");
6
+ const validation_1 = require("../request/validation");
7
+ const getBinahWellnessMethods = (makeRequest) => {
8
+ const getBinahWellnessLink = async (body) => {
9
+ const path = `/wellness-test`;
10
+ const response = await makeRequest('POST', path, {
11
+ patient_id: body.patientId,
12
+ socket: body.socket,
13
+ });
14
+ return response;
15
+ };
16
+ return {
17
+ getBinahWellnessLink: validation_1.validateFunction(zod_1.tuple([zod_1.any()]), schemas_1.doc24Schemas.binahWellnessResponse, getBinahWellnessLink),
18
+ };
19
+ };
20
+ exports.getBinahWellnessMethods = getBinahWellnessMethods;
@@ -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
  });
@@ -0,0 +1,34 @@
1
+ import { RequestMaker } from '../request';
2
+ export declare const getExternalMethods: (makeRequest: RequestMaker) => {
3
+ getExternalStudiesHistoryLink: (patient: {
4
+ gender?: "m" | "f" | "o" | undefined;
5
+ identificationType: "DNI";
6
+ identificationValue: string;
7
+ birthdate: Date;
8
+ }) => Promise<string | null>;
9
+ getExternalAppointmentsLink: (identificationValue: string, birthdate: Date) => Promise<string | null>;
10
+ getExternalAppointments: () => Promise<{
11
+ patientIdentification?: string | undefined;
12
+ date: Date;
13
+ birthdate: Date;
14
+ appointment: string;
15
+ id: number;
16
+ specialty: string;
17
+ patientName: string;
18
+ clinic: string;
19
+ professionalName: string;
20
+ modality: string;
21
+ }[]>;
22
+ cancelExternalAppointment: (appointmentId: {
23
+ patientIdentification?: string | undefined;
24
+ date: Date;
25
+ birthdate: Date;
26
+ appointment: string;
27
+ id: number;
28
+ specialty: string;
29
+ patientName: string;
30
+ clinic: string;
31
+ professionalName: string;
32
+ modality: string;
33
+ }) => Promise<void>;
34
+ };
@@ -0,0 +1,72 @@
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 getExternalStudiesHistoryLink = async (patient) => {
11
+ var _a, _b;
12
+ const path = '/history-external-studies';
13
+ const response = await makeRequest('POST', path, {
14
+ patient: mapPatientData(patient),
15
+ });
16
+ return (_b = (_a = response.data.info) === null || _a === void 0 ? void 0 : _a.link) !== null && _b !== void 0 ? _b : null;
17
+ };
18
+ const getExternalAppointmentsLink = async (identificationValue, birthdate) => {
19
+ const path = `/external-appointments-link/${identificationValue}/${date_fns_1.format(birthdate, 'yyyy-MM-dd')}`;
20
+ const response = await makeRequest('GET', path);
21
+ return response.data.link;
22
+ };
23
+ const getExternalAppointments = async () => {
24
+ const path = '/external-appointments';
25
+ const response = await makeRequest('GET', path);
26
+ return response.data.appointments.map((a) => ({
27
+ id: a.appointment_id,
28
+ patientIdentification: a.patient_id,
29
+ patientName: a.patient_name,
30
+ birthdate: utils_1.parseDate(a.birthdate),
31
+ appointment: a.appointment,
32
+ clinic: a.clinic,
33
+ professionalName: a.professional,
34
+ date: utils_1.parseDateTime(`${a.day} ${a.hour}:00`),
35
+ specialty: a.specialty,
36
+ modality: a.modality,
37
+ }));
38
+ };
39
+ const cancelExternalAppointment = async (appointment) => {
40
+ const path = `/cancel-external-appointment`;
41
+ await makeRequest('POST', path, {
42
+ appointment_id: appointment.id,
43
+ patient_id: appointment.patientIdentification,
44
+ patient_name: appointment.patientName,
45
+ birthdate: date_fns_1.format(appointment.birthdate, 'yyyy-MM-dd'),
46
+ appointment: appointment.appointment,
47
+ clinic: appointment.clinic,
48
+ professional: appointment.professionalName,
49
+ day: date_fns_1.format(appointment.date, 'yyyy-MM-dd'),
50
+ hour: date_fns_1.format(appointment.date, 'HH:mm'),
51
+ specialty: appointment.specialty,
52
+ modality: appointment.modality,
53
+ });
54
+ return;
55
+ };
56
+ return {
57
+ getExternalStudiesHistoryLink: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalPatient]), zod_1.string().nullable(), getExternalStudiesHistoryLink),
58
+ getExternalAppointmentsLink: validation_1.validateFunction(zod_1.tuple([zod_1.string(), zod_1.date()]), zod_1.string().nullable(), getExternalAppointmentsLink),
59
+ getExternalAppointments: validation_1.validateFunction(zod_1.tuple([]), zod_1.array(schemas_1.doc24Schemas.externalAppointment), getExternalAppointments),
60
+ cancelExternalAppointment: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalAppointment]), zod_1.void(), cancelExternalAppointment),
61
+ };
62
+ };
63
+ exports.getExternalMethods = getExternalMethods;
64
+ const mapPatientData = (patient) => {
65
+ var _a;
66
+ return {
67
+ birthdate: date_fns_1.format(patient.birthdate, 'yyyy-MM-dd'),
68
+ id_type: 'dni',
69
+ id_value: patient.identificationValue,
70
+ gender: (_a = patient.gender) === null || _a === void 0 ? void 0 : _a.toLocaleUpperCase(),
71
+ };
72
+ };
@@ -3,19 +3,19 @@ export declare const getPatientMethods: (makeRequest: RequestMaker) => {
3
3
  declarePatient: (patient: {
4
4
  firstName: string;
5
5
  lastName: string;
6
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
6
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
7
7
  identificationValue: string;
8
8
  gender: "m" | "f";
9
9
  countryId: string;
10
10
  birthdate: Date;
11
11
  }) => Promise<number>;
12
12
  updatePatient: (oldIdentification: {
13
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
13
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
14
14
  identificationValue: string;
15
15
  }, patient: {
16
16
  firstName: string;
17
17
  lastName: string;
18
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
18
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
19
19
  identificationValue: string;
20
20
  gender: "m" | "f";
21
21
  countryId: string;
@@ -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;
@@ -31,7 +31,7 @@ const getScheduleMethods = (makeRequest) => {
31
31
  const response = await makeRequest('GET', path);
32
32
  return response.data.available_appointments.map((a) => ({
33
33
  id: a.id,
34
- date: utils_1.parseDateTime(`${a.date} ${a.hour}`),
34
+ date: utils_1.parseDateTime(`${a.date} ${a.hour}`, a.time_zone),
35
35
  clinicId: a.clinic,
36
36
  professional: {
37
37
  id: a.professional_id,
@@ -55,7 +55,7 @@ const getScheduleMethods = (makeRequest) => {
55
55
  return {
56
56
  id: response.data.id,
57
57
  professionalId: response.data.professional_id,
58
- date: utils_1.parseDateTime(`${response.data.date} ${response.data.hour}`),
58
+ date: utils_1.parseDateTimeTzAR(`${response.data.date} ${response.data.hour}`),
59
59
  };
60
60
  });
61
61
  const getAppointmentByVcToken = validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.appointment, async (vcToken) => {
@@ -64,7 +64,7 @@ const getScheduleMethods = (makeRequest) => {
64
64
  return {
65
65
  id: response.data.id,
66
66
  professionalId: response.data.professional_id,
67
- date: utils_1.parseDateTime(`${response.data.date} ${response.data.hour}`),
67
+ date: utils_1.parseDateTimeTzAR(`${response.data.date} ${response.data.hour}`),
68
68
  };
69
69
  });
70
70
  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;
4
- export declare const getIndetificationTypeId: (type: Doc24.IdentificationType) => 1 | 6 | 5 | 999 | 1000 | 9 | 7;
3
+ export declare const parseDateTime: (str: string, timeZone: string) => Date;
4
+ export declare const parseDateTimeTzAR: (str: string) => Date;
5
+ export declare const getIndetificationTypeId: (type: Doc24.IdentificationType) => number;
package/lib/utils.js CHANGED
@@ -1,27 +1,30 @@
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;
12
+ // Doc24 identificationType to id
13
+ const identificationTypeIds = {
14
+ rg: 7,
15
+ dni: 1,
16
+ ndi: 6,
17
+ cpf: 9,
18
+ rut: 26,
19
+ cuit: 23,
20
+ nn: 1000,
21
+ passport: 5,
22
+ credential: 999,
23
+ };
10
24
  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
- if (type === 'cpf')
22
- return 9;
23
- if (type === 'rg')
24
- return 7;
25
- throw new Error('Invalid identificationType');
25
+ const id = identificationTypeIds[type];
26
+ if (!id)
27
+ throw new Error(`Invalid identificationType: ${type}`);
28
+ return id;
26
29
  };
27
30
  exports.getIndetificationTypeId = getIndetificationTypeId;
@@ -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.41.0",
4
4
  "publishConfig": {
5
5
  "tag": "0.x"
6
6
  },