@healthcloudai/hc-settings-connector 0.1.0 → 0.2.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.
- package/README.md +101 -30
- package/dist/index.cjs +104 -207
- package/dist/index.d.cts +48 -26
- package/dist/index.d.ts +48 -26
- package/dist/index.js +111 -219
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
````md
|
|
2
1
|
# Healthcheck Settings Connector
|
|
3
2
|
|
|
4
3
|
This connector gives authenticated patients access to account information and document flows used in your application. It includes dashboard information, profile image management, identification document processing, insurance information, and account deactivation.
|
|
@@ -31,7 +30,7 @@ npm install @healthcloudai/hc-settings-connector \
|
|
|
31
30
|
## Import
|
|
32
31
|
|
|
33
32
|
```ts
|
|
34
|
-
import {
|
|
33
|
+
import { HCSettingsClient } from "@healthcloudai/hc-settings-connector";
|
|
35
34
|
import { HCLoginClient } from "@healthcloudai/hc-login-connector";
|
|
36
35
|
import { FetchClient } from "@healthcloudai/hc-http";
|
|
37
36
|
```
|
|
@@ -114,40 +113,59 @@ console.log(dashboard);
|
|
|
114
113
|
{
|
|
115
114
|
"Data": {
|
|
116
115
|
"Record": {
|
|
117
|
-
"Status":
|
|
116
|
+
"Status": 1,
|
|
118
117
|
"Sex": "Male",
|
|
119
118
|
"GenderIdentity": "Male",
|
|
120
119
|
"HasInsurance": true,
|
|
121
120
|
"HasIDCard": true,
|
|
122
121
|
"HasSelfie": true,
|
|
123
|
-
"Flags":
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
122
|
+
"Flags": null,
|
|
123
|
+
"FirstName": "John",
|
|
124
|
+
"LastName": "Smith",
|
|
125
|
+
"MiddleName": null,
|
|
126
|
+
"BirthDate": "1990-01-01T00:00:00",
|
|
127
|
+
"Email": "john.smith@example.com",
|
|
128
|
+
"Phone": "+15555550123",
|
|
129
|
+
"Gender": "Male",
|
|
130
|
+
"Race": "White",
|
|
131
|
+
"Ethnicity": "",
|
|
132
|
+
"CRMID": null,
|
|
133
|
+
"AppleUserId": null,
|
|
134
|
+
"Address": {
|
|
135
|
+
"StreetAndNumber": "1 Main St",
|
|
136
|
+
"Extension": null,
|
|
137
|
+
"City": "Springfield",
|
|
138
|
+
"State": "IL",
|
|
139
|
+
"PostalCode": "62701",
|
|
140
|
+
"Country": "US"
|
|
141
|
+
},
|
|
142
|
+
"Attributes": {
|
|
143
|
+
"AthenaPatientID": "patient-id-example",
|
|
144
|
+
"AthenaGuarantorFirstName": "John",
|
|
145
|
+
"AthenaGuarantorLastName": "Smith",
|
|
146
|
+
"AthenaCountryCode": "USA",
|
|
147
|
+
"AthenaDepartmentId": "1",
|
|
148
|
+
"AthenaEmailExists": "True",
|
|
149
|
+
"AthenaTestPatient": "False",
|
|
150
|
+
"PatientImageURL": "https://storage.example.com/selfie_example.jpg",
|
|
151
|
+
"CompositeID": "tenant-id/john.smith@example.com",
|
|
152
|
+
"Insurance": "EXAMPLE INSURANCE"
|
|
153
|
+
},
|
|
154
|
+
"CompositeID": "tenant-id/john.smith@example.com",
|
|
155
|
+
"FHIRID": "fhir-id-example",
|
|
156
|
+
"AthenaID": "patient-id-example",
|
|
157
|
+
"Created": "0001-01-01T00:00:00",
|
|
158
|
+
"Modified": "0001-01-01T00:00:00",
|
|
159
|
+
"CreatedByID": null,
|
|
160
|
+
"ModifiedByID": null,
|
|
161
|
+
"IsDeactivated": false,
|
|
162
|
+
"TenantID": "test-tenant",
|
|
163
|
+
"ID": "record-uuid-example"
|
|
127
164
|
},
|
|
128
|
-
"Encounters":
|
|
129
|
-
{
|
|
130
|
-
"FHIRID": "test-fhir-id-001",
|
|
131
|
-
"AthenaID": "test-athena-id-001",
|
|
132
|
-
"Status": 0,
|
|
133
|
-
"Patient": null,
|
|
134
|
-
"EncounterClass": "ambulatory",
|
|
135
|
-
"EHR": "athena",
|
|
136
|
-
"EHRType": "Athena Health",
|
|
137
|
-
"EHRVisitName": "Office Visit",
|
|
138
|
-
"EHRAppointmentID": "test-appointment-id-001",
|
|
139
|
-
"EHRProviderID": "test-provider-id-001",
|
|
140
|
-
"EHRProviderName": "Test Provider",
|
|
141
|
-
"EHRDate": "04/22/2026",
|
|
142
|
-
"EHRStatus": "Finished",
|
|
143
|
-
"EHRStage": "completed"
|
|
144
|
-
}
|
|
145
|
-
],
|
|
165
|
+
"Encounters": null,
|
|
146
166
|
"EHR": "athena",
|
|
147
167
|
"PendingActions": [
|
|
148
|
-
"
|
|
149
|
-
"ADD_ID",
|
|
150
|
-
"IMPORT_VITALS"
|
|
168
|
+
"TAKE_TEST"
|
|
151
169
|
]
|
|
152
170
|
},
|
|
153
171
|
"IsOK": true,
|
|
@@ -567,14 +585,14 @@ console.log(response);
|
|
|
567
585
|
Public signature:
|
|
568
586
|
|
|
569
587
|
```ts
|
|
570
|
-
settingsClient.
|
|
588
|
+
settingsClient.listInsurances()
|
|
571
589
|
```
|
|
572
590
|
|
|
573
591
|
Returns insurance records associated with the authenticated patient.
|
|
574
592
|
|
|
575
593
|
```ts
|
|
576
594
|
const insurances =
|
|
577
|
-
await settingsClient.
|
|
595
|
+
await settingsClient.listInsurances();
|
|
578
596
|
|
|
579
597
|
console.log(insurances);
|
|
580
598
|
```
|
|
@@ -711,3 +729,56 @@ console.log(response);
|
|
|
711
729
|
|
|
712
730
|
```
|
|
713
731
|
```
|
|
732
|
+
|
|
733
|
+
|
|
734
|
+
---
|
|
735
|
+
|
|
736
|
+
## Prerequisites
|
|
737
|
+
|
|
738
|
+
`HCLoginClient` must be configured and the patient must be logged in before calling any method on this connector.
|
|
739
|
+
|
|
740
|
+
```ts
|
|
741
|
+
import { HCLoginClient } from "@healthcloudai/hc-login-connector";
|
|
742
|
+
import { FetchClient } from "@healthcloudai/hc-http";
|
|
743
|
+
|
|
744
|
+
const httpClient = new FetchClient();
|
|
745
|
+
const loginClient = new HCLoginClient(httpClient);
|
|
746
|
+
|
|
747
|
+
loginClient.configure("healthcheck", "dev");
|
|
748
|
+
await loginClient.login("patient@example.com", "ExamplePassword123!");
|
|
749
|
+
```
|
|
750
|
+
|
|
751
|
+
See the [hc-login-connector](../hc-login-connector) documentation for the full authentication flow.
|
|
752
|
+
|
|
753
|
+
---
|
|
754
|
+
|
|
755
|
+
## Error Handling
|
|
756
|
+
|
|
757
|
+
All methods throw errors that extend `APIError` from `@healthcloudai/hc-http`.
|
|
758
|
+
|
|
759
|
+
Backend business failures (`IsOK: false`) are thrown as `HCServiceError`.
|
|
760
|
+
|
|
761
|
+
```ts
|
|
762
|
+
import { HCServiceError, APIError } from "@healthcloudai/hc-http";
|
|
763
|
+
|
|
764
|
+
try {
|
|
765
|
+
const result = await client.someMethod();
|
|
766
|
+
} catch (err) {
|
|
767
|
+
if (err instanceof HCServiceError) {
|
|
768
|
+
console.error("Backend error:", err.backendMessage);
|
|
769
|
+
} else if (err instanceof APIError) {
|
|
770
|
+
console.error("SDK error:", err.message, err.code);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
```
|
|
774
|
+
|
|
775
|
+
|
|
776
|
+
---
|
|
777
|
+
|
|
778
|
+
## getDashboard vs getPatientHeader
|
|
779
|
+
|
|
780
|
+
`HCSettingsClient.getDashboard()` calls `/api/patient/dashboard` and returns a full patient dashboard including record, encounters, EHR type, and pending actions.
|
|
781
|
+
|
|
782
|
+
`HCLoginClient.getPatientHeader()` calls `/api/patient/header` and returns a lighter patient header used after login to quickly check patient state.
|
|
783
|
+
|
|
784
|
+
These are different endpoints returning different data shapes. Neither is a duplicate of the other.
|
package/dist/index.cjs
CHANGED
|
@@ -26,42 +26,28 @@ __export(index_exports, {
|
|
|
26
26
|
HCSettingsClient: () => HCSettingsClient,
|
|
27
27
|
NetworkError: () => import_hc_http2.NetworkError,
|
|
28
28
|
UserStatus: () => UserStatus,
|
|
29
|
-
ValidationError: () => import_hc_http2.ValidationError
|
|
30
|
-
errorFromHttpStatus: () => import_hc_http2.errorFromHttpStatus
|
|
29
|
+
ValidationError: () => import_hc_http2.ValidationError
|
|
31
30
|
});
|
|
32
31
|
module.exports = __toCommonJS(index_exports);
|
|
33
32
|
|
|
34
33
|
// src/client.ts
|
|
35
34
|
var import_hc_http = require("@healthcloudai/hc-http");
|
|
36
|
-
var HCSettingsClient = class {
|
|
35
|
+
var HCSettingsClient = class extends import_hc_http.HCBaseConnector {
|
|
37
36
|
constructor(httpClient, loginClient) {
|
|
38
|
-
|
|
39
|
-
this.
|
|
40
|
-
}
|
|
41
|
-
setApiKey(headerName, value) {
|
|
42
|
-
const trimmedHeaderName = headerName == null ? void 0 : headerName.trim();
|
|
43
|
-
const trimmedValue = value == null ? void 0 : value.trim();
|
|
44
|
-
if (!trimmedHeaderName) {
|
|
45
|
-
throw new import_hc_http.ConfigError(
|
|
46
|
-
"API key header name is required."
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
if (!trimmedValue) {
|
|
50
|
-
throw new import_hc_http.ConfigError(
|
|
51
|
-
"API key value is required."
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
this.apiKeyHeaderName = trimmedHeaderName;
|
|
55
|
-
this.apiKeyValue = trimmedValue;
|
|
37
|
+
super(httpClient);
|
|
38
|
+
this.auth = loginClient;
|
|
56
39
|
}
|
|
57
40
|
// ===========================================================================
|
|
58
41
|
// Dashboard
|
|
59
42
|
// ===========================================================================
|
|
43
|
+
/**
|
|
44
|
+
* Returns the patient dashboard including record, encounters, and pending actions.
|
|
45
|
+
*/
|
|
60
46
|
async getDashboard() {
|
|
61
47
|
return this.execute(
|
|
62
48
|
"getDashboard",
|
|
63
|
-
() => this.
|
|
64
|
-
`${this.getBaseUrl()}/api/patient/dashboard`,
|
|
49
|
+
() => this.http.get(
|
|
50
|
+
`${this.auth.getBaseUrl()}/api/patient/dashboard`,
|
|
65
51
|
this.getAuthHeaders()
|
|
66
52
|
)
|
|
67
53
|
);
|
|
@@ -69,152 +55,143 @@ var HCSettingsClient = class {
|
|
|
69
55
|
// ===========================================================================
|
|
70
56
|
// User image
|
|
71
57
|
// ===========================================================================
|
|
58
|
+
/**
|
|
59
|
+
* Returns a canned (pre-signed) URL for uploading the patient profile image.
|
|
60
|
+
* Extension must be a valid file extension such as "jpg" or "png".
|
|
61
|
+
*/
|
|
72
62
|
async getUserImageCannedUrl(extension) {
|
|
73
|
-
const resolvedExtension = this.requireValue(
|
|
74
|
-
extension,
|
|
75
|
-
"extension"
|
|
76
|
-
);
|
|
63
|
+
const resolvedExtension = this.requireValue(extension, "Extension", "extension");
|
|
77
64
|
const requestPayload = {
|
|
78
|
-
Data: {
|
|
79
|
-
Extension: resolvedExtension
|
|
80
|
-
}
|
|
65
|
+
Data: { Extension: resolvedExtension }
|
|
81
66
|
};
|
|
82
67
|
return this.execute(
|
|
83
68
|
"getUserImageCannedUrl",
|
|
84
|
-
() => this.
|
|
85
|
-
`${this.getBaseUrl()}/api/patient/image/cannedurl`,
|
|
69
|
+
() => this.http.put(
|
|
70
|
+
`${this.auth.getBaseUrl()}/api/patient/image/cannedurl`,
|
|
86
71
|
requestPayload,
|
|
87
|
-
this.
|
|
72
|
+
this.getAuthHeaders()
|
|
88
73
|
)
|
|
89
74
|
);
|
|
90
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Updates the patient's profile image by confirming the uploaded file name.
|
|
78
|
+
*/
|
|
91
79
|
async updateUserImage(fileName) {
|
|
92
|
-
const resolvedFileName = this.requireValue(
|
|
93
|
-
fileName,
|
|
94
|
-
"fileName"
|
|
95
|
-
);
|
|
80
|
+
const resolvedFileName = this.requireValue(fileName, "File name", "fileName");
|
|
96
81
|
const requestPayload = {
|
|
97
|
-
Data: {
|
|
98
|
-
FileName: resolvedFileName
|
|
99
|
-
}
|
|
82
|
+
Data: { FileName: resolvedFileName }
|
|
100
83
|
};
|
|
101
84
|
return this.execute(
|
|
102
85
|
"updateUserImage",
|
|
103
|
-
() => this.
|
|
104
|
-
`${this.getBaseUrl()}/api/patient/image/url`,
|
|
86
|
+
() => this.http.put(
|
|
87
|
+
`${this.auth.getBaseUrl()}/api/patient/image/url`,
|
|
105
88
|
requestPayload,
|
|
106
|
-
this.
|
|
89
|
+
this.getAuthHeaders()
|
|
107
90
|
)
|
|
108
91
|
);
|
|
109
92
|
}
|
|
110
93
|
// ===========================================================================
|
|
111
94
|
// Identification
|
|
112
95
|
// ===========================================================================
|
|
96
|
+
/**
|
|
97
|
+
* Returns a canned URL for uploading the patient's driving licence image.
|
|
98
|
+
*/
|
|
113
99
|
async getDrivingLicenseCannedUrl(extension) {
|
|
114
|
-
const resolvedExtension = this.requireValue(
|
|
115
|
-
extension,
|
|
116
|
-
"extension"
|
|
117
|
-
);
|
|
100
|
+
const resolvedExtension = this.requireValue(extension, "Extension", "extension");
|
|
118
101
|
const requestPayload = {
|
|
119
|
-
Data: {
|
|
120
|
-
Extension: resolvedExtension
|
|
121
|
-
}
|
|
102
|
+
Data: { Extension: resolvedExtension }
|
|
122
103
|
};
|
|
123
104
|
return this.execute(
|
|
124
105
|
"getDrivingLicenseCannedUrl",
|
|
125
|
-
() => this.
|
|
126
|
-
`${this.getBaseUrl()}/api/patient/id/cannedurl`,
|
|
106
|
+
() => this.http.put(
|
|
107
|
+
`${this.auth.getBaseUrl()}/api/patient/id/cannedurl`,
|
|
127
108
|
requestPayload,
|
|
128
|
-
this.
|
|
109
|
+
this.getAuthHeaders()
|
|
129
110
|
)
|
|
130
111
|
);
|
|
131
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Submits a driving licence file for OCR capture.
|
|
115
|
+
* fileKey is the storage key of the uploaded image.
|
|
116
|
+
*/
|
|
132
117
|
async captureDrivingLicense(fileKey) {
|
|
133
|
-
const resolvedFileKey = this.requireValue(
|
|
134
|
-
fileKey,
|
|
135
|
-
"fileKey"
|
|
136
|
-
);
|
|
118
|
+
const resolvedFileKey = this.requireValue(fileKey, "File key", "fileKey");
|
|
137
119
|
const requestPayload = {
|
|
138
|
-
Data: {
|
|
139
|
-
Type: "identification",
|
|
140
|
-
FileID: resolvedFileKey
|
|
141
|
-
}
|
|
120
|
+
Data: { Type: "identification", FileID: resolvedFileKey }
|
|
142
121
|
};
|
|
143
122
|
return this.execute(
|
|
144
123
|
"captureDrivingLicense",
|
|
145
|
-
() => this.
|
|
146
|
-
`${this.getBaseUrl()}/api/patient/capture`,
|
|
124
|
+
() => this.http.post(
|
|
125
|
+
`${this.auth.getBaseUrl()}/api/patient/capture`,
|
|
147
126
|
requestPayload,
|
|
148
|
-
this.
|
|
127
|
+
this.getAuthHeaders()
|
|
149
128
|
)
|
|
150
129
|
);
|
|
151
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Submits a base64-encoded driving licence image to the EHR.
|
|
133
|
+
*/
|
|
152
134
|
async submitDrivingLicense(image) {
|
|
153
|
-
const resolvedImage = this.requireValue(
|
|
154
|
-
image,
|
|
155
|
-
"image"
|
|
156
|
-
);
|
|
135
|
+
const resolvedImage = this.requireValue(image, "Image", "image");
|
|
157
136
|
const requestPayload = {
|
|
158
|
-
Data: {
|
|
159
|
-
Image: resolvedImage
|
|
160
|
-
}
|
|
137
|
+
Data: { Image: resolvedImage }
|
|
161
138
|
};
|
|
162
139
|
return this.execute(
|
|
163
140
|
"submitDrivingLicense",
|
|
164
|
-
() => this.
|
|
165
|
-
`${this.getBaseUrl()}/api/ehr/patient/drivinglicense`,
|
|
141
|
+
() => this.http.put(
|
|
142
|
+
`${this.auth.getBaseUrl()}/api/ehr/patient/drivinglicense`,
|
|
166
143
|
requestPayload,
|
|
167
|
-
this.
|
|
144
|
+
this.getAuthHeaders()
|
|
168
145
|
)
|
|
169
146
|
);
|
|
170
147
|
}
|
|
171
148
|
// ===========================================================================
|
|
172
149
|
// Insurance
|
|
173
150
|
// ===========================================================================
|
|
151
|
+
/**
|
|
152
|
+
* Returns a canned URL for uploading the insurance card image.
|
|
153
|
+
*/
|
|
174
154
|
async getInsuranceCannedUrl(extension) {
|
|
175
|
-
const resolvedExtension = this.requireValue(
|
|
176
|
-
extension,
|
|
177
|
-
"extension"
|
|
178
|
-
);
|
|
155
|
+
const resolvedExtension = this.requireValue(extension, "Extension", "extension");
|
|
179
156
|
const requestPayload = {
|
|
180
|
-
Data: {
|
|
181
|
-
Extension: resolvedExtension
|
|
182
|
-
}
|
|
157
|
+
Data: { Extension: resolvedExtension }
|
|
183
158
|
};
|
|
184
159
|
return this.execute(
|
|
185
160
|
"getInsuranceCannedUrl",
|
|
186
|
-
() => this.
|
|
187
|
-
`${this.getBaseUrl()}/api/patient/insurance/cannedurl`,
|
|
161
|
+
() => this.http.put(
|
|
162
|
+
`${this.auth.getBaseUrl()}/api/patient/insurance/cannedurl`,
|
|
188
163
|
requestPayload,
|
|
189
|
-
this.
|
|
164
|
+
this.getAuthHeaders()
|
|
190
165
|
)
|
|
191
166
|
);
|
|
192
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Submits an insurance card image for OCR capture.
|
|
170
|
+
* fileKey is the storage key of the uploaded image.
|
|
171
|
+
*/
|
|
193
172
|
async captureInsurance(fileKey) {
|
|
194
|
-
const resolvedFileKey = this.requireValue(
|
|
195
|
-
fileKey,
|
|
196
|
-
"fileKey"
|
|
197
|
-
);
|
|
173
|
+
const resolvedFileKey = this.requireValue(fileKey, "File key", "fileKey");
|
|
198
174
|
const requestPayload = {
|
|
199
|
-
Data: {
|
|
200
|
-
Type: "healthinsurance",
|
|
201
|
-
FileID: resolvedFileKey
|
|
202
|
-
}
|
|
175
|
+
Data: { Type: "healthinsurance", FileID: resolvedFileKey }
|
|
203
176
|
};
|
|
204
177
|
return this.execute(
|
|
205
178
|
"captureInsurance",
|
|
206
|
-
() => this.
|
|
207
|
-
`${this.getBaseUrl()}/api/patient/capture`,
|
|
179
|
+
() => this.http.post(
|
|
180
|
+
`${this.auth.getBaseUrl()}/api/patient/capture`,
|
|
208
181
|
requestPayload,
|
|
209
|
-
this.
|
|
182
|
+
this.getAuthHeaders()
|
|
210
183
|
)
|
|
211
184
|
);
|
|
212
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* Creates or updates the patient's insurance coverage record.
|
|
188
|
+
*/
|
|
213
189
|
async submitInsurance(coverage) {
|
|
214
190
|
if (!coverage) {
|
|
215
191
|
throw new import_hc_http.ValidationError({
|
|
216
192
|
message: "Insurance coverage data is required.",
|
|
217
|
-
code: "INVALID_INPUT"
|
|
193
|
+
code: "INVALID_INPUT",
|
|
194
|
+
param: "coverage"
|
|
218
195
|
});
|
|
219
196
|
}
|
|
220
197
|
const requestPayload = {
|
|
@@ -222,18 +199,21 @@ var HCSettingsClient = class {
|
|
|
222
199
|
};
|
|
223
200
|
return this.execute(
|
|
224
201
|
"submitInsurance",
|
|
225
|
-
() => this.
|
|
226
|
-
`${this.getBaseUrl()}/api/patient/coverage`,
|
|
202
|
+
() => this.http.put(
|
|
203
|
+
`${this.auth.getBaseUrl()}/api/patient/coverage`,
|
|
227
204
|
requestPayload,
|
|
228
|
-
this.
|
|
205
|
+
this.getAuthHeaders()
|
|
229
206
|
)
|
|
230
207
|
);
|
|
231
208
|
}
|
|
232
|
-
|
|
209
|
+
/**
|
|
210
|
+
* Returns all insurance records for the authenticated patient.
|
|
211
|
+
*/
|
|
212
|
+
async listInsurances() {
|
|
233
213
|
return this.execute(
|
|
234
|
-
"
|
|
235
|
-
() => this.
|
|
236
|
-
`${this.getBaseUrl()}/api/ehr/patient/insurances`,
|
|
214
|
+
"listInsurances",
|
|
215
|
+
() => this.http.get(
|
|
216
|
+
`${this.auth.getBaseUrl()}/api/ehr/patient/insurances`,
|
|
237
217
|
this.getAuthHeaders()
|
|
238
218
|
)
|
|
239
219
|
);
|
|
@@ -241,128 +221,46 @@ var HCSettingsClient = class {
|
|
|
241
221
|
// ===========================================================================
|
|
242
222
|
// User photo capture
|
|
243
223
|
// ===========================================================================
|
|
224
|
+
/**
|
|
225
|
+
* Submits a user photo (selfie) for capture.
|
|
226
|
+
* fileKey is the storage key of the uploaded image.
|
|
227
|
+
*/
|
|
244
228
|
async captureUserPhoto(fileKey) {
|
|
245
|
-
const resolvedFileKey = this.requireValue(
|
|
246
|
-
fileKey,
|
|
247
|
-
"fileKey"
|
|
248
|
-
);
|
|
229
|
+
const resolvedFileKey = this.requireValue(fileKey, "File key", "fileKey");
|
|
249
230
|
const requestPayload = {
|
|
250
|
-
Data: {
|
|
251
|
-
Type: "userphoto",
|
|
252
|
-
FileID: resolvedFileKey
|
|
253
|
-
}
|
|
231
|
+
Data: { Type: "userphoto", FileID: resolvedFileKey }
|
|
254
232
|
};
|
|
255
233
|
return this.execute(
|
|
256
234
|
"captureUserPhoto",
|
|
257
|
-
() => this.
|
|
258
|
-
`${this.getBaseUrl()}/api/patient/capture`,
|
|
235
|
+
() => this.http.post(
|
|
236
|
+
`${this.auth.getBaseUrl()}/api/patient/capture`,
|
|
259
237
|
requestPayload,
|
|
260
|
-
this.
|
|
238
|
+
this.getAuthHeaders()
|
|
261
239
|
)
|
|
262
240
|
);
|
|
263
241
|
}
|
|
264
242
|
// ===========================================================================
|
|
265
243
|
// Account
|
|
266
244
|
// ===========================================================================
|
|
267
|
-
|
|
245
|
+
/**
|
|
246
|
+
* Soft-deactivates the current patient account.
|
|
247
|
+
* The patient record is not permanently deleted.
|
|
248
|
+
*/
|
|
249
|
+
async deactivateCurrentPatient() {
|
|
268
250
|
return this.execute(
|
|
269
|
-
"
|
|
270
|
-
() => this.
|
|
271
|
-
`${this.getBaseUrl()}/api/patient/deactivate`,
|
|
251
|
+
"deactivateCurrentPatient",
|
|
252
|
+
() => this.http.put(
|
|
253
|
+
`${this.auth.getBaseUrl()}/api/patient/deactivate`,
|
|
272
254
|
void 0,
|
|
273
|
-
this.
|
|
255
|
+
this.getAuthHeaders()
|
|
274
256
|
)
|
|
275
257
|
);
|
|
276
258
|
}
|
|
277
259
|
// ===========================================================================
|
|
278
|
-
//
|
|
260
|
+
// Private
|
|
279
261
|
// ===========================================================================
|
|
280
|
-
async execute(operation, request) {
|
|
281
|
-
let response;
|
|
282
|
-
try {
|
|
283
|
-
response = await request();
|
|
284
|
-
} catch (err) {
|
|
285
|
-
if (err instanceof import_hc_http.APIError) {
|
|
286
|
-
throw err;
|
|
287
|
-
}
|
|
288
|
-
if (err instanceof Error) {
|
|
289
|
-
throw new import_hc_http.APIError({
|
|
290
|
-
message: `${operation}: ${err.message}`,
|
|
291
|
-
code: "UNKNOWN_ERROR",
|
|
292
|
-
details: err
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
throw new import_hc_http.APIError({
|
|
296
|
-
message: `${operation}: unexpected runtime failure`,
|
|
297
|
-
code: "UNKNOWN_ERROR",
|
|
298
|
-
details: err
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
if (response == null) {
|
|
302
|
-
throw new import_hc_http.APIError({
|
|
303
|
-
message: `${operation}: empty response received`,
|
|
304
|
-
code: "EMPTY_RESPONSE",
|
|
305
|
-
details: response
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
if (!this.isApiResponse(response)) {
|
|
309
|
-
throw new import_hc_http.APIError({
|
|
310
|
-
message: `${operation}: invalid API response structure`,
|
|
311
|
-
code: "INVALID_RESPONSE",
|
|
312
|
-
details: response
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
if (!response.IsOK) {
|
|
316
|
-
throw this.mapBackendError(operation, response);
|
|
317
|
-
}
|
|
318
|
-
return response;
|
|
319
|
-
}
|
|
320
|
-
mapBackendError(operation, response) {
|
|
321
|
-
return new import_hc_http.HCServiceError(
|
|
322
|
-
operation,
|
|
323
|
-
response.ErrorMessage,
|
|
324
|
-
response
|
|
325
|
-
);
|
|
326
|
-
}
|
|
327
|
-
isApiResponse(value) {
|
|
328
|
-
if (!value || typeof value !== "object") {
|
|
329
|
-
return false;
|
|
330
|
-
}
|
|
331
|
-
const response = value;
|
|
332
|
-
return "IsOK" in response && typeof response.IsOK === "boolean" && "Data" in response && "ErrorMessage" in response;
|
|
333
|
-
}
|
|
334
|
-
getBaseUrl() {
|
|
335
|
-
return this.loginClient.getBaseUrl();
|
|
336
|
-
}
|
|
337
262
|
getAuthHeaders() {
|
|
338
|
-
return {
|
|
339
|
-
...this.loginClient.getAuthHeader(),
|
|
340
|
-
...this.getApiKeyHeader()
|
|
341
|
-
};
|
|
342
|
-
}
|
|
343
|
-
getJsonHeaders() {
|
|
344
|
-
return {
|
|
345
|
-
...this.getAuthHeaders(),
|
|
346
|
-
"Content-Type": "application/json"
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
getApiKeyHeader() {
|
|
350
|
-
if (!this.apiKeyHeaderName || !this.apiKeyValue) {
|
|
351
|
-
return {};
|
|
352
|
-
}
|
|
353
|
-
return {
|
|
354
|
-
[this.apiKeyHeaderName]: this.apiKeyValue
|
|
355
|
-
};
|
|
356
|
-
}
|
|
357
|
-
requireValue(value, parameterName) {
|
|
358
|
-
const trimmedValue = value == null ? void 0 : value.trim();
|
|
359
|
-
if (!trimmedValue) {
|
|
360
|
-
throw new import_hc_http.ValidationError({
|
|
361
|
-
message: `${parameterName} is required.`,
|
|
362
|
-
code: "INVALID_INPUT"
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
|
-
return trimmedValue;
|
|
263
|
+
return { ...this.getHeaders(), ...this.auth.getAuthHeader() };
|
|
366
264
|
}
|
|
367
265
|
};
|
|
368
266
|
|
|
@@ -384,6 +282,5 @@ var UserStatus = /* @__PURE__ */ ((UserStatus2) => {
|
|
|
384
282
|
HCSettingsClient,
|
|
385
283
|
NetworkError,
|
|
386
284
|
UserStatus,
|
|
387
|
-
ValidationError
|
|
388
|
-
errorFromHttpStatus
|
|
285
|
+
ValidationError
|
|
389
286
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
import { HCLoginClient } from '@healthcloudai/hc-login-connector';
|
|
2
|
-
import { HttpClient,
|
|
3
|
-
export { APIError, ConfigError, HCServiceError, NetworkError, ValidationError
|
|
2
|
+
import { HCBaseConnector, HttpClient, APIResponse } from '@healthcloudai/hc-http';
|
|
3
|
+
export { APIError, APIResponse, ConfigError, HCServiceError, NetworkError, ValidationError } from '@healthcloudai/hc-http';
|
|
4
4
|
|
|
5
|
-
interface APIRequest<T> {
|
|
6
|
-
Data: T;
|
|
7
|
-
}
|
|
8
|
-
interface APIResponse<T> {
|
|
9
|
-
Data: T | null;
|
|
10
|
-
IsOK: boolean;
|
|
11
|
-
ErrorMessage: string | null;
|
|
12
|
-
}
|
|
13
5
|
interface UserImage {
|
|
14
6
|
ImageURL: string | null;
|
|
15
7
|
FileName: string | null;
|
|
@@ -121,33 +113,63 @@ interface InsuranceRecord {
|
|
|
121
113
|
Image?: string | null;
|
|
122
114
|
}
|
|
123
115
|
|
|
124
|
-
declare class HCSettingsClient {
|
|
125
|
-
private readonly
|
|
126
|
-
private readonly loginClient;
|
|
127
|
-
private apiKeyHeaderName?;
|
|
128
|
-
private apiKeyValue?;
|
|
116
|
+
declare class HCSettingsClient extends HCBaseConnector {
|
|
117
|
+
private readonly auth;
|
|
129
118
|
constructor(httpClient: HttpClient, loginClient: HCLoginClient);
|
|
130
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Returns the patient dashboard including record, encounters, and pending actions.
|
|
121
|
+
*/
|
|
131
122
|
getDashboard(): Promise<APIResponse<PatientDashboard>>;
|
|
123
|
+
/**
|
|
124
|
+
* Returns a canned (pre-signed) URL for uploading the patient profile image.
|
|
125
|
+
* Extension must be a valid file extension such as "jpg" or "png".
|
|
126
|
+
*/
|
|
132
127
|
getUserImageCannedUrl(extension: string): Promise<APIResponse<UserImage>>;
|
|
128
|
+
/**
|
|
129
|
+
* Updates the patient's profile image by confirming the uploaded file name.
|
|
130
|
+
*/
|
|
133
131
|
updateUserImage(fileName: string): Promise<APIResponse<boolean>>;
|
|
132
|
+
/**
|
|
133
|
+
* Returns a canned URL for uploading the patient's driving licence image.
|
|
134
|
+
*/
|
|
134
135
|
getDrivingLicenseCannedUrl(extension: string): Promise<APIResponse<UserImage>>;
|
|
136
|
+
/**
|
|
137
|
+
* Submits a driving licence file for OCR capture.
|
|
138
|
+
* fileKey is the storage key of the uploaded image.
|
|
139
|
+
*/
|
|
135
140
|
captureDrivingLicense(fileKey: string): Promise<APIResponse<CaptureResult<IdentificationCaptureData>>>;
|
|
141
|
+
/**
|
|
142
|
+
* Submits a base64-encoded driving licence image to the EHR.
|
|
143
|
+
*/
|
|
136
144
|
submitDrivingLicense(image: string): Promise<APIResponse<string>>;
|
|
145
|
+
/**
|
|
146
|
+
* Returns a canned URL for uploading the insurance card image.
|
|
147
|
+
*/
|
|
137
148
|
getInsuranceCannedUrl(extension: string): Promise<APIResponse<UserImage>>;
|
|
149
|
+
/**
|
|
150
|
+
* Submits an insurance card image for OCR capture.
|
|
151
|
+
* fileKey is the storage key of the uploaded image.
|
|
152
|
+
*/
|
|
138
153
|
captureInsurance(fileKey: string): Promise<APIResponse<CaptureResult<InsuranceCaptureData>>>;
|
|
154
|
+
/**
|
|
155
|
+
* Creates or updates the patient's insurance coverage record.
|
|
156
|
+
*/
|
|
139
157
|
submitInsurance(coverage: CoverageData): Promise<APIResponse<InsuranceRecord>>;
|
|
140
|
-
|
|
158
|
+
/**
|
|
159
|
+
* Returns all insurance records for the authenticated patient.
|
|
160
|
+
*/
|
|
161
|
+
listInsurances(): Promise<APIResponse<InsuranceRecord[]>>;
|
|
162
|
+
/**
|
|
163
|
+
* Submits a user photo (selfie) for capture.
|
|
164
|
+
* fileKey is the storage key of the uploaded image.
|
|
165
|
+
*/
|
|
141
166
|
captureUserPhoto(fileKey: string): Promise<APIResponse<CaptureResult<UserPhotoCaptureData>>>;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
167
|
+
/**
|
|
168
|
+
* Soft-deactivates the current patient account.
|
|
169
|
+
* The patient record is not permanently deleted.
|
|
170
|
+
*/
|
|
171
|
+
deactivateCurrentPatient(): Promise<APIResponse<boolean>>;
|
|
147
172
|
private getAuthHeaders;
|
|
148
|
-
private getJsonHeaders;
|
|
149
|
-
private getApiKeyHeader;
|
|
150
|
-
private requireValue;
|
|
151
173
|
}
|
|
152
174
|
|
|
153
|
-
export { type
|
|
175
|
+
export { type CaptureResult, type CaptureType, type CoverageData, type Encounter, HCSettingsClient, type IdentificationCaptureData, type InsuranceCaptureData, type InsuranceRecord, type PatientDashboard, type PatientRecord, type UserImage, type UserPhotoCaptureData, UserStatus };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
import { HCLoginClient } from '@healthcloudai/hc-login-connector';
|
|
2
|
-
import { HttpClient,
|
|
3
|
-
export { APIError, ConfigError, HCServiceError, NetworkError, ValidationError
|
|
2
|
+
import { HCBaseConnector, HttpClient, APIResponse } from '@healthcloudai/hc-http';
|
|
3
|
+
export { APIError, APIResponse, ConfigError, HCServiceError, NetworkError, ValidationError } from '@healthcloudai/hc-http';
|
|
4
4
|
|
|
5
|
-
interface APIRequest<T> {
|
|
6
|
-
Data: T;
|
|
7
|
-
}
|
|
8
|
-
interface APIResponse<T> {
|
|
9
|
-
Data: T | null;
|
|
10
|
-
IsOK: boolean;
|
|
11
|
-
ErrorMessage: string | null;
|
|
12
|
-
}
|
|
13
5
|
interface UserImage {
|
|
14
6
|
ImageURL: string | null;
|
|
15
7
|
FileName: string | null;
|
|
@@ -121,33 +113,63 @@ interface InsuranceRecord {
|
|
|
121
113
|
Image?: string | null;
|
|
122
114
|
}
|
|
123
115
|
|
|
124
|
-
declare class HCSettingsClient {
|
|
125
|
-
private readonly
|
|
126
|
-
private readonly loginClient;
|
|
127
|
-
private apiKeyHeaderName?;
|
|
128
|
-
private apiKeyValue?;
|
|
116
|
+
declare class HCSettingsClient extends HCBaseConnector {
|
|
117
|
+
private readonly auth;
|
|
129
118
|
constructor(httpClient: HttpClient, loginClient: HCLoginClient);
|
|
130
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Returns the patient dashboard including record, encounters, and pending actions.
|
|
121
|
+
*/
|
|
131
122
|
getDashboard(): Promise<APIResponse<PatientDashboard>>;
|
|
123
|
+
/**
|
|
124
|
+
* Returns a canned (pre-signed) URL for uploading the patient profile image.
|
|
125
|
+
* Extension must be a valid file extension such as "jpg" or "png".
|
|
126
|
+
*/
|
|
132
127
|
getUserImageCannedUrl(extension: string): Promise<APIResponse<UserImage>>;
|
|
128
|
+
/**
|
|
129
|
+
* Updates the patient's profile image by confirming the uploaded file name.
|
|
130
|
+
*/
|
|
133
131
|
updateUserImage(fileName: string): Promise<APIResponse<boolean>>;
|
|
132
|
+
/**
|
|
133
|
+
* Returns a canned URL for uploading the patient's driving licence image.
|
|
134
|
+
*/
|
|
134
135
|
getDrivingLicenseCannedUrl(extension: string): Promise<APIResponse<UserImage>>;
|
|
136
|
+
/**
|
|
137
|
+
* Submits a driving licence file for OCR capture.
|
|
138
|
+
* fileKey is the storage key of the uploaded image.
|
|
139
|
+
*/
|
|
135
140
|
captureDrivingLicense(fileKey: string): Promise<APIResponse<CaptureResult<IdentificationCaptureData>>>;
|
|
141
|
+
/**
|
|
142
|
+
* Submits a base64-encoded driving licence image to the EHR.
|
|
143
|
+
*/
|
|
136
144
|
submitDrivingLicense(image: string): Promise<APIResponse<string>>;
|
|
145
|
+
/**
|
|
146
|
+
* Returns a canned URL for uploading the insurance card image.
|
|
147
|
+
*/
|
|
137
148
|
getInsuranceCannedUrl(extension: string): Promise<APIResponse<UserImage>>;
|
|
149
|
+
/**
|
|
150
|
+
* Submits an insurance card image for OCR capture.
|
|
151
|
+
* fileKey is the storage key of the uploaded image.
|
|
152
|
+
*/
|
|
138
153
|
captureInsurance(fileKey: string): Promise<APIResponse<CaptureResult<InsuranceCaptureData>>>;
|
|
154
|
+
/**
|
|
155
|
+
* Creates or updates the patient's insurance coverage record.
|
|
156
|
+
*/
|
|
139
157
|
submitInsurance(coverage: CoverageData): Promise<APIResponse<InsuranceRecord>>;
|
|
140
|
-
|
|
158
|
+
/**
|
|
159
|
+
* Returns all insurance records for the authenticated patient.
|
|
160
|
+
*/
|
|
161
|
+
listInsurances(): Promise<APIResponse<InsuranceRecord[]>>;
|
|
162
|
+
/**
|
|
163
|
+
* Submits a user photo (selfie) for capture.
|
|
164
|
+
* fileKey is the storage key of the uploaded image.
|
|
165
|
+
*/
|
|
141
166
|
captureUserPhoto(fileKey: string): Promise<APIResponse<CaptureResult<UserPhotoCaptureData>>>;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
167
|
+
/**
|
|
168
|
+
* Soft-deactivates the current patient account.
|
|
169
|
+
* The patient record is not permanently deleted.
|
|
170
|
+
*/
|
|
171
|
+
deactivateCurrentPatient(): Promise<APIResponse<boolean>>;
|
|
147
172
|
private getAuthHeaders;
|
|
148
|
-
private getJsonHeaders;
|
|
149
|
-
private getApiKeyHeader;
|
|
150
|
-
private requireValue;
|
|
151
173
|
}
|
|
152
174
|
|
|
153
|
-
export { type
|
|
175
|
+
export { type CaptureResult, type CaptureType, type CoverageData, type Encounter, HCSettingsClient, type IdentificationCaptureData, type InsuranceCaptureData, type InsuranceRecord, type PatientDashboard, type PatientRecord, type UserImage, type UserPhotoCaptureData, UserStatus };
|
package/dist/index.js
CHANGED
|
@@ -1,39 +1,21 @@
|
|
|
1
1
|
// src/client.ts
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
ConfigError,
|
|
5
|
-
HCServiceError,
|
|
6
|
-
ValidationError
|
|
7
|
-
} from "@healthcloudai/hc-http";
|
|
8
|
-
var HCSettingsClient = class {
|
|
2
|
+
import { HCBaseConnector, ValidationError } from "@healthcloudai/hc-http";
|
|
3
|
+
var HCSettingsClient = class extends HCBaseConnector {
|
|
9
4
|
constructor(httpClient, loginClient) {
|
|
10
|
-
|
|
11
|
-
this.
|
|
12
|
-
}
|
|
13
|
-
setApiKey(headerName, value) {
|
|
14
|
-
const trimmedHeaderName = headerName == null ? void 0 : headerName.trim();
|
|
15
|
-
const trimmedValue = value == null ? void 0 : value.trim();
|
|
16
|
-
if (!trimmedHeaderName) {
|
|
17
|
-
throw new ConfigError(
|
|
18
|
-
"API key header name is required."
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
if (!trimmedValue) {
|
|
22
|
-
throw new ConfigError(
|
|
23
|
-
"API key value is required."
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
this.apiKeyHeaderName = trimmedHeaderName;
|
|
27
|
-
this.apiKeyValue = trimmedValue;
|
|
5
|
+
super(httpClient);
|
|
6
|
+
this.auth = loginClient;
|
|
28
7
|
}
|
|
29
8
|
// ===========================================================================
|
|
30
9
|
// Dashboard
|
|
31
10
|
// ===========================================================================
|
|
11
|
+
/**
|
|
12
|
+
* Returns the patient dashboard including record, encounters, and pending actions.
|
|
13
|
+
*/
|
|
32
14
|
async getDashboard() {
|
|
33
15
|
return this.execute(
|
|
34
16
|
"getDashboard",
|
|
35
|
-
() => this.
|
|
36
|
-
`${this.getBaseUrl()}/api/patient/dashboard`,
|
|
17
|
+
() => this.http.get(
|
|
18
|
+
`${this.auth.getBaseUrl()}/api/patient/dashboard`,
|
|
37
19
|
this.getAuthHeaders()
|
|
38
20
|
)
|
|
39
21
|
);
|
|
@@ -41,152 +23,143 @@ var HCSettingsClient = class {
|
|
|
41
23
|
// ===========================================================================
|
|
42
24
|
// User image
|
|
43
25
|
// ===========================================================================
|
|
26
|
+
/**
|
|
27
|
+
* Returns a canned (pre-signed) URL for uploading the patient profile image.
|
|
28
|
+
* Extension must be a valid file extension such as "jpg" or "png".
|
|
29
|
+
*/
|
|
44
30
|
async getUserImageCannedUrl(extension) {
|
|
45
|
-
const resolvedExtension = this.requireValue(
|
|
46
|
-
extension,
|
|
47
|
-
"extension"
|
|
48
|
-
);
|
|
31
|
+
const resolvedExtension = this.requireValue(extension, "Extension", "extension");
|
|
49
32
|
const requestPayload = {
|
|
50
|
-
Data: {
|
|
51
|
-
Extension: resolvedExtension
|
|
52
|
-
}
|
|
33
|
+
Data: { Extension: resolvedExtension }
|
|
53
34
|
};
|
|
54
35
|
return this.execute(
|
|
55
36
|
"getUserImageCannedUrl",
|
|
56
|
-
() => this.
|
|
57
|
-
`${this.getBaseUrl()}/api/patient/image/cannedurl`,
|
|
37
|
+
() => this.http.put(
|
|
38
|
+
`${this.auth.getBaseUrl()}/api/patient/image/cannedurl`,
|
|
58
39
|
requestPayload,
|
|
59
|
-
this.
|
|
40
|
+
this.getAuthHeaders()
|
|
60
41
|
)
|
|
61
42
|
);
|
|
62
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Updates the patient's profile image by confirming the uploaded file name.
|
|
46
|
+
*/
|
|
63
47
|
async updateUserImage(fileName) {
|
|
64
|
-
const resolvedFileName = this.requireValue(
|
|
65
|
-
fileName,
|
|
66
|
-
"fileName"
|
|
67
|
-
);
|
|
48
|
+
const resolvedFileName = this.requireValue(fileName, "File name", "fileName");
|
|
68
49
|
const requestPayload = {
|
|
69
|
-
Data: {
|
|
70
|
-
FileName: resolvedFileName
|
|
71
|
-
}
|
|
50
|
+
Data: { FileName: resolvedFileName }
|
|
72
51
|
};
|
|
73
52
|
return this.execute(
|
|
74
53
|
"updateUserImage",
|
|
75
|
-
() => this.
|
|
76
|
-
`${this.getBaseUrl()}/api/patient/image/url`,
|
|
54
|
+
() => this.http.put(
|
|
55
|
+
`${this.auth.getBaseUrl()}/api/patient/image/url`,
|
|
77
56
|
requestPayload,
|
|
78
|
-
this.
|
|
57
|
+
this.getAuthHeaders()
|
|
79
58
|
)
|
|
80
59
|
);
|
|
81
60
|
}
|
|
82
61
|
// ===========================================================================
|
|
83
62
|
// Identification
|
|
84
63
|
// ===========================================================================
|
|
64
|
+
/**
|
|
65
|
+
* Returns a canned URL for uploading the patient's driving licence image.
|
|
66
|
+
*/
|
|
85
67
|
async getDrivingLicenseCannedUrl(extension) {
|
|
86
|
-
const resolvedExtension = this.requireValue(
|
|
87
|
-
extension,
|
|
88
|
-
"extension"
|
|
89
|
-
);
|
|
68
|
+
const resolvedExtension = this.requireValue(extension, "Extension", "extension");
|
|
90
69
|
const requestPayload = {
|
|
91
|
-
Data: {
|
|
92
|
-
Extension: resolvedExtension
|
|
93
|
-
}
|
|
70
|
+
Data: { Extension: resolvedExtension }
|
|
94
71
|
};
|
|
95
72
|
return this.execute(
|
|
96
73
|
"getDrivingLicenseCannedUrl",
|
|
97
|
-
() => this.
|
|
98
|
-
`${this.getBaseUrl()}/api/patient/id/cannedurl`,
|
|
74
|
+
() => this.http.put(
|
|
75
|
+
`${this.auth.getBaseUrl()}/api/patient/id/cannedurl`,
|
|
99
76
|
requestPayload,
|
|
100
|
-
this.
|
|
77
|
+
this.getAuthHeaders()
|
|
101
78
|
)
|
|
102
79
|
);
|
|
103
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Submits a driving licence file for OCR capture.
|
|
83
|
+
* fileKey is the storage key of the uploaded image.
|
|
84
|
+
*/
|
|
104
85
|
async captureDrivingLicense(fileKey) {
|
|
105
|
-
const resolvedFileKey = this.requireValue(
|
|
106
|
-
fileKey,
|
|
107
|
-
"fileKey"
|
|
108
|
-
);
|
|
86
|
+
const resolvedFileKey = this.requireValue(fileKey, "File key", "fileKey");
|
|
109
87
|
const requestPayload = {
|
|
110
|
-
Data: {
|
|
111
|
-
Type: "identification",
|
|
112
|
-
FileID: resolvedFileKey
|
|
113
|
-
}
|
|
88
|
+
Data: { Type: "identification", FileID: resolvedFileKey }
|
|
114
89
|
};
|
|
115
90
|
return this.execute(
|
|
116
91
|
"captureDrivingLicense",
|
|
117
|
-
() => this.
|
|
118
|
-
`${this.getBaseUrl()}/api/patient/capture`,
|
|
92
|
+
() => this.http.post(
|
|
93
|
+
`${this.auth.getBaseUrl()}/api/patient/capture`,
|
|
119
94
|
requestPayload,
|
|
120
|
-
this.
|
|
95
|
+
this.getAuthHeaders()
|
|
121
96
|
)
|
|
122
97
|
);
|
|
123
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Submits a base64-encoded driving licence image to the EHR.
|
|
101
|
+
*/
|
|
124
102
|
async submitDrivingLicense(image) {
|
|
125
|
-
const resolvedImage = this.requireValue(
|
|
126
|
-
image,
|
|
127
|
-
"image"
|
|
128
|
-
);
|
|
103
|
+
const resolvedImage = this.requireValue(image, "Image", "image");
|
|
129
104
|
const requestPayload = {
|
|
130
|
-
Data: {
|
|
131
|
-
Image: resolvedImage
|
|
132
|
-
}
|
|
105
|
+
Data: { Image: resolvedImage }
|
|
133
106
|
};
|
|
134
107
|
return this.execute(
|
|
135
108
|
"submitDrivingLicense",
|
|
136
|
-
() => this.
|
|
137
|
-
`${this.getBaseUrl()}/api/ehr/patient/drivinglicense`,
|
|
109
|
+
() => this.http.put(
|
|
110
|
+
`${this.auth.getBaseUrl()}/api/ehr/patient/drivinglicense`,
|
|
138
111
|
requestPayload,
|
|
139
|
-
this.
|
|
112
|
+
this.getAuthHeaders()
|
|
140
113
|
)
|
|
141
114
|
);
|
|
142
115
|
}
|
|
143
116
|
// ===========================================================================
|
|
144
117
|
// Insurance
|
|
145
118
|
// ===========================================================================
|
|
119
|
+
/**
|
|
120
|
+
* Returns a canned URL for uploading the insurance card image.
|
|
121
|
+
*/
|
|
146
122
|
async getInsuranceCannedUrl(extension) {
|
|
147
|
-
const resolvedExtension = this.requireValue(
|
|
148
|
-
extension,
|
|
149
|
-
"extension"
|
|
150
|
-
);
|
|
123
|
+
const resolvedExtension = this.requireValue(extension, "Extension", "extension");
|
|
151
124
|
const requestPayload = {
|
|
152
|
-
Data: {
|
|
153
|
-
Extension: resolvedExtension
|
|
154
|
-
}
|
|
125
|
+
Data: { Extension: resolvedExtension }
|
|
155
126
|
};
|
|
156
127
|
return this.execute(
|
|
157
128
|
"getInsuranceCannedUrl",
|
|
158
|
-
() => this.
|
|
159
|
-
`${this.getBaseUrl()}/api/patient/insurance/cannedurl`,
|
|
129
|
+
() => this.http.put(
|
|
130
|
+
`${this.auth.getBaseUrl()}/api/patient/insurance/cannedurl`,
|
|
160
131
|
requestPayload,
|
|
161
|
-
this.
|
|
132
|
+
this.getAuthHeaders()
|
|
162
133
|
)
|
|
163
134
|
);
|
|
164
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Submits an insurance card image for OCR capture.
|
|
138
|
+
* fileKey is the storage key of the uploaded image.
|
|
139
|
+
*/
|
|
165
140
|
async captureInsurance(fileKey) {
|
|
166
|
-
const resolvedFileKey = this.requireValue(
|
|
167
|
-
fileKey,
|
|
168
|
-
"fileKey"
|
|
169
|
-
);
|
|
141
|
+
const resolvedFileKey = this.requireValue(fileKey, "File key", "fileKey");
|
|
170
142
|
const requestPayload = {
|
|
171
|
-
Data: {
|
|
172
|
-
Type: "healthinsurance",
|
|
173
|
-
FileID: resolvedFileKey
|
|
174
|
-
}
|
|
143
|
+
Data: { Type: "healthinsurance", FileID: resolvedFileKey }
|
|
175
144
|
};
|
|
176
145
|
return this.execute(
|
|
177
146
|
"captureInsurance",
|
|
178
|
-
() => this.
|
|
179
|
-
`${this.getBaseUrl()}/api/patient/capture`,
|
|
147
|
+
() => this.http.post(
|
|
148
|
+
`${this.auth.getBaseUrl()}/api/patient/capture`,
|
|
180
149
|
requestPayload,
|
|
181
|
-
this.
|
|
150
|
+
this.getAuthHeaders()
|
|
182
151
|
)
|
|
183
152
|
);
|
|
184
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Creates or updates the patient's insurance coverage record.
|
|
156
|
+
*/
|
|
185
157
|
async submitInsurance(coverage) {
|
|
186
158
|
if (!coverage) {
|
|
187
159
|
throw new ValidationError({
|
|
188
160
|
message: "Insurance coverage data is required.",
|
|
189
|
-
code: "INVALID_INPUT"
|
|
161
|
+
code: "INVALID_INPUT",
|
|
162
|
+
param: "coverage"
|
|
190
163
|
});
|
|
191
164
|
}
|
|
192
165
|
const requestPayload = {
|
|
@@ -194,18 +167,21 @@ var HCSettingsClient = class {
|
|
|
194
167
|
};
|
|
195
168
|
return this.execute(
|
|
196
169
|
"submitInsurance",
|
|
197
|
-
() => this.
|
|
198
|
-
`${this.getBaseUrl()}/api/patient/coverage`,
|
|
170
|
+
() => this.http.put(
|
|
171
|
+
`${this.auth.getBaseUrl()}/api/patient/coverage`,
|
|
199
172
|
requestPayload,
|
|
200
|
-
this.
|
|
173
|
+
this.getAuthHeaders()
|
|
201
174
|
)
|
|
202
175
|
);
|
|
203
176
|
}
|
|
204
|
-
|
|
177
|
+
/**
|
|
178
|
+
* Returns all insurance records for the authenticated patient.
|
|
179
|
+
*/
|
|
180
|
+
async listInsurances() {
|
|
205
181
|
return this.execute(
|
|
206
|
-
"
|
|
207
|
-
() => this.
|
|
208
|
-
`${this.getBaseUrl()}/api/ehr/patient/insurances`,
|
|
182
|
+
"listInsurances",
|
|
183
|
+
() => this.http.get(
|
|
184
|
+
`${this.auth.getBaseUrl()}/api/ehr/patient/insurances`,
|
|
209
185
|
this.getAuthHeaders()
|
|
210
186
|
)
|
|
211
187
|
);
|
|
@@ -213,139 +189,56 @@ var HCSettingsClient = class {
|
|
|
213
189
|
// ===========================================================================
|
|
214
190
|
// User photo capture
|
|
215
191
|
// ===========================================================================
|
|
192
|
+
/**
|
|
193
|
+
* Submits a user photo (selfie) for capture.
|
|
194
|
+
* fileKey is the storage key of the uploaded image.
|
|
195
|
+
*/
|
|
216
196
|
async captureUserPhoto(fileKey) {
|
|
217
|
-
const resolvedFileKey = this.requireValue(
|
|
218
|
-
fileKey,
|
|
219
|
-
"fileKey"
|
|
220
|
-
);
|
|
197
|
+
const resolvedFileKey = this.requireValue(fileKey, "File key", "fileKey");
|
|
221
198
|
const requestPayload = {
|
|
222
|
-
Data: {
|
|
223
|
-
Type: "userphoto",
|
|
224
|
-
FileID: resolvedFileKey
|
|
225
|
-
}
|
|
199
|
+
Data: { Type: "userphoto", FileID: resolvedFileKey }
|
|
226
200
|
};
|
|
227
201
|
return this.execute(
|
|
228
202
|
"captureUserPhoto",
|
|
229
|
-
() => this.
|
|
230
|
-
`${this.getBaseUrl()}/api/patient/capture`,
|
|
203
|
+
() => this.http.post(
|
|
204
|
+
`${this.auth.getBaseUrl()}/api/patient/capture`,
|
|
231
205
|
requestPayload,
|
|
232
|
-
this.
|
|
206
|
+
this.getAuthHeaders()
|
|
233
207
|
)
|
|
234
208
|
);
|
|
235
209
|
}
|
|
236
210
|
// ===========================================================================
|
|
237
211
|
// Account
|
|
238
212
|
// ===========================================================================
|
|
239
|
-
|
|
213
|
+
/**
|
|
214
|
+
* Soft-deactivates the current patient account.
|
|
215
|
+
* The patient record is not permanently deleted.
|
|
216
|
+
*/
|
|
217
|
+
async deactivateCurrentPatient() {
|
|
240
218
|
return this.execute(
|
|
241
|
-
"
|
|
242
|
-
() => this.
|
|
243
|
-
`${this.getBaseUrl()}/api/patient/deactivate`,
|
|
219
|
+
"deactivateCurrentPatient",
|
|
220
|
+
() => this.http.put(
|
|
221
|
+
`${this.auth.getBaseUrl()}/api/patient/deactivate`,
|
|
244
222
|
void 0,
|
|
245
|
-
this.
|
|
223
|
+
this.getAuthHeaders()
|
|
246
224
|
)
|
|
247
225
|
);
|
|
248
226
|
}
|
|
249
227
|
// ===========================================================================
|
|
250
|
-
//
|
|
228
|
+
// Private
|
|
251
229
|
// ===========================================================================
|
|
252
|
-
async execute(operation, request) {
|
|
253
|
-
let response;
|
|
254
|
-
try {
|
|
255
|
-
response = await request();
|
|
256
|
-
} catch (err) {
|
|
257
|
-
if (err instanceof APIError) {
|
|
258
|
-
throw err;
|
|
259
|
-
}
|
|
260
|
-
if (err instanceof Error) {
|
|
261
|
-
throw new APIError({
|
|
262
|
-
message: `${operation}: ${err.message}`,
|
|
263
|
-
code: "UNKNOWN_ERROR",
|
|
264
|
-
details: err
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
throw new APIError({
|
|
268
|
-
message: `${operation}: unexpected runtime failure`,
|
|
269
|
-
code: "UNKNOWN_ERROR",
|
|
270
|
-
details: err
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
if (response == null) {
|
|
274
|
-
throw new APIError({
|
|
275
|
-
message: `${operation}: empty response received`,
|
|
276
|
-
code: "EMPTY_RESPONSE",
|
|
277
|
-
details: response
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
if (!this.isApiResponse(response)) {
|
|
281
|
-
throw new APIError({
|
|
282
|
-
message: `${operation}: invalid API response structure`,
|
|
283
|
-
code: "INVALID_RESPONSE",
|
|
284
|
-
details: response
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
if (!response.IsOK) {
|
|
288
|
-
throw this.mapBackendError(operation, response);
|
|
289
|
-
}
|
|
290
|
-
return response;
|
|
291
|
-
}
|
|
292
|
-
mapBackendError(operation, response) {
|
|
293
|
-
return new HCServiceError(
|
|
294
|
-
operation,
|
|
295
|
-
response.ErrorMessage,
|
|
296
|
-
response
|
|
297
|
-
);
|
|
298
|
-
}
|
|
299
|
-
isApiResponse(value) {
|
|
300
|
-
if (!value || typeof value !== "object") {
|
|
301
|
-
return false;
|
|
302
|
-
}
|
|
303
|
-
const response = value;
|
|
304
|
-
return "IsOK" in response && typeof response.IsOK === "boolean" && "Data" in response && "ErrorMessage" in response;
|
|
305
|
-
}
|
|
306
|
-
getBaseUrl() {
|
|
307
|
-
return this.loginClient.getBaseUrl();
|
|
308
|
-
}
|
|
309
230
|
getAuthHeaders() {
|
|
310
|
-
return {
|
|
311
|
-
...this.loginClient.getAuthHeader(),
|
|
312
|
-
...this.getApiKeyHeader()
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
getJsonHeaders() {
|
|
316
|
-
return {
|
|
317
|
-
...this.getAuthHeaders(),
|
|
318
|
-
"Content-Type": "application/json"
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
getApiKeyHeader() {
|
|
322
|
-
if (!this.apiKeyHeaderName || !this.apiKeyValue) {
|
|
323
|
-
return {};
|
|
324
|
-
}
|
|
325
|
-
return {
|
|
326
|
-
[this.apiKeyHeaderName]: this.apiKeyValue
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
requireValue(value, parameterName) {
|
|
330
|
-
const trimmedValue = value == null ? void 0 : value.trim();
|
|
331
|
-
if (!trimmedValue) {
|
|
332
|
-
throw new ValidationError({
|
|
333
|
-
message: `${parameterName} is required.`,
|
|
334
|
-
code: "INVALID_INPUT"
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
return trimmedValue;
|
|
231
|
+
return { ...this.getHeaders(), ...this.auth.getAuthHeader() };
|
|
338
232
|
}
|
|
339
233
|
};
|
|
340
234
|
|
|
341
235
|
// src/errors.ts
|
|
342
236
|
import {
|
|
343
|
-
APIError
|
|
344
|
-
ConfigError
|
|
345
|
-
HCServiceError
|
|
237
|
+
APIError,
|
|
238
|
+
ConfigError,
|
|
239
|
+
HCServiceError,
|
|
346
240
|
NetworkError,
|
|
347
|
-
ValidationError as ValidationError2
|
|
348
|
-
errorFromHttpStatus
|
|
241
|
+
ValidationError as ValidationError2
|
|
349
242
|
} from "@healthcloudai/hc-http";
|
|
350
243
|
|
|
351
244
|
// src/types.ts
|
|
@@ -356,12 +249,11 @@ var UserStatus = /* @__PURE__ */ ((UserStatus2) => {
|
|
|
356
249
|
return UserStatus2;
|
|
357
250
|
})(UserStatus || {});
|
|
358
251
|
export {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
252
|
+
APIError,
|
|
253
|
+
ConfigError,
|
|
254
|
+
HCServiceError,
|
|
362
255
|
HCSettingsClient,
|
|
363
256
|
NetworkError,
|
|
364
257
|
UserStatus,
|
|
365
|
-
ValidationError2 as ValidationError
|
|
366
|
-
errorFromHttpStatus
|
|
258
|
+
ValidationError2 as ValidationError
|
|
367
259
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@healthcloudai/hc-settings-connector",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Healthcheck Settings SDK with TypeScript",
|
|
5
5
|
"author": "Healthcheck Systems Inc",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"axios": "^1.13.4",
|
|
39
|
-
"@healthcloudai/hc-login-connector": "^0.
|
|
40
|
-
"@healthcloudai/hc-http": "^0.1
|
|
39
|
+
"@healthcloudai/hc-login-connector": "^0.3.1",
|
|
40
|
+
"@healthcloudai/hc-http": "^0.2.1"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"react-native": ">=0.70.0"
|