@hipnation-truth/sdk 0.25.1 → 0.25.3

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.mjs CHANGED
@@ -333,10 +333,22 @@ var ConversationTasksSubresource = class {
333
333
  return __async(this, null, function* () {
334
334
  return this.post(
335
335
  `/conversations/tasks/${encodeURIComponent(input.taskId)}/status`,
336
- __spreadValues({
336
+ __spreadValues(__spreadValues({
337
337
  id: input.taskId,
338
338
  status: input.status
339
- }, input.resolvedBy ? { resolvedBy: input.resolvedBy } : {})
339
+ }, input.resolvedBy ? { resolvedBy: input.resolvedBy } : {}), input.actor ? { actor: input.actor } : {})
340
+ );
341
+ });
342
+ }
343
+ /** Archive or un-archive a task (hides it from My Tasks without deleting). */
344
+ setArchived(input) {
345
+ return __async(this, null, function* () {
346
+ return this.post(
347
+ `/conversations/tasks/${encodeURIComponent(input.taskId)}/archive`,
348
+ __spreadValues({
349
+ id: input.taskId,
350
+ archived: input.archived
351
+ }, input.actor ? { actor: input.actor } : {})
340
352
  );
341
353
  });
342
354
  }
@@ -349,12 +361,12 @@ var ConversationTasksSubresource = class {
349
361
  return __async(this, null, function* () {
350
362
  return this.patch(
351
363
  `/conversations/tasks/${encodeURIComponent(input.taskId)}`,
352
- __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
364
+ __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
353
365
  id: input.taskId,
354
366
  conversationId: input.conversationId,
355
367
  author: input.author,
356
368
  description: input.description
357
- }, input.title !== void 0 ? { title: input.title } : {}), input.priority ? { priority: input.priority } : {}), input.status ? { status: input.status } : {}), input.assignee !== void 0 ? { assignee: input.assignee } : {}), input.type !== void 0 ? { type: input.type } : {})
369
+ }, input.title !== void 0 ? { title: input.title } : {}), input.priority ? { priority: input.priority } : {}), input.status ? { status: input.status } : {}), input.assignee !== void 0 ? { assignee: input.assignee } : {}), input.type !== void 0 ? { type: input.type } : {}), input.actor ? { actor: input.actor } : {})
358
370
  );
359
371
  });
360
372
  }
@@ -856,16 +868,22 @@ var DialpadProxyError = class extends Error {
856
868
 
857
869
  // src/resources/ehr.ts
858
870
  var EhrProviderProxy = class {
859
- constructor(apiBaseUrl, provider) {
871
+ constructor(apiBaseUrl, provider, apiKey) {
860
872
  this.baseUrl = apiBaseUrl;
861
873
  this.provider = provider;
874
+ this.apiKey = apiKey;
862
875
  }
863
- /**
864
- * GET request to the EHR proxy.
865
- * @param path — path relative to the provider root (e.g., "/patients/123/")
866
- * @param params — optional query parameters
867
- */
868
- get(path, params) {
876
+ headers(withBody) {
877
+ const headers = {
878
+ Accept: "application/json",
879
+ "X-API-Key": this.apiKey
880
+ };
881
+ if (withBody) {
882
+ headers["Content-Type"] = "application/json";
883
+ }
884
+ return headers;
885
+ }
886
+ request(method, path, body, params) {
869
887
  return __async(this, null, function* () {
870
888
  const url = new URL(`/api/ehr/${this.provider}${path}`, this.baseUrl);
871
889
  if (params) {
@@ -876,96 +894,55 @@ var EhrProviderProxy = class {
876
894
  }
877
895
  }
878
896
  const response = yield fetch(url.toString(), {
879
- method: "GET",
880
- headers: { Accept: "application/json" }
897
+ method,
898
+ headers: this.headers(body !== void 0),
899
+ body: body !== void 0 ? JSON.stringify(body) : void 0
881
900
  });
882
901
  if (!response.ok) {
883
- throw new EhrProxyError(this.provider, "GET", path, response.status);
902
+ throw new EhrProxyError(this.provider, method, path, response.status);
884
903
  }
885
904
  return yield response.json();
886
905
  });
887
906
  }
888
907
  /**
889
- * POST request to the EHR proxy.
908
+ * GET request to the EHR proxy.
909
+ * @param path — path relative to the provider root (e.g., "/patients/123/")
910
+ * @param params — optional query parameters
890
911
  */
912
+ get(path, params) {
913
+ return __async(this, null, function* () {
914
+ return this.request("GET", path, void 0, params);
915
+ });
916
+ }
917
+ /** POST request to the EHR proxy. */
891
918
  post(path, body) {
892
919
  return __async(this, null, function* () {
893
- const url = `${this.baseUrl}/api/ehr/${this.provider}${path}`;
894
- const response = yield fetch(url, {
895
- method: "POST",
896
- headers: {
897
- "Content-Type": "application/json",
898
- Accept: "application/json"
899
- },
900
- body: body !== void 0 ? JSON.stringify(body) : void 0
901
- });
902
- if (!response.ok) {
903
- throw new EhrProxyError(this.provider, "POST", path, response.status);
904
- }
905
- return yield response.json();
920
+ return this.request("POST", path, body);
906
921
  });
907
922
  }
908
- /**
909
- * PUT request to the EHR proxy.
910
- */
923
+ /** PUT request to the EHR proxy. */
911
924
  put(path, body) {
912
925
  return __async(this, null, function* () {
913
- const url = `${this.baseUrl}/api/ehr/${this.provider}${path}`;
914
- const response = yield fetch(url, {
915
- method: "PUT",
916
- headers: {
917
- "Content-Type": "application/json",
918
- Accept: "application/json"
919
- },
920
- body: body !== void 0 ? JSON.stringify(body) : void 0
921
- });
922
- if (!response.ok) {
923
- throw new EhrProxyError(this.provider, "PUT", path, response.status);
924
- }
925
- return yield response.json();
926
+ return this.request("PUT", path, body);
926
927
  });
927
928
  }
928
- /**
929
- * PATCH request to the EHR proxy.
930
- */
929
+ /** PATCH request to the EHR proxy. */
931
930
  patch(path, body) {
932
931
  return __async(this, null, function* () {
933
- const url = `${this.baseUrl}/api/ehr/${this.provider}${path}`;
934
- const response = yield fetch(url, {
935
- method: "PATCH",
936
- headers: {
937
- "Content-Type": "application/json",
938
- Accept: "application/json"
939
- },
940
- body: body !== void 0 ? JSON.stringify(body) : void 0
941
- });
942
- if (!response.ok) {
943
- throw new EhrProxyError(this.provider, "PATCH", path, response.status);
944
- }
945
- return yield response.json();
932
+ return this.request("PATCH", path, body);
946
933
  });
947
934
  }
948
- /**
949
- * DELETE request to the EHR proxy.
950
- */
935
+ /** DELETE request to the EHR proxy. */
951
936
  delete(path) {
952
937
  return __async(this, null, function* () {
953
- const url = `${this.baseUrl}/api/ehr/${this.provider}${path}`;
954
- const response = yield fetch(url, {
955
- method: "DELETE",
956
- headers: { Accept: "application/json" }
957
- });
958
- if (!response.ok) {
959
- throw new EhrProxyError(this.provider, "DELETE", path, response.status);
960
- }
961
- return yield response.json();
938
+ return this.request("DELETE", path);
962
939
  });
963
940
  }
964
941
  };
965
942
  var EhrResource = class {
966
- constructor(apiBaseUrl) {
967
- this.elation = new EhrProviderProxy(apiBaseUrl, "elation");
968
- this.hint = new EhrProviderProxy(apiBaseUrl, "hint");
943
+ constructor(apiBaseUrl, apiKey) {
944
+ this.elation = new EhrProviderProxy(apiBaseUrl, "elation", apiKey);
945
+ this.hint = new EhrProviderProxy(apiBaseUrl, "hint", apiKey);
969
946
  }
970
947
  };
971
948
  var EhrProxyError = class extends Error {
@@ -1930,7 +1907,7 @@ var TruthClient = class {
1930
1907
  const apiUrl = this.tracker.apiUrl;
1931
1908
  this.patients = new PatientResource(this.convex);
1932
1909
  this.appointments = new AppointmentResource(this.convex);
1933
- this.ehr = new EhrResource(apiUrl);
1910
+ this.ehr = new EhrResource(apiUrl, config.apiKey);
1934
1911
  this.messages = new MessagesResource(apiUrl, config.apiKey);
1935
1912
  this.reminders = new RemindersResource(this.convex);
1936
1913
  this.translation = new TranslationResource(apiUrl, config.apiKey);