@integraciones_doc24/sdk 0.42.6 → 0.42.9

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>;
@@ -116,6 +116,10 @@ type UserSdk = {
116
116
  oldIdentification: OldIdentification,
117
117
  patient: PatientUpdate,
118
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;
119
123
  getSpecialties: (
120
124
  mode: SpecialtyMode,
121
125
  language: string,
@@ -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" | "rut" | "cuit";
4
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit" | "cuil";
5
5
  identificationValue: string;
6
6
  gender: "m" | "f";
7
7
  }, from: Date, to: Date) => Promise<{
@@ -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" | "rut" | "cuit";
7
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit" | "cuil";
8
8
  identificationValue: string;
9
9
  countryId: string;
10
10
  birthdate: Date;
@@ -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
@@ -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" | "rut" | "cuit";
11
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit" | "cuil";
12
12
  identificationValue: string;
13
13
  countryId: string;
14
14
  birthdate: Date;
@@ -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" | "rut" | "cuit";
22
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit" | "cuil";
23
23
  identificationValue: string;
24
24
  countryId: string;
25
25
  birthdate: Date;
@@ -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" | "rut" | "cuit";
204
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit" | "cuil";
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", "rut", "cuit"]>;
2
+ identificationType: import("zod").ZodEnum<["dni", "ndi", "passport", "credential", "nn", "cpf", "rg", "rut", "cuit", "cuil"]>;
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", "rut", "cuit"]>;
41
+ identificationType: import("zod").ZodEnum<["dni", "ndi", "passport", "credential", "nn", "cpf", "rg", "rut", "cuit", "cuil"]>;
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" | "rut" | "cuit";
52
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit" | "cuil";
53
53
  identificationValue: string;
54
54
  countryId: string;
55
55
  birthdate: Date;
@@ -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" | "rut" | "cuit";
62
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit" | "cuil";
63
63
  identificationValue: string;
64
64
  countryId: string;
65
65
  birthdate: Date;
@@ -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", "rut", "cuit"]>;
73
+ identificationType: import("zod").ZodEnum<["dni", "ndi", "passport", "credential", "nn", "cpf", "rg", "rut", "cuit", "cuil"]>;
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" | "rut" | "cuit";
81
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit" | "cuil";
82
82
  identificationValue: string;
83
83
  countryId: string;
84
84
  birthdate: Date;
@@ -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" | "rut" | "cuit";
89
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit" | "cuil";
90
90
  identificationValue: string;
91
91
  countryId: string;
92
92
  birthdate: Date;
@@ -95,7 +95,7 @@ export declare const doc24Schemas: {
95
95
  patientUpdate: import("zod").ZodObject<import("zod").extendShape<{
96
96
  firstName: import("zod").ZodString;
97
97
  lastName: import("zod").ZodString;
98
- identificationType: import("zod").ZodEnum<["dni", "ndi", "passport", "credential", "nn", "cpf", "rg", "rut", "cuit"]>;
98
+ identificationType: import("zod").ZodEnum<["dni", "ndi", "passport", "credential", "nn", "cpf", "rg", "rut", "cuit", "cuil"]>;
99
99
  identificationValue: import("zod").ZodString;
100
100
  countryId: import("zod").ZodString;
101
101
  birthdate: import("zod").ZodDate;
@@ -106,7 +106,7 @@ export declare const doc24Schemas: {
106
106
  }>, "strip", import("zod").ZodTypeAny, {
107
107
  firstName: string;
108
108
  lastName: string;
109
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
109
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit" | "cuil";
110
110
  identificationValue: string;
111
111
  countryId: string;
112
112
  birthdate: Date;
@@ -116,7 +116,7 @@ export declare const doc24Schemas: {
116
116
  }, {
117
117
  firstName: string;
118
118
  lastName: string;
119
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
119
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit" | "cuil";
120
120
  identificationValue: string;
121
121
  countryId: string;
122
122
  birthdate: Date;
@@ -1306,14 +1306,14 @@ export declare const doc24Schemas: {
1306
1306
  }>;
1307
1307
  diagnosticaPatientFilter: import("zod").ZodObject<{
1308
1308
  gender: import("zod").ZodEnum<["m", "f"]>;
1309
- identificationType: import("zod").ZodEnum<["dni", "ndi", "passport", "credential", "nn", "cpf", "rg", "rut", "cuit"]>;
1309
+ identificationType: import("zod").ZodEnum<["dni", "ndi", "passport", "credential", "nn", "cpf", "rg", "rut", "cuit", "cuil"]>;
1310
1310
  identificationValue: import("zod").ZodString;
1311
1311
  }, "strip", import("zod").ZodTypeAny, {
1312
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
1312
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit" | "cuil";
1313
1313
  identificationValue: string;
1314
1314
  gender: "m" | "f";
1315
1315
  }, {
1316
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
1316
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit" | "cuil";
1317
1317
  identificationValue: string;
1318
1318
  gender: "m" | "f";
1319
1319
  }>;
@@ -1474,13 +1474,13 @@ export declare const doc24Schemas: {
1474
1474
  authorizationCodeExpiration: Date | null;
1475
1475
  }>>;
1476
1476
  oldIdentificaiton: import("zod").ZodObject<{
1477
- identificationType: import("zod").ZodEnum<["dni", "ndi", "passport", "credential", "nn", "cpf", "rg", "rut", "cuit"]>;
1477
+ identificationType: import("zod").ZodEnum<["dni", "ndi", "passport", "credential", "nn", "cpf", "rg", "rut", "cuit", "cuil"]>;
1478
1478
  identificationValue: import("zod").ZodString;
1479
1479
  }, "strip", import("zod").ZodTypeAny, {
1480
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
1480
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit" | "cuil";
1481
1481
  identificationValue: string;
1482
1482
  }, {
1483
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
1483
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit" | "cuil";
1484
1484
  identificationValue: string;
1485
1485
  }>;
1486
1486
  videoCallLink: import("zod").ZodObject<{
package/lib/schemas.js CHANGED
@@ -13,6 +13,7 @@ const identificationType = zod_1.enum([
13
13
  'rg',
14
14
  'rut',
15
15
  'cuit',
16
+ 'cuil',
16
17
  ]);
17
18
  const sdkCredentials = zod_1.object({ iss: zod_1.string(), key: zod_1.string() });
18
19
  const basePersonData = zod_1.object({
package/lib/types.d.ts CHANGED
@@ -71,6 +71,8 @@ export declare namespace Doc24 {
71
71
  sendChatMessage: (chatId: number, message: string) => Promise<number>;
72
72
  getVideoCallLink: (vcToken: string, name: string) => Promise<VideoCallLink>;
73
73
  userId: number;
74
+ /** Patient created or reused by `getUserInstance(user)`. */
75
+ patientId?: number;
74
76
  };
75
77
  namespace Webhook {
76
78
  type StatusChangeEventStatus = 'S' | 'C' | 'F' | 'A' | 'D' | 'L';
@@ -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
  };
@@ -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" | "rut" | "cuit";
6
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit" | "cuil";
7
7
  identificationValue: string;
8
8
  countryId: string;
9
9
  birthdate: Date;
10
10
  gender: "m" | "f";
11
11
  }) => Promise<number>;
12
12
  updatePatient: (oldIdentification: {
13
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
13
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit" | "cuil";
14
14
  identificationValue: string;
15
15
  }, patient: {
16
16
  firstName: string;
17
17
  lastName: string;
18
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit";
18
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg" | "rut" | "cuit" | "cuil";
19
19
  identificationValue: string;
20
20
  countryId: string;
21
21
  birthdate: Date;
package/lib/utils.js CHANGED
@@ -18,6 +18,7 @@ const identificationTypeIds = {
18
18
  cpf: 9,
19
19
  rut: 26,
20
20
  cuit: 23,
21
+ cuil: 2,
21
22
  nn: 1000,
22
23
  passport: 5,
23
24
  credential: 999,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integraciones_doc24/sdk",
3
- "version": "0.42.6",
3
+ "version": "0.42.9",
4
4
  "publishConfig": {
5
5
  "tag": "0.x"
6
6
  },