@healthcloudai/hc-settings-connector 0.0.13 → 0.0.14

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/dist/index.cjs CHANGED
@@ -23,7 +23,8 @@ __export(index_exports, {
23
23
  AuthError: () => AuthError,
24
24
  ConfigError: () => ConfigError,
25
25
  HCSettingsClient: () => HCSettingsClient,
26
- HttpError: () => HttpError
26
+ HttpError: () => HttpError,
27
+ UserStatus: () => UserStatus
27
28
  });
28
29
  module.exports = __toCommonJS(index_exports);
29
30
 
@@ -50,144 +51,218 @@ var HttpError = class extends Error {
50
51
 
51
52
  // src/client.ts
52
53
  var HCSettingsClient = class {
53
- constructor(httpClient, authClient) {
54
- this.http = httpClient;
55
- this.auth = authClient;
54
+ constructor(httpClient, loginClient) {
55
+ this.httpClient = httpClient;
56
+ this.loginClient = loginClient;
56
57
  }
57
58
  setApiKey(headerName, value) {
58
59
  const trimmedHeaderName = headerName == null ? void 0 : headerName.trim();
59
60
  const trimmedValue = value == null ? void 0 : value.trim();
60
61
  if (!trimmedHeaderName) {
61
- throw new ConfigError("API key header name is required.");
62
+ throw new ConfigError(
63
+ "API key header name is required."
64
+ );
62
65
  }
63
66
  if (!trimmedValue) {
64
- throw new ConfigError("API key value is required.");
67
+ throw new ConfigError(
68
+ "API key value is required."
69
+ );
65
70
  }
66
71
  this.apiKeyHeaderName = trimmedHeaderName;
67
72
  this.apiKeyValue = trimmedValue;
68
73
  }
74
+ // ===========================================================================
75
+ // Dashboard
76
+ // ===========================================================================
69
77
  async getDashboard() {
70
- return this.http.get(
78
+ return this.httpClient.get(
71
79
  `${this.getBaseUrl()}/patient/dashboard`,
72
80
  this.getAuthHeaders()
73
81
  );
74
82
  }
83
+ // ===========================================================================
84
+ // User image
85
+ // ===========================================================================
75
86
  async getUserImageCannedUrl(extension) {
76
- const payload = {
87
+ const resolvedExtension = this.requireValue(
88
+ extension,
89
+ "extension"
90
+ );
91
+ const requestPayload = {
77
92
  Data: {
78
- Extension: extension
93
+ Extension: resolvedExtension
79
94
  }
80
95
  };
81
- return this.http.put(
96
+ return this.httpClient.put(
82
97
  `${this.getBaseUrl()}/patient/image/cannedurl`,
83
- payload,
98
+ requestPayload,
84
99
  this.getJsonHeaders()
85
100
  );
86
101
  }
87
- async getDrivingLicenseCannedUrl(extension) {
88
- const payload = {
102
+ async updateUserImage(fileName) {
103
+ const resolvedFileName = this.requireValue(
104
+ fileName,
105
+ "fileName"
106
+ );
107
+ const requestPayload = {
89
108
  Data: {
90
- Extension: extension
109
+ FileName: resolvedFileName
91
110
  }
92
111
  };
93
- return this.http.put(
94
- `${this.getBaseUrl()}/patient/id/cannedurl`,
95
- payload,
112
+ return this.httpClient.put(
113
+ `${this.getBaseUrl()}/patient/image/url`,
114
+ requestPayload,
96
115
  this.getJsonHeaders()
97
116
  );
98
117
  }
99
- async getInsuranceCannedUrl(extension) {
100
- const payload = {
118
+ // ===========================================================================
119
+ // Identification
120
+ // ===========================================================================
121
+ async getDrivingLicenseCannedUrl(extension) {
122
+ const resolvedExtension = this.requireValue(
123
+ extension,
124
+ "extension"
125
+ );
126
+ const requestPayload = {
101
127
  Data: {
102
- Extension: extension
128
+ Extension: resolvedExtension
103
129
  }
104
130
  };
105
- return this.http.put(
106
- `${this.getBaseUrl()}/patient/insurance/cannedurl`,
107
- payload,
131
+ return this.httpClient.put(
132
+ `${this.getBaseUrl()}/patient/id/cannedurl`,
133
+ requestPayload,
108
134
  this.getJsonHeaders()
109
135
  );
110
136
  }
111
137
  async captureDrivingLicense(fileKey) {
112
- const payload = {
138
+ const resolvedFileKey = this.requireValue(
139
+ fileKey,
140
+ "fileKey"
141
+ );
142
+ const requestPayload = {
113
143
  Data: {
114
144
  Type: "identification",
115
- FileID: fileKey
145
+ FileID: resolvedFileKey
116
146
  }
117
147
  };
118
- return this.http.post(
148
+ return this.httpClient.post(
119
149
  `${this.getBaseUrl()}/patient/capture`,
120
- payload,
150
+ requestPayload,
151
+ this.getJsonHeaders()
152
+ );
153
+ }
154
+ async submitDrivingLicense(image) {
155
+ const resolvedImage = this.requireValue(
156
+ image,
157
+ "image"
158
+ );
159
+ const requestPayload = {
160
+ Data: {
161
+ Image: resolvedImage
162
+ }
163
+ };
164
+ return this.httpClient.put(
165
+ `${this.getBaseUrl()}/ehr/patient/drivinglicense`,
166
+ requestPayload,
167
+ this.getJsonHeaders()
168
+ );
169
+ }
170
+ // ===========================================================================
171
+ // Insurance
172
+ // ===========================================================================
173
+ async getInsuranceCannedUrl(extension) {
174
+ const resolvedExtension = this.requireValue(
175
+ extension,
176
+ "extension"
177
+ );
178
+ const requestPayload = {
179
+ Data: {
180
+ Extension: resolvedExtension
181
+ }
182
+ };
183
+ return this.httpClient.put(
184
+ `${this.getBaseUrl()}/patient/insurance/cannedurl`,
185
+ requestPayload,
121
186
  this.getJsonHeaders()
122
187
  );
123
188
  }
124
189
  async captureInsurance(fileKey) {
125
- const payload = {
190
+ const resolvedFileKey = this.requireValue(
191
+ fileKey,
192
+ "fileKey"
193
+ );
194
+ const requestPayload = {
126
195
  Data: {
127
196
  Type: "healthinsurance",
128
- FileID: fileKey
197
+ FileID: resolvedFileKey
129
198
  }
130
199
  };
131
- return this.http.post(
200
+ return this.httpClient.post(
132
201
  `${this.getBaseUrl()}/patient/capture`,
133
- payload,
202
+ requestPayload,
134
203
  this.getJsonHeaders()
135
204
  );
136
205
  }
137
- async submitInsurance(payload) {
206
+ async submitInsurance(coverage) {
207
+ if (!coverage) {
208
+ throw new ConfigError(
209
+ "Insurance coverage data is required."
210
+ );
211
+ }
138
212
  const requestPayload = {
139
- Data: payload
213
+ Data: coverage
140
214
  };
141
- return this.http.put(
215
+ return this.httpClient.put(
142
216
  `${this.getBaseUrl()}/patient/coverage`,
143
217
  requestPayload,
144
218
  this.getJsonHeaders()
145
219
  );
146
220
  }
147
221
  async getInsurances() {
148
- return this.http.get(
222
+ return this.httpClient.get(
149
223
  `${this.getBaseUrl()}/ehr/patient/insurances`,
150
224
  this.getAuthHeaders()
151
225
  );
152
226
  }
153
- async submitDrivingLicense(payload) {
154
- const requestPayload = {
155
- Data: payload
156
- };
157
- return this.http.put(
158
- `${this.getBaseUrl()}/ehr/patient/drivinglicense`,
159
- requestPayload,
160
- this.getJsonHeaders()
227
+ // ===========================================================================
228
+ // User photo capture
229
+ // ===========================================================================
230
+ async captureUserPhoto(fileKey) {
231
+ const resolvedFileKey = this.requireValue(
232
+ fileKey,
233
+ "fileKey"
161
234
  );
162
- }
163
- async updateUserImage(fileName) {
164
- const payload = {
235
+ const requestPayload = {
165
236
  Data: {
166
- FileName: fileName
237
+ Type: "userphoto",
238
+ FileID: resolvedFileKey
167
239
  }
168
240
  };
169
- return this.http.put(
170
- `${this.getBaseUrl()}/patient/image/url`,
171
- payload,
241
+ return this.httpClient.post(
242
+ `${this.getBaseUrl()}/patient/capture`,
243
+ requestPayload,
172
244
  this.getJsonHeaders()
173
245
  );
174
246
  }
247
+ // ===========================================================================
248
+ // Account
249
+ // ===========================================================================
175
250
  async deactivateUser() {
176
- const payload = {
177
- Data: {}
178
- };
179
- return this.http.put(
251
+ return this.httpClient.put(
180
252
  `${this.getBaseUrl()}/patient/deactivate`,
181
- payload,
253
+ void 0,
182
254
  this.getJsonHeaders()
183
255
  );
184
256
  }
257
+ // ===========================================================================
258
+ // Helpers
259
+ // ===========================================================================
185
260
  getBaseUrl() {
186
- return this.auth.getBaseUrl();
261
+ return this.loginClient.getBaseUrl();
187
262
  }
188
263
  getAuthHeaders() {
189
264
  return {
190
- ...this.auth.getAuthHeader(),
265
+ ...this.loginClient.getAuthHeader(),
191
266
  ...this.getApiKeyHeader()
192
267
  };
193
268
  }
@@ -205,11 +280,29 @@ var HCSettingsClient = class {
205
280
  [this.apiKeyHeaderName]: this.apiKeyValue
206
281
  };
207
282
  }
283
+ requireValue(value, parameterName) {
284
+ const trimmedValue = value == null ? void 0 : value.trim();
285
+ if (!trimmedValue) {
286
+ throw new ConfigError(
287
+ `${parameterName} is required.`
288
+ );
289
+ }
290
+ return trimmedValue;
291
+ }
208
292
  };
293
+
294
+ // src/types.ts
295
+ var UserStatus = /* @__PURE__ */ ((UserStatus2) => {
296
+ UserStatus2[UserStatus2["INACTIVE"] = 0] = "INACTIVE";
297
+ UserStatus2[UserStatus2["ACTIVE"] = 1] = "ACTIVE";
298
+ UserStatus2[UserStatus2["SUSPENDED"] = -1] = "SUSPENDED";
299
+ return UserStatus2;
300
+ })(UserStatus || {});
209
301
  // Annotate the CommonJS export names for ESM import in node:
210
302
  0 && (module.exports = {
211
303
  AuthError,
212
304
  ConfigError,
213
305
  HCSettingsClient,
214
- HttpError
306
+ HttpError,
307
+ UserStatus
215
308
  });
package/dist/index.d.cts CHANGED
@@ -1,24 +1,20 @@
1
1
  import { HCLoginClient } from '@healthcloudai/hc-login-connector';
2
2
  import { HttpClient } from '@healthcloudai/hc-http';
3
3
 
4
- type Environment = "dev" | "uat" | "prod";
5
- interface UserImage {
6
- ImageURL: string;
7
- FileName: string;
8
- Extension: string;
9
- imageUrl?: string;
10
- fileName?: string;
11
- extension?: string;
12
- }
13
4
  interface APIRequest<T> {
14
5
  Data: T;
15
6
  }
16
7
  interface APIResponse<T> {
17
- Data: T;
8
+ Data: T | null;
18
9
  IsOK: boolean;
19
- ErrorMessage?: string | null;
10
+ ErrorMessage: string | null;
20
11
  }
21
- interface CoverageRequest {
12
+ interface UserImage {
13
+ ImageURL: string | null;
14
+ FileName: string | null;
15
+ Extension: string | null;
16
+ }
17
+ interface CoverageData {
22
18
  InsurancePackageId: string;
23
19
  MemberId: string;
24
20
  FirstName: string;
@@ -26,51 +22,128 @@ interface CoverageRequest {
26
22
  Sex: string;
27
23
  Image: string;
28
24
  }
29
- type CoveragePayload = APIRequest<CoverageRequest>;
30
- type CaptureType = "identification" | "healthinsurance";
31
- interface CaptureData {
32
- Type: CaptureType;
33
- FileID: string;
25
+ declare enum UserStatus {
26
+ INACTIVE = 0,
27
+ ACTIVE = 1,
28
+ SUSPENDED = -1
34
29
  }
35
- type CaptureRequest = APIRequest<CaptureData>;
36
- interface UploadImageData {
37
- Extension: string;
30
+ interface PatientRecord {
31
+ Status: UserStatus;
32
+ Sex: string | null;
33
+ GenderIdentity: string | null;
34
+ HasInsurance: boolean;
35
+ HasIDCard: boolean;
36
+ HasSelfie: boolean;
37
+ Flags: Record<string, string> | null;
38
38
  }
39
- type UploadImageRequest = APIRequest<UploadImageData>;
40
- interface UpdateImageData {
41
- FileName: string;
39
+ interface Encounter {
40
+ FHIRID: string | null;
41
+ AthenaID: string | null;
42
+ Status: number;
43
+ Patient: PatientRecord | null;
44
+ EncounterClass: string | null;
45
+ EHR: string | null;
46
+ EHRType: string | null;
47
+ EHRVisitName: string | null;
48
+ EHRAppointmentID: string | null;
49
+ EHRProviderID: string | null;
50
+ EHRProviderName: string | null;
51
+ EHRDate: string | null;
52
+ EHRStatus: string | null;
53
+ EHRStage: string | null;
42
54
  }
43
- type UpdateImageRequest = APIRequest<UpdateImageData>;
44
- type EmptyRequest = APIRequest<Record<string, never>>;
45
- interface DrivingLicenseData {
46
- Image: string;
55
+ interface PatientDashboard {
56
+ Record: PatientRecord | null;
57
+ Encounters: Encounter[];
58
+ EHR: string | null;
59
+ PendingActions: string[];
60
+ }
61
+ type CaptureType = "healthinsurance" | "identification" | "userphoto";
62
+ interface InsuranceCaptureData {
63
+ FirstName: string | null;
64
+ LastName: string | null;
65
+ MemberId: string | null;
66
+ GroupNumber: string | null;
67
+ EffectiveDate: string | null;
68
+ RxBIN: string | null;
69
+ RxPCN: string | null;
70
+ RxGRP: string | null;
71
+ Carrier: string | null;
72
+ }
73
+ interface IdentificationCaptureData {
74
+ FirstName: string | null;
75
+ LastName: string | null;
76
+ StreetAddress: string | null;
77
+ City: string | null;
78
+ ZipCode: string | null;
79
+ State: string | null;
80
+ IssuedDate: string | null;
81
+ ExpiresDate: string | null;
82
+ Dob: string | null;
83
+ IDNumber: string | null;
84
+ }
85
+ interface UserPhotoCaptureData {
86
+ ImageKey: string | null;
87
+ }
88
+ interface CaptureResult<T> {
89
+ CapturedData: T | null;
90
+ IsCaptured: boolean;
91
+ InsurancePackages: object[] | null;
92
+ }
93
+ interface InsuranceRecord {
94
+ LastUpdatedBy: string | null;
95
+ IrcName: string | null;
96
+ LastUpdated: string | null;
97
+ RelationshipToInsured: string | null;
98
+ InsurancePolicyHolder: string | null;
99
+ EligibilityStatus: string | null;
100
+ InsurancePolicyHolderCountryIso3166: string | null;
101
+ ConfidentialityCode: string | null;
102
+ Created: string | null;
103
+ InsuranceId: string | null;
104
+ InsurancePolicyHolderSex: string | null;
105
+ InsurancePlanName: string | null;
106
+ InsuranceType: string | null;
107
+ InsurancePolicyHolderCountryCode: string | null;
108
+ InsurancePackageId: number | null;
109
+ InsuredEntityTypeId: number | null;
110
+ InsurancePolicyHolderFirstName: string | null;
111
+ SequenceNumber: number | null;
112
+ IrcId: number | null;
113
+ CreatedBy: string | null;
114
+ RelationshipToInsuredId: number | null;
115
+ InsurancePolicyHolderLastName: string | null;
116
+ /**
117
+ * Internal-only fields returned in backend models.
118
+ */
119
+ MemberId?: string | null;
120
+ Image?: string | null;
47
121
  }
48
- type DrivingLicenseRequest = APIRequest<DrivingLicenseData>;
49
- type DrivingLicenseResponse = APIResponse<string>;
50
- type HCUserImage = UserImage;
51
122
 
52
123
  declare class HCSettingsClient {
53
- private http;
54
- private auth;
124
+ private readonly httpClient;
125
+ private readonly loginClient;
55
126
  private apiKeyHeaderName?;
56
127
  private apiKeyValue?;
57
- constructor(httpClient: HttpClient, authClient: HCLoginClient);
128
+ constructor(httpClient: HttpClient, loginClient: HCLoginClient);
58
129
  setApiKey(headerName: string, value: string): void;
59
- getDashboard(): Promise<any>;
60
- getUserImageCannedUrl(extension: string): Promise<UserImage>;
61
- getDrivingLicenseCannedUrl(extension: string): Promise<UserImage>;
62
- getInsuranceCannedUrl(extension: string): Promise<UserImage>;
63
- captureDrivingLicense(fileKey: string): Promise<any>;
64
- captureInsurance(fileKey: string): Promise<any>;
65
- submitInsurance(payload: CoverageRequest): Promise<any>;
66
- getInsurances(): Promise<any>;
67
- submitDrivingLicense(payload: DrivingLicenseData): Promise<DrivingLicenseResponse>;
68
- updateUserImage(fileName: string): Promise<any>;
69
- deactivateUser(): Promise<any>;
130
+ getDashboard(): Promise<APIResponse<PatientDashboard>>;
131
+ getUserImageCannedUrl(extension: string): Promise<APIResponse<UserImage>>;
132
+ updateUserImage(fileName: string): Promise<APIResponse<boolean>>;
133
+ getDrivingLicenseCannedUrl(extension: string): Promise<APIResponse<UserImage>>;
134
+ captureDrivingLicense(fileKey: string): Promise<APIResponse<CaptureResult<IdentificationCaptureData>>>;
135
+ submitDrivingLicense(image: string): Promise<APIResponse<string>>;
136
+ getInsuranceCannedUrl(extension: string): Promise<APIResponse<UserImage>>;
137
+ captureInsurance(fileKey: string): Promise<APIResponse<CaptureResult<InsuranceCaptureData>>>;
138
+ submitInsurance(coverage: CoverageData): Promise<APIResponse<InsuranceRecord>>;
139
+ getInsurances(): Promise<APIResponse<InsuranceRecord[]>>;
140
+ captureUserPhoto(fileKey: string): Promise<APIResponse<CaptureResult<UserPhotoCaptureData>>>;
141
+ deactivateUser(): Promise<APIResponse<boolean>>;
70
142
  private getBaseUrl;
71
143
  private getAuthHeaders;
72
144
  private getJsonHeaders;
73
145
  private getApiKeyHeader;
146
+ private requireValue;
74
147
  }
75
148
 
76
149
  declare class ConfigError extends Error {
@@ -84,4 +157,4 @@ declare class HttpError extends Error {
84
157
  constructor(status: number, message: string);
85
158
  }
86
159
 
87
- 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, HttpError, type UpdateImageData, type UpdateImageRequest, type UploadImageData, type UploadImageRequest, type UserImage };
160
+ export { type APIRequest, type APIResponse, AuthError, type CaptureResult, type CaptureType, ConfigError, type CoverageData, type Encounter, HCSettingsClient, HttpError, type IdentificationCaptureData, type InsuranceCaptureData, type InsuranceRecord, type PatientDashboard, type PatientRecord, type UserImage, type UserPhotoCaptureData, UserStatus };