@integraciones_doc24/sdk 1.9.0 → 1.10.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 (243) hide show
  1. package/lib/baseSdk/external.d.ts +30 -1
  2. package/lib/baseSdk/external.js +59 -3
  3. package/lib/index.d.ts +29 -0
  4. package/lib/schemas.d.ts +121 -0
  5. package/lib/schemas.js +21 -0
  6. package/lib/types.d.ts +6 -0
  7. package/package.json +1 -1
  8. package/lib/lib/baseSdk/diagnostica.d.ts +0 -11
  9. package/lib/lib/baseSdk/diagnostica.js +0 -79
  10. package/lib/lib/baseSdk/index.d.ts +0 -161
  11. package/lib/lib/baseSdk/index.js +0 -66
  12. package/lib/lib/baseSdk/user.d.ts +0 -41
  13. package/lib/lib/baseSdk/user.js +0 -130
  14. package/lib/lib/index.d.ts +0 -182
  15. package/lib/lib/index.js +0 -22
  16. package/lib/lib/lib/baseSdk/diagnostica.d.ts +0 -6
  17. package/lib/lib/lib/baseSdk/diagnostica.js +0 -79
  18. package/lib/lib/lib/baseSdk/index.d.ts +0 -51
  19. package/lib/lib/lib/baseSdk/index.js +0 -66
  20. package/lib/lib/lib/baseSdk/user.d.ts +0 -9
  21. package/lib/lib/lib/baseSdk/user.js +0 -130
  22. package/lib/lib/lib/index.d.ts +0 -168
  23. package/lib/lib/lib/index.js +0 -22
  24. package/lib/lib/lib/lib/baseSdk/diagnostica.d.ts +0 -6
  25. package/lib/lib/lib/lib/baseSdk/diagnostica.js +0 -79
  26. package/lib/lib/lib/lib/baseSdk/index.d.ts +0 -14
  27. package/lib/lib/lib/lib/baseSdk/index.js +0 -66
  28. package/lib/lib/lib/lib/baseSdk/user.d.ts +0 -9
  29. package/lib/lib/lib/lib/baseSdk/user.js +0 -130
  30. package/lib/lib/lib/lib/index.d.ts +0 -58
  31. package/lib/lib/lib/lib/index.js +0 -22
  32. package/lib/lib/lib/lib/request/index.d.ts +0 -2
  33. package/lib/lib/lib/lib/request/index.js +0 -26
  34. package/lib/lib/lib/lib/request/token.d.ts +0 -2
  35. package/lib/lib/lib/lib/request/token.js +0 -34
  36. package/lib/lib/lib/lib/request/validation.d.ts +0 -10
  37. package/lib/lib/lib/lib/request/validation.js +0 -28
  38. package/lib/lib/lib/lib/schemas.d.ts +0 -1334
  39. package/lib/lib/lib/lib/schemas.js +0 -325
  40. package/lib/lib/lib/lib/test.d.ts +0 -1
  41. package/lib/lib/lib/lib/test.js +0 -55
  42. package/lib/lib/lib/lib/types.d.ts +0 -1
  43. package/lib/lib/lib/lib/types.js +0 -2
  44. package/lib/lib/lib/lib/userSdk/chat.d.ts +0 -9
  45. package/lib/lib/lib/lib/userSdk/chat.js +0 -98
  46. package/lib/lib/lib/lib/userSdk/index.d.ts +0 -24
  47. package/lib/lib/lib/lib/userSdk/index.js +0 -27
  48. package/lib/lib/lib/lib/userSdk/patients.d.ts +0 -5
  49. package/lib/lib/lib/lib/userSdk/patients.js +0 -55
  50. package/lib/lib/lib/lib/userSdk/schedule.d.ts +0 -7
  51. package/lib/lib/lib/lib/userSdk/schedule.js +0 -76
  52. package/lib/lib/lib/lib/userSdk/specialties.d.ts +0 -4
  53. package/lib/lib/lib/lib/userSdk/specialties.js +0 -19
  54. package/lib/lib/lib/lib/userSdk/videoVisit.d.ts +0 -10
  55. package/lib/lib/lib/lib/userSdk/videoVisit.js +0 -147
  56. package/lib/lib/lib/lib/utils.d.ts +0 -4
  57. package/lib/lib/lib/lib/utils.js +0 -19
  58. package/lib/lib/lib/lib/webhook/index.d.ts +0 -8
  59. package/lib/lib/lib/lib/webhook/index.js +0 -55
  60. package/lib/lib/lib/lib/webhook/responses.d.ts +0 -36
  61. package/lib/lib/lib/lib/webhook/responses.js +0 -42
  62. package/lib/lib/lib/lib/webhook/token.d.ts +0 -2
  63. package/lib/lib/lib/lib/webhook/token.js +0 -23
  64. package/lib/lib/lib/request/index.d.ts +0 -2
  65. package/lib/lib/lib/request/index.js +0 -26
  66. package/lib/lib/lib/request/token.d.ts +0 -2
  67. package/lib/lib/lib/request/token.js +0 -34
  68. package/lib/lib/lib/request/validation.d.ts +0 -10
  69. package/lib/lib/lib/request/validation.js +0 -28
  70. package/lib/lib/lib/schemas.d.ts +0 -1334
  71. package/lib/lib/lib/schemas.js +0 -325
  72. package/lib/lib/lib/src/baseSdk/diagnostica.d.ts +0 -6
  73. package/lib/lib/lib/src/baseSdk/diagnostica.js +0 -79
  74. package/lib/lib/lib/src/baseSdk/index.d.ts +0 -51
  75. package/lib/lib/lib/src/baseSdk/index.js +0 -66
  76. package/lib/lib/lib/src/baseSdk/user.d.ts +0 -9
  77. package/lib/lib/lib/src/baseSdk/user.js +0 -130
  78. package/lib/lib/lib/src/index.d.ts +0 -169
  79. package/lib/lib/lib/src/index.js +0 -22
  80. package/lib/lib/lib/src/request/index.d.ts +0 -2
  81. package/lib/lib/lib/src/request/index.js +0 -26
  82. package/lib/lib/lib/src/request/token.d.ts +0 -2
  83. package/lib/lib/lib/src/request/token.js +0 -34
  84. package/lib/lib/lib/src/request/validation.d.ts +0 -10
  85. package/lib/lib/lib/src/request/validation.js +0 -28
  86. package/lib/lib/lib/src/schemas.d.ts +0 -1340
  87. package/lib/lib/lib/src/schemas.js +0 -325
  88. package/lib/lib/lib/src/types.d.ts +0 -1
  89. package/lib/lib/lib/src/types.js +0 -2
  90. package/lib/lib/lib/src/userSdk/chat.d.ts +0 -9
  91. package/lib/lib/lib/src/userSdk/chat.js +0 -98
  92. package/lib/lib/lib/src/userSdk/index.d.ts +0 -102
  93. package/lib/lib/lib/src/userSdk/index.js +0 -27
  94. package/lib/lib/lib/src/userSdk/patients.d.ts +0 -5
  95. package/lib/lib/lib/src/userSdk/patients.js +0 -55
  96. package/lib/lib/lib/src/userSdk/schedule.d.ts +0 -7
  97. package/lib/lib/lib/src/userSdk/schedule.js +0 -76
  98. package/lib/lib/lib/src/userSdk/specialties.d.ts +0 -4
  99. package/lib/lib/lib/src/userSdk/specialties.js +0 -19
  100. package/lib/lib/lib/src/userSdk/videoVisit.d.ts +0 -10
  101. package/lib/lib/lib/src/userSdk/videoVisit.js +0 -147
  102. package/lib/lib/lib/src/utils.d.ts +0 -4
  103. package/lib/lib/lib/src/utils.js +0 -19
  104. package/lib/lib/lib/src/webhook/index.d.ts +0 -8
  105. package/lib/lib/lib/src/webhook/index.js +0 -55
  106. package/lib/lib/lib/src/webhook/responses.d.ts +0 -36
  107. package/lib/lib/lib/src/webhook/responses.js +0 -42
  108. package/lib/lib/lib/src/webhook/token.d.ts +0 -2
  109. package/lib/lib/lib/src/webhook/token.js +0 -23
  110. package/lib/lib/lib/test.d.ts +0 -1
  111. package/lib/lib/lib/test.js +0 -55
  112. package/lib/lib/lib/types.d.ts +0 -1
  113. package/lib/lib/lib/types.js +0 -2
  114. package/lib/lib/lib/userSdk/chat.d.ts +0 -9
  115. package/lib/lib/lib/userSdk/chat.js +0 -98
  116. package/lib/lib/lib/userSdk/index.d.ts +0 -102
  117. package/lib/lib/lib/userSdk/index.js +0 -27
  118. package/lib/lib/lib/userSdk/patients.d.ts +0 -5
  119. package/lib/lib/lib/userSdk/patients.js +0 -55
  120. package/lib/lib/lib/userSdk/schedule.d.ts +0 -7
  121. package/lib/lib/lib/userSdk/schedule.js +0 -76
  122. package/lib/lib/lib/userSdk/specialties.d.ts +0 -4
  123. package/lib/lib/lib/userSdk/specialties.js +0 -19
  124. package/lib/lib/lib/userSdk/videoVisit.d.ts +0 -10
  125. package/lib/lib/lib/userSdk/videoVisit.js +0 -147
  126. package/lib/lib/lib/utils.d.ts +0 -4
  127. package/lib/lib/lib/utils.js +0 -19
  128. package/lib/lib/lib/webhook/index.d.ts +0 -8
  129. package/lib/lib/lib/webhook/index.js +0 -55
  130. package/lib/lib/lib/webhook/responses.d.ts +0 -36
  131. package/lib/lib/lib/webhook/responses.js +0 -42
  132. package/lib/lib/lib/webhook/token.d.ts +0 -2
  133. package/lib/lib/lib/webhook/token.js +0 -23
  134. package/lib/lib/request/index.d.ts +0 -2
  135. package/lib/lib/request/index.js +0 -26
  136. package/lib/lib/request/token.d.ts +0 -2
  137. package/lib/lib/request/token.js +0 -34
  138. package/lib/lib/request/validation.d.ts +0 -10
  139. package/lib/lib/request/validation.js +0 -28
  140. package/lib/lib/schemas.d.ts +0 -1334
  141. package/lib/lib/schemas.js +0 -325
  142. package/lib/lib/src/baseSdk/diagnostica.d.ts +0 -11
  143. package/lib/lib/src/baseSdk/diagnostica.js +0 -79
  144. package/lib/lib/src/baseSdk/index.d.ts +0 -162
  145. package/lib/lib/src/baseSdk/index.js +0 -66
  146. package/lib/lib/src/baseSdk/user.d.ts +0 -41
  147. package/lib/lib/src/baseSdk/user.js +0 -130
  148. package/lib/lib/src/index.d.ts +0 -183
  149. package/lib/lib/src/index.js +0 -22
  150. package/lib/lib/src/request/index.d.ts +0 -2
  151. package/lib/lib/src/request/index.js +0 -26
  152. package/lib/lib/src/request/token.d.ts +0 -2
  153. package/lib/lib/src/request/token.js +0 -34
  154. package/lib/lib/src/request/validation.d.ts +0 -10
  155. package/lib/lib/src/request/validation.js +0 -28
  156. package/lib/lib/src/schemas.d.ts +0 -1340
  157. package/lib/lib/src/schemas.js +0 -325
  158. package/lib/lib/src/types.d.ts +0 -1
  159. package/lib/lib/src/types.js +0 -2
  160. package/lib/lib/src/userSdk/chat.d.ts +0 -9
  161. package/lib/lib/src/userSdk/chat.js +0 -98
  162. package/lib/lib/src/userSdk/index.d.ts +0 -241
  163. package/lib/lib/src/userSdk/index.js +0 -27
  164. package/lib/lib/src/userSdk/patients.d.ts +0 -13
  165. package/lib/lib/src/userSdk/patients.js +0 -55
  166. package/lib/lib/src/userSdk/schedule.d.ts +0 -15
  167. package/lib/lib/src/userSdk/schedule.js +0 -76
  168. package/lib/lib/src/userSdk/specialties.d.ts +0 -4
  169. package/lib/lib/src/userSdk/specialties.js +0 -19
  170. package/lib/lib/src/userSdk/videoVisit.d.ts +0 -72
  171. package/lib/lib/src/userSdk/videoVisit.js +0 -147
  172. package/lib/lib/src/utils.d.ts +0 -4
  173. package/lib/lib/src/utils.js +0 -19
  174. package/lib/lib/src/webhook/index.d.ts +0 -8
  175. package/lib/lib/src/webhook/index.js +0 -55
  176. package/lib/lib/src/webhook/responses.d.ts +0 -36
  177. package/lib/lib/src/webhook/responses.js +0 -42
  178. package/lib/lib/src/webhook/token.d.ts +0 -2
  179. package/lib/lib/src/webhook/token.js +0 -23
  180. package/lib/lib/test.d.ts +0 -1
  181. package/lib/lib/test.js +0 -55
  182. package/lib/lib/types.d.ts +0 -1
  183. package/lib/lib/types.js +0 -2
  184. package/lib/lib/userSdk/chat.d.ts +0 -9
  185. package/lib/lib/userSdk/chat.js +0 -98
  186. package/lib/lib/userSdk/index.d.ts +0 -240
  187. package/lib/lib/userSdk/index.js +0 -27
  188. package/lib/lib/userSdk/patients.d.ts +0 -13
  189. package/lib/lib/userSdk/patients.js +0 -55
  190. package/lib/lib/userSdk/schedule.d.ts +0 -15
  191. package/lib/lib/userSdk/schedule.js +0 -76
  192. package/lib/lib/userSdk/specialties.d.ts +0 -4
  193. package/lib/lib/userSdk/specialties.js +0 -19
  194. package/lib/lib/userSdk/videoVisit.d.ts +0 -72
  195. package/lib/lib/userSdk/videoVisit.js +0 -147
  196. package/lib/lib/utils.d.ts +0 -4
  197. package/lib/lib/utils.js +0 -19
  198. package/lib/lib/webhook/index.d.ts +0 -8
  199. package/lib/lib/webhook/index.js +0 -55
  200. package/lib/lib/webhook/responses.d.ts +0 -36
  201. package/lib/lib/webhook/responses.js +0 -42
  202. package/lib/lib/webhook/token.d.ts +0 -2
  203. package/lib/lib/webhook/token.js +0 -23
  204. package/lib/src/baseSdk/diagnostica.d.ts +0 -54
  205. package/lib/src/baseSdk/diagnostica.js +0 -79
  206. package/lib/src/baseSdk/index.d.ts +0 -2
  207. package/lib/src/baseSdk/index.js +0 -66
  208. package/lib/src/baseSdk/user.d.ts +0 -89
  209. package/lib/src/baseSdk/user.js +0 -130
  210. package/lib/src/index.d.ts +0 -188
  211. package/lib/src/index.js +0 -22
  212. package/lib/src/request/index.d.ts +0 -3
  213. package/lib/src/request/index.js +0 -26
  214. package/lib/src/request/token.d.ts +0 -2
  215. package/lib/src/request/token.js +0 -34
  216. package/lib/src/request/validation.d.ts +0 -10
  217. package/lib/src/request/validation.js +0 -28
  218. package/lib/src/schemas.d.ts +0 -1311
  219. package/lib/src/schemas.js +0 -325
  220. package/lib/src/types.d.ts +0 -124
  221. package/lib/src/types.js +0 -2
  222. package/lib/src/userSdk/chat.d.ts +0 -57
  223. package/lib/src/userSdk/chat.js +0 -98
  224. package/lib/src/userSdk/index.d.ts +0 -2
  225. package/lib/src/userSdk/index.js +0 -27
  226. package/lib/src/userSdk/patients.d.ts +0 -33
  227. package/lib/src/userSdk/patients.js +0 -55
  228. package/lib/src/userSdk/schedule.d.ts +0 -44
  229. package/lib/src/userSdk/schedule.js +0 -76
  230. package/lib/src/userSdk/specialties.d.ts +0 -7
  231. package/lib/src/userSdk/specialties.js +0 -19
  232. package/lib/src/userSdk/videoVisit.d.ts +0 -111
  233. package/lib/src/userSdk/videoVisit.js +0 -147
  234. package/lib/src/utils.d.ts +0 -4
  235. package/lib/src/utils.js +0 -19
  236. package/lib/src/webhook/index.d.ts +0 -2
  237. package/lib/src/webhook/index.js +0 -55
  238. package/lib/src/webhook/responses.d.ts +0 -35
  239. package/lib/src/webhook/responses.js +0 -42
  240. package/lib/src/webhook/token.d.ts +0 -2
  241. package/lib/src/webhook/token.js +0 -23
  242. package/lib/test.d.ts +0 -1
  243. package/lib/test.js +0 -21
@@ -1,76 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getScheduleMethods = 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 utils_1 = require("../utils");
9
- const getScheduleMethods = (makeRequest) => {
10
- const getScheduleDates = validation_1.validateFunction(zod_1.tuple([zod_1.number(), schemas_1.doc24Schemas.scheduleAvailabilityFilter]), zod_1.array(zod_1.date()), async (patientId, filter = {}) => {
11
- const mappedFilter = {
12
- specialty_id: filter.specialtyId,
13
- professional_id: filter.professionalId,
14
- };
15
- const path = `/schedule/dates/${patientId}/${JSON.stringify(mappedFilter)}`;
16
- const response = await makeRequest('GET', path);
17
- return response.data.available_dates.map((o) => utils_1.parseDate(o.date));
18
- });
19
- const getSchedule = validation_1.validateFunction(zod_1.tuple([zod_1.number(), zod_1.number(), schemas_1.doc24Schemas.scheduleFilter.optional()]), zod_1.array(schemas_1.doc24Schemas.availableAppointment), async (patientId, specialtyId, filter = {}) => {
20
- const mappedFilter = {
21
- id_professional: filter.professionalId,
22
- offset: filter.offset,
23
- limit: filter.limit,
24
- week_day: filter.weekDay,
25
- date: filter.date && date_fns_1.format(filter.date, 'yyyy-MM-dd'),
26
- start_hour: filter.startHour,
27
- finish_hour: filter.finishHour,
28
- };
29
- const path = `/schedule/availability/${patientId}/${specialtyId}/${JSON.stringify(mappedFilter)}`;
30
- const response = await makeRequest('GET', path);
31
- return response.data.available_appointments.map((a) => ({
32
- id: a.id,
33
- date: utils_1.parseDateTime(`${a.date} ${a.hour}`),
34
- clinicId: a.clinic,
35
- professional: {
36
- id: a.professional_id,
37
- fullName: a.professional,
38
- logoUrl: a.logo,
39
- },
40
- cost: a.cost,
41
- specialty: {
42
- id: a.specialty_id,
43
- description: a.specialty,
44
- },
45
- type: a.type === 'P' ? 'appointment' : a.type === 'T' ? 'chat' : 'instant',
46
- atentions: a.atentions,
47
- ranking: a.ranking,
48
- length: a.length,
49
- }));
50
- });
51
- const getAppointment = validation_1.validateFunction(zod_1.tuple([zod_1.number()]), schemas_1.doc24Schemas.appointment, async (appointmentId) => {
52
- const path = `/appointment/${appointmentId}`;
53
- const response = await makeRequest('GET', path);
54
- return {
55
- id: response.data.id,
56
- professionalId: response.data.professional_id,
57
- date: utils_1.parseDateTime(`${response.data.date} ${response.data.hour}`),
58
- };
59
- });
60
- const getAppointmentByVcToken = validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.appointment, async (vcToken) => {
61
- const path = `/appointmentByToken/${vcToken}`;
62
- const response = await makeRequest('GET', path);
63
- return {
64
- id: response.data.id,
65
- professionalId: response.data.professional_id,
66
- date: utils_1.parseDateTime(`${response.data.date} ${response.data.hour}`),
67
- };
68
- });
69
- return {
70
- getSchedule,
71
- getScheduleDates,
72
- getAppointment,
73
- getAppointmentByVcToken,
74
- };
75
- };
76
- exports.getScheduleMethods = getScheduleMethods;
@@ -1,4 +0,0 @@
1
- export var __esModule: boolean;
2
- export function getSpecialtiesMethods(makeRequest: any): {
3
- getSpecialties: (...params: any[]) => Promise<any>;
4
- };
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSpecialtiesMethods = void 0;
4
- const zod_1 = require("zod");
5
- const validation_1 = require("../request/validation");
6
- const schemas_1 = require("../schemas");
7
- const getSpecialtiesMethods = (makeRequest) => {
8
- const getSpecialties = validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.specialtyMode, zod_1.string()]), zod_1.array(schemas_1.doc24Schemas.specialty), async (mode, language) => {
9
- const type = mode === 'appointment' ? 'P' : mode === 'chat' ? 'T' : 'E';
10
- const path = `/specialties/${type}/${language.toUpperCase()}`;
11
- const response = await makeRequest('GET', path);
12
- return response.data.specialties.map((s) => ({
13
- id: s.specialty_id,
14
- description: s.specialty,
15
- }));
16
- });
17
- return { getSpecialties };
18
- };
19
- exports.getSpecialtiesMethods = getSpecialtiesMethods;
@@ -1,10 +0,0 @@
1
- export var __esModule: boolean;
2
- export function getVideoVisitMethods(makeRequest: any): {
3
- scheduleVideoVisit: (...params: any[]) => Promise<any>;
4
- cancelVideoVisit: (...params: any[]) => Promise<any>;
5
- getVideoVisit: (...params: any[]) => Promise<any>;
6
- getPatientVideoVisitHistory: (...params: any[]) => Promise<any>;
7
- getVideoVisitDetails: (...params: any[]) => Promise<any>;
8
- getVideoVisitLink: (...params: any[]) => Promise<any>;
9
- getActiveVideoVisits: (...params: any[]) => Promise<any>;
10
- };
@@ -1,147 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getVideoVisitMethods = void 0;
4
- const zod_1 = require("zod");
5
- const validation_1 = require("../request/validation");
6
- const schemas_1 = require("../schemas");
7
- const utils_1 = require("../utils");
8
- const getVideoVisitMethods = (makeRequest) => {
9
- const scheduleVideoVisit = validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.scheduleParameters]), zod_1.string(), async (params) => {
10
- const specificParams = params.type === 'appointment'
11
- ? {
12
- type: 'P',
13
- appointment_id: params.appointmentId,
14
- }
15
- : { type: 'E' };
16
- const mappedParams = {
17
- ...specificParams,
18
- patient_id: params.patientId,
19
- specialty_id: params.specialtyId,
20
- language: params.language.toUpperCase(),
21
- details: params.details,
22
- extra_info: params.extraInfo,
23
- };
24
- const response = await makeRequest('POST', '/video-visit', mappedParams);
25
- return response.data.vc_token;
26
- });
27
- const cancelVideoVisit = validation_1.validateFunction(zod_1.tuple([zod_1.string()]), zod_1.undefined(), async (vcToken) => {
28
- const path = `/video-visit/${vcToken}`;
29
- await makeRequest('DELETE', path);
30
- });
31
- const getVideoVisit = validation_1.validateFunction(zod_1.tuple([zod_1.string(), zod_1.number()]), schemas_1.doc24Schemas.videoVisit, async (vcToken, patientId) => {
32
- const path = `/video-visit/${vcToken}/${patientId}`;
33
- const response = await makeRequest('GET', path);
34
- return mapVideoVisit(response.data);
35
- });
36
- const getPatientVideoVisitHistory = validation_1.validateFunction(zod_1.tuple([zod_1.number()]), zod_1.array(schemas_1.doc24Schemas.videoVisit), async (patientId) => {
37
- const path = `/video-visit-history/${patientId}`;
38
- const response = await makeRequest('GET', path);
39
- return response.data.map((raw) => mapVideoVisit(raw));
40
- });
41
- const getVideoVisitDetails = validation_1.validateFunction(zod_1.tuple([zod_1.number()]), schemas_1.doc24Schemas.videoVisitDetails, async (vcId) => {
42
- const path = `/video-visit-records/${vcId}`;
43
- const response = await makeRequest('GET', path);
44
- return {
45
- id: response.data.consultation_id,
46
- status: response.data.status,
47
- paymentStatus: response.data.payment_status,
48
- professional: response.data.professional_id
49
- ? {
50
- id: response.data.professional_id,
51
- fullName: response.data.professional,
52
- }
53
- : undefined,
54
- patient: {
55
- fullName: response.data.patient,
56
- firstAccessDate: response.data.patient_first_access_date &&
57
- utils_1.parseDateTime(response.data.patient_first_access_date),
58
- lastAccessDate: response.data.patient_last_access_date &&
59
- utils_1.parseDateTime(response.data.patient_last_access_date),
60
- },
61
- finishDate: response.data.finish_date &&
62
- utils_1.parseDateTime(response.data.finish_date),
63
- retries: response.data.retries,
64
- language: response.data.language,
65
- appointment: response.data.appointment_id
66
- ? {
67
- id: response.data.appointment_id,
68
- date: utils_1.parseDateTime(`${response.data.appointment_date} ${response.data.appointment_time}`),
69
- }
70
- : null,
71
- report: {
72
- motive: response.data.motive,
73
- actualDesease: response.data.actual_desease,
74
- indications: response.data.indications,
75
- alertSigns: response.data.alert_signs,
76
- extendedMotive: response.data.extended_motive,
77
- diagnose: response.data.diagnose.map((d) => ({
78
- description: d.diagnostico,
79
- code: d.codificacion,
80
- })),
81
- },
82
- pdf: {
83
- atention: response.data.pdf_atention
84
- ? response.data.pdf_atention
85
- : undefined,
86
- medication: response.data.pdf_medication,
87
- images: response.data.pdf_images
88
- ? response.data.pdf_images
89
- : undefined,
90
- otherExams: response.data.pdf_other_exams
91
- ? response.data.pdf_other_exams
92
- : undefined,
93
- labs: response.data.pdf_labs ? response.data.pdf_labs : undefined,
94
- },
95
- files: response.data.files.map((f) => ({
96
- name: f.nombre_file,
97
- url: f.file,
98
- })),
99
- };
100
- });
101
- const getActiveVideoVisits = validation_1.validateFunction(zod_1.tuple([]), zod_1.array(schemas_1.doc24Schemas.activeVideoVisitData), async () => {
102
- const path = '/active-video-visits';
103
- const response = await makeRequest('GET', path);
104
- const consultations = response.data['active-consultations'];
105
- return consultations.map((s) => ({
106
- patientId: s.patient_id,
107
- consultationId: s.consultation_id,
108
- vcToken: s.vc_token,
109
- }));
110
- });
111
- const getVideoVisitLink = validation_1.validateFunction(zod_1.tuple([zod_1.string(), zod_1.number()]), zod_1.string().nullable(), async (vcToken, patientId) => {
112
- const path = `/video-visit-link/${vcToken}/${patientId}`;
113
- const response = await makeRequest('GET', path);
114
- return response.data.link;
115
- });
116
- return {
117
- scheduleVideoVisit,
118
- cancelVideoVisit,
119
- getVideoVisit,
120
- getPatientVideoVisitHistory,
121
- getVideoVisitDetails,
122
- getVideoVisitLink,
123
- getActiveVideoVisits,
124
- };
125
- };
126
- exports.getVideoVisitMethods = getVideoVisitMethods;
127
- const mapVideoVisit = (raw) => {
128
- var _a, _b;
129
- return {
130
- id: raw.vc_id,
131
- creationDate: utils_1.parseDateTime(raw.creation_date),
132
- patientId: raw.patient_id,
133
- user: { id: raw.user_id, email: raw.email, phone: raw.phone },
134
- vcToken: raw.vc_token,
135
- appointment: raw.appointment_id
136
- ? {
137
- id: raw.appointment_id,
138
- date: utils_1.parseDateTime(`${raw.appointment_date} ${raw.appointment_time}`),
139
- }
140
- : undefined,
141
- videoVisit: raw.video_visit_id
142
- ? { id: raw.video_visit_id, status: raw.video_visit_status }
143
- : undefined,
144
- paymentStatus: (_a = raw.payment_status) !== null && _a !== void 0 ? _a : undefined,
145
- atentionId: (_b = raw.atentionId) !== null && _b !== void 0 ? _b : undefined,
146
- };
147
- };
@@ -1,4 +0,0 @@
1
- export var __esModule: boolean;
2
- export function parseDate(str: any): Date;
3
- export function parseDateTime(str: any): Date;
4
- export function getIdetificationTypeId(type: any): 6 | 5 | 999;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getIdetificationTypeId = exports.parseDateTime = exports.parseDate = void 0;
4
- const date_fns_1 = require("date-fns");
5
- const timeZone = '-03';
6
- const parseDate = (str) => exports.parseDateTime(`${str} 00:00:00`);
7
- exports.parseDate = parseDate;
8
- const parseDateTime = (str) => date_fns_1.parse(`${str} ${timeZone}`, 'yyyy-MM-dd HH:mm:ss X', new Date());
9
- exports.parseDateTime = parseDateTime;
10
- const getIdetificationTypeId = (type) => {
11
- if (type === 'ndi')
12
- return 6;
13
- if (type === 'passport')
14
- return 5;
15
- if (type === 'credential')
16
- return 999;
17
- throw new Error('Invalid identificationType');
18
- };
19
- exports.getIdetificationTypeId = getIdetificationTypeId;
@@ -1,8 +0,0 @@
1
- export var __esModule: boolean;
2
- export function getRequestHandler(credentials: any, baseSdk: any, eventHandlers: any): (request: any) => Promise<{
3
- status: {
4
- code: number;
5
- message: string;
6
- };
7
- data: any;
8
- }>;
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRequestHandler = void 0;
4
- const token_1 = require("./token");
5
- const responses_1 = require("./responses");
6
- const utils_1 = require("../utils");
7
- const getRequestHandler = (credentials, baseSdk, eventHandlers) => async (request) => {
8
- const tokenPayload = await token_1.getWebhookToken(request, credentials);
9
- if (!tokenPayload)
10
- return responses_1.unauthorizedErrorResponse();
11
- const body = request.body;
12
- const error = await handleEvent(body, baseSdk, eventHandlers);
13
- if (error)
14
- return responses_1.unexpectedErrorResponse(error);
15
- return responses_1.successResponse();
16
- return responses_1.notFoundErrorResponse();
17
- };
18
- exports.getRequestHandler = getRequestHandler;
19
- const handleEvent = async (body, _baseSdk, eventHandlers) => {
20
- var _a, _b, _c, _d;
21
- const date = utils_1.parseDateTime(body.fecha_estado);
22
- if (body.tipo === 'consulta')
23
- return (_a = eventHandlers.onConsultationStatusChange) === null || _a === void 0 ? void 0 : _a.call(eventHandlers, {
24
- id: Number(body.id_consulta_virtual),
25
- invitationId: Number(body.id_invitacion),
26
- status: body.id_estado,
27
- changeDate: date,
28
- vcToken: body.vc_token,
29
- patientId: body.id_paciente !== undefined ? Number(body.id_paciente) : undefined,
30
- });
31
- if (body.tipo === 'invitacion')
32
- return (_b = eventHandlers.onInvitationStatusChange) === null || _b === void 0 ? void 0 : _b.call(eventHandlers, {
33
- status: body.id_estado,
34
- changeDate: date,
35
- vcToken: body.vc_token,
36
- appointmentId: Number(body.id_turno),
37
- patientId: Number(body.id_persona),
38
- professionalId: Number(body.id_profesional),
39
- });
40
- if (body.tipo === 'turno')
41
- return (_c = eventHandlers.onAppointmentStatusChange) === null || _c === void 0 ? void 0 : _c.call(eventHandlers, {
42
- id: Number(body.id_turno),
43
- status: body.id_estado,
44
- changeDate: date,
45
- });
46
- if (body.tipo === 'chat')
47
- return (_d = eventHandlers.onChatUpdate) === null || _d === void 0 ? void 0 : _d.call(eventHandlers, {
48
- id: Number(body.id_consulta_chat),
49
- status: body.estado_chat === 'A' ? 'active' : 'ended',
50
- patientId: Number(body.id_paciente),
51
- professionalId: Number(body.id_profesional),
52
- date,
53
- });
54
- return 'message_not_understood';
55
- };
@@ -1,36 +0,0 @@
1
- export var __esModule: boolean;
2
- export function notFoundErrorResponse(): {
3
- status: {
4
- code: number;
5
- message: string;
6
- };
7
- data: {
8
- error: string;
9
- };
10
- };
11
- export function unauthorizedErrorResponse(): {
12
- status: {
13
- code: number;
14
- message: string;
15
- };
16
- data: {
17
- error: string;
18
- };
19
- };
20
- export function unexpectedErrorResponse(details: any): {
21
- status: {
22
- code: number;
23
- message: string;
24
- };
25
- data: {
26
- error: string;
27
- details: any;
28
- };
29
- };
30
- export function successResponse(data: any): {
31
- status: {
32
- code: number;
33
- message: string;
34
- };
35
- data: any;
36
- };
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.successResponse = exports.unexpectedErrorResponse = exports.unauthorizedErrorResponse = exports.notFoundErrorResponse = void 0;
4
- const notFoundErrorResponse = () => ({
5
- status: {
6
- code: 404,
7
- message: 'Not Found',
8
- },
9
- data: {
10
- error: 'not_found',
11
- },
12
- });
13
- exports.notFoundErrorResponse = notFoundErrorResponse;
14
- const unauthorizedErrorResponse = () => ({
15
- status: {
16
- code: 401,
17
- message: 'Unauthorized',
18
- },
19
- data: {
20
- error: 'unauthorized',
21
- },
22
- });
23
- exports.unauthorizedErrorResponse = unauthorizedErrorResponse;
24
- const unexpectedErrorResponse = (details) => ({
25
- status: {
26
- code: 500,
27
- message: 'Unhandled Error',
28
- },
29
- data: {
30
- error: 'unhandled_error',
31
- details,
32
- },
33
- });
34
- exports.unexpectedErrorResponse = unexpectedErrorResponse;
35
- const successResponse = (data) => ({
36
- status: {
37
- code: 200,
38
- message: 'Success',
39
- },
40
- data,
41
- });
42
- exports.successResponse = successResponse;
@@ -1,2 +0,0 @@
1
- export var __esModule: boolean;
2
- export function getWebhookToken(request: any, credentials: any): Promise<any>;
@@ -1,23 +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.getWebhookToken = void 0;
7
- const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
8
- const getWebhookToken = async (request, credentials) => {
9
- if (request.headers.authentication === undefined)
10
- return;
11
- const decoded = await decodeJwt(request.headers.authentication, credentials.key);
12
- if (!decoded || decoded.iss !== credentials.iss)
13
- return;
14
- return decoded;
15
- };
16
- exports.getWebhookToken = getWebhookToken;
17
- const decodeJwt = (token, key) => new Promise((resolve, reject) => {
18
- jsonwebtoken_1.default.verify(token, key, (err, result) => {
19
- if (!result || err)
20
- return reject(err);
21
- resolve(result);
22
- });
23
- });
@@ -1 +0,0 @@
1
- export var __esModule: boolean;
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const _1 = require(".");
4
- const test = async () => {
5
- try {
6
- const baseSdk = await _1.doc24Sdk({
7
- url: 'https://tapi.doc24.com.ar/ws/sdk',
8
- credentials: {
9
- iss: 'wehealthy',
10
- key: '33Ypv5jQ1VTr1KcOImdBhPnoRDqmPlYR3JWbrlUim9U=',
11
- },
12
- });
13
- const userSdk = await baseSdk.getUserInstance(15135);
14
- let res = await userSdk.declarePatient({
15
- patient: {
16
- firstName: 'Rafael Elias',
17
- lastName: 'Mian',
18
- identificationType: 'ndi',
19
- identificationValue: '37970350',
20
- countryId: 'AR',
21
- birthdate: new Date('1996-07-03'),
22
- gender: 'm',
23
- },
24
- });
25
- // let res = await baseSdk.declareUser({
26
- // user: {
27
- // firstName: 'Rafael Elias',
28
- // lastName: 'Mian',
29
- // identificationType: 'ndi',
30
- // identificationValue: '37970350',
31
- // countryId: 'AR',
32
- // birthdate: new Date('1996-07-03'),
33
- // gender: 'm',
34
- // email: 'rafaelmian35@gmail.com',
35
- // phone: '+5493764203061',
36
- // },
37
- // // channel: '1',
38
- // // code: '370356',
39
- // });
40
- console.log(res);
41
- // await new Promise((resolve) => setTimeout(resolve, 2000));
42
- // if (!res.ask_code) return res.userId;
43
- // await baseSdk.sendVerificationCode({
44
- // identificationType: 'ndi',
45
- // identificationValue: '37970350',
46
- // channel: '1',
47
- // });
48
- // console.log(res);
49
- return;
50
- }
51
- catch (e) {
52
- console.log(e);
53
- }
54
- };
55
- test();
@@ -1 +0,0 @@
1
- export var __esModule: boolean;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,9 +0,0 @@
1
- export var __esModule: boolean;
2
- export function getChatMethods(makeRequest: any): {
3
- getAvailableChatrooms: (...params: any[]) => Promise<any>;
4
- createNewChat: (...params: any[]) => Promise<any>;
5
- getPatientChats: (...params: any[]) => Promise<any>;
6
- getChatPosts: (...params: any[]) => Promise<any>;
7
- cancelChat: (...params: any[]) => Promise<any>;
8
- sendChatMessage: (...params: any[]) => Promise<any>;
9
- };
@@ -1,98 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getChatMethods = void 0;
4
- const zod_1 = require("zod");
5
- const validation_1 = require("../request/validation");
6
- const schemas_1 = require("../schemas");
7
- const utils_1 = require("../utils");
8
- const getChatMethods = (makeRequest) => {
9
- const getAvailableChatrooms = validation_1.validateFunction(zod_1.tuple([zod_1.number(), zod_1.number(), schemas_1.doc24Schemas.chatroomAvailabilityFilter]), zod_1.array(schemas_1.doc24Schemas.availableChatroom), async (patientId, specialtyId, filter) => {
10
- const path = `/chatroom/availability/${patientId}/${specialtyId}/${JSON.stringify(filter)}`;
11
- const response = await makeRequest('GET', path);
12
- return response.data.available_chatrooms.map((r) => ({
13
- id: r.chatroom_id,
14
- professional: {
15
- id: r.professional_id,
16
- fullName: r.professional,
17
- logoUrl: r.logo,
18
- },
19
- specialty: {
20
- id: r.specialty_id,
21
- description: r.specialty,
22
- },
23
- }));
24
- });
25
- const createNewChat = validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.chatParameters]), zod_1.number(), async (parameters) => {
26
- const path = `/chatroom/visit`;
27
- const response = await makeRequest('POST', path, {
28
- chatroom_data: {
29
- patient_id: parameters.patientId,
30
- chatroom_id: parameters.chatroomId,
31
- language: parameters.language.toLocaleUpperCase(),
32
- specialty_id: parameters.specialtyId,
33
- },
34
- });
35
- return response.data.chat_id;
36
- });
37
- const getPatientChats = validation_1.validateFunction(zod_1.tuple([zod_1.number()]), zod_1.array(schemas_1.doc24Schemas.chatDetails), async (patientId) => {
38
- const path = `/chatroom/visits/${patientId}`;
39
- const response = await makeRequest('GET', path);
40
- return response.data.chatroom_visits.map((c) => ({
41
- id: c.chat_id,
42
- chatRoomId: c.chatroom_id,
43
- status: c.status,
44
- paymentStatus: c.payment_status,
45
- startDate: utils_1.parseDateTime(c.start_date),
46
- lastEventDate: utils_1.parseDateTime(c.fecha_ultimo_evento),
47
- closureDate: c.closure_date && utils_1.parseDateTime(c.closure_date),
48
- patient: {
49
- id: c.patient_id,
50
- firstName: c.patient_name,
51
- lastName: c.patient_lastname,
52
- },
53
- patientLastPost: c.patient_last_post && utils_1.parseDateTime(c.patient_last_post),
54
- professional: {
55
- id: c.professional_id,
56
- fullName: c.professional,
57
- logoUrl: c.logo,
58
- },
59
- professionalLastPost: c.professional_last_post && utils_1.parseDateTime(c.professional_last_post),
60
- specialty: {
61
- id: c.specialty_id,
62
- description: c.specialty,
63
- },
64
- }));
65
- });
66
- const getChatPosts = validation_1.validateFunction(zod_1.tuple([zod_1.number()]), zod_1.array(schemas_1.doc24Schemas.chatPost), async (chatId) => {
67
- const path = `/chatroom/visit/${chatId}`;
68
- const response = await makeRequest('GET', path);
69
- return JSON.parse(response.data.posts).map((p) => ({
70
- id: p.post_id,
71
- message: p.post,
72
- date: utils_1.parseDateTime(p.post_date),
73
- userType: p.user_type === 'P' ? 'patient' : 'professional',
74
- }));
75
- });
76
- const cancelChat = validation_1.validateFunction(zod_1.tuple([zod_1.number()]), zod_1.void(), async (chatId) => {
77
- const path = `/chatroom/visit/${chatId}`;
78
- await makeRequest('DELETE', path);
79
- return;
80
- });
81
- const sendChatMessage = validation_1.validateFunction(zod_1.tuple([zod_1.number(), zod_1.string()]), zod_1.number(), async (chatId, message) => {
82
- const path = `/chatroom/post`;
83
- const response = await makeRequest('POST', path, {
84
- chat_id: chatId,
85
- message,
86
- });
87
- return response.data.post_id;
88
- });
89
- return {
90
- getAvailableChatrooms,
91
- createNewChat,
92
- getPatientChats,
93
- getChatPosts,
94
- cancelChat,
95
- sendChatMessage,
96
- };
97
- };
98
- exports.getChatMethods = getChatMethods;