@healthcloudai/hc-sdk 0.3.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/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 {
@@ -203,12 +215,11 @@ var HttpClient = class {
203
215
  return response.statusText || `HealthCloud API request failed with HTTP ${response.status}.`;
204
216
  }
205
217
  readMessage(payload) {
206
- if (typeof payload !== "object" || payload === null) {
218
+ if (typeof payload !== "object" || payload === null || Array.isArray(payload)) {
207
219
  return void 0;
208
220
  }
209
- const record = payload;
210
221
  for (const key of ["message", "error", "ErrorMessage", "Message", "detail"]) {
211
- const value = record[key];
222
+ const value = payload[key];
212
223
  if (typeof value === "string" && value.trim()) {
213
224
  return value;
214
225
  }
@@ -229,7 +240,9 @@ var BaseServiceClient = class {
229
240
  }
230
241
  /**
231
242
  * Low-level escape hatch — allows consumers to call any path on this service
232
- * without waiting for a typed SDK method to be added.
243
+ * without waiting for a typed SDK method to be added. The response shape is
244
+ * intentionally generic since this targets undocumented/future paths; the
245
+ * caller must supply `TResponse` once the path's contract is known.
233
246
  */
234
247
  request(method, path, options = {}) {
235
248
  return this.send(method, path, options);
@@ -261,62 +274,30 @@ var AuthClient = class extends BaseServiceClient {
261
274
  }
262
275
  async register(request) {
263
276
  return this.send("POST", "/auth/register", {
264
- body: this.withTenantId(request),
277
+ body: withTenantId(request, this.getTenantId()),
265
278
  auth: false
266
279
  });
267
280
  }
268
281
  async login(request) {
269
282
  const response = await this.send("POST", "/auth/login", {
270
- body: this.withTenantId(request),
283
+ body: withTenantId(request, this.getTenantId()),
271
284
  auth: false
272
285
  });
273
- const accessToken = this.extractAccessToken(response);
274
- if (!accessToken) {
286
+ if (!response.access_token) {
275
287
  throw new SDKError({
276
288
  message: "Login response did not include an access token.",
277
- statusCode: 0,
278
- response
289
+ statusCode: 0
279
290
  });
280
291
  }
281
- this.setAccessToken(accessToken);
292
+ this.setAccessToken(response.access_token);
282
293
  return response;
283
294
  }
284
295
  async verifyEmail(request) {
285
296
  return this.send("POST", "/auth/verify-email", {
286
- body: this.withTenantId(request),
297
+ body: withTenantId(request, this.getTenantId()),
287
298
  auth: false
288
299
  });
289
300
  }
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
301
  };
321
302
 
322
303
  // src/clients/DiagnosticsClient.ts
@@ -333,10 +314,10 @@ var DiagnosticsClient = class extends BaseServiceClient {
333
314
  body: request
334
315
  });
335
316
  }
336
- list(patientId, query) {
317
+ // No documented query params for this endpoint — see curl reference.
318
+ list(patientId) {
337
319
  return this.send("GET", "/patients/{patient_id}/diagnostics", {
338
- pathParams: { patient_id: patientId },
339
- query
320
+ pathParams: { patient_id: patientId }
340
321
  });
341
322
  }
342
323
  };
@@ -351,6 +332,114 @@ var EhrClient = class extends BaseServiceClient {
351
332
  }
352
333
  };
353
334
 
335
+ // src/clients/FieldAgentClient.ts
336
+ var FieldAgentClient = class extends BaseServiceClient {
337
+ constructor(http, setAccessToken, getTenantId) {
338
+ super(http, "fieldagent");
339
+ this.setAccessToken = setAccessToken;
340
+ this.getTenantId = getTenantId;
341
+ }
342
+ connect() {
343
+ return this.connectService();
344
+ }
345
+ register(request) {
346
+ return this.send("POST", "/auth/register", {
347
+ body: withTenantId(request, this.getTenantId()),
348
+ auth: false
349
+ });
350
+ }
351
+ resetPassword(request) {
352
+ return this.send("POST", "/auth/reset-password", {
353
+ body: withTenantId(request, this.getTenantId()),
354
+ auth: false
355
+ });
356
+ }
357
+ async login(request) {
358
+ const response = await this.send("POST", "/auth/login", {
359
+ body: withTenantId(request, this.getTenantId()),
360
+ auth: false
361
+ });
362
+ if (!response.access_token) {
363
+ throw new SDKError({
364
+ message: "Login response did not include an access token.",
365
+ statusCode: 0
366
+ });
367
+ }
368
+ this.setAccessToken(response.access_token);
369
+ return response;
370
+ }
371
+ verifyEmail(request) {
372
+ return this.send("POST", "/auth/verify-email", {
373
+ body: withTenantId(request, this.getTenantId()),
374
+ auth: false
375
+ });
376
+ }
377
+ verifySms(request) {
378
+ return this.send("POST", "/auth/verify-sms", {
379
+ body: withTenantId(request, this.getTenantId()),
380
+ auth: false
381
+ });
382
+ }
383
+ getAgent(agentSub) {
384
+ return this.send("GET", "/agents/{sub}", {
385
+ pathParams: { sub: agentSub }
386
+ });
387
+ }
388
+ updateAgent(agentSub, request) {
389
+ return this.send("PATCH", "/agents/{sub}", {
390
+ pathParams: { sub: agentSub },
391
+ body: request
392
+ });
393
+ }
394
+ getDashboard(agentSub, query) {
395
+ return this.send("GET", "/agents/{sub}/dashboard", {
396
+ pathParams: { sub: agentSub },
397
+ query
398
+ });
399
+ }
400
+ getPhotoUploadUrl(agentSub) {
401
+ return this.send("GET", "/agents/{sub}/photo/upload-url", {
402
+ pathParams: { sub: agentSub }
403
+ });
404
+ }
405
+ uploadPhoto(agentSub, request) {
406
+ return this.send("POST", "/agents/{sub}/photo", {
407
+ pathParams: { sub: agentSub },
408
+ body: request
409
+ });
410
+ }
411
+ getPhoto(agentSub, query) {
412
+ return this.send("GET", "/agents/{sub}/photo", {
413
+ pathParams: { sub: agentSub },
414
+ query
415
+ });
416
+ }
417
+ listPatients(query) {
418
+ return this.send("GET", "/patients", { query });
419
+ }
420
+ listEncounters(query) {
421
+ return this.send("GET", "/encounters", { query });
422
+ }
423
+ };
424
+
425
+ // src/clients/MCPClient.ts
426
+ var MCPClient = class extends BaseServiceClient {
427
+ constructor(http) {
428
+ super(http, "mcp");
429
+ }
430
+ connect() {
431
+ return this.connectService();
432
+ }
433
+ /** Calls one of the 14 Patient API tools via `POST /patient`. */
434
+ patient(request) {
435
+ return this.send("POST", "/patient", { body: request });
436
+ }
437
+ /** Calls one of the 8 Field Agent API tools via `POST /fieldagent`. */
438
+ fieldAgent(request) {
439
+ return this.send("POST", "/fieldagent", { body: request });
440
+ }
441
+ };
442
+
354
443
  // src/clients/PatientClient.ts
355
444
  var PatientClient = class extends BaseServiceClient {
356
445
  constructor(http) {
@@ -388,6 +477,11 @@ var PatientClient = class extends BaseServiceClient {
388
477
  pathParams: { id: patientId }
389
478
  });
390
479
  }
480
+ getDashboard(patientId) {
481
+ return this.send("GET", "/patients/{id}/dashboard", {
482
+ pathParams: { id: patientId }
483
+ });
484
+ }
391
485
  uploadPhoto(patientId, request) {
392
486
  return this.send("POST", "/patients/{id}/photo", {
393
487
  pathParams: { id: patientId },
@@ -435,9 +529,10 @@ var PatientClient = class extends BaseServiceClient {
435
529
  body: request
436
530
  });
437
531
  }
438
- listMedications(patientId) {
532
+ listMedications(patientId, query) {
439
533
  return this.send("GET", "/patients/{id}/medications", {
440
- pathParams: { id: patientId }
534
+ pathParams: { id: patientId },
535
+ query
441
536
  });
442
537
  }
443
538
  getMedication(patientId, medicationId) {
@@ -482,6 +577,8 @@ var PatientClient = class extends BaseServiceClient {
482
577
  body: request
483
578
  });
484
579
  }
580
+ // No HealthCloud schema is published for this response — see
581
+ // `InsuranceEligibilityResponse` for why it stays a raw `JsonValue`.
485
582
  checkInsuranceEligibility(request) {
486
583
  return this.send("POST", "/insurance/eligibility", {
487
584
  body: request
@@ -661,6 +758,12 @@ var HCSDK = class {
661
758
  this.rppg = new RppgClient(this.http);
662
759
  this.session = new SessionClient(this.http);
663
760
  this.telehealth = new TelehealthClient(this.http);
761
+ this.fieldAgent = new FieldAgentClient(
762
+ this.http,
763
+ (token) => this.setAccessToken(token),
764
+ () => this.state.tenantId
765
+ );
766
+ this.mcp = new MCPClient(this.http);
664
767
  }
665
768
  setAccessToken(token) {
666
769
  this.state.accessToken = token;
@@ -764,5 +867,6 @@ var HCSDK_SWAGGER_OPERATION_COUNTS = {
764
867
  SDKError,
765
868
  assertEnvironment,
766
869
  isServiceName,
767
- resolveBaseUrl
870
+ resolveBaseUrl,
871
+ withTenantId
768
872
  });