@integraciones_doc24/sdk 0.42.6 → 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>;
@@ -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,
@@ -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/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
  };
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.7",
4
4
  "publishConfig": {
5
5
  "tag": "0.x"
6
6
  },