@healthcloudai/hc-settings-connector 0.0.13 → 0.1.0
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 +280 -236
- package/dist/index.cjs +274 -100
- package/dist/index.d.cts +123 -57
- package/dist/index.d.ts +123 -57
- package/dist/index.js +280 -98
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
import { HCLoginClient } from '@healthcloudai/hc-login-connector';
|
|
2
|
-
import { HttpClient } from '@healthcloudai/hc-http';
|
|
2
|
+
import { HttpClient, APIError } from '@healthcloudai/hc-http';
|
|
3
|
+
export { APIError, ConfigError, HCServiceError, NetworkError, ValidationError, errorFromHttpStatus } from '@healthcloudai/hc-http';
|
|
3
4
|
|
|
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
5
|
interface APIRequest<T> {
|
|
14
6
|
Data: T;
|
|
15
7
|
}
|
|
16
8
|
interface APIResponse<T> {
|
|
17
|
-
Data: T;
|
|
9
|
+
Data: T | null;
|
|
18
10
|
IsOK: boolean;
|
|
19
|
-
ErrorMessage
|
|
11
|
+
ErrorMessage: string | null;
|
|
12
|
+
}
|
|
13
|
+
interface UserImage {
|
|
14
|
+
ImageURL: string | null;
|
|
15
|
+
FileName: string | null;
|
|
16
|
+
Extension: string | null;
|
|
20
17
|
}
|
|
21
|
-
interface
|
|
18
|
+
interface CoverageData {
|
|
22
19
|
InsurancePackageId: string;
|
|
23
20
|
MemberId: string;
|
|
24
21
|
FirstName: string;
|
|
@@ -26,62 +23,131 @@ interface CoverageRequest {
|
|
|
26
23
|
Sex: string;
|
|
27
24
|
Image: string;
|
|
28
25
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
FileID: string;
|
|
26
|
+
declare enum UserStatus {
|
|
27
|
+
INACTIVE = 0,
|
|
28
|
+
ACTIVE = 1,
|
|
29
|
+
SUSPENDED = -1
|
|
34
30
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
interface PatientRecord {
|
|
32
|
+
Status: UserStatus;
|
|
33
|
+
Sex: string | null;
|
|
34
|
+
GenderIdentity: string | null;
|
|
35
|
+
HasInsurance: boolean;
|
|
36
|
+
HasIDCard: boolean;
|
|
37
|
+
HasSelfie: boolean;
|
|
38
|
+
Flags: Record<string, string> | null;
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
interface Encounter {
|
|
41
|
+
FHIRID: string | null;
|
|
42
|
+
AthenaID: string | null;
|
|
43
|
+
Status: number;
|
|
44
|
+
Patient: PatientRecord | null;
|
|
45
|
+
EncounterClass: string | null;
|
|
46
|
+
EHR: string | null;
|
|
47
|
+
EHRType: string | null;
|
|
48
|
+
EHRVisitName: string | null;
|
|
49
|
+
EHRAppointmentID: string | null;
|
|
50
|
+
EHRProviderID: string | null;
|
|
51
|
+
EHRProviderName: string | null;
|
|
52
|
+
EHRDate: string | null;
|
|
53
|
+
EHRStatus: string | null;
|
|
54
|
+
EHRStage: string | null;
|
|
42
55
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
56
|
+
interface PatientDashboard {
|
|
57
|
+
Record: PatientRecord | null;
|
|
58
|
+
Encounters: Encounter[];
|
|
59
|
+
EHR: string | null;
|
|
60
|
+
PendingActions: string[];
|
|
61
|
+
}
|
|
62
|
+
type CaptureType = "healthinsurance" | "identification" | "userphoto";
|
|
63
|
+
interface InsuranceCaptureData {
|
|
64
|
+
FirstName: string | null;
|
|
65
|
+
LastName: string | null;
|
|
66
|
+
MemberId: string | null;
|
|
67
|
+
GroupNumber: string | null;
|
|
68
|
+
EffectiveDate: string | null;
|
|
69
|
+
RxBIN: string | null;
|
|
70
|
+
RxPCN: string | null;
|
|
71
|
+
RxGRP: string | null;
|
|
72
|
+
Carrier: string | null;
|
|
73
|
+
}
|
|
74
|
+
interface IdentificationCaptureData {
|
|
75
|
+
FirstName: string | null;
|
|
76
|
+
LastName: string | null;
|
|
77
|
+
StreetAddress: string | null;
|
|
78
|
+
City: string | null;
|
|
79
|
+
ZipCode: string | null;
|
|
80
|
+
State: string | null;
|
|
81
|
+
IssuedDate: string | null;
|
|
82
|
+
ExpiresDate: string | null;
|
|
83
|
+
Dob: string | null;
|
|
84
|
+
IDNumber: string | null;
|
|
85
|
+
}
|
|
86
|
+
interface UserPhotoCaptureData {
|
|
87
|
+
ImageKey: string | null;
|
|
88
|
+
}
|
|
89
|
+
interface CaptureResult<T> {
|
|
90
|
+
CapturedData: T | null;
|
|
91
|
+
IsCaptured: boolean;
|
|
92
|
+
InsurancePackages: object[] | null;
|
|
93
|
+
}
|
|
94
|
+
interface InsuranceRecord {
|
|
95
|
+
LastUpdatedBy: string | null;
|
|
96
|
+
IrcName: string | null;
|
|
97
|
+
LastUpdated: string | null;
|
|
98
|
+
RelationshipToInsured: string | null;
|
|
99
|
+
InsurancePolicyHolder: string | null;
|
|
100
|
+
EligibilityStatus: string | null;
|
|
101
|
+
InsurancePolicyHolderCountryIso3166: string | null;
|
|
102
|
+
ConfidentialityCode: string | null;
|
|
103
|
+
Created: string | null;
|
|
104
|
+
InsuranceId: string | null;
|
|
105
|
+
InsurancePolicyHolderSex: string | null;
|
|
106
|
+
InsurancePlanName: string | null;
|
|
107
|
+
InsuranceType: string | null;
|
|
108
|
+
InsurancePolicyHolderCountryCode: string | null;
|
|
109
|
+
InsurancePackageId: number | null;
|
|
110
|
+
InsuredEntityTypeId: number | null;
|
|
111
|
+
InsurancePolicyHolderFirstName: string | null;
|
|
112
|
+
SequenceNumber: number | null;
|
|
113
|
+
IrcId: number | null;
|
|
114
|
+
CreatedBy: string | null;
|
|
115
|
+
RelationshipToInsuredId: number | null;
|
|
116
|
+
InsurancePolicyHolderLastName: string | null;
|
|
117
|
+
/**
|
|
118
|
+
* Internal-only fields returned in backend models.
|
|
119
|
+
*/
|
|
120
|
+
MemberId?: string | null;
|
|
121
|
+
Image?: string | null;
|
|
47
122
|
}
|
|
48
|
-
type DrivingLicenseRequest = APIRequest<DrivingLicenseData>;
|
|
49
|
-
type DrivingLicenseResponse = APIResponse<string>;
|
|
50
|
-
type HCUserImage = UserImage;
|
|
51
123
|
|
|
52
124
|
declare class HCSettingsClient {
|
|
53
|
-
private
|
|
54
|
-
private
|
|
125
|
+
private readonly httpClient;
|
|
126
|
+
private readonly loginClient;
|
|
55
127
|
private apiKeyHeaderName?;
|
|
56
128
|
private apiKeyValue?;
|
|
57
|
-
constructor(httpClient: HttpClient,
|
|
129
|
+
constructor(httpClient: HttpClient, loginClient: HCLoginClient);
|
|
58
130
|
setApiKey(headerName: string, value: string): void;
|
|
59
|
-
getDashboard(): Promise<
|
|
60
|
-
getUserImageCannedUrl(extension: string): Promise<UserImage
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
captureDrivingLicense(fileKey: string): Promise<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
131
|
+
getDashboard(): Promise<APIResponse<PatientDashboard>>;
|
|
132
|
+
getUserImageCannedUrl(extension: string): Promise<APIResponse<UserImage>>;
|
|
133
|
+
updateUserImage(fileName: string): Promise<APIResponse<boolean>>;
|
|
134
|
+
getDrivingLicenseCannedUrl(extension: string): Promise<APIResponse<UserImage>>;
|
|
135
|
+
captureDrivingLicense(fileKey: string): Promise<APIResponse<CaptureResult<IdentificationCaptureData>>>;
|
|
136
|
+
submitDrivingLicense(image: string): Promise<APIResponse<string>>;
|
|
137
|
+
getInsuranceCannedUrl(extension: string): Promise<APIResponse<UserImage>>;
|
|
138
|
+
captureInsurance(fileKey: string): Promise<APIResponse<CaptureResult<InsuranceCaptureData>>>;
|
|
139
|
+
submitInsurance(coverage: CoverageData): Promise<APIResponse<InsuranceRecord>>;
|
|
140
|
+
getInsurances(): Promise<APIResponse<InsuranceRecord[]>>;
|
|
141
|
+
captureUserPhoto(fileKey: string): Promise<APIResponse<CaptureResult<UserPhotoCaptureData>>>;
|
|
142
|
+
deactivateUser(): Promise<APIResponse<boolean>>;
|
|
143
|
+
protected execute<T>(operation: string, request: () => Promise<APIResponse<T>>): Promise<APIResponse<T>>;
|
|
144
|
+
protected mapBackendError(operation: string, response: APIResponse<unknown>): APIError;
|
|
145
|
+
private isApiResponse;
|
|
70
146
|
private getBaseUrl;
|
|
71
147
|
private getAuthHeaders;
|
|
72
148
|
private getJsonHeaders;
|
|
73
149
|
private getApiKeyHeader;
|
|
150
|
+
private requireValue;
|
|
74
151
|
}
|
|
75
152
|
|
|
76
|
-
|
|
77
|
-
constructor(message: string);
|
|
78
|
-
}
|
|
79
|
-
declare class AuthError extends Error {
|
|
80
|
-
constructor(message: string);
|
|
81
|
-
}
|
|
82
|
-
declare class HttpError extends Error {
|
|
83
|
-
status: number;
|
|
84
|
-
constructor(status: number, message: string);
|
|
85
|
-
}
|
|
86
|
-
|
|
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 };
|
|
153
|
+
export { type APIRequest, type APIResponse, 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,164 +1,314 @@
|
|
|
1
|
-
// src/errors.ts
|
|
2
|
-
var ConfigError = class extends Error {
|
|
3
|
-
constructor(message) {
|
|
4
|
-
super(message);
|
|
5
|
-
this.name = "ConfigError";
|
|
6
|
-
}
|
|
7
|
-
};
|
|
8
|
-
var AuthError = class extends Error {
|
|
9
|
-
constructor(message) {
|
|
10
|
-
super(message);
|
|
11
|
-
this.name = "AuthError";
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
var HttpError = class extends Error {
|
|
15
|
-
constructor(status, message) {
|
|
16
|
-
super(message);
|
|
17
|
-
this.name = "HttpError";
|
|
18
|
-
this.status = status;
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
|
|
22
1
|
// src/client.ts
|
|
2
|
+
import {
|
|
3
|
+
APIError,
|
|
4
|
+
ConfigError,
|
|
5
|
+
HCServiceError,
|
|
6
|
+
ValidationError
|
|
7
|
+
} from "@healthcloudai/hc-http";
|
|
23
8
|
var HCSettingsClient = class {
|
|
24
|
-
constructor(httpClient,
|
|
25
|
-
this.
|
|
26
|
-
this.
|
|
9
|
+
constructor(httpClient, loginClient) {
|
|
10
|
+
this.httpClient = httpClient;
|
|
11
|
+
this.loginClient = loginClient;
|
|
27
12
|
}
|
|
28
13
|
setApiKey(headerName, value) {
|
|
29
14
|
const trimmedHeaderName = headerName == null ? void 0 : headerName.trim();
|
|
30
15
|
const trimmedValue = value == null ? void 0 : value.trim();
|
|
31
16
|
if (!trimmedHeaderName) {
|
|
32
|
-
throw new ConfigError(
|
|
17
|
+
throw new ConfigError(
|
|
18
|
+
"API key header name is required."
|
|
19
|
+
);
|
|
33
20
|
}
|
|
34
21
|
if (!trimmedValue) {
|
|
35
|
-
throw new ConfigError(
|
|
22
|
+
throw new ConfigError(
|
|
23
|
+
"API key value is required."
|
|
24
|
+
);
|
|
36
25
|
}
|
|
37
26
|
this.apiKeyHeaderName = trimmedHeaderName;
|
|
38
27
|
this.apiKeyValue = trimmedValue;
|
|
39
28
|
}
|
|
29
|
+
// ===========================================================================
|
|
30
|
+
// Dashboard
|
|
31
|
+
// ===========================================================================
|
|
40
32
|
async getDashboard() {
|
|
41
|
-
return this.
|
|
42
|
-
|
|
43
|
-
this.
|
|
33
|
+
return this.execute(
|
|
34
|
+
"getDashboard",
|
|
35
|
+
() => this.httpClient.get(
|
|
36
|
+
`${this.getBaseUrl()}/api/patient/dashboard`,
|
|
37
|
+
this.getAuthHeaders()
|
|
38
|
+
)
|
|
44
39
|
);
|
|
45
40
|
}
|
|
41
|
+
// ===========================================================================
|
|
42
|
+
// User image
|
|
43
|
+
// ===========================================================================
|
|
46
44
|
async getUserImageCannedUrl(extension) {
|
|
47
|
-
const
|
|
45
|
+
const resolvedExtension = this.requireValue(
|
|
46
|
+
extension,
|
|
47
|
+
"extension"
|
|
48
|
+
);
|
|
49
|
+
const requestPayload = {
|
|
48
50
|
Data: {
|
|
49
|
-
Extension:
|
|
51
|
+
Extension: resolvedExtension
|
|
50
52
|
}
|
|
51
53
|
};
|
|
52
|
-
return this.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
return this.execute(
|
|
55
|
+
"getUserImageCannedUrl",
|
|
56
|
+
() => this.httpClient.put(
|
|
57
|
+
`${this.getBaseUrl()}/api/patient/image/cannedurl`,
|
|
58
|
+
requestPayload,
|
|
59
|
+
this.getJsonHeaders()
|
|
60
|
+
)
|
|
56
61
|
);
|
|
57
62
|
}
|
|
58
|
-
async
|
|
59
|
-
const
|
|
63
|
+
async updateUserImage(fileName) {
|
|
64
|
+
const resolvedFileName = this.requireValue(
|
|
65
|
+
fileName,
|
|
66
|
+
"fileName"
|
|
67
|
+
);
|
|
68
|
+
const requestPayload = {
|
|
60
69
|
Data: {
|
|
61
|
-
|
|
70
|
+
FileName: resolvedFileName
|
|
62
71
|
}
|
|
63
72
|
};
|
|
64
|
-
return this.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
73
|
+
return this.execute(
|
|
74
|
+
"updateUserImage",
|
|
75
|
+
() => this.httpClient.put(
|
|
76
|
+
`${this.getBaseUrl()}/api/patient/image/url`,
|
|
77
|
+
requestPayload,
|
|
78
|
+
this.getJsonHeaders()
|
|
79
|
+
)
|
|
68
80
|
);
|
|
69
81
|
}
|
|
70
|
-
|
|
71
|
-
|
|
82
|
+
// ===========================================================================
|
|
83
|
+
// Identification
|
|
84
|
+
// ===========================================================================
|
|
85
|
+
async getDrivingLicenseCannedUrl(extension) {
|
|
86
|
+
const resolvedExtension = this.requireValue(
|
|
87
|
+
extension,
|
|
88
|
+
"extension"
|
|
89
|
+
);
|
|
90
|
+
const requestPayload = {
|
|
72
91
|
Data: {
|
|
73
|
-
Extension:
|
|
92
|
+
Extension: resolvedExtension
|
|
74
93
|
}
|
|
75
94
|
};
|
|
76
|
-
return this.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
95
|
+
return this.execute(
|
|
96
|
+
"getDrivingLicenseCannedUrl",
|
|
97
|
+
() => this.httpClient.put(
|
|
98
|
+
`${this.getBaseUrl()}/api/patient/id/cannedurl`,
|
|
99
|
+
requestPayload,
|
|
100
|
+
this.getJsonHeaders()
|
|
101
|
+
)
|
|
80
102
|
);
|
|
81
103
|
}
|
|
82
104
|
async captureDrivingLicense(fileKey) {
|
|
83
|
-
const
|
|
105
|
+
const resolvedFileKey = this.requireValue(
|
|
106
|
+
fileKey,
|
|
107
|
+
"fileKey"
|
|
108
|
+
);
|
|
109
|
+
const requestPayload = {
|
|
84
110
|
Data: {
|
|
85
111
|
Type: "identification",
|
|
86
|
-
FileID:
|
|
112
|
+
FileID: resolvedFileKey
|
|
87
113
|
}
|
|
88
114
|
};
|
|
89
|
-
return this.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
115
|
+
return this.execute(
|
|
116
|
+
"captureDrivingLicense",
|
|
117
|
+
() => this.httpClient.post(
|
|
118
|
+
`${this.getBaseUrl()}/api/patient/capture`,
|
|
119
|
+
requestPayload,
|
|
120
|
+
this.getJsonHeaders()
|
|
121
|
+
)
|
|
93
122
|
);
|
|
94
123
|
}
|
|
95
|
-
async
|
|
96
|
-
const
|
|
124
|
+
async submitDrivingLicense(image) {
|
|
125
|
+
const resolvedImage = this.requireValue(
|
|
126
|
+
image,
|
|
127
|
+
"image"
|
|
128
|
+
);
|
|
129
|
+
const requestPayload = {
|
|
97
130
|
Data: {
|
|
98
|
-
|
|
99
|
-
FileID: fileKey
|
|
131
|
+
Image: resolvedImage
|
|
100
132
|
}
|
|
101
133
|
};
|
|
102
|
-
return this.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
134
|
+
return this.execute(
|
|
135
|
+
"submitDrivingLicense",
|
|
136
|
+
() => this.httpClient.put(
|
|
137
|
+
`${this.getBaseUrl()}/api/ehr/patient/drivinglicense`,
|
|
138
|
+
requestPayload,
|
|
139
|
+
this.getJsonHeaders()
|
|
140
|
+
)
|
|
106
141
|
);
|
|
107
142
|
}
|
|
108
|
-
|
|
143
|
+
// ===========================================================================
|
|
144
|
+
// Insurance
|
|
145
|
+
// ===========================================================================
|
|
146
|
+
async getInsuranceCannedUrl(extension) {
|
|
147
|
+
const resolvedExtension = this.requireValue(
|
|
148
|
+
extension,
|
|
149
|
+
"extension"
|
|
150
|
+
);
|
|
109
151
|
const requestPayload = {
|
|
110
|
-
Data:
|
|
152
|
+
Data: {
|
|
153
|
+
Extension: resolvedExtension
|
|
154
|
+
}
|
|
111
155
|
};
|
|
112
|
-
return this.
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
156
|
+
return this.execute(
|
|
157
|
+
"getInsuranceCannedUrl",
|
|
158
|
+
() => this.httpClient.put(
|
|
159
|
+
`${this.getBaseUrl()}/api/patient/insurance/cannedurl`,
|
|
160
|
+
requestPayload,
|
|
161
|
+
this.getJsonHeaders()
|
|
162
|
+
)
|
|
116
163
|
);
|
|
117
164
|
}
|
|
118
|
-
async
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
165
|
+
async captureInsurance(fileKey) {
|
|
166
|
+
const resolvedFileKey = this.requireValue(
|
|
167
|
+
fileKey,
|
|
168
|
+
"fileKey"
|
|
169
|
+
);
|
|
170
|
+
const requestPayload = {
|
|
171
|
+
Data: {
|
|
172
|
+
Type: "healthinsurance",
|
|
173
|
+
FileID: resolvedFileKey
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
return this.execute(
|
|
177
|
+
"captureInsurance",
|
|
178
|
+
() => this.httpClient.post(
|
|
179
|
+
`${this.getBaseUrl()}/api/patient/capture`,
|
|
180
|
+
requestPayload,
|
|
181
|
+
this.getJsonHeaders()
|
|
182
|
+
)
|
|
122
183
|
);
|
|
123
184
|
}
|
|
124
|
-
async
|
|
185
|
+
async submitInsurance(coverage) {
|
|
186
|
+
if (!coverage) {
|
|
187
|
+
throw new ValidationError({
|
|
188
|
+
message: "Insurance coverage data is required.",
|
|
189
|
+
code: "INVALID_INPUT"
|
|
190
|
+
});
|
|
191
|
+
}
|
|
125
192
|
const requestPayload = {
|
|
126
|
-
Data:
|
|
193
|
+
Data: coverage
|
|
127
194
|
};
|
|
128
|
-
return this.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
195
|
+
return this.execute(
|
|
196
|
+
"submitInsurance",
|
|
197
|
+
() => this.httpClient.put(
|
|
198
|
+
`${this.getBaseUrl()}/api/patient/coverage`,
|
|
199
|
+
requestPayload,
|
|
200
|
+
this.getJsonHeaders()
|
|
201
|
+
)
|
|
132
202
|
);
|
|
133
203
|
}
|
|
134
|
-
async
|
|
135
|
-
|
|
204
|
+
async getInsurances() {
|
|
205
|
+
return this.execute(
|
|
206
|
+
"getInsurances",
|
|
207
|
+
() => this.httpClient.get(
|
|
208
|
+
`${this.getBaseUrl()}/api/ehr/patient/insurances`,
|
|
209
|
+
this.getAuthHeaders()
|
|
210
|
+
)
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
// ===========================================================================
|
|
214
|
+
// User photo capture
|
|
215
|
+
// ===========================================================================
|
|
216
|
+
async captureUserPhoto(fileKey) {
|
|
217
|
+
const resolvedFileKey = this.requireValue(
|
|
218
|
+
fileKey,
|
|
219
|
+
"fileKey"
|
|
220
|
+
);
|
|
221
|
+
const requestPayload = {
|
|
136
222
|
Data: {
|
|
137
|
-
|
|
223
|
+
Type: "userphoto",
|
|
224
|
+
FileID: resolvedFileKey
|
|
138
225
|
}
|
|
139
226
|
};
|
|
140
|
-
return this.
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
227
|
+
return this.execute(
|
|
228
|
+
"captureUserPhoto",
|
|
229
|
+
() => this.httpClient.post(
|
|
230
|
+
`${this.getBaseUrl()}/api/patient/capture`,
|
|
231
|
+
requestPayload,
|
|
232
|
+
this.getJsonHeaders()
|
|
233
|
+
)
|
|
144
234
|
);
|
|
145
235
|
}
|
|
236
|
+
// ===========================================================================
|
|
237
|
+
// Account
|
|
238
|
+
// ===========================================================================
|
|
146
239
|
async deactivateUser() {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
240
|
+
return this.execute(
|
|
241
|
+
"deactivateUser",
|
|
242
|
+
() => this.httpClient.put(
|
|
243
|
+
`${this.getBaseUrl()}/api/patient/deactivate`,
|
|
244
|
+
void 0,
|
|
245
|
+
this.getJsonHeaders()
|
|
246
|
+
)
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
// ===========================================================================
|
|
250
|
+
// Helpers
|
|
251
|
+
// ===========================================================================
|
|
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
|
|
154
297
|
);
|
|
155
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
|
+
}
|
|
156
306
|
getBaseUrl() {
|
|
157
|
-
return this.
|
|
307
|
+
return this.loginClient.getBaseUrl();
|
|
158
308
|
}
|
|
159
309
|
getAuthHeaders() {
|
|
160
310
|
return {
|
|
161
|
-
...this.
|
|
311
|
+
...this.loginClient.getAuthHeader(),
|
|
162
312
|
...this.getApiKeyHeader()
|
|
163
313
|
};
|
|
164
314
|
}
|
|
@@ -176,10 +326,42 @@ var HCSettingsClient = class {
|
|
|
176
326
|
[this.apiKeyHeaderName]: this.apiKeyValue
|
|
177
327
|
};
|
|
178
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;
|
|
338
|
+
}
|
|
179
339
|
};
|
|
340
|
+
|
|
341
|
+
// src/errors.ts
|
|
342
|
+
import {
|
|
343
|
+
APIError as APIError2,
|
|
344
|
+
ConfigError as ConfigError2,
|
|
345
|
+
HCServiceError as HCServiceError2,
|
|
346
|
+
NetworkError,
|
|
347
|
+
ValidationError as ValidationError2,
|
|
348
|
+
errorFromHttpStatus
|
|
349
|
+
} from "@healthcloudai/hc-http";
|
|
350
|
+
|
|
351
|
+
// src/types.ts
|
|
352
|
+
var UserStatus = /* @__PURE__ */ ((UserStatus2) => {
|
|
353
|
+
UserStatus2[UserStatus2["INACTIVE"] = 0] = "INACTIVE";
|
|
354
|
+
UserStatus2[UserStatus2["ACTIVE"] = 1] = "ACTIVE";
|
|
355
|
+
UserStatus2[UserStatus2["SUSPENDED"] = -1] = "SUSPENDED";
|
|
356
|
+
return UserStatus2;
|
|
357
|
+
})(UserStatus || {});
|
|
180
358
|
export {
|
|
181
|
-
|
|
182
|
-
ConfigError,
|
|
359
|
+
APIError2 as APIError,
|
|
360
|
+
ConfigError2 as ConfigError,
|
|
361
|
+
HCServiceError2 as HCServiceError,
|
|
183
362
|
HCSettingsClient,
|
|
184
|
-
|
|
363
|
+
NetworkError,
|
|
364
|
+
UserStatus,
|
|
365
|
+
ValidationError2 as ValidationError,
|
|
366
|
+
errorFromHttpStatus
|
|
185
367
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@healthcloudai/hc-settings-connector",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
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.0
|
|
39
|
+
"@healthcloudai/hc-login-connector": "^0.2.0",
|
|
40
|
+
"@healthcloudai/hc-http": "^0.1.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"react-native": ">=0.70.0"
|