@integraciones_doc24/sdk 0.39.7 → 0.39.8

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.
@@ -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;
@@ -1,9 +1,9 @@
1
1
  import { RequestMaker } from '../request';
2
2
  export declare const getDiagnosticaMethods: (makeRequest: RequestMaker) => {
3
3
  getDiagnosticaHistory: (patient: {
4
- gender?: "m" | "f" | "o" | undefined;
5
- identificationType: "DNI";
4
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
6
5
  identificationValue: string;
6
+ gender: "m" | "f";
7
7
  }, from: Date, to: Date) => Promise<{
8
8
  date: Date;
9
9
  location: string;
@@ -11,22 +11,22 @@ export declare const getDiagnosticaMethods: (makeRequest: RequestMaker) => {
11
11
  deepLink: string;
12
12
  }[]>;
13
13
  getDiagnosticaDeepLink: (kiosk: string, user: {
14
- gender?: "m" | "f" | "o" | undefined;
14
+ language: string;
15
15
  firstName: string;
16
16
  lastName: string;
17
- identificationType: "DNI";
17
+ birthday: Date;
18
+ identificationType: "dni";
18
19
  identificationValue: string;
20
+ gender: "m" | "f";
19
21
  phone: string;
20
22
  email: string;
21
- language: string;
22
- birthday: Date;
23
23
  }, patient: {
24
- gender?: "m" | "f" | "o" | undefined;
25
24
  firstName: string;
26
25
  lastName: string;
27
- identificationType: "DNI";
28
- identificationValue: string;
29
26
  birthday: Date;
27
+ identificationType: "dni";
28
+ identificationValue: string;
29
+ gender: "m" | "f";
30
30
  }) => Promise<{
31
31
  forwardingRequired: true;
32
32
  deepLink: string;
@@ -34,21 +34,21 @@ export declare const getDiagnosticaMethods: (makeRequest: RequestMaker) => {
34
34
  forwardingRequired: false;
35
35
  }>;
36
36
  getDiagnosticaAccess: (kiosk: string, user: {
37
- gender?: "m" | "f" | "o" | undefined;
37
+ language: string;
38
38
  firstName: string;
39
39
  lastName: string;
40
- identificationType: "DNI";
40
+ birthday: Date;
41
+ identificationType: "dni";
41
42
  identificationValue: string;
43
+ gender: "m" | "f";
42
44
  phone: string;
43
45
  email: string;
44
- language: string;
45
- birthday: Date;
46
46
  }, patient: {
47
- gender?: "m" | "f" | "o" | undefined;
48
47
  firstName: string;
49
48
  lastName: string;
50
- identificationType: "DNI";
51
- identificationValue: string;
52
49
  birthday: Date;
50
+ identificationType: "dni";
51
+ identificationValue: string;
52
+ gender: "m" | "f";
53
53
  }) => Promise<void>;
54
54
  };
@@ -6,12 +6,14 @@ const zod_1 = require("zod");
6
6
  const validation_1 = require("../request/validation");
7
7
  const schemas_1 = require("../schemas");
8
8
  const getDiagnosticaMethods = (makeRequest) => {
9
- const getDiagnosticaHistory = async (patient, from, to) => {
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
10
  const path = '/history-diagnostica';
11
11
  const response = await makeRequest('POST', path, {
12
12
  patient: {
13
13
  gender: patient.gender,
14
- id_type: patient.identificationType,
14
+ id_type: patient.identificationType === 'ndi'
15
+ ? 'DNI'
16
+ : patient.identificationType,
15
17
  id_value: patient.identificationValue,
16
18
  },
17
19
  dateFrom: from.toISOString(),
@@ -24,8 +26,12 @@ const getDiagnosticaMethods = (makeRequest) => {
24
26
  exams: i.exams,
25
27
  deepLink: i.deeplink,
26
28
  }));
27
- };
28
- const getDiagnosticaDeepLink = async (kiosk, user, patient) => {
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) => {
29
35
  const path = '/deeplink-diagnostica';
30
36
  const response = await makeRequest('POST', path, {
31
37
  kiosk,
@@ -36,8 +42,12 @@ const getDiagnosticaMethods = (makeRequest) => {
36
42
  if (data.forwarding_required)
37
43
  return { forwardingRequired: true, deepLink: data.deeplink };
38
44
  return { forwardingRequired: false };
39
- };
40
- const getDiagnosticaAccess = async (kiosk, user, patient) => {
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) => {
41
51
  const path = '/access-diagnostica';
42
52
  await makeRequest('POST', path, {
43
53
  kiosk,
@@ -45,31 +55,18 @@ const getDiagnosticaMethods = (makeRequest) => {
45
55
  patient: mapPatientData(patient),
46
56
  });
47
57
  return;
48
- };
49
- return {
50
- getDiagnosticaHistory: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.diagnosticaPatientFilter, zod_1.date(), zod_1.date()]), schemas_1.doc24Schemas.diagnosticaHistoryAppointment.array(), getDiagnosticaHistory),
51
- getDiagnosticaDeepLink: validation_1.validateFunction(zod_1.tuple([
52
- zod_1.string(),
53
- schemas_1.doc24Schemas.diagnosticaUser,
54
- schemas_1.doc24Schemas.diagnosticaPatient,
55
- ]), schemas_1.doc24Schemas.diagnosticaDeepLinkResponse, getDiagnosticaDeepLink),
56
- getDiagnosticaAccess: validation_1.validateFunction(zod_1.tuple([
57
- zod_1.string(),
58
- schemas_1.doc24Schemas.diagnosticaUser,
59
- schemas_1.doc24Schemas.diagnosticaPatient,
60
- ]), zod_1.void(), getDiagnosticaAccess),
61
- };
58
+ });
59
+ return { getDiagnosticaHistory, getDiagnosticaDeepLink, getDiagnosticaAccess };
62
60
  };
63
61
  exports.getDiagnosticaMethods = getDiagnosticaMethods;
64
62
  const mapPatientData = (patient) => {
65
- var _a;
66
63
  return {
67
64
  name: patient.firstName,
68
65
  surname: patient.lastName,
69
66
  birthday: date_fns_1.format(patient.birthday, 'yyyy-MM-dd'),
70
67
  id_type: 'DNI',
71
68
  id_value: patient.identificationValue,
72
- gender: (_a = patient.gender) === null || _a === void 0 ? void 0 : _a.toLocaleUpperCase(),
69
+ gender: patient.gender.toLocaleUpperCase(),
73
70
  };
74
71
  };
75
72
  const mapUserData = (user) => {
@@ -8,16 +8,16 @@ const schemas_1 = require("../schemas");
8
8
  const utils_1 = require("../utils");
9
9
  const diagnostica_1 = require("./diagnostica");
10
10
  const user_1 = require("./user");
11
- const external_1 = require("./external");
11
+ const consultation_1 = require("./consultation");
12
12
  const getBaseSdk = async (url, credentials) => {
13
13
  const makeRequest = await request_1.getRequestFactory(url, credentials);
14
14
  const diagnosticaMethods = diagnostica_1.getDiagnosticaMethods(makeRequest);
15
- const externalMethods = external_1.getExternalMethods(makeRequest);
16
15
  const userMethods = user_1.getUserMethods(makeRequest, url, credentials);
16
+ const consultationMethods = consultation_1.getConsultationMethods(url, credentials);
17
17
  const baseSdk = {
18
18
  ...diagnosticaMethods,
19
- ...externalMethods,
20
19
  ...userMethods,
20
+ ...consultationMethods,
21
21
  getProfessional: validation_1.validateFunction(zod_1.tuple([zod_1.number()]), schemas_1.doc24Schemas.professional, async (professionalId) => {
22
22
  const path = `/professional/${professionalId}`;
23
23
  const response = await makeRequest('GET', path);
@@ -42,7 +42,6 @@ const getBaseSdk = async (url, credentials) => {
42
42
  link: raw.resume_link,
43
43
  brief: raw.resume_brief,
44
44
  },
45
- consultation_value: raw.consultation_value
46
45
  };
47
46
  }),
48
47
  getAvailableScheduleClinics: validation_1.validateFunction(zod_1.tuple([]), schemas_1.doc24Schemas.availableScheduleClinics, async () => {
@@ -1,75 +1,25 @@
1
1
  import { RequestMaker } from '../request';
2
2
  import { Doc24 } from '../types';
3
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
- phone?: string | undefined;
10
- firstName: string;
11
- lastName: string;
12
- countryId: string;
13
- birthdate: Date;
14
- email: string;
15
- };
16
- } & {
17
- code?: string | undefined;
18
- channel?: "1" | "2" | undefined;
19
- }) => Promise<{
20
- askCode: true;
21
- userInfo: {
22
- phone: string;
23
- email: string;
24
- };
25
- } | {
26
- patientId: number | null;
27
- askCode: false;
28
- userId: number;
29
- }>;
30
- getUserId: (user: {
31
- identificationType?: number | undefined;
32
- identificationValue?: string | undefined;
33
- gender?: "m" | "f" | "o" | undefined;
34
- phone?: string | undefined;
4
+ declareUser: (user: {
35
5
  firstName: string;
36
6
  lastName: string;
37
- countryId: string;
38
- birthdate: Date;
39
- email: string;
40
- }) => Promise<number>;
41
- sendVerificationCode: (params: {
42
- identificationType: number;
7
+ identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
43
8
  identificationValue: string;
44
- channel: "1" | "2";
45
- }) => Promise<void>;
46
- getUserInstance: (user: number | {
47
- identificationType?: number | undefined;
48
- identificationValue?: string | undefined;
49
- gender?: "m" | "f" | "o" | undefined;
50
- phone?: string | undefined;
51
- firstName: string;
52
- lastName: string;
9
+ gender: "m" | "f";
10
+ phone: string;
11
+ email: string;
53
12
  countryId: string;
54
13
  birthdate: Date;
55
- email: string;
56
14
  }) => Promise<any>;
57
- enroll: (params: {
58
- gender?: "m" | "f" | "o" | undefined;
59
- firstName: string;
60
- lastName: string;
61
- birthdate: Date;
62
- email: string;
63
- identificationNumber: string;
64
- startDate: Date;
65
- plan: string;
66
- }) => Promise<void>;
67
- getCoverageInfo: (identificationValue: string) => Promise<{
68
- gender?: "m" | "f" | "o" | undefined;
15
+ getUserInstance: (...params: any) => Promise<any>;
16
+ enroll: (...params: any) => Promise<void>;
17
+ getConverageInfo: (identificationValue: string) => Promise<{
69
18
  firstName: string | null;
70
19
  lastName: string | null;
71
- birthdate: Date;
20
+ gender: "m" | "f";
72
21
  email: string | null;
22
+ birthdate: Date;
73
23
  identificationNumber: string;
74
24
  plan: string | null;
75
25
  financerId: number | null;
@@ -8,90 +8,27 @@ const schemas_1 = require("../schemas");
8
8
  const userSdk_1 = require("../userSdk");
9
9
  const utils_1 = require("../utils");
10
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
11
  const getUserId = async (user) => {
41
- var _a;
42
- const path = '/search-user';
43
12
  const mappedUser = {
44
13
  lastname: user.lastName,
45
14
  firstname: user.firstName,
46
- identification_type: user.identificationType,
15
+ identification_type: utils_1.getIndetificationTypeId(user.identificationType),
47
16
  identification_value: user.identificationValue,
48
17
  birthdate: date_fns_1.format(user.birthdate, 'yyyy-MM-dd'),
49
- gender: (_a = user.gender) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
18
+ gender: user.gender.toUpperCase(),
50
19
  phone: user.phone,
51
20
  email: user.email,
52
21
  country_id: user.countryId,
53
22
  };
54
- const response = await makeRequest('POST', path, {
23
+ const response = await makeRequest('POST', '/user', {
55
24
  user_data: mappedUser,
56
25
  });
57
26
  return response.data.user_id;
58
27
  };
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) => {
28
+ const getConverageInfo = validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.coverageInfo, async (identificationValue) => {
90
29
  const path = `/info-coverage/${identificationValue}`;
91
30
  const response = await makeRequest('GET', path);
92
31
  const raw = response.data.info;
93
- if (!raw)
94
- return null;
95
32
  const mappedCoverageInfo = {
96
33
  financerId: raw.id_financiador,
97
34
  defaultAffiliationId: raw.id_afiliacion_default,
@@ -121,16 +58,31 @@ const getUserMethods = (makeRequest, url, credentials) => {
121
58
  : null,
122
59
  };
123
60
  return mappedCoverageInfo;
124
- };
61
+ });
125
62
  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),
63
+ declareUser: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.user]), zod_1.number(), getUserId),
129
64
  getUserInstance: validation_1.validateFunction(zod_1.tuple([zod_1.union([schemas_1.doc24Schemas.user, zod_1.number()])]),
130
65
  // 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),
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,
134
86
  };
135
87
  };
136
88
  exports.getUserMethods = getUserMethods;