@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
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { Doc24 } from './types';
|
|
2
|
+
export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
|
|
3
|
+
getRequestHandler: (params: {
|
|
4
|
+
credentials: Doc24.SdkCredentials;
|
|
5
|
+
eventHandlers: Doc24.Webhook.Events;
|
|
6
|
+
baseAddress: string;
|
|
7
|
+
}) => Promise<Doc24.Webhook.Handler>;
|
|
8
|
+
declareUser: (user: {
|
|
9
|
+
firstName: string;
|
|
10
|
+
lastName: string;
|
|
11
|
+
identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
|
|
12
|
+
identificationValue: string;
|
|
13
|
+
gender: "m" | "f";
|
|
14
|
+
phone: string;
|
|
15
|
+
email: string;
|
|
16
|
+
countryId: string;
|
|
17
|
+
birthdate: Date;
|
|
18
|
+
}) => Promise<number>;
|
|
19
|
+
getUserInstance: (user: number | {
|
|
20
|
+
firstName: string;
|
|
21
|
+
lastName: string;
|
|
22
|
+
identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
|
|
23
|
+
identificationValue: string;
|
|
24
|
+
gender: "m" | "f";
|
|
25
|
+
phone: string;
|
|
26
|
+
email: string;
|
|
27
|
+
countryId: string;
|
|
28
|
+
birthdate: Date;
|
|
29
|
+
}) => Promise<Doc24.UserSdk>;
|
|
30
|
+
getProfessional: (professionalId: number) => Promise<{
|
|
31
|
+
id: number;
|
|
32
|
+
logoUrl: string;
|
|
33
|
+
firstName: string;
|
|
34
|
+
lastName: string;
|
|
35
|
+
gender: "m" | "f";
|
|
36
|
+
phone: string | null;
|
|
37
|
+
email: string;
|
|
38
|
+
birthdate: Date;
|
|
39
|
+
specialties: {
|
|
40
|
+
id: number;
|
|
41
|
+
description: string;
|
|
42
|
+
}[];
|
|
43
|
+
matriculation: {
|
|
44
|
+
number: string;
|
|
45
|
+
type: string;
|
|
46
|
+
}[];
|
|
47
|
+
degree: string;
|
|
48
|
+
languages: string[];
|
|
49
|
+
resume: {
|
|
50
|
+
link: string;
|
|
51
|
+
brief: string;
|
|
52
|
+
};
|
|
53
|
+
}>;
|
|
54
|
+
getAvailableScheduleClinics: () => Promise<{
|
|
55
|
+
specialties: {
|
|
56
|
+
id: number;
|
|
57
|
+
description: string;
|
|
58
|
+
}[];
|
|
59
|
+
specialtiesER: {
|
|
60
|
+
id: number;
|
|
61
|
+
description: string;
|
|
62
|
+
}[];
|
|
63
|
+
professionals: {
|
|
64
|
+
id: number;
|
|
65
|
+
fullName: string;
|
|
66
|
+
clinicId: number;
|
|
67
|
+
specialties: {
|
|
68
|
+
id: number;
|
|
69
|
+
description: string;
|
|
70
|
+
}[];
|
|
71
|
+
}[];
|
|
72
|
+
}>;
|
|
73
|
+
enroll: (params: {
|
|
74
|
+
firstName: string;
|
|
75
|
+
lastName: string;
|
|
76
|
+
gender: "m" | "f";
|
|
77
|
+
email: string;
|
|
78
|
+
birthdate: Date;
|
|
79
|
+
startDate: Date;
|
|
80
|
+
identificationNumber: string;
|
|
81
|
+
plan: string;
|
|
82
|
+
}) => Promise<void>;
|
|
83
|
+
getConverageInfo: (identificationValue: string) => Promise<{
|
|
84
|
+
firstName: string | null;
|
|
85
|
+
lastName: string | null;
|
|
86
|
+
gender: "m" | "f";
|
|
87
|
+
email: string | null;
|
|
88
|
+
birthdate: Date;
|
|
89
|
+
identificationNumber: string;
|
|
90
|
+
plan: string | null;
|
|
91
|
+
financerId: number | null;
|
|
92
|
+
defaultAffiliationId: number | null;
|
|
93
|
+
credentialNumber: string | null;
|
|
94
|
+
financerPlanId: number | null;
|
|
95
|
+
brand: number | null;
|
|
96
|
+
holderIdentificationNumber: string | null;
|
|
97
|
+
copaymentValue: number | null;
|
|
98
|
+
mobilePhone: string | null;
|
|
99
|
+
company: string | null;
|
|
100
|
+
dischargeDate: Date | null;
|
|
101
|
+
leavingDate: Date | null;
|
|
102
|
+
identificacion_tributaria: string | null;
|
|
103
|
+
deregistrationDate: Date | null;
|
|
104
|
+
authorizationCode: string | null;
|
|
105
|
+
authorizationCodeExpiration: Date | null;
|
|
106
|
+
} | null>;
|
|
107
|
+
getConsultation: (consultationId: number) => Promise<{
|
|
108
|
+
pdf_laboratorios?: any;
|
|
109
|
+
pdf_otras?: any;
|
|
110
|
+
pdf_imagenes?: any;
|
|
111
|
+
snapshot_paciente?: any;
|
|
112
|
+
snapshot_profesional?: any;
|
|
113
|
+
custom_1?: any;
|
|
114
|
+
custom_2?: any;
|
|
115
|
+
custom_3?: any;
|
|
116
|
+
custom_4?: any;
|
|
117
|
+
custom_5?: any;
|
|
118
|
+
tag_idioma: string;
|
|
119
|
+
id_consulta: number;
|
|
120
|
+
tipo_consulta: string;
|
|
121
|
+
estado: string;
|
|
122
|
+
tipo_usuario_cancelacion: string | null;
|
|
123
|
+
fecha_cancelacion: string | null;
|
|
124
|
+
estado_pago: string;
|
|
125
|
+
referencia_mercadopago: string | null;
|
|
126
|
+
id_atencion: number;
|
|
127
|
+
id_profesional: number;
|
|
128
|
+
profesional: string;
|
|
129
|
+
modalidad_paciente_turno: string | null;
|
|
130
|
+
provincia_consultorio: string | null;
|
|
131
|
+
localidad_consultorio: string | null;
|
|
132
|
+
domicilio_consultorio: string | null;
|
|
133
|
+
marketplace: string;
|
|
134
|
+
profesional_matriculas: any[];
|
|
135
|
+
info_paciente: {
|
|
136
|
+
email?: string | null | undefined;
|
|
137
|
+
apellido?: string | null | undefined;
|
|
138
|
+
nombre?: string | null | undefined;
|
|
139
|
+
genero?: string | null | undefined;
|
|
140
|
+
valor_identificacion?: string | null | undefined;
|
|
141
|
+
telefono?: string | null | undefined;
|
|
142
|
+
id_pais?: string | null | undefined;
|
|
143
|
+
provincia?: string | null | undefined;
|
|
144
|
+
localidad?: string | null | undefined;
|
|
145
|
+
domicilio?: string | null | undefined;
|
|
146
|
+
fecha_de_nacimiento?: string | null | undefined;
|
|
147
|
+
tag_idioma?: number | null | undefined;
|
|
148
|
+
estado_paciente?: number | null | undefined;
|
|
149
|
+
fecha_suspension?: string | null | undefined;
|
|
150
|
+
fecha_activacion?: string | null | undefined;
|
|
151
|
+
fecha_modificacion?: string | null | undefined;
|
|
152
|
+
fecha_baja?: string | null | undefined;
|
|
153
|
+
id_paciente: number;
|
|
154
|
+
id_tipo_de_identificacion: number;
|
|
155
|
+
};
|
|
156
|
+
fecha_primer_llamado_profesional: string;
|
|
157
|
+
fecha_inicio: string;
|
|
158
|
+
fecha_primer_acceso_paciente: string;
|
|
159
|
+
fecha_ultimo_acceso_paciente: string;
|
|
160
|
+
fecha_corte_medico: string;
|
|
161
|
+
fecha_fin: string;
|
|
162
|
+
intentos_conexion: number;
|
|
163
|
+
id_turno: number | null;
|
|
164
|
+
fecha_turno_invitacion: string | null;
|
|
165
|
+
hora_turno_invitacion: string | null;
|
|
166
|
+
firma_profesional: string | null;
|
|
167
|
+
id_especialidad: number;
|
|
168
|
+
especialidad: string;
|
|
169
|
+
motivo: string;
|
|
170
|
+
enfermedad_actual: string;
|
|
171
|
+
conducta_terapeutica: string;
|
|
172
|
+
signos_alerta: string;
|
|
173
|
+
motivo_extendido_consulta: string;
|
|
174
|
+
presencial_requerida: string;
|
|
175
|
+
derivada: string;
|
|
176
|
+
derivada_id_especialidad: string;
|
|
177
|
+
derivada_presencial_obligatoria: string;
|
|
178
|
+
derivada_comentarios: string | null;
|
|
179
|
+
diagnostico: any[];
|
|
180
|
+
practicas: any[];
|
|
181
|
+
link_medicacion: any[];
|
|
182
|
+
medicacion: any[];
|
|
183
|
+
link_receta: string | null;
|
|
184
|
+
link_compra: string | null;
|
|
185
|
+
identificador_receta: string | null;
|
|
186
|
+
codigo_verificacion_receta: string | null;
|
|
187
|
+
financiador: string;
|
|
188
|
+
registro_custom: any[];
|
|
189
|
+
pdf_medicacion: any[];
|
|
190
|
+
uploads: any[];
|
|
191
|
+
files_atencion: any[];
|
|
192
|
+
motivo_cancelacion: string | null;
|
|
193
|
+
detalle_cancelacion: string | null;
|
|
194
|
+
documentos: string;
|
|
195
|
+
id_consultorio: number;
|
|
196
|
+
token: string;
|
|
197
|
+
tipo_protocolo_seguimiento: string | null;
|
|
198
|
+
form_data: {};
|
|
199
|
+
ubicacion: string;
|
|
200
|
+
link_full: string;
|
|
201
|
+
timestamp: string;
|
|
202
|
+
} | null>;
|
|
203
|
+
getDiagnosticaHistory: (patient: {
|
|
204
|
+
identificationType: "dni" | "ndi" | "passport" | "credential" | "nn" | "cpf" | "rg";
|
|
205
|
+
identificationValue: string;
|
|
206
|
+
gender: "m" | "f";
|
|
207
|
+
}, from: Date, to: Date) => Promise<{
|
|
208
|
+
date: Date;
|
|
209
|
+
location: string;
|
|
210
|
+
exams: string[];
|
|
211
|
+
deepLink: string;
|
|
212
|
+
}[]>;
|
|
213
|
+
getDiagnosticaDeepLink: (kiosk: string, user: {
|
|
214
|
+
language: string;
|
|
215
|
+
firstName: string;
|
|
216
|
+
lastName: string;
|
|
217
|
+
birthday: Date;
|
|
218
|
+
identificationType: "dni";
|
|
219
|
+
identificationValue: string;
|
|
220
|
+
gender: "m" | "f";
|
|
221
|
+
phone: string;
|
|
222
|
+
email: string;
|
|
223
|
+
}, patient: {
|
|
224
|
+
firstName: string;
|
|
225
|
+
lastName: string;
|
|
226
|
+
birthday: Date;
|
|
227
|
+
identificationType: "dni";
|
|
228
|
+
identificationValue: string;
|
|
229
|
+
gender: "m" | "f";
|
|
230
|
+
}) => Promise<{
|
|
231
|
+
forwardingRequired: true;
|
|
232
|
+
deepLink: string;
|
|
233
|
+
} | {
|
|
234
|
+
forwardingRequired: false;
|
|
235
|
+
}>;
|
|
236
|
+
getDiagnosticaAccess: (kiosk: string, user: {
|
|
237
|
+
language: string;
|
|
238
|
+
firstName: string;
|
|
239
|
+
lastName: string;
|
|
240
|
+
birthday: Date;
|
|
241
|
+
identificationType: "dni";
|
|
242
|
+
identificationValue: string;
|
|
243
|
+
gender: "m" | "f";
|
|
244
|
+
phone: string;
|
|
245
|
+
email: string;
|
|
246
|
+
}, patient: {
|
|
247
|
+
firstName: string;
|
|
248
|
+
lastName: string;
|
|
249
|
+
birthday: Date;
|
|
250
|
+
identificationType: "dni";
|
|
251
|
+
identificationValue: string;
|
|
252
|
+
gender: "m" | "f";
|
|
253
|
+
}) => Promise<void>;
|
|
254
|
+
}>;
|
|
255
|
+
export type { Doc24 } from './types';
|
package/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;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Doc24 } from '../types';
|
|
2
|
+
export declare const getRequestFactory: (url: string, credentials: Doc24.SdkCredentials, userId?: number | undefined) => Promise<RequestMaker>;
|
|
3
|
+
export declare type RequestMaker = (method: 'POST' | 'GET' | 'PUT' | 'DELETE', path: string, body?: object) => Promise<any>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getRequestFactory = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const token_1 = require("./token");
|
|
9
|
+
const debug_1 = __importDefault(require("debug"));
|
|
10
|
+
const debugRequest = debug_1.default('doc24Sdk:request');
|
|
11
|
+
const getRequestFactory = async (url, credentials, userId) => {
|
|
12
|
+
const makeRequest = async (method, path, body) => {
|
|
13
|
+
const token = await token_1.getToken(credentials, body ? JSON.stringify(body) : undefined, userId);
|
|
14
|
+
const fullUrl = url + path;
|
|
15
|
+
const result = await axios_1.default({
|
|
16
|
+
method,
|
|
17
|
+
url: fullUrl,
|
|
18
|
+
headers: { Authentication: token },
|
|
19
|
+
data: body,
|
|
20
|
+
});
|
|
21
|
+
debugRequest({ url: fullUrl, response: result.data, body });
|
|
22
|
+
return result.data;
|
|
23
|
+
};
|
|
24
|
+
return makeRequest;
|
|
25
|
+
};
|
|
26
|
+
exports.getRequestFactory = getRequestFactory;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getToken = void 0;
|
|
7
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
8
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
9
|
+
const tokenLifeTimeInSeconds = 500 * 60;
|
|
10
|
+
const getToken = async (credentials, bodyAsJson, userId) => {
|
|
11
|
+
const tokenData = {
|
|
12
|
+
msg_sig: createSignature(credentials.key, bodyAsJson),
|
|
13
|
+
user_id: userId,
|
|
14
|
+
};
|
|
15
|
+
const encodedToken = await makeJwt(tokenData, credentials.key, {
|
|
16
|
+
expiresIn: tokenLifeTimeInSeconds,
|
|
17
|
+
issuer: credentials.iss,
|
|
18
|
+
});
|
|
19
|
+
return encodedToken;
|
|
20
|
+
};
|
|
21
|
+
exports.getToken = getToken;
|
|
22
|
+
const makeJwt = (payload, key, options = {}) => new Promise((resolve, reject) => jsonwebtoken_1.default.sign(payload, key, options, (err, token) => {
|
|
23
|
+
if (err || !token)
|
|
24
|
+
return reject(err);
|
|
25
|
+
resolve(token);
|
|
26
|
+
}));
|
|
27
|
+
const createSignature = (secret, bodyAsJson) => {
|
|
28
|
+
//TODO: verify this, seems wrong
|
|
29
|
+
const realSecret = bodyAsJson ? secret : 'true';
|
|
30
|
+
const realBody = bodyAsJson !== null && bodyAsJson !== void 0 ? bodyAsJson : secret;
|
|
31
|
+
const hmac = crypto_1.default.createHmac('sha256', realSecret);
|
|
32
|
+
hmac.update(realBody);
|
|
33
|
+
return hmac.digest('base64');
|
|
34
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ZodError, ZodType } from 'zod';
|
|
2
|
+
export declare class ParametersValidationError extends Error {
|
|
3
|
+
details: ZodError;
|
|
4
|
+
constructor(details: ZodError);
|
|
5
|
+
}
|
|
6
|
+
export declare class ResponseValidationError extends Error {
|
|
7
|
+
details: ZodError;
|
|
8
|
+
constructor(details: ZodError);
|
|
9
|
+
}
|
|
10
|
+
export declare const validateFunction: <TParams extends unknown[], TResponse>(inValidation: ZodType<TParams, import("zod").ZodTypeDef, TParams>, outValidation: ZodType<TResponse, import("zod").ZodTypeDef, TResponse>, fn: (...params: TParams) => Promise<TResponse>) => (...params: TParams) => Promise<TResponse>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateFunction = exports.ResponseValidationError = exports.ParametersValidationError = void 0;
|
|
4
|
+
class ParametersValidationError extends Error {
|
|
5
|
+
constructor(details) {
|
|
6
|
+
super('Invalid parameters supplied to function');
|
|
7
|
+
this.details = details;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.ParametersValidationError = ParametersValidationError;
|
|
11
|
+
class ResponseValidationError extends Error {
|
|
12
|
+
constructor(details) {
|
|
13
|
+
super('Invalid response returned from function');
|
|
14
|
+
this.details = details;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.ResponseValidationError = ResponseValidationError;
|
|
18
|
+
const validateFunction = (inValidation, outValidation, fn) => async (...params) => {
|
|
19
|
+
const validationResult = inValidation.safeParse(params);
|
|
20
|
+
if (!validationResult.success)
|
|
21
|
+
throw new ParametersValidationError(validationResult.error);
|
|
22
|
+
const out = await fn(...validationResult.data);
|
|
23
|
+
const responseValidationResult = outValidation.safeParse(out);
|
|
24
|
+
if (!responseValidationResult.success)
|
|
25
|
+
throw new ResponseValidationError(responseValidationResult.error);
|
|
26
|
+
return responseValidationResult.data;
|
|
27
|
+
};
|
|
28
|
+
exports.validateFunction = validateFunction;
|