@integraciones_doc24/sdk 1.16.41 → 1.16.42
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.
- package/README.md +246 -225
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/schemas.d.ts +105 -0
- package/lib/schemas.js +36 -0
- package/lib/types.d.ts +5 -0
- package/lib/userSdk/eligibility.d.ts +29 -0
- package/lib/userSdk/eligibility.js +81 -0
- package/lib/userSdk/index.js +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,225 +1,246 @@
|
|
|
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: PatientSearch) => 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
|
-
|
|
224
|
-
|
|
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
|
+
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: PatientSearch) => 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
|
+
checkEligibility: (params: EligibilityParams) => Promise<EligibilityResponse>;
|
|
224
|
+
userId: number;
|
|
225
|
+
};
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
#### Eligibility (InSSSeP)
|
|
229
|
+
|
|
230
|
+
`checkEligibility` calls `POST /eligibility`. Doc24 queries InSSSeP and, when it accepts (code `100`), stores the result and updates the patient's document.
|
|
231
|
+
|
|
232
|
+
```ts
|
|
233
|
+
const result = await userSdk.checkEligibility({
|
|
234
|
+
patientId: 12345,
|
|
235
|
+
identificationType: '3', // '3' = DNI, '8' = Credencial
|
|
236
|
+
identificationValue: '30111222',
|
|
237
|
+
// Optional, always together:
|
|
238
|
+
// credentialToken: '123',
|
|
239
|
+
// credential: '354495',
|
|
240
|
+
});
|
|
241
|
+
// { eligible, code, message, affiliate: {...} | null, notices, timestamp }
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
- The response signature is verified with the integrator key. If it doesn't match, a `ResponseSignatureError` is thrown.
|
|
245
|
+
- `eligible: false` is a normal response: `code` and `message` carry InSSSeP's answer.
|
|
246
|
+
- Errors are thrown by axios with `error.response.data.mensaje`: `INVALID PARAMS` (400), `INVALID PATIENT`, `SERVICE DISABLED` or `INSSSEP_UNAVAILABLE` (409).
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.doc24Sdk = void 0;
|
|
3
|
+
exports.ResponseSignatureError = exports.doc24Sdk = void 0;
|
|
4
4
|
const webhook_1 = require("./webhook");
|
|
5
5
|
const baseSdk_1 = require("./baseSdk");
|
|
6
6
|
const request_1 = require("./request");
|
|
@@ -20,3 +20,5 @@ const doc24Sdk = async (params) => {
|
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
exports.doc24Sdk = doc24Sdk;
|
|
23
|
+
var eligibility_1 = require("./userSdk/eligibility");
|
|
24
|
+
Object.defineProperty(exports, "ResponseSignatureError", { enumerable: true, get: function () { return eligibility_1.ResponseSignatureError; } });
|
package/lib/schemas.d.ts
CHANGED
|
@@ -2705,6 +2705,111 @@ export declare const doc24Schemas: {
|
|
|
2705
2705
|
socketAuthToken: string;
|
|
2706
2706
|
};
|
|
2707
2707
|
}>;
|
|
2708
|
+
eligibilityIdentificationType: import("zod").ZodEnum<["3", "8"]>;
|
|
2709
|
+
eligibilityParams: import("zod").ZodEffects<import("zod").ZodObject<{
|
|
2710
|
+
patientId: import("zod").ZodNumber;
|
|
2711
|
+
identificationType: import("zod").ZodEnum<["3", "8"]>;
|
|
2712
|
+
identificationValue: import("zod").ZodString;
|
|
2713
|
+
credentialToken: import("zod").ZodOptional<import("zod").ZodString>;
|
|
2714
|
+
credential: import("zod").ZodOptional<import("zod").ZodString>;
|
|
2715
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
2716
|
+
credential?: string | undefined;
|
|
2717
|
+
credentialToken?: string | undefined;
|
|
2718
|
+
identificationType: "3" | "8";
|
|
2719
|
+
identificationValue: string;
|
|
2720
|
+
patientId: number;
|
|
2721
|
+
}, {
|
|
2722
|
+
credential?: string | undefined;
|
|
2723
|
+
credentialToken?: string | undefined;
|
|
2724
|
+
identificationType: "3" | "8";
|
|
2725
|
+
identificationValue: string;
|
|
2726
|
+
patientId: number;
|
|
2727
|
+
}>, {
|
|
2728
|
+
credential?: string | undefined;
|
|
2729
|
+
credentialToken?: string | undefined;
|
|
2730
|
+
identificationType: "3" | "8";
|
|
2731
|
+
identificationValue: string;
|
|
2732
|
+
patientId: number;
|
|
2733
|
+
}>;
|
|
2734
|
+
eligibilityAffiliate: import("zod").ZodObject<{
|
|
2735
|
+
name: import("zod").ZodOptional<import("zod").ZodString>;
|
|
2736
|
+
holder: import("zod").ZodOptional<import("zod").ZodString>;
|
|
2737
|
+
gender: import("zod").ZodOptional<import("zod").ZodString>;
|
|
2738
|
+
age: import("zod").ZodOptional<import("zod").ZodString>;
|
|
2739
|
+
affiliateNumber: import("zod").ZodOptional<import("zod").ZodString>;
|
|
2740
|
+
plan: import("zod").ZodOptional<import("zod").ZodString>;
|
|
2741
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
2742
|
+
gender?: string | undefined;
|
|
2743
|
+
plan?: string | undefined;
|
|
2744
|
+
name?: string | undefined;
|
|
2745
|
+
holder?: string | undefined;
|
|
2746
|
+
age?: string | undefined;
|
|
2747
|
+
affiliateNumber?: string | undefined;
|
|
2748
|
+
}, {
|
|
2749
|
+
gender?: string | undefined;
|
|
2750
|
+
plan?: string | undefined;
|
|
2751
|
+
name?: string | undefined;
|
|
2752
|
+
holder?: string | undefined;
|
|
2753
|
+
age?: string | undefined;
|
|
2754
|
+
affiliateNumber?: string | undefined;
|
|
2755
|
+
}>;
|
|
2756
|
+
eligibilityResponse: import("zod").ZodObject<{
|
|
2757
|
+
eligible: import("zod").ZodBoolean;
|
|
2758
|
+
code: import("zod").ZodString;
|
|
2759
|
+
message: import("zod").ZodString;
|
|
2760
|
+
affiliate: import("zod").ZodNullable<import("zod").ZodObject<{
|
|
2761
|
+
name: import("zod").ZodOptional<import("zod").ZodString>;
|
|
2762
|
+
holder: import("zod").ZodOptional<import("zod").ZodString>;
|
|
2763
|
+
gender: import("zod").ZodOptional<import("zod").ZodString>;
|
|
2764
|
+
age: import("zod").ZodOptional<import("zod").ZodString>;
|
|
2765
|
+
affiliateNumber: import("zod").ZodOptional<import("zod").ZodString>;
|
|
2766
|
+
plan: import("zod").ZodOptional<import("zod").ZodString>;
|
|
2767
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
2768
|
+
gender?: string | undefined;
|
|
2769
|
+
plan?: string | undefined;
|
|
2770
|
+
name?: string | undefined;
|
|
2771
|
+
holder?: string | undefined;
|
|
2772
|
+
age?: string | undefined;
|
|
2773
|
+
affiliateNumber?: string | undefined;
|
|
2774
|
+
}, {
|
|
2775
|
+
gender?: string | undefined;
|
|
2776
|
+
plan?: string | undefined;
|
|
2777
|
+
name?: string | undefined;
|
|
2778
|
+
holder?: string | undefined;
|
|
2779
|
+
age?: string | undefined;
|
|
2780
|
+
affiliateNumber?: string | undefined;
|
|
2781
|
+
}>>;
|
|
2782
|
+
notices: import("zod").ZodArray<import("zod").ZodString, "many">;
|
|
2783
|
+
timestamp: import("zod").ZodDate;
|
|
2784
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
2785
|
+
code: string;
|
|
2786
|
+
message: string;
|
|
2787
|
+
timestamp: Date;
|
|
2788
|
+
eligible: boolean;
|
|
2789
|
+
affiliate: {
|
|
2790
|
+
gender?: string | undefined;
|
|
2791
|
+
plan?: string | undefined;
|
|
2792
|
+
name?: string | undefined;
|
|
2793
|
+
holder?: string | undefined;
|
|
2794
|
+
age?: string | undefined;
|
|
2795
|
+
affiliateNumber?: string | undefined;
|
|
2796
|
+
} | null;
|
|
2797
|
+
notices: string[];
|
|
2798
|
+
}, {
|
|
2799
|
+
code: string;
|
|
2800
|
+
message: string;
|
|
2801
|
+
timestamp: Date;
|
|
2802
|
+
eligible: boolean;
|
|
2803
|
+
affiliate: {
|
|
2804
|
+
gender?: string | undefined;
|
|
2805
|
+
plan?: string | undefined;
|
|
2806
|
+
name?: string | undefined;
|
|
2807
|
+
holder?: string | undefined;
|
|
2808
|
+
age?: string | undefined;
|
|
2809
|
+
affiliateNumber?: string | undefined;
|
|
2810
|
+
} | null;
|
|
2811
|
+
notices: string[];
|
|
2812
|
+
}>;
|
|
2708
2813
|
emailOrPhone: import("zod").ZodEffects<import("zod").ZodUnion<[import("zod").ZodObject<{
|
|
2709
2814
|
email: import("zod").ZodString;
|
|
2710
2815
|
phone: import("zod").ZodString;
|
package/lib/schemas.js
CHANGED
|
@@ -366,6 +366,38 @@ const binahWellnessResponse = zod_1.object({
|
|
|
366
366
|
}),
|
|
367
367
|
signature: zod_1.string(),
|
|
368
368
|
});
|
|
369
|
+
// WEH-1937: InSSSeP eligibility. Codes from InSSSeP Table 15.
|
|
370
|
+
const eligibilityIdentificationType = zod_1.enum(['3', '8']);
|
|
371
|
+
const eligibilityParams = zod_1.object({
|
|
372
|
+
patientId: zod_1.number().int().positive(),
|
|
373
|
+
// '3' = DNI, '8' = Credencial
|
|
374
|
+
identificationType: eligibilityIdentificationType,
|
|
375
|
+
identificationValue: zod_1.string().regex(/^\d+$/),
|
|
376
|
+
credentialToken: zod_1.string()
|
|
377
|
+
.regex(/^\d{1,3}$/)
|
|
378
|
+
.optional(),
|
|
379
|
+
credential: zod_1.string().min(1).optional(),
|
|
380
|
+
}).refine((params) => (params.credentialToken === undefined) ===
|
|
381
|
+
(params.credential === undefined), {
|
|
382
|
+
message: 'credentialToken and credential must be sent together',
|
|
383
|
+
path: ['credentialToken'],
|
|
384
|
+
});
|
|
385
|
+
const eligibilityAffiliate = zod_1.object({
|
|
386
|
+
name: zod_1.string().optional(),
|
|
387
|
+
holder: zod_1.string().optional(),
|
|
388
|
+
gender: zod_1.string().optional(),
|
|
389
|
+
age: zod_1.string().optional(),
|
|
390
|
+
affiliateNumber: zod_1.string().optional(),
|
|
391
|
+
plan: zod_1.string().optional(),
|
|
392
|
+
});
|
|
393
|
+
const eligibilityResponse = zod_1.object({
|
|
394
|
+
eligible: zod_1.boolean(),
|
|
395
|
+
code: zod_1.string(),
|
|
396
|
+
message: zod_1.string(),
|
|
397
|
+
affiliate: eligibilityAffiliate.nullable(),
|
|
398
|
+
notices: zod_1.array(zod_1.string()),
|
|
399
|
+
timestamp: zod_1.date(),
|
|
400
|
+
});
|
|
369
401
|
const integrationErrorDetailsMaxBytes = 64 * 1024;
|
|
370
402
|
const reportIntegrationErrorParams = zod_1.object({
|
|
371
403
|
integration: zod_1.string().min(1),
|
|
@@ -582,6 +614,10 @@ exports.doc24Schemas = {
|
|
|
582
614
|
externalAppointment,
|
|
583
615
|
binahWellnessResponse,
|
|
584
616
|
binahWellnessGetLinkParams,
|
|
617
|
+
eligibilityIdentificationType,
|
|
618
|
+
eligibilityParams,
|
|
619
|
+
eligibilityAffiliate,
|
|
620
|
+
eligibilityResponse,
|
|
585
621
|
emailOrPhone,
|
|
586
622
|
emailOrPhoneCode,
|
|
587
623
|
uploadFileConsultationParams: zod_1.object({
|
package/lib/types.d.ts
CHANGED
|
@@ -51,6 +51,10 @@ export declare namespace Doc24 {
|
|
|
51
51
|
type ExternalAppointment = TypeOf<typeof doc24Schemas.externalAppointment>;
|
|
52
52
|
type BinahWellnessGetLinkParams = TypeOf<typeof doc24Schemas.binahWellnessGetLinkParams>;
|
|
53
53
|
type BinahWellnessResponse = TypeOf<typeof doc24Schemas.binahWellnessResponse>;
|
|
54
|
+
type EligibilityIdentificationType = TypeOf<typeof doc24Schemas.eligibilityIdentificationType>;
|
|
55
|
+
type EligibilityParams = TypeOf<typeof doc24Schemas.eligibilityParams>;
|
|
56
|
+
type EligibilityAffiliate = TypeOf<typeof doc24Schemas.eligibilityAffiliate>;
|
|
57
|
+
type EligibilityResponse = TypeOf<typeof doc24Schemas.eligibilityResponse>;
|
|
54
58
|
type ProfessionalsBySpecialtyFilter = TypeOf<typeof doc24Schemas.professionalsBySpecialtyFilter>;
|
|
55
59
|
type ReportIntegrationErrorParams = TypeOf<typeof doc24Schemas.reportIntegrationErrorParams>;
|
|
56
60
|
type ReportIntegrationErrorResponse = TypeOf<typeof doc24Schemas.reportIntegrationErrorResponse>;
|
|
@@ -112,6 +116,7 @@ export declare namespace Doc24 {
|
|
|
112
116
|
getBinahWellnessLink: (body: BinahWellnessGetLinkParams) => Promise<BinahWellnessResponse>;
|
|
113
117
|
uploadFileConsultation: (params: UploadFileConsultationParams) => Promise<UploadFileConsultationResponse>;
|
|
114
118
|
deleteFileConsultation: (params: DeleteFileConsultationParams) => Promise<void>;
|
|
119
|
+
checkEligibility: (params: EligibilityParams) => Promise<EligibilityResponse>;
|
|
115
120
|
};
|
|
116
121
|
namespace Webhook {
|
|
117
122
|
type StatusChangeEventStatus = 'S' | 'C' | 'F' | 'A' | 'D' | 'L';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { RequestMaker } from '../request';
|
|
2
|
+
export declare class ResponseSignatureError extends Error {
|
|
3
|
+
constructor();
|
|
4
|
+
}
|
|
5
|
+
export declare const signResponseData: (data: unknown, key: string) => string;
|
|
6
|
+
export declare const isValidResponseSignature: (data: unknown, signature: unknown, key: string) => boolean;
|
|
7
|
+
export declare const getEligibilityMethods: (makeRequest: RequestMaker, key: string) => {
|
|
8
|
+
checkEligibility: (params: {
|
|
9
|
+
credential?: string | undefined;
|
|
10
|
+
credentialToken?: string | undefined;
|
|
11
|
+
identificationType: "3" | "8";
|
|
12
|
+
identificationValue: string;
|
|
13
|
+
patientId: number;
|
|
14
|
+
}) => Promise<{
|
|
15
|
+
code: string;
|
|
16
|
+
message: string;
|
|
17
|
+
timestamp: Date;
|
|
18
|
+
eligible: boolean;
|
|
19
|
+
affiliate: {
|
|
20
|
+
gender?: string | undefined;
|
|
21
|
+
plan?: string | undefined;
|
|
22
|
+
name?: string | undefined;
|
|
23
|
+
holder?: string | undefined;
|
|
24
|
+
age?: string | undefined;
|
|
25
|
+
affiliateNumber?: string | undefined;
|
|
26
|
+
} | null;
|
|
27
|
+
notices: string[];
|
|
28
|
+
}>;
|
|
29
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
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.getEligibilityMethods = exports.isValidResponseSignature = exports.signResponseData = exports.ResponseSignatureError = void 0;
|
|
7
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
+
const zod_1 = require("zod");
|
|
9
|
+
const validation_1 = require("../request/validation");
|
|
10
|
+
const schemas_1 = require("../schemas");
|
|
11
|
+
const utils_1 = require("../utils");
|
|
12
|
+
class ResponseSignatureError extends Error {
|
|
13
|
+
constructor() {
|
|
14
|
+
super('Invalid signature in Doc24 response');
|
|
15
|
+
this.name = 'ResponseSignatureError';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.ResponseSignatureError = ResponseSignatureError;
|
|
19
|
+
// Doc24 signs `data` as serialized by PHP's json_encode: compact, `/` escaped
|
|
20
|
+
// as `\/` and non-ASCII characters as `\uXXXX`. Key order is the one received.
|
|
21
|
+
const phpJsonEncode = (value) => JSON.stringify(value)
|
|
22
|
+
.replace(/\//g, '\\/')
|
|
23
|
+
.replace(/[\u0080-]/g, (char) => '\\u' + char.charCodeAt(0).toString(16).padStart(4, '0'));
|
|
24
|
+
// base64(HMAC-SHA256(json(data), key)) with `+` → `-`, `/` → `_`, `=` → `,`
|
|
25
|
+
const signResponseData = (data, key) => crypto_1.default
|
|
26
|
+
.createHmac('sha256', key)
|
|
27
|
+
.update(phpJsonEncode(data))
|
|
28
|
+
.digest('base64')
|
|
29
|
+
.replace(/\+/g, '-')
|
|
30
|
+
.replace(/\//g, '_')
|
|
31
|
+
.replace(/=/g, ',');
|
|
32
|
+
exports.signResponseData = signResponseData;
|
|
33
|
+
const isValidResponseSignature = (data, signature, key) => {
|
|
34
|
+
if (typeof signature !== 'string')
|
|
35
|
+
return false;
|
|
36
|
+
const expected = Buffer.from(exports.signResponseData(data, key));
|
|
37
|
+
const received = Buffer.from(signature);
|
|
38
|
+
return (expected.length === received.length &&
|
|
39
|
+
crypto_1.default.timingSafeEqual(expected, received));
|
|
40
|
+
};
|
|
41
|
+
exports.isValidResponseSignature = isValidResponseSignature;
|
|
42
|
+
const getEligibilityMethods = (makeRequest, key) => {
|
|
43
|
+
// Errors (4xx) are thrown by axios; `error.response.data.mensaje` carries
|
|
44
|
+
// INVALID PARAMS, INVALID PATIENT, SERVICE DISABLED or INSSSEP_UNAVAILABLE.
|
|
45
|
+
const checkEligibility = async (params) => {
|
|
46
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
47
|
+
const response = await makeRequest('POST', '/eligibility', {
|
|
48
|
+
patient_id: params.patientId,
|
|
49
|
+
identification_type: params.identificationType,
|
|
50
|
+
identification_value: params.identificationValue,
|
|
51
|
+
credential_token: params.credentialToken,
|
|
52
|
+
credential: params.credential,
|
|
53
|
+
});
|
|
54
|
+
if (!exports.isValidResponseSignature(response.data, response.signature, key))
|
|
55
|
+
throw new ResponseSignatureError();
|
|
56
|
+
const data = response.data;
|
|
57
|
+
const affiliate = data.affiliate;
|
|
58
|
+
return {
|
|
59
|
+
eligible: data.eligible,
|
|
60
|
+
code: data.code,
|
|
61
|
+
message: data.message,
|
|
62
|
+
affiliate: affiliate
|
|
63
|
+
? {
|
|
64
|
+
name: (_a = affiliate.name) !== null && _a !== void 0 ? _a : undefined,
|
|
65
|
+
holder: (_b = affiliate.holder) !== null && _b !== void 0 ? _b : undefined,
|
|
66
|
+
gender: (_c = affiliate.gender) !== null && _c !== void 0 ? _c : undefined,
|
|
67
|
+
age: (_d = affiliate.age) !== null && _d !== void 0 ? _d : undefined,
|
|
68
|
+
affiliateNumber: (_e = affiliate.affiliate_number) !== null && _e !== void 0 ? _e : undefined,
|
|
69
|
+
plan: (_f = affiliate.plan) !== null && _f !== void 0 ? _f : undefined,
|
|
70
|
+
}
|
|
71
|
+
: null,
|
|
72
|
+
notices: (_g = data.notices) !== null && _g !== void 0 ? _g : [],
|
|
73
|
+
// UTC
|
|
74
|
+
timestamp: utils_1.parseDateTime(data.timestamp, '+00'),
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
return {
|
|
78
|
+
checkEligibility: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.eligibilityParams]), schemas_1.doc24Schemas.eligibilityResponse, checkEligibility),
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
exports.getEligibilityMethods = getEligibilityMethods;
|
package/lib/userSdk/index.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.userSdk = void 0;
|
|
|
4
4
|
const request_1 = require("../request");
|
|
5
5
|
const binah_1 = require("./binah");
|
|
6
6
|
const chat_1 = require("./chat");
|
|
7
|
+
const eligibility_1 = require("./eligibility");
|
|
7
8
|
const external_1 = require("./external");
|
|
8
9
|
const patients_1 = require("./patients");
|
|
9
10
|
const schedule_1 = require("./schedule");
|
|
@@ -18,6 +19,7 @@ const userSdk = async (url, credentials, userId) => {
|
|
|
18
19
|
const chatMethods = chat_1.getChatMethods(makeRequest);
|
|
19
20
|
const externalMethods = external_1.getExternalMethods(makeRequest);
|
|
20
21
|
const binahWellnessMethods = binah_1.getBinahWellnessMethods(makeRequest);
|
|
22
|
+
const eligibilityMethods = eligibility_1.getEligibilityMethods(makeRequest, credentials.key);
|
|
21
23
|
const sdk = {
|
|
22
24
|
...patientMethods,
|
|
23
25
|
...specialtyMethods,
|
|
@@ -26,6 +28,7 @@ const userSdk = async (url, credentials, userId) => {
|
|
|
26
28
|
...chatMethods,
|
|
27
29
|
...externalMethods,
|
|
28
30
|
...binahWellnessMethods,
|
|
31
|
+
...eligibilityMethods,
|
|
29
32
|
userId,
|
|
30
33
|
};
|
|
31
34
|
return sdk;
|