@hipnation-truth/sdk 0.25.2 → 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.d.mts +11 -15
- package/dist/index.d.ts +11 -15
- package/dist/index.js +37 -72
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -72
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.ts +11 -15
- package/dist/react.js +37 -72
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/react.d.ts
CHANGED
|
@@ -1748,7 +1748,8 @@ declare class MessagesResource {
|
|
|
1748
1748
|
* EHR proxy resource — typed access to Truth's EHR proxy endpoints.
|
|
1749
1749
|
*
|
|
1750
1750
|
* Provides per-provider proxy methods so consumers never construct
|
|
1751
|
-
* proxy URLs manually.
|
|
1751
|
+
* proxy URLs manually. Every request carries the application's
|
|
1752
|
+
* `X-API-Key` — Truth's API gate rejects unauthenticated callers.
|
|
1752
1753
|
*
|
|
1753
1754
|
* @example
|
|
1754
1755
|
* ```ts
|
|
@@ -1760,28 +1761,23 @@ declare class MessagesResource {
|
|
|
1760
1761
|
declare class EhrProviderProxy {
|
|
1761
1762
|
private readonly baseUrl;
|
|
1762
1763
|
private readonly provider;
|
|
1763
|
-
|
|
1764
|
+
private readonly apiKey;
|
|
1765
|
+
constructor(apiBaseUrl: string, provider: string, apiKey: string);
|
|
1766
|
+
private headers;
|
|
1767
|
+
private request;
|
|
1764
1768
|
/**
|
|
1765
1769
|
* GET request to the EHR proxy.
|
|
1766
1770
|
* @param path — path relative to the provider root (e.g., "/patients/123/")
|
|
1767
1771
|
* @param params — optional query parameters
|
|
1768
1772
|
*/
|
|
1769
1773
|
get<T = unknown>(path: string, params?: Record<string, unknown>): Promise<T>;
|
|
1770
|
-
/**
|
|
1771
|
-
* POST request to the EHR proxy.
|
|
1772
|
-
*/
|
|
1774
|
+
/** POST request to the EHR proxy. */
|
|
1773
1775
|
post<T = unknown>(path: string, body?: unknown): Promise<T>;
|
|
1774
|
-
/**
|
|
1775
|
-
* PUT request to the EHR proxy.
|
|
1776
|
-
*/
|
|
1776
|
+
/** PUT request to the EHR proxy. */
|
|
1777
1777
|
put<T = unknown>(path: string, body?: unknown): Promise<T>;
|
|
1778
|
-
/**
|
|
1779
|
-
* PATCH request to the EHR proxy.
|
|
1780
|
-
*/
|
|
1778
|
+
/** PATCH request to the EHR proxy. */
|
|
1781
1779
|
patch<T = unknown>(path: string, body?: unknown): Promise<T>;
|
|
1782
|
-
/**
|
|
1783
|
-
* DELETE request to the EHR proxy.
|
|
1784
|
-
*/
|
|
1780
|
+
/** DELETE request to the EHR proxy. */
|
|
1785
1781
|
delete<T = unknown>(path: string): Promise<T>;
|
|
1786
1782
|
}
|
|
1787
1783
|
declare class EhrResource {
|
|
@@ -1789,7 +1785,7 @@ declare class EhrResource {
|
|
|
1789
1785
|
readonly elation: EhrProviderProxy;
|
|
1790
1786
|
/** Hint Health proxy */
|
|
1791
1787
|
readonly hint: EhrProviderProxy;
|
|
1792
|
-
constructor(apiBaseUrl: string);
|
|
1788
|
+
constructor(apiBaseUrl: string, apiKey: string);
|
|
1793
1789
|
}
|
|
1794
1790
|
|
|
1795
1791
|
/**
|
package/dist/react.js
CHANGED
|
@@ -1205,16 +1205,22 @@ var DialpadProxyError = class extends Error {
|
|
|
1205
1205
|
|
|
1206
1206
|
// src/resources/ehr.ts
|
|
1207
1207
|
var EhrProviderProxy = class {
|
|
1208
|
-
constructor(apiBaseUrl, provider) {
|
|
1208
|
+
constructor(apiBaseUrl, provider, apiKey) {
|
|
1209
1209
|
this.baseUrl = apiBaseUrl;
|
|
1210
1210
|
this.provider = provider;
|
|
1211
|
+
this.apiKey = apiKey;
|
|
1211
1212
|
}
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1213
|
+
headers(withBody) {
|
|
1214
|
+
const headers = {
|
|
1215
|
+
Accept: "application/json",
|
|
1216
|
+
"X-API-Key": this.apiKey
|
|
1217
|
+
};
|
|
1218
|
+
if (withBody) {
|
|
1219
|
+
headers["Content-Type"] = "application/json";
|
|
1220
|
+
}
|
|
1221
|
+
return headers;
|
|
1222
|
+
}
|
|
1223
|
+
request(method, path, body, params) {
|
|
1218
1224
|
return __async(this, null, function* () {
|
|
1219
1225
|
const url = new URL(`/api/ehr/${this.provider}${path}`, this.baseUrl);
|
|
1220
1226
|
if (params) {
|
|
@@ -1225,96 +1231,55 @@ var EhrProviderProxy = class {
|
|
|
1225
1231
|
}
|
|
1226
1232
|
}
|
|
1227
1233
|
const response = yield fetch(url.toString(), {
|
|
1228
|
-
method
|
|
1229
|
-
headers:
|
|
1234
|
+
method,
|
|
1235
|
+
headers: this.headers(body !== void 0),
|
|
1236
|
+
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
1230
1237
|
});
|
|
1231
1238
|
if (!response.ok) {
|
|
1232
|
-
throw new EhrProxyError(this.provider,
|
|
1239
|
+
throw new EhrProxyError(this.provider, method, path, response.status);
|
|
1233
1240
|
}
|
|
1234
1241
|
return yield response.json();
|
|
1235
1242
|
});
|
|
1236
1243
|
}
|
|
1237
1244
|
/**
|
|
1238
|
-
*
|
|
1245
|
+
* GET request to the EHR proxy.
|
|
1246
|
+
* @param path — path relative to the provider root (e.g., "/patients/123/")
|
|
1247
|
+
* @param params — optional query parameters
|
|
1239
1248
|
*/
|
|
1249
|
+
get(path, params) {
|
|
1250
|
+
return __async(this, null, function* () {
|
|
1251
|
+
return this.request("GET", path, void 0, params);
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1254
|
+
/** POST request to the EHR proxy. */
|
|
1240
1255
|
post(path, body) {
|
|
1241
1256
|
return __async(this, null, function* () {
|
|
1242
|
-
|
|
1243
|
-
const response = yield fetch(url, {
|
|
1244
|
-
method: "POST",
|
|
1245
|
-
headers: {
|
|
1246
|
-
"Content-Type": "application/json",
|
|
1247
|
-
Accept: "application/json"
|
|
1248
|
-
},
|
|
1249
|
-
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
1250
|
-
});
|
|
1251
|
-
if (!response.ok) {
|
|
1252
|
-
throw new EhrProxyError(this.provider, "POST", path, response.status);
|
|
1253
|
-
}
|
|
1254
|
-
return yield response.json();
|
|
1257
|
+
return this.request("POST", path, body);
|
|
1255
1258
|
});
|
|
1256
1259
|
}
|
|
1257
|
-
/**
|
|
1258
|
-
* PUT request to the EHR proxy.
|
|
1259
|
-
*/
|
|
1260
|
+
/** PUT request to the EHR proxy. */
|
|
1260
1261
|
put(path, body) {
|
|
1261
1262
|
return __async(this, null, function* () {
|
|
1262
|
-
|
|
1263
|
-
const response = yield fetch(url, {
|
|
1264
|
-
method: "PUT",
|
|
1265
|
-
headers: {
|
|
1266
|
-
"Content-Type": "application/json",
|
|
1267
|
-
Accept: "application/json"
|
|
1268
|
-
},
|
|
1269
|
-
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
1270
|
-
});
|
|
1271
|
-
if (!response.ok) {
|
|
1272
|
-
throw new EhrProxyError(this.provider, "PUT", path, response.status);
|
|
1273
|
-
}
|
|
1274
|
-
return yield response.json();
|
|
1263
|
+
return this.request("PUT", path, body);
|
|
1275
1264
|
});
|
|
1276
1265
|
}
|
|
1277
|
-
/**
|
|
1278
|
-
* PATCH request to the EHR proxy.
|
|
1279
|
-
*/
|
|
1266
|
+
/** PATCH request to the EHR proxy. */
|
|
1280
1267
|
patch(path, body) {
|
|
1281
1268
|
return __async(this, null, function* () {
|
|
1282
|
-
|
|
1283
|
-
const response = yield fetch(url, {
|
|
1284
|
-
method: "PATCH",
|
|
1285
|
-
headers: {
|
|
1286
|
-
"Content-Type": "application/json",
|
|
1287
|
-
Accept: "application/json"
|
|
1288
|
-
},
|
|
1289
|
-
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
1290
|
-
});
|
|
1291
|
-
if (!response.ok) {
|
|
1292
|
-
throw new EhrProxyError(this.provider, "PATCH", path, response.status);
|
|
1293
|
-
}
|
|
1294
|
-
return yield response.json();
|
|
1269
|
+
return this.request("PATCH", path, body);
|
|
1295
1270
|
});
|
|
1296
1271
|
}
|
|
1297
|
-
/**
|
|
1298
|
-
* DELETE request to the EHR proxy.
|
|
1299
|
-
*/
|
|
1272
|
+
/** DELETE request to the EHR proxy. */
|
|
1300
1273
|
delete(path) {
|
|
1301
1274
|
return __async(this, null, function* () {
|
|
1302
|
-
|
|
1303
|
-
const response = yield fetch(url, {
|
|
1304
|
-
method: "DELETE",
|
|
1305
|
-
headers: { Accept: "application/json" }
|
|
1306
|
-
});
|
|
1307
|
-
if (!response.ok) {
|
|
1308
|
-
throw new EhrProxyError(this.provider, "DELETE", path, response.status);
|
|
1309
|
-
}
|
|
1310
|
-
return yield response.json();
|
|
1275
|
+
return this.request("DELETE", path);
|
|
1311
1276
|
});
|
|
1312
1277
|
}
|
|
1313
1278
|
};
|
|
1314
1279
|
var EhrResource = class {
|
|
1315
|
-
constructor(apiBaseUrl) {
|
|
1316
|
-
this.elation = new EhrProviderProxy(apiBaseUrl, "elation");
|
|
1317
|
-
this.hint = new EhrProviderProxy(apiBaseUrl, "hint");
|
|
1280
|
+
constructor(apiBaseUrl, apiKey) {
|
|
1281
|
+
this.elation = new EhrProviderProxy(apiBaseUrl, "elation", apiKey);
|
|
1282
|
+
this.hint = new EhrProviderProxy(apiBaseUrl, "hint", apiKey);
|
|
1318
1283
|
}
|
|
1319
1284
|
};
|
|
1320
1285
|
var EhrProxyError = class extends Error {
|
|
@@ -2265,7 +2230,7 @@ var TruthClient = class {
|
|
|
2265
2230
|
const apiUrl = this.tracker.apiUrl;
|
|
2266
2231
|
this.patients = new PatientResource(this.convex);
|
|
2267
2232
|
this.appointments = new AppointmentResource(this.convex);
|
|
2268
|
-
this.ehr = new EhrResource(apiUrl);
|
|
2233
|
+
this.ehr = new EhrResource(apiUrl, config.apiKey);
|
|
2269
2234
|
this.messages = new MessagesResource(apiUrl, config.apiKey);
|
|
2270
2235
|
this.reminders = new RemindersResource(this.convex);
|
|
2271
2236
|
this.translation = new TranslationResource(apiUrl, config.apiKey);
|