@integraciones_doc24/sdk 0.34.2 → 0.35.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.
Files changed (90) hide show
  1. package/lib/baseSdk/index.js +1 -0
  2. package/lib/baseSdk/user.d.ts +18 -18
  3. package/lib/baseSdk/user.js +30 -1
  4. package/lib/index.d.ts +22 -18
  5. package/lib/lib/baseSdk/diagnostica.d.ts +11 -0
  6. package/lib/lib/baseSdk/diagnostica.js +79 -0
  7. package/lib/lib/baseSdk/external.d.ts +15 -0
  8. package/lib/lib/baseSdk/external.js +73 -0
  9. package/lib/lib/baseSdk/index.d.ts +114 -0
  10. package/lib/lib/baseSdk/index.js +66 -0
  11. package/lib/lib/baseSdk/user.d.ts +30 -0
  12. package/lib/lib/baseSdk/user.js +88 -0
  13. package/lib/lib/index.d.ts +154 -0
  14. package/lib/lib/index.js +22 -0
  15. package/lib/lib/request/index.d.ts +2 -0
  16. package/lib/lib/request/index.js +26 -0
  17. package/lib/lib/request/token.d.ts +2 -0
  18. package/lib/lib/request/token.js +34 -0
  19. package/lib/lib/request/validation.d.ts +10 -0
  20. package/lib/lib/request/validation.js +28 -0
  21. package/lib/lib/schemas.d.ts +1138 -0
  22. package/lib/lib/schemas.js +294 -0
  23. package/lib/lib/test.d.ts +1 -0
  24. package/lib/lib/test.js +55 -0
  25. package/lib/lib/types.d.ts +1 -0
  26. package/lib/lib/types.js +2 -0
  27. package/lib/lib/userSdk/chat.d.ts +9 -0
  28. package/lib/lib/userSdk/chat.js +98 -0
  29. package/lib/lib/userSdk/index.d.ts +220 -0
  30. package/lib/lib/userSdk/index.js +27 -0
  31. package/lib/lib/userSdk/patients.d.ts +4 -0
  32. package/lib/lib/userSdk/patients.js +27 -0
  33. package/lib/lib/userSdk/sarasas.d.ts +6 -0
  34. package/lib/lib/userSdk/sarasas.js +13 -0
  35. package/lib/lib/userSdk/schedule.d.ts +15 -0
  36. package/lib/lib/userSdk/schedule.js +76 -0
  37. package/lib/lib/userSdk/specialties.d.ts +4 -0
  38. package/lib/lib/userSdk/specialties.js +19 -0
  39. package/lib/lib/userSdk/videoVisit.d.ts +72 -0
  40. package/lib/lib/userSdk/videoVisit.js +147 -0
  41. package/lib/lib/utils.d.ts +4 -0
  42. package/lib/lib/utils.js +19 -0
  43. package/lib/lib/webhook/index.d.ts +8 -0
  44. package/lib/lib/webhook/index.js +55 -0
  45. package/lib/lib/webhook/responses.d.ts +36 -0
  46. package/lib/lib/webhook/responses.js +42 -0
  47. package/lib/lib/webhook/token.d.ts +2 -0
  48. package/lib/lib/webhook/token.js +23 -0
  49. package/lib/schemas.d.ts +72 -54
  50. package/lib/schemas.js +19 -18
  51. package/lib/src/baseSdk/diagnostica.d.ts +54 -0
  52. package/lib/src/baseSdk/diagnostica.js +79 -0
  53. package/lib/src/baseSdk/index.d.ts +2 -0
  54. package/lib/src/baseSdk/index.js +66 -0
  55. package/lib/src/baseSdk/user.d.ts +41 -0
  56. package/lib/src/baseSdk/user.js +88 -0
  57. package/lib/src/index.d.ts +159 -0
  58. package/lib/src/index.js +22 -0
  59. package/lib/src/request/index.d.ts +3 -0
  60. package/lib/src/request/index.js +26 -0
  61. package/lib/src/request/token.d.ts +2 -0
  62. package/lib/src/request/token.js +34 -0
  63. package/lib/src/request/validation.d.ts +10 -0
  64. package/lib/src/request/validation.js +28 -0
  65. package/lib/src/schemas.d.ts +1115 -0
  66. package/lib/src/schemas.js +294 -0
  67. package/lib/src/types.d.ts +116 -0
  68. package/lib/src/types.js +2 -0
  69. package/lib/src/userSdk/chat.d.ts +57 -0
  70. package/lib/src/userSdk/chat.js +98 -0
  71. package/lib/src/userSdk/index.d.ts +2 -0
  72. package/lib/src/userSdk/index.js +27 -0
  73. package/lib/src/userSdk/patients.d.ts +12 -0
  74. package/lib/src/userSdk/patients.js +27 -0
  75. package/lib/src/userSdk/schedule.d.ts +44 -0
  76. package/lib/src/userSdk/schedule.js +76 -0
  77. package/lib/src/userSdk/specialties.d.ts +7 -0
  78. package/lib/src/userSdk/specialties.js +19 -0
  79. package/lib/src/userSdk/videoVisit.d.ts +111 -0
  80. package/lib/src/userSdk/videoVisit.js +147 -0
  81. package/lib/src/utils.d.ts +4 -0
  82. package/lib/src/utils.js +19 -0
  83. package/lib/src/webhook/index.d.ts +2 -0
  84. package/lib/src/webhook/index.js +55 -0
  85. package/lib/src/webhook/responses.d.ts +35 -0
  86. package/lib/src/webhook/responses.js +42 -0
  87. package/lib/src/webhook/token.d.ts +2 -0
  88. package/lib/src/webhook/token.js +23 -0
  89. package/lib/test.js +49 -8
  90. package/package.json +1 -1
package/lib/schemas.d.ts CHANGED
@@ -193,6 +193,16 @@ export declare const doc24Schemas: {
193
193
  id: number;
194
194
  description: string;
195
195
  }>, "many">;
196
+ specialtiesER: import("zod").ZodArray<import("zod").ZodObject<{
197
+ id: import("zod").ZodNumber;
198
+ description: import("zod").ZodString;
199
+ }, "strip", import("zod").ZodTypeAny, {
200
+ id: number;
201
+ description: string;
202
+ }, {
203
+ id: number;
204
+ description: string;
205
+ }>, "many">;
196
206
  professionals: import("zod").ZodArray<import("zod").ZodObject<{
197
207
  id: import("zod").ZodNumber;
198
208
  fullName: import("zod").ZodString;
@@ -229,6 +239,10 @@ export declare const doc24Schemas: {
229
239
  id: number;
230
240
  description: string;
231
241
  }[];
242
+ specialtiesER: {
243
+ id: number;
244
+ description: string;
245
+ }[];
232
246
  professionals: {
233
247
  id: number;
234
248
  fullName: string;
@@ -243,6 +257,10 @@ export declare const doc24Schemas: {
243
257
  id: number;
244
258
  description: string;
245
259
  }[];
260
+ specialtiesER: {
261
+ id: number;
262
+ description: string;
263
+ }[];
246
264
  professionals: {
247
265
  id: number;
248
266
  fullName: string;
@@ -1025,73 +1043,73 @@ export declare const doc24Schemas: {
1025
1043
  forwardingRequired: false;
1026
1044
  }>]>;
1027
1045
  coverageInfo: import("zod").ZodNullable<import("zod").ZodObject<{
1028
- id_afiliacion_default: import("zod").ZodNullable<import("zod").ZodNumber>;
1029
- id_financiador: import("zod").ZodNullable<import("zod").ZodNumber>;
1046
+ financerId: import("zod").ZodNullable<import("zod").ZodNumber>;
1047
+ defaultAffiliationId: import("zod").ZodNullable<import("zod").ZodNumber>;
1030
1048
  plan: import("zod").ZodNullable<import("zod").ZodString>;
1031
- nro_documento: import("zod").ZodString;
1032
- nro_credencial: import("zod").ZodNullable<import("zod").ZodString>;
1033
- apellido: import("zod").ZodNullable<import("zod").ZodString>;
1034
- nombre: import("zod").ZodNullable<import("zod").ZodString>;
1035
- fecha_nacimiento: import("zod").ZodString;
1036
- id_financiador_plan: import("zod").ZodNullable<import("zod").ZodNumber>;
1037
- sexo: import("zod").ZodNullable<import("zod").ZodEnum<["M", "F"]>>;
1049
+ identificationNumber: import("zod").ZodString;
1050
+ credentialNumber: import("zod").ZodNullable<import("zod").ZodString>;
1051
+ lastName: import("zod").ZodNullable<import("zod").ZodString>;
1052
+ firstName: import("zod").ZodNullable<import("zod").ZodString>;
1053
+ birthdate: import("zod").ZodDate;
1054
+ financerPlanId: import("zod").ZodNullable<import("zod").ZodNumber>;
1055
+ gender: import("zod").ZodEnum<["m", "f"]>;
1038
1056
  brand: import("zod").ZodNullable<import("zod").ZodNumber>;
1039
- nro_documento_titular: import("zod").ZodNullable<import("zod").ZodString>;
1040
- valor_copago: import("zod").ZodNullable<import("zod").ZodNumber>;
1041
- telefono_movil: import("zod").ZodNullable<import("zod").ZodString>;
1042
- empresa: import("zod").ZodNullable<import("zod").ZodString>;
1057
+ holderIdentificationNumber: import("zod").ZodNullable<import("zod").ZodString>;
1058
+ copaymentValue: import("zod").ZodNullable<import("zod").ZodNumber>;
1059
+ mobilePhone: import("zod").ZodNullable<import("zod").ZodString>;
1060
+ company: import("zod").ZodNullable<import("zod").ZodString>;
1043
1061
  email: import("zod").ZodNullable<import("zod").ZodString>;
1044
- fecha_alta: import("zod").ZodNullable<import("zod").ZodString>;
1045
- fecha_baja: import("zod").ZodNullable<import("zod").ZodString>;
1062
+ dischargeDate: import("zod").ZodNullable<import("zod").ZodDate>;
1063
+ leavingDate: import("zod").ZodNullable<import("zod").ZodDate>;
1046
1064
  identificacion_tributaria: import("zod").ZodNullable<import("zod").ZodString>;
1047
- fecha_baja_padron: import("zod").ZodNullable<import("zod").ZodString>;
1048
- codigo_autorizacion: import("zod").ZodNullable<import("zod").ZodString>;
1049
- codigo_autorizacion_vencimiento: import("zod").ZodNullable<import("zod").ZodString>;
1065
+ deregistrationDate: import("zod").ZodNullable<import("zod").ZodDate>;
1066
+ authorizationCode: import("zod").ZodNullable<import("zod").ZodString>;
1067
+ authorizationCodeExpiration: import("zod").ZodNullable<import("zod").ZodDate>;
1050
1068
  }, "strip", import("zod").ZodTypeAny, {
1069
+ firstName: string | null;
1070
+ lastName: string | null;
1071
+ gender: "m" | "f";
1051
1072
  email: string | null;
1073
+ birthdate: Date;
1074
+ identificationNumber: string;
1052
1075
  plan: string | null;
1053
- id_afiliacion_default: number | null;
1054
- id_financiador: number | null;
1055
- nro_documento: string;
1056
- nro_credencial: string | null;
1057
- apellido: string | null;
1058
- nombre: string | null;
1059
- fecha_nacimiento: string;
1060
- id_financiador_plan: number | null;
1061
- sexo: "M" | "F" | null;
1076
+ financerId: number | null;
1077
+ defaultAffiliationId: number | null;
1078
+ credentialNumber: string | null;
1079
+ financerPlanId: number | null;
1062
1080
  brand: number | null;
1063
- nro_documento_titular: string | null;
1064
- valor_copago: number | null;
1065
- telefono_movil: string | null;
1066
- empresa: string | null;
1067
- fecha_alta: string | null;
1068
- fecha_baja: string | null;
1081
+ holderIdentificationNumber: string | null;
1082
+ copaymentValue: number | null;
1083
+ mobilePhone: string | null;
1084
+ company: string | null;
1085
+ dischargeDate: Date | null;
1086
+ leavingDate: Date | null;
1069
1087
  identificacion_tributaria: string | null;
1070
- fecha_baja_padron: string | null;
1071
- codigo_autorizacion: string | null;
1072
- codigo_autorizacion_vencimiento: string | null;
1088
+ deregistrationDate: Date | null;
1089
+ authorizationCode: string | null;
1090
+ authorizationCodeExpiration: Date | null;
1073
1091
  }, {
1092
+ firstName: string | null;
1093
+ lastName: string | null;
1094
+ gender: "m" | "f";
1074
1095
  email: string | null;
1096
+ birthdate: Date;
1097
+ identificationNumber: string;
1075
1098
  plan: string | null;
1076
- id_afiliacion_default: number | null;
1077
- id_financiador: number | null;
1078
- nro_documento: string;
1079
- nro_credencial: string | null;
1080
- apellido: string | null;
1081
- nombre: string | null;
1082
- fecha_nacimiento: string;
1083
- id_financiador_plan: number | null;
1084
- sexo: "M" | "F" | null;
1099
+ financerId: number | null;
1100
+ defaultAffiliationId: number | null;
1101
+ credentialNumber: string | null;
1102
+ financerPlanId: number | null;
1085
1103
  brand: number | null;
1086
- nro_documento_titular: string | null;
1087
- valor_copago: number | null;
1088
- telefono_movil: string | null;
1089
- empresa: string | null;
1090
- fecha_alta: string | null;
1091
- fecha_baja: string | null;
1104
+ holderIdentificationNumber: string | null;
1105
+ copaymentValue: number | null;
1106
+ mobilePhone: string | null;
1107
+ company: string | null;
1108
+ dischargeDate: Date | null;
1109
+ leavingDate: Date | null;
1092
1110
  identificacion_tributaria: string | null;
1093
- fecha_baja_padron: string | null;
1094
- codigo_autorizacion: string | null;
1095
- codigo_autorizacion_vencimiento: string | null;
1111
+ deregistrationDate: Date | null;
1112
+ authorizationCode: string | null;
1113
+ authorizationCodeExpiration: Date | null;
1096
1114
  }>>;
1097
1115
  };
package/lib/schemas.js CHANGED
@@ -46,6 +46,7 @@ const appointment = zod_1.object({
46
46
  });
47
47
  const availableScheduleClinics = zod_1.object({
48
48
  specialties: specialty.array(),
49
+ specialtiesER: specialty.array(),
49
50
  professionals: zod_1.object({
50
51
  id: zod_1.number(),
51
52
  fullName: zod_1.string(),
@@ -148,28 +149,28 @@ const diagnosticaDeepLinkResponse = zod_1.object({
148
149
  deepLink: zod_1.string().url(),
149
150
  }).or(zod_1.object({ forwardingRequired: zod_1.literal(false) }));
150
151
  const coverageInfo = zod_1.object({
151
- id_afiliacion_default: zod_1.number().nullable(),
152
- id_financiador: zod_1.number().nullable(),
152
+ financerId: zod_1.number().nullable(),
153
+ defaultAffiliationId: zod_1.number().nullable(),
153
154
  plan: zod_1.string().nullable(),
154
- nro_documento: zod_1.string(),
155
- nro_credencial: zod_1.string().nullable(),
156
- apellido: zod_1.string().nullable(),
157
- nombre: zod_1.string().nullable(),
158
- fecha_nacimiento: zod_1.string(),
159
- id_financiador_plan: zod_1.number().nullable(),
160
- sexo: zod_1.enum(['M', 'F']).nullable(),
155
+ identificationNumber: zod_1.string(),
156
+ credentialNumber: zod_1.string().nullable(),
157
+ lastName: zod_1.string().nullable(),
158
+ firstName: zod_1.string().nullable(),
159
+ birthdate: zod_1.date(),
160
+ financerPlanId: zod_1.number().nullable(),
161
+ gender,
161
162
  brand: zod_1.number().nullable(),
162
- nro_documento_titular: zod_1.string().nullable(),
163
- valor_copago: zod_1.number().nullable(),
164
- telefono_movil: zod_1.string().nullable(),
165
- empresa: zod_1.string().nullable(),
163
+ holderIdentificationNumber: zod_1.string().nullable(),
164
+ copaymentValue: zod_1.number().nullable(),
165
+ mobilePhone: zod_1.string().nullable(),
166
+ company: zod_1.string().nullable(),
166
167
  email: zod_1.string().email().nullable(),
167
- fecha_alta: zod_1.string().nullable(),
168
- fecha_baja: zod_1.string().nullable(),
168
+ dischargeDate: zod_1.date().nullable(),
169
+ leavingDate: zod_1.date().nullable(),
169
170
  identificacion_tributaria: zod_1.string().nullable(),
170
- fecha_baja_padron: zod_1.string().nullable(),
171
- codigo_autorizacion: zod_1.string().nullable(),
172
- codigo_autorizacion_vencimiento: zod_1.string().nullable(),
171
+ deregistrationDate: zod_1.date().nullable(),
172
+ authorizationCode: zod_1.string().nullable(),
173
+ authorizationCodeExpiration: zod_1.date().nullable(),
173
174
  }).nullable();
174
175
  exports.doc24Schemas = {
175
176
  identificationType,
@@ -0,0 +1,54 @@
1
+ import { RequestMaker } from '../request';
2
+ export declare const getDiagnosticaMethods: (makeRequest: RequestMaker) => {
3
+ getDiagnosticaHistory: (patient: {
4
+ identificationType: "ndi" | "passport" | "credential";
5
+ identificationValue: string;
6
+ gender: "m" | "f";
7
+ }, from: Date, to: Date) => Promise<{
8
+ date: Date;
9
+ location: string;
10
+ exams: string[];
11
+ deepLink: string;
12
+ }[]>;
13
+ getDiagnosticaDeepLink: (kiosk: string, user: {
14
+ language: string;
15
+ firstName: string;
16
+ lastName: string;
17
+ birthday: Date;
18
+ identificationType: "dni";
19
+ identificationValue: string;
20
+ gender: "m" | "f";
21
+ phone: string;
22
+ email: string;
23
+ }, patient: {
24
+ firstName: string;
25
+ lastName: string;
26
+ birthday: Date;
27
+ identificationType: "dni";
28
+ identificationValue: string;
29
+ gender: "m" | "f";
30
+ }) => Promise<{
31
+ forwardingRequired: true;
32
+ deepLink: string;
33
+ } | {
34
+ forwardingRequired: false;
35
+ }>;
36
+ getDiagnosticaAccess: (kiosk: string, user: {
37
+ language: string;
38
+ firstName: string;
39
+ lastName: string;
40
+ birthday: Date;
41
+ identificationType: "dni";
42
+ identificationValue: string;
43
+ gender: "m" | "f";
44
+ phone: string;
45
+ email: string;
46
+ }, patient: {
47
+ firstName: string;
48
+ lastName: string;
49
+ birthday: Date;
50
+ identificationType: "dni";
51
+ identificationValue: string;
52
+ gender: "m" | "f";
53
+ }) => Promise<void>;
54
+ };
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDiagnosticaMethods = 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 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) => {
10
+ const path = '/history-diagnostica';
11
+ const response = await makeRequest('POST', path, {
12
+ patient: {
13
+ gender: patient.gender,
14
+ id_type: patient.identificationType === 'ndi'
15
+ ? 'DNI'
16
+ : patient.identificationType,
17
+ id_value: patient.identificationValue,
18
+ },
19
+ dateFrom: from.toISOString(),
20
+ dateTo: to.toISOString(),
21
+ });
22
+ const list = response.data.info;
23
+ return list.map((i) => ({
24
+ date: new Date(Date.parse(i.date)),
25
+ location: i.location,
26
+ exams: i.exams,
27
+ deepLink: i.deeplink,
28
+ }));
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) => {
35
+ const path = '/deeplink-diagnostica';
36
+ const response = await makeRequest('POST', path, {
37
+ kiosk,
38
+ user: mapUserData(user),
39
+ patient: mapPatientData(patient),
40
+ });
41
+ const data = response.data.info.data;
42
+ if (data.forwarding_required)
43
+ return { forwardingRequired: true, deepLink: data.deeplink };
44
+ 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) => {
51
+ const path = '/access-diagnostica';
52
+ await makeRequest('POST', path, {
53
+ kiosk,
54
+ user: mapUserData(user),
55
+ patient: mapPatientData(patient),
56
+ });
57
+ return;
58
+ });
59
+ return { getDiagnosticaHistory, getDiagnosticaDeepLink, getDiagnosticaAccess };
60
+ };
61
+ exports.getDiagnosticaMethods = getDiagnosticaMethods;
62
+ const mapPatientData = (patient) => {
63
+ return {
64
+ name: patient.firstName,
65
+ surname: patient.lastName,
66
+ birthday: date_fns_1.format(patient.birthday, 'yyyy-MM-dd'),
67
+ id_type: 'DNI',
68
+ id_value: patient.identificationValue,
69
+ gender: patient.gender.toLocaleUpperCase(),
70
+ };
71
+ };
72
+ const mapUserData = (user) => {
73
+ return {
74
+ ...mapPatientData(user),
75
+ phone: user.phone,
76
+ email: user.email,
77
+ language: user.language,
78
+ };
79
+ };
@@ -0,0 +1,2 @@
1
+ import { Doc24 } from '../types';
2
+ export declare const getBaseSdk: (url: string, credentials: Doc24.SdkCredentials) => Promise<Doc24.BaseSdk>;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBaseSdk = void 0;
4
+ const zod_1 = require("zod");
5
+ const request_1 = require("../request");
6
+ const validation_1 = require("../request/validation");
7
+ const schemas_1 = require("../schemas");
8
+ const utils_1 = require("../utils");
9
+ const diagnostica_1 = require("./diagnostica");
10
+ const user_1 = require("./user");
11
+ const getBaseSdk = async (url, credentials) => {
12
+ const makeRequest = await request_1.getRequestFactory(url, credentials);
13
+ const diagnosticaMethods = diagnostica_1.getDiagnosticaMethods(makeRequest);
14
+ const userMethods = user_1.getUserMethods(makeRequest, url, credentials);
15
+ const baseSdk = {
16
+ ...diagnosticaMethods,
17
+ ...userMethods,
18
+ getProfessional: validation_1.validateFunction(zod_1.tuple([zod_1.number()]), schemas_1.doc24Schemas.professional, async (professionalId) => {
19
+ const path = `/professional/${professionalId}`;
20
+ const response = await makeRequest('GET', path);
21
+ const raw = response.data;
22
+ return {
23
+ id: raw.professional_id,
24
+ firstName: raw.name,
25
+ lastName: raw.lastname,
26
+ birthdate: utils_1.parseDate(raw.birthdate),
27
+ gender: raw.gender.toLowerCase(),
28
+ email: raw.email,
29
+ phone: raw.phone,
30
+ logoUrl: raw.image,
31
+ matriculation: raw.matriculation,
32
+ specialties: raw.specialties.map((s) => ({
33
+ id: s.specialty_id,
34
+ description: s.specialty,
35
+ })),
36
+ degree: raw.degree,
37
+ languages: raw.languages.map((l) => l.languages),
38
+ resume: {
39
+ link: raw.resume_link,
40
+ brief: raw.resume_brief,
41
+ },
42
+ };
43
+ }),
44
+ getAvailableScheduleClinics: validation_1.validateFunction(zod_1.tuple([]), schemas_1.doc24Schemas.availableScheduleClinics, async () => {
45
+ const path = `/schedule/clinics`;
46
+ const response = await makeRequest('GET', path);
47
+ const mapSpeciality = (s) => ({
48
+ id: s.id_especialidad,
49
+ description: s.especialidad,
50
+ });
51
+ const mapped = {
52
+ specialties: response.data.specialties.map(mapSpeciality),
53
+ specialtiesER: response.data.specialties_er.map(mapSpeciality),
54
+ professionals: response.data.professionals.map((p) => ({
55
+ id: p.id_profesional,
56
+ fullName: p.denominacion,
57
+ clinicId: p.id_consultorio,
58
+ specialties: p.especialidades.map(mapSpeciality),
59
+ })),
60
+ };
61
+ return mapped;
62
+ }),
63
+ };
64
+ return baseSdk;
65
+ };
66
+ exports.getBaseSdk = getBaseSdk;
@@ -0,0 +1,41 @@
1
+ import { RequestMaker } from '../request';
2
+ import { Doc24 } from '../types';
3
+ export declare const getUserMethods: (makeRequest: RequestMaker, url: string, credentials: Doc24.SdkCredentials) => {
4
+ declareUser: (user: {
5
+ firstName: string;
6
+ lastName: string;
7
+ identificationType: "ndi" | "passport" | "credential";
8
+ identificationValue: string;
9
+ gender: "m" | "f";
10
+ phone: string;
11
+ email: string;
12
+ countryId: string;
13
+ birthdate: Date;
14
+ }) => Promise<any>;
15
+ getUserInstance: (...params: any) => Promise<any>;
16
+ enroll: (...params: any) => Promise<void>;
17
+ getConverageInfo: (identificationValue: string) => Promise<{
18
+ firstName: string | null;
19
+ lastName: string | null;
20
+ gender: "m" | "f";
21
+ email: string | null;
22
+ birthdate: Date;
23
+ identificationNumber: string;
24
+ plan: string | null;
25
+ financerId: number | null;
26
+ defaultAffiliationId: number | null;
27
+ credentialNumber: string | null;
28
+ financerPlanId: number | null;
29
+ brand: number | null;
30
+ holderIdentificationNumber: string | null;
31
+ copaymentValue: number | null;
32
+ mobilePhone: string | null;
33
+ company: string | null;
34
+ dischargeDate: Date | null;
35
+ leavingDate: Date | null;
36
+ identificacion_tributaria: string | null;
37
+ deregistrationDate: Date | null;
38
+ authorizationCode: string | null;
39
+ authorizationCodeExpiration: Date | null;
40
+ } | null>;
41
+ };
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getUserMethods = 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 userSdk_1 = require("../userSdk");
9
+ const utils_1 = require("../utils");
10
+ const getUserMethods = (makeRequest, url, credentials) => {
11
+ const getUserId = async (user) => {
12
+ const mappedUser = {
13
+ lastname: user.lastName,
14
+ firstname: user.firstName,
15
+ identification_type: utils_1.getIndetificationTypeId(user.identificationType),
16
+ identification_value: user.identificationValue,
17
+ birthdate: date_fns_1.format(user.birthdate, 'yyyy-MM-dd'),
18
+ gender: user.gender.toUpperCase(),
19
+ phone: user.phone,
20
+ email: user.email,
21
+ country_id: user.countryId,
22
+ };
23
+ const response = await makeRequest('POST', '/user', {
24
+ user_data: mappedUser,
25
+ });
26
+ return response.data.user_id;
27
+ };
28
+ const getConverageInfo = validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.coverageInfo, async (identificationValue) => {
29
+ const path = `/info-coverage/${identificationValue}`;
30
+ const response = await makeRequest('GET', path);
31
+ const raw = response.data.info;
32
+ const mappedCoverageInfo = {
33
+ financerId: raw.id_financiador,
34
+ defaultAffiliationId: raw.id_afiliacion_default,
35
+ plan: raw.plan,
36
+ identificationNumber: raw.nro_documento,
37
+ credentialNumber: raw.nro_credencial,
38
+ lastName: raw.apellido,
39
+ firstName: raw.nombre,
40
+ birthdate: utils_1.parseDate(raw.fecha_nacimiento),
41
+ financerPlanId: raw.id_financiador_plan,
42
+ gender: raw.sexo.toLowerCase(),
43
+ brand: raw.brand,
44
+ holderIdentificationNumber: raw.nro_documento_titular,
45
+ copaymentValue: raw.valor_copago,
46
+ mobilePhone: raw.telefono_movil,
47
+ company: raw.empresa,
48
+ email: raw.email,
49
+ dischargeDate: raw.fecha_alta ? utils_1.parseDateTime(raw.fecha_alta) : null,
50
+ leavingDate: raw.fecha_baja ? utils_1.parseDateTime(raw.fecha_baja) : null,
51
+ identificacion_tributaria: raw.identificacion_tributaria,
52
+ deregistrationDate: raw.fecha_baja_padron
53
+ ? utils_1.parseDateTime(raw.fecha_baja_padron)
54
+ : null,
55
+ authorizationCode: raw.codigo_autorizacion,
56
+ authorizationCodeExpiration: raw.codigo_autorizacion_vencimiento
57
+ ? utils_1.parseDateTime(raw.codigo_autorizacion_vencimiento)
58
+ : null,
59
+ };
60
+ return mappedCoverageInfo;
61
+ });
62
+ return {
63
+ declareUser: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.user]), zod_1.number(), getUserId),
64
+ getUserInstance: validation_1.validateFunction(zod_1.tuple([zod_1.union([schemas_1.doc24Schemas.user, zod_1.number()])]),
65
+ // 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,
86
+ };
87
+ };
88
+ exports.getUserMethods = getUserMethods;