@hipnation-truth/sdk 0.26.13 → 0.26.15
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 +13 -3
- package/dist/index.d.ts +13 -3
- package/dist/index.js +44 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -3
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.ts +19 -5
- package/dist/react.js +58 -18
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/react.d.ts
CHANGED
|
@@ -522,8 +522,12 @@ declare function usePatients(options?: UsePatientListOptions): any;
|
|
|
522
522
|
declare function usePatient(id: string): any;
|
|
523
523
|
/**
|
|
524
524
|
* Subscribe to a patient by their Elation ID.
|
|
525
|
+
*
|
|
526
|
+
* Accepts the id in any form (string/number/bigint) and coerces it to a
|
|
527
|
+
* `bigint` (int64) for the now-int64 Convex `patients:getByElationId` arg.
|
|
528
|
+
* Returns `null` (skip) for a non-numeric / absent id.
|
|
525
529
|
*/
|
|
526
|
-
declare function usePatientByElationId(elationId: string): any;
|
|
530
|
+
declare function usePatientByElationId(elationId: string | number | bigint): any;
|
|
527
531
|
/**
|
|
528
532
|
* Subscribe to a patient by their Hint ID.
|
|
529
533
|
*/
|
|
@@ -943,7 +947,7 @@ interface FamilyMemberRow {
|
|
|
943
947
|
_creationTime: number;
|
|
944
948
|
firstName: string;
|
|
945
949
|
lastName: string;
|
|
946
|
-
elationId?: string;
|
|
950
|
+
elationId?: string | bigint;
|
|
947
951
|
hintId?: string;
|
|
948
952
|
familyId?: string;
|
|
949
953
|
phones: Array<{
|
|
@@ -1108,8 +1112,14 @@ declare function usePatientSearch(options: UsePatientSearchOptions): UseQueryRes
|
|
|
1108
1112
|
interface Patient {
|
|
1109
1113
|
/** Truth platform patient ID */
|
|
1110
1114
|
id: string;
|
|
1111
|
-
/**
|
|
1112
|
-
|
|
1115
|
+
/**
|
|
1116
|
+
* Elation EHR patient ID (if linked).
|
|
1117
|
+
*
|
|
1118
|
+
* `bigint | string` during the int64 normalization transition: Convex stores
|
|
1119
|
+
* the normalized int64 (a JS `bigint` over the wire) or a legacy string.
|
|
1120
|
+
* Render via `String(elationId)` / `.toString()`.
|
|
1121
|
+
*/
|
|
1122
|
+
elationId?: string | bigint;
|
|
1113
1123
|
/** Hint EHR patient ID (if linked) */
|
|
1114
1124
|
hintId?: string;
|
|
1115
1125
|
/** Patient first name */
|
|
@@ -2084,8 +2094,12 @@ declare class PatientResource {
|
|
|
2084
2094
|
get(id: string): Promise<Patient | null>;
|
|
2085
2095
|
/**
|
|
2086
2096
|
* Get a patient by their Elation EHR ID.
|
|
2097
|
+
*
|
|
2098
|
+
* Accepts the id in any form (string/number/bigint) and coerces it to a
|
|
2099
|
+
* `bigint` (int64) for the now-int64 Convex `patients:getByElationId` arg.
|
|
2100
|
+
* Returns `null` for a non-numeric / absent id.
|
|
2087
2101
|
*/
|
|
2088
|
-
getByElationId(elationId: string): Promise<Patient | null>;
|
|
2102
|
+
getByElationId(elationId: string | number | bigint): Promise<Patient | null>;
|
|
2089
2103
|
/**
|
|
2090
2104
|
* Get a patient by their Hint EHR ID.
|
|
2091
2105
|
*/
|
package/dist/react.js
CHANGED
|
@@ -239,6 +239,11 @@ var REQUIRE_TOKEN_RETRY_DELAY_MS = 150;
|
|
|
239
239
|
function delay(ms) {
|
|
240
240
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
241
241
|
}
|
|
242
|
+
var USER_TOKEN_HEADER = "X-Truth-Authorization";
|
|
243
|
+
function setUserToken(headers, token) {
|
|
244
|
+
headers.Authorization = `Bearer ${token}`;
|
|
245
|
+
headers[USER_TOKEN_HEADER] = `Bearer ${token}`;
|
|
246
|
+
}
|
|
242
247
|
function resolveAuthToken(getAuthToken) {
|
|
243
248
|
return __async(this, null, function* () {
|
|
244
249
|
try {
|
|
@@ -269,7 +274,7 @@ function buildAuthHeaders(auth, options) {
|
|
|
269
274
|
for (let attempt = 0; attempt < REQUIRE_TOKEN_MAX_ATTEMPTS; attempt++) {
|
|
270
275
|
const token = yield resolveAuthToken(auth.getAuthToken);
|
|
271
276
|
if (token) {
|
|
272
|
-
headers
|
|
277
|
+
setUserToken(headers, token);
|
|
273
278
|
return headers;
|
|
274
279
|
}
|
|
275
280
|
if (attempt < REQUIRE_TOKEN_MAX_ATTEMPTS - 1) {
|
|
@@ -283,7 +288,7 @@ function buildAuthHeaders(auth, options) {
|
|
|
283
288
|
if (auth.getAuthToken) {
|
|
284
289
|
const token = yield resolveAuthToken(auth.getAuthToken);
|
|
285
290
|
if (token) {
|
|
286
|
-
headers
|
|
291
|
+
setUserToken(headers, token);
|
|
287
292
|
}
|
|
288
293
|
}
|
|
289
294
|
return headers;
|
|
@@ -1405,6 +1410,41 @@ var PatientDetailsResource = class {
|
|
|
1405
1410
|
}
|
|
1406
1411
|
};
|
|
1407
1412
|
|
|
1413
|
+
// src/react/elation-id.ts
|
|
1414
|
+
function toBigIntElationId(value) {
|
|
1415
|
+
if (value === void 0 || value === null || value === "") {
|
|
1416
|
+
return void 0;
|
|
1417
|
+
}
|
|
1418
|
+
if (typeof value === "bigint") {
|
|
1419
|
+
return value;
|
|
1420
|
+
}
|
|
1421
|
+
if (typeof value === "number") {
|
|
1422
|
+
if (!Number.isFinite(value) || !Number.isInteger(value)) {
|
|
1423
|
+
return void 0;
|
|
1424
|
+
}
|
|
1425
|
+
return BigInt(Math.trunc(value));
|
|
1426
|
+
}
|
|
1427
|
+
if (typeof value === "string") {
|
|
1428
|
+
const trimmed = value.trim();
|
|
1429
|
+
if (!/^\d+$/.test(trimmed)) {
|
|
1430
|
+
return void 0;
|
|
1431
|
+
}
|
|
1432
|
+
try {
|
|
1433
|
+
return BigInt(trimmed);
|
|
1434
|
+
} catch (e) {
|
|
1435
|
+
return void 0;
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
return void 0;
|
|
1439
|
+
}
|
|
1440
|
+
function toFiniteElationId(value) {
|
|
1441
|
+
if (value === void 0 || value === null || value === "") {
|
|
1442
|
+
return void 0;
|
|
1443
|
+
}
|
|
1444
|
+
const n = typeof value === "number" ? value : Number(value);
|
|
1445
|
+
return Number.isFinite(n) ? n : void 0;
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1408
1448
|
// src/resources/patients.ts
|
|
1409
1449
|
var PatientResource = class {
|
|
1410
1450
|
constructor(convexClient) {
|
|
@@ -1430,13 +1470,21 @@ var PatientResource = class {
|
|
|
1430
1470
|
}
|
|
1431
1471
|
/**
|
|
1432
1472
|
* Get a patient by their Elation EHR ID.
|
|
1473
|
+
*
|
|
1474
|
+
* Accepts the id in any form (string/number/bigint) and coerces it to a
|
|
1475
|
+
* `bigint` (int64) for the now-int64 Convex `patients:getByElationId` arg.
|
|
1476
|
+
* Returns `null` for a non-numeric / absent id.
|
|
1433
1477
|
*/
|
|
1434
1478
|
getByElationId(elationId) {
|
|
1435
1479
|
return __async(this, null, function* () {
|
|
1480
|
+
const id = toBigIntElationId(elationId);
|
|
1481
|
+
if (id === void 0) {
|
|
1482
|
+
return null;
|
|
1483
|
+
}
|
|
1436
1484
|
try {
|
|
1437
1485
|
const result = yield this.convex.query(
|
|
1438
1486
|
"patients:getByElationId",
|
|
1439
|
-
{ elationId }
|
|
1487
|
+
{ elationId: id }
|
|
1440
1488
|
);
|
|
1441
1489
|
return result != null ? result : null;
|
|
1442
1490
|
} catch (e) {
|
|
@@ -2800,17 +2848,6 @@ function useConversationTasksByPhonePair(phonePair) {
|
|
|
2800
2848
|
|
|
2801
2849
|
// src/react/hooks.ts
|
|
2802
2850
|
var import_react5 = require("react");
|
|
2803
|
-
|
|
2804
|
-
// src/react/elation-id.ts
|
|
2805
|
-
function toFiniteElationId(value) {
|
|
2806
|
-
if (value === void 0 || value === null || value === "") {
|
|
2807
|
-
return void 0;
|
|
2808
|
-
}
|
|
2809
|
-
const n = typeof value === "number" ? value : Number(value);
|
|
2810
|
-
return Number.isFinite(n) ? n : void 0;
|
|
2811
|
-
}
|
|
2812
|
-
|
|
2813
|
-
// src/react/hooks.ts
|
|
2814
2851
|
var import_server5 = require("convex/server");
|
|
2815
2852
|
var patientsListRef = (0, import_server5.makeFunctionReference)("patients:list");
|
|
2816
2853
|
var patientsGetRef = (0, import_server5.makeFunctionReference)("patients:get");
|
|
@@ -2826,9 +2863,11 @@ function usePatient(id) {
|
|
|
2826
2863
|
return usePersistentQuery(patientsGetRef, { id });
|
|
2827
2864
|
}
|
|
2828
2865
|
function usePatientByElationId(elationId) {
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2866
|
+
const id = toBigIntElationId(elationId);
|
|
2867
|
+
return usePersistentQuery(
|
|
2868
|
+
patientsByElationIdRef,
|
|
2869
|
+
id !== void 0 ? { elationId: id } : "skip"
|
|
2870
|
+
);
|
|
2832
2871
|
}
|
|
2833
2872
|
function usePatientByHintId(hintId) {
|
|
2834
2873
|
return usePersistentQuery(patientsByHintIdRef, {
|
|
@@ -2942,9 +2981,10 @@ function usePatientBasic(input, options) {
|
|
|
2942
2981
|
const apiKey = (_b = options == null ? void 0 : options.apiKey) != null ? _b : sdkContext == null ? void 0 : sdkContext.apiKey;
|
|
2943
2982
|
const getAuthToken = sdkContext == null ? void 0 : sdkContext.getAuthToken;
|
|
2944
2983
|
const elationId = toFiniteElationId(input.elationId);
|
|
2984
|
+
const elationIdBig = toBigIntElationId(input.elationId);
|
|
2945
2985
|
const elationRow = usePersistentQuery(
|
|
2946
2986
|
elationPatientByIdRef,
|
|
2947
|
-
|
|
2987
|
+
elationIdBig !== void 0 ? { elationId: elationIdBig } : "skip"
|
|
2948
2988
|
);
|
|
2949
2989
|
const hintRow = usePersistentQuery(
|
|
2950
2990
|
hintPatientByIdRef,
|