@healthcloudai/hc-sdk 0.2.0 → 0.4.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 +343 -154
- package/dist/index.cjs +154 -50
- package/dist/index.d.cts +823 -406
- package/dist/index.d.ts +823 -406
- package/dist/index.js +152 -49
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8,7 +8,9 @@ var SERVICES = [
|
|
|
8
8
|
"appointments",
|
|
9
9
|
"rppg",
|
|
10
10
|
"session",
|
|
11
|
-
"telehealth"
|
|
11
|
+
"telehealth",
|
|
12
|
+
"fieldagent",
|
|
13
|
+
"mcp"
|
|
12
14
|
];
|
|
13
15
|
function isServiceName(value) {
|
|
14
16
|
return SERVICES.includes(value);
|
|
@@ -22,6 +24,15 @@ function assertEnvironment(environment) {
|
|
|
22
24
|
throw new Error(`Unsupported HealthCloud environment: "${environment}"`);
|
|
23
25
|
}
|
|
24
26
|
}
|
|
27
|
+
function withTenantId(request, tenantId) {
|
|
28
|
+
if (!tenantId) {
|
|
29
|
+
return request;
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
...request,
|
|
33
|
+
tenant_id: tenantId
|
|
34
|
+
};
|
|
35
|
+
}
|
|
25
36
|
|
|
26
37
|
// src/errors/SDKError.ts
|
|
27
38
|
var SDKError = class extends Error {
|
|
@@ -169,12 +180,11 @@ var HttpClient = class {
|
|
|
169
180
|
return response.statusText || `HealthCloud API request failed with HTTP ${response.status}.`;
|
|
170
181
|
}
|
|
171
182
|
readMessage(payload) {
|
|
172
|
-
if (typeof payload !== "object" || payload === null) {
|
|
183
|
+
if (typeof payload !== "object" || payload === null || Array.isArray(payload)) {
|
|
173
184
|
return void 0;
|
|
174
185
|
}
|
|
175
|
-
const record = payload;
|
|
176
186
|
for (const key of ["message", "error", "ErrorMessage", "Message", "detail"]) {
|
|
177
|
-
const value =
|
|
187
|
+
const value = payload[key];
|
|
178
188
|
if (typeof value === "string" && value.trim()) {
|
|
179
189
|
return value;
|
|
180
190
|
}
|
|
@@ -195,7 +205,9 @@ var BaseServiceClient = class {
|
|
|
195
205
|
}
|
|
196
206
|
/**
|
|
197
207
|
* Low-level escape hatch — allows consumers to call any path on this service
|
|
198
|
-
* without waiting for a typed SDK method to be added.
|
|
208
|
+
* without waiting for a typed SDK method to be added. The response shape is
|
|
209
|
+
* intentionally generic since this targets undocumented/future paths; the
|
|
210
|
+
* caller must supply `TResponse` once the path's contract is known.
|
|
199
211
|
*/
|
|
200
212
|
request(method, path, options = {}) {
|
|
201
213
|
return this.send(method, path, options);
|
|
@@ -227,62 +239,30 @@ var AuthClient = class extends BaseServiceClient {
|
|
|
227
239
|
}
|
|
228
240
|
async register(request) {
|
|
229
241
|
return this.send("POST", "/auth/register", {
|
|
230
|
-
body: this.
|
|
242
|
+
body: withTenantId(request, this.getTenantId()),
|
|
231
243
|
auth: false
|
|
232
244
|
});
|
|
233
245
|
}
|
|
234
246
|
async login(request) {
|
|
235
247
|
const response = await this.send("POST", "/auth/login", {
|
|
236
|
-
body: this.
|
|
248
|
+
body: withTenantId(request, this.getTenantId()),
|
|
237
249
|
auth: false
|
|
238
250
|
});
|
|
239
|
-
|
|
240
|
-
if (!accessToken) {
|
|
251
|
+
if (!response.access_token) {
|
|
241
252
|
throw new SDKError({
|
|
242
253
|
message: "Login response did not include an access token.",
|
|
243
|
-
statusCode: 0
|
|
244
|
-
response
|
|
254
|
+
statusCode: 0
|
|
245
255
|
});
|
|
246
256
|
}
|
|
247
|
-
this.setAccessToken(
|
|
257
|
+
this.setAccessToken(response.access_token);
|
|
248
258
|
return response;
|
|
249
259
|
}
|
|
250
260
|
async verifyEmail(request) {
|
|
251
261
|
return this.send("POST", "/auth/verify-email", {
|
|
252
|
-
body: this.
|
|
262
|
+
body: withTenantId(request, this.getTenantId()),
|
|
253
263
|
auth: false
|
|
254
264
|
});
|
|
255
265
|
}
|
|
256
|
-
withTenantId(request) {
|
|
257
|
-
const tenantId = this.getTenantId();
|
|
258
|
-
if (!tenantId || request["tenant_id"]) {
|
|
259
|
-
return request;
|
|
260
|
-
}
|
|
261
|
-
return {
|
|
262
|
-
tenant_id: tenantId,
|
|
263
|
-
...request
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
extractAccessToken(response) {
|
|
267
|
-
if (typeof response !== "object" || response === null) {
|
|
268
|
-
return void 0;
|
|
269
|
-
}
|
|
270
|
-
const record = response;
|
|
271
|
-
for (const key of ["token", "access_token", "accessToken", "AccessToken", "idToken", "IDToken"]) {
|
|
272
|
-
const value = record[key];
|
|
273
|
-
if (typeof value === "string" && value.trim()) {
|
|
274
|
-
return value;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
for (const key of ["data", "Data", "result", "Result"]) {
|
|
278
|
-
const nested = record[key];
|
|
279
|
-
const token = this.extractAccessToken(nested);
|
|
280
|
-
if (token) {
|
|
281
|
-
return token;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
return void 0;
|
|
285
|
-
}
|
|
286
266
|
};
|
|
287
267
|
|
|
288
268
|
// src/clients/DiagnosticsClient.ts
|
|
@@ -299,10 +279,10 @@ var DiagnosticsClient = class extends BaseServiceClient {
|
|
|
299
279
|
body: request
|
|
300
280
|
});
|
|
301
281
|
}
|
|
302
|
-
|
|
282
|
+
// No documented query params for this endpoint — see curl reference.
|
|
283
|
+
list(patientId) {
|
|
303
284
|
return this.send("GET", "/patients/{patient_id}/diagnostics", {
|
|
304
|
-
pathParams: { patient_id: patientId }
|
|
305
|
-
query
|
|
285
|
+
pathParams: { patient_id: patientId }
|
|
306
286
|
});
|
|
307
287
|
}
|
|
308
288
|
};
|
|
@@ -317,6 +297,114 @@ var EhrClient = class extends BaseServiceClient {
|
|
|
317
297
|
}
|
|
318
298
|
};
|
|
319
299
|
|
|
300
|
+
// src/clients/FieldAgentClient.ts
|
|
301
|
+
var FieldAgentClient = class extends BaseServiceClient {
|
|
302
|
+
constructor(http, setAccessToken, getTenantId) {
|
|
303
|
+
super(http, "fieldagent");
|
|
304
|
+
this.setAccessToken = setAccessToken;
|
|
305
|
+
this.getTenantId = getTenantId;
|
|
306
|
+
}
|
|
307
|
+
connect() {
|
|
308
|
+
return this.connectService();
|
|
309
|
+
}
|
|
310
|
+
register(request) {
|
|
311
|
+
return this.send("POST", "/auth/register", {
|
|
312
|
+
body: withTenantId(request, this.getTenantId()),
|
|
313
|
+
auth: false
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
resetPassword(request) {
|
|
317
|
+
return this.send("POST", "/auth/reset-password", {
|
|
318
|
+
body: withTenantId(request, this.getTenantId()),
|
|
319
|
+
auth: false
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
async login(request) {
|
|
323
|
+
const response = await this.send("POST", "/auth/login", {
|
|
324
|
+
body: withTenantId(request, this.getTenantId()),
|
|
325
|
+
auth: false
|
|
326
|
+
});
|
|
327
|
+
if (!response.access_token) {
|
|
328
|
+
throw new SDKError({
|
|
329
|
+
message: "Login response did not include an access token.",
|
|
330
|
+
statusCode: 0
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
this.setAccessToken(response.access_token);
|
|
334
|
+
return response;
|
|
335
|
+
}
|
|
336
|
+
verifyEmail(request) {
|
|
337
|
+
return this.send("POST", "/auth/verify-email", {
|
|
338
|
+
body: withTenantId(request, this.getTenantId()),
|
|
339
|
+
auth: false
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
verifySms(request) {
|
|
343
|
+
return this.send("POST", "/auth/verify-sms", {
|
|
344
|
+
body: withTenantId(request, this.getTenantId()),
|
|
345
|
+
auth: false
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
getAgent(agentSub) {
|
|
349
|
+
return this.send("GET", "/agents/{sub}", {
|
|
350
|
+
pathParams: { sub: agentSub }
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
updateAgent(agentSub, request) {
|
|
354
|
+
return this.send("PATCH", "/agents/{sub}", {
|
|
355
|
+
pathParams: { sub: agentSub },
|
|
356
|
+
body: request
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
getDashboard(agentSub, query) {
|
|
360
|
+
return this.send("GET", "/agents/{sub}/dashboard", {
|
|
361
|
+
pathParams: { sub: agentSub },
|
|
362
|
+
query
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
getPhotoUploadUrl(agentSub) {
|
|
366
|
+
return this.send("GET", "/agents/{sub}/photo/upload-url", {
|
|
367
|
+
pathParams: { sub: agentSub }
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
uploadPhoto(agentSub, request) {
|
|
371
|
+
return this.send("POST", "/agents/{sub}/photo", {
|
|
372
|
+
pathParams: { sub: agentSub },
|
|
373
|
+
body: request
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
getPhoto(agentSub, query) {
|
|
377
|
+
return this.send("GET", "/agents/{sub}/photo", {
|
|
378
|
+
pathParams: { sub: agentSub },
|
|
379
|
+
query
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
listPatients(query) {
|
|
383
|
+
return this.send("GET", "/patients", { query });
|
|
384
|
+
}
|
|
385
|
+
listEncounters(query) {
|
|
386
|
+
return this.send("GET", "/encounters", { query });
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
// src/clients/MCPClient.ts
|
|
391
|
+
var MCPClient = class extends BaseServiceClient {
|
|
392
|
+
constructor(http) {
|
|
393
|
+
super(http, "mcp");
|
|
394
|
+
}
|
|
395
|
+
connect() {
|
|
396
|
+
return this.connectService();
|
|
397
|
+
}
|
|
398
|
+
/** Calls one of the 14 Patient API tools via `POST /patient`. */
|
|
399
|
+
patient(request) {
|
|
400
|
+
return this.send("POST", "/patient", { body: request });
|
|
401
|
+
}
|
|
402
|
+
/** Calls one of the 8 Field Agent API tools via `POST /fieldagent`. */
|
|
403
|
+
fieldAgent(request) {
|
|
404
|
+
return this.send("POST", "/fieldagent", { body: request });
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
|
|
320
408
|
// src/clients/PatientClient.ts
|
|
321
409
|
var PatientClient = class extends BaseServiceClient {
|
|
322
410
|
constructor(http) {
|
|
@@ -354,6 +442,11 @@ var PatientClient = class extends BaseServiceClient {
|
|
|
354
442
|
pathParams: { id: patientId }
|
|
355
443
|
});
|
|
356
444
|
}
|
|
445
|
+
getDashboard(patientId) {
|
|
446
|
+
return this.send("GET", "/patients/{id}/dashboard", {
|
|
447
|
+
pathParams: { id: patientId }
|
|
448
|
+
});
|
|
449
|
+
}
|
|
357
450
|
uploadPhoto(patientId, request) {
|
|
358
451
|
return this.send("POST", "/patients/{id}/photo", {
|
|
359
452
|
pathParams: { id: patientId },
|
|
@@ -401,9 +494,10 @@ var PatientClient = class extends BaseServiceClient {
|
|
|
401
494
|
body: request
|
|
402
495
|
});
|
|
403
496
|
}
|
|
404
|
-
listMedications(patientId) {
|
|
497
|
+
listMedications(patientId, query) {
|
|
405
498
|
return this.send("GET", "/patients/{id}/medications", {
|
|
406
|
-
pathParams: { id: patientId }
|
|
499
|
+
pathParams: { id: patientId },
|
|
500
|
+
query
|
|
407
501
|
});
|
|
408
502
|
}
|
|
409
503
|
getMedication(patientId, medicationId) {
|
|
@@ -448,6 +542,8 @@ var PatientClient = class extends BaseServiceClient {
|
|
|
448
542
|
body: request
|
|
449
543
|
});
|
|
450
544
|
}
|
|
545
|
+
// No HealthCloud schema is published for this response — see
|
|
546
|
+
// `InsuranceEligibilityResponse` for why it stays a raw `JsonValue`.
|
|
451
547
|
checkInsuranceEligibility(request) {
|
|
452
548
|
return this.send("POST", "/insurance/eligibility", {
|
|
453
549
|
body: request
|
|
@@ -627,6 +723,12 @@ var HCSDK = class {
|
|
|
627
723
|
this.rppg = new RppgClient(this.http);
|
|
628
724
|
this.session = new SessionClient(this.http);
|
|
629
725
|
this.telehealth = new TelehealthClient(this.http);
|
|
726
|
+
this.fieldAgent = new FieldAgentClient(
|
|
727
|
+
this.http,
|
|
728
|
+
(token) => this.setAccessToken(token),
|
|
729
|
+
() => this.state.tenantId
|
|
730
|
+
);
|
|
731
|
+
this.mcp = new MCPClient(this.http);
|
|
630
732
|
}
|
|
631
733
|
setAccessToken(token) {
|
|
632
734
|
this.state.accessToken = token;
|
|
@@ -729,5 +831,6 @@ export {
|
|
|
729
831
|
SDKError,
|
|
730
832
|
assertEnvironment,
|
|
731
833
|
isServiceName,
|
|
732
|
-
resolveBaseUrl
|
|
834
|
+
resolveBaseUrl,
|
|
835
|
+
withTenantId
|
|
733
836
|
};
|