@healthcloudai/hc-settings-connector 0.0.3 → 0.0.5
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 +134 -10
- package/dist/index.cjs +136 -8
- package/dist/index.d.cts +41 -12
- package/dist/index.d.ts +41 -12
- package/dist/index.js +136 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -6,11 +6,19 @@ It is built on top of the shared Healthcheck HTTP and Login connectors.
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
## Features
|
|
9
|
-
1.
|
|
10
|
-
2. Generate a pre-signed URL for user
|
|
11
|
-
3.
|
|
12
|
-
4.
|
|
13
|
-
5.
|
|
9
|
+
1. Retrieve patient dashboard data
|
|
10
|
+
2. Generate a pre-signed URL for user selfie upload
|
|
11
|
+
3. Capture user selfie from uploaded file key
|
|
12
|
+
4. Generate a pre-signed URL for driving license / ID upload
|
|
13
|
+
5. Capture driving license / ID data from uploaded file key
|
|
14
|
+
6. Submit driving license / ID data
|
|
15
|
+
7. Generate a pre-signed URL for insurance upload
|
|
16
|
+
8. Capture insurance data from uploaded file key
|
|
17
|
+
9. Submit user insurance
|
|
18
|
+
10. Retrieve patient insurances
|
|
19
|
+
11. Update user profile image URL
|
|
20
|
+
12. Self deactivate user
|
|
21
|
+
13. Built on shared Healthcheck HttpClient and authentication layer
|
|
14
22
|
|
|
15
23
|
---
|
|
16
24
|
|
|
@@ -40,7 +48,10 @@ import { FetchClient } from "@healthcloudai/hc-http";
|
|
|
40
48
|
|
|
41
49
|
```ts
|
|
42
50
|
const httpClient = new FetchClient();
|
|
43
|
-
const authClient = new HCLoginClient(
|
|
51
|
+
const authClient = new HCLoginClient(httpClient);
|
|
52
|
+
|
|
53
|
+
authClient.configure("tenant-id", "dev");
|
|
54
|
+
await authClient.login("john.doe@test.com", "password");
|
|
44
55
|
|
|
45
56
|
const settingsClient = new HCSettingsClient(
|
|
46
57
|
httpClient,
|
|
@@ -64,6 +75,18 @@ const userInfo = await settingsClient.getUserInfo();
|
|
|
64
75
|
|
|
65
76
|
---
|
|
66
77
|
|
|
78
|
+
### Get Dashboard
|
|
79
|
+
|
|
80
|
+
Public signature: `settingsClient.getDashboard()`
|
|
81
|
+
|
|
82
|
+
Returns the current patient dashboard response.
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
const dashboard = await settingsClient.getDashboard();
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
67
90
|
### Submit Insurance
|
|
68
91
|
|
|
69
92
|
Public signature: `settingsClient.submitInsurance(payload)`
|
|
@@ -81,14 +104,101 @@ await settingsClient.submitInsurance({
|
|
|
81
104
|
});
|
|
82
105
|
```
|
|
83
106
|
|
|
84
|
-
###
|
|
107
|
+
### Get User Image Canned URL
|
|
108
|
+
|
|
109
|
+
Public signature: `settingsClient.getUserImageCannedUrl(extension)`
|
|
110
|
+
|
|
111
|
+
Generates a pre-signed upload URL for a user selfie file.
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
const selfieUpload = await settingsClient.getUserImageCannedUrl("jpg");
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Capture User Photo
|
|
118
|
+
|
|
119
|
+
Public signature: `settingsClient.captureUserPhoto(fileKey)`
|
|
120
|
+
|
|
121
|
+
Captures a user selfie through `POST /patient/capture`.
|
|
122
|
+
The client internally sends `Type: "userphoto"` and `FileID: fileKey`.
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
const capturedSelfie = await settingsClient.captureUserPhoto(
|
|
126
|
+
"selfie_639064123637965380.jpg"
|
|
127
|
+
);
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Get Driving License Canned URL
|
|
131
|
+
|
|
132
|
+
Public signature: `settingsClient.getDrivingLicenseCannedUrl(extension)`
|
|
133
|
+
|
|
134
|
+
Generates a pre-signed upload URL for a driving license / ID file.
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
const idUpload = await settingsClient.getDrivingLicenseCannedUrl("jpg");
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Capture Driving License
|
|
141
|
+
|
|
142
|
+
Public signature: `settingsClient.captureDrivingLicense(fileKey)`
|
|
143
|
+
|
|
144
|
+
Captures and extracts patient identification data through `POST /patient/capture`.
|
|
145
|
+
The client internally sends `Type: "identification"` and `FileID: fileKey`.
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
const capturedLicense = await settingsClient.captureDrivingLicense(
|
|
149
|
+
"idcard_639064123637965380.jpg"
|
|
150
|
+
);
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Update Driving License
|
|
154
|
+
|
|
155
|
+
Public signature: `settingsClient.updateDrivingLicense(payload)`
|
|
156
|
+
|
|
157
|
+
Updates patient driving license data through the wrapper-backed EHR route.
|
|
158
|
+
The client resolves the current patient's `EHR` internally from `authClient.getUserInfo()`
|
|
159
|
+
and sends the payload inside the backend `Data` wrapper.
|
|
160
|
+
`Image` should be the uploaded file key / path, not a raw file.
|
|
161
|
+
|
|
162
|
+
```ts
|
|
163
|
+
const response = await settingsClient.updateDrivingLicense({
|
|
164
|
+
Image: "idcard_639064123637965380.jpg"
|
|
165
|
+
});
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
`submitDrivingLicense(payload)` is still available as a backward-compatible alias.
|
|
169
|
+
|
|
170
|
+
### Get Insurance Canned URL
|
|
85
171
|
|
|
86
|
-
Public signature: `settingsClient.
|
|
172
|
+
Public signature: `settingsClient.getInsuranceCannedUrl(extension)`
|
|
87
173
|
|
|
88
|
-
Generates a pre-signed upload URL for
|
|
174
|
+
Generates a pre-signed upload URL for an insurance file.
|
|
89
175
|
|
|
90
176
|
```ts
|
|
91
|
-
const
|
|
177
|
+
const insuranceUpload = await settingsClient.getInsuranceCannedUrl("jpg");
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Capture Insurance
|
|
181
|
+
|
|
182
|
+
Public signature: `settingsClient.captureInsurance(fileKey)`
|
|
183
|
+
|
|
184
|
+
Captures and extracts insurance data through `POST /patient/capture`.
|
|
185
|
+
The client internally sends `Type: "healthinsurance"` and `FileID: fileKey`.
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
const capturedInsurance = await settingsClient.captureInsurance(
|
|
189
|
+
"insurance_639064123637965380.jpg"
|
|
190
|
+
);
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Get Insurances
|
|
194
|
+
|
|
195
|
+
Public signature: `settingsClient.getInsurances()`
|
|
196
|
+
|
|
197
|
+
Returns patient insurances through the wrapper-backed EHR route.
|
|
198
|
+
The client resolves the current patient's `EHR` internally from `authClient.getUserInfo()`.
|
|
199
|
+
|
|
200
|
+
```ts
|
|
201
|
+
const insurances = await settingsClient.getInsurances();
|
|
92
202
|
```
|
|
93
203
|
|
|
94
204
|
### Update User Image URL
|
|
@@ -119,6 +229,7 @@ await settingsClient.deactivateUser();
|
|
|
119
229
|
- Handles authentication
|
|
120
230
|
- Resolves base API URL
|
|
121
231
|
- Provides authorization headers
|
|
232
|
+
- Resolves the current user's `EHR` for EHR-backed settings methods
|
|
122
233
|
|
|
123
234
|
- **HttpClient**
|
|
124
235
|
- Performs all HTTP requests
|
|
@@ -126,4 +237,17 @@ await settingsClient.deactivateUser();
|
|
|
126
237
|
- **HCSettingsClient**
|
|
127
238
|
- Exposes user settings and profile-related endpoints
|
|
128
239
|
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## Notes
|
|
243
|
+
|
|
244
|
+
- `HCLoginClient` must be configured and logged in before calling settings methods
|
|
245
|
+
- `getUserImageCannedUrl()` uses `PUT /patient/image/cannedurl`
|
|
246
|
+
- `getDrivingLicenseCannedUrl()` uses `PUT /patient/id/cannedurl`
|
|
247
|
+
- `getInsuranceCannedUrl()` uses `PUT /patient/insurance/cannedurl`
|
|
248
|
+
- `captureUserPhoto()` sends `Type: "userphoto"` and `FileID` to `/patient/capture`
|
|
249
|
+
- `captureDrivingLicense()` sends `Type: "identification"` and `FileID` to `/patient/capture`
|
|
250
|
+
- `captureInsurance()` sends `Type: "healthinsurance"` and `FileID` to `/patient/capture`
|
|
251
|
+
- `updateDrivingLicense()` and `submitDrivingLicense()` send `{ Data: { Image: fileKey } }`
|
|
252
|
+
- `getInsurances()`, `updateDrivingLicense()` and `submitDrivingLicense()` internally resolve the current patient's `EHR`
|
|
129
253
|
|
package/dist/index.cjs
CHANGED
|
@@ -30,6 +30,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
30
30
|
// src/client.ts
|
|
31
31
|
var HCSettingsClient = class {
|
|
32
32
|
constructor(httpClient, authClient) {
|
|
33
|
+
this.resolvedEhr = null;
|
|
33
34
|
this.http = httpClient;
|
|
34
35
|
this.auth = authClient;
|
|
35
36
|
}
|
|
@@ -39,20 +40,30 @@ var HCSettingsClient = class {
|
|
|
39
40
|
this.auth.getAuthHeader()
|
|
40
41
|
);
|
|
41
42
|
}
|
|
42
|
-
async
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
async getDashboard() {
|
|
44
|
+
return this.http.get(
|
|
45
|
+
`${this.auth.getBaseUrl()}/patient/dashboard`,
|
|
46
|
+
this.auth.getAuthHeader()
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
async getUserImageCannedUrl(extension) {
|
|
50
|
+
var _a;
|
|
51
|
+
const payload = {
|
|
52
|
+
Data: {
|
|
53
|
+
Extension: extension
|
|
54
|
+
}
|
|
45
55
|
};
|
|
46
|
-
|
|
47
|
-
`${this.auth.getBaseUrl()}/patient/
|
|
48
|
-
|
|
56
|
+
const response = await this.http.put(
|
|
57
|
+
`${this.auth.getBaseUrl()}/patient/image/cannedurl`,
|
|
58
|
+
payload,
|
|
49
59
|
{
|
|
50
60
|
...this.auth.getAuthHeader(),
|
|
51
61
|
"Content-Type": "application/json"
|
|
52
62
|
}
|
|
53
63
|
);
|
|
64
|
+
return (_a = response.Data) != null ? _a : response;
|
|
54
65
|
}
|
|
55
|
-
async
|
|
66
|
+
async getDrivingLicenseCannedUrl(extension) {
|
|
56
67
|
var _a;
|
|
57
68
|
const payload = {
|
|
58
69
|
Data: {
|
|
@@ -60,7 +71,24 @@ var HCSettingsClient = class {
|
|
|
60
71
|
}
|
|
61
72
|
};
|
|
62
73
|
const response = await this.http.put(
|
|
63
|
-
`${this.auth.getBaseUrl()}/patient/
|
|
74
|
+
`${this.auth.getBaseUrl()}/patient/id/cannedurl`,
|
|
75
|
+
payload,
|
|
76
|
+
{
|
|
77
|
+
...this.auth.getAuthHeader(),
|
|
78
|
+
"Content-Type": "application/json"
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
return (_a = response.Data) != null ? _a : response;
|
|
82
|
+
}
|
|
83
|
+
async getInsuranceCannedUrl(extension) {
|
|
84
|
+
var _a;
|
|
85
|
+
const payload = {
|
|
86
|
+
Data: {
|
|
87
|
+
Extension: extension
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const response = await this.http.put(
|
|
91
|
+
`${this.auth.getBaseUrl()}/patient/insurance/cannedurl`,
|
|
64
92
|
payload,
|
|
65
93
|
{
|
|
66
94
|
...this.auth.getAuthHeader(),
|
|
@@ -69,6 +97,89 @@ var HCSettingsClient = class {
|
|
|
69
97
|
);
|
|
70
98
|
return (_a = response.Data) != null ? _a : response;
|
|
71
99
|
}
|
|
100
|
+
async captureUserPhoto(fileKey) {
|
|
101
|
+
const payload = {
|
|
102
|
+
Data: {
|
|
103
|
+
Type: "userphoto",
|
|
104
|
+
FileID: fileKey
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
return this.http.post(
|
|
108
|
+
`${this.auth.getBaseUrl()}/patient/capture`,
|
|
109
|
+
payload,
|
|
110
|
+
{
|
|
111
|
+
...this.auth.getAuthHeader(),
|
|
112
|
+
"Content-Type": "application/json"
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
async captureDrivingLicense(fileKey) {
|
|
117
|
+
const payload = {
|
|
118
|
+
Data: {
|
|
119
|
+
Type: "identification",
|
|
120
|
+
FileID: fileKey
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
return this.http.post(
|
|
124
|
+
`${this.auth.getBaseUrl()}/patient/capture`,
|
|
125
|
+
payload,
|
|
126
|
+
{
|
|
127
|
+
...this.auth.getAuthHeader(),
|
|
128
|
+
"Content-Type": "application/json"
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
async captureInsurance(fileKey) {
|
|
133
|
+
const payload = {
|
|
134
|
+
Data: {
|
|
135
|
+
Type: "healthinsurance",
|
|
136
|
+
FileID: fileKey
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
return this.http.post(
|
|
140
|
+
`${this.auth.getBaseUrl()}/patient/capture`,
|
|
141
|
+
payload,
|
|
142
|
+
{
|
|
143
|
+
...this.auth.getAuthHeader(),
|
|
144
|
+
"Content-Type": "application/json"
|
|
145
|
+
}
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
async submitInsurance(payload) {
|
|
149
|
+
const requestPayload = {
|
|
150
|
+
Data: payload
|
|
151
|
+
};
|
|
152
|
+
return this.http.put(
|
|
153
|
+
`${this.auth.getBaseUrl()}/patient/coverage`,
|
|
154
|
+
requestPayload,
|
|
155
|
+
{
|
|
156
|
+
...this.auth.getAuthHeader(),
|
|
157
|
+
"Content-Type": "application/json"
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
async getInsurances() {
|
|
162
|
+
return this.http.get(
|
|
163
|
+
await this.buildEhrPatientUrl("insurances"),
|
|
164
|
+
this.auth.getAuthHeader()
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
async updateDrivingLicense(payload) {
|
|
168
|
+
const requestPayload = {
|
|
169
|
+
Data: payload
|
|
170
|
+
};
|
|
171
|
+
return this.http.put(
|
|
172
|
+
await this.buildEhrPatientUrl("drivinglicense"),
|
|
173
|
+
requestPayload,
|
|
174
|
+
{
|
|
175
|
+
...this.auth.getAuthHeader(),
|
|
176
|
+
"Content-Type": "application/json"
|
|
177
|
+
}
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
async submitDrivingLicense(payload) {
|
|
181
|
+
return this.updateDrivingLicense(payload);
|
|
182
|
+
}
|
|
72
183
|
async updateUserImage(fileName) {
|
|
73
184
|
var _a;
|
|
74
185
|
const payload = {
|
|
@@ -99,6 +210,23 @@ var HCSettingsClient = class {
|
|
|
99
210
|
}
|
|
100
211
|
);
|
|
101
212
|
}
|
|
213
|
+
async buildEhrPatientUrl(path) {
|
|
214
|
+
const ehr = await this.getResolvedEhr();
|
|
215
|
+
return `${this.auth.getBaseUrl()}/ehr/${ehr}/patient/${path}`;
|
|
216
|
+
}
|
|
217
|
+
async getResolvedEhr() {
|
|
218
|
+
var _a, _b, _c;
|
|
219
|
+
if (this.resolvedEhr) {
|
|
220
|
+
return this.resolvedEhr;
|
|
221
|
+
}
|
|
222
|
+
const userInfo = await this.auth.getUserInfo();
|
|
223
|
+
const ehr = ((_b = (_a = userInfo == null ? void 0 : userInfo.Data) == null ? void 0 : _a.EHR) == null ? void 0 : _b.trim()) || ((_c = userInfo == null ? void 0 : userInfo.EHR) == null ? void 0 : _c.trim());
|
|
224
|
+
if (!ehr) {
|
|
225
|
+
throw new Error("Could not resolve EHR from loginClient.getUserInfo()");
|
|
226
|
+
}
|
|
227
|
+
this.resolvedEhr = ehr;
|
|
228
|
+
return ehr;
|
|
229
|
+
}
|
|
102
230
|
};
|
|
103
231
|
|
|
104
232
|
// src/errors.ts
|
package/dist/index.d.cts
CHANGED
|
@@ -16,6 +16,20 @@ interface UserInfo {
|
|
|
16
16
|
HasSelfie?: boolean;
|
|
17
17
|
Attributes?: Record<string, any>;
|
|
18
18
|
}
|
|
19
|
+
interface UserInfoResponse {
|
|
20
|
+
Data?: {
|
|
21
|
+
EHR?: string;
|
|
22
|
+
};
|
|
23
|
+
EHR?: string;
|
|
24
|
+
}
|
|
25
|
+
interface APIRequest<T> {
|
|
26
|
+
Data: T;
|
|
27
|
+
}
|
|
28
|
+
interface APIResponse<T> {
|
|
29
|
+
Data: T;
|
|
30
|
+
IsOK: boolean;
|
|
31
|
+
ErrorMessage?: string | null;
|
|
32
|
+
}
|
|
19
33
|
interface CoverageRequest {
|
|
20
34
|
InsurancePackageId: string;
|
|
21
35
|
MemberId: string;
|
|
@@ -24,36 +38,51 @@ interface CoverageRequest {
|
|
|
24
38
|
Sex: string;
|
|
25
39
|
Image: string;
|
|
26
40
|
}
|
|
27
|
-
|
|
28
|
-
|
|
41
|
+
type CoveragePayload = APIRequest<CoverageRequest>;
|
|
42
|
+
type CaptureType = "identification" | "healthinsurance" | "userphoto";
|
|
43
|
+
interface CaptureData {
|
|
44
|
+
Type: CaptureType;
|
|
45
|
+
FileID: string;
|
|
29
46
|
}
|
|
47
|
+
type CaptureRequest = APIRequest<CaptureData>;
|
|
30
48
|
interface UploadImageData {
|
|
31
49
|
Extension: string;
|
|
32
50
|
}
|
|
33
|
-
|
|
34
|
-
Data: UploadImageData;
|
|
35
|
-
}
|
|
51
|
+
type UploadImageRequest = APIRequest<UploadImageData>;
|
|
36
52
|
interface UpdateImageData {
|
|
37
53
|
FileName: string;
|
|
38
54
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Data: Record<string, never>;
|
|
55
|
+
type UpdateImageRequest = APIRequest<UpdateImageData>;
|
|
56
|
+
type EmptyRequest = APIRequest<Record<string, never>>;
|
|
57
|
+
interface DrivingLicenseData {
|
|
58
|
+
Image: string;
|
|
44
59
|
}
|
|
60
|
+
type DrivingLicenseRequest = APIRequest<DrivingLicenseData>;
|
|
61
|
+
type DrivingLicenseResponse = APIResponse<string>;
|
|
45
62
|
type HCUserImage = UserImage;
|
|
46
63
|
type HCUserInfo = UserInfo;
|
|
47
64
|
|
|
48
65
|
declare class HCSettingsClient {
|
|
49
66
|
private http;
|
|
50
67
|
private auth;
|
|
68
|
+
private resolvedEhr;
|
|
51
69
|
constructor(httpClient: HttpClient, authClient: HCLoginClient);
|
|
52
70
|
getUserInfo(): Promise<any>;
|
|
71
|
+
getDashboard(): Promise<any>;
|
|
72
|
+
getUserImageCannedUrl(extension: string): Promise<UserImage>;
|
|
73
|
+
getDrivingLicenseCannedUrl(extension: string): Promise<UserImage>;
|
|
74
|
+
getInsuranceCannedUrl(extension: string): Promise<UserImage>;
|
|
75
|
+
captureUserPhoto(fileKey: string): Promise<any>;
|
|
76
|
+
captureDrivingLicense(fileKey: string): Promise<any>;
|
|
77
|
+
captureInsurance(fileKey: string): Promise<any>;
|
|
53
78
|
submitInsurance(payload: CoverageRequest): Promise<any>;
|
|
54
|
-
|
|
79
|
+
getInsurances(): Promise<any>;
|
|
80
|
+
updateDrivingLicense(payload: DrivingLicenseData): Promise<DrivingLicenseResponse>;
|
|
81
|
+
submitDrivingLicense(payload: DrivingLicenseData): Promise<DrivingLicenseResponse>;
|
|
55
82
|
updateUserImage(fileName: string): Promise<UserImage>;
|
|
56
83
|
deactivateUser(): Promise<any>;
|
|
84
|
+
private buildEhrPatientUrl;
|
|
85
|
+
private getResolvedEhr;
|
|
57
86
|
}
|
|
58
87
|
|
|
59
88
|
declare class ConfigError extends Error {
|
|
@@ -67,4 +96,4 @@ declare class HttpError extends Error {
|
|
|
67
96
|
constructor(status: number, message: string);
|
|
68
97
|
}
|
|
69
98
|
|
|
70
|
-
export { AuthError, ConfigError, type CoveragePayload, type CoverageRequest, type EmptyRequest, type Environment, HCSettingsClient, type HCUserImage, type HCUserInfo, HttpError, type UpdateImageData, type UpdateImageRequest, type UploadImageData, type UploadImageRequest, type UserImage, type UserInfo };
|
|
99
|
+
export { type APIRequest, type APIResponse, AuthError, type CaptureData, type CaptureRequest, type CaptureType, ConfigError, type CoveragePayload, type CoverageRequest, type DrivingLicenseData, type DrivingLicenseRequest, type DrivingLicenseResponse, type EmptyRequest, type Environment, HCSettingsClient, type HCUserImage, type HCUserInfo, HttpError, type UpdateImageData, type UpdateImageRequest, type UploadImageData, type UploadImageRequest, type UserImage, type UserInfo, type UserInfoResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,20 @@ interface UserInfo {
|
|
|
16
16
|
HasSelfie?: boolean;
|
|
17
17
|
Attributes?: Record<string, any>;
|
|
18
18
|
}
|
|
19
|
+
interface UserInfoResponse {
|
|
20
|
+
Data?: {
|
|
21
|
+
EHR?: string;
|
|
22
|
+
};
|
|
23
|
+
EHR?: string;
|
|
24
|
+
}
|
|
25
|
+
interface APIRequest<T> {
|
|
26
|
+
Data: T;
|
|
27
|
+
}
|
|
28
|
+
interface APIResponse<T> {
|
|
29
|
+
Data: T;
|
|
30
|
+
IsOK: boolean;
|
|
31
|
+
ErrorMessage?: string | null;
|
|
32
|
+
}
|
|
19
33
|
interface CoverageRequest {
|
|
20
34
|
InsurancePackageId: string;
|
|
21
35
|
MemberId: string;
|
|
@@ -24,36 +38,51 @@ interface CoverageRequest {
|
|
|
24
38
|
Sex: string;
|
|
25
39
|
Image: string;
|
|
26
40
|
}
|
|
27
|
-
|
|
28
|
-
|
|
41
|
+
type CoveragePayload = APIRequest<CoverageRequest>;
|
|
42
|
+
type CaptureType = "identification" | "healthinsurance" | "userphoto";
|
|
43
|
+
interface CaptureData {
|
|
44
|
+
Type: CaptureType;
|
|
45
|
+
FileID: string;
|
|
29
46
|
}
|
|
47
|
+
type CaptureRequest = APIRequest<CaptureData>;
|
|
30
48
|
interface UploadImageData {
|
|
31
49
|
Extension: string;
|
|
32
50
|
}
|
|
33
|
-
|
|
34
|
-
Data: UploadImageData;
|
|
35
|
-
}
|
|
51
|
+
type UploadImageRequest = APIRequest<UploadImageData>;
|
|
36
52
|
interface UpdateImageData {
|
|
37
53
|
FileName: string;
|
|
38
54
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Data: Record<string, never>;
|
|
55
|
+
type UpdateImageRequest = APIRequest<UpdateImageData>;
|
|
56
|
+
type EmptyRequest = APIRequest<Record<string, never>>;
|
|
57
|
+
interface DrivingLicenseData {
|
|
58
|
+
Image: string;
|
|
44
59
|
}
|
|
60
|
+
type DrivingLicenseRequest = APIRequest<DrivingLicenseData>;
|
|
61
|
+
type DrivingLicenseResponse = APIResponse<string>;
|
|
45
62
|
type HCUserImage = UserImage;
|
|
46
63
|
type HCUserInfo = UserInfo;
|
|
47
64
|
|
|
48
65
|
declare class HCSettingsClient {
|
|
49
66
|
private http;
|
|
50
67
|
private auth;
|
|
68
|
+
private resolvedEhr;
|
|
51
69
|
constructor(httpClient: HttpClient, authClient: HCLoginClient);
|
|
52
70
|
getUserInfo(): Promise<any>;
|
|
71
|
+
getDashboard(): Promise<any>;
|
|
72
|
+
getUserImageCannedUrl(extension: string): Promise<UserImage>;
|
|
73
|
+
getDrivingLicenseCannedUrl(extension: string): Promise<UserImage>;
|
|
74
|
+
getInsuranceCannedUrl(extension: string): Promise<UserImage>;
|
|
75
|
+
captureUserPhoto(fileKey: string): Promise<any>;
|
|
76
|
+
captureDrivingLicense(fileKey: string): Promise<any>;
|
|
77
|
+
captureInsurance(fileKey: string): Promise<any>;
|
|
53
78
|
submitInsurance(payload: CoverageRequest): Promise<any>;
|
|
54
|
-
|
|
79
|
+
getInsurances(): Promise<any>;
|
|
80
|
+
updateDrivingLicense(payload: DrivingLicenseData): Promise<DrivingLicenseResponse>;
|
|
81
|
+
submitDrivingLicense(payload: DrivingLicenseData): Promise<DrivingLicenseResponse>;
|
|
55
82
|
updateUserImage(fileName: string): Promise<UserImage>;
|
|
56
83
|
deactivateUser(): Promise<any>;
|
|
84
|
+
private buildEhrPatientUrl;
|
|
85
|
+
private getResolvedEhr;
|
|
57
86
|
}
|
|
58
87
|
|
|
59
88
|
declare class ConfigError extends Error {
|
|
@@ -67,4 +96,4 @@ declare class HttpError extends Error {
|
|
|
67
96
|
constructor(status: number, message: string);
|
|
68
97
|
}
|
|
69
98
|
|
|
70
|
-
export { AuthError, ConfigError, type CoveragePayload, type CoverageRequest, type EmptyRequest, type Environment, HCSettingsClient, type HCUserImage, type HCUserInfo, HttpError, type UpdateImageData, type UpdateImageRequest, type UploadImageData, type UploadImageRequest, type UserImage, type UserInfo };
|
|
99
|
+
export { type APIRequest, type APIResponse, AuthError, type CaptureData, type CaptureRequest, type CaptureType, ConfigError, type CoveragePayload, type CoverageRequest, type DrivingLicenseData, type DrivingLicenseRequest, type DrivingLicenseResponse, type EmptyRequest, type Environment, HCSettingsClient, type HCUserImage, type HCUserInfo, HttpError, type UpdateImageData, type UpdateImageRequest, type UploadImageData, type UploadImageRequest, type UserImage, type UserInfo, type UserInfoResponse };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// src/client.ts
|
|
2
2
|
var HCSettingsClient = class {
|
|
3
3
|
constructor(httpClient, authClient) {
|
|
4
|
+
this.resolvedEhr = null;
|
|
4
5
|
this.http = httpClient;
|
|
5
6
|
this.auth = authClient;
|
|
6
7
|
}
|
|
@@ -10,20 +11,30 @@ var HCSettingsClient = class {
|
|
|
10
11
|
this.auth.getAuthHeader()
|
|
11
12
|
);
|
|
12
13
|
}
|
|
13
|
-
async
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
async getDashboard() {
|
|
15
|
+
return this.http.get(
|
|
16
|
+
`${this.auth.getBaseUrl()}/patient/dashboard`,
|
|
17
|
+
this.auth.getAuthHeader()
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
async getUserImageCannedUrl(extension) {
|
|
21
|
+
var _a;
|
|
22
|
+
const payload = {
|
|
23
|
+
Data: {
|
|
24
|
+
Extension: extension
|
|
25
|
+
}
|
|
16
26
|
};
|
|
17
|
-
|
|
18
|
-
`${this.auth.getBaseUrl()}/patient/
|
|
19
|
-
|
|
27
|
+
const response = await this.http.put(
|
|
28
|
+
`${this.auth.getBaseUrl()}/patient/image/cannedurl`,
|
|
29
|
+
payload,
|
|
20
30
|
{
|
|
21
31
|
...this.auth.getAuthHeader(),
|
|
22
32
|
"Content-Type": "application/json"
|
|
23
33
|
}
|
|
24
34
|
);
|
|
35
|
+
return (_a = response.Data) != null ? _a : response;
|
|
25
36
|
}
|
|
26
|
-
async
|
|
37
|
+
async getDrivingLicenseCannedUrl(extension) {
|
|
27
38
|
var _a;
|
|
28
39
|
const payload = {
|
|
29
40
|
Data: {
|
|
@@ -31,7 +42,24 @@ var HCSettingsClient = class {
|
|
|
31
42
|
}
|
|
32
43
|
};
|
|
33
44
|
const response = await this.http.put(
|
|
34
|
-
`${this.auth.getBaseUrl()}/patient/
|
|
45
|
+
`${this.auth.getBaseUrl()}/patient/id/cannedurl`,
|
|
46
|
+
payload,
|
|
47
|
+
{
|
|
48
|
+
...this.auth.getAuthHeader(),
|
|
49
|
+
"Content-Type": "application/json"
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
return (_a = response.Data) != null ? _a : response;
|
|
53
|
+
}
|
|
54
|
+
async getInsuranceCannedUrl(extension) {
|
|
55
|
+
var _a;
|
|
56
|
+
const payload = {
|
|
57
|
+
Data: {
|
|
58
|
+
Extension: extension
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const response = await this.http.put(
|
|
62
|
+
`${this.auth.getBaseUrl()}/patient/insurance/cannedurl`,
|
|
35
63
|
payload,
|
|
36
64
|
{
|
|
37
65
|
...this.auth.getAuthHeader(),
|
|
@@ -40,6 +68,89 @@ var HCSettingsClient = class {
|
|
|
40
68
|
);
|
|
41
69
|
return (_a = response.Data) != null ? _a : response;
|
|
42
70
|
}
|
|
71
|
+
async captureUserPhoto(fileKey) {
|
|
72
|
+
const payload = {
|
|
73
|
+
Data: {
|
|
74
|
+
Type: "userphoto",
|
|
75
|
+
FileID: fileKey
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
return this.http.post(
|
|
79
|
+
`${this.auth.getBaseUrl()}/patient/capture`,
|
|
80
|
+
payload,
|
|
81
|
+
{
|
|
82
|
+
...this.auth.getAuthHeader(),
|
|
83
|
+
"Content-Type": "application/json"
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
async captureDrivingLicense(fileKey) {
|
|
88
|
+
const payload = {
|
|
89
|
+
Data: {
|
|
90
|
+
Type: "identification",
|
|
91
|
+
FileID: fileKey
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
return this.http.post(
|
|
95
|
+
`${this.auth.getBaseUrl()}/patient/capture`,
|
|
96
|
+
payload,
|
|
97
|
+
{
|
|
98
|
+
...this.auth.getAuthHeader(),
|
|
99
|
+
"Content-Type": "application/json"
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
async captureInsurance(fileKey) {
|
|
104
|
+
const payload = {
|
|
105
|
+
Data: {
|
|
106
|
+
Type: "healthinsurance",
|
|
107
|
+
FileID: fileKey
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
return this.http.post(
|
|
111
|
+
`${this.auth.getBaseUrl()}/patient/capture`,
|
|
112
|
+
payload,
|
|
113
|
+
{
|
|
114
|
+
...this.auth.getAuthHeader(),
|
|
115
|
+
"Content-Type": "application/json"
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
async submitInsurance(payload) {
|
|
120
|
+
const requestPayload = {
|
|
121
|
+
Data: payload
|
|
122
|
+
};
|
|
123
|
+
return this.http.put(
|
|
124
|
+
`${this.auth.getBaseUrl()}/patient/coverage`,
|
|
125
|
+
requestPayload,
|
|
126
|
+
{
|
|
127
|
+
...this.auth.getAuthHeader(),
|
|
128
|
+
"Content-Type": "application/json"
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
async getInsurances() {
|
|
133
|
+
return this.http.get(
|
|
134
|
+
await this.buildEhrPatientUrl("insurances"),
|
|
135
|
+
this.auth.getAuthHeader()
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
async updateDrivingLicense(payload) {
|
|
139
|
+
const requestPayload = {
|
|
140
|
+
Data: payload
|
|
141
|
+
};
|
|
142
|
+
return this.http.put(
|
|
143
|
+
await this.buildEhrPatientUrl("drivinglicense"),
|
|
144
|
+
requestPayload,
|
|
145
|
+
{
|
|
146
|
+
...this.auth.getAuthHeader(),
|
|
147
|
+
"Content-Type": "application/json"
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
async submitDrivingLicense(payload) {
|
|
152
|
+
return this.updateDrivingLicense(payload);
|
|
153
|
+
}
|
|
43
154
|
async updateUserImage(fileName) {
|
|
44
155
|
var _a;
|
|
45
156
|
const payload = {
|
|
@@ -70,6 +181,23 @@ var HCSettingsClient = class {
|
|
|
70
181
|
}
|
|
71
182
|
);
|
|
72
183
|
}
|
|
184
|
+
async buildEhrPatientUrl(path) {
|
|
185
|
+
const ehr = await this.getResolvedEhr();
|
|
186
|
+
return `${this.auth.getBaseUrl()}/ehr/${ehr}/patient/${path}`;
|
|
187
|
+
}
|
|
188
|
+
async getResolvedEhr() {
|
|
189
|
+
var _a, _b, _c;
|
|
190
|
+
if (this.resolvedEhr) {
|
|
191
|
+
return this.resolvedEhr;
|
|
192
|
+
}
|
|
193
|
+
const userInfo = await this.auth.getUserInfo();
|
|
194
|
+
const ehr = ((_b = (_a = userInfo == null ? void 0 : userInfo.Data) == null ? void 0 : _a.EHR) == null ? void 0 : _b.trim()) || ((_c = userInfo == null ? void 0 : userInfo.EHR) == null ? void 0 : _c.trim());
|
|
195
|
+
if (!ehr) {
|
|
196
|
+
throw new Error("Could not resolve EHR from loginClient.getUserInfo()");
|
|
197
|
+
}
|
|
198
|
+
this.resolvedEhr = ehr;
|
|
199
|
+
return ehr;
|
|
200
|
+
}
|
|
73
201
|
};
|
|
74
202
|
|
|
75
203
|
// src/errors.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@healthcloudai/hc-settings-connector",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Healthcheck Settings SDK with TypeScript",
|
|
5
5
|
"author": "Healthcheck Systems Inc",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"axios": "^1.13.4",
|
|
39
|
-
"@healthcloudai/hc-login-connector": "^0.0.
|
|
39
|
+
"@healthcloudai/hc-login-connector": "^0.0.7",
|
|
40
40
|
"@healthcloudai/hc-http": "^0.0.3"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|