@integraciones_doc24/sdk 0.40.0 → 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;
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<{
@@ -11,7 +11,6 @@ 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);
15
14
  const fullUrl = url + path;
16
15
  const result = await axios_1.default({
17
16
  method,
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;
@@ -1274,14 +1274,14 @@ export declare const doc24Schemas: {
1274
1274
  }>;
1275
1275
  diagnosticaPatientFilter: import("zod").ZodObject<{
1276
1276
  gender: import("zod").ZodEnum<["m", "f"]>;
1277
- 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"]>;
1278
1278
  identificationValue: import("zod").ZodString;
1279
1279
  }, "strip", import("zod").ZodTypeAny, {
1280
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
1280
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
1281
1281
  identificationValue: string;
1282
1282
  gender: "m" | "f";
1283
1283
  }, {
1284
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
1284
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
1285
1285
  identificationValue: string;
1286
1286
  gender: "m" | "f";
1287
1287
  }>;
@@ -1442,13 +1442,13 @@ export declare const doc24Schemas: {
1442
1442
  authorizationCodeExpiration: Date | null;
1443
1443
  }>>;
1444
1444
  oldIdentificaiton: import("zod").ZodObject<{
1445
- 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"]>;
1446
1446
  identificationValue: import("zod").ZodString;
1447
1447
  }, "strip", import("zod").ZodTypeAny, {
1448
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
1448
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
1449
1449
  identificationValue: string;
1450
1450
  }, {
1451
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
1451
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
1452
1452
  identificationValue: string;
1453
1453
  }>;
1454
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({
@@ -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;
@@ -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;
@@ -28,9 +28,7 @@ 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);
32
31
  const response = await makeRequest('GET', path);
33
- console.log(response.data);
34
32
  return response.data.available_appointments.map((a) => ({
35
33
  id: a.id,
36
34
  date: utils_1.parseDateTime(`${a.date} ${a.hour}`, a.time_zone),
package/lib/utils.d.ts CHANGED
@@ -2,4 +2,4 @@ import { Doc24 } from '.';
2
2
  export declare const parseDate: (str: string) => Date;
3
3
  export declare const parseDateTime: (str: string, timeZone: string) => Date;
4
4
  export declare const parseDateTimeTzAR: (str: string) => Date;
5
- export declare const getIndetificationTypeId: (type: Doc24.IdentificationType) => 1 | 6 | 5 | 999 | 1000 | 9 | 7;
5
+ export declare const getIndetificationTypeId: (type: Doc24.IdentificationType) => number;
package/lib/utils.js CHANGED
@@ -9,21 +9,22 @@ const parseDateTime = (str, timeZone) => date_fns_1.parse(`${str} ${timeZone}`,
9
9
  exports.parseDateTime = parseDateTime;
10
10
  const parseDateTimeTzAR = (str) => date_fns_1.parse(`${str} -03`, 'yyyy-MM-dd HH:mm:ss X', new Date());
11
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
+ };
12
24
  const getIndetificationTypeId = (type) => {
13
- if (type === 'dni')
14
- return 1;
15
- if (type === 'ndi')
16
- return 6;
17
- if (type === 'passport')
18
- return 5;
19
- if (type === 'credential')
20
- return 999;
21
- if (type === 'nn')
22
- return 1000;
23
- if (type === 'cpf')
24
- return 9;
25
- if (type === 'rg')
26
- return 7;
27
- throw new Error('Invalid identificationType');
25
+ const id = identificationTypeIds[type];
26
+ if (!id)
27
+ throw new Error(`Invalid identificationType: ${type}`);
28
+ return id;
28
29
  };
29
30
  exports.getIndetificationTypeId = getIndetificationTypeId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integraciones_doc24/sdk",
3
- "version": "0.40.0",
3
+ "version": "0.41.0",
4
4
  "publishConfig": {
5
5
  "tag": "0.x"
6
6
  },