@integraciones_doc24/sdk 0.34.3 → 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.
- package/lib/baseSdk/index.js +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/lib/baseSdk/diagnostica.d.ts +11 -0
- package/lib/lib/baseSdk/diagnostica.js +79 -0
- package/lib/lib/baseSdk/external.d.ts +15 -0
- package/lib/lib/baseSdk/external.js +73 -0
- package/lib/lib/baseSdk/index.d.ts +114 -0
- package/lib/lib/baseSdk/index.js +66 -0
- package/lib/lib/baseSdk/user.d.ts +30 -0
- package/lib/lib/baseSdk/user.js +88 -0
- package/lib/lib/index.d.ts +154 -0
- package/lib/lib/index.js +22 -0
- package/lib/lib/request/index.d.ts +2 -0
- package/lib/lib/request/index.js +26 -0
- package/lib/lib/request/token.d.ts +2 -0
- package/lib/lib/request/token.js +34 -0
- package/lib/lib/request/validation.d.ts +10 -0
- package/lib/lib/request/validation.js +28 -0
- package/lib/lib/schemas.d.ts +1138 -0
- package/lib/lib/schemas.js +294 -0
- package/lib/lib/test.d.ts +1 -0
- package/lib/lib/test.js +55 -0
- package/lib/lib/types.d.ts +1 -0
- package/lib/lib/types.js +2 -0
- package/lib/lib/userSdk/chat.d.ts +9 -0
- package/lib/lib/userSdk/chat.js +98 -0
- package/lib/lib/userSdk/index.d.ts +220 -0
- package/lib/lib/userSdk/index.js +27 -0
- package/lib/lib/userSdk/patients.d.ts +4 -0
- package/lib/lib/userSdk/patients.js +27 -0
- package/lib/lib/userSdk/sarasas.d.ts +6 -0
- package/lib/lib/userSdk/sarasas.js +13 -0
- package/lib/lib/userSdk/schedule.d.ts +15 -0
- package/lib/lib/userSdk/schedule.js +76 -0
- package/lib/lib/userSdk/specialties.d.ts +4 -0
- package/lib/lib/userSdk/specialties.js +19 -0
- package/lib/lib/userSdk/videoVisit.d.ts +72 -0
- package/lib/lib/userSdk/videoVisit.js +147 -0
- package/lib/lib/utils.d.ts +4 -0
- package/lib/lib/utils.js +19 -0
- package/lib/lib/webhook/index.d.ts +8 -0
- package/lib/lib/webhook/index.js +55 -0
- package/lib/lib/webhook/responses.d.ts +36 -0
- package/lib/lib/webhook/responses.js +42 -0
- package/lib/lib/webhook/token.d.ts +2 -0
- package/lib/lib/webhook/token.js +23 -0
- package/lib/schemas.d.ts +18 -0
- package/lib/schemas.js +1 -0
- package/lib/src/baseSdk/diagnostica.d.ts +54 -0
- package/lib/src/baseSdk/diagnostica.js +79 -0
- package/lib/src/baseSdk/index.d.ts +2 -0
- package/lib/src/baseSdk/index.js +66 -0
- package/lib/src/baseSdk/user.d.ts +41 -0
- package/lib/src/baseSdk/user.js +88 -0
- package/lib/src/index.d.ts +159 -0
- package/lib/src/index.js +22 -0
- package/lib/src/request/index.d.ts +3 -0
- package/lib/src/request/index.js +26 -0
- package/lib/src/request/token.d.ts +2 -0
- package/lib/src/request/token.js +34 -0
- package/lib/src/request/validation.d.ts +10 -0
- package/lib/src/request/validation.js +28 -0
- package/lib/src/schemas.d.ts +1115 -0
- package/lib/src/schemas.js +294 -0
- package/lib/src/types.d.ts +116 -0
- package/lib/src/types.js +2 -0
- package/lib/src/userSdk/chat.d.ts +57 -0
- package/lib/src/userSdk/chat.js +98 -0
- package/lib/src/userSdk/index.d.ts +2 -0
- package/lib/src/userSdk/index.js +27 -0
- package/lib/src/userSdk/patients.d.ts +12 -0
- package/lib/src/userSdk/patients.js +27 -0
- package/lib/src/userSdk/schedule.d.ts +44 -0
- package/lib/src/userSdk/schedule.js +76 -0
- package/lib/src/userSdk/specialties.d.ts +7 -0
- package/lib/src/userSdk/specialties.js +19 -0
- package/lib/src/userSdk/videoVisit.d.ts +111 -0
- package/lib/src/userSdk/videoVisit.js +147 -0
- package/lib/src/utils.d.ts +4 -0
- package/lib/src/utils.js +19 -0
- package/lib/src/webhook/index.d.ts +2 -0
- package/lib/src/webhook/index.js +55 -0
- package/lib/src/webhook/responses.d.ts +35 -0
- package/lib/src/webhook/responses.js +42 -0
- package/lib/src/webhook/token.d.ts +2 -0
- package/lib/src/webhook/token.js +23 -0
- package/lib/test.js +49 -8
- package/package.json +1 -1
package/lib/baseSdk/index.js
CHANGED
|
@@ -50,6 +50,7 @@ const getBaseSdk = async (url, credentials) => {
|
|
|
50
50
|
});
|
|
51
51
|
const mapped = {
|
|
52
52
|
specialties: response.data.specialties.map(mapSpeciality),
|
|
53
|
+
specialtiesER: response.data.specialties_er.map(mapSpeciality),
|
|
53
54
|
professionals: response.data.professionals.map((p) => ({
|
|
54
55
|
id: p.id_profesional,
|
|
55
56
|
fullName: p.denominacion,
|
package/lib/index.d.ts
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export var __esModule: boolean;
|
|
2
|
+
export function getDiagnosticaMethods(makeRequest: any): {
|
|
3
|
+
getDiagnosticaHistory: (...params: any) => Promise<any>;
|
|
4
|
+
getDiagnosticaDeepLink: (...params: any) => Promise<{
|
|
5
|
+
forwardingRequired: true;
|
|
6
|
+
deepLink: string;
|
|
7
|
+
} | {
|
|
8
|
+
forwardingRequired: false;
|
|
9
|
+
}>;
|
|
10
|
+
getDiagnosticaAccess: (...params: any) => Promise<void>;
|
|
11
|
+
};
|
|
@@ -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,15 @@
|
|
|
1
|
+
export var __esModule: boolean;
|
|
2
|
+
export function getExternalMethods(makeRequest: any): {
|
|
3
|
+
externalLogin: (...params: any) => Promise<{
|
|
4
|
+
firstName: any;
|
|
5
|
+
lastName: any;
|
|
6
|
+
countryId: any;
|
|
7
|
+
birthday: Date;
|
|
8
|
+
identificationNumber: any;
|
|
9
|
+
gender: string;
|
|
10
|
+
email: any;
|
|
11
|
+
phone: any;
|
|
12
|
+
}>;
|
|
13
|
+
preExternalEnroll: (...params: any) => Promise<void>;
|
|
14
|
+
externalEnroll: (...params: any) => Promise<void>;
|
|
15
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getExternalMethods = 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 getExternalMethods = (makeRequest) => {
|
|
9
|
+
const externalLogin = validation_1.validateFunction(zod_1.tuple([zod_1.string(), zod_1.string()]), schemas_1.doc24Schemas.externalLoginResponse, async (user, password) => {
|
|
10
|
+
const path = '/external-login';
|
|
11
|
+
const response = await makeRequest('POST', path, { user, password });
|
|
12
|
+
/* {
|
|
13
|
+
data: {
|
|
14
|
+
login_info: {
|
|
15
|
+
firstname: 'Nieves Iris',
|
|
16
|
+
lastname: 'Veiga',
|
|
17
|
+
birthdate: '1964-03-18T00:00:00',
|
|
18
|
+
identification_number: '16766094',
|
|
19
|
+
identification_type: 1,
|
|
20
|
+
country_id: 'AR',
|
|
21
|
+
gender: 'F',
|
|
22
|
+
address: 'Av. Pte Illia 13267',
|
|
23
|
+
city: 'Buenos Aires',
|
|
24
|
+
province: 'José C. Paz',
|
|
25
|
+
email: 'carlosiosella@gmail.com',
|
|
26
|
+
email_validated: true,
|
|
27
|
+
telephone: '3426310240',
|
|
28
|
+
cellphoneValidated: true,
|
|
29
|
+
external_id: null,
|
|
30
|
+
external_uid: 'srfoTzzYcE9',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
}; */
|
|
34
|
+
console.log(response);
|
|
35
|
+
const info = response.data.login_info;
|
|
36
|
+
return {
|
|
37
|
+
firstName: info.firstname,
|
|
38
|
+
lastName: info.lastname,
|
|
39
|
+
countryId: info.country_id,
|
|
40
|
+
birthday: new Date(Date.parse(info.birthdate)),
|
|
41
|
+
identificationNumber: info.identification_number,
|
|
42
|
+
gender: info.gender === 'F' ? 'f' : 'm',
|
|
43
|
+
email: info.email,
|
|
44
|
+
phone: info.telephone,
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
const preExternalEnroll = validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.preExternalEnrollmentParams]), zod_1.void(), async (params) => {
|
|
48
|
+
const path = '/pre-external-enrollment';
|
|
49
|
+
await makeRequest('POST', path, {
|
|
50
|
+
identification_number: params.identificationNumber,
|
|
51
|
+
birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
|
|
52
|
+
email: params.email,
|
|
53
|
+
telephone: params.phone,
|
|
54
|
+
});
|
|
55
|
+
return;
|
|
56
|
+
});
|
|
57
|
+
const externalEnroll = validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.externalEnrollmentParams]), zod_1.void(), async (params) => {
|
|
58
|
+
const path = '/external-enrollment';
|
|
59
|
+
const response = await makeRequest('POST', path, {
|
|
60
|
+
identification_number: params.identificationNumber,
|
|
61
|
+
birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
|
|
62
|
+
email: params.email,
|
|
63
|
+
telephone: params.phone,
|
|
64
|
+
email_code: params.emailCode,
|
|
65
|
+
telephone_code: params.phoneCode,
|
|
66
|
+
password: params.password,
|
|
67
|
+
});
|
|
68
|
+
console.log(response);
|
|
69
|
+
return;
|
|
70
|
+
});
|
|
71
|
+
return { externalLogin, preExternalEnroll, externalEnroll };
|
|
72
|
+
};
|
|
73
|
+
exports.getExternalMethods = getExternalMethods;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
export var __esModule: boolean;
|
|
2
|
+
export function getBaseSdk(url: any, credentials: any): Promise<{
|
|
3
|
+
getProfessional: (...params: any) => Promise<{
|
|
4
|
+
id: any;
|
|
5
|
+
firstName: any;
|
|
6
|
+
lastName: any;
|
|
7
|
+
birthdate: Date;
|
|
8
|
+
gender: any;
|
|
9
|
+
email: any;
|
|
10
|
+
phone: any;
|
|
11
|
+
logoUrl: any;
|
|
12
|
+
matriculation: any;
|
|
13
|
+
specialties: any;
|
|
14
|
+
degree: any;
|
|
15
|
+
languages: any;
|
|
16
|
+
resume: {
|
|
17
|
+
link: any;
|
|
18
|
+
brief: any;
|
|
19
|
+
};
|
|
20
|
+
}>;
|
|
21
|
+
getAvailableScheduleClinics: () => Promise<{
|
|
22
|
+
specialties: any;
|
|
23
|
+
specialtiesER: any;
|
|
24
|
+
professionals: any;
|
|
25
|
+
}>;
|
|
26
|
+
declareUser: (user: {
|
|
27
|
+
firstName: string;
|
|
28
|
+
lastName: string;
|
|
29
|
+
identificationType: "ndi" | "passport" | "credential";
|
|
30
|
+
identificationValue: string;
|
|
31
|
+
gender: "m" | "f";
|
|
32
|
+
phone: string;
|
|
33
|
+
email: string;
|
|
34
|
+
countryId: string;
|
|
35
|
+
birthdate: Date;
|
|
36
|
+
}) => Promise<any>;
|
|
37
|
+
getUserInstance: (...params: any) => Promise<any>;
|
|
38
|
+
enroll: (...params: any) => Promise<void>;
|
|
39
|
+
getConverageInfo: (identificationValue: string) => Promise<{
|
|
40
|
+
firstName: string | null;
|
|
41
|
+
lastName: string | null;
|
|
42
|
+
gender: "m" | "f";
|
|
43
|
+
email: string | null;
|
|
44
|
+
birthdate: Date;
|
|
45
|
+
identificationNumber: string;
|
|
46
|
+
plan: string | null;
|
|
47
|
+
financerId: number | null;
|
|
48
|
+
defaultAffiliationId: number | null;
|
|
49
|
+
credentialNumber: string | null;
|
|
50
|
+
financerPlanId: number | null;
|
|
51
|
+
brand: number | null;
|
|
52
|
+
holderIdentificationNumber: string | null;
|
|
53
|
+
copaymentValue: number | null;
|
|
54
|
+
mobilePhone: string | null;
|
|
55
|
+
company: string | null;
|
|
56
|
+
dischargeDate: Date | null;
|
|
57
|
+
leavingDate: Date | null;
|
|
58
|
+
identificacion_tributaria: string | null;
|
|
59
|
+
deregistrationDate: Date | null;
|
|
60
|
+
authorizationCode: string | null;
|
|
61
|
+
authorizationCodeExpiration: Date | null;
|
|
62
|
+
} | null>;
|
|
63
|
+
getDiagnosticaHistory: (patient: {
|
|
64
|
+
identificationType: "ndi" | "passport" | "credential";
|
|
65
|
+
identificationValue: string;
|
|
66
|
+
gender: "m" | "f";
|
|
67
|
+
}, from: Date, to: Date) => Promise<{
|
|
68
|
+
date: Date;
|
|
69
|
+
location: string;
|
|
70
|
+
exams: string[];
|
|
71
|
+
deepLink: string;
|
|
72
|
+
}[]>;
|
|
73
|
+
getDiagnosticaDeepLink: (kiosk: string, user: {
|
|
74
|
+
language: string;
|
|
75
|
+
firstName: string;
|
|
76
|
+
lastName: string;
|
|
77
|
+
birthday: Date;
|
|
78
|
+
identificationType: "dni";
|
|
79
|
+
identificationValue: string;
|
|
80
|
+
gender: "m" | "f";
|
|
81
|
+
phone: string;
|
|
82
|
+
email: string;
|
|
83
|
+
}, patient: {
|
|
84
|
+
firstName: string;
|
|
85
|
+
lastName: string;
|
|
86
|
+
birthday: Date;
|
|
87
|
+
identificationType: "dni";
|
|
88
|
+
identificationValue: string;
|
|
89
|
+
gender: "m" | "f";
|
|
90
|
+
}) => Promise<{
|
|
91
|
+
forwardingRequired: true;
|
|
92
|
+
deepLink: string;
|
|
93
|
+
} | {
|
|
94
|
+
forwardingRequired: false;
|
|
95
|
+
}>;
|
|
96
|
+
getDiagnosticaAccess: (kiosk: string, user: {
|
|
97
|
+
language: string;
|
|
98
|
+
firstName: string;
|
|
99
|
+
lastName: string;
|
|
100
|
+
birthday: Date;
|
|
101
|
+
identificationType: "dni";
|
|
102
|
+
identificationValue: string;
|
|
103
|
+
gender: "m" | "f";
|
|
104
|
+
phone: string;
|
|
105
|
+
email: string;
|
|
106
|
+
}, patient: {
|
|
107
|
+
firstName: string;
|
|
108
|
+
lastName: string;
|
|
109
|
+
birthday: Date;
|
|
110
|
+
identificationType: "dni";
|
|
111
|
+
identificationValue: string;
|
|
112
|
+
gender: "m" | "f";
|
|
113
|
+
}) => Promise<void>;
|
|
114
|
+
}>;
|
|
@@ -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,30 @@
|
|
|
1
|
+
export var __esModule: boolean;
|
|
2
|
+
export function getUserMethods(makeRequest: any, url: any, credentials: any): {
|
|
3
|
+
declareUser: (user?: any) => Promise<any>;
|
|
4
|
+
getUserInstance: (...params: any) => Promise<any>;
|
|
5
|
+
enroll: (...params: any) => Promise<void>;
|
|
6
|
+
getConverageInfo: (...params: any) => Promise<{
|
|
7
|
+
firstName: string | null;
|
|
8
|
+
lastName: string | null;
|
|
9
|
+
gender: "m" | "f";
|
|
10
|
+
email: string | null;
|
|
11
|
+
birthdate: Date;
|
|
12
|
+
identificationNumber: string;
|
|
13
|
+
plan: string | null;
|
|
14
|
+
financerId: number | null;
|
|
15
|
+
defaultAffiliationId: number | null;
|
|
16
|
+
credentialNumber: string | null;
|
|
17
|
+
financerPlanId: number | null;
|
|
18
|
+
brand: number | null;
|
|
19
|
+
holderIdentificationNumber: string | null;
|
|
20
|
+
copaymentValue: number | null;
|
|
21
|
+
mobilePhone: string | null;
|
|
22
|
+
company: string | null;
|
|
23
|
+
dischargeDate: Date | null;
|
|
24
|
+
leavingDate: Date | null;
|
|
25
|
+
identificacion_tributaria: string | null;
|
|
26
|
+
deregistrationDate: Date | null;
|
|
27
|
+
authorizationCode: string | null;
|
|
28
|
+
authorizationCodeExpiration: Date | null;
|
|
29
|
+
} | null>;
|
|
30
|
+
};
|
|
@@ -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;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
export var __esModule: boolean;
|
|
2
|
+
export function doc24Sdk(params: any): Promise<{
|
|
3
|
+
getRequestHandler: (params: any) => Promise<import("./types").Doc24.Webhook.Handler>;
|
|
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<number>;
|
|
15
|
+
getUserInstance: (user: number | {
|
|
16
|
+
firstName: string;
|
|
17
|
+
lastName: string;
|
|
18
|
+
identificationType: "ndi" | "passport" | "credential";
|
|
19
|
+
identificationValue: string;
|
|
20
|
+
gender: "m" | "f";
|
|
21
|
+
phone: string;
|
|
22
|
+
email: string;
|
|
23
|
+
countryId: string;
|
|
24
|
+
birthdate: Date;
|
|
25
|
+
}) => Promise<import("./types").Doc24.UserSdk>;
|
|
26
|
+
getProfessional: (professionalId: number) => Promise<{
|
|
27
|
+
id: number;
|
|
28
|
+
logoUrl: string;
|
|
29
|
+
firstName: string;
|
|
30
|
+
lastName: string;
|
|
31
|
+
gender: "m" | "f";
|
|
32
|
+
phone: string | null;
|
|
33
|
+
email: string;
|
|
34
|
+
birthdate: Date;
|
|
35
|
+
specialties: {
|
|
36
|
+
id: number;
|
|
37
|
+
description: string;
|
|
38
|
+
}[];
|
|
39
|
+
matriculation: {
|
|
40
|
+
number: string;
|
|
41
|
+
type: string;
|
|
42
|
+
}[];
|
|
43
|
+
degree: string;
|
|
44
|
+
languages: string[];
|
|
45
|
+
resume: {
|
|
46
|
+
link: string;
|
|
47
|
+
brief: string;
|
|
48
|
+
};
|
|
49
|
+
}>;
|
|
50
|
+
getAvailableScheduleClinics: () => Promise<{
|
|
51
|
+
specialties: {
|
|
52
|
+
id: number;
|
|
53
|
+
description: string;
|
|
54
|
+
}[];
|
|
55
|
+
specialtiesER: {
|
|
56
|
+
id: number;
|
|
57
|
+
description: string;
|
|
58
|
+
}[];
|
|
59
|
+
professionals: {
|
|
60
|
+
id: number;
|
|
61
|
+
fullName: string;
|
|
62
|
+
clinicId: number;
|
|
63
|
+
specialties: {
|
|
64
|
+
id: number;
|
|
65
|
+
description: string;
|
|
66
|
+
}[];
|
|
67
|
+
}[];
|
|
68
|
+
}>;
|
|
69
|
+
enroll: (params: {
|
|
70
|
+
firstName: string;
|
|
71
|
+
lastName: string;
|
|
72
|
+
gender: "m" | "f";
|
|
73
|
+
email: string;
|
|
74
|
+
birthdate: Date;
|
|
75
|
+
startDate: Date;
|
|
76
|
+
identificationNumber: string;
|
|
77
|
+
plan: string;
|
|
78
|
+
}) => Promise<void>;
|
|
79
|
+
getConverageInfo: (identificationValue: string) => Promise<{
|
|
80
|
+
firstName: string | null;
|
|
81
|
+
lastName: string | null;
|
|
82
|
+
gender: "m" | "f";
|
|
83
|
+
email: string | null;
|
|
84
|
+
birthdate: Date;
|
|
85
|
+
identificationNumber: string;
|
|
86
|
+
plan: string | null;
|
|
87
|
+
financerId: number | null;
|
|
88
|
+
defaultAffiliationId: number | null;
|
|
89
|
+
credentialNumber: string | null;
|
|
90
|
+
financerPlanId: number | null;
|
|
91
|
+
brand: number | null;
|
|
92
|
+
holderIdentificationNumber: string | null;
|
|
93
|
+
copaymentValue: number | null;
|
|
94
|
+
mobilePhone: string | null;
|
|
95
|
+
company: string | null;
|
|
96
|
+
dischargeDate: Date | null;
|
|
97
|
+
leavingDate: Date | null;
|
|
98
|
+
identificacion_tributaria: string | null;
|
|
99
|
+
deregistrationDate: Date | null;
|
|
100
|
+
authorizationCode: string | null;
|
|
101
|
+
authorizationCodeExpiration: Date | null;
|
|
102
|
+
} | null>;
|
|
103
|
+
getDiagnosticaHistory: (patient: {
|
|
104
|
+
identificationType: "ndi" | "passport" | "credential";
|
|
105
|
+
identificationValue: string;
|
|
106
|
+
gender: "m" | "f";
|
|
107
|
+
}, from: Date, to: Date) => Promise<{
|
|
108
|
+
date: Date;
|
|
109
|
+
location: string;
|
|
110
|
+
exams: string[];
|
|
111
|
+
deepLink: string;
|
|
112
|
+
}[]>;
|
|
113
|
+
getDiagnosticaDeepLink: (kiosk: string, user: {
|
|
114
|
+
language: string;
|
|
115
|
+
firstName: string;
|
|
116
|
+
lastName: string;
|
|
117
|
+
birthday: Date;
|
|
118
|
+
identificationType: "dni";
|
|
119
|
+
identificationValue: string;
|
|
120
|
+
gender: "m" | "f";
|
|
121
|
+
phone: string;
|
|
122
|
+
email: string;
|
|
123
|
+
}, patient: {
|
|
124
|
+
firstName: string;
|
|
125
|
+
lastName: string;
|
|
126
|
+
birthday: Date;
|
|
127
|
+
identificationType: "dni";
|
|
128
|
+
identificationValue: string;
|
|
129
|
+
gender: "m" | "f";
|
|
130
|
+
}) => Promise<{
|
|
131
|
+
forwardingRequired: true;
|
|
132
|
+
deepLink: string;
|
|
133
|
+
} | {
|
|
134
|
+
forwardingRequired: false;
|
|
135
|
+
}>;
|
|
136
|
+
getDiagnosticaAccess: (kiosk: string, user: {
|
|
137
|
+
language: string;
|
|
138
|
+
firstName: string;
|
|
139
|
+
lastName: string;
|
|
140
|
+
birthday: Date;
|
|
141
|
+
identificationType: "dni";
|
|
142
|
+
identificationValue: string;
|
|
143
|
+
gender: "m" | "f";
|
|
144
|
+
phone: string;
|
|
145
|
+
email: string;
|
|
146
|
+
}, patient: {
|
|
147
|
+
firstName: string;
|
|
148
|
+
lastName: string;
|
|
149
|
+
birthday: Date;
|
|
150
|
+
identificationType: "dni";
|
|
151
|
+
identificationValue: string;
|
|
152
|
+
gender: "m" | "f";
|
|
153
|
+
}) => Promise<void>;
|
|
154
|
+
}>;
|
package/lib/lib/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.doc24Sdk = void 0;
|
|
4
|
+
const webhook_1 = require("./webhook");
|
|
5
|
+
const baseSdk_1 = require("./baseSdk");
|
|
6
|
+
const request_1 = require("./request");
|
|
7
|
+
const doc24Sdk = async (params) => {
|
|
8
|
+
const baseSdk = await baseSdk_1.getBaseSdk(params.url, params.credentials);
|
|
9
|
+
const makeRequest = await request_1.getRequestFactory(params.url, params.credentials);
|
|
10
|
+
return {
|
|
11
|
+
...baseSdk,
|
|
12
|
+
getRequestHandler: async (params) => {
|
|
13
|
+
await makeRequest('PUT', '/webhook', {
|
|
14
|
+
url: params.baseAddress,
|
|
15
|
+
issuer: params.credentials.iss,
|
|
16
|
+
secret: params.credentials.key,
|
|
17
|
+
});
|
|
18
|
+
return webhook_1.getRequestHandler(params.credentials, baseSdk, params.eventHandlers);
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
exports.doc24Sdk = doc24Sdk;
|