@integraciones_doc24/sdk 0.39.5 → 0.39.6
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/consultation.d.ts +99 -0
- package/lib/baseSdk/consultation.js +23 -0
- package/lib/baseSdk/diagnostica.d.ts +54 -0
- package/lib/baseSdk/diagnostica.js +79 -0
- package/lib/baseSdk/index.d.ts +2 -0
- package/lib/baseSdk/index.js +73 -0
- package/lib/baseSdk/user.d.ts +41 -0
- package/lib/baseSdk/user.js +88 -0
- package/lib/index.d.ts +255 -0
- package/lib/index.js +22 -0
- package/lib/request/index.d.ts +3 -0
- package/lib/request/index.js +26 -0
- package/lib/request/token.d.ts +2 -0
- package/lib/request/token.js +34 -0
- package/lib/request/validation.d.ts +10 -0
- package/lib/request/validation.js +28 -0
- package/lib/schemas.d.ts +1451 -0
- package/lib/schemas.js +404 -0
- package/lib/types.d.ts +120 -0
- package/lib/types.js +2 -0
- package/lib/userSdk/chat.d.ts +57 -0
- package/lib/userSdk/chat.js +98 -0
- package/lib/userSdk/index.d.ts +2 -0
- package/lib/userSdk/index.js +27 -0
- package/lib/userSdk/patients.d.ts +24 -0
- package/lib/userSdk/patients.js +46 -0
- package/lib/userSdk/schedule.d.ts +44 -0
- package/lib/userSdk/schedule.js +76 -0
- package/lib/userSdk/specialties.d.ts +7 -0
- package/lib/userSdk/specialties.js +19 -0
- package/lib/userSdk/videoVisit.d.ts +111 -0
- package/lib/userSdk/videoVisit.js +147 -0
- package/lib/utils.d.ts +4 -0
- package/lib/utils.js +27 -0
- package/lib/webhook/index.d.ts +2 -0
- package/lib/webhook/index.js +55 -0
- package/lib/webhook/responses.d.ts +35 -0
- package/lib/webhook/responses.js +42 -0
- package/lib/webhook/token.d.ts +2 -0
- package/lib/webhook/token.js +23 -0
- package/package.json +1 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Doc24 } from '../types';
|
|
2
|
+
export declare const getConsultationMethods: (url: string, credentials: Doc24.SdkCredentials) => {
|
|
3
|
+
getConsultation: (consultationId: number) => Promise<{
|
|
4
|
+
pdf_laboratorios?: any;
|
|
5
|
+
pdf_otras?: any;
|
|
6
|
+
pdf_imagenes?: any;
|
|
7
|
+
snapshot_paciente?: any;
|
|
8
|
+
snapshot_profesional?: any;
|
|
9
|
+
custom_1?: any;
|
|
10
|
+
custom_2?: any;
|
|
11
|
+
custom_3?: any;
|
|
12
|
+
custom_4?: any;
|
|
13
|
+
custom_5?: any;
|
|
14
|
+
tag_idioma: string;
|
|
15
|
+
id_consulta: number;
|
|
16
|
+
tipo_consulta: string;
|
|
17
|
+
estado: string;
|
|
18
|
+
tipo_usuario_cancelacion: string | null;
|
|
19
|
+
fecha_cancelacion: string | null;
|
|
20
|
+
estado_pago: string;
|
|
21
|
+
referencia_mercadopago: string | null;
|
|
22
|
+
id_atencion: number;
|
|
23
|
+
id_profesional: number;
|
|
24
|
+
profesional: string;
|
|
25
|
+
modalidad_paciente_turno: string | null;
|
|
26
|
+
provincia_consultorio: string | null;
|
|
27
|
+
localidad_consultorio: string | null;
|
|
28
|
+
domicilio_consultorio: string | null;
|
|
29
|
+
marketplace: string;
|
|
30
|
+
profesional_matriculas: any[];
|
|
31
|
+
info_paciente: {
|
|
32
|
+
email?: string | null | undefined;
|
|
33
|
+
apellido?: string | null | undefined;
|
|
34
|
+
nombre?: string | null | undefined;
|
|
35
|
+
genero?: string | null | undefined;
|
|
36
|
+
valor_identificacion?: string | null | undefined;
|
|
37
|
+
telefono?: string | null | undefined;
|
|
38
|
+
id_pais?: string | null | undefined;
|
|
39
|
+
provincia?: string | null | undefined;
|
|
40
|
+
localidad?: string | null | undefined;
|
|
41
|
+
domicilio?: string | null | undefined;
|
|
42
|
+
fecha_de_nacimiento?: string | null | undefined;
|
|
43
|
+
tag_idioma?: number | null | undefined;
|
|
44
|
+
estado_paciente?: number | null | undefined;
|
|
45
|
+
fecha_suspension?: string | null | undefined;
|
|
46
|
+
fecha_activacion?: string | null | undefined;
|
|
47
|
+
fecha_modificacion?: string | null | undefined;
|
|
48
|
+
fecha_baja?: string | null | undefined;
|
|
49
|
+
id_paciente: number;
|
|
50
|
+
id_tipo_de_identificacion: number;
|
|
51
|
+
};
|
|
52
|
+
fecha_primer_llamado_profesional: string;
|
|
53
|
+
fecha_inicio: string;
|
|
54
|
+
fecha_primer_acceso_paciente: string;
|
|
55
|
+
fecha_ultimo_acceso_paciente: string;
|
|
56
|
+
fecha_corte_medico: string;
|
|
57
|
+
fecha_fin: string;
|
|
58
|
+
intentos_conexion: number;
|
|
59
|
+
id_turno: number | null;
|
|
60
|
+
fecha_turno_invitacion: string | null;
|
|
61
|
+
hora_turno_invitacion: string | null;
|
|
62
|
+
firma_profesional: string | null;
|
|
63
|
+
id_especialidad: number;
|
|
64
|
+
especialidad: string;
|
|
65
|
+
motivo: string;
|
|
66
|
+
enfermedad_actual: string;
|
|
67
|
+
conducta_terapeutica: string;
|
|
68
|
+
signos_alerta: string;
|
|
69
|
+
motivo_extendido_consulta: string;
|
|
70
|
+
presencial_requerida: string;
|
|
71
|
+
derivada: string;
|
|
72
|
+
derivada_id_especialidad: string;
|
|
73
|
+
derivada_presencial_obligatoria: string;
|
|
74
|
+
derivada_comentarios: string | null;
|
|
75
|
+
diagnostico: any[];
|
|
76
|
+
practicas: any[];
|
|
77
|
+
link_medicacion: any[];
|
|
78
|
+
medicacion: any[];
|
|
79
|
+
link_receta: string | null;
|
|
80
|
+
link_compra: string | null;
|
|
81
|
+
identificador_receta: string | null;
|
|
82
|
+
codigo_verificacion_receta: string | null;
|
|
83
|
+
financiador: string;
|
|
84
|
+
registro_custom: any[];
|
|
85
|
+
pdf_medicacion: any[];
|
|
86
|
+
uploads: any[];
|
|
87
|
+
files_atencion: any[];
|
|
88
|
+
motivo_cancelacion: string | null;
|
|
89
|
+
detalle_cancelacion: string | null;
|
|
90
|
+
documentos: string;
|
|
91
|
+
id_consultorio: number;
|
|
92
|
+
token: string;
|
|
93
|
+
tipo_protocolo_seguimiento: string | null;
|
|
94
|
+
form_data: {};
|
|
95
|
+
ubicacion: string;
|
|
96
|
+
link_full: string;
|
|
97
|
+
timestamp: string;
|
|
98
|
+
} | null>;
|
|
99
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getConsultationMethods = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const schemas_1 = require("../schemas");
|
|
6
|
+
const request_1 = require("../request");
|
|
7
|
+
const validation_1 = require("../request/validation");
|
|
8
|
+
const getConsultationMethods = (url, credentials) => {
|
|
9
|
+
const getConsultation = validation_1.validateFunction(zod_1.tuple([zod_1.number()]), schemas_1.doc24Schemas.consultation, async (consultationId) => {
|
|
10
|
+
// Replace /sdk with /api/v2 in the base URL
|
|
11
|
+
const apiUrl = url.replace('/sdk', '/api/v2');
|
|
12
|
+
const apiRequest = await request_1.getRequestFactory(apiUrl, credentials);
|
|
13
|
+
const path = `/consulta/${consultationId}`;
|
|
14
|
+
const response = await apiRequest('GET', path);
|
|
15
|
+
// Remove pdf_atencion and pdf_certificado from the response
|
|
16
|
+
const { pdf_atencion, pdf_certificado, ...attention } = response === null || response === void 0 ? void 0 : response.data;
|
|
17
|
+
return attention;
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
getConsultation,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
exports.getConsultationMethods = getConsultationMethods;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { RequestMaker } from '../request';
|
|
2
|
+
export declare const getDiagnosticaMethods: (makeRequest: RequestMaker) => {
|
|
3
|
+
getDiagnosticaHistory: (patient: {
|
|
4
|
+
identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
|
|
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,73 @@
|
|
|
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 consultation_1 = require("./consultation");
|
|
12
|
+
const getBaseSdk = async (url, credentials) => {
|
|
13
|
+
const makeRequest = await request_1.getRequestFactory(url, credentials);
|
|
14
|
+
const diagnosticaMethods = diagnostica_1.getDiagnosticaMethods(makeRequest);
|
|
15
|
+
const userMethods = user_1.getUserMethods(makeRequest, url, credentials);
|
|
16
|
+
const consultationMethods = consultation_1.getConsultationMethods(url, credentials);
|
|
17
|
+
const baseSdk = {
|
|
18
|
+
...diagnosticaMethods,
|
|
19
|
+
...userMethods,
|
|
20
|
+
...consultationMethods,
|
|
21
|
+
getProfessional: validation_1.validateFunction(zod_1.tuple([zod_1.number()]), schemas_1.doc24Schemas.professional, async (professionalId) => {
|
|
22
|
+
const path = `/professional/${professionalId}`;
|
|
23
|
+
const response = await makeRequest('GET', path);
|
|
24
|
+
const raw = response.data;
|
|
25
|
+
return {
|
|
26
|
+
id: raw.professional_id,
|
|
27
|
+
firstName: raw.name,
|
|
28
|
+
lastName: raw.lastname,
|
|
29
|
+
birthdate: utils_1.parseDate(raw.birthdate),
|
|
30
|
+
gender: raw.gender.toLowerCase(),
|
|
31
|
+
email: raw.email,
|
|
32
|
+
phone: raw.phone,
|
|
33
|
+
logoUrl: raw.image,
|
|
34
|
+
matriculation: raw.matriculation,
|
|
35
|
+
specialties: raw.specialties.map((s) => ({
|
|
36
|
+
id: s.specialty_id,
|
|
37
|
+
description: s.specialty,
|
|
38
|
+
})),
|
|
39
|
+
degree: raw.degree,
|
|
40
|
+
languages: raw.languages.map((l) => l.languages),
|
|
41
|
+
resume: {
|
|
42
|
+
link: raw.resume_link,
|
|
43
|
+
brief: raw.resume_brief,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}),
|
|
47
|
+
getAvailableScheduleClinics: validation_1.validateFunction(zod_1.tuple([]), schemas_1.doc24Schemas.availableScheduleClinics, async () => {
|
|
48
|
+
const path = `/schedule/clinics`;
|
|
49
|
+
const response = await makeRequest('GET', path);
|
|
50
|
+
const mapSpeciality = (s) => ({
|
|
51
|
+
id: s.id_especialidad,
|
|
52
|
+
description: s.especialidad,
|
|
53
|
+
});
|
|
54
|
+
const mapSpecialityER = (s) => ({
|
|
55
|
+
id: s.specialty_id,
|
|
56
|
+
description: s.specialty,
|
|
57
|
+
});
|
|
58
|
+
const mapped = {
|
|
59
|
+
specialties: response.data.specialties.map(mapSpeciality),
|
|
60
|
+
specialtiesER: response.data.specialties_er.map(mapSpecialityER),
|
|
61
|
+
professionals: response.data.professionals.map((p) => ({
|
|
62
|
+
id: p.id_profesional,
|
|
63
|
+
fullName: p.denominacion,
|
|
64
|
+
clinicId: p.id_consultorio,
|
|
65
|
+
specialties: p.especialidades.map(mapSpeciality),
|
|
66
|
+
})),
|
|
67
|
+
};
|
|
68
|
+
return mapped;
|
|
69
|
+
}),
|
|
70
|
+
};
|
|
71
|
+
return baseSdk;
|
|
72
|
+
};
|
|
73
|
+
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: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
|
|
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;
|