@healthcloudai/hc-sdk 3.23.0 → 3.24.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/dist/index.cjs +101 -5
- package/dist/index.d.cts +1107 -3
- package/dist/index.d.ts +1107 -3
- package/dist/index.js +98 -5
- package/docs/clients/ProviderClient.md +7 -0
- package/docs/configuration.md +2 -2
- package/docs/docs-manifest.json +26 -3
- package/docs/examples/index.md +7 -0
- package/docs/index.md +7 -0
- package/docs/models/CreateProviderPatientRequest.md +22 -0
- package/docs/models/LabOrder.md +35 -0
- package/docs/models/LabOrderDiagnosis.md +18 -0
- package/docs/models/LabOrderErrorResponse.md +21 -0
- package/docs/models/LabOrderItemRequest.md +17 -0
- package/docs/models/LabOrderProvider.md +20 -0
- package/docs/models/LabOrderRequisitionResponse.md +20 -0
- package/docs/models/LabOrderTest.md +19 -0
- package/docs/models/LabOrderUnsentItem.md +19 -0
- package/docs/models/ListLabOrdersResponse.md +18 -0
- package/docs/models/PlaceLabOrderRequest.md +27 -0
- package/docs/models/PlaceLabOrderResponse.md +20 -0
- package/docs/models/ProviderEncounterStatusCounts.md +21 -0
- package/docs/models/ProviderHomeSummaryResponse.md +19 -0
- package/docs/models/ProviderPatientListResponse.md +19 -0
- package/docs/models/ProviderPatientResponse.md +17 -0
- package/docs/models/index.md +16 -0
- package/docs/operations/provider.createPatient.md +155 -0
- package/docs/operations/provider.getHomeSummary.md +115 -0
- package/docs/operations/provider.getLabOrder.md +179 -0
- package/docs/operations/provider.getLabOrderRequisition.md +148 -0
- package/docs/operations/provider.listLabOrders.md +198 -0
- package/docs/operations/provider.listPatients.md +154 -0
- package/docs/operations/provider.placeLabOrder.md +384 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -68,6 +68,9 @@ __export(index_exports, {
|
|
|
68
68
|
assertTimeout: () => assertTimeout,
|
|
69
69
|
isJsonRpcError: () => isJsonRpcError,
|
|
70
70
|
isServiceName: () => isServiceName,
|
|
71
|
+
joinServiceUrl: () => joinServiceUrl,
|
|
72
|
+
normalizeBaseUrl: () => normalizeBaseUrl,
|
|
73
|
+
normalizeOverrides: () => normalizeOverrides,
|
|
71
74
|
resolveBaseUrl: () => resolveBaseUrl,
|
|
72
75
|
withTenantId: () => withTenantId
|
|
73
76
|
});
|
|
@@ -96,12 +99,67 @@ function isServiceName(value) {
|
|
|
96
99
|
return SERVICES.includes(value);
|
|
97
100
|
}
|
|
98
101
|
function resolveBaseUrl(environment, service) {
|
|
102
|
+
assertEnvironment(environment);
|
|
99
103
|
if (service === "ams") {
|
|
104
|
+
if (environment === "dev") return "https://dev-ams-services.health.cloud/api/ams";
|
|
100
105
|
const prefix = environment === "prod" ? "" : `${environment}-`;
|
|
101
106
|
return `https://${prefix}amsservices.health.cloud/api/ams`;
|
|
102
107
|
}
|
|
103
108
|
return `https://${environment}-api-${service}.health.cloud`;
|
|
104
109
|
}
|
|
110
|
+
function normalizeBaseUrl(value) {
|
|
111
|
+
const message = "Invalid service base URL: expected HTTPS (or literal loopback HTTP); no credentials, query or fragment";
|
|
112
|
+
try {
|
|
113
|
+
if (typeof value !== "string" || /[^\x21-\x7e]|[\\?#]/.test(value) || !/^https?:\/\//i.test(value)) {
|
|
114
|
+
throw new Error();
|
|
115
|
+
}
|
|
116
|
+
const authority = value.slice(value.indexOf("://") + 3).split("/")[0];
|
|
117
|
+
if (!authority || /[@%]/.test(authority) || authority.endsWith(":")) throw new Error();
|
|
118
|
+
const url = new URL(value);
|
|
119
|
+
const host = url.hostname;
|
|
120
|
+
const allowedScheme = url.protocol === "https:" || url.protocol === "http:" && (host === "127.0.0.1" || host === "[::1]");
|
|
121
|
+
if (!allowedScheme || !host || url.username || url.password || url.port && Number(url.port) < 1) {
|
|
122
|
+
throw new Error();
|
|
123
|
+
}
|
|
124
|
+
if (!host.startsWith("[") && (!/^[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/.test(host) || host.split(".").some(
|
|
125
|
+
(label) => !label || label.length > 63 || label.startsWith("-") || label.endsWith("-")
|
|
126
|
+
))) throw new Error();
|
|
127
|
+
const rawHost = authority.startsWith("[") ? authority.slice(0, authority.indexOf("]") + 1) : authority.split(":")[0];
|
|
128
|
+
if (!host.startsWith("[") && host !== rawHost.toLowerCase()) throw new Error();
|
|
129
|
+
const rawPath = value.slice(value.indexOf("://") + 3 + authority.length);
|
|
130
|
+
if (rawPath.includes("//") || /%(?![0-9a-f]{2})|%2f/i.test(rawPath)) throw new Error();
|
|
131
|
+
const decoded = decodePathBytes(rawPath);
|
|
132
|
+
if (hasControls(decoded) || /[\\?#%]/.test(decoded) || decoded.split("/").some((s) => s === "." || s === "..")) {
|
|
133
|
+
throw new Error();
|
|
134
|
+
}
|
|
135
|
+
return `${url.origin}${rawPath.replace(/\/+$/, "")}`;
|
|
136
|
+
} catch {
|
|
137
|
+
throw new Error(message);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function normalizeOverrides(values) {
|
|
141
|
+
if (values === void 0) return {};
|
|
142
|
+
if (values === null || typeof values !== "object" || Array.isArray(values)) throw new Error("Invalid service URL overrides");
|
|
143
|
+
const result = {};
|
|
144
|
+
for (const [service, value] of Object.entries(values)) {
|
|
145
|
+
if (!isServiceName(service)) throw new Error("Invalid service URL overrides: expected known service names");
|
|
146
|
+
result[service] = normalizeBaseUrl(value);
|
|
147
|
+
}
|
|
148
|
+
return result;
|
|
149
|
+
}
|
|
150
|
+
function joinServiceUrl(base, path) {
|
|
151
|
+
if (hasControls(path) || /[\\?#]/.test(path) || path.includes("://") || path.startsWith("//") || path.split("/").some((segment) => {
|
|
152
|
+
const decoded = decodePathBytes(segment);
|
|
153
|
+
return decoded === "." || decoded === "..";
|
|
154
|
+
})) throw new Error("Invalid service request path");
|
|
155
|
+
return `${base.replace(/\/+$/, "")}/${path.replace(/^\/+/, "")}`;
|
|
156
|
+
}
|
|
157
|
+
function hasControls(value) {
|
|
158
|
+
return Array.from(value).some((character) => character.charCodeAt(0) < 32 || character.charCodeAt(0) === 127);
|
|
159
|
+
}
|
|
160
|
+
function decodePathBytes(value) {
|
|
161
|
+
return value.replace(/%([0-9a-f]{2})/gi, (_, hex) => String.fromCharCode(parseInt(hex, 16)));
|
|
162
|
+
}
|
|
105
163
|
function assertTimeout(timeout, label = "timeout") {
|
|
106
164
|
if (typeof timeout !== "number" || !Number.isFinite(timeout) || timeout <= 0) {
|
|
107
165
|
throw new Error(`Invalid HealthCloud SDK ${label}: expected a positive number of milliseconds, got ${String(timeout)}`);
|
|
@@ -137,12 +195,13 @@ var SDKError = class extends Error {
|
|
|
137
195
|
var HttpClient = class {
|
|
138
196
|
constructor(state) {
|
|
139
197
|
this.state = state;
|
|
198
|
+
this.baseUrlOverrides = normalizeOverrides(state.baseUrlOverrides);
|
|
140
199
|
}
|
|
141
200
|
async request(service, method, path, options = {}) {
|
|
142
201
|
var _a, _b;
|
|
143
202
|
const url = this.buildUrl(service, path, options);
|
|
144
203
|
const headers = this.buildHeaders(options);
|
|
145
|
-
const init = { method, headers };
|
|
204
|
+
const init = { method, headers, redirect: "error" };
|
|
146
205
|
if (method !== "GET" && method !== "DELETE" && options.body !== void 0) {
|
|
147
206
|
init.body = this.serializeBody(options.body, headers);
|
|
148
207
|
}
|
|
@@ -159,6 +218,9 @@ var HttpClient = class {
|
|
|
159
218
|
let payload;
|
|
160
219
|
try {
|
|
161
220
|
response = await fetch(url, init);
|
|
221
|
+
if (response.redirected || response.status >= 300 && response.status < 400 || response.type === "opaqueredirect") {
|
|
222
|
+
throw new SDKError({ message: "Service redirects are not allowed", statusCode: response.status });
|
|
223
|
+
}
|
|
162
224
|
payload = await this.parseResponse(response);
|
|
163
225
|
} catch (error) {
|
|
164
226
|
if (didTimeout) {
|
|
@@ -172,7 +234,7 @@ var HttpClient = class {
|
|
|
172
234
|
throw error;
|
|
173
235
|
}
|
|
174
236
|
throw new SDKError({
|
|
175
|
-
message:
|
|
237
|
+
message: "Network request failed.",
|
|
176
238
|
statusCode: 0,
|
|
177
239
|
cause: error
|
|
178
240
|
});
|
|
@@ -208,8 +270,8 @@ var HttpClient = class {
|
|
|
208
270
|
buildUrl(service, path, options) {
|
|
209
271
|
var _a, _b, _c;
|
|
210
272
|
const normalizedPath = this.resolvePath(path, (_a = options.pathParams) != null ? _a : {});
|
|
211
|
-
const base = (_c = (_b = this.
|
|
212
|
-
const url = new URL(
|
|
273
|
+
const base = (_c = (_b = this.baseUrlOverrides) == null ? void 0 : _b[service]) != null ? _c : resolveBaseUrl(this.state.environment, service);
|
|
274
|
+
const url = new URL(joinServiceUrl(base, normalizedPath));
|
|
213
275
|
if (options.query) {
|
|
214
276
|
for (const [key, value] of Object.entries(options.query)) {
|
|
215
277
|
this.appendQuery(url, key, value);
|
|
@@ -3794,6 +3856,37 @@ var ProviderClient = class extends BaseServiceClient {
|
|
|
3794
3856
|
getAppointment(appointmentId) {
|
|
3795
3857
|
return this.send("GET", "/appointments/{appointment_id}", { pathParams: { appointment_id: appointmentId } });
|
|
3796
3858
|
}
|
|
3859
|
+
/**
|
|
3860
|
+
* List or search the calling practitioner's own patients (GET /patients), one page at a time. Never tenant-wide: only patients assigned to the caller. `q` matches the start of a given or
|
|
3861
|
+
* family name; pass the previous page's `next_page_token` as `page_token` to read on. `page_size` is 1-100 (default 20).
|
|
3862
|
+
*/
|
|
3863
|
+
listPatients(filters) {
|
|
3864
|
+
return this.send("GET", "/patients", { query: filters });
|
|
3865
|
+
}
|
|
3866
|
+
/** Create a patient assigned to the calling practitioner (POST /patients). Returns the patient's demographic summary. */
|
|
3867
|
+
createPatient(request) {
|
|
3868
|
+
return this.send("POST", "/patients", { body: request });
|
|
3869
|
+
}
|
|
3870
|
+
/** Counts for the home screen (GET /dashboard/summary): the caller's own patients and encounters by status. */
|
|
3871
|
+
getHomeSummary() {
|
|
3872
|
+
return this.send("GET", "/dashboard/summary", {});
|
|
3873
|
+
}
|
|
3874
|
+
/** Place a real Quest lab order for a patient (POST /patients/{patient_id}/lab-orders). Confirm the tests with the clinician first. */
|
|
3875
|
+
placeLabOrder(patientId, request) {
|
|
3876
|
+
return this.send("POST", "/patients/{patient_id}/lab-orders", { pathParams: { patient_id: patientId }, body: request });
|
|
3877
|
+
}
|
|
3878
|
+
/** List a patient's lab orders (GET /patients/{patient_id}/lab-orders), optionally by `status` (submitting, accepted or rejected). */
|
|
3879
|
+
listLabOrders(patientId, filters) {
|
|
3880
|
+
return this.send("GET", "/patients/{patient_id}/lab-orders", { pathParams: { patient_id: patientId }, query: filters });
|
|
3881
|
+
}
|
|
3882
|
+
/** Get one lab order (GET /patients/{patient_id}/lab-orders/{order_id}). */
|
|
3883
|
+
getLabOrder(patientId, orderId) {
|
|
3884
|
+
return this.send("GET", "/patients/{patient_id}/lab-orders/{order_id}", { pathParams: { patient_id: patientId, order_id: orderId } });
|
|
3885
|
+
}
|
|
3886
|
+
/** Get a lab order's Quest requisition PDF (GET /patients/{patient_id}/lab-orders/{order_id}/requisition). */
|
|
3887
|
+
getLabOrderRequisition(patientId, orderId) {
|
|
3888
|
+
return this.send("GET", "/patients/{patient_id}/lab-orders/{order_id}/requisition", { pathParams: { patient_id: patientId, order_id: orderId } });
|
|
3889
|
+
}
|
|
3797
3890
|
/** Get a patient's consolidated health record (provider tenant scope). */
|
|
3798
3891
|
getPatientRecord(patientId) {
|
|
3799
3892
|
return this.send("GET", "/patients/{patient_id}/record", { pathParams: { patient_id: patientId } });
|
|
@@ -7085,7 +7178,7 @@ var HCSDK = class {
|
|
|
7085
7178
|
environment: config.environment,
|
|
7086
7179
|
tenantId: config.tenantId,
|
|
7087
7180
|
accessToken: config.accessToken,
|
|
7088
|
-
baseUrlOverrides: config.baseUrlOverrides,
|
|
7181
|
+
baseUrlOverrides: normalizeOverrides(config.baseUrlOverrides),
|
|
7089
7182
|
timeout: (_b = config.timeout) != null ? _b : DEFAULT_TIMEOUT_MS
|
|
7090
7183
|
};
|
|
7091
7184
|
this.http = new HttpClient(this.state);
|
|
@@ -7259,6 +7352,9 @@ var HCSDK_SWAGGER_OPERATION_COUNTS = {
|
|
|
7259
7352
|
assertTimeout,
|
|
7260
7353
|
isJsonRpcError,
|
|
7261
7354
|
isServiceName,
|
|
7355
|
+
joinServiceUrl,
|
|
7356
|
+
normalizeBaseUrl,
|
|
7357
|
+
normalizeOverrides,
|
|
7262
7358
|
resolveBaseUrl,
|
|
7263
7359
|
withTenantId
|
|
7264
7360
|
});
|