@hipnation-truth/sdk 0.27.0 → 0.29.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.d.mts +462 -3
- package/dist/index.d.ts +462 -3
- package/dist/index.js +464 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +448 -1
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.ts +753 -86
- package/dist/react.js +899 -124
- package/dist/react.js.map +1 -1
- package/package.json +3 -3
package/dist/react.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use strict";
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
8
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
9
|
var __getProtoOf = Object.getPrototypeOf;
|
|
@@ -21,6 +23,7 @@ var __spreadValues = (a, b) => {
|
|
|
21
23
|
}
|
|
22
24
|
return a;
|
|
23
25
|
};
|
|
26
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
27
|
var __export = (target, all) => {
|
|
25
28
|
for (var name in all)
|
|
26
29
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -63,25 +66,41 @@ __export(react_exports, {
|
|
|
63
66
|
API_BASE_URLS: () => API_BASE_URLS,
|
|
64
67
|
CONNECTED_CALL_STATES: () => CONNECTED_CALL_STATES,
|
|
65
68
|
CONVEX_URLS: () => CONVEX_URLS2,
|
|
69
|
+
CareInboxError: () => CareInboxError,
|
|
66
70
|
DialpadCallState: () => DialpadCallState,
|
|
67
71
|
NoopStore: () => NoopStore,
|
|
68
72
|
RINGING_CALL_STATES: () => RINGING_CALL_STATES,
|
|
69
73
|
TERMINAL_CALL_STATES: () => TERMINAL_CALL_STATES,
|
|
70
74
|
TruthProvider: () => TruthProvider,
|
|
71
75
|
TruthTrackingProvider: () => TruthTrackingProvider,
|
|
76
|
+
careInboxErrorInfo: () => careInboxErrorInfo,
|
|
77
|
+
careInboxRefs: () => careInboxRefs,
|
|
78
|
+
createCareInboxSource: () => createCareInboxSource,
|
|
72
79
|
getTruthClient: () => getTruthClient,
|
|
80
|
+
isCareInboxError: () => isCareInboxError,
|
|
73
81
|
readPersistedSavedAt: () => readPersistedSavedAt,
|
|
74
82
|
resolveApiBaseUrl: () => resolveApiBaseUrl,
|
|
75
83
|
resolveConvexUrl: () => resolveConvexUrl,
|
|
84
|
+
toCareInboxError: () => toCareInboxError,
|
|
85
|
+
toEmailMailbox: () => toEmailMailbox,
|
|
86
|
+
toEmailMessage: () => toEmailMessage,
|
|
87
|
+
toEmailThreadDetail: () => toEmailThreadDetail,
|
|
88
|
+
toEmailThreadSummary: () => toEmailThreadSummary,
|
|
89
|
+
toMailboxAccess: () => toMailboxAccess,
|
|
90
|
+
toMarkReadResult: () => toMarkReadResult,
|
|
91
|
+
toThreadPage: () => toThreadPage,
|
|
92
|
+
toUnlinkedMessagePage: () => toUnlinkedMessagePage,
|
|
76
93
|
useActiveCalls: () => useActiveCalls,
|
|
77
94
|
useAppointment: () => useAppointment,
|
|
78
95
|
useAppointmentByElationId: () => useAppointmentByElationId,
|
|
79
96
|
useAppointments: () => useAppointments,
|
|
97
|
+
useCareInboxSource: () => useCareInboxSource,
|
|
80
98
|
useConversationById: () => useConversationById,
|
|
81
99
|
useConversationByPhonePair: () => useConversationByPhonePair,
|
|
82
100
|
useConversationMessages: () => useConversationMessages,
|
|
83
101
|
useConversationNotes: () => useConversationNotes,
|
|
84
102
|
useConversationNotesByPhonePair: () => useConversationNotesByPhonePair,
|
|
103
|
+
useConversationTaskHistory: () => useConversationTaskHistory,
|
|
85
104
|
useConversationTaskMarkSeen: () => useConversationTaskMarkSeen,
|
|
86
105
|
useConversationTasks: () => useConversationTasks,
|
|
87
106
|
useConversationTasksByPhonePair: () => useConversationTasksByPhonePair,
|
|
@@ -90,11 +109,19 @@ __export(react_exports, {
|
|
|
90
109
|
useDialpadCallByCallId: () => useDialpadCallByCallId,
|
|
91
110
|
useDialpadCallLog: () => useDialpadCallLog,
|
|
92
111
|
useDialpadCallsForConversation: () => useDialpadCallsForConversation,
|
|
112
|
+
useEmailThread: () => useEmailThread,
|
|
113
|
+
useEmailThreads: () => useEmailThreads,
|
|
114
|
+
useEmailUnreadCount: () => useEmailUnreadCount,
|
|
115
|
+
useLinkEmailMessage: () => useLinkEmailMessage,
|
|
116
|
+
useMailboxes: () => useMailboxes,
|
|
117
|
+
useMarkEmailThreadRead: () => useMarkEmailThreadRead,
|
|
93
118
|
useMessages: () => useMessages,
|
|
94
119
|
useNotifications: () => useNotifications,
|
|
95
120
|
useNotificationsActions: () => useNotificationsActions,
|
|
96
121
|
useOfflineEnabled: () => useOfflineEnabled,
|
|
97
122
|
useOfflineStore: () => useOfflineStore,
|
|
123
|
+
useOpenEmailThreadBodies: () => useOpenEmailThreadBodies,
|
|
124
|
+
usePaginatedEmailThreads: () => usePaginatedEmailThreads,
|
|
98
125
|
usePatient: () => usePatient,
|
|
99
126
|
usePatientBasic: () => usePatientBasic,
|
|
100
127
|
usePatientByElationId: () => usePatientByElationId,
|
|
@@ -111,11 +138,16 @@ __export(react_exports, {
|
|
|
111
138
|
usePhysiciansByElationIds: () => usePhysiciansByElationIds,
|
|
112
139
|
useRemindersForConversations: () => useRemindersForConversations,
|
|
113
140
|
useSaveCallSummary: () => useSaveCallSummary,
|
|
141
|
+
useSearchPatientsForLink: () => useSearchPatientsForLink,
|
|
142
|
+
useTaskHistory: () => useTaskHistory,
|
|
114
143
|
useTruth: () => useTruth,
|
|
115
144
|
useTruthClient: () => useTruthClient,
|
|
116
145
|
useTruthSdkContext: () => useTruthSdkContext,
|
|
146
|
+
useUnlinkEmailMessage: () => useUnlinkEmailMessage,
|
|
147
|
+
useUnlinkedEmails: () => useUnlinkedEmails,
|
|
117
148
|
useUnreadAggregate: () => useUnreadAggregate,
|
|
118
149
|
useUnreadCount: () => useUnreadCount,
|
|
150
|
+
useUrgentConversations: () => useUrgentConversations,
|
|
119
151
|
useUserSettings: () => useUserSettings,
|
|
120
152
|
useUserSync: () => useUserSync,
|
|
121
153
|
useVoicemailUrl: () => useVoicemailUrl
|
|
@@ -454,6 +486,304 @@ var AttachmentsResource = class {
|
|
|
454
486
|
}
|
|
455
487
|
};
|
|
456
488
|
|
|
489
|
+
// src/resources/care-inbox.ts
|
|
490
|
+
var NO_PARTICIPANT = { address: "", name: null };
|
|
491
|
+
function participant(p) {
|
|
492
|
+
return p ? { address: p.address, name: p.name } : __spreadValues({}, NO_PARTICIPANT);
|
|
493
|
+
}
|
|
494
|
+
function toEmailMessage(m) {
|
|
495
|
+
var _a, _b;
|
|
496
|
+
return {
|
|
497
|
+
id: m.id,
|
|
498
|
+
threadId: (_a = m.threadId) != null ? _a : "",
|
|
499
|
+
mailboxId: m.mailboxId,
|
|
500
|
+
direction: m.direction,
|
|
501
|
+
from: participant(m.from),
|
|
502
|
+
to: m.to.map(participant),
|
|
503
|
+
subject: (_b = m.subject) != null ? _b : "",
|
|
504
|
+
sentAt: m.sentAt,
|
|
505
|
+
hasAttachments: m.hasAttachments,
|
|
506
|
+
linkedPatientId: m.linkedPatientId,
|
|
507
|
+
linkedPatientName: m.linkedPatientName,
|
|
508
|
+
bodyText: m.bodyText
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
function toEmailThreadSummary(t) {
|
|
512
|
+
var _a, _b;
|
|
513
|
+
return {
|
|
514
|
+
id: t.id,
|
|
515
|
+
mailboxId: t.mailboxId,
|
|
516
|
+
subject: (_a = t.subject) != null ? _a : "",
|
|
517
|
+
lastMessageAt: t.lastMessageAt,
|
|
518
|
+
lastDirection: (_b = t.lastDirection) != null ? _b : "inbound",
|
|
519
|
+
counterpart: participant(t.counterpart),
|
|
520
|
+
messageCount: t.messageCount,
|
|
521
|
+
unreadCount: t.unreadCount,
|
|
522
|
+
unlinkedCount: t.unlinkedCount,
|
|
523
|
+
linkedPatientName: t.linkedPatientName,
|
|
524
|
+
hasAttachments: t.hasAttachments
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
function toEmailMailbox(m) {
|
|
528
|
+
var _a;
|
|
529
|
+
return {
|
|
530
|
+
id: m.id,
|
|
531
|
+
address: (_a = m.address) != null ? _a : "",
|
|
532
|
+
displayName: m.displayName,
|
|
533
|
+
mode: m.mode,
|
|
534
|
+
canSend: m.canSend,
|
|
535
|
+
bodyVisible: m.bodyVisible
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
function toMailboxAccess(a) {
|
|
539
|
+
return { mailboxes: a.mailboxes.map(toEmailMailbox), canTriage: a.canTriage };
|
|
540
|
+
}
|
|
541
|
+
function toEmailThreadDetail(d) {
|
|
542
|
+
return {
|
|
543
|
+
summary: toEmailThreadSummary(d.summary),
|
|
544
|
+
mailbox: toEmailMailbox(d.mailbox),
|
|
545
|
+
messages: d.messages.map(toEmailMessage),
|
|
546
|
+
bodyVisible: d.bodyVisible,
|
|
547
|
+
patientContact: null
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
function toThreadPage(p) {
|
|
551
|
+
return {
|
|
552
|
+
threads: p.threads.map(toEmailThreadSummary),
|
|
553
|
+
nextCursor: p.nextCursor
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
function toUnlinkedMessagePage(p) {
|
|
557
|
+
return {
|
|
558
|
+
messages: p.messages.map(toEmailMessage),
|
|
559
|
+
nextCursor: p.nextCursor
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
function toMarkReadResult(r) {
|
|
563
|
+
return { thread: toEmailThreadSummary(r.thread) };
|
|
564
|
+
}
|
|
565
|
+
var REASONS = [
|
|
566
|
+
"send_disabled",
|
|
567
|
+
"not_triage",
|
|
568
|
+
"body_gated",
|
|
569
|
+
"unauthenticated"
|
|
570
|
+
];
|
|
571
|
+
var CODES = [
|
|
572
|
+
"forbidden",
|
|
573
|
+
"not_found",
|
|
574
|
+
"offline",
|
|
575
|
+
"unavailable",
|
|
576
|
+
"validation",
|
|
577
|
+
"unknown"
|
|
578
|
+
];
|
|
579
|
+
function asReason(value) {
|
|
580
|
+
return REASONS.includes(value) ? value : null;
|
|
581
|
+
}
|
|
582
|
+
function asCode(value) {
|
|
583
|
+
return CODES.includes(value) ? value : null;
|
|
584
|
+
}
|
|
585
|
+
var CareInboxError = class extends Error {
|
|
586
|
+
constructor(code, fields = {}) {
|
|
587
|
+
var _a, _b, _c, _d;
|
|
588
|
+
const reason = (_a = fields.reason) != null ? _a : null;
|
|
589
|
+
const status = (_b = fields.status) != null ? _b : 0;
|
|
590
|
+
super(
|
|
591
|
+
`Care inbox request failed: ${code}${reason ? ` (${reason})` : ""}${status ? ` HTTP ${status}` : ""}`
|
|
592
|
+
);
|
|
593
|
+
this.name = "CareInboxError";
|
|
594
|
+
this.code = code;
|
|
595
|
+
this.status = status;
|
|
596
|
+
this.rpcCode = (_c = fields.rpcCode) != null ? _c : null;
|
|
597
|
+
this.reason = reason;
|
|
598
|
+
this.detail = (_d = fields.detail) != null ? _d : null;
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
function codeForStatus(status, rpcCode) {
|
|
602
|
+
if (status === 0) {
|
|
603
|
+
if (rpcCode === "TRANSPORT" || rpcCode === "TIMEOUT") {
|
|
604
|
+
return "offline";
|
|
605
|
+
}
|
|
606
|
+
if (rpcCode === "NO_USER_TOKEN") {
|
|
607
|
+
return "forbidden";
|
|
608
|
+
}
|
|
609
|
+
return "unknown";
|
|
610
|
+
}
|
|
611
|
+
if (status === 400) {
|
|
612
|
+
return "validation";
|
|
613
|
+
}
|
|
614
|
+
if (status === 401 || status === 403) {
|
|
615
|
+
return "forbidden";
|
|
616
|
+
}
|
|
617
|
+
if (status === 404) {
|
|
618
|
+
return "not_found";
|
|
619
|
+
}
|
|
620
|
+
if (status === 503) {
|
|
621
|
+
return "unavailable";
|
|
622
|
+
}
|
|
623
|
+
return "unknown";
|
|
624
|
+
}
|
|
625
|
+
function httpError(fields) {
|
|
626
|
+
var _a;
|
|
627
|
+
const unauthenticated = fields.status === 401 || fields.rpcCode === "NO_USER_TOKEN";
|
|
628
|
+
return new CareInboxError(codeForStatus(fields.status, fields.rpcCode), __spreadProps(__spreadValues({}, fields), {
|
|
629
|
+
reason: (_a = fields.reason) != null ? _a : unauthenticated ? "unauthenticated" : null
|
|
630
|
+
}));
|
|
631
|
+
}
|
|
632
|
+
function isCareInboxError(value) {
|
|
633
|
+
return value instanceof Error && asCode(value.code) !== null;
|
|
634
|
+
}
|
|
635
|
+
function toCareInboxError(value) {
|
|
636
|
+
if (value instanceof CareInboxError) {
|
|
637
|
+
return value;
|
|
638
|
+
}
|
|
639
|
+
const data = value && typeof value === "object" ? value.data : void 0;
|
|
640
|
+
if (data && typeof data === "object") {
|
|
641
|
+
const { code, reason } = data;
|
|
642
|
+
const known = asCode(code);
|
|
643
|
+
if (known) {
|
|
644
|
+
return new CareInboxError(known, { reason: asReason(reason) });
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
if (isCareInboxError(value)) {
|
|
648
|
+
const v = value;
|
|
649
|
+
return new CareInboxError(value.code, {
|
|
650
|
+
status: typeof v.status === "number" && Number.isInteger(v.status) && v.status >= 0 ? v.status : 0,
|
|
651
|
+
rpcCode: typeof v.rpcCode === "string" ? v.rpcCode : null,
|
|
652
|
+
reason: asReason(v.reason),
|
|
653
|
+
detail: typeof v.detail === "string" ? v.detail : null
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
return new CareInboxError("unknown");
|
|
657
|
+
}
|
|
658
|
+
function careInboxErrorInfo(err) {
|
|
659
|
+
const e = toCareInboxError(err);
|
|
660
|
+
return { code: e.code, reason: e.reason };
|
|
661
|
+
}
|
|
662
|
+
function newRequestId() {
|
|
663
|
+
const c = globalThis.crypto;
|
|
664
|
+
if (c && typeof c.randomUUID === "function") {
|
|
665
|
+
return c.randomUUID();
|
|
666
|
+
}
|
|
667
|
+
const bytes = new Uint8Array(16);
|
|
668
|
+
if (c && typeof c.getRandomValues === "function") {
|
|
669
|
+
c.getRandomValues(bytes);
|
|
670
|
+
} else {
|
|
671
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
672
|
+
bytes[i] = Math.floor(Math.random() * 256);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
bytes[6] = bytes[6] & 15 | 64;
|
|
676
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
677
|
+
const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join(
|
|
678
|
+
""
|
|
679
|
+
);
|
|
680
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
681
|
+
}
|
|
682
|
+
var _CareInboxResource = class _CareInboxResource {
|
|
683
|
+
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
684
|
+
this.baseUrl = apiBaseUrl;
|
|
685
|
+
this.auth = { apiKey, getAuthToken };
|
|
686
|
+
}
|
|
687
|
+
/** Link one message to a patient (triage only). */
|
|
688
|
+
linkMessage(input) {
|
|
689
|
+
return __async(this, null, function* () {
|
|
690
|
+
var _a;
|
|
691
|
+
return this.post("/care-inbox/link", {
|
|
692
|
+
messageId: input.messageId,
|
|
693
|
+
patientId: input.patientId,
|
|
694
|
+
requestId: (_a = input.requestId) != null ? _a : newRequestId()
|
|
695
|
+
});
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
/** Undo a manual link (triage only). */
|
|
699
|
+
unlinkMessage(input) {
|
|
700
|
+
return __async(this, null, function* () {
|
|
701
|
+
var _a;
|
|
702
|
+
return this.post("/care-inbox/unlink", {
|
|
703
|
+
messageId: input.messageId,
|
|
704
|
+
requestId: (_a = input.requestId) != null ? _a : newRequestId()
|
|
705
|
+
});
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
/** Reply into a thread. This build always rejects 403 `send_disabled`. */
|
|
709
|
+
replyToThread(input) {
|
|
710
|
+
return __async(this, null, function* () {
|
|
711
|
+
return this.post("/care-inbox/outbound/thread-reply", {
|
|
712
|
+
threadId: input.threadId,
|
|
713
|
+
body: input.body,
|
|
714
|
+
clientRequestId: input.clientRequestId
|
|
715
|
+
});
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
/** Start a new email. This build always rejects 403 `send_disabled`. */
|
|
719
|
+
composeEmail(input) {
|
|
720
|
+
return __async(this, null, function* () {
|
|
721
|
+
return this.post("/care-inbox/outbound/compose", __spreadProps(__spreadValues({
|
|
722
|
+
to: input.to,
|
|
723
|
+
subject: input.subject,
|
|
724
|
+
body: input.body
|
|
725
|
+
}, input.patientId !== void 0 ? { patientId: input.patientId } : {}), {
|
|
726
|
+
mailboxId: input.mailboxId,
|
|
727
|
+
clientRequestId: input.clientRequestId
|
|
728
|
+
}));
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
post(path, body) {
|
|
732
|
+
return __async(this, null, function* () {
|
|
733
|
+
const fail = (rpcCode) => httpError({ status: 0, rpcCode, reason: null, detail: null });
|
|
734
|
+
if (!this.auth.apiKey) {
|
|
735
|
+
throw fail("NO_API_KEY");
|
|
736
|
+
}
|
|
737
|
+
let headers;
|
|
738
|
+
try {
|
|
739
|
+
headers = yield buildAuthHeaders(this.auth, {
|
|
740
|
+
json: true,
|
|
741
|
+
requireUserToken: true
|
|
742
|
+
});
|
|
743
|
+
} catch (e) {
|
|
744
|
+
throw fail("NO_USER_TOKEN");
|
|
745
|
+
}
|
|
746
|
+
const controller = new AbortController();
|
|
747
|
+
const timeout = setTimeout(
|
|
748
|
+
() => controller.abort(),
|
|
749
|
+
_CareInboxResource.REQUEST_TIMEOUT_MS
|
|
750
|
+
);
|
|
751
|
+
let res;
|
|
752
|
+
try {
|
|
753
|
+
res = yield fetch(`${this.baseUrl}/api${path}`, {
|
|
754
|
+
method: "POST",
|
|
755
|
+
headers,
|
|
756
|
+
body: JSON.stringify(body),
|
|
757
|
+
signal: controller.signal
|
|
758
|
+
});
|
|
759
|
+
} catch (err) {
|
|
760
|
+
const isAbort = err instanceof Error && (err.name === "AbortError" || err.name === "TimeoutError");
|
|
761
|
+
throw fail(isAbort ? "TIMEOUT" : "TRANSPORT");
|
|
762
|
+
} finally {
|
|
763
|
+
clearTimeout(timeout);
|
|
764
|
+
}
|
|
765
|
+
if (!res.ok) {
|
|
766
|
+
let parsed = {};
|
|
767
|
+
try {
|
|
768
|
+
parsed = yield res.json();
|
|
769
|
+
} catch (e) {
|
|
770
|
+
}
|
|
771
|
+
const data = parsed.data && typeof parsed.data === "object" ? parsed.data : {};
|
|
772
|
+
throw httpError({
|
|
773
|
+
status: res.status,
|
|
774
|
+
rpcCode: typeof parsed.code === "string" ? parsed.code : null,
|
|
775
|
+
reason: asReason(data.reason),
|
|
776
|
+
detail: typeof parsed.message === "string" ? parsed.message.slice(0, 200) : null
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
return yield res.json();
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
};
|
|
783
|
+
/** 30s upstream timeout — matches ConversationsResource. */
|
|
784
|
+
_CareInboxResource.REQUEST_TIMEOUT_MS = 3e4;
|
|
785
|
+
var CareInboxResource = _CareInboxResource;
|
|
786
|
+
|
|
457
787
|
// src/resources/conversations.ts
|
|
458
788
|
var ConversationsError = class extends Error {
|
|
459
789
|
constructor(operation, status, message) {
|
|
@@ -616,6 +946,25 @@ var _ConversationsResource = class _ConversationsResource {
|
|
|
616
946
|
);
|
|
617
947
|
});
|
|
618
948
|
}
|
|
949
|
+
/**
|
|
950
|
+
* Mark / unmark a conversation Urgent (conversation-level, shared by
|
|
951
|
+
* participants). Refused if `userId` is not a participant.
|
|
952
|
+
*/
|
|
953
|
+
setUrgent(input) {
|
|
954
|
+
return __async(this, null, function* () {
|
|
955
|
+
if (!this.convex) {
|
|
956
|
+
throw new ConversationsError(
|
|
957
|
+
"/setUrgent",
|
|
958
|
+
0,
|
|
959
|
+
"ConversationsResource missing Convex client"
|
|
960
|
+
);
|
|
961
|
+
}
|
|
962
|
+
return yield this.convex.mutation(
|
|
963
|
+
"conversations:setUrgent",
|
|
964
|
+
input
|
|
965
|
+
);
|
|
966
|
+
});
|
|
967
|
+
}
|
|
619
968
|
/**
|
|
620
969
|
* Zero unread on every conversation the user has reads for, except
|
|
621
970
|
* those whose `providerPhone` is in `excludedProviderPhones`.
|
|
@@ -1177,6 +1526,11 @@ var _NotesResource = class _NotesResource {
|
|
|
1177
1526
|
* physician/practice in Elation, posts the note, and writes an audit
|
|
1178
1527
|
* row to `elationSyncEvents`. Replaces CommHub's `pushNotesToElation`
|
|
1179
1528
|
* Hasura action.
|
|
1529
|
+
*
|
|
1530
|
+
* Auth: requires a user token. The server runs this route under
|
|
1531
|
+
* `verifiedUserProcedure`, so the API key alone is rejected with 401 —
|
|
1532
|
+
* configure `getAuthToken` on the client. `input.initiatedBy` is ignored;
|
|
1533
|
+
* the audit row's actor is the verified JWT `sub`.
|
|
1180
1534
|
*/
|
|
1181
1535
|
pushConversationToElation(input) {
|
|
1182
1536
|
return __async(this, null, function* () {
|
|
@@ -1668,6 +2022,11 @@ var import_zod = require("zod");
|
|
|
1668
2022
|
var memberSchema = import_zod.z.object({
|
|
1669
2023
|
elationId: import_zod.z.string(),
|
|
1670
2024
|
name: import_zod.z.string(),
|
|
2025
|
+
// T6: mirrors truth's member-activation-report.ts memberSchema (T5).
|
|
2026
|
+
// Optional/nullable so a comhub build against an older/newer server
|
|
2027
|
+
// payload still parses either way.
|
|
2028
|
+
lastName: import_zod.z.string().nullable().optional(),
|
|
2029
|
+
firstName: import_zod.z.string().nullable().optional(),
|
|
1671
2030
|
doctor: import_zod.z.string().nullable(),
|
|
1672
2031
|
status: import_zod.z.enum(["activated", "outreach", "scheduled", "review", "data"]),
|
|
1673
2032
|
membershipStart: import_zod.z.string(),
|
|
@@ -2271,6 +2630,11 @@ var TruthClient = class {
|
|
|
2271
2630
|
this.convex,
|
|
2272
2631
|
config.getAuthToken
|
|
2273
2632
|
);
|
|
2633
|
+
this.careInbox = new CareInboxResource(
|
|
2634
|
+
apiUrl,
|
|
2635
|
+
config.apiKey,
|
|
2636
|
+
config.getAuthToken
|
|
2637
|
+
);
|
|
2274
2638
|
this.userSettings = new UserSettingsResource(this.convex);
|
|
2275
2639
|
this._getAuthToken = config.getAuthToken;
|
|
2276
2640
|
this._serviceWorkerPath = (_h = config.serviceWorkerPath) != null ? _h : "/truth-sw.js";
|
|
@@ -2889,9 +3253,364 @@ function useSaveCallSummary() {
|
|
|
2889
3253
|
);
|
|
2890
3254
|
}
|
|
2891
3255
|
|
|
2892
|
-
// src/react/
|
|
3256
|
+
// src/react/care-inbox.ts
|
|
3257
|
+
var import_react6 = require("convex/react");
|
|
3258
|
+
var import_react7 = require("react");
|
|
3259
|
+
|
|
3260
|
+
// src/resources/care-inbox-source.ts
|
|
2893
3261
|
var import_server3 = require("convex/server");
|
|
2894
|
-
var
|
|
3262
|
+
var careInboxRefs = {
|
|
3263
|
+
listThreadsForUser: (0, import_server3.makeFunctionReference)("careInboxQueries:listThreadsForUser"),
|
|
3264
|
+
getThread: (0, import_server3.makeFunctionReference)("careInboxQueries:getThread"),
|
|
3265
|
+
listUnlinked: (0, import_server3.makeFunctionReference)("careInboxQueries:listUnlinked"),
|
|
3266
|
+
unreadEmailCount: (0, import_server3.makeFunctionReference)("careInboxQueries:unreadEmailCount"),
|
|
3267
|
+
listMailboxesForUser: (0, import_server3.makeFunctionReference)("careInboxQueries:listMailboxesForUser"),
|
|
3268
|
+
searchPatientsForLink: (0, import_server3.makeFunctionReference)("careInboxQueries:searchPatientsForLink"),
|
|
3269
|
+
markRead: (0, import_server3.makeFunctionReference)("careInboxReads:markRead"),
|
|
3270
|
+
openThreadBodies: (0, import_server3.makeFunctionReference)("careInboxReads:openThreadBodies")
|
|
3271
|
+
};
|
|
3272
|
+
function compactArgs(args) {
|
|
3273
|
+
const out = {};
|
|
3274
|
+
for (const [k, v] of Object.entries(args)) {
|
|
3275
|
+
if (v !== void 0) {
|
|
3276
|
+
out[k] = v;
|
|
3277
|
+
}
|
|
3278
|
+
}
|
|
3279
|
+
return out;
|
|
3280
|
+
}
|
|
3281
|
+
function guarded(run) {
|
|
3282
|
+
return __async(this, null, function* () {
|
|
3283
|
+
try {
|
|
3284
|
+
return yield run();
|
|
3285
|
+
} catch (err) {
|
|
3286
|
+
throw toCareInboxError(err);
|
|
3287
|
+
}
|
|
3288
|
+
});
|
|
3289
|
+
}
|
|
3290
|
+
function createCareInboxSource({
|
|
3291
|
+
convex,
|
|
3292
|
+
careInbox
|
|
3293
|
+
}) {
|
|
3294
|
+
const q = (ref, args) => convex.query(
|
|
3295
|
+
ref,
|
|
3296
|
+
compactArgs(args)
|
|
3297
|
+
);
|
|
3298
|
+
return {
|
|
3299
|
+
listThreads: (args = {}) => guarded(
|
|
3300
|
+
() => __async(null, null, function* () {
|
|
3301
|
+
return toThreadPage(
|
|
3302
|
+
yield q(careInboxRefs.listThreadsForUser, {
|
|
3303
|
+
mailboxId: args.mailboxId,
|
|
3304
|
+
filter: args.filter,
|
|
3305
|
+
cursor: args.cursor,
|
|
3306
|
+
limit: args.limit
|
|
3307
|
+
})
|
|
3308
|
+
);
|
|
3309
|
+
})
|
|
3310
|
+
),
|
|
3311
|
+
getUnreadCount: (args = {}) => guarded(
|
|
3312
|
+
() => q(careInboxRefs.unreadEmailCount, {
|
|
3313
|
+
mailboxId: args.mailboxId
|
|
3314
|
+
})
|
|
3315
|
+
),
|
|
3316
|
+
getThread: (threadId) => guarded(() => __async(null, null, function* () {
|
|
3317
|
+
const detail = yield q(
|
|
3318
|
+
careInboxRefs.getThread,
|
|
3319
|
+
{ threadId }
|
|
3320
|
+
);
|
|
3321
|
+
if (!detail) {
|
|
3322
|
+
throw new CareInboxError("unavailable");
|
|
3323
|
+
}
|
|
3324
|
+
return toEmailThreadDetail(detail);
|
|
3325
|
+
})),
|
|
3326
|
+
listMailboxesForUser: () => guarded(
|
|
3327
|
+
() => __async(null, null, function* () {
|
|
3328
|
+
return toMailboxAccess(
|
|
3329
|
+
yield q(
|
|
3330
|
+
careInboxRefs.listMailboxesForUser,
|
|
3331
|
+
{}
|
|
3332
|
+
)
|
|
3333
|
+
);
|
|
3334
|
+
})
|
|
3335
|
+
),
|
|
3336
|
+
searchPatientsForLink: (query) => guarded(
|
|
3337
|
+
() => q(careInboxRefs.searchPatientsForLink, {
|
|
3338
|
+
q: query
|
|
3339
|
+
})
|
|
3340
|
+
),
|
|
3341
|
+
linkMessage: (args) => guarded(() => careInbox.linkMessage(args)),
|
|
3342
|
+
unlinkMessage: (args) => guarded(() => careInbox.unlinkMessage(args)),
|
|
3343
|
+
sendReply: (args) => guarded(() => careInbox.replyToThread(args)),
|
|
3344
|
+
sendEmail: (args) => guarded(() => careInbox.composeEmail(args)),
|
|
3345
|
+
markRead: ({ threadId }) => guarded(
|
|
3346
|
+
() => __async(null, null, function* () {
|
|
3347
|
+
return toMarkReadResult(
|
|
3348
|
+
yield convex.mutation(careInboxRefs.markRead, {
|
|
3349
|
+
threadId
|
|
3350
|
+
})
|
|
3351
|
+
);
|
|
3352
|
+
})
|
|
3353
|
+
)
|
|
3354
|
+
};
|
|
3355
|
+
}
|
|
3356
|
+
|
|
3357
|
+
// src/react/care-inbox.ts
|
|
3358
|
+
var SKIP2 = "skip";
|
|
3359
|
+
var DEFAULT_SEARCH_MIN_LENGTH = 2;
|
|
3360
|
+
var NOT_TRIAGE = () => new CareInboxError("forbidden", { reason: "not_triage" });
|
|
3361
|
+
function useCareInboxQuery(ref, args, project) {
|
|
3362
|
+
const { isAuthenticated } = (0, import_react6.useConvexAuth)();
|
|
3363
|
+
const skipped = args === null || !isAuthenticated;
|
|
3364
|
+
const value = (0, import_react6.useQuery)(ref, skipped ? SKIP2 : args);
|
|
3365
|
+
const data = (0, import_react7.useMemo)(
|
|
3366
|
+
() => value === void 0 ? void 0 : project(value),
|
|
3367
|
+
[value, project]
|
|
3368
|
+
);
|
|
3369
|
+
if (skipped) {
|
|
3370
|
+
return { data: void 0, loading: false, error: void 0 };
|
|
3371
|
+
}
|
|
3372
|
+
return { data, loading: value === void 0, error: void 0 };
|
|
3373
|
+
}
|
|
3374
|
+
function useCanTriage(enabled) {
|
|
3375
|
+
const { isAuthenticated } = (0, import_react6.useConvexAuth)();
|
|
3376
|
+
const access = (0, import_react6.useQuery)(
|
|
3377
|
+
careInboxRefs.listMailboxesForUser,
|
|
3378
|
+
enabled && isAuthenticated ? {} : SKIP2
|
|
3379
|
+
);
|
|
3380
|
+
return access == null ? void 0 : access.canTriage;
|
|
3381
|
+
}
|
|
3382
|
+
function triageResult(canTriage, active, inner) {
|
|
3383
|
+
if (!active) {
|
|
3384
|
+
return inner;
|
|
3385
|
+
}
|
|
3386
|
+
if (canTriage === false) {
|
|
3387
|
+
return { data: void 0, loading: false, error: NOT_TRIAGE() };
|
|
3388
|
+
}
|
|
3389
|
+
if (canTriage === void 0) {
|
|
3390
|
+
return { data: void 0, loading: true, error: void 0 };
|
|
3391
|
+
}
|
|
3392
|
+
return inner;
|
|
3393
|
+
}
|
|
3394
|
+
var projectThreadDetail = (v) => v ? toEmailThreadDetail(v) : null;
|
|
3395
|
+
var identity = (v) => v;
|
|
3396
|
+
function useEmailThreads(options = {}) {
|
|
3397
|
+
const { isAuthenticated } = (0, import_react6.useConvexAuth)();
|
|
3398
|
+
const enabled = options.enabled !== false;
|
|
3399
|
+
const triageOnly = enabled && options.filter === "unlinked";
|
|
3400
|
+
const canTriage = useCanTriage(triageOnly);
|
|
3401
|
+
const inner = useCareInboxQuery(
|
|
3402
|
+
careInboxRefs.listThreadsForUser,
|
|
3403
|
+
!enabled || triageOnly && canTriage !== true ? null : compactArgs({
|
|
3404
|
+
mailboxId: options.mailboxId,
|
|
3405
|
+
filter: options.filter,
|
|
3406
|
+
cursor: options.cursor,
|
|
3407
|
+
limit: options.limit
|
|
3408
|
+
}),
|
|
3409
|
+
toThreadPage
|
|
3410
|
+
);
|
|
3411
|
+
return triageResult(canTriage, triageOnly && isAuthenticated, inner);
|
|
3412
|
+
}
|
|
3413
|
+
function usePaginatedEmailThreads(options = {}) {
|
|
3414
|
+
var _a, _b, _c;
|
|
3415
|
+
const { isAuthenticated } = (0, import_react6.useConvexAuth)();
|
|
3416
|
+
const enabled = options.enabled !== false;
|
|
3417
|
+
const triageOnly = enabled && options.filter === "unlinked";
|
|
3418
|
+
const canTriage = useCanTriage(triageOnly);
|
|
3419
|
+
const key = `${(_a = options.mailboxId) != null ? _a : ""}|${(_b = options.filter) != null ? _b : "all"}|${(_c = options.limit) != null ? _c : ""}`;
|
|
3420
|
+
const [state, setState] = (0, import_react7.useState)({ key, cursors: [null] });
|
|
3421
|
+
const cursors = state.key === key ? state.cursors : [null];
|
|
3422
|
+
const triageBlocked = triageOnly && canTriage !== true;
|
|
3423
|
+
const skipped = !enabled || !isAuthenticated || triageBlocked;
|
|
3424
|
+
const requests = {};
|
|
3425
|
+
if (!skipped) {
|
|
3426
|
+
cursors.forEach((cursor, i) => {
|
|
3427
|
+
requests[String(i)] = {
|
|
3428
|
+
query: careInboxRefs.listThreadsForUser,
|
|
3429
|
+
args: compactArgs({
|
|
3430
|
+
mailboxId: options.mailboxId,
|
|
3431
|
+
filter: options.filter,
|
|
3432
|
+
limit: options.limit,
|
|
3433
|
+
cursor
|
|
3434
|
+
})
|
|
3435
|
+
};
|
|
3436
|
+
});
|
|
3437
|
+
}
|
|
3438
|
+
const results = (0, import_react6.useQueries)(requests);
|
|
3439
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3440
|
+
const threads = [];
|
|
3441
|
+
let pending = -1;
|
|
3442
|
+
let error;
|
|
3443
|
+
let nextCursor = null;
|
|
3444
|
+
for (let i = 0; i < cursors.length; i++) {
|
|
3445
|
+
const page = results[String(i)];
|
|
3446
|
+
if (page === void 0) {
|
|
3447
|
+
pending = i;
|
|
3448
|
+
break;
|
|
3449
|
+
}
|
|
3450
|
+
if (page instanceof Error) {
|
|
3451
|
+
error = toCareInboxError(page);
|
|
3452
|
+
break;
|
|
3453
|
+
}
|
|
3454
|
+
for (const t of page.threads) {
|
|
3455
|
+
if (!seen.has(t.id)) {
|
|
3456
|
+
seen.add(t.id);
|
|
3457
|
+
threads.push(toEmailThreadSummary(t));
|
|
3458
|
+
}
|
|
3459
|
+
}
|
|
3460
|
+
nextCursor = page.nextCursor;
|
|
3461
|
+
}
|
|
3462
|
+
const settled = !skipped && pending === -1 && !error;
|
|
3463
|
+
const hasMore = settled && nextCursor !== null;
|
|
3464
|
+
const loadMore = (0, import_react7.useCallback)(() => {
|
|
3465
|
+
if (!hasMore || nextCursor === null) {
|
|
3466
|
+
return;
|
|
3467
|
+
}
|
|
3468
|
+
const next = nextCursor;
|
|
3469
|
+
setState((s) => {
|
|
3470
|
+
const base = s.key === key ? s.cursors : [null];
|
|
3471
|
+
return base.includes(next) ? s : { key, cursors: [...base, next] };
|
|
3472
|
+
});
|
|
3473
|
+
}, [hasMore, nextCursor, key]);
|
|
3474
|
+
if (skipped) {
|
|
3475
|
+
const waitingForTriage = isAuthenticated && triageBlocked && canTriage === void 0;
|
|
3476
|
+
return {
|
|
3477
|
+
data: void 0,
|
|
3478
|
+
loading: waitingForTriage,
|
|
3479
|
+
loadingMore: false,
|
|
3480
|
+
error: isAuthenticated && triageBlocked && canTriage === false ? NOT_TRIAGE() : void 0,
|
|
3481
|
+
hasMore: false,
|
|
3482
|
+
loadMore
|
|
3483
|
+
};
|
|
3484
|
+
}
|
|
3485
|
+
return {
|
|
3486
|
+
data: pending === 0 || error && threads.length === 0 ? void 0 : threads,
|
|
3487
|
+
loading: pending === 0,
|
|
3488
|
+
loadingMore: pending > 0,
|
|
3489
|
+
error,
|
|
3490
|
+
hasMore,
|
|
3491
|
+
loadMore
|
|
3492
|
+
};
|
|
3493
|
+
}
|
|
3494
|
+
function useEmailThread(threadId) {
|
|
3495
|
+
return useCareInboxQuery(
|
|
3496
|
+
careInboxRefs.getThread,
|
|
3497
|
+
threadId ? { threadId } : null,
|
|
3498
|
+
projectThreadDetail
|
|
3499
|
+
);
|
|
3500
|
+
}
|
|
3501
|
+
function useUnlinkedEmails(options) {
|
|
3502
|
+
const { isAuthenticated } = (0, import_react6.useConvexAuth)();
|
|
3503
|
+
const enabled = options.enabled !== false && Boolean(options.mailboxId);
|
|
3504
|
+
const canTriage = useCanTriage(enabled);
|
|
3505
|
+
const inner = useCareInboxQuery(
|
|
3506
|
+
careInboxRefs.listUnlinked,
|
|
3507
|
+
enabled && canTriage === true ? compactArgs({
|
|
3508
|
+
mailboxId: options.mailboxId,
|
|
3509
|
+
cursor: options.cursor,
|
|
3510
|
+
limit: options.limit
|
|
3511
|
+
}) : null,
|
|
3512
|
+
toUnlinkedMessagePage
|
|
3513
|
+
);
|
|
3514
|
+
return triageResult(canTriage, enabled && isAuthenticated, inner);
|
|
3515
|
+
}
|
|
3516
|
+
function useEmailUnreadCount(options = {}) {
|
|
3517
|
+
return useCareInboxQuery(
|
|
3518
|
+
careInboxRefs.unreadEmailCount,
|
|
3519
|
+
options.enabled === false ? null : compactArgs({ mailboxId: options.mailboxId }),
|
|
3520
|
+
identity
|
|
3521
|
+
);
|
|
3522
|
+
}
|
|
3523
|
+
function useMailboxes(options = {}) {
|
|
3524
|
+
return useCareInboxQuery(
|
|
3525
|
+
careInboxRefs.listMailboxesForUser,
|
|
3526
|
+
options.enabled === false ? null : {},
|
|
3527
|
+
toMailboxAccess
|
|
3528
|
+
);
|
|
3529
|
+
}
|
|
3530
|
+
function useSearchPatientsForLink(q, options = {}) {
|
|
3531
|
+
var _a, _b;
|
|
3532
|
+
const trimmed = (_a = q == null ? void 0 : q.trim()) != null ? _a : "";
|
|
3533
|
+
const minLength = Math.max(1, (_b = options.minLength) != null ? _b : DEFAULT_SEARCH_MIN_LENGTH);
|
|
3534
|
+
const { isAuthenticated } = (0, import_react6.useConvexAuth)();
|
|
3535
|
+
const enabled = options.enabled !== false;
|
|
3536
|
+
const canTriage = useCanTriage(enabled);
|
|
3537
|
+
const inner = useCareInboxQuery(
|
|
3538
|
+
careInboxRefs.searchPatientsForLink,
|
|
3539
|
+
enabled && canTriage === true && trimmed.length >= minLength ? { q: trimmed } : null,
|
|
3540
|
+
identity
|
|
3541
|
+
);
|
|
3542
|
+
return triageResult(canTriage, enabled && isAuthenticated, inner);
|
|
3543
|
+
}
|
|
3544
|
+
function useLinkEmailMessage() {
|
|
3545
|
+
const client = useTruthClient();
|
|
3546
|
+
return (0, import_react7.useCallback)(
|
|
3547
|
+
(input) => client.careInbox.linkMessage(input),
|
|
3548
|
+
[client]
|
|
3549
|
+
);
|
|
3550
|
+
}
|
|
3551
|
+
function useUnlinkEmailMessage() {
|
|
3552
|
+
const client = useTruthClient();
|
|
3553
|
+
return (0, import_react7.useCallback)(
|
|
3554
|
+
(input) => client.careInbox.unlinkMessage(input),
|
|
3555
|
+
[client]
|
|
3556
|
+
);
|
|
3557
|
+
}
|
|
3558
|
+
function useMarkEmailThreadRead() {
|
|
3559
|
+
const mutate = (0, import_react6.useMutation)(
|
|
3560
|
+
careInboxRefs.markRead
|
|
3561
|
+
);
|
|
3562
|
+
return (0, import_react7.useCallback)(
|
|
3563
|
+
(threadId) => __async(null, null, function* () {
|
|
3564
|
+
try {
|
|
3565
|
+
return toMarkReadResult(
|
|
3566
|
+
yield mutate({ threadId })
|
|
3567
|
+
);
|
|
3568
|
+
} catch (err) {
|
|
3569
|
+
throw toCareInboxError(err);
|
|
3570
|
+
}
|
|
3571
|
+
}),
|
|
3572
|
+
[mutate]
|
|
3573
|
+
);
|
|
3574
|
+
}
|
|
3575
|
+
function useOpenEmailThreadBodies() {
|
|
3576
|
+
const mutate = (0, import_react6.useMutation)(
|
|
3577
|
+
careInboxRefs.openThreadBodies
|
|
3578
|
+
);
|
|
3579
|
+
return (0, import_react7.useCallback)(
|
|
3580
|
+
(threadId) => __async(null, null, function* () {
|
|
3581
|
+
try {
|
|
3582
|
+
return yield mutate({ threadId });
|
|
3583
|
+
} catch (err) {
|
|
3584
|
+
throw toCareInboxError(err);
|
|
3585
|
+
}
|
|
3586
|
+
}),
|
|
3587
|
+
[mutate]
|
|
3588
|
+
);
|
|
3589
|
+
}
|
|
3590
|
+
var NOT_READY = {
|
|
3591
|
+
query: () => Promise.reject(
|
|
3592
|
+
new CareInboxError("forbidden", { reason: "unauthenticated" })
|
|
3593
|
+
),
|
|
3594
|
+
mutation: () => Promise.reject(
|
|
3595
|
+
new CareInboxError("forbidden", { reason: "unauthenticated" })
|
|
3596
|
+
)
|
|
3597
|
+
};
|
|
3598
|
+
function useCareInboxSource() {
|
|
3599
|
+
const convex = (0, import_react6.useConvex)();
|
|
3600
|
+
const client = useTruthClient();
|
|
3601
|
+
const { isAuthenticated } = (0, import_react6.useConvexAuth)();
|
|
3602
|
+
return (0, import_react7.useMemo)(
|
|
3603
|
+
() => createCareInboxSource({
|
|
3604
|
+
convex: isAuthenticated ? convex : NOT_READY,
|
|
3605
|
+
careInbox: client.careInbox
|
|
3606
|
+
}),
|
|
3607
|
+
[convex, client, isAuthenticated]
|
|
3608
|
+
);
|
|
3609
|
+
}
|
|
3610
|
+
|
|
3611
|
+
// src/react/conversation-by-id.ts
|
|
3612
|
+
var import_server4 = require("convex/server");
|
|
3613
|
+
var conversationsGetByIdRef = (0, import_server4.makeFunctionReference)("conversations:getById");
|
|
2895
3614
|
function useConversationById(id) {
|
|
2896
3615
|
const skipped = !id;
|
|
2897
3616
|
const result = usePersistentQuery(
|
|
@@ -2909,20 +3628,23 @@ function useConversationById(id) {
|
|
|
2909
3628
|
}
|
|
2910
3629
|
|
|
2911
3630
|
// src/react/conversations.ts
|
|
2912
|
-
var
|
|
2913
|
-
var
|
|
2914
|
-
var conversationsListForUserRef = (0,
|
|
2915
|
-
var
|
|
2916
|
-
var
|
|
2917
|
-
var
|
|
2918
|
-
var
|
|
2919
|
-
var
|
|
2920
|
-
var
|
|
2921
|
-
var
|
|
2922
|
-
var
|
|
2923
|
-
var
|
|
2924
|
-
var
|
|
2925
|
-
var
|
|
3631
|
+
var import_server5 = require("convex/server");
|
|
3632
|
+
var import_react8 = require("react");
|
|
3633
|
+
var conversationsListForUserRef = (0, import_server5.makeFunctionReference)("conversations:listForUser");
|
|
3634
|
+
var conversationsListUrgentForUserRef = (0, import_server5.makeFunctionReference)("conversations:listUrgentForUser");
|
|
3635
|
+
var conversationsSearchForUserRef = (0, import_server5.makeFunctionReference)("conversations:searchForUser");
|
|
3636
|
+
var conversationsGetUnreadTotalForUserRef = (0, import_server5.makeFunctionReference)("conversations:getUnreadTotalForUser");
|
|
3637
|
+
var conversationsGetUnreadAggregateForUserRef = (0, import_server5.makeFunctionReference)("conversations:getUnreadAggregateForUser");
|
|
3638
|
+
var conversationsGetByPhonePairRef = (0, import_server5.makeFunctionReference)("conversations:getByPhonePair");
|
|
3639
|
+
var conversationMessagesGetByConversationIdRef = (0, import_server5.makeFunctionReference)("conversationMessages:getByConversationId");
|
|
3640
|
+
var conversationNotesListForConversationRef = (0, import_server5.makeFunctionReference)("conversationNotes:listForConversation");
|
|
3641
|
+
var conversationTasksListForConversationRef = (0, import_server5.makeFunctionReference)("conversationTasks:listForConversation");
|
|
3642
|
+
var conversationNotesListByPhonePairRef = (0, import_server5.makeFunctionReference)("conversationNotes:listByPhonePair");
|
|
3643
|
+
var conversationTasksListByPhonePairRef = (0, import_server5.makeFunctionReference)("conversationTasks:listByPhonePair");
|
|
3644
|
+
var taskEventsListForTaskRef = (0, import_server5.makeFunctionReference)("taskEvents:listForTask");
|
|
3645
|
+
var taskEventsListForConversationRef = (0, import_server5.makeFunctionReference)("taskEvents:listForConversation");
|
|
3646
|
+
var conversationTasksListForUserRef = (0, import_server5.makeFunctionReference)("conversationTasks:listForUser");
|
|
3647
|
+
var SKIP3 = "skip";
|
|
2926
3648
|
function toResult2(value, skipped) {
|
|
2927
3649
|
if (skipped) {
|
|
2928
3650
|
return { data: void 0, loading: false, error: void 0 };
|
|
@@ -2940,14 +3662,14 @@ function useConversations(filters) {
|
|
|
2940
3662
|
const skipped = !filters.userId;
|
|
2941
3663
|
const listResult = usePersistentQuery(
|
|
2942
3664
|
conversationsListForUserRef,
|
|
2943
|
-
skipped || isSearchMode ?
|
|
3665
|
+
skipped || isSearchMode ? SKIP3 : {
|
|
2944
3666
|
userId: filters.userId,
|
|
2945
3667
|
limit: filters.limit
|
|
2946
3668
|
}
|
|
2947
3669
|
);
|
|
2948
3670
|
const searchResult = usePersistentQuery(
|
|
2949
3671
|
conversationsSearchForUserRef,
|
|
2950
|
-
skipped || !isSearchMode ?
|
|
3672
|
+
skipped || !isSearchMode ? SKIP3 : {
|
|
2951
3673
|
userId: filters.userId,
|
|
2952
3674
|
search: trimmedSearch,
|
|
2953
3675
|
limit: filters.limit
|
|
@@ -2955,11 +3677,19 @@ function useConversations(filters) {
|
|
|
2955
3677
|
);
|
|
2956
3678
|
return toResult2(isSearchMode ? searchResult : listResult, skipped);
|
|
2957
3679
|
}
|
|
3680
|
+
function useUrgentConversations(filters) {
|
|
3681
|
+
const skipped = !filters.userId;
|
|
3682
|
+
const result = usePersistentQuery(
|
|
3683
|
+
conversationsListUrgentForUserRef,
|
|
3684
|
+
skipped ? SKIP3 : { userId: filters.userId, limit: filters.limit }
|
|
3685
|
+
);
|
|
3686
|
+
return toResult2(result, skipped);
|
|
3687
|
+
}
|
|
2958
3688
|
function useConversationByPhonePair(phonePair) {
|
|
2959
3689
|
const skipped = !phonePair;
|
|
2960
3690
|
const result = usePersistentQuery(
|
|
2961
3691
|
conversationsGetByPhonePairRef,
|
|
2962
|
-
skipped ?
|
|
3692
|
+
skipped ? SKIP3 : { phonePair }
|
|
2963
3693
|
);
|
|
2964
3694
|
return toResult2(result, skipped);
|
|
2965
3695
|
}
|
|
@@ -2967,7 +3697,7 @@ function useMessages(conversationId, options) {
|
|
|
2967
3697
|
const skipped = !conversationId;
|
|
2968
3698
|
const result = usePersistentQuery(
|
|
2969
3699
|
conversationMessagesGetByConversationIdRef,
|
|
2970
|
-
skipped ?
|
|
3700
|
+
skipped ? SKIP3 : {
|
|
2971
3701
|
conversationId,
|
|
2972
3702
|
limit: options == null ? void 0 : options.limit
|
|
2973
3703
|
}
|
|
@@ -2978,7 +3708,7 @@ function useUnreadCount(userId) {
|
|
|
2978
3708
|
const skipped = !userId;
|
|
2979
3709
|
const result = usePersistentQuery(
|
|
2980
3710
|
conversationsGetUnreadTotalForUserRef,
|
|
2981
|
-
skipped ?
|
|
3711
|
+
skipped ? SKIP3 : { userId }
|
|
2982
3712
|
);
|
|
2983
3713
|
return toResult2(result, skipped);
|
|
2984
3714
|
}
|
|
@@ -2988,7 +3718,7 @@ function useUnreadAggregate(userId, options) {
|
|
|
2988
3718
|
const stablePhones = useMemoizedPhones(phones);
|
|
2989
3719
|
const result = usePersistentQuery(
|
|
2990
3720
|
conversationsGetUnreadAggregateForUserRef,
|
|
2991
|
-
skipped ?
|
|
3721
|
+
skipped ? SKIP3 : {
|
|
2992
3722
|
userId,
|
|
2993
3723
|
providerPhones: stablePhones
|
|
2994
3724
|
}
|
|
@@ -2997,7 +3727,7 @@ function useUnreadAggregate(userId, options) {
|
|
|
2997
3727
|
}
|
|
2998
3728
|
function useMemoizedPhones(phones) {
|
|
2999
3729
|
const key = phones ? [...phones].sort().join("|") : "";
|
|
3000
|
-
return (0,
|
|
3730
|
+
return (0, import_react8.useMemo)(
|
|
3001
3731
|
() => (phones == null ? void 0 : phones.length) ? [...phones].sort() : void 0,
|
|
3002
3732
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3003
3733
|
[key]
|
|
@@ -3007,7 +3737,7 @@ function useConversationNotes(conversationId) {
|
|
|
3007
3737
|
const skipped = !conversationId;
|
|
3008
3738
|
const result = usePersistentQuery(
|
|
3009
3739
|
conversationNotesListForConversationRef,
|
|
3010
|
-
skipped ?
|
|
3740
|
+
skipped ? SKIP3 : { conversationId }
|
|
3011
3741
|
);
|
|
3012
3742
|
return toResult2(result, skipped);
|
|
3013
3743
|
}
|
|
@@ -3015,7 +3745,7 @@ function useConversationTasks(conversationId) {
|
|
|
3015
3745
|
const skipped = !conversationId;
|
|
3016
3746
|
const result = usePersistentQuery(
|
|
3017
3747
|
conversationTasksListForConversationRef,
|
|
3018
|
-
skipped ?
|
|
3748
|
+
skipped ? SKIP3 : { conversationId }
|
|
3019
3749
|
);
|
|
3020
3750
|
return toResult2(result, skipped);
|
|
3021
3751
|
}
|
|
@@ -3023,7 +3753,7 @@ function useConversationNotesByPhonePair(phonePair) {
|
|
|
3023
3753
|
const skipped = !phonePair;
|
|
3024
3754
|
const result = usePersistentQuery(
|
|
3025
3755
|
conversationNotesListByPhonePairRef,
|
|
3026
|
-
skipped ?
|
|
3756
|
+
skipped ? SKIP3 : { phonePair }
|
|
3027
3757
|
);
|
|
3028
3758
|
return toResult2(result, skipped);
|
|
3029
3759
|
}
|
|
@@ -3031,7 +3761,7 @@ function useConversationTasksForUser(userId, options) {
|
|
|
3031
3761
|
const skipped = !userId;
|
|
3032
3762
|
const result = usePersistentQuery(
|
|
3033
3763
|
conversationTasksListForUserRef,
|
|
3034
|
-
skipped ?
|
|
3764
|
+
skipped ? SKIP3 : { userId, limit: options == null ? void 0 : options.limit }
|
|
3035
3765
|
);
|
|
3036
3766
|
return toResult2(result, skipped);
|
|
3037
3767
|
}
|
|
@@ -3039,21 +3769,37 @@ function useConversationTasksByPhonePair(phonePair) {
|
|
|
3039
3769
|
const skipped = !phonePair;
|
|
3040
3770
|
const result = usePersistentQuery(
|
|
3041
3771
|
conversationTasksListByPhonePairRef,
|
|
3042
|
-
skipped ?
|
|
3772
|
+
skipped ? SKIP3 : { phonePair }
|
|
3773
|
+
);
|
|
3774
|
+
return toResult2(result, skipped);
|
|
3775
|
+
}
|
|
3776
|
+
function useTaskHistory(taskId, options) {
|
|
3777
|
+
const skipped = !taskId;
|
|
3778
|
+
const result = usePersistentQuery(
|
|
3779
|
+
taskEventsListForTaskRef,
|
|
3780
|
+
skipped ? SKIP3 : { taskId, limit: options == null ? void 0 : options.limit }
|
|
3781
|
+
);
|
|
3782
|
+
return toResult2(result, skipped);
|
|
3783
|
+
}
|
|
3784
|
+
function useConversationTaskHistory(conversationId, options) {
|
|
3785
|
+
const skipped = !conversationId;
|
|
3786
|
+
const result = usePersistentQuery(
|
|
3787
|
+
taskEventsListForConversationRef,
|
|
3788
|
+
skipped ? SKIP3 : { conversationId, limit: options == null ? void 0 : options.limit }
|
|
3043
3789
|
);
|
|
3044
3790
|
return toResult2(result, skipped);
|
|
3045
3791
|
}
|
|
3046
3792
|
|
|
3047
3793
|
// src/react/hooks.ts
|
|
3048
|
-
var
|
|
3049
|
-
var
|
|
3050
|
-
var patientsListRef = (0,
|
|
3051
|
-
var patientsGetRef = (0,
|
|
3052
|
-
var patientsByElationIdRef = (0,
|
|
3053
|
-
var patientsByHintIdRef = (0,
|
|
3054
|
-
var appointmentsListRef = (0,
|
|
3055
|
-
var appointmentsGetRef = (0,
|
|
3056
|
-
var appointmentsByElationIdRef = (0,
|
|
3794
|
+
var import_react9 = require("react");
|
|
3795
|
+
var import_server6 = require("convex/server");
|
|
3796
|
+
var patientsListRef = (0, import_server6.makeFunctionReference)("patients:list");
|
|
3797
|
+
var patientsGetRef = (0, import_server6.makeFunctionReference)("patients:get");
|
|
3798
|
+
var patientsByElationIdRef = (0, import_server6.makeFunctionReference)("patients:getByElationId");
|
|
3799
|
+
var patientsByHintIdRef = (0, import_server6.makeFunctionReference)("patients:getByHintId");
|
|
3800
|
+
var appointmentsListRef = (0, import_server6.makeFunctionReference)("appointments:list");
|
|
3801
|
+
var appointmentsGetRef = (0, import_server6.makeFunctionReference)("appointments:get");
|
|
3802
|
+
var appointmentsByElationIdRef = (0, import_server6.makeFunctionReference)("appointments:getByElationId");
|
|
3057
3803
|
function usePatients(options) {
|
|
3058
3804
|
return usePersistentQuery(patientsListRef, options != null ? options : {});
|
|
3059
3805
|
}
|
|
@@ -3086,8 +3832,8 @@ function useAppointmentByElationId(elationId) {
|
|
|
3086
3832
|
elationId
|
|
3087
3833
|
});
|
|
3088
3834
|
}
|
|
3089
|
-
var physiciansGetByElationIdsRef = (0,
|
|
3090
|
-
var physiciansGetByElationIdRef = (0,
|
|
3835
|
+
var physiciansGetByElationIdsRef = (0, import_server6.makeFunctionReference)("physicians:getByElationIds");
|
|
3836
|
+
var physiciansGetByElationIdRef = (0, import_server6.makeFunctionReference)("physicians:getByElationId");
|
|
3091
3837
|
function usePhysiciansByElationIds(ids) {
|
|
3092
3838
|
return usePersistentQuery(
|
|
3093
3839
|
physiciansGetByElationIdsRef,
|
|
@@ -3100,10 +3846,10 @@ function usePhysicianByElationId(id) {
|
|
|
3100
3846
|
id !== void 0 ? { id } : "skip"
|
|
3101
3847
|
);
|
|
3102
3848
|
}
|
|
3103
|
-
var medicationsByPatientRef = (0,
|
|
3104
|
-
var problemsByPatientRef = (0,
|
|
3105
|
-
var allergiesByPatientRef = (0,
|
|
3106
|
-
var appointmentsByPatientRef = (0,
|
|
3849
|
+
var medicationsByPatientRef = (0, import_server6.makeFunctionReference)("medicalRecords:getMedicationsByElationPatient");
|
|
3850
|
+
var problemsByPatientRef = (0, import_server6.makeFunctionReference)("medicalRecords:getProblemsByElationPatient");
|
|
3851
|
+
var allergiesByPatientRef = (0, import_server6.makeFunctionReference)("medicalRecords:getAllergiesByElationPatient");
|
|
3852
|
+
var appointmentsByPatientRef = (0, import_server6.makeFunctionReference)("medicalRecords:getAppointmentsByElationPatient");
|
|
3107
3853
|
function postPatientRefresh(url, apiKey, getAuthToken, body, signal) {
|
|
3108
3854
|
return __async(this, null, function* () {
|
|
3109
3855
|
const headers = yield buildAuthHeaders(
|
|
@@ -3141,7 +3887,7 @@ function usePatientMedical(elationId, options) {
|
|
|
3141
3887
|
appointmentsByPatientRef,
|
|
3142
3888
|
id !== void 0 ? { elationPatientId: id } : "skip"
|
|
3143
3889
|
);
|
|
3144
|
-
(0,
|
|
3890
|
+
(0, import_react9.useEffect)(() => {
|
|
3145
3891
|
if (id === void 0 || (options == null ? void 0 : options.skipRefresh)) {
|
|
3146
3892
|
return;
|
|
3147
3893
|
}
|
|
@@ -3161,10 +3907,10 @@ function usePatientMedical(elationId, options) {
|
|
|
3161
3907
|
}, [id, apiBaseUrl, apiKey, getAuthToken, options == null ? void 0 : options.skipRefresh]);
|
|
3162
3908
|
return { medications, problems, allergies, appointments };
|
|
3163
3909
|
}
|
|
3164
|
-
var elationPatientByIdRef = (0,
|
|
3165
|
-
var hintPatientByIdRef = (0,
|
|
3166
|
-
var pharmacyByNcpdpRef = (0,
|
|
3167
|
-
var patientPhotoByIdRef = (0,
|
|
3910
|
+
var elationPatientByIdRef = (0, import_server6.makeFunctionReference)("elationPatients:getByElationId");
|
|
3911
|
+
var hintPatientByIdRef = (0, import_server6.makeFunctionReference)("hintPatients:getByHintId");
|
|
3912
|
+
var pharmacyByNcpdpRef = (0, import_server6.makeFunctionReference)("elationPharmacies:getByNcpdpId");
|
|
3913
|
+
var patientPhotoByIdRef = (0, import_server6.makeFunctionReference)("elationPatientPhotos:getByElationPatientId");
|
|
3168
3914
|
function usePatientBasic(input, options) {
|
|
3169
3915
|
var _a, _b, _c, _d;
|
|
3170
3916
|
const sdkContext = useTruthSdkContext();
|
|
@@ -3181,7 +3927,7 @@ function usePatientBasic(input, options) {
|
|
|
3181
3927
|
hintPatientByIdRef,
|
|
3182
3928
|
input.hintId !== void 0 ? { hintId: input.hintId } : "skip"
|
|
3183
3929
|
);
|
|
3184
|
-
(0,
|
|
3930
|
+
(0, import_react9.useEffect)(() => {
|
|
3185
3931
|
if (options == null ? void 0 : options.skipRefresh) {
|
|
3186
3932
|
return;
|
|
3187
3933
|
}
|
|
@@ -3238,7 +3984,7 @@ function usePatientPhoto(elationId, options) {
|
|
|
3238
3984
|
patientPhotoByIdRef,
|
|
3239
3985
|
id !== void 0 ? { elationPatientId: id } : "skip"
|
|
3240
3986
|
);
|
|
3241
|
-
(0,
|
|
3987
|
+
(0, import_react9.useEffect)(() => {
|
|
3242
3988
|
if (options == null ? void 0 : options.skipRefresh) {
|
|
3243
3989
|
return;
|
|
3244
3990
|
}
|
|
@@ -3261,8 +4007,8 @@ function usePatientPhoto(elationId, options) {
|
|
|
3261
4007
|
}, [id, apiBaseUrl, apiKey, getAuthToken, options == null ? void 0 : options.skipRefresh]);
|
|
3262
4008
|
return photo;
|
|
3263
4009
|
}
|
|
3264
|
-
var messagesByPhonesRef = (0,
|
|
3265
|
-
var messagesByConversationIdRef = (0,
|
|
4010
|
+
var messagesByPhonesRef = (0, import_server6.makeFunctionReference)("conversationMessages:getByPhones");
|
|
4011
|
+
var messagesByConversationIdRef = (0, import_server6.makeFunctionReference)("conversationMessages:getByConversationId");
|
|
3266
4012
|
function useConversationMessages(input, options) {
|
|
3267
4013
|
const hasPair = !!input.phoneA && !!input.phoneB;
|
|
3268
4014
|
const byPair = usePersistentQuery(
|
|
@@ -3281,7 +4027,7 @@ function useConversationMessages(input, options) {
|
|
|
3281
4027
|
}
|
|
3282
4028
|
|
|
3283
4029
|
// src/react/notifications.ts
|
|
3284
|
-
var
|
|
4030
|
+
var import_react10 = require("react");
|
|
3285
4031
|
function loadExpo() {
|
|
3286
4032
|
return __async(this, null, function* () {
|
|
3287
4033
|
try {
|
|
@@ -3297,13 +4043,13 @@ function useNotifications(options) {
|
|
|
3297
4043
|
const apiBaseUrl = (_b = (_a = options.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _b : "";
|
|
3298
4044
|
const apiKey = (_d = (_c = options.apiKey) != null ? _c : sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _d : "";
|
|
3299
4045
|
const getAuthToken = sdkContext == null ? void 0 : sdkContext.getAuthToken;
|
|
3300
|
-
const [permissionStatus, setPermissionStatus] = (0,
|
|
3301
|
-
const [devicePushToken, setDevicePushToken] = (0,
|
|
3302
|
-
const expoRef = (0,
|
|
3303
|
-
const isWebRef = (0,
|
|
3304
|
-
const vapidKeyRef = (0,
|
|
3305
|
-
const prevUserIdRef = (0,
|
|
3306
|
-
(0,
|
|
4046
|
+
const [permissionStatus, setPermissionStatus] = (0, import_react10.useState)("unknown");
|
|
4047
|
+
const [devicePushToken, setDevicePushToken] = (0, import_react10.useState)(null);
|
|
4048
|
+
const expoRef = (0, import_react10.useRef)(null);
|
|
4049
|
+
const isWebRef = (0, import_react10.useRef)(false);
|
|
4050
|
+
const vapidKeyRef = (0, import_react10.useRef)((_e = options.vapidPublicKey) != null ? _e : null);
|
|
4051
|
+
const prevUserIdRef = (0, import_react10.useRef)(void 0);
|
|
4052
|
+
(0, import_react10.useEffect)(() => {
|
|
3307
4053
|
let mounted = true;
|
|
3308
4054
|
void (() => __async(null, null, function* () {
|
|
3309
4055
|
var _a2;
|
|
@@ -3359,7 +4105,7 @@ function useNotifications(options) {
|
|
|
3359
4105
|
mounted = false;
|
|
3360
4106
|
};
|
|
3361
4107
|
}, [apiBaseUrl, apiKey]);
|
|
3362
|
-
const register = (0,
|
|
4108
|
+
const register = (0, import_react10.useCallback)(() => __async(null, null, function* () {
|
|
3363
4109
|
var _a2, _b2;
|
|
3364
4110
|
if (!options.userId) {
|
|
3365
4111
|
return { ok: false, reason: "missing_userId" };
|
|
@@ -3482,7 +4228,7 @@ function useNotifications(options) {
|
|
|
3482
4228
|
options.appVersion,
|
|
3483
4229
|
options.serviceWorkerPath
|
|
3484
4230
|
]);
|
|
3485
|
-
const unregister = (0,
|
|
4231
|
+
const unregister = (0, import_react10.useCallback)(() => __async(null, null, function* () {
|
|
3486
4232
|
if (!devicePushToken) {
|
|
3487
4233
|
return;
|
|
3488
4234
|
}
|
|
@@ -3500,7 +4246,7 @@ function useNotifications(options) {
|
|
|
3500
4246
|
}
|
|
3501
4247
|
setDevicePushToken(null);
|
|
3502
4248
|
}), [apiBaseUrl, apiKey, getAuthToken, devicePushToken]);
|
|
3503
|
-
const addReceivedListener = (0,
|
|
4249
|
+
const addReceivedListener = (0, import_react10.useCallback)(
|
|
3504
4250
|
(listener) => {
|
|
3505
4251
|
if (isWebRef.current) {
|
|
3506
4252
|
if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) {
|
|
@@ -3529,7 +4275,7 @@ function useNotifications(options) {
|
|
|
3529
4275
|
},
|
|
3530
4276
|
[]
|
|
3531
4277
|
);
|
|
3532
|
-
const addResponseListener = (0,
|
|
4278
|
+
const addResponseListener = (0, import_react10.useCallback)(
|
|
3533
4279
|
(listener) => {
|
|
3534
4280
|
if (isWebRef.current) {
|
|
3535
4281
|
if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) {
|
|
@@ -3558,7 +4304,7 @@ function useNotifications(options) {
|
|
|
3558
4304
|
},
|
|
3559
4305
|
[]
|
|
3560
4306
|
);
|
|
3561
|
-
const getBadgeCount = (0,
|
|
4307
|
+
const getBadgeCount = (0, import_react10.useCallback)(() => __async(null, null, function* () {
|
|
3562
4308
|
var _a2;
|
|
3563
4309
|
const expo = expoRef.current;
|
|
3564
4310
|
if (!(expo == null ? void 0 : expo.getBadgeCountAsync)) {
|
|
@@ -3566,7 +4312,7 @@ function useNotifications(options) {
|
|
|
3566
4312
|
}
|
|
3567
4313
|
return (_a2 = yield expo.getBadgeCountAsync()) != null ? _a2 : 0;
|
|
3568
4314
|
}), []);
|
|
3569
|
-
const setBadgeCount = (0,
|
|
4315
|
+
const setBadgeCount = (0, import_react10.useCallback)((count) => __async(null, null, function* () {
|
|
3570
4316
|
const expo = expoRef.current;
|
|
3571
4317
|
if (!(expo == null ? void 0 : expo.setBadgeCountAsync)) {
|
|
3572
4318
|
return;
|
|
@@ -3574,7 +4320,7 @@ function useNotifications(options) {
|
|
|
3574
4320
|
yield expo.setBadgeCountAsync(count);
|
|
3575
4321
|
}), []);
|
|
3576
4322
|
const autoRegister = options.autoRegister !== false;
|
|
3577
|
-
(0,
|
|
4323
|
+
(0, import_react10.useEffect)(() => {
|
|
3578
4324
|
if (!autoRegister) {
|
|
3579
4325
|
return;
|
|
3580
4326
|
}
|
|
@@ -3613,7 +4359,7 @@ function useNotifications(options) {
|
|
|
3613
4359
|
remove == null ? void 0 : remove();
|
|
3614
4360
|
};
|
|
3615
4361
|
}, [autoRegister, options.userId, register]);
|
|
3616
|
-
(0,
|
|
4362
|
+
(0, import_react10.useEffect)(() => {
|
|
3617
4363
|
const prev = prevUserIdRef.current;
|
|
3618
4364
|
prevUserIdRef.current = options.userId;
|
|
3619
4365
|
if (!autoRegister) {
|
|
@@ -3624,7 +4370,7 @@ function useNotifications(options) {
|
|
|
3624
4370
|
}
|
|
3625
4371
|
void register();
|
|
3626
4372
|
}, [options.userId, autoRegister, register]);
|
|
3627
|
-
(0,
|
|
4373
|
+
(0, import_react10.useEffect)(() => {
|
|
3628
4374
|
if (!autoRegister) {
|
|
3629
4375
|
return;
|
|
3630
4376
|
}
|
|
@@ -3662,7 +4408,7 @@ function useNotificationsActions() {
|
|
|
3662
4408
|
const apiBaseUrl = (_a = sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _a : "";
|
|
3663
4409
|
const apiKey = (_b = sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _b : "";
|
|
3664
4410
|
const getAuthToken = sdkContext == null ? void 0 : sdkContext.getAuthToken;
|
|
3665
|
-
const post = (0,
|
|
4411
|
+
const post = (0, import_react10.useCallback)(
|
|
3666
4412
|
(path, body, opts) => __async(null, null, function* () {
|
|
3667
4413
|
if (!apiBaseUrl || !apiKey) {
|
|
3668
4414
|
throw new Error(
|
|
@@ -3692,7 +4438,7 @@ function useNotificationsActions() {
|
|
|
3692
4438
|
}),
|
|
3693
4439
|
[apiBaseUrl, apiKey, getAuthToken]
|
|
3694
4440
|
);
|
|
3695
|
-
const get = (0,
|
|
4441
|
+
const get = (0, import_react10.useCallback)(
|
|
3696
4442
|
(path, opts) => __async(null, null, function* () {
|
|
3697
4443
|
const headers = (opts == null ? void 0 : opts.requireUserToken) ? yield buildAuthHeaders(
|
|
3698
4444
|
{ apiKey, getAuthToken },
|
|
@@ -3712,22 +4458,22 @@ function useNotificationsActions() {
|
|
|
3712
4458
|
}),
|
|
3713
4459
|
[apiBaseUrl, apiKey, getAuthToken]
|
|
3714
4460
|
);
|
|
3715
|
-
const send = (0,
|
|
4461
|
+
const send = (0, import_react10.useCallback)(
|
|
3716
4462
|
(input) => post("/notifications/send", input),
|
|
3717
4463
|
[post]
|
|
3718
4464
|
);
|
|
3719
|
-
const schedule = (0,
|
|
4465
|
+
const schedule = (0, import_react10.useCallback)(
|
|
3720
4466
|
(input) => post("/notifications/schedule", input),
|
|
3721
4467
|
[post]
|
|
3722
4468
|
);
|
|
3723
|
-
const getPreferences = (0,
|
|
4469
|
+
const getPreferences = (0, import_react10.useCallback)(
|
|
3724
4470
|
(userId) => get(
|
|
3725
4471
|
`/notifications/preferences/${encodeURIComponent(userId)}`,
|
|
3726
4472
|
{ requireUserToken: true }
|
|
3727
4473
|
),
|
|
3728
4474
|
[get]
|
|
3729
4475
|
);
|
|
3730
|
-
const updatePreferences = (0,
|
|
4476
|
+
const updatePreferences = (0, import_react10.useCallback)(
|
|
3731
4477
|
(userId, prefs) => post(
|
|
3732
4478
|
`/notifications/preferences/${encodeURIComponent(userId)}`,
|
|
3733
4479
|
prefs,
|
|
@@ -3763,14 +4509,14 @@ function detectPlatform(tokenType) {
|
|
|
3763
4509
|
}
|
|
3764
4510
|
|
|
3765
4511
|
// src/react/patient-family.ts
|
|
3766
|
-
var
|
|
3767
|
-
var patientsFamilyMembersRef = (0,
|
|
3768
|
-
var
|
|
4512
|
+
var import_server7 = require("convex/server");
|
|
4513
|
+
var patientsFamilyMembersRef = (0, import_server7.makeFunctionReference)("patients:listFamilyMembers");
|
|
4514
|
+
var SKIP4 = "skip";
|
|
3769
4515
|
function usePatientFamilyMembers(input) {
|
|
3770
4516
|
const hasFamilyId = !!(input == null ? void 0 : input.familyId);
|
|
3771
4517
|
const hasPhoneNumbers = !!((input == null ? void 0 : input.phoneNumbers) && input.phoneNumbers.length > 0);
|
|
3772
4518
|
const shouldQuery = hasFamilyId || hasPhoneNumbers;
|
|
3773
|
-
const args = shouldQuery ? __spreadValues(__spreadValues(__spreadValues({}, (input == null ? void 0 : input.familyId) ? { familyId: input.familyId } : {}), (input == null ? void 0 : input.phoneNumbers) && input.phoneNumbers.length > 0 ? { phoneNumbers: input.phoneNumbers } : {}), (input == null ? void 0 : input.excludeHintId) ? { excludeHintId: input.excludeHintId } : {}) :
|
|
4519
|
+
const args = shouldQuery ? __spreadValues(__spreadValues(__spreadValues({}, (input == null ? void 0 : input.familyId) ? { familyId: input.familyId } : {}), (input == null ? void 0 : input.phoneNumbers) && input.phoneNumbers.length > 0 ? { phoneNumbers: input.phoneNumbers } : {}), (input == null ? void 0 : input.excludeHintId) ? { excludeHintId: input.excludeHintId } : {}) : SKIP4;
|
|
3774
4520
|
const result = usePersistentQuery(
|
|
3775
4521
|
patientsFamilyMembersRef,
|
|
3776
4522
|
args
|
|
@@ -3786,16 +4532,16 @@ function usePatientFamilyMembers(input) {
|
|
|
3786
4532
|
}
|
|
3787
4533
|
|
|
3788
4534
|
// src/react/patient-search.ts
|
|
3789
|
-
var
|
|
3790
|
-
var patientsSearchRef = (0,
|
|
3791
|
-
var
|
|
4535
|
+
var import_server8 = require("convex/server");
|
|
4536
|
+
var patientsSearchRef = (0, import_server8.makeFunctionReference)("patients:search");
|
|
4537
|
+
var SKIP5 = "skip";
|
|
3792
4538
|
function usePatientSearch(options) {
|
|
3793
4539
|
var _a;
|
|
3794
4540
|
const trimmedQuery = ((_a = options.query) != null ? _a : "").trim();
|
|
3795
4541
|
const skipped = trimmedQuery.length === 0;
|
|
3796
4542
|
const result = usePersistentQuery(
|
|
3797
4543
|
patientsSearchRef,
|
|
3798
|
-
skipped ?
|
|
4544
|
+
skipped ? SKIP5 : __spreadValues(__spreadValues(__spreadValues({
|
|
3799
4545
|
query: trimmedQuery
|
|
3800
4546
|
}, options.officeId ? { officeId: options.officeId } : {}), options.mode ? { mode: options.mode } : {}), options.limit !== void 0 ? { limit: options.limit } : {})
|
|
3801
4547
|
);
|
|
@@ -3810,22 +4556,22 @@ function usePatientSearch(options) {
|
|
|
3810
4556
|
}
|
|
3811
4557
|
|
|
3812
4558
|
// src/react/patients-bulk.ts
|
|
3813
|
-
var
|
|
3814
|
-
var
|
|
3815
|
-
var patientsGetByIdsRef = (0,
|
|
3816
|
-
var patientsGetByPhonesRef = (0,
|
|
3817
|
-
var
|
|
4559
|
+
var import_server9 = require("convex/server");
|
|
4560
|
+
var import_react11 = require("react");
|
|
4561
|
+
var patientsGetByIdsRef = (0, import_server9.makeFunctionReference)("patients:getByIds");
|
|
4562
|
+
var patientsGetByPhonesRef = (0, import_server9.makeFunctionReference)("patients:getByPhones");
|
|
4563
|
+
var SKIP6 = "skip";
|
|
3818
4564
|
function usePatientsByIds(ids) {
|
|
3819
|
-
const stableIds = (0,
|
|
4565
|
+
const stableIds = (0, import_react11.useMemo)(() => {
|
|
3820
4566
|
const arr = ids != null ? ids : [];
|
|
3821
4567
|
return [...new Set(arr)].sort();
|
|
3822
4568
|
}, [ids]);
|
|
3823
4569
|
const skipped = stableIds.length === 0;
|
|
3824
4570
|
const result = usePersistentQuery(
|
|
3825
4571
|
patientsGetByIdsRef,
|
|
3826
|
-
skipped ?
|
|
4572
|
+
skipped ? SKIP6 : { ids: stableIds }
|
|
3827
4573
|
);
|
|
3828
|
-
const mapped = (0,
|
|
4574
|
+
const mapped = (0, import_react11.useMemo)(() => {
|
|
3829
4575
|
if (result === void 0) {
|
|
3830
4576
|
return void 0;
|
|
3831
4577
|
}
|
|
@@ -3847,7 +4593,7 @@ function usePatientsByIds(ids) {
|
|
|
3847
4593
|
};
|
|
3848
4594
|
}
|
|
3849
4595
|
function usePatientsByPhones(phones) {
|
|
3850
|
-
const stableDigits = (0,
|
|
4596
|
+
const stableDigits = (0, import_react11.useMemo)(() => {
|
|
3851
4597
|
const arr = phones != null ? phones : [];
|
|
3852
4598
|
const digits = arr.map((p) => p.replace(/\D+/g, "")).filter((s) => s.length > 0);
|
|
3853
4599
|
return [...new Set(digits)].sort();
|
|
@@ -3855,9 +4601,9 @@ function usePatientsByPhones(phones) {
|
|
|
3855
4601
|
const skipped = stableDigits.length === 0;
|
|
3856
4602
|
const result = usePersistentQuery(
|
|
3857
4603
|
patientsGetByPhonesRef,
|
|
3858
|
-
skipped ?
|
|
4604
|
+
skipped ? SKIP6 : { phoneDigits: stableDigits }
|
|
3859
4605
|
);
|
|
3860
|
-
const mapped = (0,
|
|
4606
|
+
const mapped = (0, import_react11.useMemo)(() => {
|
|
3861
4607
|
if (result === void 0) {
|
|
3862
4608
|
return void 0;
|
|
3863
4609
|
}
|
|
@@ -3874,15 +4620,15 @@ function usePatientsByPhones(phones) {
|
|
|
3874
4620
|
}
|
|
3875
4621
|
|
|
3876
4622
|
// src/react/reminders.ts
|
|
3877
|
-
var
|
|
3878
|
-
var remindersListPendingByConversationIdsRef = (0,
|
|
3879
|
-
var
|
|
4623
|
+
var import_server10 = require("convex/server");
|
|
4624
|
+
var remindersListPendingByConversationIdsRef = (0, import_server10.makeFunctionReference)("reminders:listPendingByConversationIds");
|
|
4625
|
+
var SKIP7 = "skip";
|
|
3880
4626
|
function useRemindersForConversations(conversationIds) {
|
|
3881
4627
|
const ids = conversationIds != null ? conversationIds : [];
|
|
3882
4628
|
const skipped = ids.length === 0;
|
|
3883
4629
|
const result = usePersistentQuery(
|
|
3884
4630
|
remindersListPendingByConversationIdsRef,
|
|
3885
|
-
skipped ?
|
|
4631
|
+
skipped ? SKIP7 : { conversationIds: ids }
|
|
3886
4632
|
);
|
|
3887
4633
|
const mapped = result === void 0 ? void 0 : Object.fromEntries(result.map((r) => [r.conversationId, r]));
|
|
3888
4634
|
if (skipped) {
|
|
@@ -3896,23 +4642,23 @@ function useRemindersForConversations(conversationIds) {
|
|
|
3896
4642
|
}
|
|
3897
4643
|
|
|
3898
4644
|
// src/react/tasks.ts
|
|
3899
|
-
var
|
|
3900
|
-
var
|
|
3901
|
-
var
|
|
3902
|
-
var conversationTasksMarkSeenRef = (0,
|
|
4645
|
+
var import_react12 = require("convex/react");
|
|
4646
|
+
var import_server11 = require("convex/server");
|
|
4647
|
+
var import_react13 = require("react");
|
|
4648
|
+
var conversationTasksMarkSeenRef = (0, import_server11.makeFunctionReference)("conversationTasks:markSeen");
|
|
3903
4649
|
function useConversationTaskMarkSeen() {
|
|
3904
|
-
const mutate = (0,
|
|
4650
|
+
const mutate = (0, import_react12.useMutation)(
|
|
3905
4651
|
conversationTasksMarkSeenRef
|
|
3906
4652
|
);
|
|
3907
|
-
return (0,
|
|
4653
|
+
return (0, import_react13.useCallback)(
|
|
3908
4654
|
(taskId, userId) => mutate({ taskId, userId }),
|
|
3909
4655
|
[mutate]
|
|
3910
4656
|
);
|
|
3911
4657
|
}
|
|
3912
4658
|
|
|
3913
4659
|
// src/react/tracking.ts
|
|
3914
|
-
var
|
|
3915
|
-
var TruthTrackingContext = (0,
|
|
4660
|
+
var import_react14 = require("react");
|
|
4661
|
+
var TruthTrackingContext = (0, import_react14.createContext)(
|
|
3916
4662
|
null
|
|
3917
4663
|
);
|
|
3918
4664
|
function TruthTrackingProvider({
|
|
@@ -3925,7 +4671,7 @@ function TruthTrackingProvider({
|
|
|
3925
4671
|
}) {
|
|
3926
4672
|
var _a, _b;
|
|
3927
4673
|
const resolvedApiKey = (_b = apiKey != null ? apiKey : typeof process !== "undefined" ? (_a = process.env) == null ? void 0 : _a.EXPO_PUBLIC_TRUTH_API_KEY : void 0) != null ? _b : "";
|
|
3928
|
-
const value = (0,
|
|
4674
|
+
const value = (0, import_react14.useMemo)(() => {
|
|
3929
4675
|
const tracker = new Tracker({
|
|
3930
4676
|
apiKey: resolvedApiKey,
|
|
3931
4677
|
environment,
|
|
@@ -3944,10 +4690,10 @@ function TruthTrackingProvider({
|
|
|
3944
4690
|
}
|
|
3945
4691
|
};
|
|
3946
4692
|
}, [resolvedApiKey, environment, source, sourceVersion, tenantId]);
|
|
3947
|
-
return (0,
|
|
4693
|
+
return (0, import_react14.createElement)(TruthTrackingContext.Provider, { value }, children);
|
|
3948
4694
|
}
|
|
3949
4695
|
function useTruth() {
|
|
3950
|
-
const ctx = (0,
|
|
4696
|
+
const ctx = (0, import_react14.useContext)(TruthTrackingContext);
|
|
3951
4697
|
if (!ctx) {
|
|
3952
4698
|
throw new Error("useTruth must be used within a TruthTrackingProvider");
|
|
3953
4699
|
}
|
|
@@ -3955,14 +4701,14 @@ function useTruth() {
|
|
|
3955
4701
|
}
|
|
3956
4702
|
|
|
3957
4703
|
// src/react/user-settings.ts
|
|
3958
|
-
var
|
|
3959
|
-
var userSettingsGetByUserIdRef = (0,
|
|
3960
|
-
var
|
|
4704
|
+
var import_server12 = require("convex/server");
|
|
4705
|
+
var userSettingsGetByUserIdRef = (0, import_server12.makeFunctionReference)("userSettings:getByUserId");
|
|
4706
|
+
var SKIP8 = "skip";
|
|
3961
4707
|
function useUserSettings(userId) {
|
|
3962
4708
|
const skip = !userId;
|
|
3963
4709
|
const result = usePersistentQuery(
|
|
3964
4710
|
userSettingsGetByUserIdRef,
|
|
3965
|
-
skip ?
|
|
4711
|
+
skip ? SKIP8 : { userId }
|
|
3966
4712
|
);
|
|
3967
4713
|
if (skip) {
|
|
3968
4714
|
return { data: null, loading: false, error: void 0 };
|
|
@@ -3975,16 +4721,16 @@ function useUserSettings(userId) {
|
|
|
3975
4721
|
}
|
|
3976
4722
|
|
|
3977
4723
|
// src/react/users.ts
|
|
3978
|
-
var
|
|
4724
|
+
var import_react15 = require("react");
|
|
3979
4725
|
function useUserSync(input) {
|
|
3980
4726
|
var _a, _b, _c, _d;
|
|
3981
4727
|
const sdkContext = useTruthSdkContext();
|
|
3982
4728
|
const apiBaseUrl = (_b = (_a = input.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _b : "";
|
|
3983
4729
|
const apiKey = (_d = (_c = input.apiKey) != null ? _c : sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _d : "";
|
|
3984
4730
|
const getAuthToken = sdkContext == null ? void 0 : sdkContext.getAuthToken;
|
|
3985
|
-
const [status, setStatus] = (0,
|
|
3986
|
-
const [error, setError] = (0,
|
|
3987
|
-
const lastKeyRef = (0,
|
|
4731
|
+
const [status, setStatus] = (0, import_react15.useState)("idle");
|
|
4732
|
+
const [error, setError] = (0, import_react15.useState)(null);
|
|
4733
|
+
const lastKeyRef = (0, import_react15.useRef)(null);
|
|
3988
4734
|
const sync = () => __async(null, null, function* () {
|
|
3989
4735
|
if (!input.userId) {
|
|
3990
4736
|
return { ok: false, reason: "missing_userId" };
|
|
@@ -4028,7 +4774,7 @@ function useUserSync(input) {
|
|
|
4028
4774
|
return { ok: false, reason: message };
|
|
4029
4775
|
}
|
|
4030
4776
|
});
|
|
4031
|
-
(0,
|
|
4777
|
+
(0, import_react15.useEffect)(() => {
|
|
4032
4778
|
var _a2, _b2, _c2, _d2, _e;
|
|
4033
4779
|
if (!input.userId) {
|
|
4034
4780
|
return;
|
|
@@ -4067,13 +4813,13 @@ function useUserSync(input) {
|
|
|
4067
4813
|
}
|
|
4068
4814
|
|
|
4069
4815
|
// src/react/voicemail.ts
|
|
4070
|
-
var
|
|
4816
|
+
var import_react16 = require("react");
|
|
4071
4817
|
function useVoicemailUrl(client) {
|
|
4072
|
-
const [url, setUrl] = (0,
|
|
4073
|
-
const [isLoading, setIsLoading] = (0,
|
|
4074
|
-
const [error, setError] = (0,
|
|
4075
|
-
const inFlightRef = (0,
|
|
4076
|
-
const fetchUrl = (0,
|
|
4818
|
+
const [url, setUrl] = (0, import_react16.useState)(null);
|
|
4819
|
+
const [isLoading, setIsLoading] = (0, import_react16.useState)(false);
|
|
4820
|
+
const [error, setError] = (0, import_react16.useState)(null);
|
|
4821
|
+
const inFlightRef = (0, import_react16.useRef)(false);
|
|
4822
|
+
const fetchUrl = (0, import_react16.useCallback)(
|
|
4077
4823
|
(voicemailLink) => __async(null, null, function* () {
|
|
4078
4824
|
if (inFlightRef.current) {
|
|
4079
4825
|
return null;
|
|
@@ -4104,25 +4850,41 @@ function useVoicemailUrl(client) {
|
|
|
4104
4850
|
API_BASE_URLS,
|
|
4105
4851
|
CONNECTED_CALL_STATES,
|
|
4106
4852
|
CONVEX_URLS,
|
|
4853
|
+
CareInboxError,
|
|
4107
4854
|
DialpadCallState,
|
|
4108
4855
|
NoopStore,
|
|
4109
4856
|
RINGING_CALL_STATES,
|
|
4110
4857
|
TERMINAL_CALL_STATES,
|
|
4111
4858
|
TruthProvider,
|
|
4112
4859
|
TruthTrackingProvider,
|
|
4860
|
+
careInboxErrorInfo,
|
|
4861
|
+
careInboxRefs,
|
|
4862
|
+
createCareInboxSource,
|
|
4113
4863
|
getTruthClient,
|
|
4864
|
+
isCareInboxError,
|
|
4114
4865
|
readPersistedSavedAt,
|
|
4115
4866
|
resolveApiBaseUrl,
|
|
4116
4867
|
resolveConvexUrl,
|
|
4868
|
+
toCareInboxError,
|
|
4869
|
+
toEmailMailbox,
|
|
4870
|
+
toEmailMessage,
|
|
4871
|
+
toEmailThreadDetail,
|
|
4872
|
+
toEmailThreadSummary,
|
|
4873
|
+
toMailboxAccess,
|
|
4874
|
+
toMarkReadResult,
|
|
4875
|
+
toThreadPage,
|
|
4876
|
+
toUnlinkedMessagePage,
|
|
4117
4877
|
useActiveCalls,
|
|
4118
4878
|
useAppointment,
|
|
4119
4879
|
useAppointmentByElationId,
|
|
4120
4880
|
useAppointments,
|
|
4881
|
+
useCareInboxSource,
|
|
4121
4882
|
useConversationById,
|
|
4122
4883
|
useConversationByPhonePair,
|
|
4123
4884
|
useConversationMessages,
|
|
4124
4885
|
useConversationNotes,
|
|
4125
4886
|
useConversationNotesByPhonePair,
|
|
4887
|
+
useConversationTaskHistory,
|
|
4126
4888
|
useConversationTaskMarkSeen,
|
|
4127
4889
|
useConversationTasks,
|
|
4128
4890
|
useConversationTasksByPhonePair,
|
|
@@ -4131,11 +4893,19 @@ function useVoicemailUrl(client) {
|
|
|
4131
4893
|
useDialpadCallByCallId,
|
|
4132
4894
|
useDialpadCallLog,
|
|
4133
4895
|
useDialpadCallsForConversation,
|
|
4896
|
+
useEmailThread,
|
|
4897
|
+
useEmailThreads,
|
|
4898
|
+
useEmailUnreadCount,
|
|
4899
|
+
useLinkEmailMessage,
|
|
4900
|
+
useMailboxes,
|
|
4901
|
+
useMarkEmailThreadRead,
|
|
4134
4902
|
useMessages,
|
|
4135
4903
|
useNotifications,
|
|
4136
4904
|
useNotificationsActions,
|
|
4137
4905
|
useOfflineEnabled,
|
|
4138
4906
|
useOfflineStore,
|
|
4907
|
+
useOpenEmailThreadBodies,
|
|
4908
|
+
usePaginatedEmailThreads,
|
|
4139
4909
|
usePatient,
|
|
4140
4910
|
usePatientBasic,
|
|
4141
4911
|
usePatientByElationId,
|
|
@@ -4152,11 +4922,16 @@ function useVoicemailUrl(client) {
|
|
|
4152
4922
|
usePhysiciansByElationIds,
|
|
4153
4923
|
useRemindersForConversations,
|
|
4154
4924
|
useSaveCallSummary,
|
|
4925
|
+
useSearchPatientsForLink,
|
|
4926
|
+
useTaskHistory,
|
|
4155
4927
|
useTruth,
|
|
4156
4928
|
useTruthClient,
|
|
4157
4929
|
useTruthSdkContext,
|
|
4930
|
+
useUnlinkEmailMessage,
|
|
4931
|
+
useUnlinkedEmails,
|
|
4158
4932
|
useUnreadAggregate,
|
|
4159
4933
|
useUnreadCount,
|
|
4934
|
+
useUrgentConversations,
|
|
4160
4935
|
useUserSettings,
|
|
4161
4936
|
useUserSync,
|
|
4162
4937
|
useVoicemailUrl
|