@integraciones_doc24/sdk 1.16.39 → 1.16.40

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 (48) hide show
  1. package/README.md +225 -225
  2. package/lib/baseSdk/diagnostica.d.ts +54 -54
  3. package/lib/baseSdk/diagnostica.js +82 -82
  4. package/lib/baseSdk/external.d.ts +177 -177
  5. package/lib/baseSdk/external.js +96 -96
  6. package/lib/baseSdk/index.d.ts +2 -2
  7. package/lib/baseSdk/index.js +80 -80
  8. package/lib/baseSdk/integrationError.d.ts +16 -16
  9. package/lib/baseSdk/integrationError.js +33 -33
  10. package/lib/baseSdk/user.d.ts +115 -115
  11. package/lib/baseSdk/user.js +136 -136
  12. package/lib/index.d.ts +416 -416
  13. package/lib/index.js +22 -22
  14. package/lib/request/index.d.ts +4 -4
  15. package/lib/request/index.js +32 -32
  16. package/lib/request/token.d.ts +2 -2
  17. package/lib/request/token.js +34 -34
  18. package/lib/request/validation.d.ts +10 -10
  19. package/lib/request/validation.js +28 -28
  20. package/lib/schemas.d.ts +2813 -2757
  21. package/lib/schemas.js +601 -594
  22. package/lib/types.d.ts +178 -177
  23. package/lib/types.js +2 -2
  24. package/lib/userSdk/binah.d.ts +21 -21
  25. package/lib/userSdk/binah.js +20 -20
  26. package/lib/userSdk/chat.d.ts +57 -57
  27. package/lib/userSdk/chat.js +98 -98
  28. package/lib/userSdk/external.d.ts +34 -34
  29. package/lib/userSdk/external.js +72 -72
  30. package/lib/userSdk/index.d.ts +2 -2
  31. package/lib/userSdk/index.js +33 -33
  32. package/lib/userSdk/patients.d.ts +62 -60
  33. package/lib/userSdk/patients.js +93 -91
  34. package/lib/userSdk/schedule.d.ts +59 -59
  35. package/lib/userSdk/schedule.js +90 -90
  36. package/lib/userSdk/specialties.d.ts +19 -19
  37. package/lib/userSdk/specialties.js +48 -48
  38. package/lib/userSdk/videoVisit.d.ts +225 -225
  39. package/lib/userSdk/videoVisit.js +283 -283
  40. package/lib/utils.d.ts +4 -4
  41. package/lib/utils.js +68 -68
  42. package/lib/webhook/index.d.ts +2 -2
  43. package/lib/webhook/index.js +67 -67
  44. package/lib/webhook/responses.d.ts +35 -35
  45. package/lib/webhook/responses.js +42 -42
  46. package/lib/webhook/token.d.ts +2 -2
  47. package/lib/webhook/token.js +23 -23
  48. package/package.json +37 -37
@@ -1,115 +1,115 @@
1
- import { RequestMaker } from '../request';
2
- import { Doc24 } from '../types';
3
- export declare const getUserMethods: (makeRequest: RequestMaker, url: string, credentials: Doc24.SdkCredentials) => {
4
- declareUser: (params: {
5
- user: {
6
- identificationType?: number | undefined;
7
- identificationValue?: string | undefined;
8
- gender?: "m" | "f" | "o" | undefined;
9
- emergencyContact?: string | null | undefined;
10
- emergencyContactPhone?: string | number | null | undefined;
11
- credential?: string | null | undefined;
12
- plan?: string | null | undefined;
13
- affiliationStatus?: string | null | undefined;
14
- localidad?: string | null | undefined;
15
- codPostal?: string | null | undefined;
16
- provincia?: string | null | undefined;
17
- phone?: string | undefined;
18
- firstName: string;
19
- lastName: string;
20
- countryId: string;
21
- birthdate: Date;
22
- email: string;
23
- };
24
- } & {
25
- code?: string | undefined;
26
- channel?: "1" | "2" | undefined;
27
- }) => Promise<{
28
- askCode: true;
29
- userInfo: {
30
- phone: string;
31
- email: string;
32
- };
33
- } | {
34
- patientId: number | null;
35
- askCode: false;
36
- userId: number;
37
- }>;
38
- getUserId: (user: {
39
- identificationType?: number | undefined;
40
- identificationValue?: string | undefined;
41
- gender?: "m" | "f" | "o" | undefined;
42
- emergencyContact?: string | null | undefined;
43
- emergencyContactPhone?: string | number | null | undefined;
44
- credential?: string | null | undefined;
45
- plan?: string | null | undefined;
46
- affiliationStatus?: string | null | undefined;
47
- localidad?: string | null | undefined;
48
- codPostal?: string | null | undefined;
49
- provincia?: string | null | undefined;
50
- phone?: string | undefined;
51
- firstName: string;
52
- lastName: string;
53
- countryId: string;
54
- birthdate: Date;
55
- email: string;
56
- }) => Promise<number>;
57
- sendVerificationCode: (params: {
58
- identificationType: number;
59
- identificationValue: string;
60
- channel: "1" | "2";
61
- }) => Promise<void>;
62
- getUserInstance: (user: number | {
63
- identificationType?: number | undefined;
64
- identificationValue?: string | undefined;
65
- gender?: "m" | "f" | "o" | undefined;
66
- emergencyContact?: string | null | undefined;
67
- emergencyContactPhone?: string | number | null | undefined;
68
- credential?: string | null | undefined;
69
- plan?: string | null | undefined;
70
- affiliationStatus?: string | null | undefined;
71
- localidad?: string | null | undefined;
72
- codPostal?: string | null | undefined;
73
- provincia?: string | null | undefined;
74
- phone?: string | undefined;
75
- firstName: string;
76
- lastName: string;
77
- countryId: string;
78
- birthdate: Date;
79
- email: string;
80
- }) => Promise<any>;
81
- enroll: (params: {
82
- gender?: "m" | "f" | "o" | undefined;
83
- firstName: string;
84
- lastName: string;
85
- birthdate: Date;
86
- plan: string;
87
- email: string;
88
- identificationNumber: string;
89
- startDate: Date;
90
- }) => Promise<void>;
91
- getCoverageInfo: (identificationValue: string) => Promise<{
92
- gender?: "m" | "f" | "o" | undefined;
93
- firstName: string | null;
94
- lastName: string | null;
95
- birthdate: Date;
96
- plan: string | null;
97
- email: string | null;
98
- identificationNumber: string;
99
- financerId: number | null;
100
- defaultAffiliationId: number | null;
101
- credentialNumber: string | null;
102
- financerPlanId: number | null;
103
- brand: number | null;
104
- holderIdentificationNumber: string | null;
105
- copaymentValue: number | null;
106
- mobilePhone: string | null;
107
- company: string | null;
108
- dischargeDate: Date | null;
109
- leavingDate: Date | null;
110
- identificacion_tributaria: string | null;
111
- deregistrationDate: Date | null;
112
- authorizationCode: string | null;
113
- authorizationCodeExpiration: Date | null;
114
- } | null>;
115
- };
1
+ import { RequestMaker } from '../request';
2
+ import { Doc24 } from '../types';
3
+ export declare const getUserMethods: (makeRequest: RequestMaker, url: string, credentials: Doc24.SdkCredentials) => {
4
+ declareUser: (params: {
5
+ user: {
6
+ identificationType?: number | undefined;
7
+ identificationValue?: string | undefined;
8
+ gender?: "m" | "f" | "o" | undefined;
9
+ emergencyContact?: string | null | undefined;
10
+ emergencyContactPhone?: string | number | null | undefined;
11
+ credential?: string | null | undefined;
12
+ plan?: string | null | undefined;
13
+ affiliationStatus?: string | null | undefined;
14
+ localidad?: string | null | undefined;
15
+ codPostal?: string | null | undefined;
16
+ provincia?: string | null | undefined;
17
+ phone?: string | undefined;
18
+ firstName: string;
19
+ lastName: string;
20
+ countryId: string;
21
+ birthdate: Date;
22
+ email: string;
23
+ };
24
+ } & {
25
+ code?: string | undefined;
26
+ channel?: "1" | "2" | undefined;
27
+ }) => Promise<{
28
+ askCode: true;
29
+ userInfo: {
30
+ email: string;
31
+ phone: string;
32
+ };
33
+ } | {
34
+ patientId: number | null;
35
+ askCode: false;
36
+ userId: number;
37
+ }>;
38
+ getUserId: (user: {
39
+ identificationType?: number | undefined;
40
+ identificationValue?: string | undefined;
41
+ gender?: "m" | "f" | "o" | undefined;
42
+ emergencyContact?: string | null | undefined;
43
+ emergencyContactPhone?: string | number | null | undefined;
44
+ credential?: string | null | undefined;
45
+ plan?: string | null | undefined;
46
+ affiliationStatus?: string | null | undefined;
47
+ localidad?: string | null | undefined;
48
+ codPostal?: string | null | undefined;
49
+ provincia?: string | null | undefined;
50
+ phone?: string | undefined;
51
+ firstName: string;
52
+ lastName: string;
53
+ countryId: string;
54
+ birthdate: Date;
55
+ email: string;
56
+ }) => Promise<number>;
57
+ sendVerificationCode: (params: {
58
+ identificationType: number;
59
+ identificationValue: string;
60
+ channel: "1" | "2";
61
+ }) => Promise<void>;
62
+ getUserInstance: (user: number | {
63
+ identificationType?: number | undefined;
64
+ identificationValue?: string | undefined;
65
+ gender?: "m" | "f" | "o" | undefined;
66
+ emergencyContact?: string | null | undefined;
67
+ emergencyContactPhone?: string | number | null | undefined;
68
+ credential?: string | null | undefined;
69
+ plan?: string | null | undefined;
70
+ affiliationStatus?: string | null | undefined;
71
+ localidad?: string | null | undefined;
72
+ codPostal?: string | null | undefined;
73
+ provincia?: string | null | undefined;
74
+ phone?: string | undefined;
75
+ firstName: string;
76
+ lastName: string;
77
+ countryId: string;
78
+ birthdate: Date;
79
+ email: string;
80
+ }) => Promise<any>;
81
+ enroll: (params: {
82
+ gender?: "m" | "f" | "o" | undefined;
83
+ firstName: string;
84
+ lastName: string;
85
+ birthdate: Date;
86
+ plan: string;
87
+ email: string;
88
+ identificationNumber: string;
89
+ startDate: Date;
90
+ }) => Promise<void>;
91
+ getCoverageInfo: (identificationValue: string) => Promise<{
92
+ gender?: "m" | "f" | "o" | undefined;
93
+ firstName: string | null;
94
+ lastName: string | null;
95
+ birthdate: Date;
96
+ plan: string | null;
97
+ email: string | null;
98
+ identificationNumber: string;
99
+ financerId: number | null;
100
+ defaultAffiliationId: number | null;
101
+ credentialNumber: string | null;
102
+ financerPlanId: number | null;
103
+ brand: number | null;
104
+ holderIdentificationNumber: string | null;
105
+ copaymentValue: number | null;
106
+ mobilePhone: string | null;
107
+ company: string | null;
108
+ dischargeDate: Date | null;
109
+ leavingDate: Date | null;
110
+ identificacion_tributaria: string | null;
111
+ deregistrationDate: Date | null;
112
+ authorizationCode: string | null;
113
+ authorizationCodeExpiration: Date | null;
114
+ } | null>;
115
+ };
@@ -1,136 +1,136 @@
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 declareUser = async ({ user, channel, code, }) => {
12
- var _a;
13
- const path = '/user';
14
- const mappedUser = {
15
- lastname: user.lastName,
16
- firstname: user.firstName,
17
- identification_type: user.identificationType,
18
- identification_value: user.identificationValue,
19
- birthdate: date_fns_1.format(user.birthdate, 'yyyy-MM-dd'),
20
- gender: (_a = user.gender) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
21
- phone: user.phone,
22
- email: user.email,
23
- country_id: user.countryId,
24
- };
25
- const parsedChannel = channel ? parseInt(channel) : channel;
26
- const response = await makeRequest('POST', path, {
27
- user_data: mappedUser,
28
- channel: parsedChannel,
29
- code,
30
- });
31
- const data = response.data;
32
- if (data.ask_code)
33
- return { askCode: true, userInfo: data.user_info };
34
- return {
35
- askCode: false,
36
- userId: response.data.user_id,
37
- patientId: response.data.patient_id,
38
- };
39
- };
40
- const getUserId = async (user) => {
41
- var _a;
42
- const path = '/search-user';
43
- const mappedUser = {
44
- lastname: user.lastName,
45
- firstname: user.firstName,
46
- identification_type: user.identificationType,
47
- identification_value: user.identificationValue,
48
- birthdate: date_fns_1.format(user.birthdate, 'yyyy-MM-dd'),
49
- gender: (_a = user.gender) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
50
- phone: user.phone,
51
- email: user.email,
52
- country_id: user.countryId,
53
- };
54
- const response = await makeRequest('POST', path, {
55
- user_data: mappedUser,
56
- });
57
- return response.data.user_id;
58
- };
59
- const sendVerificationCode = async (params) => {
60
- const path = '/send-verification-code';
61
- const mappedParams = {
62
- identification_type: params.identificationType,
63
- identification_value: params.identificationValue,
64
- channel: parseInt(params.channel),
65
- };
66
- await makeRequest('POST', path, mappedParams);
67
- };
68
- const getUserInstance = async (user) => {
69
- const userId = typeof user === 'number' ? user : await getUserId(user);
70
- return userSdk_1.userSdk(url, credentials, userId);
71
- };
72
- const enroll = async (params) => {
73
- var _a;
74
- const path = `/enrollment`;
75
- const mappedUser = {
76
- firstname: params.firstName,
77
- lastname: params.lastName,
78
- gender: (_a = params.gender) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
79
- identification_number: params.identificationNumber,
80
- birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
81
- email: params.email,
82
- plan: params.plan,
83
- start_date: date_fns_1.format(params.startDate, 'yyyy-MM-dd'),
84
- };
85
- await makeRequest('POST', path, {
86
- user_data: mappedUser,
87
- });
88
- };
89
- const getCoverageInfo = async (identificationValue) => {
90
- const path = `/info-coverage/${identificationValue}`;
91
- const response = await makeRequest('GET', path);
92
- const raw = response.data.info;
93
- if (!raw)
94
- return null;
95
- const mappedCoverageInfo = {
96
- financerId: raw.id_financiador,
97
- defaultAffiliationId: raw.id_afiliacion_default,
98
- plan: raw.plan,
99
- identificationNumber: raw.nro_documento,
100
- credentialNumber: raw.nro_credencial,
101
- lastName: raw.apellido,
102
- firstName: raw.nombre,
103
- birthdate: utils_1.parseDate(raw.fecha_nacimiento),
104
- financerPlanId: raw.id_financiador_plan,
105
- gender: raw.sexo.toLowerCase(),
106
- brand: raw.brand,
107
- holderIdentificationNumber: raw.nro_documento_titular,
108
- copaymentValue: raw.valor_copago,
109
- mobilePhone: raw.telefono_movil,
110
- company: raw.empresa,
111
- email: raw.email,
112
- dischargeDate: raw.fecha_alta ? utils_1.parseDateTime(raw.fecha_alta) : null,
113
- leavingDate: raw.fecha_baja ? utils_1.parseDateTime(raw.fecha_baja) : null,
114
- identificacion_tributaria: raw.identificacion_tributaria,
115
- deregistrationDate: raw.fecha_baja_padron
116
- ? utils_1.parseDateTime(raw.fecha_baja_padron)
117
- : null,
118
- authorizationCode: raw.codigo_autorizacion,
119
- authorizationCodeExpiration: raw.codigo_autorizacion_vencimiento
120
- ? utils_1.parseDateTime(raw.codigo_autorizacion_vencimiento)
121
- : null,
122
- };
123
- return mappedCoverageInfo;
124
- };
125
- return {
126
- declareUser: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.declareUserParams]), schemas_1.doc24Schemas.declareUserResponse, declareUser),
127
- getUserId: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.user]), zod_1.number(), getUserId),
128
- sendVerificationCode: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.sendVerificationCodeParams]), zod_1.void(), sendVerificationCode),
129
- getUserInstance: validation_1.validateFunction(zod_1.tuple([zod_1.union([schemas_1.doc24Schemas.user, zod_1.number()])]),
130
- // TODO: validate?
131
- zod_1.any(), getUserInstance),
132
- enroll: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.enrollmentParams]), zod_1.void(), enroll),
133
- getCoverageInfo: validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.coverageInfo, getCoverageInfo),
134
- };
135
- };
136
- exports.getUserMethods = getUserMethods;
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 declareUser = async ({ user, channel, code, }) => {
12
+ var _a;
13
+ const path = '/user';
14
+ const mappedUser = {
15
+ lastname: user.lastName,
16
+ firstname: user.firstName,
17
+ identification_type: user.identificationType,
18
+ identification_value: user.identificationValue,
19
+ birthdate: date_fns_1.format(user.birthdate, 'yyyy-MM-dd'),
20
+ gender: (_a = user.gender) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
21
+ phone: user.phone,
22
+ email: user.email,
23
+ country_id: user.countryId,
24
+ };
25
+ const parsedChannel = channel ? parseInt(channel) : channel;
26
+ const response = await makeRequest('POST', path, {
27
+ user_data: mappedUser,
28
+ channel: parsedChannel,
29
+ code,
30
+ });
31
+ const data = response.data;
32
+ if (data.ask_code)
33
+ return { askCode: true, userInfo: data.user_info };
34
+ return {
35
+ askCode: false,
36
+ userId: response.data.user_id,
37
+ patientId: response.data.patient_id,
38
+ };
39
+ };
40
+ const getUserId = async (user) => {
41
+ var _a;
42
+ const path = '/search-user';
43
+ const mappedUser = {
44
+ lastname: user.lastName,
45
+ firstname: user.firstName,
46
+ identification_type: user.identificationType,
47
+ identification_value: user.identificationValue,
48
+ birthdate: date_fns_1.format(user.birthdate, 'yyyy-MM-dd'),
49
+ gender: (_a = user.gender) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
50
+ phone: user.phone,
51
+ email: user.email,
52
+ country_id: user.countryId,
53
+ };
54
+ const response = await makeRequest('POST', path, {
55
+ user_data: mappedUser,
56
+ });
57
+ return response.data.user_id;
58
+ };
59
+ const sendVerificationCode = async (params) => {
60
+ const path = '/send-verification-code';
61
+ const mappedParams = {
62
+ identification_type: params.identificationType,
63
+ identification_value: params.identificationValue,
64
+ channel: parseInt(params.channel),
65
+ };
66
+ await makeRequest('POST', path, mappedParams);
67
+ };
68
+ const getUserInstance = async (user) => {
69
+ const userId = typeof user === 'number' ? user : await getUserId(user);
70
+ return userSdk_1.userSdk(url, credentials, userId);
71
+ };
72
+ const enroll = async (params) => {
73
+ var _a;
74
+ const path = `/enrollment`;
75
+ const mappedUser = {
76
+ firstname: params.firstName,
77
+ lastname: params.lastName,
78
+ gender: (_a = params.gender) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
79
+ identification_number: params.identificationNumber,
80
+ birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
81
+ email: params.email,
82
+ plan: params.plan,
83
+ start_date: date_fns_1.format(params.startDate, 'yyyy-MM-dd'),
84
+ };
85
+ await makeRequest('POST', path, {
86
+ user_data: mappedUser,
87
+ });
88
+ };
89
+ const getCoverageInfo = async (identificationValue) => {
90
+ const path = `/info-coverage/${identificationValue}`;
91
+ const response = await makeRequest('GET', path);
92
+ const raw = response.data.info;
93
+ if (!raw)
94
+ return null;
95
+ const mappedCoverageInfo = {
96
+ financerId: raw.id_financiador,
97
+ defaultAffiliationId: raw.id_afiliacion_default,
98
+ plan: raw.plan,
99
+ identificationNumber: raw.nro_documento,
100
+ credentialNumber: raw.nro_credencial,
101
+ lastName: raw.apellido,
102
+ firstName: raw.nombre,
103
+ birthdate: utils_1.parseDate(raw.fecha_nacimiento),
104
+ financerPlanId: raw.id_financiador_plan,
105
+ gender: raw.sexo.toLowerCase(),
106
+ brand: raw.brand,
107
+ holderIdentificationNumber: raw.nro_documento_titular,
108
+ copaymentValue: raw.valor_copago,
109
+ mobilePhone: raw.telefono_movil,
110
+ company: raw.empresa,
111
+ email: raw.email,
112
+ dischargeDate: raw.fecha_alta ? utils_1.parseDateTime(raw.fecha_alta) : null,
113
+ leavingDate: raw.fecha_baja ? utils_1.parseDateTime(raw.fecha_baja) : null,
114
+ identificacion_tributaria: raw.identificacion_tributaria,
115
+ deregistrationDate: raw.fecha_baja_padron
116
+ ? utils_1.parseDateTime(raw.fecha_baja_padron)
117
+ : null,
118
+ authorizationCode: raw.codigo_autorizacion,
119
+ authorizationCodeExpiration: raw.codigo_autorizacion_vencimiento
120
+ ? utils_1.parseDateTime(raw.codigo_autorizacion_vencimiento)
121
+ : null,
122
+ };
123
+ return mappedCoverageInfo;
124
+ };
125
+ return {
126
+ declareUser: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.declareUserParams]), schemas_1.doc24Schemas.declareUserResponse, declareUser),
127
+ getUserId: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.user]), zod_1.number(), getUserId),
128
+ sendVerificationCode: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.sendVerificationCodeParams]), zod_1.void(), sendVerificationCode),
129
+ getUserInstance: validation_1.validateFunction(zod_1.tuple([zod_1.union([schemas_1.doc24Schemas.user, zod_1.number()])]),
130
+ // TODO: validate?
131
+ zod_1.any(), getUserInstance),
132
+ enroll: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.enrollmentParams]), zod_1.void(), enroll),
133
+ getCoverageInfo: validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.coverageInfo, getCoverageInfo),
134
+ };
135
+ };
136
+ exports.getUserMethods = getUserMethods;