@integraciones_doc24/sdk 1.14.4 → 1.14.5

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
@@ -110,11 +110,13 @@ export type BaseSdk = {
110
110
  params: VerifyExternalVerificationCodeParams,
111
111
  ) => Promise<any>;
112
112
  externalResetPassword: (params: ExternalResetPasswordParams) => Promise<any>;
113
- getExternalStudiesHistoryLink: (patient: ExternalPatient) => Promise<string>;
113
+ getExternalStudiesHistoryLink: (
114
+ patient: ExternalPatient,
115
+ ) => Promise<string | null>;
114
116
  getExternalAppointmentsLink: (
115
117
  identificationValue: string,
116
118
  birthdate: Date,
117
- ) => Promise<string>;
119
+ ) => Promise<string | null>;
118
120
  getExternalAppointments: () => Promise<ExternalAppointment[]>;
119
121
  cancelExternalAppointment: (
120
122
  appointmentId: ExternalAppointment,
@@ -181,7 +183,9 @@ export type UserSdk = {
181
183
  vcToken: string,
182
184
  patientId: number,
183
185
  ) => Promise<string | null>;
184
- getPatientVideoVisitHistory: (patientId: number) => Promise<VideoVisit[]>;
186
+ getPatientVideoVisitHistory: (
187
+ patientId: number,
188
+ ) => Promise<HistoricalVideoVisit[]>;
185
189
  getActiveVideoVisits: () => Promise<ActiveVideoVisitData[]>;
186
190
  getAvailableChatrooms: (
187
191
  patientId: number,
@@ -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";
4
+ identificationType: "DNI";
5
5
  identificationValue: string;
6
6
  gender: "m" | "f";
7
7
  }, from: Date, to: Date) => Promise<{
@@ -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
- identificationType: "dni";
16
+ identificationType: "DNI";
19
17
  identificationValue: string;
20
18
  gender: "m" | "f";
21
19
  phone: string;
22
20
  email: string;
21
+ language: string;
22
+ birthday: Date;
23
23
  }, patient: {
24
24
  firstName: string;
25
25
  lastName: string;
26
- birthday: Date;
27
- identificationType: "dni";
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
- identificationType: "dni";
39
+ identificationType: "DNI";
42
40
  identificationValue: string;
43
41
  gender: "m" | "f";
44
42
  phone: string;
45
43
  email: string;
44
+ language: string;
45
+ birthday: Date;
46
46
  }, patient: {
47
47
  firstName: string;
48
48
  lastName: string;
49
- birthday: Date;
50
- identificationType: "dni";
49
+ identificationType: "DNI";
51
50
  identificationValue: string;
52
51
  gender: "m" | "f";
52
+ birthday: Date;
53
53
  }) => Promise<void>;
54
54
  };
@@ -6,14 +6,12 @@ const zod_1 = require("zod");
6
6
  const validation_1 = require("../request/validation");
7
7
  const schemas_1 = require("../schemas");
8
8
  const getDiagnosticaMethods = (makeRequest) => {
9
- const getDiagnosticaHistory = validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.diagnosticaPatientFilter, zod_1.date(), zod_1.date()]), schemas_1.doc24Schemas.diagnosticaHistoryAppointment.array(), async (patient, from, to) => {
9
+ const getDiagnosticaHistory = async (patient, from, to) => {
10
10
  const path = '/history-diagnostica';
11
11
  const response = await makeRequest('POST', path, {
12
12
  patient: {
13
13
  gender: patient.gender,
14
- id_type: patient.identificationType === 'ndi'
15
- ? 'DNI'
16
- : patient.identificationType,
14
+ id_type: patient.identificationType,
17
15
  id_value: patient.identificationValue,
18
16
  },
19
17
  dateFrom: from.toISOString(),
@@ -26,12 +24,8 @@ const getDiagnosticaMethods = (makeRequest) => {
26
24
  exams: i.exams,
27
25
  deepLink: i.deeplink,
28
26
  }));
29
- });
30
- const getDiagnosticaDeepLink = validation_1.validateFunction(zod_1.tuple([
31
- zod_1.string(),
32
- schemas_1.doc24Schemas.diagnosticaUser,
33
- schemas_1.doc24Schemas.diagnosticaPatient,
34
- ]), schemas_1.doc24Schemas.diagnosticaDeepLinkResponse, async (kiosk, user, patient) => {
27
+ };
28
+ const getDiagnosticaDeepLink = async (kiosk, user, patient) => {
35
29
  const path = '/deeplink-diagnostica';
36
30
  const response = await makeRequest('POST', path, {
37
31
  kiosk,
@@ -42,12 +36,8 @@ const getDiagnosticaMethods = (makeRequest) => {
42
36
  if (data.forwarding_required)
43
37
  return { forwardingRequired: true, deepLink: data.deeplink };
44
38
  return { forwardingRequired: false };
45
- });
46
- const getDiagnosticaAccess = validation_1.validateFunction(zod_1.tuple([
47
- zod_1.string(),
48
- schemas_1.doc24Schemas.diagnosticaUser,
49
- schemas_1.doc24Schemas.diagnosticaPatient,
50
- ]), zod_1.void(), async (kiosk, user, patient) => {
39
+ };
40
+ const getDiagnosticaAccess = async (kiosk, user, patient) => {
51
41
  const path = '/access-diagnostica';
52
42
  await makeRequest('POST', path, {
53
43
  kiosk,
@@ -55,8 +45,20 @@ const getDiagnosticaMethods = (makeRequest) => {
55
45
  patient: mapPatientData(patient),
56
46
  });
57
47
  return;
58
- });
59
- return { getDiagnosticaHistory, getDiagnosticaDeepLink, getDiagnosticaAccess };
48
+ };
49
+ return {
50
+ getDiagnosticaHistory: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.diagnosticaPatientFilter, zod_1.date(), zod_1.date()]), schemas_1.doc24Schemas.diagnosticaHistoryAppointment.array(), getDiagnosticaHistory),
51
+ getDiagnosticaDeepLink: validation_1.validateFunction(zod_1.tuple([
52
+ zod_1.string(),
53
+ schemas_1.doc24Schemas.diagnosticaUser,
54
+ schemas_1.doc24Schemas.diagnosticaPatient,
55
+ ]), schemas_1.doc24Schemas.diagnosticaDeepLinkResponse, getDiagnosticaDeepLink),
56
+ getDiagnosticaAccess: validation_1.validateFunction(zod_1.tuple([
57
+ zod_1.string(),
58
+ schemas_1.doc24Schemas.diagnosticaUser,
59
+ schemas_1.doc24Schemas.diagnosticaPatient,
60
+ ]), zod_1.void(), getDiagnosticaAccess),
61
+ };
60
62
  };
61
63
  exports.getDiagnosticaMethods = getDiagnosticaMethods;
62
64
  const mapPatientData = (patient) => {
@@ -8,12 +8,15 @@ const schemas_1 = require("../schemas");
8
8
  const utils_1 = require("../utils");
9
9
  const diagnostica_1 = require("./diagnostica");
10
10
  const user_1 = require("./user");
11
+ const external_1 = require("./external");
11
12
  const getBaseSdk = async (url, credentials) => {
12
13
  const makeRequest = await request_1.getRequestFactory(url, credentials);
13
14
  const diagnosticaMethods = diagnostica_1.getDiagnosticaMethods(makeRequest);
15
+ const externalMethods = external_1.getExternalMethods(makeRequest);
14
16
  const userMethods = user_1.getUserMethods(makeRequest, url, credentials);
15
17
  const baseSdk = {
16
18
  ...diagnosticaMethods,
19
+ ...externalMethods,
17
20
  ...userMethods,
18
21
  getProfessional: validation_1.validateFunction(zod_1.tuple([zod_1.number()]), schemas_1.doc24Schemas.professional, async (professionalId) => {
19
22
  const path = `/professional/${professionalId}`;
@@ -1,25 +1,75 @@
1
1
  import { RequestMaker } from '../request';
2
2
  import { Doc24 } from '../types';
3
3
  export declare const getUserMethods: (makeRequest: RequestMaker, url: string, credentials: Doc24.SdkCredentials) => {
4
- declareUser: (user: {
4
+ declareUser: (params: {
5
+ user: {
6
+ firstName: string;
7
+ lastName: string;
8
+ identificationType: number;
9
+ identificationValue: string;
10
+ countryId: string;
11
+ birthdate: Date;
12
+ gender: "m" | "f";
13
+ phone: string;
14
+ email: string;
15
+ };
16
+ } & {
17
+ code?: string | undefined;
18
+ channel?: "1" | "2" | undefined;
19
+ }) => Promise<{
20
+ askCode: true;
21
+ userInfo: {
22
+ phone: string;
23
+ email: string;
24
+ };
25
+ } | {
26
+ patientId: number | null;
27
+ askCode: false;
28
+ userId: number;
29
+ }>;
30
+ getUserId: (user: {
5
31
  firstName: string;
6
32
  lastName: string;
7
- identificationType: "dni" | "ndi" | "passport" | "credential" | "nn";
33
+ identificationType: number;
8
34
  identificationValue: string;
35
+ countryId: string;
36
+ birthdate: Date;
9
37
  gender: "m" | "f";
10
38
  phone: string;
11
39
  email: string;
40
+ }) => Promise<number>;
41
+ sendVerificationCode: (params: {
42
+ identificationType: number;
43
+ identificationValue: string;
44
+ channel: "1" | "2";
45
+ }) => Promise<void>;
46
+ getUserInstance: (user: number | {
47
+ firstName: string;
48
+ lastName: string;
49
+ identificationType: number;
50
+ identificationValue: string;
12
51
  countryId: string;
13
52
  birthdate: Date;
53
+ gender: "m" | "f";
54
+ phone: string;
55
+ email: string;
14
56
  }) => Promise<any>;
15
- getUserInstance: (...params: any) => Promise<any>;
16
- enroll: (...params: any) => Promise<void>;
17
- getConverageInfo: (identificationValue: string) => Promise<{
57
+ enroll: (params: {
58
+ firstName: string;
59
+ lastName: string;
60
+ birthdate: Date;
61
+ gender: "m" | "f";
62
+ email: string;
63
+ identificationNumber: string;
64
+ startDate: Date;
65
+ plan: string;
66
+ }) => Promise<void>;
67
+ getCoverageInfo: (identificationValue: string) => Promise<{
18
68
  firstName: string | null;
19
69
  lastName: string | null;
70
+ birthdate: Date;
20
71
  gender: "m" | "f";
21
72
  email: string | null;
22
- birthdate: Date;
23
73
  identificationNumber: string;
24
74
  plan: string | null;
25
75
  financerId: number | null;
@@ -8,11 +8,40 @@ 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 declareUser = async ({ user, channel, code, }) => {
12
+ const path = '/user';
13
+ const mappedUser = {
14
+ lastname: user.lastName,
15
+ firstname: user.firstName,
16
+ identification_type: user.identificationType,
17
+ identification_value: user.identificationValue,
18
+ birthdate: date_fns_1.format(user.birthdate, 'yyyy-MM-dd'),
19
+ gender: user.gender.toUpperCase(),
20
+ phone: user.phone,
21
+ email: user.email,
22
+ country_id: user.countryId,
23
+ };
24
+ const parsedChannel = channel ? parseInt(channel) : channel;
25
+ const response = await makeRequest('POST', path, {
26
+ user_data: mappedUser,
27
+ channel: parsedChannel,
28
+ code,
29
+ });
30
+ const data = response.data;
31
+ if (data.ask_code)
32
+ return { askCode: true, userInfo: data.user_info };
33
+ return {
34
+ askCode: false,
35
+ userId: response.data.user_id,
36
+ patientId: response.data.patient_id,
37
+ };
38
+ };
11
39
  const getUserId = async (user) => {
40
+ const path = '/search-user';
12
41
  const mappedUser = {
13
42
  lastname: user.lastName,
14
43
  firstname: user.firstName,
15
- identification_type: utils_1.getIndetificationTypeId(user.identificationType),
44
+ identification_type: user.identificationType,
16
45
  identification_value: user.identificationValue,
17
46
  birthdate: date_fns_1.format(user.birthdate, 'yyyy-MM-dd'),
18
47
  gender: user.gender.toUpperCase(),
@@ -20,15 +49,46 @@ const getUserMethods = (makeRequest, url, credentials) => {
20
49
  email: user.email,
21
50
  country_id: user.countryId,
22
51
  };
23
- const response = await makeRequest('POST', '/user', {
52
+ const response = await makeRequest('POST', path, {
24
53
  user_data: mappedUser,
25
54
  });
26
55
  return response.data.user_id;
27
56
  };
28
- const getConverageInfo = validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.coverageInfo, async (identificationValue) => {
57
+ const sendVerificationCode = async (params) => {
58
+ const path = '/send-verification-code';
59
+ const mappedParams = {
60
+ identification_type: params.identificationType,
61
+ identification_value: params.identificationValue,
62
+ channel: parseInt(params.channel),
63
+ };
64
+ await makeRequest('POST', path, mappedParams);
65
+ };
66
+ const getUserInstance = async (user) => {
67
+ const userId = typeof user === 'number' ? user : await getUserId(user);
68
+ return userSdk_1.userSdk(url, credentials, userId);
69
+ };
70
+ const enroll = async (params) => {
71
+ const path = `/enrollment`;
72
+ const mappedUser = {
73
+ firstname: params.firstName,
74
+ lastname: params.lastName,
75
+ gender: params.gender.toUpperCase(),
76
+ identification_number: params.identificationNumber,
77
+ birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
78
+ email: params.email,
79
+ plan: params.plan,
80
+ start_date: date_fns_1.format(params.startDate, 'yyyy-MM-dd'),
81
+ };
82
+ await makeRequest('POST', path, {
83
+ user_data: mappedUser,
84
+ });
85
+ };
86
+ const getCoverageInfo = async (identificationValue) => {
29
87
  const path = `/info-coverage/${identificationValue}`;
30
88
  const response = await makeRequest('GET', path);
31
89
  const raw = response.data.info;
90
+ if (!raw)
91
+ return null;
32
92
  const mappedCoverageInfo = {
33
93
  financerId: raw.id_financiador,
34
94
  defaultAffiliationId: raw.id_afiliacion_default,
@@ -58,31 +118,16 @@ const getUserMethods = (makeRequest, url, credentials) => {
58
118
  : null,
59
119
  };
60
120
  return mappedCoverageInfo;
61
- });
121
+ };
62
122
  return {
63
- declareUser: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.user]), zod_1.number(), getUserId),
123
+ declareUser: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.declareUserParams]), schemas_1.doc24Schemas.declareUserResponse, declareUser),
124
+ getUserId: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.user]), zod_1.number(), getUserId),
125
+ sendVerificationCode: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.sendVerificationCodeParams]), zod_1.void(), sendVerificationCode),
64
126
  getUserInstance: validation_1.validateFunction(zod_1.tuple([zod_1.union([schemas_1.doc24Schemas.user, zod_1.number()])]),
65
127
  // TODO: validate?
66
- zod_1.any(), async (user) => {
67
- const userId = typeof user === 'number' ? user : await getUserId(user);
68
- return userSdk_1.userSdk(url, credentials, userId);
69
- }),
70
- enroll: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.enrollmentParams]), zod_1.void(), async (params) => {
71
- const path = `/enrollment`;
72
- await makeRequest('POST', path, {
73
- user_data: {
74
- firstname: params.firstName,
75
- lastname: params.lastName,
76
- gender: params.gender.toUpperCase(),
77
- identification_number: params.identificationNumber,
78
- birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
79
- email: params.email,
80
- plan: params.plan,
81
- start_date: date_fns_1.format(params.startDate, 'yyyy-MM-dd'),
82
- },
83
- });
84
- }),
85
- getConverageInfo,
128
+ zod_1.any(), getUserInstance),
129
+ enroll: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.enrollmentParams]), zod_1.void(), enroll),
130
+ getCoverageInfo: validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.coverageInfo, getCoverageInfo),
86
131
  };
87
132
  };
88
133
  exports.getUserMethods = getUserMethods;