@integraciones_doc24/sdk 0.33.2 → 0.34.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.
- package/lib/baseSdk/index.js +3 -41
- package/lib/baseSdk/user.d.ts +41 -0
- package/lib/baseSdk/user.js +59 -0
- package/lib/index.d.ts +24 -0
- package/lib/schemas.d.ts +70 -0
- package/lib/schemas.js +25 -0
- package/lib/test.d.ts +1 -0
- package/lib/test.js +14 -0
- package/lib/types.d.ts +2 -0
- package/lib/userSdk/sarasas.d.ts +6 -0
- package/lib/userSdk/sarasas.js +13 -0
- package/package.json +1 -1
package/lib/baseSdk/index.js
CHANGED
|
@@ -1,43 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getBaseSdk = void 0;
|
|
4
|
-
const date_fns_1 = require("date-fns");
|
|
5
4
|
const zod_1 = require("zod");
|
|
6
5
|
const request_1 = require("../request");
|
|
7
6
|
const validation_1 = require("../request/validation");
|
|
8
7
|
const schemas_1 = require("../schemas");
|
|
9
|
-
const userSdk_1 = require("../userSdk");
|
|
10
8
|
const utils_1 = require("../utils");
|
|
11
9
|
const diagnostica_1 = require("./diagnostica");
|
|
10
|
+
const user_1 = require("./user");
|
|
12
11
|
const getBaseSdk = async (url, credentials) => {
|
|
13
12
|
const makeRequest = await request_1.getRequestFactory(url, credentials);
|
|
14
|
-
const getUserId = async (user) => {
|
|
15
|
-
const mappedUser = {
|
|
16
|
-
lastname: user.lastName,
|
|
17
|
-
firstname: user.firstName,
|
|
18
|
-
identification_type: utils_1.getIndetificationTypeId(user.identificationType),
|
|
19
|
-
identification_value: user.identificationValue,
|
|
20
|
-
birthdate: date_fns_1.format(user.birthdate, 'yyyy-MM-dd'),
|
|
21
|
-
gender: user.gender.toUpperCase(),
|
|
22
|
-
phone: user.phone,
|
|
23
|
-
email: user.email,
|
|
24
|
-
country_id: user.countryId,
|
|
25
|
-
};
|
|
26
|
-
const response = await makeRequest('POST', '/user', {
|
|
27
|
-
user_data: mappedUser,
|
|
28
|
-
});
|
|
29
|
-
return response.data.user_id;
|
|
30
|
-
};
|
|
31
13
|
const diagnosticaMethods = diagnostica_1.getDiagnosticaMethods(makeRequest);
|
|
14
|
+
const userMethods = user_1.getUserMethods(makeRequest, url, credentials);
|
|
32
15
|
const baseSdk = {
|
|
33
16
|
...diagnosticaMethods,
|
|
34
|
-
|
|
35
|
-
getUserInstance: validation_1.validateFunction(zod_1.tuple([zod_1.union([schemas_1.doc24Schemas.user, zod_1.number()])]),
|
|
36
|
-
// TODO: validate?
|
|
37
|
-
zod_1.any(), async (user) => {
|
|
38
|
-
const userId = typeof user === 'number' ? user : await getUserId(user);
|
|
39
|
-
return userSdk_1.userSdk(url, credentials, userId);
|
|
40
|
-
}),
|
|
17
|
+
...userMethods,
|
|
41
18
|
getProfessional: validation_1.validateFunction(zod_1.tuple([zod_1.number()]), schemas_1.doc24Schemas.professional, async (professionalId) => {
|
|
42
19
|
const path = `/professional/${professionalId}`;
|
|
43
20
|
const response = await makeRequest('GET', path);
|
|
@@ -82,21 +59,6 @@ const getBaseSdk = async (url, credentials) => {
|
|
|
82
59
|
};
|
|
83
60
|
return mapped;
|
|
84
61
|
}),
|
|
85
|
-
enroll: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.enrollmentParams]), zod_1.void(), async (params) => {
|
|
86
|
-
const path = `/enrollment`;
|
|
87
|
-
await makeRequest('POST', path, {
|
|
88
|
-
user_data: {
|
|
89
|
-
firstname: params.firstName,
|
|
90
|
-
lastname: params.lastName,
|
|
91
|
-
gender: params.gender.toUpperCase(),
|
|
92
|
-
identification_number: params.identificationNumber,
|
|
93
|
-
birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
|
|
94
|
-
email: params.email,
|
|
95
|
-
plan: params.plan,
|
|
96
|
-
start_date: date_fns_1.format(params.startDate, 'yyyy-MM-dd'),
|
|
97
|
-
},
|
|
98
|
-
});
|
|
99
|
-
}),
|
|
100
62
|
};
|
|
101
63
|
return baseSdk;
|
|
102
64
|
};
|
|
@@ -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
|
+
nro_credencial?: any;
|
|
19
|
+
valor_copago?: any;
|
|
20
|
+
telefono_movil?: any;
|
|
21
|
+
empresa?: any;
|
|
22
|
+
fecha_baja?: any;
|
|
23
|
+
identificacion_tributaria?: any;
|
|
24
|
+
fecha_baja_padron?: any;
|
|
25
|
+
codigo_autorizacion?: any;
|
|
26
|
+
codigo_autorizacion_vencimiento?: any;
|
|
27
|
+
email: string | null;
|
|
28
|
+
plan: string | null;
|
|
29
|
+
id_afiliacion_default: number;
|
|
30
|
+
id_financiador: number | null;
|
|
31
|
+
nro_documento: string;
|
|
32
|
+
apellido: string;
|
|
33
|
+
nombre: string;
|
|
34
|
+
fecha_nacimiento: string;
|
|
35
|
+
id_financiador_plan: number | null;
|
|
36
|
+
sexo: "M" | "F";
|
|
37
|
+
brand: number;
|
|
38
|
+
nro_documento_titular: string;
|
|
39
|
+
fecha_alta: string;
|
|
40
|
+
} | null>;
|
|
41
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
return response.data.info;
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
declareUser: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.user]), zod_1.number(), getUserId),
|
|
35
|
+
getUserInstance: validation_1.validateFunction(zod_1.tuple([zod_1.union([schemas_1.doc24Schemas.user, zod_1.number()])]),
|
|
36
|
+
// TODO: validate?
|
|
37
|
+
zod_1.any(), async (user) => {
|
|
38
|
+
const userId = typeof user === 'number' ? user : await getUserId(user);
|
|
39
|
+
return userSdk_1.userSdk(url, credentials, userId);
|
|
40
|
+
}),
|
|
41
|
+
enroll: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.enrollmentParams]), zod_1.void(), async (params) => {
|
|
42
|
+
const path = `/enrollment`;
|
|
43
|
+
await makeRequest('POST', path, {
|
|
44
|
+
user_data: {
|
|
45
|
+
firstname: params.firstName,
|
|
46
|
+
lastname: params.lastName,
|
|
47
|
+
gender: params.gender.toUpperCase(),
|
|
48
|
+
identification_number: params.identificationNumber,
|
|
49
|
+
birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
|
|
50
|
+
email: params.email,
|
|
51
|
+
plan: params.plan,
|
|
52
|
+
start_date: date_fns_1.format(params.startDate, 'yyyy-MM-dd'),
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
}),
|
|
56
|
+
getConverageInfo,
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
exports.getUserMethods = getUserMethods;
|
package/lib/index.d.ts
CHANGED
|
@@ -76,6 +76,30 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
|
|
|
76
76
|
identificationNumber: string;
|
|
77
77
|
plan: string;
|
|
78
78
|
}) => Promise<void>;
|
|
79
|
+
getConverageInfo: (identificationValue: string) => Promise<{
|
|
80
|
+
nro_credencial?: any;
|
|
81
|
+
valor_copago?: any;
|
|
82
|
+
telefono_movil?: any;
|
|
83
|
+
empresa?: any;
|
|
84
|
+
fecha_baja?: any;
|
|
85
|
+
identificacion_tributaria?: any;
|
|
86
|
+
fecha_baja_padron?: any;
|
|
87
|
+
codigo_autorizacion?: any;
|
|
88
|
+
codigo_autorizacion_vencimiento?: any;
|
|
89
|
+
email: string | null;
|
|
90
|
+
plan: string | null;
|
|
91
|
+
id_afiliacion_default: number;
|
|
92
|
+
id_financiador: number | null;
|
|
93
|
+
nro_documento: string;
|
|
94
|
+
apellido: string;
|
|
95
|
+
nombre: string;
|
|
96
|
+
fecha_nacimiento: string;
|
|
97
|
+
id_financiador_plan: number | null;
|
|
98
|
+
sexo: "M" | "F";
|
|
99
|
+
brand: number;
|
|
100
|
+
nro_documento_titular: string;
|
|
101
|
+
fecha_alta: string;
|
|
102
|
+
} | null>;
|
|
79
103
|
getDiagnosticaHistory: (patient: {
|
|
80
104
|
identificationType: "ndi" | "passport" | "credential";
|
|
81
105
|
identificationValue: string;
|
package/lib/schemas.d.ts
CHANGED
|
@@ -1024,4 +1024,74 @@ export declare const doc24Schemas: {
|
|
|
1024
1024
|
}, {
|
|
1025
1025
|
forwardingRequired: false;
|
|
1026
1026
|
}>]>;
|
|
1027
|
+
coverageInfo: import("zod").ZodNullable<import("zod").ZodObject<{
|
|
1028
|
+
id_afiliacion_default: import("zod").ZodNumber;
|
|
1029
|
+
id_financiador: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
1030
|
+
plan: import("zod").ZodNullable<import("zod").ZodString>;
|
|
1031
|
+
nro_documento: import("zod").ZodString;
|
|
1032
|
+
nro_credencial: import("zod").ZodNullable<import("zod").ZodAny>;
|
|
1033
|
+
apellido: import("zod").ZodString;
|
|
1034
|
+
nombre: import("zod").ZodString;
|
|
1035
|
+
fecha_nacimiento: import("zod").ZodString;
|
|
1036
|
+
id_financiador_plan: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
1037
|
+
sexo: import("zod").ZodEnum<["M", "F"]>;
|
|
1038
|
+
brand: import("zod").ZodNumber;
|
|
1039
|
+
nro_documento_titular: import("zod").ZodString;
|
|
1040
|
+
valor_copago: import("zod").ZodNullable<import("zod").ZodAny>;
|
|
1041
|
+
telefono_movil: import("zod").ZodNullable<import("zod").ZodAny>;
|
|
1042
|
+
empresa: import("zod").ZodNullable<import("zod").ZodAny>;
|
|
1043
|
+
email: import("zod").ZodNullable<import("zod").ZodString>;
|
|
1044
|
+
fecha_alta: import("zod").ZodString;
|
|
1045
|
+
fecha_baja: import("zod").ZodNullable<import("zod").ZodAny>;
|
|
1046
|
+
identificacion_tributaria: import("zod").ZodNullable<import("zod").ZodAny>;
|
|
1047
|
+
fecha_baja_padron: import("zod").ZodNullable<import("zod").ZodAny>;
|
|
1048
|
+
codigo_autorizacion: import("zod").ZodNullable<import("zod").ZodAny>;
|
|
1049
|
+
codigo_autorizacion_vencimiento: import("zod").ZodNullable<import("zod").ZodAny>;
|
|
1050
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
1051
|
+
nro_credencial?: any;
|
|
1052
|
+
valor_copago?: any;
|
|
1053
|
+
telefono_movil?: any;
|
|
1054
|
+
empresa?: any;
|
|
1055
|
+
fecha_baja?: any;
|
|
1056
|
+
identificacion_tributaria?: any;
|
|
1057
|
+
fecha_baja_padron?: any;
|
|
1058
|
+
codigo_autorizacion?: any;
|
|
1059
|
+
codigo_autorizacion_vencimiento?: any;
|
|
1060
|
+
email: string | null;
|
|
1061
|
+
plan: string | null;
|
|
1062
|
+
id_afiliacion_default: number;
|
|
1063
|
+
id_financiador: number | null;
|
|
1064
|
+
nro_documento: string;
|
|
1065
|
+
apellido: string;
|
|
1066
|
+
nombre: string;
|
|
1067
|
+
fecha_nacimiento: string;
|
|
1068
|
+
id_financiador_plan: number | null;
|
|
1069
|
+
sexo: "M" | "F";
|
|
1070
|
+
brand: number;
|
|
1071
|
+
nro_documento_titular: string;
|
|
1072
|
+
fecha_alta: string;
|
|
1073
|
+
}, {
|
|
1074
|
+
nro_credencial?: any;
|
|
1075
|
+
valor_copago?: any;
|
|
1076
|
+
telefono_movil?: any;
|
|
1077
|
+
empresa?: any;
|
|
1078
|
+
fecha_baja?: any;
|
|
1079
|
+
identificacion_tributaria?: any;
|
|
1080
|
+
fecha_baja_padron?: any;
|
|
1081
|
+
codigo_autorizacion?: any;
|
|
1082
|
+
codigo_autorizacion_vencimiento?: any;
|
|
1083
|
+
email: string | null;
|
|
1084
|
+
plan: string | null;
|
|
1085
|
+
id_afiliacion_default: number;
|
|
1086
|
+
id_financiador: number | null;
|
|
1087
|
+
nro_documento: string;
|
|
1088
|
+
apellido: string;
|
|
1089
|
+
nombre: string;
|
|
1090
|
+
fecha_nacimiento: string;
|
|
1091
|
+
id_financiador_plan: number | null;
|
|
1092
|
+
sexo: "M" | "F";
|
|
1093
|
+
brand: number;
|
|
1094
|
+
nro_documento_titular: string;
|
|
1095
|
+
fecha_alta: string;
|
|
1096
|
+
}>>;
|
|
1027
1097
|
};
|
package/lib/schemas.js
CHANGED
|
@@ -147,6 +147,30 @@ const diagnosticaDeepLinkResponse = zod_1.object({
|
|
|
147
147
|
forwardingRequired: zod_1.literal(true),
|
|
148
148
|
deepLink: zod_1.string().url(),
|
|
149
149
|
}).or(zod_1.object({ forwardingRequired: zod_1.literal(false) }));
|
|
150
|
+
const coverageInfo = zod_1.object({
|
|
151
|
+
id_afiliacion_default: zod_1.number(),
|
|
152
|
+
id_financiador: zod_1.number().nullable(),
|
|
153
|
+
plan: zod_1.string().nullable(),
|
|
154
|
+
nro_documento: zod_1.string(),
|
|
155
|
+
nro_credencial: zod_1.any().nullable(),
|
|
156
|
+
apellido: zod_1.string(),
|
|
157
|
+
nombre: zod_1.string(),
|
|
158
|
+
fecha_nacimiento: zod_1.string(),
|
|
159
|
+
id_financiador_plan: zod_1.number().nullable(),
|
|
160
|
+
sexo: zod_1.enum(['M', 'F']),
|
|
161
|
+
brand: zod_1.number(),
|
|
162
|
+
nro_documento_titular: zod_1.string(),
|
|
163
|
+
valor_copago: zod_1.any().nullable(),
|
|
164
|
+
telefono_movil: zod_1.any().nullable(),
|
|
165
|
+
empresa: zod_1.any().nullable(),
|
|
166
|
+
email: zod_1.string().email().nullable(),
|
|
167
|
+
fecha_alta: zod_1.string(),
|
|
168
|
+
fecha_baja: zod_1.any().nullable(),
|
|
169
|
+
identificacion_tributaria: zod_1.any().nullable(),
|
|
170
|
+
fecha_baja_padron: zod_1.any().nullable(),
|
|
171
|
+
codigo_autorizacion: zod_1.any().nullable(),
|
|
172
|
+
codigo_autorizacion_vencimiento: zod_1.any().nullable(),
|
|
173
|
+
}).nullable();
|
|
150
174
|
exports.doc24Schemas = {
|
|
151
175
|
identificationType,
|
|
152
176
|
sdkCredentials,
|
|
@@ -265,4 +289,5 @@ exports.doc24Schemas = {
|
|
|
265
289
|
diagnosticaUser,
|
|
266
290
|
diagnosticaPatient,
|
|
267
291
|
diagnosticaDeepLinkResponse,
|
|
292
|
+
coverageInfo,
|
|
268
293
|
};
|
package/lib/test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/test.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const _1 = require(".");
|
|
4
|
+
const test = async () => {
|
|
5
|
+
const baseSdk = await _1.doc24Sdk({
|
|
6
|
+
url: 'https://tapi.doc24.com.ar/ws/sdk',
|
|
7
|
+
credentials: {
|
|
8
|
+
iss: 'wehealthy',
|
|
9
|
+
key: '33Ypv5jQ1VTr1KcOImdBhPnoRDqmPlYR3JWbrlUim9U=',
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
await baseSdk.getConverageInfo('37970350');
|
|
13
|
+
};
|
|
14
|
+
test();
|
package/lib/types.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export declare namespace Doc24 {
|
|
|
24
24
|
type ChatDetails = TypeOf<typeof doc24Schemas.chatDetails>;
|
|
25
25
|
type ChatPost = TypeOf<typeof doc24Schemas.chatPost>;
|
|
26
26
|
type EnrollmentParams = TypeOf<typeof doc24Schemas.enrollmentParams>;
|
|
27
|
+
type CoverageInfo = TypeOf<typeof doc24Schemas.coverageInfo>;
|
|
27
28
|
type DiagnosticaPatientFilter = TypeOf<typeof doc24Schemas.diagnosticaPatientFilter>;
|
|
28
29
|
type DiagnosticaUser = TypeOf<typeof doc24Schemas.diagnosticaUser>;
|
|
29
30
|
type DiagnosticaPatient = TypeOf<typeof doc24Schemas.diagnosticaPatient>;
|
|
@@ -35,6 +36,7 @@ export declare namespace Doc24 {
|
|
|
35
36
|
getProfessional: (professionalId: number) => Promise<Professional>;
|
|
36
37
|
getAvailableScheduleClinics: () => Promise<AvailableScheduleClinics>;
|
|
37
38
|
enroll: (params: EnrollmentParams) => Promise<void>;
|
|
39
|
+
getConverageInfo: (identificationValue: string) => Promise<CoverageInfo>;
|
|
38
40
|
getDiagnosticaHistory: (patient: DiagnosticaPatientFilter, from: Date, to: Date) => Promise<DiagnosticaHistoryAppointment[]>;
|
|
39
41
|
getDiagnosticaDeepLink: (kiosk: string, user: DiagnosticaUser, patient: DiagnosticaPatient) => Promise<DiagnosticaDeepLinkResponse>;
|
|
40
42
|
getDiagnosticaAccess: (kiosk: string, user: DiagnosticaUser, patient: DiagnosticaPatient) => Promise<void>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSarasaMethods = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const validation_1 = require("../request/validation");
|
|
6
|
+
const schemas_1 = require("../schemas");
|
|
7
|
+
const getSarasaMethods = (_makeRequest) => {
|
|
8
|
+
const getSarasa = validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.sarasa, async (userId) => {
|
|
9
|
+
return { id: userId };
|
|
10
|
+
});
|
|
11
|
+
return { getSarasa };
|
|
12
|
+
};
|
|
13
|
+
exports.getSarasaMethods = getSarasaMethods;
|