@integraciones_doc24/sdk 1.1.1 → 1.3.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 (250) hide show
  1. package/lib/baseSdk/diagnostica.d.ts +6 -6
  2. package/lib/baseSdk/index.js +5 -1
  3. package/lib/baseSdk/user.d.ts +4 -51
  4. package/lib/baseSdk/user.js +25 -67
  5. package/lib/index.d.ts +16 -44
  6. package/lib/lib/baseSdk/diagnostica.d.ts +11 -0
  7. package/lib/lib/baseSdk/diagnostica.js +79 -0
  8. package/lib/lib/baseSdk/index.d.ts +161 -0
  9. package/lib/lib/baseSdk/index.js +66 -0
  10. package/lib/lib/baseSdk/user.d.ts +41 -0
  11. package/lib/lib/baseSdk/user.js +130 -0
  12. package/lib/lib/index.d.ts +182 -0
  13. package/lib/lib/index.js +22 -0
  14. package/lib/lib/lib/baseSdk/diagnostica.d.ts +6 -0
  15. package/lib/lib/lib/baseSdk/diagnostica.js +79 -0
  16. package/lib/lib/lib/baseSdk/index.d.ts +51 -0
  17. package/lib/lib/lib/baseSdk/index.js +66 -0
  18. package/lib/lib/lib/baseSdk/user.d.ts +9 -0
  19. package/lib/lib/lib/baseSdk/user.js +130 -0
  20. package/lib/lib/lib/index.d.ts +168 -0
  21. package/lib/lib/lib/index.js +22 -0
  22. package/lib/lib/lib/lib/baseSdk/diagnostica.d.ts +6 -0
  23. package/lib/lib/lib/lib/baseSdk/diagnostica.js +79 -0
  24. package/lib/lib/lib/lib/baseSdk/index.d.ts +14 -0
  25. package/lib/lib/lib/lib/baseSdk/index.js +66 -0
  26. package/lib/lib/lib/lib/baseSdk/user.d.ts +9 -0
  27. package/lib/lib/lib/lib/baseSdk/user.js +130 -0
  28. package/lib/lib/lib/lib/index.d.ts +58 -0
  29. package/lib/lib/lib/lib/index.js +22 -0
  30. package/lib/lib/lib/lib/request/index.d.ts +2 -0
  31. package/lib/lib/lib/lib/request/index.js +26 -0
  32. package/lib/lib/lib/lib/request/token.d.ts +2 -0
  33. package/lib/lib/lib/lib/request/token.js +34 -0
  34. package/lib/lib/lib/lib/request/validation.d.ts +10 -0
  35. package/lib/lib/lib/lib/request/validation.js +28 -0
  36. package/lib/lib/lib/lib/schemas.d.ts +1334 -0
  37. package/lib/lib/lib/lib/schemas.js +325 -0
  38. package/lib/lib/lib/lib/test.d.ts +1 -0
  39. package/lib/lib/lib/lib/test.js +55 -0
  40. package/lib/lib/lib/lib/types.d.ts +1 -0
  41. package/lib/lib/lib/lib/types.js +2 -0
  42. package/lib/lib/lib/lib/userSdk/chat.d.ts +9 -0
  43. package/lib/lib/lib/lib/userSdk/chat.js +98 -0
  44. package/lib/lib/lib/lib/userSdk/index.d.ts +24 -0
  45. package/lib/lib/lib/lib/userSdk/index.js +27 -0
  46. package/lib/lib/lib/lib/userSdk/patients.d.ts +5 -0
  47. package/lib/lib/lib/lib/userSdk/patients.js +55 -0
  48. package/lib/lib/lib/lib/userSdk/schedule.d.ts +7 -0
  49. package/lib/lib/lib/lib/userSdk/schedule.js +76 -0
  50. package/lib/lib/lib/lib/userSdk/specialties.d.ts +4 -0
  51. package/lib/lib/lib/lib/userSdk/specialties.js +19 -0
  52. package/lib/lib/lib/lib/userSdk/videoVisit.d.ts +10 -0
  53. package/lib/lib/lib/lib/userSdk/videoVisit.js +147 -0
  54. package/lib/lib/lib/lib/utils.d.ts +4 -0
  55. package/lib/lib/lib/lib/utils.js +19 -0
  56. package/lib/lib/lib/lib/webhook/index.d.ts +8 -0
  57. package/lib/lib/lib/lib/webhook/index.js +55 -0
  58. package/lib/lib/lib/lib/webhook/responses.d.ts +36 -0
  59. package/lib/lib/lib/lib/webhook/responses.js +42 -0
  60. package/lib/lib/lib/lib/webhook/token.d.ts +2 -0
  61. package/lib/lib/lib/lib/webhook/token.js +23 -0
  62. package/lib/lib/lib/request/index.d.ts +2 -0
  63. package/lib/lib/lib/request/index.js +26 -0
  64. package/lib/lib/lib/request/token.d.ts +2 -0
  65. package/lib/lib/lib/request/token.js +34 -0
  66. package/lib/lib/lib/request/validation.d.ts +10 -0
  67. package/lib/lib/lib/request/validation.js +28 -0
  68. package/lib/lib/lib/schemas.d.ts +1334 -0
  69. package/lib/lib/lib/schemas.js +325 -0
  70. package/lib/lib/lib/src/baseSdk/diagnostica.d.ts +6 -0
  71. package/lib/lib/lib/src/baseSdk/diagnostica.js +79 -0
  72. package/lib/lib/lib/src/baseSdk/index.d.ts +51 -0
  73. package/lib/lib/lib/src/baseSdk/index.js +66 -0
  74. package/lib/lib/lib/src/baseSdk/user.d.ts +9 -0
  75. package/lib/lib/lib/src/baseSdk/user.js +130 -0
  76. package/lib/lib/lib/src/index.d.ts +169 -0
  77. package/lib/lib/lib/src/index.js +22 -0
  78. package/lib/lib/lib/src/request/index.d.ts +2 -0
  79. package/lib/lib/lib/src/request/index.js +26 -0
  80. package/lib/lib/lib/src/request/token.d.ts +2 -0
  81. package/lib/lib/lib/src/request/token.js +34 -0
  82. package/lib/lib/lib/src/request/validation.d.ts +10 -0
  83. package/lib/lib/lib/src/request/validation.js +28 -0
  84. package/lib/lib/lib/src/schemas.d.ts +1340 -0
  85. package/lib/lib/lib/src/schemas.js +325 -0
  86. package/lib/lib/lib/src/types.d.ts +1 -0
  87. package/lib/lib/lib/src/types.js +2 -0
  88. package/lib/lib/lib/src/userSdk/chat.d.ts +9 -0
  89. package/lib/lib/lib/src/userSdk/chat.js +98 -0
  90. package/lib/lib/lib/src/userSdk/index.d.ts +102 -0
  91. package/lib/lib/lib/src/userSdk/index.js +27 -0
  92. package/lib/lib/lib/src/userSdk/patients.d.ts +5 -0
  93. package/lib/lib/lib/src/userSdk/patients.js +55 -0
  94. package/lib/lib/lib/src/userSdk/schedule.d.ts +7 -0
  95. package/lib/lib/lib/src/userSdk/schedule.js +76 -0
  96. package/lib/lib/lib/src/userSdk/specialties.d.ts +4 -0
  97. package/lib/lib/lib/src/userSdk/specialties.js +19 -0
  98. package/lib/lib/lib/src/userSdk/videoVisit.d.ts +10 -0
  99. package/lib/lib/lib/src/userSdk/videoVisit.js +147 -0
  100. package/lib/lib/lib/src/utils.d.ts +4 -0
  101. package/lib/lib/lib/src/utils.js +19 -0
  102. package/lib/lib/lib/src/webhook/index.d.ts +8 -0
  103. package/lib/lib/lib/src/webhook/index.js +55 -0
  104. package/lib/lib/lib/src/webhook/responses.d.ts +36 -0
  105. package/lib/lib/lib/src/webhook/responses.js +42 -0
  106. package/lib/lib/lib/src/webhook/token.d.ts +2 -0
  107. package/lib/lib/lib/src/webhook/token.js +23 -0
  108. package/lib/lib/lib/test.d.ts +1 -0
  109. package/lib/lib/lib/test.js +55 -0
  110. package/lib/lib/lib/types.d.ts +1 -0
  111. package/lib/lib/lib/types.js +2 -0
  112. package/lib/lib/lib/userSdk/chat.d.ts +9 -0
  113. package/lib/lib/lib/userSdk/chat.js +98 -0
  114. package/lib/lib/lib/userSdk/index.d.ts +102 -0
  115. package/lib/lib/lib/userSdk/index.js +27 -0
  116. package/lib/lib/lib/userSdk/patients.d.ts +5 -0
  117. package/lib/lib/lib/userSdk/patients.js +55 -0
  118. package/lib/lib/lib/userSdk/schedule.d.ts +7 -0
  119. package/lib/lib/lib/userSdk/schedule.js +76 -0
  120. package/lib/lib/lib/userSdk/specialties.d.ts +4 -0
  121. package/lib/lib/lib/userSdk/specialties.js +19 -0
  122. package/lib/lib/lib/userSdk/videoVisit.d.ts +10 -0
  123. package/lib/lib/lib/userSdk/videoVisit.js +147 -0
  124. package/lib/lib/lib/utils.d.ts +4 -0
  125. package/lib/lib/lib/utils.js +19 -0
  126. package/lib/lib/lib/webhook/index.d.ts +8 -0
  127. package/lib/lib/lib/webhook/index.js +55 -0
  128. package/lib/lib/lib/webhook/responses.d.ts +36 -0
  129. package/lib/lib/lib/webhook/responses.js +42 -0
  130. package/lib/lib/lib/webhook/token.d.ts +2 -0
  131. package/lib/lib/lib/webhook/token.js +23 -0
  132. package/lib/lib/request/index.d.ts +2 -0
  133. package/lib/lib/request/index.js +26 -0
  134. package/lib/lib/request/token.d.ts +2 -0
  135. package/lib/lib/request/token.js +34 -0
  136. package/lib/lib/request/validation.d.ts +10 -0
  137. package/lib/lib/request/validation.js +28 -0
  138. package/lib/lib/schemas.d.ts +1334 -0
  139. package/lib/lib/schemas.js +325 -0
  140. package/lib/lib/src/baseSdk/diagnostica.d.ts +11 -0
  141. package/lib/lib/src/baseSdk/diagnostica.js +79 -0
  142. package/lib/lib/src/baseSdk/index.d.ts +162 -0
  143. package/lib/lib/src/baseSdk/index.js +66 -0
  144. package/lib/lib/src/baseSdk/user.d.ts +41 -0
  145. package/lib/lib/src/baseSdk/user.js +130 -0
  146. package/lib/lib/src/index.d.ts +183 -0
  147. package/lib/lib/src/index.js +22 -0
  148. package/lib/lib/src/request/index.d.ts +2 -0
  149. package/lib/lib/src/request/index.js +26 -0
  150. package/lib/lib/src/request/token.d.ts +2 -0
  151. package/lib/lib/src/request/token.js +34 -0
  152. package/lib/lib/src/request/validation.d.ts +10 -0
  153. package/lib/lib/src/request/validation.js +28 -0
  154. package/lib/lib/src/schemas.d.ts +1340 -0
  155. package/lib/lib/src/schemas.js +325 -0
  156. package/lib/lib/src/types.d.ts +1 -0
  157. package/lib/lib/src/types.js +2 -0
  158. package/lib/lib/src/userSdk/chat.d.ts +9 -0
  159. package/lib/lib/src/userSdk/chat.js +98 -0
  160. package/lib/lib/src/userSdk/index.d.ts +241 -0
  161. package/lib/lib/src/userSdk/index.js +27 -0
  162. package/lib/lib/src/userSdk/patients.d.ts +13 -0
  163. package/lib/lib/src/userSdk/patients.js +55 -0
  164. package/lib/lib/src/userSdk/schedule.d.ts +15 -0
  165. package/lib/lib/src/userSdk/schedule.js +76 -0
  166. package/lib/lib/src/userSdk/specialties.d.ts +4 -0
  167. package/lib/lib/src/userSdk/specialties.js +19 -0
  168. package/lib/lib/src/userSdk/videoVisit.d.ts +72 -0
  169. package/lib/lib/src/userSdk/videoVisit.js +147 -0
  170. package/lib/lib/src/utils.d.ts +4 -0
  171. package/lib/lib/src/utils.js +19 -0
  172. package/lib/lib/src/webhook/index.d.ts +8 -0
  173. package/lib/lib/src/webhook/index.js +55 -0
  174. package/lib/lib/src/webhook/responses.d.ts +36 -0
  175. package/lib/lib/src/webhook/responses.js +42 -0
  176. package/lib/lib/src/webhook/token.d.ts +2 -0
  177. package/lib/lib/src/webhook/token.js +23 -0
  178. package/lib/lib/test.d.ts +1 -0
  179. package/lib/lib/test.js +55 -0
  180. package/lib/lib/types.d.ts +1 -0
  181. package/lib/lib/types.js +2 -0
  182. package/lib/lib/userSdk/chat.d.ts +9 -0
  183. package/lib/lib/userSdk/chat.js +98 -0
  184. package/lib/lib/userSdk/index.d.ts +240 -0
  185. package/lib/lib/userSdk/index.js +27 -0
  186. package/lib/lib/userSdk/patients.d.ts +13 -0
  187. package/lib/lib/userSdk/patients.js +55 -0
  188. package/lib/lib/userSdk/schedule.d.ts +15 -0
  189. package/lib/lib/userSdk/schedule.js +76 -0
  190. package/lib/lib/userSdk/specialties.d.ts +4 -0
  191. package/lib/lib/userSdk/specialties.js +19 -0
  192. package/lib/lib/userSdk/videoVisit.d.ts +72 -0
  193. package/lib/lib/userSdk/videoVisit.js +147 -0
  194. package/lib/lib/utils.d.ts +4 -0
  195. package/lib/lib/utils.js +19 -0
  196. package/lib/lib/webhook/index.d.ts +8 -0
  197. package/lib/lib/webhook/index.js +55 -0
  198. package/lib/lib/webhook/responses.d.ts +36 -0
  199. package/lib/lib/webhook/responses.js +42 -0
  200. package/lib/lib/webhook/token.d.ts +2 -0
  201. package/lib/lib/webhook/token.js +23 -0
  202. package/lib/schemas.d.ts +30 -220
  203. package/lib/schemas.js +2 -33
  204. package/lib/src/baseSdk/diagnostica.d.ts +54 -0
  205. package/lib/src/baseSdk/diagnostica.js +79 -0
  206. package/lib/src/baseSdk/index.d.ts +2 -0
  207. package/lib/src/baseSdk/index.js +66 -0
  208. package/lib/src/baseSdk/user.d.ts +89 -0
  209. package/lib/src/baseSdk/user.js +130 -0
  210. package/lib/src/index.d.ts +188 -0
  211. package/lib/src/index.js +22 -0
  212. package/lib/src/request/index.d.ts +3 -0
  213. package/lib/src/request/index.js +26 -0
  214. package/lib/src/request/token.d.ts +2 -0
  215. package/lib/src/request/token.js +34 -0
  216. package/lib/src/request/validation.d.ts +10 -0
  217. package/lib/src/request/validation.js +28 -0
  218. package/lib/src/schemas.d.ts +1311 -0
  219. package/lib/src/schemas.js +325 -0
  220. package/lib/src/types.d.ts +124 -0
  221. package/lib/src/types.js +2 -0
  222. package/lib/src/userSdk/chat.d.ts +57 -0
  223. package/lib/src/userSdk/chat.js +98 -0
  224. package/lib/src/userSdk/index.d.ts +2 -0
  225. package/lib/src/userSdk/index.js +27 -0
  226. package/lib/src/userSdk/patients.d.ts +33 -0
  227. package/lib/src/userSdk/patients.js +55 -0
  228. package/lib/src/userSdk/schedule.d.ts +44 -0
  229. package/lib/src/userSdk/schedule.js +76 -0
  230. package/lib/src/userSdk/specialties.d.ts +7 -0
  231. package/lib/src/userSdk/specialties.js +19 -0
  232. package/lib/src/userSdk/videoVisit.d.ts +111 -0
  233. package/lib/src/userSdk/videoVisit.js +147 -0
  234. package/lib/src/utils.d.ts +4 -0
  235. package/lib/src/utils.js +19 -0
  236. package/lib/src/webhook/index.d.ts +2 -0
  237. package/lib/src/webhook/index.js +55 -0
  238. package/lib/src/webhook/responses.d.ts +35 -0
  239. package/lib/src/webhook/responses.js +42 -0
  240. package/lib/src/webhook/token.d.ts +2 -0
  241. package/lib/src/webhook/token.js +23 -0
  242. package/lib/test.js +1 -36
  243. package/lib/types.d.ts +2 -10
  244. package/lib/userSdk/chat.d.ts +1 -1
  245. package/lib/userSdk/patients.d.ts +2 -22
  246. package/lib/userSdk/patients.js +6 -34
  247. package/lib/userSdk/videoVisit.d.ts +2 -2
  248. package/lib/utils.d.ts +1 -1
  249. package/lib/utils.js +3 -3
  250. package/package.json +1 -1
@@ -11,22 +11,22 @@ export declare const getDiagnosticaMethods: (makeRequest: RequestMaker) => {
11
11
  deepLink: string;
12
12
  }[]>;
13
13
  getDiagnosticaDeepLink: (kiosk: string, user: {
14
+ language: string;
14
15
  firstName: string;
15
16
  lastName: string;
17
+ birthday: Date;
16
18
  identificationType: "dni";
17
19
  identificationValue: string;
18
20
  gender: "m" | "f";
19
21
  phone: string;
20
22
  email: string;
21
- language: string;
22
- birthday: Date;
23
23
  }, patient: {
24
24
  firstName: string;
25
25
  lastName: string;
26
+ birthday: Date;
26
27
  identificationType: "dni";
27
28
  identificationValue: string;
28
29
  gender: "m" | "f";
29
- birthday: Date;
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
+ language: string;
37
38
  firstName: string;
38
39
  lastName: string;
40
+ birthday: Date;
39
41
  identificationType: "dni";
40
42
  identificationValue: string;
41
43
  gender: "m" | "f";
42
44
  phone: string;
43
45
  email: string;
44
- language: string;
45
- birthday: Date;
46
46
  }, patient: {
47
47
  firstName: string;
48
48
  lastName: string;
49
+ birthday: Date;
49
50
  identificationType: "dni";
50
51
  identificationValue: string;
51
52
  gender: "m" | "f";
52
- birthday: Date;
53
53
  }) => Promise<void>;
54
54
  };
@@ -48,9 +48,13 @@ const getBaseSdk = async (url, credentials) => {
48
48
  id: s.id_especialidad,
49
49
  description: s.especialidad,
50
50
  });
51
+ const mapSpecialityER = (s) => ({
52
+ id: s.specialty_id,
53
+ description: s.specialty,
54
+ });
51
55
  const mapped = {
52
56
  specialties: response.data.specialties.map(mapSpeciality),
53
- specialtiesER: response.data.specialties_er.map(mapSpeciality),
57
+ specialtiesER: response.data.specialties_er.map(mapSpecialityER),
54
58
  professionals: response.data.professionals.map((p) => ({
55
59
  id: p.id_profesional,
56
60
  fullName: p.denominacion,
@@ -1,72 +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
- code?: string | undefined;
6
- channel?: "1" | "2" | undefined;
7
- user: {
8
- firstName: string;
9
- lastName: string;
10
- identificationType: "ndi" | "passport" | "credential";
11
- identificationValue: string;
12
- countryId: string;
13
- birthdate: Date;
14
- gender: "m" | "f";
15
- phone: string;
16
- email: string;
17
- };
18
- }) => Promise<{
19
- patientId: number | null;
20
- userInfo: {
21
- phone: string;
22
- email: string;
23
- };
24
- askCode: boolean;
25
- userId: number;
26
- }>;
27
- getUserId: (user: {
4
+ declareUser: (user: {
28
5
  firstName: string;
29
6
  lastName: string;
30
7
  identificationType: "ndi" | "passport" | "credential";
31
8
  identificationValue: string;
32
- countryId: string;
33
- birthdate: Date;
34
9
  gender: "m" | "f";
35
10
  phone: string;
36
11
  email: string;
37
- }) => Promise<number>;
38
- sendVerificationCode: (params: {
39
- identificationType: "ndi" | "passport" | "credential";
40
- identificationValue: string;
41
- channel: "1" | "2";
42
- }) => Promise<any>;
43
- getUserInstance: (user: number | {
44
- firstName: string;
45
- lastName: string;
46
- identificationType: "ndi" | "passport" | "credential";
47
- identificationValue: string;
48
12
  countryId: string;
49
13
  birthdate: Date;
50
- gender: "m" | "f";
51
- phone: string;
52
- email: string;
53
14
  }) => Promise<any>;
54
- enroll: (params: {
55
- firstName: string;
56
- lastName: string;
57
- birthdate: Date;
58
- gender: "m" | "f";
59
- email: string;
60
- startDate: Date;
61
- identificationNumber: string;
62
- plan: string;
63
- }) => Promise<void>;
15
+ getUserInstance: (...params: any) => Promise<any>;
16
+ enroll: (...params: any) => Promise<void>;
64
17
  getConverageInfo: (identificationValue: string) => Promise<{
65
18
  firstName: string | null;
66
19
  lastName: string | null;
67
- birthdate: Date;
68
20
  gender: "m" | "f";
69
21
  email: string | null;
22
+ birthdate: Date;
70
23
  identificationNumber: string;
71
24
  plan: string | null;
72
25
  financerId: number | null;
@@ -8,39 +8,11 @@ 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
- 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
11
  const getUserId = async (user) => {
39
- const path = '/user';
40
12
  const mappedUser = {
41
13
  lastname: user.lastName,
42
14
  firstname: user.firstName,
43
- identification_type: utils_1.getIdetificationTypeId(user.identificationType),
15
+ identification_type: utils_1.getIndetificationTypeId(user.identificationType),
44
16
  identification_value: user.identificationValue,
45
17
  birthdate: date_fns_1.format(user.birthdate, 'yyyy-MM-dd'),
46
18
  gender: user.gender.toUpperCase(),
@@ -48,41 +20,12 @@ const getUserMethods = (makeRequest, url, credentials) => {
48
20
  email: user.email,
49
21
  country_id: user.countryId,
50
22
  };
51
- const response = await makeRequest('POST', path, {
23
+ const response = await makeRequest('POST', '/user', {
52
24
  user_data: mappedUser,
53
25
  });
54
26
  return response.data.user_id;
55
27
  };
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) => {
28
+ const getConverageInfo = validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.coverageInfo, async (identificationValue) => {
86
29
  const path = `/info-coverage/${identificationValue}`;
87
30
  const response = await makeRequest('GET', path);
88
31
  const raw = response.data.info;
@@ -115,16 +58,31 @@ const getUserMethods = (makeRequest, url, credentials) => {
115
58
  : null,
116
59
  };
117
60
  return mappedCoverageInfo;
118
- };
61
+ });
119
62
  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),
63
+ declareUser: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.user]), zod_1.number(), getUserId),
123
64
  getUserInstance: validation_1.validateFunction(zod_1.tuple([zod_1.union([schemas_1.doc24Schemas.user, zod_1.number()])]),
124
65
  // 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),
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,
128
86
  };
129
87
  };
130
88
  exports.getUserMethods = getUserMethods;
package/lib/index.d.ts CHANGED
@@ -5,60 +5,37 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
5
5
  eventHandlers: Doc24.Webhook.Events;
6
6
  baseAddress: string;
7
7
  }) => Promise<Doc24.Webhook.Handler>;
8
- declareUser: (params: {
9
- code?: string | undefined;
10
- channel?: "1" | "2" | undefined;
11
- user: {
12
- firstName: string;
13
- lastName: string;
14
- identificationType: "ndi" | "passport" | "credential";
15
- identificationValue: string;
16
- countryId: string;
17
- birthdate: Date;
18
- gender: "m" | "f";
19
- phone: string;
20
- email: string;
21
- };
22
- }) => Promise<{
23
- patientId: number | null;
24
- userInfo: {
25
- phone: string;
26
- email: string;
27
- };
28
- askCode: boolean;
29
- userId: number;
30
- }>;
31
- getUserId: (user: {
8
+ declareUser: (user: {
32
9
  firstName: string;
33
10
  lastName: string;
34
11
  identificationType: "ndi" | "passport" | "credential";
35
12
  identificationValue: string;
36
- countryId: string;
37
- birthdate: Date;
38
13
  gender: "m" | "f";
39
14
  phone: string;
40
15
  email: string;
16
+ countryId: string;
17
+ birthdate: Date;
41
18
  }) => Promise<number>;
42
19
  getUserInstance: (user: number | {
43
20
  firstName: string;
44
21
  lastName: string;
45
22
  identificationType: "ndi" | "passport" | "credential";
46
23
  identificationValue: string;
47
- countryId: string;
48
- birthdate: Date;
49
24
  gender: "m" | "f";
50
25
  phone: string;
51
26
  email: string;
27
+ countryId: string;
28
+ birthdate: Date;
52
29
  }) => Promise<Doc24.UserSdk>;
53
30
  getProfessional: (professionalId: number) => Promise<{
31
+ id: number;
32
+ logoUrl: string;
54
33
  firstName: string;
55
34
  lastName: string;
56
- birthdate: Date;
57
35
  gender: "m" | "f";
58
36
  phone: string | null;
59
37
  email: string;
60
- id: number;
61
- logoUrl: string;
38
+ birthdate: Date;
62
39
  specialties: {
63
40
  id: number;
64
41
  description: string;
@@ -96,9 +73,9 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
96
73
  enroll: (params: {
97
74
  firstName: string;
98
75
  lastName: string;
99
- birthdate: Date;
100
76
  gender: "m" | "f";
101
77
  email: string;
78
+ birthdate: Date;
102
79
  startDate: Date;
103
80
  identificationNumber: string;
104
81
  plan: string;
@@ -106,9 +83,9 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
106
83
  getConverageInfo: (identificationValue: string) => Promise<{
107
84
  firstName: string | null;
108
85
  lastName: string | null;
109
- birthdate: Date;
110
86
  gender: "m" | "f";
111
87
  email: string | null;
88
+ birthdate: Date;
112
89
  identificationNumber: string;
113
90
  plan: string | null;
114
91
  financerId: number | null;
@@ -127,11 +104,6 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
127
104
  authorizationCode: string | null;
128
105
  authorizationCodeExpiration: Date | null;
129
106
  } | null>;
130
- sendVerificationCode: (params: {
131
- identificationType: "ndi" | "passport" | "credential";
132
- identificationValue: string;
133
- channel: "1" | "2";
134
- }) => Promise<any>;
135
107
  getDiagnosticaHistory: (patient: {
136
108
  identificationType: "ndi" | "passport" | "credential";
137
109
  identificationValue: string;
@@ -143,22 +115,22 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
143
115
  deepLink: string;
144
116
  }[]>;
145
117
  getDiagnosticaDeepLink: (kiosk: string, user: {
118
+ language: string;
146
119
  firstName: string;
147
120
  lastName: string;
121
+ birthday: Date;
148
122
  identificationType: "dni";
149
123
  identificationValue: string;
150
124
  gender: "m" | "f";
151
125
  phone: string;
152
126
  email: string;
153
- language: string;
154
- birthday: Date;
155
127
  }, patient: {
156
128
  firstName: string;
157
129
  lastName: string;
130
+ birthday: Date;
158
131
  identificationType: "dni";
159
132
  identificationValue: string;
160
133
  gender: "m" | "f";
161
- birthday: Date;
162
134
  }) => Promise<{
163
135
  forwardingRequired: true;
164
136
  deepLink: string;
@@ -166,22 +138,22 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
166
138
  forwardingRequired: false;
167
139
  }>;
168
140
  getDiagnosticaAccess: (kiosk: string, user: {
141
+ language: string;
169
142
  firstName: string;
170
143
  lastName: string;
144
+ birthday: Date;
171
145
  identificationType: "dni";
172
146
  identificationValue: string;
173
147
  gender: "m" | "f";
174
148
  phone: string;
175
149
  email: string;
176
- language: string;
177
- birthday: Date;
178
150
  }, patient: {
179
151
  firstName: string;
180
152
  lastName: string;
153
+ birthday: Date;
181
154
  identificationType: "dni";
182
155
  identificationValue: string;
183
156
  gender: "m" | "f";
184
- birthday: Date;
185
157
  }) => Promise<void>;
186
158
  }>;
187
159
  export type { Doc24 } from './types';
@@ -0,0 +1,11 @@
1
+ export var __esModule: boolean;
2
+ export function getDiagnosticaMethods(makeRequest: any): {
3
+ getDiagnosticaHistory: (...params: any) => Promise<any>;
4
+ getDiagnosticaDeepLink: (...params: any) => Promise<{
5
+ forwardingRequired: true;
6
+ deepLink: string;
7
+ } | {
8
+ forwardingRequired: false;
9
+ }>;
10
+ getDiagnosticaAccess: (...params: any) => Promise<void>;
11
+ };
@@ -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,161 @@
1
+ export var __esModule: boolean;
2
+ export function getBaseSdk(url: any, credentials: any): Promise<{
3
+ getProfessional: (...params: any) => Promise<{
4
+ id: any;
5
+ firstName: any;
6
+ lastName: any;
7
+ birthdate: Date;
8
+ gender: any;
9
+ email: any;
10
+ phone: any;
11
+ logoUrl: any;
12
+ matriculation: any;
13
+ specialties: any;
14
+ degree: any;
15
+ languages: any;
16
+ resume: {
17
+ link: any;
18
+ brief: any;
19
+ };
20
+ }>;
21
+ getAvailableScheduleClinics: () => Promise<{
22
+ specialties: any;
23
+ specialtiesER: any;
24
+ professionals: any;
25
+ }>;
26
+ declareUser: (params: {
27
+ code?: string | undefined;
28
+ channel?: "1" | "2" | undefined;
29
+ user: {
30
+ firstName: string;
31
+ lastName: string;
32
+ identificationType: "ndi" | "passport" | "credential";
33
+ identificationValue: string;
34
+ countryId: string;
35
+ birthdate: Date;
36
+ gender: "m" | "f";
37
+ phone: string;
38
+ email: string;
39
+ };
40
+ }) => Promise<{
41
+ patientId: number | null;
42
+ userInfo: {
43
+ phone: string;
44
+ email: string;
45
+ };
46
+ askCode: boolean;
47
+ userId: number;
48
+ }>;
49
+ getUserId: (user: {
50
+ firstName: string;
51
+ lastName: string;
52
+ identificationType: "ndi" | "passport" | "credential";
53
+ identificationValue: string;
54
+ countryId: string;
55
+ birthdate: Date;
56
+ gender: "m" | "f";
57
+ phone: string;
58
+ email: string;
59
+ }) => Promise<number>;
60
+ sendVerificationCode: (params: {
61
+ identificationType: "ndi" | "passport" | "credential";
62
+ identificationValue: string;
63
+ channel: "1" | "2";
64
+ }) => Promise<any>;
65
+ getUserInstance: (user: number | {
66
+ firstName: string;
67
+ lastName: string;
68
+ identificationType: "ndi" | "passport" | "credential";
69
+ identificationValue: string;
70
+ countryId: string;
71
+ birthdate: Date;
72
+ gender: "m" | "f";
73
+ phone: string;
74
+ email: string;
75
+ }) => Promise<any>;
76
+ enroll: (params: {
77
+ firstName: string;
78
+ lastName: string;
79
+ birthdate: Date;
80
+ gender: "m" | "f";
81
+ email: string;
82
+ startDate: Date;
83
+ identificationNumber: string;
84
+ plan: string;
85
+ }) => Promise<void>;
86
+ getConverageInfo: (identificationValue: string) => Promise<{
87
+ firstName: string | null;
88
+ lastName: string | null;
89
+ birthdate: Date;
90
+ gender: "m" | "f";
91
+ email: string | null;
92
+ identificationNumber: string;
93
+ plan: string | null;
94
+ financerId: number | null;
95
+ defaultAffiliationId: number | null;
96
+ credentialNumber: string | null;
97
+ financerPlanId: number | null;
98
+ brand: number | null;
99
+ holderIdentificationNumber: string | null;
100
+ copaymentValue: number | null;
101
+ mobilePhone: string | null;
102
+ company: string | null;
103
+ dischargeDate: Date | null;
104
+ leavingDate: Date | null;
105
+ identificacion_tributaria: string | null;
106
+ deregistrationDate: Date | null;
107
+ authorizationCode: string | null;
108
+ authorizationCodeExpiration: Date | null;
109
+ } | null>;
110
+ getDiagnosticaHistory: (patient: {
111
+ identificationType: "ndi" | "passport" | "credential";
112
+ identificationValue: string;
113
+ gender: "m" | "f";
114
+ }, from: Date, to: Date) => Promise<{
115
+ date: Date;
116
+ location: string;
117
+ exams: string[];
118
+ deepLink: string;
119
+ }[]>;
120
+ getDiagnosticaDeepLink: (kiosk: string, user: {
121
+ firstName: string;
122
+ lastName: string;
123
+ identificationType: "dni";
124
+ identificationValue: string;
125
+ gender: "m" | "f";
126
+ phone: string;
127
+ email: string;
128
+ language: string;
129
+ birthday: Date;
130
+ }, patient: {
131
+ firstName: string;
132
+ lastName: string;
133
+ identificationType: "dni";
134
+ identificationValue: string;
135
+ gender: "m" | "f";
136
+ birthday: Date;
137
+ }) => Promise<{
138
+ forwardingRequired: true;
139
+ deepLink: string;
140
+ } | {
141
+ forwardingRequired: false;
142
+ }>;
143
+ getDiagnosticaAccess: (kiosk: string, user: {
144
+ firstName: string;
145
+ lastName: string;
146
+ identificationType: "dni";
147
+ identificationValue: string;
148
+ gender: "m" | "f";
149
+ phone: string;
150
+ email: string;
151
+ language: string;
152
+ birthday: Date;
153
+ }, patient: {
154
+ firstName: string;
155
+ lastName: string;
156
+ identificationType: "dni";
157
+ identificationValue: string;
158
+ gender: "m" | "f";
159
+ birthday: Date;
160
+ }) => Promise<void>;
161
+ }>;