@integraciones_doc24/sdk 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/lib/baseSdk/user.d.ts +3 -2
  2. package/lib/index.d.ts +3 -2
  3. package/lib/lib/baseSdk/diagnostica.d.ts +11 -0
  4. package/lib/lib/baseSdk/diagnostica.js +79 -0
  5. package/lib/lib/baseSdk/index.d.ts +161 -0
  6. package/lib/lib/baseSdk/index.js +66 -0
  7. package/lib/lib/baseSdk/user.d.ts +41 -0
  8. package/lib/lib/baseSdk/user.js +130 -0
  9. package/lib/lib/index.d.ts +182 -0
  10. package/lib/lib/index.js +22 -0
  11. package/lib/lib/lib/baseSdk/diagnostica.d.ts +6 -0
  12. package/lib/lib/lib/baseSdk/diagnostica.js +79 -0
  13. package/lib/lib/lib/baseSdk/index.d.ts +51 -0
  14. package/lib/lib/lib/baseSdk/index.js +66 -0
  15. package/lib/lib/lib/baseSdk/user.d.ts +9 -0
  16. package/lib/lib/lib/baseSdk/user.js +130 -0
  17. package/lib/lib/lib/index.d.ts +168 -0
  18. package/lib/lib/lib/index.js +22 -0
  19. package/lib/lib/lib/request/index.d.ts +2 -0
  20. package/lib/lib/lib/request/index.js +26 -0
  21. package/lib/lib/lib/request/token.d.ts +2 -0
  22. package/lib/lib/lib/request/token.js +34 -0
  23. package/lib/lib/lib/request/validation.d.ts +10 -0
  24. package/lib/lib/lib/request/validation.js +28 -0
  25. package/lib/lib/lib/schemas.d.ts +1334 -0
  26. package/lib/lib/lib/schemas.js +325 -0
  27. package/lib/lib/lib/test.d.ts +1 -0
  28. package/lib/lib/lib/test.js +55 -0
  29. package/lib/lib/lib/types.d.ts +1 -0
  30. package/lib/lib/lib/types.js +2 -0
  31. package/lib/lib/lib/userSdk/chat.d.ts +9 -0
  32. package/lib/lib/lib/userSdk/chat.js +98 -0
  33. package/lib/lib/lib/userSdk/index.d.ts +102 -0
  34. package/lib/lib/lib/userSdk/index.js +27 -0
  35. package/lib/lib/lib/userSdk/patients.d.ts +5 -0
  36. package/lib/lib/lib/userSdk/patients.js +55 -0
  37. package/lib/lib/lib/userSdk/schedule.d.ts +7 -0
  38. package/lib/lib/lib/userSdk/schedule.js +76 -0
  39. package/lib/lib/lib/userSdk/specialties.d.ts +4 -0
  40. package/lib/lib/lib/userSdk/specialties.js +19 -0
  41. package/lib/lib/lib/userSdk/videoVisit.d.ts +10 -0
  42. package/lib/lib/lib/userSdk/videoVisit.js +147 -0
  43. package/lib/lib/lib/utils.d.ts +4 -0
  44. package/lib/lib/lib/utils.js +19 -0
  45. package/lib/lib/lib/webhook/index.d.ts +8 -0
  46. package/lib/lib/lib/webhook/index.js +55 -0
  47. package/lib/lib/lib/webhook/responses.d.ts +36 -0
  48. package/lib/lib/lib/webhook/responses.js +42 -0
  49. package/lib/lib/lib/webhook/token.d.ts +2 -0
  50. package/lib/lib/lib/webhook/token.js +23 -0
  51. package/lib/lib/request/index.d.ts +2 -0
  52. package/lib/lib/request/index.js +26 -0
  53. package/lib/lib/request/token.d.ts +2 -0
  54. package/lib/lib/request/token.js +34 -0
  55. package/lib/lib/request/validation.d.ts +10 -0
  56. package/lib/lib/request/validation.js +28 -0
  57. package/lib/lib/schemas.d.ts +1334 -0
  58. package/lib/lib/schemas.js +325 -0
  59. package/lib/lib/src/baseSdk/diagnostica.d.ts +11 -0
  60. package/lib/lib/src/baseSdk/diagnostica.js +79 -0
  61. package/lib/lib/src/baseSdk/index.d.ts +162 -0
  62. package/lib/lib/src/baseSdk/index.js +66 -0
  63. package/lib/lib/src/baseSdk/user.d.ts +41 -0
  64. package/lib/lib/src/baseSdk/user.js +130 -0
  65. package/lib/lib/src/index.d.ts +183 -0
  66. package/lib/lib/src/index.js +22 -0
  67. package/lib/lib/src/request/index.d.ts +2 -0
  68. package/lib/lib/src/request/index.js +26 -0
  69. package/lib/lib/src/request/token.d.ts +2 -0
  70. package/lib/lib/src/request/token.js +34 -0
  71. package/lib/lib/src/request/validation.d.ts +10 -0
  72. package/lib/lib/src/request/validation.js +28 -0
  73. package/lib/lib/src/schemas.d.ts +1340 -0
  74. package/lib/lib/src/schemas.js +325 -0
  75. package/lib/lib/src/types.d.ts +1 -0
  76. package/lib/lib/src/types.js +2 -0
  77. package/lib/lib/src/userSdk/chat.d.ts +9 -0
  78. package/lib/lib/src/userSdk/chat.js +98 -0
  79. package/lib/lib/src/userSdk/index.d.ts +241 -0
  80. package/lib/lib/src/userSdk/index.js +27 -0
  81. package/lib/lib/src/userSdk/patients.d.ts +13 -0
  82. package/lib/lib/src/userSdk/patients.js +55 -0
  83. package/lib/lib/src/userSdk/schedule.d.ts +15 -0
  84. package/lib/lib/src/userSdk/schedule.js +76 -0
  85. package/lib/lib/src/userSdk/specialties.d.ts +4 -0
  86. package/lib/lib/src/userSdk/specialties.js +19 -0
  87. package/lib/lib/src/userSdk/videoVisit.d.ts +72 -0
  88. package/lib/lib/src/userSdk/videoVisit.js +147 -0
  89. package/lib/lib/src/utils.d.ts +4 -0
  90. package/lib/lib/src/utils.js +19 -0
  91. package/lib/lib/src/webhook/index.d.ts +8 -0
  92. package/lib/lib/src/webhook/index.js +55 -0
  93. package/lib/lib/src/webhook/responses.d.ts +36 -0
  94. package/lib/lib/src/webhook/responses.js +42 -0
  95. package/lib/lib/src/webhook/token.d.ts +2 -0
  96. package/lib/lib/src/webhook/token.js +23 -0
  97. package/lib/lib/test.d.ts +1 -0
  98. package/lib/lib/test.js +55 -0
  99. package/lib/lib/types.d.ts +1 -0
  100. package/lib/lib/types.js +2 -0
  101. package/lib/lib/userSdk/chat.d.ts +9 -0
  102. package/lib/lib/userSdk/chat.js +98 -0
  103. package/lib/lib/userSdk/index.d.ts +240 -0
  104. package/lib/lib/userSdk/index.js +27 -0
  105. package/lib/lib/userSdk/patients.d.ts +13 -0
  106. package/lib/lib/userSdk/patients.js +55 -0
  107. package/lib/lib/userSdk/schedule.d.ts +15 -0
  108. package/lib/lib/userSdk/schedule.js +76 -0
  109. package/lib/lib/userSdk/specialties.d.ts +4 -0
  110. package/lib/lib/userSdk/specialties.js +19 -0
  111. package/lib/lib/userSdk/videoVisit.d.ts +72 -0
  112. package/lib/lib/userSdk/videoVisit.js +147 -0
  113. package/lib/lib/utils.d.ts +4 -0
  114. package/lib/lib/utils.js +19 -0
  115. package/lib/lib/webhook/index.d.ts +8 -0
  116. package/lib/lib/webhook/index.js +55 -0
  117. package/lib/lib/webhook/responses.d.ts +36 -0
  118. package/lib/lib/webhook/responses.js +42 -0
  119. package/lib/lib/webhook/token.d.ts +2 -0
  120. package/lib/lib/webhook/token.js +23 -0
  121. package/lib/schemas.d.ts +32 -16
  122. package/lib/schemas.js +6 -5
  123. package/lib/src/baseSdk/diagnostica.d.ts +54 -0
  124. package/lib/src/baseSdk/diagnostica.js +79 -0
  125. package/lib/src/baseSdk/index.d.ts +2 -0
  126. package/lib/src/baseSdk/index.js +66 -0
  127. package/lib/src/baseSdk/user.d.ts +89 -0
  128. package/lib/src/baseSdk/user.js +130 -0
  129. package/lib/src/index.d.ts +188 -0
  130. package/lib/src/index.js +22 -0
  131. package/lib/src/request/index.d.ts +3 -0
  132. package/lib/src/request/index.js +26 -0
  133. package/lib/src/request/token.d.ts +2 -0
  134. package/lib/src/request/token.js +34 -0
  135. package/lib/src/request/validation.d.ts +10 -0
  136. package/lib/src/request/validation.js +28 -0
  137. package/lib/src/schemas.d.ts +1311 -0
  138. package/lib/src/schemas.js +325 -0
  139. package/lib/src/types.d.ts +124 -0
  140. package/lib/src/types.js +2 -0
  141. package/lib/src/userSdk/chat.d.ts +57 -0
  142. package/lib/src/userSdk/chat.js +98 -0
  143. package/lib/src/userSdk/index.d.ts +2 -0
  144. package/lib/src/userSdk/index.js +27 -0
  145. package/lib/src/userSdk/patients.d.ts +33 -0
  146. package/lib/src/userSdk/patients.js +55 -0
  147. package/lib/src/userSdk/schedule.d.ts +44 -0
  148. package/lib/src/userSdk/schedule.js +76 -0
  149. package/lib/src/userSdk/specialties.d.ts +7 -0
  150. package/lib/src/userSdk/specialties.js +19 -0
  151. package/lib/src/userSdk/videoVisit.d.ts +111 -0
  152. package/lib/src/userSdk/videoVisit.js +147 -0
  153. package/lib/src/utils.d.ts +4 -0
  154. package/lib/src/utils.js +19 -0
  155. package/lib/src/webhook/index.d.ts +2 -0
  156. package/lib/src/webhook/index.js +55 -0
  157. package/lib/src/webhook/responses.d.ts +35 -0
  158. package/lib/src/webhook/responses.js +42 -0
  159. package/lib/src/webhook/token.d.ts +2 -0
  160. package/lib/src/webhook/token.js +23 -0
  161. package/lib/types.d.ts +1 -0
  162. package/lib/userSdk/patients.d.ts +3 -2
  163. package/package.json +1 -1
@@ -0,0 +1,168 @@
1
+ export var __esModule: boolean;
2
+ export function doc24Sdk(params: any): Promise<{
3
+ getRequestHandler: (params: any) => Promise<(request: any) => Promise<{
4
+ status: {
5
+ code: number;
6
+ message: string;
7
+ };
8
+ data: unknown;
9
+ }>>;
10
+ getProfessional: (...params: any) => Promise<{
11
+ id: any;
12
+ firstName: any;
13
+ lastName: any;
14
+ birthdate: Date;
15
+ gender: any;
16
+ email: any;
17
+ phone: any;
18
+ logoUrl: any;
19
+ matriculation: any;
20
+ specialties: any;
21
+ degree: any;
22
+ languages: any;
23
+ resume: {
24
+ link: any;
25
+ brief: any;
26
+ };
27
+ }>;
28
+ getAvailableScheduleClinics: () => Promise<{
29
+ specialties: any;
30
+ specialtiesER: any;
31
+ professionals: any;
32
+ }>;
33
+ declareUser: (params: {
34
+ code?: string | undefined;
35
+ channel?: "1" | "2" | undefined;
36
+ user: {
37
+ firstName: string;
38
+ lastName: string;
39
+ identificationType: "ndi" | "passport" | "credential";
40
+ identificationValue: string;
41
+ countryId: string;
42
+ birthdate: Date;
43
+ gender: "m" | "f";
44
+ phone: string;
45
+ email: string;
46
+ };
47
+ }) => Promise<{
48
+ patientId: number | null;
49
+ userInfo: {
50
+ phone: string;
51
+ email: string;
52
+ };
53
+ askCode: boolean;
54
+ userId: number;
55
+ }>;
56
+ getUserId: (user: {
57
+ firstName: string;
58
+ lastName: string;
59
+ identificationType: "ndi" | "passport" | "credential";
60
+ identificationValue: string;
61
+ countryId: string;
62
+ birthdate: Date;
63
+ gender: "m" | "f";
64
+ phone: string;
65
+ email: string;
66
+ }) => Promise<number>;
67
+ sendVerificationCode: (params: {
68
+ identificationType: "ndi" | "passport" | "credential";
69
+ identificationValue: string;
70
+ channel: "1" | "2";
71
+ }) => Promise<any>;
72
+ getUserInstance: (user: number | {
73
+ firstName: string;
74
+ lastName: string;
75
+ identificationType: "ndi" | "passport" | "credential";
76
+ identificationValue: string;
77
+ countryId: string;
78
+ birthdate: Date;
79
+ gender: "m" | "f";
80
+ phone: string;
81
+ email: string;
82
+ }) => Promise<any>;
83
+ enroll: (params: {
84
+ firstName: string;
85
+ lastName: string;
86
+ birthdate: Date;
87
+ gender: "m" | "f";
88
+ email: string;
89
+ startDate: Date;
90
+ identificationNumber: string;
91
+ plan: string;
92
+ }) => Promise<void>;
93
+ getConverageInfo: (identificationValue: string) => Promise<{
94
+ firstName: string | null;
95
+ lastName: string | null;
96
+ birthdate: Date;
97
+ gender: "m" | "f";
98
+ email: string | null;
99
+ identificationNumber: string;
100
+ plan: string | null;
101
+ financerId: number | null;
102
+ defaultAffiliationId: number | null;
103
+ credentialNumber: string | null;
104
+ financerPlanId: number | null;
105
+ brand: number | null;
106
+ holderIdentificationNumber: string | null;
107
+ copaymentValue: number | null;
108
+ mobilePhone: string | null;
109
+ company: string | null;
110
+ dischargeDate: Date | null;
111
+ leavingDate: Date | null;
112
+ identificacion_tributaria: string | null;
113
+ deregistrationDate: Date | null;
114
+ authorizationCode: string | null;
115
+ authorizationCodeExpiration: Date | null;
116
+ } | null>;
117
+ getDiagnosticaHistory: (patient: {
118
+ identificationType: "ndi" | "passport" | "credential";
119
+ identificationValue: string;
120
+ gender: "m" | "f";
121
+ }, from: Date, to: Date) => Promise<{
122
+ date: Date;
123
+ location: string;
124
+ exams: string[];
125
+ deepLink: string;
126
+ }[]>;
127
+ getDiagnosticaDeepLink: (kiosk: string, user: {
128
+ firstName: string;
129
+ lastName: string;
130
+ identificationType: "dni";
131
+ identificationValue: string;
132
+ gender: "m" | "f";
133
+ phone: string;
134
+ email: string;
135
+ language: string;
136
+ birthday: Date;
137
+ }, patient: {
138
+ firstName: string;
139
+ lastName: string;
140
+ identificationType: "dni";
141
+ identificationValue: string;
142
+ gender: "m" | "f";
143
+ birthday: Date;
144
+ }) => Promise<{
145
+ forwardingRequired: true;
146
+ deepLink: string;
147
+ } | {
148
+ forwardingRequired: false;
149
+ }>;
150
+ getDiagnosticaAccess: (kiosk: string, user: {
151
+ firstName: string;
152
+ lastName: string;
153
+ identificationType: "dni";
154
+ identificationValue: string;
155
+ gender: "m" | "f";
156
+ phone: string;
157
+ email: string;
158
+ language: string;
159
+ birthday: Date;
160
+ }, patient: {
161
+ firstName: string;
162
+ lastName: string;
163
+ identificationType: "dni";
164
+ identificationValue: string;
165
+ gender: "m" | "f";
166
+ birthday: Date;
167
+ }) => Promise<void>;
168
+ }>;
@@ -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,2 @@
1
+ export var __esModule: boolean;
2
+ export function getRequestFactory(url: any, credentials: any, userId: any): Promise<(method: any, path: any, body: any) => 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,2 @@
1
+ export var __esModule: boolean;
2
+ export function getToken(credentials: any, bodyAsJson: any, userId: any): Promise<any>;
@@ -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
+ export var __esModule: boolean;
2
+ export class ParametersValidationError extends Error {
3
+ constructor(details: any);
4
+ details: any;
5
+ }
6
+ export class ResponseValidationError extends Error {
7
+ constructor(details: any);
8
+ details: any;
9
+ }
10
+ export function validateFunction(inValidation: any, outValidation: any, fn: any): (...params: any[]) => Promise<any>;
@@ -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;