@healthcloudai/hc-sdk 0.3.0 → 0.5.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 CHANGED
@@ -28,7 +28,8 @@ __export(index_exports, {
28
28
  SDKError: () => SDKError,
29
29
  assertEnvironment: () => assertEnvironment,
30
30
  isServiceName: () => isServiceName,
31
- resolveBaseUrl: () => resolveBaseUrl
31
+ resolveBaseUrl: () => resolveBaseUrl,
32
+ withTenantId: () => withTenantId
32
33
  });
33
34
  module.exports = __toCommonJS(index_exports);
34
35
 
@@ -42,7 +43,9 @@ var SERVICES = [
42
43
  "appointments",
43
44
  "rppg",
44
45
  "session",
45
- "telehealth"
46
+ "telehealth",
47
+ "fieldagent",
48
+ "mcp"
46
49
  ];
47
50
  function isServiceName(value) {
48
51
  return SERVICES.includes(value);
@@ -56,6 +59,15 @@ function assertEnvironment(environment) {
56
59
  throw new Error(`Unsupported HealthCloud environment: "${environment}"`);
57
60
  }
58
61
  }
62
+ function withTenantId(request, tenantId) {
63
+ if (!tenantId) {
64
+ return request;
65
+ }
66
+ return {
67
+ ...request,
68
+ tenant_id: tenantId
69
+ };
70
+ }
59
71
 
60
72
  // src/errors/SDKError.ts
61
73
  var SDKError = class extends Error {
@@ -106,9 +118,6 @@ var HttpClient = class {
106
118
  Accept: "application/json",
107
119
  ...(_a = options.headers) != null ? _a : {}
108
120
  };
109
- if (this.state.tenantId) {
110
- headers["X-Tenant-ID"] = this.state.tenantId;
111
- }
112
121
  if (options.auth !== false) {
113
122
  if (!this.state.accessToken) {
114
123
  throw new SDKError({
@@ -203,12 +212,11 @@ var HttpClient = class {
203
212
  return response.statusText || `HealthCloud API request failed with HTTP ${response.status}.`;
204
213
  }
205
214
  readMessage(payload) {
206
- if (typeof payload !== "object" || payload === null) {
215
+ if (typeof payload !== "object" || payload === null || Array.isArray(payload)) {
207
216
  return void 0;
208
217
  }
209
- const record = payload;
210
218
  for (const key of ["message", "error", "ErrorMessage", "Message", "detail"]) {
211
- const value = record[key];
219
+ const value = payload[key];
212
220
  if (typeof value === "string" && value.trim()) {
213
221
  return value;
214
222
  }
@@ -229,7 +237,9 @@ var BaseServiceClient = class {
229
237
  }
230
238
  /**
231
239
  * Low-level escape hatch — allows consumers to call any path on this service
232
- * without waiting for a typed SDK method to be added.
240
+ * without waiting for a typed SDK method to be added. The response shape is
241
+ * intentionally generic since this targets undocumented/future paths; the
242
+ * caller must supply `TResponse` once the path's contract is known.
233
243
  */
234
244
  request(method, path, options = {}) {
235
245
  return this.send(method, path, options);
@@ -261,62 +271,30 @@ var AuthClient = class extends BaseServiceClient {
261
271
  }
262
272
  async register(request) {
263
273
  return this.send("POST", "/auth/register", {
264
- body: this.withTenantId(request),
274
+ body: withTenantId(request, this.getTenantId()),
265
275
  auth: false
266
276
  });
267
277
  }
268
278
  async login(request) {
269
279
  const response = await this.send("POST", "/auth/login", {
270
- body: this.withTenantId(request),
280
+ body: withTenantId(request, this.getTenantId()),
271
281
  auth: false
272
282
  });
273
- const accessToken = this.extractAccessToken(response);
274
- if (!accessToken) {
283
+ if (!response.access_token) {
275
284
  throw new SDKError({
276
285
  message: "Login response did not include an access token.",
277
- statusCode: 0,
278
- response
286
+ statusCode: 0
279
287
  });
280
288
  }
281
- this.setAccessToken(accessToken);
289
+ this.setAccessToken(response.access_token);
282
290
  return response;
283
291
  }
284
292
  async verifyEmail(request) {
285
293
  return this.send("POST", "/auth/verify-email", {
286
- body: this.withTenantId(request),
294
+ body: withTenantId(request, this.getTenantId()),
287
295
  auth: false
288
296
  });
289
297
  }
290
- withTenantId(request) {
291
- const tenantId = this.getTenantId();
292
- if (!tenantId) {
293
- return request;
294
- }
295
- return {
296
- ...request,
297
- tenant_id: tenantId
298
- };
299
- }
300
- extractAccessToken(response) {
301
- if (typeof response !== "object" || response === null) {
302
- return void 0;
303
- }
304
- const record = response;
305
- for (const key of ["token", "access_token", "accessToken", "AccessToken", "idToken", "IDToken"]) {
306
- const value = record[key];
307
- if (typeof value === "string" && value.trim()) {
308
- return value;
309
- }
310
- }
311
- for (const key of ["data", "Data", "result", "Result"]) {
312
- const nested = record[key];
313
- const token = this.extractAccessToken(nested);
314
- if (token) {
315
- return token;
316
- }
317
- }
318
- return void 0;
319
- }
320
298
  };
321
299
 
322
300
  // src/clients/DiagnosticsClient.ts
@@ -333,10 +311,10 @@ var DiagnosticsClient = class extends BaseServiceClient {
333
311
  body: request
334
312
  });
335
313
  }
336
- list(patientId, query) {
314
+ // No documented query params for this endpoint — see curl reference.
315
+ list(patientId) {
337
316
  return this.send("GET", "/patients/{patient_id}/diagnostics", {
338
- pathParams: { patient_id: patientId },
339
- query
317
+ pathParams: { patient_id: patientId }
340
318
  });
341
319
  }
342
320
  };
@@ -351,6 +329,114 @@ var EhrClient = class extends BaseServiceClient {
351
329
  }
352
330
  };
353
331
 
332
+ // src/clients/FieldAgentClient.ts
333
+ var FieldAgentClient = class extends BaseServiceClient {
334
+ constructor(http, setAccessToken, getTenantId) {
335
+ super(http, "fieldagent");
336
+ this.setAccessToken = setAccessToken;
337
+ this.getTenantId = getTenantId;
338
+ }
339
+ connect() {
340
+ return this.connectService();
341
+ }
342
+ register(request) {
343
+ return this.send("POST", "/auth/register", {
344
+ body: withTenantId(request, this.getTenantId()),
345
+ auth: false
346
+ });
347
+ }
348
+ resetPassword(request) {
349
+ return this.send("POST", "/auth/reset-password", {
350
+ body: withTenantId(request, this.getTenantId()),
351
+ auth: false
352
+ });
353
+ }
354
+ async login(request) {
355
+ const response = await this.send("POST", "/auth/login", {
356
+ body: withTenantId(request, this.getTenantId()),
357
+ auth: false
358
+ });
359
+ if (!response.access_token) {
360
+ throw new SDKError({
361
+ message: "Login response did not include an access token.",
362
+ statusCode: 0
363
+ });
364
+ }
365
+ this.setAccessToken(response.access_token);
366
+ return response;
367
+ }
368
+ verifyEmail(request) {
369
+ return this.send("POST", "/auth/verify-email", {
370
+ body: withTenantId(request, this.getTenantId()),
371
+ auth: false
372
+ });
373
+ }
374
+ verifySms(request) {
375
+ return this.send("POST", "/auth/verify-sms", {
376
+ body: withTenantId(request, this.getTenantId()),
377
+ auth: false
378
+ });
379
+ }
380
+ getAgent(agentSub) {
381
+ return this.send("GET", "/agents/{sub}", {
382
+ pathParams: { sub: agentSub }
383
+ });
384
+ }
385
+ updateAgent(agentSub, request) {
386
+ return this.send("PATCH", "/agents/{sub}", {
387
+ pathParams: { sub: agentSub },
388
+ body: request
389
+ });
390
+ }
391
+ getDashboard(agentSub, query) {
392
+ return this.send("GET", "/agents/{sub}/dashboard", {
393
+ pathParams: { sub: agentSub },
394
+ query
395
+ });
396
+ }
397
+ getPhotoUploadUrl(agentSub) {
398
+ return this.send("GET", "/agents/{sub}/photo/upload-url", {
399
+ pathParams: { sub: agentSub }
400
+ });
401
+ }
402
+ uploadPhoto(agentSub, request) {
403
+ return this.send("POST", "/agents/{sub}/photo", {
404
+ pathParams: { sub: agentSub },
405
+ body: request
406
+ });
407
+ }
408
+ getPhoto(agentSub, query) {
409
+ return this.send("GET", "/agents/{sub}/photo", {
410
+ pathParams: { sub: agentSub },
411
+ query
412
+ });
413
+ }
414
+ listPatients(query) {
415
+ return this.send("GET", "/patients", { query });
416
+ }
417
+ listEncounters(query) {
418
+ return this.send("GET", "/encounters", { query });
419
+ }
420
+ };
421
+
422
+ // src/clients/MCPClient.ts
423
+ var MCPClient = class extends BaseServiceClient {
424
+ constructor(http) {
425
+ super(http, "mcp");
426
+ }
427
+ connect() {
428
+ return this.connectService();
429
+ }
430
+ /** Calls one of the 14 Patient API tools via `POST /patient`. */
431
+ patient(request) {
432
+ return this.send("POST", "/patient", { body: request });
433
+ }
434
+ /** Calls one of the 8 Field Agent API tools via `POST /fieldagent`. */
435
+ fieldAgent(request) {
436
+ return this.send("POST", "/fieldagent", { body: request });
437
+ }
438
+ };
439
+
354
440
  // src/clients/PatientClient.ts
355
441
  var PatientClient = class extends BaseServiceClient {
356
442
  constructor(http) {
@@ -388,6 +474,11 @@ var PatientClient = class extends BaseServiceClient {
388
474
  pathParams: { id: patientId }
389
475
  });
390
476
  }
477
+ getDashboard(patientId) {
478
+ return this.send("GET", "/patients/{id}/dashboard", {
479
+ pathParams: { id: patientId }
480
+ });
481
+ }
391
482
  uploadPhoto(patientId, request) {
392
483
  return this.send("POST", "/patients/{id}/photo", {
393
484
  pathParams: { id: patientId },
@@ -435,9 +526,10 @@ var PatientClient = class extends BaseServiceClient {
435
526
  body: request
436
527
  });
437
528
  }
438
- listMedications(patientId) {
529
+ listMedications(patientId, query) {
439
530
  return this.send("GET", "/patients/{id}/medications", {
440
- pathParams: { id: patientId }
531
+ pathParams: { id: patientId },
532
+ query
441
533
  });
442
534
  }
443
535
  getMedication(patientId, medicationId) {
@@ -482,6 +574,8 @@ var PatientClient = class extends BaseServiceClient {
482
574
  body: request
483
575
  });
484
576
  }
577
+ // No HealthCloud schema is published for this response — see
578
+ // `InsuranceEligibilityResponse` for why it stays a raw `JsonValue`.
485
579
  checkInsuranceEligibility(request) {
486
580
  return this.send("POST", "/insurance/eligibility", {
487
581
  body: request
@@ -661,6 +755,12 @@ var HCSDK = class {
661
755
  this.rppg = new RppgClient(this.http);
662
756
  this.session = new SessionClient(this.http);
663
757
  this.telehealth = new TelehealthClient(this.http);
758
+ this.fieldAgent = new FieldAgentClient(
759
+ this.http,
760
+ (token) => this.setAccessToken(token),
761
+ () => this.state.tenantId
762
+ );
763
+ this.mcp = new MCPClient(this.http);
664
764
  }
665
765
  setAccessToken(token) {
666
766
  this.state.accessToken = token;
@@ -764,5 +864,6 @@ var HCSDK_SWAGGER_OPERATION_COUNTS = {
764
864
  SDKError,
765
865
  assertEnvironment,
766
866
  isServiceName,
767
- resolveBaseUrl
867
+ resolveBaseUrl,
868
+ withTenantId
768
869
  });