@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.
Files changed (251) hide show
  1. package/README.md +131 -83
  2. package/lib/baseSdk/diagnostica.d.ts +6 -6
  3. package/lib/baseSdk/index.js +1 -5
  4. package/lib/baseSdk/user.d.ts +51 -4
  5. package/lib/baseSdk/user.js +67 -25
  6. package/lib/index.d.ts +44 -16
  7. package/lib/schemas.d.ts +220 -30
  8. package/lib/schemas.js +33 -2
  9. package/lib/test.js +36 -1
  10. package/lib/types.d.ts +10 -2
  11. package/lib/userSdk/chat.d.ts +1 -1
  12. package/lib/userSdk/patients.d.ts +22 -2
  13. package/lib/userSdk/patients.js +34 -6
  14. package/lib/userSdk/videoVisit.d.ts +2 -2
  15. package/lib/utils.d.ts +1 -1
  16. package/lib/utils.js +3 -3
  17. package/package.json +2 -2
  18. package/lib/lib/baseSdk/diagnostica.d.ts +0 -11
  19. package/lib/lib/baseSdk/diagnostica.js +0 -79
  20. package/lib/lib/baseSdk/index.d.ts +0 -161
  21. package/lib/lib/baseSdk/index.js +0 -66
  22. package/lib/lib/baseSdk/user.d.ts +0 -41
  23. package/lib/lib/baseSdk/user.js +0 -130
  24. package/lib/lib/index.d.ts +0 -182
  25. package/lib/lib/index.js +0 -22
  26. package/lib/lib/lib/baseSdk/diagnostica.d.ts +0 -6
  27. package/lib/lib/lib/baseSdk/diagnostica.js +0 -79
  28. package/lib/lib/lib/baseSdk/index.d.ts +0 -51
  29. package/lib/lib/lib/baseSdk/index.js +0 -66
  30. package/lib/lib/lib/baseSdk/user.d.ts +0 -9
  31. package/lib/lib/lib/baseSdk/user.js +0 -130
  32. package/lib/lib/lib/index.d.ts +0 -168
  33. package/lib/lib/lib/index.js +0 -22
  34. package/lib/lib/lib/lib/baseSdk/diagnostica.d.ts +0 -6
  35. package/lib/lib/lib/lib/baseSdk/diagnostica.js +0 -79
  36. package/lib/lib/lib/lib/baseSdk/index.d.ts +0 -14
  37. package/lib/lib/lib/lib/baseSdk/index.js +0 -66
  38. package/lib/lib/lib/lib/baseSdk/user.d.ts +0 -9
  39. package/lib/lib/lib/lib/baseSdk/user.js +0 -130
  40. package/lib/lib/lib/lib/index.d.ts +0 -58
  41. package/lib/lib/lib/lib/index.js +0 -22
  42. package/lib/lib/lib/lib/request/index.d.ts +0 -2
  43. package/lib/lib/lib/lib/request/index.js +0 -26
  44. package/lib/lib/lib/lib/request/token.d.ts +0 -2
  45. package/lib/lib/lib/lib/request/token.js +0 -34
  46. package/lib/lib/lib/lib/request/validation.d.ts +0 -10
  47. package/lib/lib/lib/lib/request/validation.js +0 -28
  48. package/lib/lib/lib/lib/schemas.d.ts +0 -1334
  49. package/lib/lib/lib/lib/schemas.js +0 -325
  50. package/lib/lib/lib/lib/test.d.ts +0 -1
  51. package/lib/lib/lib/lib/test.js +0 -55
  52. package/lib/lib/lib/lib/types.d.ts +0 -1
  53. package/lib/lib/lib/lib/types.js +0 -2
  54. package/lib/lib/lib/lib/userSdk/chat.d.ts +0 -9
  55. package/lib/lib/lib/lib/userSdk/chat.js +0 -98
  56. package/lib/lib/lib/lib/userSdk/index.d.ts +0 -24
  57. package/lib/lib/lib/lib/userSdk/index.js +0 -27
  58. package/lib/lib/lib/lib/userSdk/patients.d.ts +0 -5
  59. package/lib/lib/lib/lib/userSdk/patients.js +0 -55
  60. package/lib/lib/lib/lib/userSdk/schedule.d.ts +0 -7
  61. package/lib/lib/lib/lib/userSdk/schedule.js +0 -76
  62. package/lib/lib/lib/lib/userSdk/specialties.d.ts +0 -4
  63. package/lib/lib/lib/lib/userSdk/specialties.js +0 -19
  64. package/lib/lib/lib/lib/userSdk/videoVisit.d.ts +0 -10
  65. package/lib/lib/lib/lib/userSdk/videoVisit.js +0 -147
  66. package/lib/lib/lib/lib/utils.d.ts +0 -4
  67. package/lib/lib/lib/lib/utils.js +0 -19
  68. package/lib/lib/lib/lib/webhook/index.d.ts +0 -8
  69. package/lib/lib/lib/lib/webhook/index.js +0 -55
  70. package/lib/lib/lib/lib/webhook/responses.d.ts +0 -36
  71. package/lib/lib/lib/lib/webhook/responses.js +0 -42
  72. package/lib/lib/lib/lib/webhook/token.d.ts +0 -2
  73. package/lib/lib/lib/lib/webhook/token.js +0 -23
  74. package/lib/lib/lib/request/index.d.ts +0 -2
  75. package/lib/lib/lib/request/index.js +0 -26
  76. package/lib/lib/lib/request/token.d.ts +0 -2
  77. package/lib/lib/lib/request/token.js +0 -34
  78. package/lib/lib/lib/request/validation.d.ts +0 -10
  79. package/lib/lib/lib/request/validation.js +0 -28
  80. package/lib/lib/lib/schemas.d.ts +0 -1334
  81. package/lib/lib/lib/schemas.js +0 -325
  82. package/lib/lib/lib/src/baseSdk/diagnostica.d.ts +0 -6
  83. package/lib/lib/lib/src/baseSdk/diagnostica.js +0 -79
  84. package/lib/lib/lib/src/baseSdk/index.d.ts +0 -51
  85. package/lib/lib/lib/src/baseSdk/index.js +0 -66
  86. package/lib/lib/lib/src/baseSdk/user.d.ts +0 -9
  87. package/lib/lib/lib/src/baseSdk/user.js +0 -130
  88. package/lib/lib/lib/src/index.d.ts +0 -169
  89. package/lib/lib/lib/src/index.js +0 -22
  90. package/lib/lib/lib/src/request/index.d.ts +0 -2
  91. package/lib/lib/lib/src/request/index.js +0 -26
  92. package/lib/lib/lib/src/request/token.d.ts +0 -2
  93. package/lib/lib/lib/src/request/token.js +0 -34
  94. package/lib/lib/lib/src/request/validation.d.ts +0 -10
  95. package/lib/lib/lib/src/request/validation.js +0 -28
  96. package/lib/lib/lib/src/schemas.d.ts +0 -1340
  97. package/lib/lib/lib/src/schemas.js +0 -325
  98. package/lib/lib/lib/src/types.d.ts +0 -1
  99. package/lib/lib/lib/src/types.js +0 -2
  100. package/lib/lib/lib/src/userSdk/chat.d.ts +0 -9
  101. package/lib/lib/lib/src/userSdk/chat.js +0 -98
  102. package/lib/lib/lib/src/userSdk/index.d.ts +0 -102
  103. package/lib/lib/lib/src/userSdk/index.js +0 -27
  104. package/lib/lib/lib/src/userSdk/patients.d.ts +0 -5
  105. package/lib/lib/lib/src/userSdk/patients.js +0 -55
  106. package/lib/lib/lib/src/userSdk/schedule.d.ts +0 -7
  107. package/lib/lib/lib/src/userSdk/schedule.js +0 -76
  108. package/lib/lib/lib/src/userSdk/specialties.d.ts +0 -4
  109. package/lib/lib/lib/src/userSdk/specialties.js +0 -19
  110. package/lib/lib/lib/src/userSdk/videoVisit.d.ts +0 -10
  111. package/lib/lib/lib/src/userSdk/videoVisit.js +0 -147
  112. package/lib/lib/lib/src/utils.d.ts +0 -4
  113. package/lib/lib/lib/src/utils.js +0 -19
  114. package/lib/lib/lib/src/webhook/index.d.ts +0 -8
  115. package/lib/lib/lib/src/webhook/index.js +0 -55
  116. package/lib/lib/lib/src/webhook/responses.d.ts +0 -36
  117. package/lib/lib/lib/src/webhook/responses.js +0 -42
  118. package/lib/lib/lib/src/webhook/token.d.ts +0 -2
  119. package/lib/lib/lib/src/webhook/token.js +0 -23
  120. package/lib/lib/lib/test.d.ts +0 -1
  121. package/lib/lib/lib/test.js +0 -55
  122. package/lib/lib/lib/types.d.ts +0 -1
  123. package/lib/lib/lib/types.js +0 -2
  124. package/lib/lib/lib/userSdk/chat.d.ts +0 -9
  125. package/lib/lib/lib/userSdk/chat.js +0 -98
  126. package/lib/lib/lib/userSdk/index.d.ts +0 -102
  127. package/lib/lib/lib/userSdk/index.js +0 -27
  128. package/lib/lib/lib/userSdk/patients.d.ts +0 -5
  129. package/lib/lib/lib/userSdk/patients.js +0 -55
  130. package/lib/lib/lib/userSdk/schedule.d.ts +0 -7
  131. package/lib/lib/lib/userSdk/schedule.js +0 -76
  132. package/lib/lib/lib/userSdk/specialties.d.ts +0 -4
  133. package/lib/lib/lib/userSdk/specialties.js +0 -19
  134. package/lib/lib/lib/userSdk/videoVisit.d.ts +0 -10
  135. package/lib/lib/lib/userSdk/videoVisit.js +0 -147
  136. package/lib/lib/lib/utils.d.ts +0 -4
  137. package/lib/lib/lib/utils.js +0 -19
  138. package/lib/lib/lib/webhook/index.d.ts +0 -8
  139. package/lib/lib/lib/webhook/index.js +0 -55
  140. package/lib/lib/lib/webhook/responses.d.ts +0 -36
  141. package/lib/lib/lib/webhook/responses.js +0 -42
  142. package/lib/lib/lib/webhook/token.d.ts +0 -2
  143. package/lib/lib/lib/webhook/token.js +0 -23
  144. package/lib/lib/request/index.d.ts +0 -2
  145. package/lib/lib/request/index.js +0 -26
  146. package/lib/lib/request/token.d.ts +0 -2
  147. package/lib/lib/request/token.js +0 -34
  148. package/lib/lib/request/validation.d.ts +0 -10
  149. package/lib/lib/request/validation.js +0 -28
  150. package/lib/lib/schemas.d.ts +0 -1334
  151. package/lib/lib/schemas.js +0 -325
  152. package/lib/lib/src/baseSdk/diagnostica.d.ts +0 -11
  153. package/lib/lib/src/baseSdk/diagnostica.js +0 -79
  154. package/lib/lib/src/baseSdk/index.d.ts +0 -162
  155. package/lib/lib/src/baseSdk/index.js +0 -66
  156. package/lib/lib/src/baseSdk/user.d.ts +0 -41
  157. package/lib/lib/src/baseSdk/user.js +0 -130
  158. package/lib/lib/src/index.d.ts +0 -183
  159. package/lib/lib/src/index.js +0 -22
  160. package/lib/lib/src/request/index.d.ts +0 -2
  161. package/lib/lib/src/request/index.js +0 -26
  162. package/lib/lib/src/request/token.d.ts +0 -2
  163. package/lib/lib/src/request/token.js +0 -34
  164. package/lib/lib/src/request/validation.d.ts +0 -10
  165. package/lib/lib/src/request/validation.js +0 -28
  166. package/lib/lib/src/schemas.d.ts +0 -1340
  167. package/lib/lib/src/schemas.js +0 -325
  168. package/lib/lib/src/types.d.ts +0 -1
  169. package/lib/lib/src/types.js +0 -2
  170. package/lib/lib/src/userSdk/chat.d.ts +0 -9
  171. package/lib/lib/src/userSdk/chat.js +0 -98
  172. package/lib/lib/src/userSdk/index.d.ts +0 -241
  173. package/lib/lib/src/userSdk/index.js +0 -27
  174. package/lib/lib/src/userSdk/patients.d.ts +0 -13
  175. package/lib/lib/src/userSdk/patients.js +0 -55
  176. package/lib/lib/src/userSdk/schedule.d.ts +0 -15
  177. package/lib/lib/src/userSdk/schedule.js +0 -76
  178. package/lib/lib/src/userSdk/specialties.d.ts +0 -4
  179. package/lib/lib/src/userSdk/specialties.js +0 -19
  180. package/lib/lib/src/userSdk/videoVisit.d.ts +0 -72
  181. package/lib/lib/src/userSdk/videoVisit.js +0 -147
  182. package/lib/lib/src/utils.d.ts +0 -4
  183. package/lib/lib/src/utils.js +0 -19
  184. package/lib/lib/src/webhook/index.d.ts +0 -8
  185. package/lib/lib/src/webhook/index.js +0 -55
  186. package/lib/lib/src/webhook/responses.d.ts +0 -36
  187. package/lib/lib/src/webhook/responses.js +0 -42
  188. package/lib/lib/src/webhook/token.d.ts +0 -2
  189. package/lib/lib/src/webhook/token.js +0 -23
  190. package/lib/lib/test.d.ts +0 -1
  191. package/lib/lib/test.js +0 -55
  192. package/lib/lib/types.d.ts +0 -1
  193. package/lib/lib/types.js +0 -2
  194. package/lib/lib/userSdk/chat.d.ts +0 -9
  195. package/lib/lib/userSdk/chat.js +0 -98
  196. package/lib/lib/userSdk/index.d.ts +0 -240
  197. package/lib/lib/userSdk/index.js +0 -27
  198. package/lib/lib/userSdk/patients.d.ts +0 -13
  199. package/lib/lib/userSdk/patients.js +0 -55
  200. package/lib/lib/userSdk/schedule.d.ts +0 -15
  201. package/lib/lib/userSdk/schedule.js +0 -76
  202. package/lib/lib/userSdk/specialties.d.ts +0 -4
  203. package/lib/lib/userSdk/specialties.js +0 -19
  204. package/lib/lib/userSdk/videoVisit.d.ts +0 -72
  205. package/lib/lib/userSdk/videoVisit.js +0 -147
  206. package/lib/lib/utils.d.ts +0 -4
  207. package/lib/lib/utils.js +0 -19
  208. package/lib/lib/webhook/index.d.ts +0 -8
  209. package/lib/lib/webhook/index.js +0 -55
  210. package/lib/lib/webhook/responses.d.ts +0 -36
  211. package/lib/lib/webhook/responses.js +0 -42
  212. package/lib/lib/webhook/token.d.ts +0 -2
  213. package/lib/lib/webhook/token.js +0 -23
  214. package/lib/src/baseSdk/diagnostica.d.ts +0 -54
  215. package/lib/src/baseSdk/diagnostica.js +0 -79
  216. package/lib/src/baseSdk/index.d.ts +0 -2
  217. package/lib/src/baseSdk/index.js +0 -66
  218. package/lib/src/baseSdk/user.d.ts +0 -89
  219. package/lib/src/baseSdk/user.js +0 -130
  220. package/lib/src/index.d.ts +0 -188
  221. package/lib/src/index.js +0 -22
  222. package/lib/src/request/index.d.ts +0 -3
  223. package/lib/src/request/index.js +0 -26
  224. package/lib/src/request/token.d.ts +0 -2
  225. package/lib/src/request/token.js +0 -34
  226. package/lib/src/request/validation.d.ts +0 -10
  227. package/lib/src/request/validation.js +0 -28
  228. package/lib/src/schemas.d.ts +0 -1311
  229. package/lib/src/schemas.js +0 -325
  230. package/lib/src/types.d.ts +0 -124
  231. package/lib/src/types.js +0 -2
  232. package/lib/src/userSdk/chat.d.ts +0 -57
  233. package/lib/src/userSdk/chat.js +0 -98
  234. package/lib/src/userSdk/index.d.ts +0 -2
  235. package/lib/src/userSdk/index.js +0 -27
  236. package/lib/src/userSdk/patients.d.ts +0 -33
  237. package/lib/src/userSdk/patients.js +0 -55
  238. package/lib/src/userSdk/schedule.d.ts +0 -44
  239. package/lib/src/userSdk/schedule.js +0 -76
  240. package/lib/src/userSdk/specialties.d.ts +0 -7
  241. package/lib/src/userSdk/specialties.js +0 -19
  242. package/lib/src/userSdk/videoVisit.d.ts +0 -111
  243. package/lib/src/userSdk/videoVisit.js +0 -147
  244. package/lib/src/utils.d.ts +0 -4
  245. package/lib/src/utils.js +0 -19
  246. package/lib/src/webhook/index.d.ts +0 -2
  247. package/lib/src/webhook/index.js +0 -55
  248. package/lib/src/webhook/responses.d.ts +0 -35
  249. package/lib/src/webhook/responses.js +0 -42
  250. package/lib/src/webhook/token.d.ts +0 -2
  251. package/lib/src/webhook/token.js +0 -23
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @integraciones_doc24/sdk
2
2
 
3
- Node.JS library for accessing doc24 api
3
+ Node.JS library for accessing doc24 api
4
4
 
5
5
  ## Installation
6
6
 
@@ -9,48 +9,55 @@
9
9
  ## Usage
10
10
 
11
11
  ```ts
12
- import {doc24Sdk} from '@integraciones_doc24/sdk'
12
+ import {doc24Sdk} from '@integraciones_doc24/sdk';
13
13
 
14
- const getBaseSdk = () => doc24Sdk({
15
- url: 'https://tapi.doc24.com.ar/ws/sdk',
16
- credentials: {
17
- iss: 'myissuer',
18
- key: 'mysecret',
19
- },
20
- });
21
-
22
- const getSpecialities = async (user) => {
23
- const baseSdk = await getBaseSdk()
14
+ const getBaseSdk = () =>
15
+ doc24Sdk({
16
+ url: 'https://tapi.doc24.com.ar/ws/sdk',
17
+ credentials: {
18
+ iss: 'myissuer',
19
+ key: 'mysecret',
20
+ },
21
+ });
22
+
23
+ const getSpecialities = async (user) => {
24
+ const baseSdk = await getBaseSdk();
24
25
 
25
- const userSdk = await baseSdk.getUserInstance(user)
26
+ const userSdk = await baseSdk.getUserInstance(user);
26
27
 
27
- return await userSdk.getSpecialties('instant', 'ES');
28
- }
28
+ return await userSdk.getSpecialties('instant', 'ES');
29
+ };
29
30
 
30
31
  const getRequestHandler = async () => {
31
- const baseSdk = await getBaseSdk()
32
- return baseSdk.getRequestHandler({
33
- credentials: {
34
- iss: 'doc24issuer',
35
- key: 'doc24secret',
36
- },
37
- baseAddress: 'http://myaddress.com/route/to/webhook',
38
- eventHandlers: {
39
- onAppointmentStatusChange: ({id, status, changeDate}) => {
40
- console.log({id, status, changeDate});
41
- },
42
- onConsultationStatusChange: ({id, invitationId, status, changeDate, vcToken}) => {
43
- console.log({id, invitationId, status, changeDate, vcToken});
44
- },
45
- onInvitationStatusChange: ({id, status, changeDate}) => {
46
- console.log({id, status, changeDate});
47
- },
48
- onChatUpdate: ({id, status, patientId, professionalId, date}) => {
49
- console.log({id, status, patientId, professionalId, date});
50
- }
51
- },
52
- });
53
- }
32
+ const baseSdk = await getBaseSdk();
33
+ return baseSdk.getRequestHandler({
34
+ credentials: {
35
+ iss: 'doc24issuer',
36
+ key: 'doc24secret',
37
+ },
38
+ baseAddress: 'http://myaddress.com/route/to/webhook',
39
+ eventHandlers: {
40
+ onAppointmentStatusChange: ({id, status, changeDate}) => {
41
+ console.log({id, status, changeDate});
42
+ },
43
+ onConsultationStatusChange: ({
44
+ id,
45
+ invitationId,
46
+ status,
47
+ changeDate,
48
+ vcToken,
49
+ }) => {
50
+ console.log({id, invitationId, status, changeDate, vcToken});
51
+ },
52
+ onInvitationStatusChange: ({id, status, changeDate}) => {
53
+ console.log({id, status, changeDate});
54
+ },
55
+ onChatUpdate: ({id, status, patientId, professionalId, date}) => {
56
+ console.log({id, status, patientId, professionalId, date});
57
+ },
58
+ },
59
+ });
60
+ };
54
61
  ```
55
62
 
56
63
  The library exports the function `doc24Sdk`. It takes one parameters of type `SdkParams`, and returns a `BaseSdk`.
@@ -58,69 +65,110 @@ It also returns an extra `getRequestHandler` function that takes a `RequestHandl
58
65
 
59
66
  ```ts
60
67
  type SdkCredentials = {
61
- iss: string;
62
- key: string;
63
- }
68
+ iss: string;
69
+ key: string;
70
+ };
64
71
  type SdkParams = {
65
- url: string;
66
- credentials: SdkCredentials;
72
+ url: string;
73
+ credentials: SdkCredentials;
67
74
  };
68
75
  type BaseSdk = {
69
- getUserInstance: (user: User) => Promise<UserSdk>;
70
- getProfessional: (professionalId: number) => Promise<Professional>;
71
- getAvailableScheduleClinics: () => Promise<AvailableScheduleClinics>
72
- }
76
+ declareUser: (params: DeclareUserParams) => Promise<any>;
77
+ getUserId: (user: User) => Promise<number>;
78
+ getUserInstance: (user: User | number) => Promise<UserSdk>;
79
+ getProfessional: (professionalId: number) => Promise<Professional>;
80
+ getAvailableScheduleClinics: () => Promise<AvailableScheduleClinics>;
81
+ enroll: (params: EnrollmentParams) => Promise<void>;
82
+ getConverageInfo: (identificationValue: string) => Promise<CoverageInfo>;
83
+ sendVerificationCode: (params: SendVerificationCodeParams) => Promise<void>;
84
+ getDiagnosticaHistory: (
85
+ patient: DiagnosticaPatientFilter,
86
+ from: Date,
87
+ to: Date,
88
+ ) => Promise<DiagnosticaHistoryAppointment[]>;
89
+ getDiagnosticaDeepLink: (
90
+ kiosk: string,
91
+ user: DiagnosticaUser,
92
+ patient: DiagnosticaPatient,
93
+ ) => Promise<DiagnosticaDeepLinkResponse>;
94
+ getDiagnosticaAccess: (
95
+ kiosk: string,
96
+ user: DiagnosticaUser,
97
+ patient: DiagnosticaPatient,
98
+ ) => Promise<void>;
99
+ };
73
100
 
74
101
  type RequestHandlerParams = {
75
- // Credentials that doc24 should use when singing the jwt
76
- credentials: SdkCredentials;
77
- eventHandlers: Webhook.Events;
78
- // Address in which doc24 should send the requests
79
- baseAddress: string;
80
- }
102
+ // Credentials that doc24 should use when singing the jwt
103
+ credentials: SdkCredentials;
104
+ eventHandlers: Webhook.Events;
105
+ // Address in which doc24 should send the requests
106
+ baseAddress: string;
107
+ };
81
108
  ```
82
109
 
83
110
  `getRequestHandler` should be called only once, and takes care of managing the webhook that receives events from doc24.
84
111
 
85
112
  ### Express example
113
+
86
114
  ```ts
87
- const handler = await getRequestHandler()
115
+ const handler = await getRequestHandler();
88
116
  app.all('/doc24', async (req, res) => {
89
- const response = await handler({
90
- headers: req.headers,
91
- body: req.body,
92
- query: req.query,
93
- });
117
+ const response = await handler({
118
+ headers: req.headers,
119
+ body: req.body,
120
+ query: req.query,
121
+ });
94
122
 
95
- res.status(response.status.code).json(response.data);
123
+ res.status(response.status.code).json(response.data);
96
124
  });
97
125
  ```
98
126
 
99
127
  ### UserSdk
128
+
100
129
  Most of the methods need a user specified, so `getUserInstance` returns an instance of `UserSdk` with them.
101
130
 
102
131
  ```ts
103
132
  type UserSdk = {
104
- declarePatient: (patient: Patient) => Promise<number>;
105
- getSpecialties: (
106
- mode: SpecialtyMode,
107
- language: string,
108
- ) => Promise<Specialty[]>;
109
- getScheduleDates: (
110
- patientId: number,
111
- filter?: ScheduleAvailabilityFilter,
112
- ) => Promise<Date[]>;
113
- getSchedule: (
114
- patientId: number,
115
- specialtyId: number,
116
- filter?: ScheduleFilter,
117
- ) => Promise<AvailableAppointment[]>;
118
- getAppointment: (appointmentId: number) => Promise<Appointment>;
119
- scheduleVideoVisit: (params: ScheduleParameters) => Promise<string>;
120
- cancelVideoVisit: (vcToken: string) => Promise<void>;
121
- getVideoVisit: (vcToken: string, patientId: number) => Promise<VideoVisit>;
122
- getVideoVisitDetails: (vcId: number) => Promise<VideoVisitDetails>;
123
- getPatientVideoVisitHistory: (patientId: number) => Promise<VideoVisit[]>;
124
- userId: number;
125
- }
126
- ```
133
+ declarePatient: (
134
+ params: DeclarePatientParams,
135
+ ) => Promise<DeclarePatientResponse>;
136
+ getPatientId: (patient: Patient) => Promise<number>;
137
+ getSpecialties: (
138
+ mode: SpecialtyMode,
139
+ language: string,
140
+ ) => Promise<Specialty[]>;
141
+ getScheduleDates: (
142
+ patientId: number,
143
+ filter?: ScheduleAvailabilityFilter,
144
+ ) => Promise<Date[]>;
145
+ getSchedule: (
146
+ patientId: number,
147
+ specialtyId: number,
148
+ filter?: ScheduleFilter,
149
+ ) => Promise<AvailableAppointment[]>;
150
+ getAppointment: (appointmentId: number) => Promise<Appointment>;
151
+ getAppointmentByVcToken: (vcToken: string) => Promise<Appointment>;
152
+ scheduleVideoVisit: (params: ScheduleParameters) => Promise<string>;
153
+ cancelVideoVisit: (vcToken: string) => Promise<void>;
154
+ getVideoVisit: (vcToken: string, patientId: number) => Promise<VideoVisit>;
155
+ getVideoVisitDetails: (vcId: number) => Promise<VideoVisitDetails>;
156
+ getVideoVisitLink: (
157
+ vcToken: string,
158
+ patientId: number,
159
+ ) => Promise<string | null>;
160
+ getPatientVideoVisitHistory: (patientId: number) => Promise<VideoVisit[]>;
161
+ getActiveVideoVisits: () => Promise<ActiveVideoVisitData[]>;
162
+ getAvailableChatrooms: (
163
+ patientId: number,
164
+ specialtyId: number,
165
+ filter: ChatroomAvailabilityFilter,
166
+ ) => Promise<AvailableChatroom[]>;
167
+ createNewChat: (chatParameters: ChatParameters) => Promise<number>;
168
+ getPatientChats: (patientId: number) => Promise<ChatDetails[]>;
169
+ getChatPosts: (chatId: number) => Promise<ChatPost[]>;
170
+ cancelChat: (chatId: number) => Promise<void>;
171
+ sendChatMessage: (chatId: number, message: string) => Promise<number>;
172
+ userId: number;
173
+ };
174
+ ```
@@ -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;
15
14
  firstName: string;
16
15
  lastName: string;
17
- birthday: Date;
18
16
  identificationType: "dni";
19
17
  identificationValue: string;
20
18
  gender: "m" | "f";
21
19
  phone: string;
22
20
  email: string;
21
+ language: string;
22
+ birthday: Date;
23
23
  }, patient: {
24
24
  firstName: string;
25
25
  lastName: string;
26
- birthday: Date;
27
26
  identificationType: "dni";
28
27
  identificationValue: string;
29
28
  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;
38
37
  firstName: string;
39
38
  lastName: string;
40
- birthday: Date;
41
39
  identificationType: "dni";
42
40
  identificationValue: string;
43
41
  gender: "m" | "f";
44
42
  phone: string;
45
43
  email: string;
44
+ language: string;
45
+ birthday: Date;
46
46
  }, patient: {
47
47
  firstName: string;
48
48
  lastName: string;
49
- birthday: Date;
50
49
  identificationType: "dni";
51
50
  identificationValue: string;
52
51
  gender: "m" | "f";
52
+ birthday: Date;
53
53
  }) => Promise<void>;
54
54
  };
@@ -48,13 +48,9 @@ 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
- });
55
51
  const mapped = {
56
52
  specialties: response.data.specialties.map(mapSpeciality),
57
- specialtiesER: response.data.specialties_er.map(mapSpecialityER),
53
+ specialtiesER: response.data.specialties_er.map(mapSpeciality),
58
54
  professionals: response.data.professionals.map((p) => ({
59
55
  id: p.id_profesional,
60
56
  fullName: p.denominacion,
@@ -1,25 +1,72 @@
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: (user: {
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: {
5
28
  firstName: string;
6
29
  lastName: string;
7
30
  identificationType: "ndi" | "passport" | "credential";
8
31
  identificationValue: string;
32
+ countryId: string;
33
+ birthdate: Date;
9
34
  gender: "m" | "f";
10
35
  phone: string;
11
36
  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;
12
48
  countryId: string;
13
49
  birthdate: Date;
50
+ gender: "m" | "f";
51
+ phone: string;
52
+ email: string;
14
53
  }) => Promise<any>;
15
- getUserInstance: (...params: any) => Promise<any>;
16
- enroll: (...params: any) => Promise<void>;
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>;
17
64
  getConverageInfo: (identificationValue: string) => Promise<{
18
65
  firstName: string | null;
19
66
  lastName: string | null;
67
+ birthdate: Date;
20
68
  gender: "m" | "f";
21
69
  email: string | null;
22
- birthdate: Date;
23
70
  identificationNumber: string;
24
71
  plan: string | null;
25
72
  financerId: number | null;
@@ -8,11 +8,39 @@ 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
+ };
11
38
  const getUserId = async (user) => {
39
+ const path = '/user';
12
40
  const mappedUser = {
13
41
  lastname: user.lastName,
14
42
  firstname: user.firstName,
15
- identification_type: utils_1.getIndetificationTypeId(user.identificationType),
43
+ identification_type: utils_1.getIdetificationTypeId(user.identificationType),
16
44
  identification_value: user.identificationValue,
17
45
  birthdate: date_fns_1.format(user.birthdate, 'yyyy-MM-dd'),
18
46
  gender: user.gender.toUpperCase(),
@@ -20,12 +48,41 @@ const getUserMethods = (makeRequest, url, credentials) => {
20
48
  email: user.email,
21
49
  country_id: user.countryId,
22
50
  };
23
- const response = await makeRequest('POST', '/user', {
51
+ const response = await makeRequest('POST', path, {
24
52
  user_data: mappedUser,
25
53
  });
26
54
  return response.data.user_id;
27
55
  };
28
- const getConverageInfo = validation_1.validateFunction(zod_1.tuple([zod_1.string()]), schemas_1.doc24Schemas.coverageInfo, async (identificationValue) => {
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) => {
29
86
  const path = `/info-coverage/${identificationValue}`;
30
87
  const response = await makeRequest('GET', path);
31
88
  const raw = response.data.info;
@@ -58,31 +115,16 @@ const getUserMethods = (makeRequest, url, credentials) => {
58
115
  : null,
59
116
  };
60
117
  return mappedCoverageInfo;
61
- });
118
+ };
62
119
  return {
63
- declareUser: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.user]), zod_1.number(), getUserId),
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),
64
123
  getUserInstance: validation_1.validateFunction(zod_1.tuple([zod_1.union([schemas_1.doc24Schemas.user, zod_1.number()])]),
65
124
  // TODO: validate?
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,
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),
86
128
  };
87
129
  };
88
130
  exports.getUserMethods = getUserMethods;
package/lib/index.d.ts CHANGED
@@ -5,37 +5,60 @@ 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: (user: {
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: {
9
32
  firstName: string;
10
33
  lastName: string;
11
34
  identificationType: "ndi" | "passport" | "credential";
12
35
  identificationValue: string;
36
+ countryId: string;
37
+ birthdate: Date;
13
38
  gender: "m" | "f";
14
39
  phone: string;
15
40
  email: string;
16
- countryId: string;
17
- birthdate: Date;
18
41
  }) => Promise<number>;
19
42
  getUserInstance: (user: number | {
20
43
  firstName: string;
21
44
  lastName: string;
22
45
  identificationType: "ndi" | "passport" | "credential";
23
46
  identificationValue: string;
47
+ countryId: string;
48
+ birthdate: Date;
24
49
  gender: "m" | "f";
25
50
  phone: string;
26
51
  email: string;
27
- countryId: string;
28
- birthdate: Date;
29
52
  }) => Promise<Doc24.UserSdk>;
30
53
  getProfessional: (professionalId: number) => Promise<{
31
- id: number;
32
- logoUrl: string;
33
54
  firstName: string;
34
55
  lastName: string;
56
+ birthdate: Date;
35
57
  gender: "m" | "f";
36
58
  phone: string | null;
37
59
  email: string;
38
- birthdate: Date;
60
+ id: number;
61
+ logoUrl: string;
39
62
  specialties: {
40
63
  id: number;
41
64
  description: string;
@@ -73,9 +96,9 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
73
96
  enroll: (params: {
74
97
  firstName: string;
75
98
  lastName: string;
99
+ birthdate: Date;
76
100
  gender: "m" | "f";
77
101
  email: string;
78
- birthdate: Date;
79
102
  startDate: Date;
80
103
  identificationNumber: string;
81
104
  plan: string;
@@ -83,9 +106,9 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
83
106
  getConverageInfo: (identificationValue: string) => Promise<{
84
107
  firstName: string | null;
85
108
  lastName: string | null;
109
+ birthdate: Date;
86
110
  gender: "m" | "f";
87
111
  email: string | null;
88
- birthdate: Date;
89
112
  identificationNumber: string;
90
113
  plan: string | null;
91
114
  financerId: number | null;
@@ -104,6 +127,11 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
104
127
  authorizationCode: string | null;
105
128
  authorizationCodeExpiration: Date | null;
106
129
  } | null>;
130
+ sendVerificationCode: (params: {
131
+ identificationType: "ndi" | "passport" | "credential";
132
+ identificationValue: string;
133
+ channel: "1" | "2";
134
+ }) => Promise<any>;
107
135
  getDiagnosticaHistory: (patient: {
108
136
  identificationType: "ndi" | "passport" | "credential";
109
137
  identificationValue: string;
@@ -115,22 +143,22 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
115
143
  deepLink: string;
116
144
  }[]>;
117
145
  getDiagnosticaDeepLink: (kiosk: string, user: {
118
- language: string;
119
146
  firstName: string;
120
147
  lastName: string;
121
- birthday: Date;
122
148
  identificationType: "dni";
123
149
  identificationValue: string;
124
150
  gender: "m" | "f";
125
151
  phone: string;
126
152
  email: string;
153
+ language: string;
154
+ birthday: Date;
127
155
  }, patient: {
128
156
  firstName: string;
129
157
  lastName: string;
130
- birthday: Date;
131
158
  identificationType: "dni";
132
159
  identificationValue: string;
133
160
  gender: "m" | "f";
161
+ birthday: Date;
134
162
  }) => Promise<{
135
163
  forwardingRequired: true;
136
164
  deepLink: string;
@@ -138,22 +166,22 @@ export declare const doc24Sdk: (params: Doc24.SdkParams) => Promise<{
138
166
  forwardingRequired: false;
139
167
  }>;
140
168
  getDiagnosticaAccess: (kiosk: string, user: {
141
- language: string;
142
169
  firstName: string;
143
170
  lastName: string;
144
- birthday: Date;
145
171
  identificationType: "dni";
146
172
  identificationValue: string;
147
173
  gender: "m" | "f";
148
174
  phone: string;
149
175
  email: string;
176
+ language: string;
177
+ birthday: Date;
150
178
  }, patient: {
151
179
  firstName: string;
152
180
  lastName: string;
153
- birthday: Date;
154
181
  identificationType: "dni";
155
182
  identificationValue: string;
156
183
  gender: "m" | "f";
184
+ birthday: Date;
157
185
  }) => Promise<void>;
158
186
  }>;
159
187
  export type { Doc24 } from './types';