@integraciones_doc24/sdk 0.42.4 → 0.42.7

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.
package/README.md CHANGED
@@ -73,7 +73,7 @@ type SdkParams = {
73
73
  credentials: SdkCredentials;
74
74
  };
75
75
  type BaseSdk = {
76
- getUserInstance: (user: User) => Promise<UserSdk>;
76
+ getUserInstance: (user: User | number) => Promise<UserSdk>;
77
77
  getProfessional: (professionalId: number) => Promise<Professional>;
78
78
  getAvailableScheduleClinics: () => Promise<AvailableScheduleClinics>;
79
79
  getConsultation: (consultationId: number) => Promise<Consultation | null>;
@@ -112,6 +112,14 @@ Most of the methods need a user specified, so `getUserInstance` returns an insta
112
112
  ```ts
113
113
  type UserSdk = {
114
114
  declarePatient: (patient: Patient) => Promise<number>;
115
+ updatePatient: (
116
+ oldIdentification: OldIdentification,
117
+ patient: PatientUpdate,
118
+ ) => Promise<number>;
119
+ userId: number;
120
+ // Present when getUserInstance receives user data. The /user endpoint
121
+ // creates or reuses this patient together with the Doc24 user.
122
+ patientId?: number;
115
123
  getSpecialties: (
116
124
  mode: SpecialtyMode,
117
125
  language: string,
@@ -134,3 +142,7 @@ type UserSdk = {
134
142
  userId: number;
135
143
  };
136
144
  ```
145
+
146
+ `Patient` contains identity and demographic data. `PatientUpdate` additionally
147
+ requires a valid `email` and a string `phone`; those contact fields are sent only
148
+ to `/update-patient`, not to `/patient`.
@@ -11,22 +11,22 @@ export declare const getDiagnosticaMethods: (makeRequest: RequestMaker) => {
11
11
  deepLink: string;
12
12
  }[]>;
13
13
  getDiagnosticaDeepLink: (kiosk: string, user: {
14
- language: string;
15
14
  firstName: string;
16
15
  lastName: string;
17
- birthday: Date;
18
16
  identificationType: "dni";
19
17
  identificationValue: string;
20
18
  gender: "m" | "f";
21
- phone: string;
22
19
  email: string;
20
+ phone: string;
21
+ language: string;
22
+ birthday: Date;
23
23
  }, patient: {
24
24
  firstName: string;
25
25
  lastName: string;
26
- birthday: Date;
27
26
  identificationType: "dni";
28
27
  identificationValue: string;
29
28
  gender: "m" | "f";
29
+ birthday: Date;
30
30
  }) => Promise<{
31
31
  forwardingRequired: true;
32
32
  deepLink: string;
@@ -34,21 +34,21 @@ export declare const getDiagnosticaMethods: (makeRequest: RequestMaker) => {
34
34
  forwardingRequired: false;
35
35
  }>;
36
36
  getDiagnosticaAccess: (kiosk: string, user: {
37
- language: string;
38
37
  firstName: string;
39
38
  lastName: string;
40
- birthday: Date;
41
39
  identificationType: "dni";
42
40
  identificationValue: string;
43
41
  gender: "m" | "f";
44
- phone: string;
45
42
  email: string;
43
+ phone: string;
44
+ language: string;
45
+ birthday: Date;
46
46
  }, patient: {
47
47
  firstName: string;
48
48
  lastName: string;
49
- birthday: Date;
50
49
  identificationType: "dni";
51
50
  identificationValue: string;
52
51
  gender: "m" | "f";
52
+ birthday: Date;
53
53
  }) => Promise<void>;
54
54
  };
@@ -6,20 +6,20 @@ export declare const getUserMethods: (makeRequest: RequestMaker, url: string, cr
6
6
  lastName: string;
7
7
  identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
8
8
  identificationValue: string;
9
- gender: "m" | "f";
10
- phone: string;
11
- email: string;
12
9
  countryId: string;
13
10
  birthdate: Date;
11
+ gender: "m" | "f";
12
+ email: string;
13
+ phone: string;
14
14
  }) => Promise<any>;
15
15
  getUserInstance: (...params: any) => Promise<any>;
16
16
  enroll: (...params: any) => Promise<void>;
17
17
  getConverageInfo: (identificationValue: string) => Promise<{
18
18
  firstName: string | null;
19
19
  lastName: string | null;
20
+ birthdate: Date;
20
21
  gender: "m" | "f";
21
22
  email: string | null;
22
- birthdate: Date;
23
23
  identificationNumber: string;
24
24
  plan: string | null;
25
25
  financerId: number | null;
@@ -8,7 +8,7 @@ const schemas_1 = require("../schemas");
8
8
  const userSdk_1 = require("../userSdk");
9
9
  const utils_1 = require("../utils");
10
10
  const getUserMethods = (makeRequest, url, credentials) => {
11
- const getUserId = async (user) => {
11
+ const getUserIdentity = async (user) => {
12
12
  const mappedUser = {
13
13
  lastname: user.lastName,
14
14
  firstname: user.firstName,
@@ -23,8 +23,12 @@ const getUserMethods = (makeRequest, url, credentials) => {
23
23
  const response = await makeRequest('POST', '/user', {
24
24
  user_data: mappedUser,
25
25
  });
26
- return response.data.user_id;
26
+ return {
27
+ userId: response.data.user_id,
28
+ patientId: response.data.patient_id,
29
+ };
27
30
  };
31
+ const getUserId = async (user) => (await getUserIdentity(user)).userId;
28
32
  const getConverageInfo = validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.coverageInfo, async (identificationValue) => {
29
33
  const path = `/info-coverage/${identificationValue}`;
30
34
  const response = await makeRequest('GET', path);
@@ -64,8 +68,10 @@ const getUserMethods = (makeRequest, url, credentials) => {
64
68
  getUserInstance: validation_1.validateFunction(zod_1.tuple([zod_1.union([schemas_1.doc24Schemas.user, zod_1.number()])]),
65
69
  // TODO: validate?
66
70
  zod_1.any(), async (user) => {
67
- const userId = typeof user === 'number' ? user : await getUserId(user);
68
- return userSdk_1.userSdk(url, credentials, userId);
71
+ const identity = typeof user === 'number'
72
+ ? { userId: user, patientId: undefined }
73
+ : await getUserIdentity(user);
74
+ return userSdk_1.userSdk(url, credentials, identity.userId, identity.patientId);
69
75
  }),
70
76
  enroll: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.enrollmentParams]), zod_1.void(), async (params) => {
71
77
  const path = `/enrollment`;
package/lib/index.d.ts CHANGED
@@ -10,32 +10,32 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
10
10
  lastName: string;
11
11
  identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
12
12
  identificationValue: string;
13
- gender: "m" | "f";
14
- phone: string;
15
- email: string;
16
13
  countryId: string;
17
14
  birthdate: Date;
15
+ gender: "m" | "f";
16
+ email: string;
17
+ phone: string;
18
18
  }) => Promise<number>;
19
19
  getUserInstance: (user: number | {
20
20
  firstName: string;
21
21
  lastName: string;
22
22
  identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
23
23
  identificationValue: string;
24
- gender: "m" | "f";
25
- phone: string;
26
- email: string;
27
24
  countryId: string;
28
25
  birthdate: Date;
26
+ gender: "m" | "f";
27
+ email: string;
28
+ phone: string;
29
29
  }) => Promise<Doc24.UserSdk>;
30
30
  getProfessional: (professionalId: number) => Promise<{
31
- id: number;
32
- logoUrl: string;
33
31
  firstName: string;
34
32
  lastName: string;
33
+ birthdate: Date;
35
34
  gender: "m" | "f";
36
- phone: string | null;
37
35
  email: string;
38
- birthdate: Date;
36
+ phone: string | null;
37
+ id: number;
38
+ logoUrl: string;
39
39
  specialties: {
40
40
  id: number;
41
41
  description: string;
@@ -73,9 +73,9 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
73
73
  enroll: (params: {
74
74
  firstName: string;
75
75
  lastName: string;
76
+ birthdate: Date;
76
77
  gender: "m" | "f";
77
78
  email: string;
78
- birthdate: Date;
79
79
  startDate: Date;
80
80
  identificationNumber: string;
81
81
  plan: string;
@@ -83,9 +83,9 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
83
83
  getConverageInfo: (identificationValue: string) => Promise<{
84
84
  firstName: string | null;
85
85
  lastName: string | null;
86
+ birthdate: Date;
86
87
  gender: "m" | "f";
87
88
  email: string | null;
88
- birthdate: Date;
89
89
  identificationNumber: string;
90
90
  plan: string | null;
91
91
  financerId: number | null;
@@ -211,22 +211,22 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
211
211
  deepLink: string;
212
212
  }[]>;
213
213
  getDiagnosticaDeepLink: (kiosk: string, user: {
214
- language: string;
215
214
  firstName: string;
216
215
  lastName: string;
217
- birthday: Date;
218
216
  identificationType: "dni";
219
217
  identificationValue: string;
220
218
  gender: "m" | "f";
221
- phone: string;
222
219
  email: string;
220
+ phone: string;
221
+ language: string;
222
+ birthday: Date;
223
223
  }, patient: {
224
224
  firstName: string;
225
225
  lastName: string;
226
- birthday: Date;
227
226
  identificationType: "dni";
228
227
  identificationValue: string;
229
228
  gender: "m" | "f";
229
+ birthday: Date;
230
230
  }) => Promise<{
231
231
  forwardingRequired: true;
232
232
  deepLink: string;
@@ -234,22 +234,22 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
234
234
  forwardingRequired: false;
235
235
  }>;
236
236
  getDiagnosticaAccess: (kiosk: string, user: {
237
- language: string;
238
237
  firstName: string;
239
238
  lastName: string;
240
- birthday: Date;
241
239
  identificationType: "dni";
242
240
  identificationValue: string;
243
241
  gender: "m" | "f";
244
- phone: string;
245
242
  email: string;
243
+ phone: string;
244
+ language: string;
245
+ birthday: Date;
246
246
  }, patient: {
247
247
  firstName: string;
248
248
  lastName: string;
249
- birthday: Date;
250
249
  identificationType: "dni";
251
250
  identificationValue: string;
252
251
  gender: "m" | "f";
252
+ birthday: Date;
253
253
  }) => Promise<void>;
254
254
  }>;
255
255
  export type { Doc24 } from './types';
package/lib/schemas.d.ts CHANGED
@@ -43,8 +43,6 @@ export declare const doc24Schemas: {
43
43
  countryId: import("zod").ZodString;
44
44
  birthdate: import("zod").ZodDate;
45
45
  gender: import("zod").ZodEnum<["m", "f"]>;
46
- email: import("zod").ZodString;
47
- phone: import("zod").ZodString;
48
46
  }, {
49
47
  phone: import("zod").ZodString;
50
48
  email: import("zod").ZodString;
@@ -53,21 +51,21 @@ export declare const doc24Schemas: {
53
51
  lastName: string;
54
52
  identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
55
53
  identificationValue: string;
56
- gender: "m" | "f";
57
- phone: string;
58
- email: string;
59
54
  countryId: string;
60
55
  birthdate: Date;
56
+ gender: "m" | "f";
57
+ email: string;
58
+ phone: string;
61
59
  }, {
62
60
  firstName: string;
63
61
  lastName: string;
64
62
  identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
65
63
  identificationValue: string;
66
- gender: "m" | "f";
67
- phone: string;
68
- email: string;
69
64
  countryId: string;
70
65
  birthdate: Date;
66
+ gender: "m" | "f";
67
+ email: string;
68
+ phone: string;
71
69
  }>;
72
70
  patient: import("zod").ZodObject<{
73
71
  firstName: import("zod").ZodString;
@@ -77,28 +75,54 @@ export declare const doc24Schemas: {
77
75
  countryId: import("zod").ZodString;
78
76
  birthdate: import("zod").ZodDate;
79
77
  gender: import("zod").ZodEnum<["m", "f"]>;
80
- email: import("zod").ZodString;
81
- phone: import("zod").ZodString;
82
78
  }, "strip", import("zod").ZodTypeAny, {
83
79
  firstName: string;
84
80
  lastName: string;
85
81
  identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
86
82
  identificationValue: string;
83
+ countryId: string;
84
+ birthdate: Date;
87
85
  gender: "m" | "f";
88
- phone: string;
89
- email: string;
86
+ }, {
87
+ firstName: string;
88
+ lastName: string;
89
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
90
+ identificationValue: string;
90
91
  countryId: string;
91
92
  birthdate: Date;
93
+ gender: "m" | "f";
94
+ }>;
95
+ patientUpdate: import("zod").ZodObject<import("zod").extendShape<{
96
+ firstName: import("zod").ZodString;
97
+ lastName: import("zod").ZodString;
98
+ identificationType: import("zod").ZodEnum<["dni", "ndi", "passport", "credential", "nn", "cpf", "rg", "rut", "cuit"]>;
99
+ identificationValue: import("zod").ZodString;
100
+ countryId: import("zod").ZodString;
101
+ birthdate: import("zod").ZodDate;
102
+ gender: import("zod").ZodEnum<["m", "f"]>;
92
103
  }, {
104
+ email: import("zod").ZodString;
105
+ phone: import("zod").ZodString;
106
+ }>, "strip", import("zod").ZodTypeAny, {
93
107
  firstName: string;
94
108
  lastName: string;
95
109
  identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
96
110
  identificationValue: string;
111
+ countryId: string;
112
+ birthdate: Date;
97
113
  gender: "m" | "f";
98
- phone: string;
99
114
  email: string;
115
+ phone: string;
116
+ }, {
117
+ firstName: string;
118
+ lastName: string;
119
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
120
+ identificationValue: string;
100
121
  countryId: string;
101
122
  birthdate: Date;
123
+ gender: "m" | "f";
124
+ email: string;
125
+ phone: string;
102
126
  }>;
103
127
  specialtyMode: import("zod").ZodEnum<["appointment", "chat", "instant"]>;
104
128
  specialty: import("zod").ZodObject<{
@@ -364,13 +388,13 @@ export declare const doc24Schemas: {
364
388
  email: import("zod").ZodNullable<import("zod").ZodString>;
365
389
  phone: import("zod").ZodNullable<import("zod").ZodString>;
366
390
  }, "strip", import("zod").ZodTypeAny, {
367
- id: number;
368
- phone: string | null;
369
391
  email: string | null;
370
- }, {
371
- id: number;
372
392
  phone: string | null;
393
+ id: number;
394
+ }, {
373
395
  email: string | null;
396
+ phone: string | null;
397
+ id: number;
374
398
  }>;
375
399
  vcToken: import("zod").ZodString;
376
400
  appointment: import("zod").ZodOptional<import("zod").ZodObject<{
@@ -410,9 +434,9 @@ export declare const doc24Schemas: {
410
434
  patientId: number;
411
435
  creationDate: Date;
412
436
  user: {
413
- id: number;
414
- phone: string | null;
415
437
  email: string | null;
438
+ phone: string | null;
439
+ id: number;
416
440
  };
417
441
  vcToken: string;
418
442
  }, {
@@ -430,9 +454,9 @@ export declare const doc24Schemas: {
430
454
  patientId: number;
431
455
  creationDate: Date;
432
456
  user: {
433
- id: number;
434
- phone: string | null;
435
457
  email: string | null;
458
+ phone: string | null;
459
+ id: number;
436
460
  };
437
461
  vcToken: string;
438
462
  }>;
@@ -1008,14 +1032,14 @@ export declare const doc24Schemas: {
1008
1032
  brief: string;
1009
1033
  }>;
1010
1034
  }, "strip", import("zod").ZodTypeAny, {
1011
- id: number;
1012
- logoUrl: string;
1013
1035
  firstName: string;
1014
1036
  lastName: string;
1037
+ birthdate: Date;
1015
1038
  gender: "m" | "f";
1016
- phone: string | null;
1017
1039
  email: string;
1018
- birthdate: Date;
1040
+ phone: string | null;
1041
+ id: number;
1042
+ logoUrl: string;
1019
1043
  specialties: {
1020
1044
  id: number;
1021
1045
  description: string;
@@ -1031,14 +1055,14 @@ export declare const doc24Schemas: {
1031
1055
  brief: string;
1032
1056
  };
1033
1057
  }, {
1034
- id: number;
1035
- logoUrl: string;
1036
1058
  firstName: string;
1037
1059
  lastName: string;
1060
+ birthdate: Date;
1038
1061
  gender: "m" | "f";
1039
- phone: string | null;
1040
1062
  email: string;
1041
- birthdate: Date;
1063
+ phone: string | null;
1064
+ id: number;
1065
+ logoUrl: string;
1042
1066
  specialties: {
1043
1067
  id: number;
1044
1068
  description: string;
@@ -1152,13 +1176,13 @@ export declare const doc24Schemas: {
1152
1176
  firstName: import("zod").ZodString;
1153
1177
  lastName: import("zod").ZodString;
1154
1178
  }, "strip", import("zod").ZodTypeAny, {
1155
- id: number;
1156
1179
  firstName: string;
1157
1180
  lastName: string;
1158
- }, {
1159
1181
  id: number;
1182
+ }, {
1160
1183
  firstName: string;
1161
1184
  lastName: string;
1185
+ id: number;
1162
1186
  }>;
1163
1187
  patientLastPost: import("zod").ZodNullable<import("zod").ZodDate>;
1164
1188
  professional: import("zod").ZodObject<{
@@ -1190,9 +1214,9 @@ export declare const doc24Schemas: {
1190
1214
  }, "strip", import("zod").ZodTypeAny, {
1191
1215
  id: number;
1192
1216
  patient: {
1193
- id: number;
1194
1217
  firstName: string;
1195
1218
  lastName: string;
1219
+ id: number;
1196
1220
  };
1197
1221
  professional: {
1198
1222
  id: number;
@@ -1214,9 +1238,9 @@ export declare const doc24Schemas: {
1214
1238
  }, {
1215
1239
  id: number;
1216
1240
  patient: {
1217
- id: number;
1218
1241
  firstName: string;
1219
1242
  lastName: string;
1243
+ id: number;
1220
1244
  };
1221
1245
  professional: {
1222
1246
  id: number;
@@ -1264,18 +1288,18 @@ export declare const doc24Schemas: {
1264
1288
  }, "strip", import("zod").ZodTypeAny, {
1265
1289
  firstName: string;
1266
1290
  lastName: string;
1291
+ birthdate: Date;
1267
1292
  gender: "m" | "f";
1268
1293
  email: string;
1269
- birthdate: Date;
1270
1294
  startDate: Date;
1271
1295
  identificationNumber: string;
1272
1296
  plan: string;
1273
1297
  }, {
1274
1298
  firstName: string;
1275
1299
  lastName: string;
1300
+ birthdate: Date;
1276
1301
  gender: "m" | "f";
1277
1302
  email: string;
1278
- birthdate: Date;
1279
1303
  startDate: Date;
1280
1304
  identificationNumber: string;
1281
1305
  plan: string;
@@ -1321,25 +1345,25 @@ export declare const doc24Schemas: {
1321
1345
  email: import("zod").ZodString;
1322
1346
  language: import("zod").ZodString;
1323
1347
  }>, "strip", import("zod").ZodTypeAny, {
1324
- language: string;
1325
1348
  firstName: string;
1326
1349
  lastName: string;
1327
- birthday: Date;
1328
1350
  identificationType: "dni";
1329
1351
  identificationValue: string;
1330
1352
  gender: "m" | "f";
1331
- phone: string;
1332
1353
  email: string;
1333
- }, {
1354
+ phone: string;
1334
1355
  language: string;
1356
+ birthday: Date;
1357
+ }, {
1335
1358
  firstName: string;
1336
1359
  lastName: string;
1337
- birthday: Date;
1338
1360
  identificationType: "dni";
1339
1361
  identificationValue: string;
1340
1362
  gender: "m" | "f";
1341
- phone: string;
1342
1363
  email: string;
1364
+ phone: string;
1365
+ language: string;
1366
+ birthday: Date;
1343
1367
  }>;
1344
1368
  diagnosticaPatient: import("zod").ZodObject<{
1345
1369
  firstName: import("zod").ZodString;
@@ -1351,17 +1375,17 @@ export declare const doc24Schemas: {
1351
1375
  }, "strip", import("zod").ZodTypeAny, {
1352
1376
  firstName: string;
1353
1377
  lastName: string;
1354
- birthday: Date;
1355
1378
  identificationType: "dni";
1356
1379
  identificationValue: string;
1357
1380
  gender: "m" | "f";
1381
+ birthday: Date;
1358
1382
  }, {
1359
1383
  firstName: string;
1360
1384
  lastName: string;
1361
- birthday: Date;
1362
1385
  identificationType: "dni";
1363
1386
  identificationValue: string;
1364
1387
  gender: "m" | "f";
1388
+ birthday: Date;
1365
1389
  }>;
1366
1390
  diagnosticaDeepLinkResponse: import("zod").ZodUnion<[import("zod").ZodObject<{
1367
1391
  forwardingRequired: import("zod").ZodLiteral<true>;
@@ -1405,9 +1429,9 @@ export declare const doc24Schemas: {
1405
1429
  }, "strip", import("zod").ZodTypeAny, {
1406
1430
  firstName: string | null;
1407
1431
  lastName: string | null;
1432
+ birthdate: Date;
1408
1433
  gender: "m" | "f";
1409
1434
  email: string | null;
1410
- birthdate: Date;
1411
1435
  identificationNumber: string;
1412
1436
  plan: string | null;
1413
1437
  financerId: number | null;
@@ -1428,9 +1452,9 @@ export declare const doc24Schemas: {
1428
1452
  }, {
1429
1453
  firstName: string | null;
1430
1454
  lastName: string | null;
1455
+ birthdate: Date;
1431
1456
  gender: "m" | "f";
1432
1457
  email: string | null;
1433
- birthdate: Date;
1434
1458
  identificationNumber: string;
1435
1459
  plan: string | null;
1436
1460
  financerId: number | null;
package/lib/schemas.js CHANGED
@@ -23,6 +23,8 @@ const basePersonData = zod_1.object({
23
23
  countryId: zod_1.string(),
24
24
  birthdate: zod_1.date(),
25
25
  gender,
26
+ });
27
+ const patientUpdateData = basePersonData.extend({
26
28
  email: zod_1.string().email(),
27
29
  phone: zod_1.string(),
28
30
  });
@@ -301,6 +303,7 @@ exports.doc24Schemas = {
301
303
  sdkParams: zod_1.object({ url: zod_1.string(), credentials: sdkCredentials }),
302
304
  user: basePersonData.extend({ phone: zod_1.string(), email: zod_1.string() }),
303
305
  patient: basePersonData,
306
+ patientUpdate: patientUpdateData,
304
307
  specialtyMode,
305
308
  specialty,
306
309
  scheduleAvailabilityFilter,
package/lib/types.d.ts CHANGED
@@ -6,6 +6,7 @@ export declare namespace Doc24 {
6
6
  type SdkParams = TypeOf<typeof doc24Schemas.sdkParams>;
7
7
  type User = TypeOf<typeof doc24Schemas.user>;
8
8
  type Patient = TypeOf<typeof doc24Schemas.patient>;
9
+ type PatientUpdate = TypeOf<typeof doc24Schemas.patientUpdate>;
9
10
  type Specialty = TypeOf<typeof doc24Schemas.specialty>;
10
11
  type ScheduleAvailabilityFilter = TypeOf<typeof doc24Schemas.scheduleAvailabilityFilter>;
11
12
  type AvailableAppointment = TypeOf<typeof doc24Schemas.availableAppointment>;
@@ -31,7 +32,9 @@ export declare namespace Doc24 {
31
32
  type DiagnosticaPatient = TypeOf<typeof doc24Schemas.diagnosticaPatient>;
32
33
  type DiagnosticaHistoryAppointment = TypeOf<typeof doc24Schemas.diagnosticaHistoryAppointment>;
33
34
  type DiagnosticaDeepLinkResponse = TypeOf<typeof doc24Schemas.diagnosticaDeepLinkResponse>;
34
- type OldIdentificaiton = TypeOf<typeof doc24Schemas.oldIdentificaiton>;
35
+ type OldIdentification = TypeOf<typeof doc24Schemas.oldIdentificaiton>;
36
+ /** @deprecated Use OldIdentification. */
37
+ type OldIdentificaiton = OldIdentification;
35
38
  type VideoCallLink = TypeOf<typeof doc24Schemas.videoCallLink>;
36
39
  type BaseSdk = {
37
40
  declareUser: (user: User) => Promise<number>;
@@ -47,7 +50,7 @@ export declare namespace Doc24 {
47
50
  };
48
51
  type UserSdk = {
49
52
  declarePatient: (patient: Patient) => Promise<number>;
50
- updatePatient: (oldIdentification: OldIdentificaiton, patient: Patient) => Promise<number>;
53
+ updatePatient: (oldIdentification: OldIdentification, patient: PatientUpdate) => Promise<number>;
51
54
  getSpecialties: (mode: SpecialtyMode, language: string) => Promise<Specialty[]>;
52
55
  getScheduleDates: (patientId: number, filter?: ScheduleAvailabilityFilter) => Promise<Date[]>;
53
56
  getSchedule: (patientId: number, specialtyId: number, filter?: ScheduleFilter) => Promise<AvailableAppointment[]>;
@@ -68,6 +71,8 @@ export declare namespace Doc24 {
68
71
  sendChatMessage: (chatId: number, message: string) => Promise<number>;
69
72
  getVideoCallLink: (vcToken: string, name: string) => Promise<VideoCallLink>;
70
73
  userId: number;
74
+ /** Patient created or reused by `getUserInstance(user)`. */
75
+ patientId?: number;
71
76
  };
72
77
  namespace Webhook {
73
78
  type StatusChangeEventStatus = 'S' | 'C' | 'F' | 'A' | 'D' | 'L';
@@ -24,9 +24,9 @@ export declare const getChatMethods: (makeRequest: RequestMaker) => {
24
24
  getPatientChats: (patientId: number) => Promise<{
25
25
  id: number;
26
26
  patient: {
27
- id: number;
28
27
  firstName: string;
29
28
  lastName: string;
29
+ id: number;
30
30
  };
31
31
  professional: {
32
32
  id: number;
@@ -13,11 +13,11 @@ export declare const getExternalMethods: (makeRequest: RequestMaker) => {
13
13
  birthdate: Date;
14
14
  appointment: string;
15
15
  id: number;
16
+ modality: string;
16
17
  specialty: string;
17
18
  patientName: string;
18
19
  clinic: string;
19
20
  professionalName: string;
20
- modality: string;
21
21
  }[]>;
22
22
  cancelExternalAppointment: (appointmentId: {
23
23
  patientIdentification?: string | undefined;
@@ -25,10 +25,10 @@ export declare const getExternalMethods: (makeRequest: RequestMaker) => {
25
25
  birthdate: Date;
26
26
  appointment: string;
27
27
  id: number;
28
+ modality: string;
28
29
  specialty: string;
29
30
  patientName: string;
30
31
  clinic: string;
31
32
  professionalName: string;
32
- modality: string;
33
33
  }) => Promise<void>;
34
34
  };
@@ -1,2 +1,2 @@
1
1
  import { Doc24 } from '../types';
2
- export declare const userSdk: (url: string, credentials: Doc24.SdkCredentials, userId: number) => Promise<Doc24.UserSdk>;
2
+ export declare const userSdk: (url: string, credentials: Doc24.SdkCredentials, userId: number, patientId?: number | undefined) => Promise<Doc24.UserSdk>;
@@ -7,7 +7,7 @@ const patients_1 = require("./patients");
7
7
  const schedule_1 = require("./schedule");
8
8
  const specialties_1 = require("./specialties");
9
9
  const videoVisit_1 = require("./videoVisit");
10
- const userSdk = async (url, credentials, userId) => {
10
+ const userSdk = async (url, credentials, userId, patientId) => {
11
11
  const makeRequest = await request_1.getRequestFactory(url, credentials, userId);
12
12
  const patientMethods = patients_1.getPatientMethods(makeRequest);
13
13
  const specialtyMethods = specialties_1.getSpecialtiesMethods(makeRequest);
@@ -21,6 +21,7 @@ const userSdk = async (url, credentials, userId) => {
21
21
  ...videoVisitMethods,
22
22
  ...chatMethods,
23
23
  userId,
24
+ patientId,
24
25
  };
25
26
  return sdk;
26
27
  };
@@ -5,11 +5,9 @@ export declare const getPatientMethods: (makeRequest: RequestMaker) => {
5
5
  lastName: string;
6
6
  identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
7
7
  identificationValue: string;
8
- gender: "m" | "f";
9
- phone: string;
10
- email: string;
11
8
  countryId: string;
12
9
  birthdate: Date;
10
+ gender: "m" | "f";
13
11
  }) => Promise<number>;
14
12
  updatePatient: (oldIdentification: {
15
13
  identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
@@ -19,10 +17,10 @@ export declare const getPatientMethods: (makeRequest: RequestMaker) => {
19
17
  lastName: string;
20
18
  identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
21
19
  identificationValue: string;
22
- gender: "m" | "f";
23
- phone: string;
24
- email: string;
25
20
  countryId: string;
26
21
  birthdate: Date;
22
+ gender: "m" | "f";
23
+ email: string;
24
+ phone: string;
27
25
  }) => Promise<number>;
28
26
  };
@@ -22,7 +22,7 @@ const getPatientMethods = (makeRequest) => {
22
22
  });
23
23
  return response.data.patient_id;
24
24
  };
25
- const updatePatient = async (oldIdentificaiton, patient) => {
25
+ const updatePatient = async (oldIdentification, patient) => {
26
26
  const mappedPatient = {
27
27
  lastname: patient.lastName,
28
28
  firstname: patient.firstName,
@@ -34,15 +34,15 @@ const getPatientMethods = (makeRequest) => {
34
34
  phone: patient.phone,
35
35
  };
36
36
  const response = await makeRequest('POST', '/update-patient', {
37
- old_identification_type: utils_1.getIndetificationTypeId(oldIdentificaiton.identificationType),
38
- old_identification_value: oldIdentificaiton.identificationValue,
37
+ old_identification_type: utils_1.getIndetificationTypeId(oldIdentification.identificationType),
38
+ old_identification_value: oldIdentification.identificationValue,
39
39
  user_data: mappedPatient,
40
40
  });
41
41
  return response.data.patient_id;
42
42
  };
43
43
  return {
44
44
  declarePatient: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.patient]), zod_1.number(), declarePatient),
45
- updatePatient: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.oldIdentificaiton, schemas_1.doc24Schemas.patient]), zod_1.number(), updatePatient),
45
+ updatePatient: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.oldIdentificaiton, schemas_1.doc24Schemas.patientUpdate]), zod_1.number(), updatePatient),
46
46
  };
47
47
  };
48
48
  exports.getPatientMethods = getPatientMethods;
@@ -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
- phone: string | null;
37
35
  email: string | null;
36
+ phone: string | null;
37
+ id: number;
38
38
  };
39
39
  vcToken: string;
40
40
  }>;
@@ -53,9 +53,9 @@ export declare const getVideoVisitMethods: (makeRequest: RequestMaker) => {
53
53
  patientId: number;
54
54
  creationDate: Date;
55
55
  user: {
56
- id: number;
57
- phone: string | null;
58
56
  email: string | null;
57
+ phone: string | null;
58
+ id: number;
59
59
  };
60
60
  vcToken: string;
61
61
  }[]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integraciones_doc24/sdk",
3
- "version": "0.42.4",
3
+ "version": "0.42.7",
4
4
  "publishConfig": {
5
5
  "tag": "0.x"
6
6
  },
@@ -8,6 +8,7 @@
8
8
  "main": "lib/index.js",
9
9
  "scripts": {
10
10
  "build": "tsc",
11
+ "test": "npm run build && node --test tests/*.test.js",
11
12
  "prepublish": "npm run build"
12
13
  },
13
14
  "keywords": [],