@healthcloudai/hc-sdk 3.24.0 → 3.25.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/dist/index.cjs +113 -7
- package/dist/index.d.cts +846 -27
- package/dist/index.d.ts +846 -27
- package/dist/index.js +110 -7
- package/docs/clients/ProviderClient.md +7 -2
- package/docs/configuration.md +2 -2
- package/docs/docs-manifest.json +18 -3
- package/docs/examples/index.md +7 -2
- package/docs/index.md +7 -2
- package/docs/models/CheckInEncounterResponse.md +2 -0
- package/docs/models/ClaimEncounterResponse.md +20 -0
- package/docs/models/DiagnosisInput.md +20 -0
- package/docs/models/GetEncounterResponse.md +2 -0
- package/docs/models/Icd10Code.md +18 -0
- package/docs/models/Icd10SearchResponse.md +19 -0
- package/docs/models/ProviderEncounterQueueResponse.md +19 -0
- package/docs/models/ProviderEncounterRecord.md +2 -0
- package/docs/models/ProviderQueueEncounter.md +28 -0
- package/docs/models/ProviderQueuePatient.md +21 -0
- package/docs/models/SignEncounterResponse.md +18 -0
- package/docs/models/UpdateEncounterDiagnosesRequest.md +17 -0
- package/docs/models/UpdateEncounterDiagnosesResponse.md +17 -0
- package/docs/models/fieldagent.Encounter.md +2 -0
- package/docs/models/index.md +10 -0
- package/docs/models/patient.Encounter.md +2 -0
- package/docs/models/provider.Encounter.md +2 -0
- package/docs/operations/fieldagent.listEncounters.md +2 -0
- package/docs/operations/patient.checkEncounter.md +64 -64
- package/docs/operations/patient.checkInEncounter.md +2 -0
- package/docs/operations/patient.createEncounter.md +2 -0
- package/docs/operations/patient.getCheckinCheckin.md +2 -0
- package/docs/operations/patient.getCurrentCareSessionCareSessionsCurrent.md +2 -0
- package/docs/operations/patient.getEncounter.md +2 -0
- package/docs/operations/patient.getLatestEncounter.md +2 -0
- package/docs/operations/patient.getPatientSidebarPatientSidebar.md +2 -0
- package/docs/operations/patient.listEncounters.md +2 -0
- package/docs/operations/provider.claimEncounter.md +235 -0
- package/docs/operations/provider.getEncounter.md +12 -1
- package/docs/operations/provider.getEncounterQueue.md +148 -0
- package/docs/operations/provider.getPatientRecord.md +11 -0
- package/docs/operations/provider.listEncounters.md +24 -3
- package/docs/operations/provider.searchIcd10.md +128 -0
- package/docs/operations/provider.signEncounter.md +233 -0
- package/docs/operations/provider.updateEncounterClinicalNote.md +20 -0
- package/docs/operations/provider.updateEncounterDiagnoses.md +267 -0
- package/docs/operations/provider.updateEncounterStatus.md +20 -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);
|
|
@@ -3758,11 +3820,52 @@ var ProviderClient = class extends BaseServiceClient {
|
|
|
3758
3820
|
connect() {
|
|
3759
3821
|
return this.connectService();
|
|
3760
3822
|
}
|
|
3761
|
-
/**
|
|
3823
|
+
/**
|
|
3824
|
+
* List the caller's OWN encounters (never tenant-wide). Pass `open: true` for the provider's task list: encounters that
|
|
3825
|
+
* are not finished, cancelled or entered in error.
|
|
3826
|
+
*/
|
|
3762
3827
|
listEncounters(filters) {
|
|
3763
3828
|
return this.send("GET", "/encounters", { query: filters });
|
|
3764
3829
|
}
|
|
3765
|
-
/**
|
|
3830
|
+
/**
|
|
3831
|
+
* The queue (GET /encounters/queue): the newest 10 encounters in the tenant that no provider has taken, newest created
|
|
3832
|
+
* first, each with a minimal patient summary. Use the item's `fhir_id` with claimEncounter.
|
|
3833
|
+
*/
|
|
3834
|
+
getEncounterQueue() {
|
|
3835
|
+
return this.send("GET", "/encounters/queue", {});
|
|
3836
|
+
}
|
|
3837
|
+
/**
|
|
3838
|
+
* Take an encounter from the queue (POST /encounters/{id}/claim): assigns the caller, starts it (in-progress), adds the
|
|
3839
|
+
* patient to the caller's patient list and notifies the patient. Repeating the call as the same provider changes nothing
|
|
3840
|
+
* (`claimed: false`). Rejects with a 409 when another provider took it first, 403 when the caller's role or account may not
|
|
3841
|
+
* work the queue, and 404 when the encounter does not exist.
|
|
3842
|
+
*/
|
|
3843
|
+
claimEncounter(encounterId) {
|
|
3844
|
+
return this.send("POST", "/encounters/{encounter_id}/claim", { pathParams: { encounter_id: encounterId } });
|
|
3845
|
+
}
|
|
3846
|
+
/**
|
|
3847
|
+
* Replace an encounter's diagnoses (PUT /encounters/{id}/diagnoses): add, change or remove. Codes come from
|
|
3848
|
+
* searchIcd10; codes left out of the list are removed, and the display text always comes from the ICD-10 data. Only the
|
|
3849
|
+
* assigned provider (403 otherwise), and not once the encounter is signed (409).
|
|
3850
|
+
*/
|
|
3851
|
+
updateEncounterDiagnoses(encounterId, request) {
|
|
3852
|
+
return this.send("PUT", "/encounters/{encounter_id}/diagnoses", {
|
|
3853
|
+
pathParams: { encounter_id: encounterId },
|
|
3854
|
+
body: request
|
|
3855
|
+
});
|
|
3856
|
+
}
|
|
3857
|
+
/**
|
|
3858
|
+
* Sign and complete an encounter (POST /encounters/{id}/sign): finished, end time, signer and time recorded, patient
|
|
3859
|
+
* notified. The encounter is then locked (409 on later edits). Only the assigned provider.
|
|
3860
|
+
*/
|
|
3861
|
+
signEncounter(encounterId) {
|
|
3862
|
+
return this.send("POST", "/encounters/{encounter_id}/sign", { pathParams: { encounter_id: encounterId } });
|
|
3863
|
+
}
|
|
3864
|
+
/** Search the ICD-10-CM codes accepted on encounters (GET /icd10). `q` is a code prefix or description words. */
|
|
3865
|
+
searchIcd10(filters) {
|
|
3866
|
+
return this.send("GET", "/icd10", { query: filters });
|
|
3867
|
+
}
|
|
3868
|
+
/** Get one of the caller's own encounters with its patient demographic summary (404 until the caller holds it). */
|
|
3766
3869
|
getEncounter(encounterId) {
|
|
3767
3870
|
return this.send("GET", "/encounters/{encounter_id}", { pathParams: { encounter_id: encounterId } });
|
|
3768
3871
|
}
|
|
@@ -7116,7 +7219,7 @@ var HCSDK = class {
|
|
|
7116
7219
|
environment: config.environment,
|
|
7117
7220
|
tenantId: config.tenantId,
|
|
7118
7221
|
accessToken: config.accessToken,
|
|
7119
|
-
baseUrlOverrides: config.baseUrlOverrides,
|
|
7222
|
+
baseUrlOverrides: normalizeOverrides(config.baseUrlOverrides),
|
|
7120
7223
|
timeout: (_b = config.timeout) != null ? _b : DEFAULT_TIMEOUT_MS
|
|
7121
7224
|
};
|
|
7122
7225
|
this.http = new HttpClient(this.state);
|
|
@@ -7290,6 +7393,9 @@ var HCSDK_SWAGGER_OPERATION_COUNTS = {
|
|
|
7290
7393
|
assertTimeout,
|
|
7291
7394
|
isJsonRpcError,
|
|
7292
7395
|
isServiceName,
|
|
7396
|
+
joinServiceUrl,
|
|
7397
|
+
normalizeBaseUrl,
|
|
7398
|
+
normalizeOverrides,
|
|
7293
7399
|
resolveBaseUrl,
|
|
7294
7400
|
withTenantId
|
|
7295
7401
|
});
|