@integraciones_doc24/sdk 0.35.1 → 1.1.1
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/README.md +131 -83
- package/lib/baseSdk/diagnostica.d.ts +6 -6
- package/lib/baseSdk/index.js +1 -5
- package/lib/baseSdk/user.d.ts +51 -4
- package/lib/baseSdk/user.js +67 -25
- package/lib/index.d.ts +44 -16
- package/lib/schemas.d.ts +220 -30
- package/lib/schemas.js +33 -2
- package/lib/test.js +36 -1
- package/lib/types.d.ts +10 -2
- package/lib/userSdk/chat.d.ts +1 -1
- package/lib/userSdk/patients.d.ts +22 -2
- package/lib/userSdk/patients.js +34 -6
- package/lib/userSdk/videoVisit.d.ts +2 -2
- package/lib/utils.d.ts +1 -1
- package/lib/utils.js +3 -3
- package/package.json +2 -2
- package/lib/lib/baseSdk/diagnostica.d.ts +0 -11
- package/lib/lib/baseSdk/diagnostica.js +0 -79
- package/lib/lib/baseSdk/index.d.ts +0 -161
- package/lib/lib/baseSdk/index.js +0 -66
- package/lib/lib/baseSdk/user.d.ts +0 -41
- package/lib/lib/baseSdk/user.js +0 -130
- package/lib/lib/index.d.ts +0 -182
- package/lib/lib/index.js +0 -22
- package/lib/lib/lib/baseSdk/diagnostica.d.ts +0 -6
- package/lib/lib/lib/baseSdk/diagnostica.js +0 -79
- package/lib/lib/lib/baseSdk/index.d.ts +0 -51
- package/lib/lib/lib/baseSdk/index.js +0 -66
- package/lib/lib/lib/baseSdk/user.d.ts +0 -9
- package/lib/lib/lib/baseSdk/user.js +0 -130
- package/lib/lib/lib/index.d.ts +0 -168
- package/lib/lib/lib/index.js +0 -22
- package/lib/lib/lib/lib/baseSdk/diagnostica.d.ts +0 -6
- package/lib/lib/lib/lib/baseSdk/diagnostica.js +0 -79
- package/lib/lib/lib/lib/baseSdk/index.d.ts +0 -14
- package/lib/lib/lib/lib/baseSdk/index.js +0 -66
- package/lib/lib/lib/lib/baseSdk/user.d.ts +0 -9
- package/lib/lib/lib/lib/baseSdk/user.js +0 -130
- package/lib/lib/lib/lib/index.d.ts +0 -58
- package/lib/lib/lib/lib/index.js +0 -22
- package/lib/lib/lib/lib/request/index.d.ts +0 -2
- package/lib/lib/lib/lib/request/index.js +0 -26
- package/lib/lib/lib/lib/request/token.d.ts +0 -2
- package/lib/lib/lib/lib/request/token.js +0 -34
- package/lib/lib/lib/lib/request/validation.d.ts +0 -10
- package/lib/lib/lib/lib/request/validation.js +0 -28
- package/lib/lib/lib/lib/schemas.d.ts +0 -1334
- package/lib/lib/lib/lib/schemas.js +0 -325
- package/lib/lib/lib/lib/test.d.ts +0 -1
- package/lib/lib/lib/lib/test.js +0 -55
- package/lib/lib/lib/lib/types.d.ts +0 -1
- package/lib/lib/lib/lib/types.js +0 -2
- package/lib/lib/lib/lib/userSdk/chat.d.ts +0 -9
- package/lib/lib/lib/lib/userSdk/chat.js +0 -98
- package/lib/lib/lib/lib/userSdk/index.d.ts +0 -24
- package/lib/lib/lib/lib/userSdk/index.js +0 -27
- package/lib/lib/lib/lib/userSdk/patients.d.ts +0 -5
- package/lib/lib/lib/lib/userSdk/patients.js +0 -55
- package/lib/lib/lib/lib/userSdk/schedule.d.ts +0 -7
- package/lib/lib/lib/lib/userSdk/schedule.js +0 -76
- package/lib/lib/lib/lib/userSdk/specialties.d.ts +0 -4
- package/lib/lib/lib/lib/userSdk/specialties.js +0 -19
- package/lib/lib/lib/lib/userSdk/videoVisit.d.ts +0 -10
- package/lib/lib/lib/lib/userSdk/videoVisit.js +0 -147
- package/lib/lib/lib/lib/utils.d.ts +0 -4
- package/lib/lib/lib/lib/utils.js +0 -19
- package/lib/lib/lib/lib/webhook/index.d.ts +0 -8
- package/lib/lib/lib/lib/webhook/index.js +0 -55
- package/lib/lib/lib/lib/webhook/responses.d.ts +0 -36
- package/lib/lib/lib/lib/webhook/responses.js +0 -42
- package/lib/lib/lib/lib/webhook/token.d.ts +0 -2
- package/lib/lib/lib/lib/webhook/token.js +0 -23
- package/lib/lib/lib/request/index.d.ts +0 -2
- package/lib/lib/lib/request/index.js +0 -26
- package/lib/lib/lib/request/token.d.ts +0 -2
- package/lib/lib/lib/request/token.js +0 -34
- package/lib/lib/lib/request/validation.d.ts +0 -10
- package/lib/lib/lib/request/validation.js +0 -28
- package/lib/lib/lib/schemas.d.ts +0 -1334
- package/lib/lib/lib/schemas.js +0 -325
- package/lib/lib/lib/src/baseSdk/diagnostica.d.ts +0 -6
- package/lib/lib/lib/src/baseSdk/diagnostica.js +0 -79
- package/lib/lib/lib/src/baseSdk/index.d.ts +0 -51
- package/lib/lib/lib/src/baseSdk/index.js +0 -66
- package/lib/lib/lib/src/baseSdk/user.d.ts +0 -9
- package/lib/lib/lib/src/baseSdk/user.js +0 -130
- package/lib/lib/lib/src/index.d.ts +0 -169
- package/lib/lib/lib/src/index.js +0 -22
- package/lib/lib/lib/src/request/index.d.ts +0 -2
- package/lib/lib/lib/src/request/index.js +0 -26
- package/lib/lib/lib/src/request/token.d.ts +0 -2
- package/lib/lib/lib/src/request/token.js +0 -34
- package/lib/lib/lib/src/request/validation.d.ts +0 -10
- package/lib/lib/lib/src/request/validation.js +0 -28
- package/lib/lib/lib/src/schemas.d.ts +0 -1340
- package/lib/lib/lib/src/schemas.js +0 -325
- package/lib/lib/lib/src/types.d.ts +0 -1
- package/lib/lib/lib/src/types.js +0 -2
- package/lib/lib/lib/src/userSdk/chat.d.ts +0 -9
- package/lib/lib/lib/src/userSdk/chat.js +0 -98
- package/lib/lib/lib/src/userSdk/index.d.ts +0 -102
- package/lib/lib/lib/src/userSdk/index.js +0 -27
- package/lib/lib/lib/src/userSdk/patients.d.ts +0 -5
- package/lib/lib/lib/src/userSdk/patients.js +0 -55
- package/lib/lib/lib/src/userSdk/schedule.d.ts +0 -7
- package/lib/lib/lib/src/userSdk/schedule.js +0 -76
- package/lib/lib/lib/src/userSdk/specialties.d.ts +0 -4
- package/lib/lib/lib/src/userSdk/specialties.js +0 -19
- package/lib/lib/lib/src/userSdk/videoVisit.d.ts +0 -10
- package/lib/lib/lib/src/userSdk/videoVisit.js +0 -147
- package/lib/lib/lib/src/utils.d.ts +0 -4
- package/lib/lib/lib/src/utils.js +0 -19
- package/lib/lib/lib/src/webhook/index.d.ts +0 -8
- package/lib/lib/lib/src/webhook/index.js +0 -55
- package/lib/lib/lib/src/webhook/responses.d.ts +0 -36
- package/lib/lib/lib/src/webhook/responses.js +0 -42
- package/lib/lib/lib/src/webhook/token.d.ts +0 -2
- package/lib/lib/lib/src/webhook/token.js +0 -23
- package/lib/lib/lib/test.d.ts +0 -1
- package/lib/lib/lib/test.js +0 -55
- package/lib/lib/lib/types.d.ts +0 -1
- package/lib/lib/lib/types.js +0 -2
- package/lib/lib/lib/userSdk/chat.d.ts +0 -9
- package/lib/lib/lib/userSdk/chat.js +0 -98
- package/lib/lib/lib/userSdk/index.d.ts +0 -102
- package/lib/lib/lib/userSdk/index.js +0 -27
- package/lib/lib/lib/userSdk/patients.d.ts +0 -5
- package/lib/lib/lib/userSdk/patients.js +0 -55
- package/lib/lib/lib/userSdk/schedule.d.ts +0 -7
- package/lib/lib/lib/userSdk/schedule.js +0 -76
- package/lib/lib/lib/userSdk/specialties.d.ts +0 -4
- package/lib/lib/lib/userSdk/specialties.js +0 -19
- package/lib/lib/lib/userSdk/videoVisit.d.ts +0 -10
- package/lib/lib/lib/userSdk/videoVisit.js +0 -147
- package/lib/lib/lib/utils.d.ts +0 -4
- package/lib/lib/lib/utils.js +0 -19
- package/lib/lib/lib/webhook/index.d.ts +0 -8
- package/lib/lib/lib/webhook/index.js +0 -55
- package/lib/lib/lib/webhook/responses.d.ts +0 -36
- package/lib/lib/lib/webhook/responses.js +0 -42
- package/lib/lib/lib/webhook/token.d.ts +0 -2
- package/lib/lib/lib/webhook/token.js +0 -23
- package/lib/lib/request/index.d.ts +0 -2
- package/lib/lib/request/index.js +0 -26
- package/lib/lib/request/token.d.ts +0 -2
- package/lib/lib/request/token.js +0 -34
- package/lib/lib/request/validation.d.ts +0 -10
- package/lib/lib/request/validation.js +0 -28
- package/lib/lib/schemas.d.ts +0 -1334
- package/lib/lib/schemas.js +0 -325
- package/lib/lib/src/baseSdk/diagnostica.d.ts +0 -11
- package/lib/lib/src/baseSdk/diagnostica.js +0 -79
- package/lib/lib/src/baseSdk/index.d.ts +0 -162
- package/lib/lib/src/baseSdk/index.js +0 -66
- package/lib/lib/src/baseSdk/user.d.ts +0 -41
- package/lib/lib/src/baseSdk/user.js +0 -130
- package/lib/lib/src/index.d.ts +0 -183
- package/lib/lib/src/index.js +0 -22
- package/lib/lib/src/request/index.d.ts +0 -2
- package/lib/lib/src/request/index.js +0 -26
- package/lib/lib/src/request/token.d.ts +0 -2
- package/lib/lib/src/request/token.js +0 -34
- package/lib/lib/src/request/validation.d.ts +0 -10
- package/lib/lib/src/request/validation.js +0 -28
- package/lib/lib/src/schemas.d.ts +0 -1340
- package/lib/lib/src/schemas.js +0 -325
- package/lib/lib/src/types.d.ts +0 -1
- package/lib/lib/src/types.js +0 -2
- package/lib/lib/src/userSdk/chat.d.ts +0 -9
- package/lib/lib/src/userSdk/chat.js +0 -98
- package/lib/lib/src/userSdk/index.d.ts +0 -241
- package/lib/lib/src/userSdk/index.js +0 -27
- package/lib/lib/src/userSdk/patients.d.ts +0 -13
- package/lib/lib/src/userSdk/patients.js +0 -55
- package/lib/lib/src/userSdk/schedule.d.ts +0 -15
- package/lib/lib/src/userSdk/schedule.js +0 -76
- package/lib/lib/src/userSdk/specialties.d.ts +0 -4
- package/lib/lib/src/userSdk/specialties.js +0 -19
- package/lib/lib/src/userSdk/videoVisit.d.ts +0 -72
- package/lib/lib/src/userSdk/videoVisit.js +0 -147
- package/lib/lib/src/utils.d.ts +0 -4
- package/lib/lib/src/utils.js +0 -19
- package/lib/lib/src/webhook/index.d.ts +0 -8
- package/lib/lib/src/webhook/index.js +0 -55
- package/lib/lib/src/webhook/responses.d.ts +0 -36
- package/lib/lib/src/webhook/responses.js +0 -42
- package/lib/lib/src/webhook/token.d.ts +0 -2
- package/lib/lib/src/webhook/token.js +0 -23
- package/lib/lib/test.d.ts +0 -1
- package/lib/lib/test.js +0 -55
- package/lib/lib/types.d.ts +0 -1
- package/lib/lib/types.js +0 -2
- package/lib/lib/userSdk/chat.d.ts +0 -9
- package/lib/lib/userSdk/chat.js +0 -98
- package/lib/lib/userSdk/index.d.ts +0 -240
- package/lib/lib/userSdk/index.js +0 -27
- package/lib/lib/userSdk/patients.d.ts +0 -13
- package/lib/lib/userSdk/patients.js +0 -55
- package/lib/lib/userSdk/schedule.d.ts +0 -15
- package/lib/lib/userSdk/schedule.js +0 -76
- package/lib/lib/userSdk/specialties.d.ts +0 -4
- package/lib/lib/userSdk/specialties.js +0 -19
- package/lib/lib/userSdk/videoVisit.d.ts +0 -72
- package/lib/lib/userSdk/videoVisit.js +0 -147
- package/lib/lib/utils.d.ts +0 -4
- package/lib/lib/utils.js +0 -19
- package/lib/lib/webhook/index.d.ts +0 -8
- package/lib/lib/webhook/index.js +0 -55
- package/lib/lib/webhook/responses.d.ts +0 -36
- package/lib/lib/webhook/responses.js +0 -42
- package/lib/lib/webhook/token.d.ts +0 -2
- package/lib/lib/webhook/token.js +0 -23
- package/lib/src/baseSdk/diagnostica.d.ts +0 -54
- package/lib/src/baseSdk/diagnostica.js +0 -79
- package/lib/src/baseSdk/index.d.ts +0 -2
- package/lib/src/baseSdk/index.js +0 -66
- package/lib/src/baseSdk/user.d.ts +0 -89
- package/lib/src/baseSdk/user.js +0 -130
- package/lib/src/index.d.ts +0 -188
- package/lib/src/index.js +0 -22
- package/lib/src/request/index.d.ts +0 -3
- package/lib/src/request/index.js +0 -26
- package/lib/src/request/token.d.ts +0 -2
- package/lib/src/request/token.js +0 -34
- package/lib/src/request/validation.d.ts +0 -10
- package/lib/src/request/validation.js +0 -28
- package/lib/src/schemas.d.ts +0 -1311
- package/lib/src/schemas.js +0 -325
- package/lib/src/types.d.ts +0 -124
- package/lib/src/types.js +0 -2
- package/lib/src/userSdk/chat.d.ts +0 -57
- package/lib/src/userSdk/chat.js +0 -98
- package/lib/src/userSdk/index.d.ts +0 -2
- package/lib/src/userSdk/index.js +0 -27
- package/lib/src/userSdk/patients.d.ts +0 -33
- package/lib/src/userSdk/patients.js +0 -55
- package/lib/src/userSdk/schedule.d.ts +0 -44
- package/lib/src/userSdk/schedule.js +0 -76
- package/lib/src/userSdk/specialties.d.ts +0 -7
- package/lib/src/userSdk/specialties.js +0 -19
- package/lib/src/userSdk/videoVisit.d.ts +0 -111
- package/lib/src/userSdk/videoVisit.js +0 -147
- package/lib/src/utils.d.ts +0 -4
- package/lib/src/utils.js +0 -19
- package/lib/src/webhook/index.d.ts +0 -2
- package/lib/src/webhook/index.js +0 -55
- package/lib/src/webhook/responses.d.ts +0 -35
- package/lib/src/webhook/responses.js +0 -42
- package/lib/src/webhook/token.d.ts +0 -2
- package/lib/src/webhook/token.js +0 -23
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { RequestMaker } from '../request';
|
|
2
|
-
import { Doc24 } from '../types';
|
|
3
|
-
export declare const getUserMethods: (makeRequest: RequestMaker, url: string, credentials: Doc24.SdkCredentials) => {
|
|
4
|
-
declareUser: (params: {
|
|
5
|
-
user: {
|
|
6
|
-
firstName: string;
|
|
7
|
-
lastName: string;
|
|
8
|
-
identificationType: "ndi" | "passport" | "credential";
|
|
9
|
-
identificationValue: string;
|
|
10
|
-
countryId: string;
|
|
11
|
-
birthdate: Date;
|
|
12
|
-
gender: "m" | "f";
|
|
13
|
-
phone: string;
|
|
14
|
-
email: string;
|
|
15
|
-
};
|
|
16
|
-
} & {
|
|
17
|
-
code?: string | undefined;
|
|
18
|
-
channel?: "1" | "2" | undefined;
|
|
19
|
-
}) => Promise<{
|
|
20
|
-
patientId: number | null;
|
|
21
|
-
userInfo: {
|
|
22
|
-
phone: string;
|
|
23
|
-
email: string;
|
|
24
|
-
};
|
|
25
|
-
askCode: boolean;
|
|
26
|
-
userId: number;
|
|
27
|
-
}>;
|
|
28
|
-
getUserId: (user: {
|
|
29
|
-
firstName: string;
|
|
30
|
-
lastName: string;
|
|
31
|
-
identificationType: "ndi" | "passport" | "credential";
|
|
32
|
-
identificationValue: string;
|
|
33
|
-
countryId: string;
|
|
34
|
-
birthdate: Date;
|
|
35
|
-
gender: "m" | "f";
|
|
36
|
-
phone: string;
|
|
37
|
-
email: string;
|
|
38
|
-
}) => Promise<number>;
|
|
39
|
-
sendVerificationCode: (params: {
|
|
40
|
-
identificationType: "ndi" | "passport" | "credential";
|
|
41
|
-
identificationValue: string;
|
|
42
|
-
channel: "1" | "2";
|
|
43
|
-
}) => Promise<any>;
|
|
44
|
-
getUserInstance: (user: number | {
|
|
45
|
-
firstName: string;
|
|
46
|
-
lastName: string;
|
|
47
|
-
identificationType: "ndi" | "passport" | "credential";
|
|
48
|
-
identificationValue: string;
|
|
49
|
-
countryId: string;
|
|
50
|
-
birthdate: Date;
|
|
51
|
-
gender: "m" | "f";
|
|
52
|
-
phone: string;
|
|
53
|
-
email: string;
|
|
54
|
-
}) => Promise<any>;
|
|
55
|
-
enroll: (params: {
|
|
56
|
-
firstName: string;
|
|
57
|
-
lastName: string;
|
|
58
|
-
birthdate: Date;
|
|
59
|
-
gender: "m" | "f";
|
|
60
|
-
email: string;
|
|
61
|
-
startDate: Date;
|
|
62
|
-
identificationNumber: string;
|
|
63
|
-
plan: string;
|
|
64
|
-
}) => Promise<void>;
|
|
65
|
-
getConverageInfo: (identificationValue: string) => Promise<{
|
|
66
|
-
firstName: string | null;
|
|
67
|
-
lastName: string | null;
|
|
68
|
-
birthdate: Date;
|
|
69
|
-
gender: "m" | "f";
|
|
70
|
-
email: string | null;
|
|
71
|
-
identificationNumber: string;
|
|
72
|
-
plan: string | null;
|
|
73
|
-
financerId: number | null;
|
|
74
|
-
defaultAffiliationId: number | null;
|
|
75
|
-
credentialNumber: string | null;
|
|
76
|
-
financerPlanId: number | null;
|
|
77
|
-
brand: number | null;
|
|
78
|
-
holderIdentificationNumber: string | null;
|
|
79
|
-
copaymentValue: number | null;
|
|
80
|
-
mobilePhone: string | null;
|
|
81
|
-
company: string | null;
|
|
82
|
-
dischargeDate: Date | null;
|
|
83
|
-
leavingDate: Date | null;
|
|
84
|
-
identificacion_tributaria: string | null;
|
|
85
|
-
deregistrationDate: Date | null;
|
|
86
|
-
authorizationCode: string | null;
|
|
87
|
-
authorizationCodeExpiration: Date | null;
|
|
88
|
-
} | null>;
|
|
89
|
-
};
|
package/lib/src/baseSdk/user.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
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 declareUser = async ({ user, channel, code, }) => {
|
|
12
|
-
const path = '/user';
|
|
13
|
-
const mappedUser = {
|
|
14
|
-
lastname: user.lastName,
|
|
15
|
-
firstname: user.firstName,
|
|
16
|
-
identification_type: utils_1.getIdetificationTypeId(user.identificationType),
|
|
17
|
-
identification_value: user.identificationValue,
|
|
18
|
-
birthdate: date_fns_1.format(user.birthdate, 'yyyy-MM-dd'),
|
|
19
|
-
gender: user.gender.toUpperCase(),
|
|
20
|
-
phone: user.phone,
|
|
21
|
-
email: user.email,
|
|
22
|
-
country_id: user.countryId,
|
|
23
|
-
};
|
|
24
|
-
const parsedChannel = channel ? parseInt(channel) : channel;
|
|
25
|
-
const response = await makeRequest('POST', path, {
|
|
26
|
-
user_data: mappedUser,
|
|
27
|
-
channel: parsedChannel,
|
|
28
|
-
code,
|
|
29
|
-
});
|
|
30
|
-
const mappedResponse = {
|
|
31
|
-
userId: response.data.user_id,
|
|
32
|
-
patientId: response.data.patient_id,
|
|
33
|
-
userInfo: response.data.user_info,
|
|
34
|
-
askCode: response.data.ask_code,
|
|
35
|
-
};
|
|
36
|
-
return mappedResponse;
|
|
37
|
-
};
|
|
38
|
-
const getUserId = async (user) => {
|
|
39
|
-
const path = '/user';
|
|
40
|
-
const mappedUser = {
|
|
41
|
-
lastname: user.lastName,
|
|
42
|
-
firstname: user.firstName,
|
|
43
|
-
identification_type: utils_1.getIdetificationTypeId(user.identificationType),
|
|
44
|
-
identification_value: user.identificationValue,
|
|
45
|
-
birthdate: date_fns_1.format(user.birthdate, 'yyyy-MM-dd'),
|
|
46
|
-
gender: user.gender.toUpperCase(),
|
|
47
|
-
phone: user.phone,
|
|
48
|
-
email: user.email,
|
|
49
|
-
country_id: user.countryId,
|
|
50
|
-
};
|
|
51
|
-
const response = await makeRequest('POST', path, {
|
|
52
|
-
user_data: mappedUser,
|
|
53
|
-
});
|
|
54
|
-
return response.data.user_id;
|
|
55
|
-
};
|
|
56
|
-
const sendVerificationCode = async (params) => {
|
|
57
|
-
const path = '/send-verification-code';
|
|
58
|
-
const mappedParams = {
|
|
59
|
-
identification_type: utils_1.getIdetificationTypeId(params.identificationType),
|
|
60
|
-
identification_value: params.identificationValue,
|
|
61
|
-
channel: parseInt(params.channel),
|
|
62
|
-
};
|
|
63
|
-
await makeRequest('POST', path, mappedParams);
|
|
64
|
-
};
|
|
65
|
-
const getUserInstance = async (user) => {
|
|
66
|
-
const userId = typeof user === 'number' ? user : await getUserId(user);
|
|
67
|
-
return userSdk_1.userSdk(url, credentials, userId);
|
|
68
|
-
};
|
|
69
|
-
const enroll = async (params) => {
|
|
70
|
-
const path = `/enrollment`;
|
|
71
|
-
const mappedUser = {
|
|
72
|
-
firstname: params.firstName,
|
|
73
|
-
lastname: params.lastName,
|
|
74
|
-
gender: params.gender.toUpperCase(),
|
|
75
|
-
identification_number: params.identificationNumber,
|
|
76
|
-
birthdate: date_fns_1.format(params.birthdate, 'yyyy-MM-dd'),
|
|
77
|
-
email: params.email,
|
|
78
|
-
plan: params.plan,
|
|
79
|
-
start_date: date_fns_1.format(params.startDate, 'yyyy-MM-dd'),
|
|
80
|
-
};
|
|
81
|
-
await makeRequest('POST', path, {
|
|
82
|
-
user_data: mappedUser,
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
const getConverageInfo = async (identificationValue) => {
|
|
86
|
-
const path = `/info-coverage/${identificationValue}`;
|
|
87
|
-
const response = await makeRequest('GET', path);
|
|
88
|
-
const raw = response.data.info;
|
|
89
|
-
const mappedCoverageInfo = {
|
|
90
|
-
financerId: raw.id_financiador,
|
|
91
|
-
defaultAffiliationId: raw.id_afiliacion_default,
|
|
92
|
-
plan: raw.plan,
|
|
93
|
-
identificationNumber: raw.nro_documento,
|
|
94
|
-
credentialNumber: raw.nro_credencial,
|
|
95
|
-
lastName: raw.apellido,
|
|
96
|
-
firstName: raw.nombre,
|
|
97
|
-
birthdate: utils_1.parseDate(raw.fecha_nacimiento),
|
|
98
|
-
financerPlanId: raw.id_financiador_plan,
|
|
99
|
-
gender: raw.sexo.toLowerCase(),
|
|
100
|
-
brand: raw.brand,
|
|
101
|
-
holderIdentificationNumber: raw.nro_documento_titular,
|
|
102
|
-
copaymentValue: raw.valor_copago,
|
|
103
|
-
mobilePhone: raw.telefono_movil,
|
|
104
|
-
company: raw.empresa,
|
|
105
|
-
email: raw.email,
|
|
106
|
-
dischargeDate: raw.fecha_alta ? utils_1.parseDateTime(raw.fecha_alta) : null,
|
|
107
|
-
leavingDate: raw.fecha_baja ? utils_1.parseDateTime(raw.fecha_baja) : null,
|
|
108
|
-
identificacion_tributaria: raw.identificacion_tributaria,
|
|
109
|
-
deregistrationDate: raw.fecha_baja_padron
|
|
110
|
-
? utils_1.parseDateTime(raw.fecha_baja_padron)
|
|
111
|
-
: null,
|
|
112
|
-
authorizationCode: raw.codigo_autorizacion,
|
|
113
|
-
authorizationCodeExpiration: raw.codigo_autorizacion_vencimiento
|
|
114
|
-
? utils_1.parseDateTime(raw.codigo_autorizacion_vencimiento)
|
|
115
|
-
: null,
|
|
116
|
-
};
|
|
117
|
-
return mappedCoverageInfo;
|
|
118
|
-
};
|
|
119
|
-
return {
|
|
120
|
-
declareUser: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.declareUserParams]), schemas_1.doc24Schemas.declareUserResponse, declareUser),
|
|
121
|
-
getUserId: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.user]), zod_1.number(), getUserId),
|
|
122
|
-
sendVerificationCode: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.sendVerificationCodeParams]), zod_1.void(), sendVerificationCode),
|
|
123
|
-
getUserInstance: validation_1.validateFunction(zod_1.tuple([zod_1.union([schemas_1.doc24Schemas.user, zod_1.number()])]),
|
|
124
|
-
// TODO: validate?
|
|
125
|
-
zod_1.any(), getUserInstance),
|
|
126
|
-
enroll: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.enrollmentParams]), zod_1.void(), enroll),
|
|
127
|
-
getConverageInfo: validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.coverageInfo, getConverageInfo),
|
|
128
|
-
};
|
|
129
|
-
};
|
|
130
|
-
exports.getUserMethods = getUserMethods;
|
package/lib/src/index.d.ts
DELETED
|
@@ -1,188 +0,0 @@
|
|
|
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: (params: {
|
|
9
|
-
user: {
|
|
10
|
-
firstName: string;
|
|
11
|
-
lastName: string;
|
|
12
|
-
identificationType: "ndi" | "passport" | "credential";
|
|
13
|
-
identificationValue: string;
|
|
14
|
-
countryId: string;
|
|
15
|
-
birthdate: Date;
|
|
16
|
-
gender: "m" | "f";
|
|
17
|
-
phone: string;
|
|
18
|
-
email: string;
|
|
19
|
-
};
|
|
20
|
-
} & {
|
|
21
|
-
code?: string | undefined;
|
|
22
|
-
channel?: "1" | "2" | undefined;
|
|
23
|
-
}) => Promise<{
|
|
24
|
-
patientId: number | null;
|
|
25
|
-
userInfo: {
|
|
26
|
-
phone: string;
|
|
27
|
-
email: string;
|
|
28
|
-
};
|
|
29
|
-
askCode: boolean;
|
|
30
|
-
userId: number;
|
|
31
|
-
}>;
|
|
32
|
-
getUserId: (user: {
|
|
33
|
-
firstName: string;
|
|
34
|
-
lastName: string;
|
|
35
|
-
identificationType: "ndi" | "passport" | "credential";
|
|
36
|
-
identificationValue: string;
|
|
37
|
-
countryId: string;
|
|
38
|
-
birthdate: Date;
|
|
39
|
-
gender: "m" | "f";
|
|
40
|
-
phone: string;
|
|
41
|
-
email: string;
|
|
42
|
-
}) => Promise<number>;
|
|
43
|
-
getUserInstance: (user: number | {
|
|
44
|
-
firstName: string;
|
|
45
|
-
lastName: string;
|
|
46
|
-
identificationType: "ndi" | "passport" | "credential";
|
|
47
|
-
identificationValue: string;
|
|
48
|
-
countryId: string;
|
|
49
|
-
birthdate: Date;
|
|
50
|
-
gender: "m" | "f";
|
|
51
|
-
phone: string;
|
|
52
|
-
email: string;
|
|
53
|
-
}) => Promise<Doc24.UserSdk>;
|
|
54
|
-
getProfessional: (professionalId: number) => Promise<{
|
|
55
|
-
firstName: string;
|
|
56
|
-
lastName: string;
|
|
57
|
-
birthdate: Date;
|
|
58
|
-
gender: "m" | "f";
|
|
59
|
-
phone: string | null;
|
|
60
|
-
email: string;
|
|
61
|
-
id: number;
|
|
62
|
-
logoUrl: string;
|
|
63
|
-
specialties: {
|
|
64
|
-
id: number;
|
|
65
|
-
description: string;
|
|
66
|
-
}[];
|
|
67
|
-
matriculation: {
|
|
68
|
-
number: string;
|
|
69
|
-
type: string;
|
|
70
|
-
}[];
|
|
71
|
-
degree: string;
|
|
72
|
-
languages: string[];
|
|
73
|
-
resume: {
|
|
74
|
-
link: string;
|
|
75
|
-
brief: string;
|
|
76
|
-
};
|
|
77
|
-
}>;
|
|
78
|
-
getAvailableScheduleClinics: () => Promise<{
|
|
79
|
-
specialties: {
|
|
80
|
-
id: number;
|
|
81
|
-
description: string;
|
|
82
|
-
}[];
|
|
83
|
-
specialtiesER: {
|
|
84
|
-
id: number;
|
|
85
|
-
description: string;
|
|
86
|
-
}[];
|
|
87
|
-
professionals: {
|
|
88
|
-
id: number;
|
|
89
|
-
fullName: string;
|
|
90
|
-
clinicId: number;
|
|
91
|
-
specialties: {
|
|
92
|
-
id: number;
|
|
93
|
-
description: string;
|
|
94
|
-
}[];
|
|
95
|
-
}[];
|
|
96
|
-
}>;
|
|
97
|
-
enroll: (params: {
|
|
98
|
-
firstName: string;
|
|
99
|
-
lastName: string;
|
|
100
|
-
birthdate: Date;
|
|
101
|
-
gender: "m" | "f";
|
|
102
|
-
email: string;
|
|
103
|
-
startDate: Date;
|
|
104
|
-
identificationNumber: string;
|
|
105
|
-
plan: string;
|
|
106
|
-
}) => Promise<void>;
|
|
107
|
-
getConverageInfo: (identificationValue: string) => Promise<{
|
|
108
|
-
firstName: string | null;
|
|
109
|
-
lastName: string | null;
|
|
110
|
-
birthdate: Date;
|
|
111
|
-
gender: "m" | "f";
|
|
112
|
-
email: string | null;
|
|
113
|
-
identificationNumber: string;
|
|
114
|
-
plan: string | null;
|
|
115
|
-
financerId: number | null;
|
|
116
|
-
defaultAffiliationId: number | null;
|
|
117
|
-
credentialNumber: string | null;
|
|
118
|
-
financerPlanId: number | null;
|
|
119
|
-
brand: number | null;
|
|
120
|
-
holderIdentificationNumber: string | null;
|
|
121
|
-
copaymentValue: number | null;
|
|
122
|
-
mobilePhone: string | null;
|
|
123
|
-
company: string | null;
|
|
124
|
-
dischargeDate: Date | null;
|
|
125
|
-
leavingDate: Date | null;
|
|
126
|
-
identificacion_tributaria: string | null;
|
|
127
|
-
deregistrationDate: Date | null;
|
|
128
|
-
authorizationCode: string | null;
|
|
129
|
-
authorizationCodeExpiration: Date | null;
|
|
130
|
-
} | null>;
|
|
131
|
-
sendVerificationCode: (params: {
|
|
132
|
-
identificationType: "ndi" | "passport" | "credential";
|
|
133
|
-
identificationValue: string;
|
|
134
|
-
channel: "1" | "2";
|
|
135
|
-
}) => Promise<any>;
|
|
136
|
-
getDiagnosticaHistory: (patient: {
|
|
137
|
-
identificationType: "ndi" | "passport" | "credential";
|
|
138
|
-
identificationValue: string;
|
|
139
|
-
gender: "m" | "f";
|
|
140
|
-
}, from: Date, to: Date) => Promise<{
|
|
141
|
-
date: Date;
|
|
142
|
-
location: string;
|
|
143
|
-
exams: string[];
|
|
144
|
-
deepLink: string;
|
|
145
|
-
}[]>;
|
|
146
|
-
getDiagnosticaDeepLink: (kiosk: string, user: {
|
|
147
|
-
firstName: string;
|
|
148
|
-
lastName: string;
|
|
149
|
-
identificationType: "dni";
|
|
150
|
-
identificationValue: string;
|
|
151
|
-
gender: "m" | "f";
|
|
152
|
-
phone: string;
|
|
153
|
-
email: string;
|
|
154
|
-
language: string;
|
|
155
|
-
birthday: Date;
|
|
156
|
-
}, patient: {
|
|
157
|
-
firstName: string;
|
|
158
|
-
lastName: string;
|
|
159
|
-
identificationType: "dni";
|
|
160
|
-
identificationValue: string;
|
|
161
|
-
gender: "m" | "f";
|
|
162
|
-
birthday: Date;
|
|
163
|
-
}) => Promise<{
|
|
164
|
-
forwardingRequired: true;
|
|
165
|
-
deepLink: string;
|
|
166
|
-
} | {
|
|
167
|
-
forwardingRequired: false;
|
|
168
|
-
}>;
|
|
169
|
-
getDiagnosticaAccess: (kiosk: string, user: {
|
|
170
|
-
firstName: string;
|
|
171
|
-
lastName: string;
|
|
172
|
-
identificationType: "dni";
|
|
173
|
-
identificationValue: string;
|
|
174
|
-
gender: "m" | "f";
|
|
175
|
-
phone: string;
|
|
176
|
-
email: string;
|
|
177
|
-
language: string;
|
|
178
|
-
birthday: Date;
|
|
179
|
-
}, patient: {
|
|
180
|
-
firstName: string;
|
|
181
|
-
lastName: string;
|
|
182
|
-
identificationType: "dni";
|
|
183
|
-
identificationValue: string;
|
|
184
|
-
gender: "m" | "f";
|
|
185
|
-
birthday: Date;
|
|
186
|
-
}) => Promise<void>;
|
|
187
|
-
}>;
|
|
188
|
-
export type { Doc24 } from './types';
|
package/lib/src/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
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;
|
|
@@ -1,3 +0,0 @@
|
|
|
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>;
|
package/lib/src/request/index.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
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;
|
package/lib/src/request/token.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
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>;
|
|
@@ -1,28 +0,0 @@
|
|
|
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;
|