@healthcloudai/hc-settings-connector 0.0.3 → 0.0.4

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 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. Submit user insurance
10
- 2. Generate a pre-signed URL for user image upload
11
- 3. Update user profile image URL
12
- 4. Self deactivate user
13
- 5. Built on shared Healthcheck HttpClient and authentication layer
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(/* auth configuration */);
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,99 @@ await settingsClient.submitInsurance({
81
104
  });
82
105
  ```
83
106
 
84
- ### Upload User Image
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
85
118
 
86
- Public signature: `settingsClient.uploadUserImage(extension)`
119
+ Public signature: `settingsClient.captureUserPhoto(fileKey)`
87
120
 
88
- Generates a pre-signed upload URL for uploading a user profile image.
121
+ Captures a user selfie through `POST /patient/capture`.
122
+ The client internally sends `Type: "userphoto"` and `FileID: fileKey`.
89
123
 
90
124
  ```ts
91
- const image = await settingsClient.uploadUserImage("jpg");
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
+ "drivers-license-front.jpg"
150
+ );
151
+ ```
152
+
153
+ ### Submit Driving License
154
+
155
+ Public signature: `settingsClient.submitDrivingLicense(payload)`
156
+
157
+ Submits 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
+
161
+ ```ts
162
+ await settingsClient.submitDrivingLicense({
163
+ Number: "DL-123456",
164
+ State: "CA"
165
+ });
166
+ ```
167
+
168
+ ### Get Insurance Canned URL
169
+
170
+ Public signature: `settingsClient.getInsuranceCannedUrl(extension)`
171
+
172
+ Generates a pre-signed upload URL for an insurance file.
173
+
174
+ ```ts
175
+ const insuranceUpload = await settingsClient.getInsuranceCannedUrl("jpg");
176
+ ```
177
+
178
+ ### Capture Insurance
179
+
180
+ Public signature: `settingsClient.captureInsurance(fileKey)`
181
+
182
+ Captures and extracts insurance data through `POST /patient/capture`.
183
+ The client internally sends `Type: "healthinsurance"` and `FileID: fileKey`.
184
+
185
+ ```ts
186
+ const capturedInsurance = await settingsClient.captureInsurance(
187
+ "insurance-card-front.jpg"
188
+ );
189
+ ```
190
+
191
+ ### Get Insurances
192
+
193
+ Public signature: `settingsClient.getInsurances()`
194
+
195
+ Returns patient insurances through the wrapper-backed EHR route.
196
+ The client resolves the current patient's `EHR` internally from `authClient.getUserInfo()`.
197
+
198
+ ```ts
199
+ const insurances = await settingsClient.getInsurances();
92
200
  ```
93
201
 
94
202
  ### Update User Image URL
@@ -119,6 +227,7 @@ await settingsClient.deactivateUser();
119
227
  - Handles authentication
120
228
  - Resolves base API URL
121
229
  - Provides authorization headers
230
+ - Resolves the current user's `EHR` for EHR-backed settings methods
122
231
 
123
232
  - **HttpClient**
124
233
  - Performs all HTTP requests
@@ -126,4 +235,17 @@ await settingsClient.deactivateUser();
126
235
  - **HCSettingsClient**
127
236
  - Exposes user settings and profile-related endpoints
128
237
 
238
+ ---
239
+
240
+ ## Notes
241
+
242
+ - `HCLoginClient` must be configured and logged in before calling settings methods
243
+ - `getUserImageCannedUrl()` uses `PUT /patient/image/cannedurl`
244
+ - `getDrivingLicenseCannedUrl()` uses `PUT /patient/id/cannedurl`
245
+ - `getInsuranceCannedUrl()` uses `PUT /patient/insurance/cannedurl`
246
+ - `captureUserPhoto()` sends `Type: "userphoto"` and `FileID` to `/patient/capture`
247
+ - `captureDrivingLicense()` sends `Type: "identification"` and `FileID` to `/patient/capture`
248
+ - `captureInsurance()` sends `Type: "healthinsurance"` and `FileID` to `/patient/capture`
249
+ - `getInsurances()` and `submitDrivingLicense()` internally resolve the current patient's `EHR`
250
+
129
251
 
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 submitInsurance(payload) {
43
- const requestPayload = {
44
- Data: payload
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
- return this.http.put(
47
- `${this.auth.getBaseUrl()}/patient/coverage`,
48
- requestPayload,
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 uploadUserImage(extension) {
66
+ async getDrivingLicenseCannedUrl(extension) {
56
67
  var _a;
57
68
  const payload = {
58
69
  Data: {
@@ -60,7 +71,7 @@ var HCSettingsClient = class {
60
71
  }
61
72
  };
62
73
  const response = await this.http.put(
63
- `${this.auth.getBaseUrl()}/patient/image/cannedurl`,
74
+ `${this.auth.getBaseUrl()}/patient/id/cannedurl`,
64
75
  payload,
65
76
  {
66
77
  ...this.auth.getAuthHeader(),
@@ -69,6 +80,103 @@ var HCSettingsClient = class {
69
80
  );
70
81
  return (_a = response.Data) != null ? _a : response;
71
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`,
92
+ payload,
93
+ {
94
+ ...this.auth.getAuthHeader(),
95
+ "Content-Type": "application/json"
96
+ }
97
+ );
98
+ return (_a = response.Data) != null ? _a : response;
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 submitDrivingLicense(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
+ }
72
180
  async updateUserImage(fileName) {
73
181
  var _a;
74
182
  const payload = {
@@ -99,6 +207,23 @@ var HCSettingsClient = class {
99
207
  }
100
208
  );
101
209
  }
210
+ async buildEhrPatientUrl(path) {
211
+ const ehr = await this.getResolvedEhr();
212
+ return `${this.auth.getBaseUrl()}/ehr/${ehr}/patient/${path}`;
213
+ }
214
+ async getResolvedEhr() {
215
+ var _a, _b, _c;
216
+ if (this.resolvedEhr) {
217
+ return this.resolvedEhr;
218
+ }
219
+ const userInfo = await this.auth.getUserInfo();
220
+ 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());
221
+ if (!ehr) {
222
+ throw new Error("Could not resolve EHR from loginClient.getUserInfo()");
223
+ }
224
+ this.resolvedEhr = ehr;
225
+ return ehr;
226
+ }
102
227
  };
103
228
 
104
229
  // src/errors.ts
package/dist/index.d.cts CHANGED
@@ -16,6 +16,12 @@ 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
+ }
19
25
  interface CoverageRequest {
20
26
  InsurancePackageId: string;
21
27
  MemberId: string;
@@ -27,6 +33,14 @@ interface CoverageRequest {
27
33
  interface CoveragePayload {
28
34
  Data: CoverageRequest;
29
35
  }
36
+ type CaptureType = "identification" | "healthinsurance" | "userphoto";
37
+ interface CaptureData {
38
+ Type: CaptureType;
39
+ FileID: string;
40
+ }
41
+ interface CaptureRequest {
42
+ Data: CaptureData;
43
+ }
30
44
  interface UploadImageData {
31
45
  Extension: string;
32
46
  }
@@ -42,18 +56,33 @@ interface UpdateImageRequest {
42
56
  interface EmptyRequest {
43
57
  Data: Record<string, never>;
44
58
  }
59
+ type DrivingLicenseData = Record<string, string | number | boolean | null>;
60
+ interface DrivingLicenseRequest {
61
+ Data: DrivingLicenseData;
62
+ }
45
63
  type HCUserImage = UserImage;
46
64
  type HCUserInfo = UserInfo;
47
65
 
48
66
  declare class HCSettingsClient {
49
67
  private http;
50
68
  private auth;
69
+ private resolvedEhr;
51
70
  constructor(httpClient: HttpClient, authClient: HCLoginClient);
52
71
  getUserInfo(): Promise<any>;
72
+ getDashboard(): Promise<any>;
73
+ getUserImageCannedUrl(extension: string): Promise<UserImage>;
74
+ getDrivingLicenseCannedUrl(extension: string): Promise<UserImage>;
75
+ getInsuranceCannedUrl(extension: string): Promise<UserImage>;
76
+ captureUserPhoto(fileKey: string): Promise<any>;
77
+ captureDrivingLicense(fileKey: string): Promise<any>;
78
+ captureInsurance(fileKey: string): Promise<any>;
53
79
  submitInsurance(payload: CoverageRequest): Promise<any>;
54
- uploadUserImage(extension: string): Promise<UserImage>;
80
+ getInsurances(): Promise<any>;
81
+ submitDrivingLicense(payload: DrivingLicenseData): Promise<any>;
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 { AuthError, type CaptureData, type CaptureRequest, type CaptureType, ConfigError, type CoveragePayload, type CoverageRequest, type DrivingLicenseData, type DrivingLicenseRequest, 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,12 @@ 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
+ }
19
25
  interface CoverageRequest {
20
26
  InsurancePackageId: string;
21
27
  MemberId: string;
@@ -27,6 +33,14 @@ interface CoverageRequest {
27
33
  interface CoveragePayload {
28
34
  Data: CoverageRequest;
29
35
  }
36
+ type CaptureType = "identification" | "healthinsurance" | "userphoto";
37
+ interface CaptureData {
38
+ Type: CaptureType;
39
+ FileID: string;
40
+ }
41
+ interface CaptureRequest {
42
+ Data: CaptureData;
43
+ }
30
44
  interface UploadImageData {
31
45
  Extension: string;
32
46
  }
@@ -42,18 +56,33 @@ interface UpdateImageRequest {
42
56
  interface EmptyRequest {
43
57
  Data: Record<string, never>;
44
58
  }
59
+ type DrivingLicenseData = Record<string, string | number | boolean | null>;
60
+ interface DrivingLicenseRequest {
61
+ Data: DrivingLicenseData;
62
+ }
45
63
  type HCUserImage = UserImage;
46
64
  type HCUserInfo = UserInfo;
47
65
 
48
66
  declare class HCSettingsClient {
49
67
  private http;
50
68
  private auth;
69
+ private resolvedEhr;
51
70
  constructor(httpClient: HttpClient, authClient: HCLoginClient);
52
71
  getUserInfo(): Promise<any>;
72
+ getDashboard(): Promise<any>;
73
+ getUserImageCannedUrl(extension: string): Promise<UserImage>;
74
+ getDrivingLicenseCannedUrl(extension: string): Promise<UserImage>;
75
+ getInsuranceCannedUrl(extension: string): Promise<UserImage>;
76
+ captureUserPhoto(fileKey: string): Promise<any>;
77
+ captureDrivingLicense(fileKey: string): Promise<any>;
78
+ captureInsurance(fileKey: string): Promise<any>;
53
79
  submitInsurance(payload: CoverageRequest): Promise<any>;
54
- uploadUserImage(extension: string): Promise<UserImage>;
80
+ getInsurances(): Promise<any>;
81
+ submitDrivingLicense(payload: DrivingLicenseData): Promise<any>;
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 { AuthError, type CaptureData, type CaptureRequest, type CaptureType, ConfigError, type CoveragePayload, type CoverageRequest, type DrivingLicenseData, type DrivingLicenseRequest, 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 submitInsurance(payload) {
14
- const requestPayload = {
15
- Data: payload
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
- return this.http.put(
18
- `${this.auth.getBaseUrl()}/patient/coverage`,
19
- requestPayload,
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 uploadUserImage(extension) {
37
+ async getDrivingLicenseCannedUrl(extension) {
27
38
  var _a;
28
39
  const payload = {
29
40
  Data: {
@@ -31,7 +42,7 @@ var HCSettingsClient = class {
31
42
  }
32
43
  };
33
44
  const response = await this.http.put(
34
- `${this.auth.getBaseUrl()}/patient/image/cannedurl`,
45
+ `${this.auth.getBaseUrl()}/patient/id/cannedurl`,
35
46
  payload,
36
47
  {
37
48
  ...this.auth.getAuthHeader(),
@@ -40,6 +51,103 @@ var HCSettingsClient = class {
40
51
  );
41
52
  return (_a = response.Data) != null ? _a : response;
42
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`,
63
+ payload,
64
+ {
65
+ ...this.auth.getAuthHeader(),
66
+ "Content-Type": "application/json"
67
+ }
68
+ );
69
+ return (_a = response.Data) != null ? _a : response;
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 submitDrivingLicense(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
+ }
43
151
  async updateUserImage(fileName) {
44
152
  var _a;
45
153
  const payload = {
@@ -70,6 +178,23 @@ var HCSettingsClient = class {
70
178
  }
71
179
  );
72
180
  }
181
+ async buildEhrPatientUrl(path) {
182
+ const ehr = await this.getResolvedEhr();
183
+ return `${this.auth.getBaseUrl()}/ehr/${ehr}/patient/${path}`;
184
+ }
185
+ async getResolvedEhr() {
186
+ var _a, _b, _c;
187
+ if (this.resolvedEhr) {
188
+ return this.resolvedEhr;
189
+ }
190
+ const userInfo = await this.auth.getUserInfo();
191
+ 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());
192
+ if (!ehr) {
193
+ throw new Error("Could not resolve EHR from loginClient.getUserInfo()");
194
+ }
195
+ this.resolvedEhr = ehr;
196
+ return ehr;
197
+ }
73
198
  };
74
199
 
75
200
  // 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",
3
+ "version": "0.0.4",
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.2",
39
+ "@healthcloudai/hc-login-connector": "^0.0.7",
40
40
  "@healthcloudai/hc-http": "^0.0.3"
41
41
  },
42
42
  "peerDependencies": {