@healthcloudai/hc-sdk 3.20.0 → 3.21.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
@@ -1010,6 +1010,85 @@ var MCPClient = class extends BaseServiceClient {
1010
1010
  }
1011
1011
  };
1012
1012
 
1013
+ // src/models/openapi-generated/patient/models/ObservedIntakeResponse.ts
1014
+ function ObservedIntakeResponseFromJSON(json) {
1015
+ return ObservedIntakeResponseFromJSONTyped(json, false);
1016
+ }
1017
+ function ObservedIntakeResponseFromJSONTyped(json, ignoreDiscriminator) {
1018
+ if (json == null) {
1019
+ return json;
1020
+ }
1021
+ return {
1022
+ "error_messages": json["error_messages"]
1023
+ };
1024
+ }
1025
+
1026
+ // src/models/openapi-generated/patient/models/IntakeOperationResponse.ts
1027
+ function IntakeOperationResponseFromJSON(json) {
1028
+ return IntakeOperationResponseFromJSONTyped(json, false);
1029
+ }
1030
+ function IntakeOperationResponseFromJSONTyped(json, ignoreDiscriminator) {
1031
+ if (json == null) {
1032
+ return json;
1033
+ }
1034
+ return {
1035
+ "idempotency_key": json["idempotency_key"],
1036
+ "patient_id": json["patient_id"],
1037
+ "request_hash": json["request_hash"],
1038
+ "response_body": json["response_body"] === void 0 ? void 0 : json["response_body"] === null ? null : ObservedIntakeResponseFromJSON(json["response_body"]),
1039
+ "response_code": json["response_code"] === void 0 ? void 0 : json["response_code"] === null ? null : json["response_code"],
1040
+ "status": json["status"]
1041
+ };
1042
+ }
1043
+
1044
+ // src/clients/intakeOperations.ts
1045
+ var sections = /* @__PURE__ */ new Set(["allergies", "cancer_cases", "family_history", "gyn_history", "perinatal_history", "medications", "problems", "social_history", "surgical_history", "vaccines"]);
1046
+ var record = (value) => !!value && typeof value === "object" && !Array.isArray(value);
1047
+ function intakeOperationKey(key) {
1048
+ if (typeof key !== "string" || key.length !== 36 || !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(key)) {
1049
+ throw new Error("A canonical UUID operation key is required");
1050
+ }
1051
+ return key;
1052
+ }
1053
+ function intakeRequestSnapshot(request) {
1054
+ const invalid = () => new Error("Valid bounded raw intake terms are required");
1055
+ if (!record(request) || Object.keys(request).sort().join(",") !== "idempotency_key,section,summary") throw invalid();
1056
+ const key = intakeOperationKey(request.idempotency_key);
1057
+ if (!sections.has(request.section)) throw invalid();
1058
+ const raw = request.summary;
1059
+ if (typeof raw === "string" ? !raw.trim() : !record(raw) || Object.keys(raw).length !== 1 || !Object.prototype.hasOwnProperty.call(raw, request.section)) throw invalid();
1060
+ let visited = 0;
1061
+ function snapshot(value, depth) {
1062
+ if (depth > 16 || ++visited > 65536) throw invalid();
1063
+ if (value === null || typeof value === "string" || typeof value === "boolean") return value;
1064
+ if (typeof value === "number" && Number.isFinite(value)) return value;
1065
+ if (!value || typeof value !== "object" || Object.getOwnPropertySymbols(value).length) throw invalid();
1066
+ const array = Array.isArray(value);
1067
+ if (!array && Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) throw invalid();
1068
+ const names = Object.getOwnPropertyNames(value).filter((name) => !(array && name === "length"));
1069
+ if (array && (names.length !== value.length || names.some((name, index) => name !== String(index)))) throw invalid();
1070
+ const entries = names.map((name) => {
1071
+ const descriptor = Object.getOwnPropertyDescriptor(value, name);
1072
+ if (!descriptor.enumerable || !("value" in descriptor)) throw invalid();
1073
+ return [name, snapshot(descriptor.value, depth + 1)];
1074
+ });
1075
+ return array ? entries.map(([, item]) => item) : Object.fromEntries(entries);
1076
+ }
1077
+ const summary = snapshot(raw, 0);
1078
+ if (new TextEncoder().encode(JSON.stringify(summary)).length > 65536) throw invalid();
1079
+ return { idempotency_key: key, section: request.section, summary };
1080
+ }
1081
+ function intakeOperationResponse(value, key) {
1082
+ const invalid = () => new Error("Invalid or mismatched intake operation response; reconcile the original key");
1083
+ const required = ["idempotency_key", "patient_id", "request_hash", "status"];
1084
+ if (!record(value) || required.some((name) => !Object.prototype.hasOwnProperty.call(value, name)) || Object.keys(value).some((name) => ![...required, "response_code", "response_body"].includes(name)) || value.idempotency_key !== key || typeof value.patient_id !== "string" || value.patient_id.length > 64 || !/^[A-Za-z0-9.-]+$/.test(value.patient_id) || value.patient_id.trim() !== value.patient_id || typeof value.request_hash !== "string" || value.request_hash.length !== 64 || !/^[0-9a-f]{64}$/.test(value.request_hash) || typeof value.status !== "string" || !["reserved", "dispatching", "unknown", "recorded"].includes(value.status)) throw invalid();
1085
+ const code = value.response_code, body = value.response_body;
1086
+ if (value.status === "recorded") {
1087
+ if (typeof code !== "number" || !Number.isInteger(code) || code < 100 || code > 599 || !record(body) || Object.keys(body).join(",") !== "error_messages" || !Array.isArray(body.error_messages) || body.error_messages.length > 100 || body.error_messages.some((item) => typeof item !== "string" || Array.from(item).length > 4e3)) throw invalid();
1088
+ } else if (code != null || body != null) throw invalid();
1089
+ return IntakeOperationResponseFromJSON(value);
1090
+ }
1091
+
1013
1092
  // src/models/openapi-generated/patient/models/StediClaimsResponse.ts
1014
1093
  function StediClaimsResponseFromJSON(json) {
1015
1094
  return StediClaimsResponseFromJSONTyped(json, false);
@@ -2880,6 +2959,20 @@ var PatientClient = class extends BaseServiceClient {
2880
2959
  body: payload
2881
2960
  });
2882
2961
  }
2962
+ /** Submit exact approved terms once. Pending/unknown remains unresolved;
2963
+ * recorded HTTP evidence is not independent proof of clinical success.
2964
+ * After transport failure, look up the original key. No retries or fallback.
2965
+ */
2966
+ async submitPatientIntakeOperation(request) {
2967
+ const body = intakeRequestSnapshot(request);
2968
+ const response = await this.send("POST", "/patients/intake/operations", { body });
2969
+ return intakeOperationResponse(response, body.idempotency_key);
2970
+ }
2971
+ /** Read the original key without writing. A 404 does not prove no effect. */
2972
+ async getPatientIntakeOperation(idempotencyKey) {
2973
+ const key = intakeOperationKey(idempotencyKey);
2974
+ return intakeOperationResponse(await this.send("GET", `/patients/intake/operations/${key}`), key);
2975
+ }
2883
2976
  /** GET /patients/attributes - get the authenticated patient's arbitrary JSON attributes. */
2884
2977
  getAttributes() {
2885
2978
  return this.send("GET", "/patients/attributes", {});