@integraciones_doc24/sdk 1.16.37 → 1.16.38

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 (46) hide show
  1. package/README.md +225 -206
  2. package/lib/baseSdk/diagnostica.d.ts +54 -54
  3. package/lib/baseSdk/diagnostica.js +82 -82
  4. package/lib/baseSdk/external.d.ts +177 -177
  5. package/lib/baseSdk/external.js +96 -96
  6. package/lib/baseSdk/index.d.ts +2 -2
  7. package/lib/baseSdk/index.js +76 -77
  8. package/lib/baseSdk/user.d.ts +112 -112
  9. package/lib/baseSdk/user.js +136 -136
  10. package/lib/index.d.ts +400 -400
  11. package/lib/index.js +22 -22
  12. package/lib/request/index.d.ts +4 -4
  13. package/lib/request/index.js +32 -32
  14. package/lib/request/token.d.ts +2 -2
  15. package/lib/request/token.js +34 -34
  16. package/lib/request/validation.d.ts +10 -10
  17. package/lib/request/validation.js +28 -28
  18. package/lib/schemas.d.ts +2482 -2703
  19. package/lib/schemas.js +540 -573
  20. package/lib/types.d.ts +170 -174
  21. package/lib/types.js +2 -2
  22. package/lib/userSdk/binah.d.ts +21 -21
  23. package/lib/userSdk/binah.js +20 -20
  24. package/lib/userSdk/chat.d.ts +57 -57
  25. package/lib/userSdk/chat.js +98 -98
  26. package/lib/userSdk/external.d.ts +34 -34
  27. package/lib/userSdk/external.js +72 -72
  28. package/lib/userSdk/index.d.ts +2 -2
  29. package/lib/userSdk/index.js +33 -33
  30. package/lib/userSdk/patients.d.ts +58 -58
  31. package/lib/userSdk/patients.js +89 -89
  32. package/lib/userSdk/schedule.d.ts +58 -59
  33. package/lib/userSdk/schedule.js +89 -90
  34. package/lib/userSdk/specialties.d.ts +19 -19
  35. package/lib/userSdk/specialties.js +48 -48
  36. package/lib/userSdk/videoVisit.d.ts +175 -225
  37. package/lib/userSdk/videoVisit.js +242 -283
  38. package/lib/utils.d.ts +3 -4
  39. package/lib/utils.js +43 -68
  40. package/lib/webhook/index.d.ts +2 -2
  41. package/lib/webhook/index.js +67 -67
  42. package/lib/webhook/responses.d.ts +35 -35
  43. package/lib/webhook/responses.js +42 -42
  44. package/lib/webhook/token.d.ts +2 -2
  45. package/lib/webhook/token.js +23 -23
  46. package/package.json +37 -37
package/README.md CHANGED
@@ -1,206 +1,225 @@
1
- # @integraciones_doc24/sdk
2
-
3
- Node.JS library for accessing doc24 api
4
-
5
- ## Installation
6
-
7
- `npm i @integraciones_doc24/sdk`
8
-
9
- ## Usage
10
-
11
- ```ts
12
- import {doc24Sdk} from '@integraciones_doc24/sdk';
13
-
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();
25
-
26
- const userSdk = await baseSdk.getUserInstance(user);
27
-
28
- return await userSdk.getSpecialties('instant', 'ES');
29
- };
30
-
31
- const getRequestHandler = async () => {
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
- };
61
- ```
62
-
63
- The library exports the function `doc24Sdk`. It takes one parameters of type `SdkParams`, and returns a `BaseSdk`.
64
- It also returns an extra `getRequestHandler` function that takes a `RequestHandlerParams`
65
-
66
- ```ts
67
- type SdkCredentials = {
68
- iss: string;
69
- key: string;
70
- };
71
- type SdkParams = {
72
- url: string;
73
- credentials: SdkCredentials;
74
- };
75
- export type BaseSdk = {
76
- declareUser: (params: DeclareUserParams) => Promise<DeclareUserResponse>;
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
- getCoverageInfo: (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
- externalLogin: (
100
- params: ExternalLoginParams,
101
- ) => Promise<ExternalLoginResponse>;
102
- preExternalEnrollment: (params: PreExternalEnrollmentParams) => Promise<void>;
103
- externalEnrollment: (
104
- params: ExternalEnrollmentParams,
105
- ) => Promise<ExternalLoginResponse>;
106
- sendExternalVerificationCode: (
107
- params: SendExternalVerificationCodeParams,
108
- ) => Promise<void>;
109
- verifyExternalVerificationCode: (
110
- params: VerifyExternalVerificationCodeParams,
111
- ) => Promise<any>;
112
- externalResetPassword: (params: ExternalResetPasswordParams) => Promise<any>;
113
- getExternalStudiesHistoryLink: (
114
- patient: ExternalPatient,
115
- ) => Promise<string | null>;
116
- getExternalAppointmentsLink: (
117
- identificationValue: string,
118
- birthdate: Date,
119
- ) => Promise<string | null>;
120
- getExternalAppointments: () => Promise<ExternalAppointment[]>;
121
- cancelExternalAppointment: (
122
- appointmentId: ExternalAppointment,
123
- ) => Promise<void>;
124
- };
125
-
126
- type RequestHandlerParams = {
127
- // Credentials that doc24 should use when singing the jwt
128
- credentials: SdkCredentials;
129
- eventHandlers: Webhook.Events;
130
- // Address in which doc24 should send the requests
131
- baseAddress: string;
132
- };
133
- ```
134
-
135
- `getRequestHandler` should be called only once, and takes care of managing the webhook that receives events from doc24.
136
-
137
- ### Express example
138
-
139
- ```ts
140
- const handler = await getRequestHandler();
141
- app.all('/doc24', async (req, res) => {
142
- const response = await handler({
143
- headers: req.headers,
144
- body: req.body,
145
- query: req.query,
146
- });
147
-
148
- res.status(response.status.code).json(response.data);
149
- });
150
- ```
151
-
152
- ### UserSdk
153
-
154
- Most of the methods need a user specified, so `getUserInstance` returns an instance of `UserSdk` with them.
155
-
156
- ```ts
157
- export type UserSdk = {
158
- declarePatient: (
159
- params: DeclarePatientParams,
160
- ) => Promise<DeclarePatientResponse>;
161
- getPatientId: (patient: Patient) => Promise<number>;
162
- deletePatient: (patientId: number) => Promise<void>;
163
- getSpecialties: (
164
- mode: SpecialtyMode,
165
- language: string,
166
- ) => Promise<Specialty[]>;
167
- getScheduleDates: (
168
- patientId: number,
169
- filter?: ScheduleAvailabilityFilter,
170
- ) => Promise<Date[]>;
171
- getSchedule: (
172
- patientId: number,
173
- specialtyId: number,
174
- filter?: ScheduleFilter,
175
- ) => Promise<AvailableAppointment[]>;
176
- getAppointment: (appointmentId: number) => Promise<Appointment>;
177
- getAppointmentByVcToken: (vcToken: string) => Promise<Appointment>;
178
- scheduleVideoVisit: (params: ScheduleParameters) => Promise<string>;
179
- cancelVideoVisit: (vcToken: string) => Promise<void>;
180
- getVideoVisit: (vcToken: string, patientId: number) => Promise<VideoVisit>;
181
- getVideoVisitDetails: (vcId: number) => Promise<VideoVisitDetails>;
182
- getCompleteVideoVisitDetails: (
183
- vcId: number,
184
- ) => Promise<CompleteVideoVisitDetails>;
185
- getVideoVisitLink: (
186
- vcToken: string,
187
- patientId: number,
188
- ) => Promise<string | null>;
189
- getPatientVideoVisitHistory: (
190
- patientId: number,
191
- ) => Promise<HistoricalVideoVisit[]>;
192
- getActiveVideoVisits: () => Promise<ActiveVideoVisitData[]>;
193
- getAvailableChatrooms: (
194
- patientId: number,
195
- specialtyId: number,
196
- filter: ChatroomAvailabilityFilter,
197
- ) => Promise<AvailableChatroom[]>;
198
- createNewChat: (chatParameters: ChatParameters) => Promise<number>;
199
- getPatientChats: (patientId: number) => Promise<ChatDetails[]>;
200
- getChatPosts: (chatId: number) => Promise<ChatPost[]>;
201
- cancelChat: (chatId: number) => Promise<void>;
202
- sendChatMessage: (chatId: number, message: string) => Promise<number>;
203
- getPatientPHR: (patientId: number) => Promise<string>;
204
- userId: number;
205
- };
206
- ```
1
+ # @integraciones_doc24/sdk
2
+
3
+ Node.JS library for accessing doc24 api
4
+
5
+ ## Installation
6
+
7
+ `npm i @integraciones_doc24/sdk`
8
+
9
+ ## Usage
10
+
11
+ ```ts
12
+ import {doc24Sdk} from '@integraciones_doc24/sdk';
13
+
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();
25
+
26
+ const userSdk = await baseSdk.getUserInstance(user);
27
+
28
+ return await userSdk.getSpecialties('instant', 'ES');
29
+ };
30
+
31
+ const getRequestHandler = async () => {
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
+ };
61
+ ```
62
+
63
+ The library exports the function `doc24Sdk`. It takes one parameters of type `SdkParams`, and returns a `BaseSdk`.
64
+ It also returns an extra `getRequestHandler` function that takes a `RequestHandlerParams`
65
+
66
+ ```ts
67
+ type SdkCredentials = {
68
+ iss: string;
69
+ key: string;
70
+ };
71
+ type SdkParams = {
72
+ url: string;
73
+ credentials: SdkCredentials;
74
+ };
75
+ export type BaseSdk = {
76
+ declareUser: (params: DeclareUserParams) => Promise<DeclareUserResponse>;
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
+ getCoverageInfo: (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
+ externalLogin: (
100
+ params: ExternalLoginParams,
101
+ ) => Promise<ExternalLoginResponse>;
102
+ preExternalEnrollment: (params: PreExternalEnrollmentParams) => Promise<void>;
103
+ externalEnrollment: (
104
+ params: ExternalEnrollmentParams,
105
+ ) => Promise<ExternalLoginResponse>;
106
+ sendExternalVerificationCode: (
107
+ params: SendExternalVerificationCodeParams,
108
+ ) => Promise<void>;
109
+ verifyExternalVerificationCode: (
110
+ params: VerifyExternalVerificationCodeParams,
111
+ ) => Promise<any>;
112
+ externalResetPassword: (params: ExternalResetPasswordParams) => Promise<any>;
113
+ getExternalStudiesHistoryLink: (
114
+ patient: ExternalPatient,
115
+ ) => Promise<string | null>;
116
+ getExternalAppointmentsLink: (
117
+ identificationValue: string,
118
+ birthdate: Date,
119
+ ) => Promise<string | null>;
120
+ getExternalAppointments: () => Promise<ExternalAppointment[]>;
121
+ cancelExternalAppointment: (
122
+ appointmentId: ExternalAppointment,
123
+ ) => Promise<void>;
124
+ reportIntegrationError: (
125
+ params: ReportIntegrationErrorParams,
126
+ ) => Promise<ReportIntegrationErrorResponse>;
127
+ };
128
+
129
+ type ReportIntegrationErrorParams = {
130
+ integration: string;
131
+ operation?: string;
132
+ severity?: 'INFO' | 'WARNING' | 'ERROR' | 'CRITICAL';
133
+ errorCode?: string;
134
+ httpStatus?: number;
135
+ // Payload of the request sent to the third party that ended in error
136
+ params: Record<string, unknown>;
137
+ occurredAt: Date;
138
+ // Idempotency key: reporting the same externalId again returns the same errorId
139
+ externalId?: string;
140
+ // Up to 64 KB once serialized. Never include credentials or tokens.
141
+ details?: Record<string, unknown>;
142
+ };
143
+ type ReportIntegrationErrorResponse = {errorId: number};
144
+
145
+ type RequestHandlerParams = {
146
+ // Credentials that doc24 should use when singing the jwt
147
+ credentials: SdkCredentials;
148
+ eventHandlers: Webhook.Events;
149
+ // Address in which doc24 should send the requests
150
+ baseAddress: string;
151
+ };
152
+ ```
153
+
154
+ `getRequestHandler` should be called only once, and takes care of managing the webhook that receives events from doc24.
155
+
156
+ ### Express example
157
+
158
+ ```ts
159
+ const handler = await getRequestHandler();
160
+ app.all('/doc24', async (req, res) => {
161
+ const response = await handler({
162
+ headers: req.headers,
163
+ body: req.body,
164
+ query: req.query,
165
+ });
166
+
167
+ res.status(response.status.code).json(response.data);
168
+ });
169
+ ```
170
+
171
+ ### UserSdk
172
+
173
+ Most of the methods need a user specified, so `getUserInstance` returns an instance of `UserSdk` with them.
174
+
175
+ ```ts
176
+ export type UserSdk = {
177
+ declarePatient: (
178
+ params: DeclarePatientParams,
179
+ ) => Promise<DeclarePatientResponse>;
180
+ getPatientId: (patient: Patient) => Promise<number>;
181
+ deletePatient: (patientId: number) => Promise<void>;
182
+ getSpecialties: (
183
+ mode: SpecialtyMode,
184
+ language: string,
185
+ ) => Promise<Specialty[]>;
186
+ getScheduleDates: (
187
+ patientId: number,
188
+ filter?: ScheduleAvailabilityFilter,
189
+ ) => Promise<Date[]>;
190
+ getSchedule: (
191
+ patientId: number,
192
+ specialtyId: number,
193
+ filter?: ScheduleFilter,
194
+ ) => Promise<AvailableAppointment[]>;
195
+ getAppointment: (appointmentId: number) => Promise<Appointment>;
196
+ getAppointmentByVcToken: (vcToken: string) => Promise<Appointment>;
197
+ scheduleVideoVisit: (params: ScheduleParameters) => Promise<string>;
198
+ cancelVideoVisit: (vcToken: string) => Promise<void>;
199
+ getVideoVisit: (vcToken: string, patientId: number) => Promise<VideoVisit>;
200
+ getVideoVisitDetails: (vcId: number) => Promise<VideoVisitDetails>;
201
+ getCompleteVideoVisitDetails: (
202
+ vcId: number,
203
+ ) => Promise<CompleteVideoVisitDetails>;
204
+ getVideoVisitLink: (
205
+ vcToken: string,
206
+ patientId: number,
207
+ ) => Promise<string | null>;
208
+ getPatientVideoVisitHistory: (
209
+ patientId: number,
210
+ ) => Promise<HistoricalVideoVisit[]>;
211
+ getActiveVideoVisits: () => Promise<ActiveVideoVisitData[]>;
212
+ getAvailableChatrooms: (
213
+ patientId: number,
214
+ specialtyId: number,
215
+ filter: ChatroomAvailabilityFilter,
216
+ ) => Promise<AvailableChatroom[]>;
217
+ createNewChat: (chatParameters: ChatParameters) => Promise<number>;
218
+ getPatientChats: (patientId: number) => Promise<ChatDetails[]>;
219
+ getChatPosts: (chatId: number) => Promise<ChatPost[]>;
220
+ cancelChat: (chatId: number) => Promise<void>;
221
+ sendChatMessage: (chatId: number, message: string) => Promise<number>;
222
+ getPatientPHR: (patientId: number) => Promise<string>;
223
+ userId: number;
224
+ };
225
+ ```
@@ -1,54 +1,54 @@
1
- import { RequestMaker } from '../request';
2
- export declare const getDiagnosticaMethods: (makeRequest: RequestMaker) => {
3
- getDiagnosticaHistory: (patient: {
4
- gender?: "m" | "f" | "o" | undefined;
5
- identificationType: "DNI";
6
- identificationValue: string;
7
- }, from: Date, to: Date) => Promise<{
8
- date: Date;
9
- location: string;
10
- exams: string[];
11
- deepLink: string;
12
- }[]>;
13
- getDiagnosticaDeepLink: (kiosk: string, user: {
14
- gender?: "m" | "f" | "o" | undefined;
15
- firstName: string;
16
- lastName: string;
17
- identificationType: "DNI";
18
- identificationValue: string;
19
- phone: string;
20
- email: string;
21
- language: string;
22
- birthday: Date;
23
- }, patient: {
24
- gender?: "m" | "f" | "o" | undefined;
25
- firstName: string;
26
- lastName: string;
27
- identificationType: "DNI";
28
- identificationValue: string;
29
- birthday: Date;
30
- }) => Promise<{
31
- forwardingRequired: true;
32
- deepLink: string;
33
- } | {
34
- forwardingRequired: false;
35
- }>;
36
- getDiagnosticaAccess: (kiosk: string, user: {
37
- gender?: "m" | "f" | "o" | undefined;
38
- firstName: string;
39
- lastName: string;
40
- identificationType: "DNI";
41
- identificationValue: string;
42
- phone: string;
43
- email: string;
44
- language: string;
45
- birthday: Date;
46
- }, patient: {
47
- gender?: "m" | "f" | "o" | undefined;
48
- firstName: string;
49
- lastName: string;
50
- identificationType: "DNI";
51
- identificationValue: string;
52
- birthday: Date;
53
- }) => Promise<void>;
54
- };
1
+ import { RequestMaker } from '../request';
2
+ export declare const getDiagnosticaMethods: (makeRequest: RequestMaker) => {
3
+ getDiagnosticaHistory: (patient: {
4
+ gender?: "m" | "f" | "o" | undefined;
5
+ identificationType: "DNI";
6
+ identificationValue: string;
7
+ }, from: Date, to: Date) => Promise<{
8
+ date: Date;
9
+ location: string;
10
+ exams: string[];
11
+ deepLink: string;
12
+ }[]>;
13
+ getDiagnosticaDeepLink: (kiosk: string, user: {
14
+ gender?: "m" | "f" | "o" | undefined;
15
+ firstName: string;
16
+ lastName: string;
17
+ identificationType: "DNI";
18
+ identificationValue: string;
19
+ phone: string;
20
+ email: string;
21
+ language: string;
22
+ birthday: Date;
23
+ }, patient: {
24
+ gender?: "m" | "f" | "o" | undefined;
25
+ firstName: string;
26
+ lastName: string;
27
+ identificationType: "DNI";
28
+ identificationValue: string;
29
+ birthday: Date;
30
+ }) => Promise<{
31
+ forwardingRequired: true;
32
+ deepLink: string;
33
+ } | {
34
+ forwardingRequired: false;
35
+ }>;
36
+ getDiagnosticaAccess: (kiosk: string, user: {
37
+ gender?: "m" | "f" | "o" | undefined;
38
+ firstName: string;
39
+ lastName: string;
40
+ identificationType: "DNI";
41
+ identificationValue: string;
42
+ phone: string;
43
+ email: string;
44
+ language: string;
45
+ birthday: Date;
46
+ }, patient: {
47
+ gender?: "m" | "f" | "o" | undefined;
48
+ firstName: string;
49
+ lastName: string;
50
+ identificationType: "DNI";
51
+ identificationValue: string;
52
+ birthday: Date;
53
+ }) => Promise<void>;
54
+ };