@hipnation-truth/sdk 0.26.19 → 0.28.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 +601 -10
- package/dist/index.d.ts +601 -10
- package/dist/index.js +631 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +613 -8
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.ts +914 -93
- package/dist/react.js +1079 -132
- package/dist/react.js.map +1 -1
- package/package.json +7 -4
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,
|
|
@@ -110,11 +137,17 @@ __export(react_exports, {
|
|
|
110
137
|
usePhysicianByElationId: () => usePhysicianByElationId,
|
|
111
138
|
usePhysiciansByElationIds: () => usePhysiciansByElationIds,
|
|
112
139
|
useRemindersForConversations: () => useRemindersForConversations,
|
|
140
|
+
useSaveCallSummary: () => useSaveCallSummary,
|
|
141
|
+
useSearchPatientsForLink: () => useSearchPatientsForLink,
|
|
142
|
+
useTaskHistory: () => useTaskHistory,
|
|
113
143
|
useTruth: () => useTruth,
|
|
114
144
|
useTruthClient: () => useTruthClient,
|
|
115
145
|
useTruthSdkContext: () => useTruthSdkContext,
|
|
146
|
+
useUnlinkEmailMessage: () => useUnlinkEmailMessage,
|
|
147
|
+
useUnlinkedEmails: () => useUnlinkedEmails,
|
|
116
148
|
useUnreadAggregate: () => useUnreadAggregate,
|
|
117
149
|
useUnreadCount: () => useUnreadCount,
|
|
150
|
+
useUrgentConversations: () => useUrgentConversations,
|
|
118
151
|
useUserSettings: () => useUserSettings,
|
|
119
152
|
useUserSync: () => useUserSync,
|
|
120
153
|
useVoicemailUrl: () => useVoicemailUrl
|
|
@@ -122,7 +155,9 @@ __export(react_exports, {
|
|
|
122
155
|
module.exports = __toCommonJS(react_exports);
|
|
123
156
|
|
|
124
157
|
// src/react/calls.ts
|
|
158
|
+
var import_react4 = require("convex/react");
|
|
125
159
|
var import_server2 = require("convex/server");
|
|
160
|
+
var import_react5 = require("react");
|
|
126
161
|
|
|
127
162
|
// src/react/offline/use-persistent-query.ts
|
|
128
163
|
var import_react_query3 = require("@convex-dev/react-query");
|
|
@@ -306,7 +341,6 @@ var AttachmentsError = class extends Error {
|
|
|
306
341
|
var AttachmentsResource = class {
|
|
307
342
|
constructor(apiBaseUrl, apiKey, convexClient, getAuthToken) {
|
|
308
343
|
this.baseUrl = apiBaseUrl;
|
|
309
|
-
this.apiKey = apiKey;
|
|
310
344
|
this.auth = { apiKey, getAuthToken };
|
|
311
345
|
this.convex = convexClient;
|
|
312
346
|
}
|
|
@@ -452,6 +486,304 @@ var AttachmentsResource = class {
|
|
|
452
486
|
}
|
|
453
487
|
};
|
|
454
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
|
+
|
|
455
787
|
// src/resources/conversations.ts
|
|
456
788
|
var ConversationsError = class extends Error {
|
|
457
789
|
constructor(operation, status, message) {
|
|
@@ -614,6 +946,25 @@ var _ConversationsResource = class _ConversationsResource {
|
|
|
614
946
|
);
|
|
615
947
|
});
|
|
616
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
|
+
}
|
|
617
968
|
/**
|
|
618
969
|
* Zero unread on every conversation the user has reads for, except
|
|
619
970
|
* those whose `providerPhone` is in `excludedProviderPhones`.
|
|
@@ -737,7 +1088,6 @@ var ConversationsResource = _ConversationsResource;
|
|
|
737
1088
|
var DialpadResource = class {
|
|
738
1089
|
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
739
1090
|
this.baseUrl = apiBaseUrl;
|
|
740
|
-
this.apiKey = apiKey;
|
|
741
1091
|
this.auth = { apiKey, getAuthToken };
|
|
742
1092
|
}
|
|
743
1093
|
/**
|
|
@@ -949,7 +1299,6 @@ var MessagesResource = class {
|
|
|
949
1299
|
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
950
1300
|
this.dialpad = new DialpadResource(apiBaseUrl, apiKey, getAuthToken);
|
|
951
1301
|
this.baseUrl = apiBaseUrl;
|
|
952
|
-
this.apiKey = apiKey;
|
|
953
1302
|
this.auth = { apiKey, getAuthToken };
|
|
954
1303
|
}
|
|
955
1304
|
/**
|
|
@@ -1122,7 +1471,6 @@ var NotesError = class extends Error {
|
|
|
1122
1471
|
var _NotesResource = class _NotesResource {
|
|
1123
1472
|
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
1124
1473
|
this.baseUrl = apiBaseUrl;
|
|
1125
|
-
this.apiKey = apiKey;
|
|
1126
1474
|
this.auth = { apiKey, getAuthToken };
|
|
1127
1475
|
}
|
|
1128
1476
|
post(path, body) {
|
|
@@ -1178,6 +1526,11 @@ var _NotesResource = class _NotesResource {
|
|
|
1178
1526
|
* physician/practice in Elation, posts the note, and writes an audit
|
|
1179
1527
|
* row to `elationSyncEvents`. Replaces CommHub's `pushNotesToElation`
|
|
1180
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`.
|
|
1181
1534
|
*/
|
|
1182
1535
|
pushConversationToElation(input) {
|
|
1183
1536
|
return __async(this, null, function* () {
|
|
@@ -1204,7 +1557,6 @@ var NotificationsError = class extends Error {
|
|
|
1204
1557
|
var NotificationsResource = class {
|
|
1205
1558
|
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
1206
1559
|
this.baseUrl = apiBaseUrl;
|
|
1207
|
-
this.apiKey = apiKey;
|
|
1208
1560
|
this.auth = { apiKey, getAuthToken };
|
|
1209
1561
|
}
|
|
1210
1562
|
post(path, body) {
|
|
@@ -1377,7 +1729,6 @@ var PatientDetailsError = class extends Error {
|
|
|
1377
1729
|
var PatientDetailsResource = class {
|
|
1378
1730
|
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
1379
1731
|
this.baseUrl = apiBaseUrl;
|
|
1380
|
-
this.apiKey = apiKey;
|
|
1381
1732
|
this.auth = { apiKey, getAuthToken };
|
|
1382
1733
|
}
|
|
1383
1734
|
post(path, body) {
|
|
@@ -1666,6 +2017,151 @@ var RemindersResource = class {
|
|
|
1666
2017
|
}
|
|
1667
2018
|
};
|
|
1668
2019
|
|
|
2020
|
+
// src/resources/reports.ts
|
|
2021
|
+
var import_zod = require("zod");
|
|
2022
|
+
var memberSchema = import_zod.z.object({
|
|
2023
|
+
elationId: import_zod.z.string(),
|
|
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(),
|
|
2030
|
+
doctor: import_zod.z.string().nullable(),
|
|
2031
|
+
status: import_zod.z.enum(["activated", "outreach", "scheduled", "review", "data"]),
|
|
2032
|
+
membershipStart: import_zod.z.string(),
|
|
2033
|
+
daysSinceMembershipStart: import_zod.z.number(),
|
|
2034
|
+
activationDate: import_zod.z.string().nullable(),
|
|
2035
|
+
futureApptDate: import_zod.z.string().nullable(),
|
|
2036
|
+
reason: import_zod.z.string().nullable(),
|
|
2037
|
+
hasLink: import_zod.z.boolean()
|
|
2038
|
+
});
|
|
2039
|
+
var reportSchema = import_zod.z.object({
|
|
2040
|
+
synthetic: import_zod.z.boolean(),
|
|
2041
|
+
generatedAt: import_zod.z.string(),
|
|
2042
|
+
employers: import_zod.z.array(
|
|
2043
|
+
import_zod.z.object({ id: import_zod.z.string(), name: import_zod.z.string(), activeMembers: import_zod.z.number() })
|
|
2044
|
+
),
|
|
2045
|
+
selected: import_zod.z.object({
|
|
2046
|
+
employerId: import_zod.z.string(),
|
|
2047
|
+
employerName: import_zod.z.string(),
|
|
2048
|
+
kpis: import_zod.z.object({
|
|
2049
|
+
active: import_zod.z.number(),
|
|
2050
|
+
linked: import_zod.z.number(),
|
|
2051
|
+
activated: import_zod.z.number(),
|
|
2052
|
+
needsOutreach: import_zod.z.number(),
|
|
2053
|
+
scheduled: import_zod.z.number(),
|
|
2054
|
+
needsReview: import_zod.z.number(),
|
|
2055
|
+
dataIssue: import_zod.z.number(),
|
|
2056
|
+
activationRate: import_zod.z.number()
|
|
2057
|
+
}),
|
|
2058
|
+
coverage: import_zod.z.object({
|
|
2059
|
+
active: import_zod.z.number(),
|
|
2060
|
+
linked: import_zod.z.number(),
|
|
2061
|
+
unlinked: import_zod.z.number(),
|
|
2062
|
+
pct: import_zod.z.number()
|
|
2063
|
+
}),
|
|
2064
|
+
breakdown: import_zod.z.array(
|
|
2065
|
+
import_zod.z.object({
|
|
2066
|
+
status: import_zod.z.enum([
|
|
2067
|
+
"activated",
|
|
2068
|
+
"outreach",
|
|
2069
|
+
"scheduled",
|
|
2070
|
+
"review",
|
|
2071
|
+
"data"
|
|
2072
|
+
]),
|
|
2073
|
+
label: import_zod.z.string(),
|
|
2074
|
+
count: import_zod.z.number(),
|
|
2075
|
+
pct: import_zod.z.number()
|
|
2076
|
+
})
|
|
2077
|
+
),
|
|
2078
|
+
aging: import_zod.z.array(
|
|
2079
|
+
import_zod.z.object({
|
|
2080
|
+
bucket: import_zod.z.string(),
|
|
2081
|
+
total: import_zod.z.number(),
|
|
2082
|
+
outreach: import_zod.z.number(),
|
|
2083
|
+
scheduled: import_zod.z.number(),
|
|
2084
|
+
review: import_zod.z.number()
|
|
2085
|
+
})
|
|
2086
|
+
),
|
|
2087
|
+
doctors: import_zod.z.array(
|
|
2088
|
+
import_zod.z.object({
|
|
2089
|
+
name: import_zod.z.string(),
|
|
2090
|
+
counts: import_zod.z.object({
|
|
2091
|
+
outreach: import_zod.z.number(),
|
|
2092
|
+
scheduled: import_zod.z.number(),
|
|
2093
|
+
review: import_zod.z.number(),
|
|
2094
|
+
data: import_zod.z.number()
|
|
2095
|
+
}),
|
|
2096
|
+
members: import_zod.z.array(memberSchema)
|
|
2097
|
+
})
|
|
2098
|
+
)
|
|
2099
|
+
}).nullable(),
|
|
2100
|
+
// True when the requested employer has no materialized report row yet
|
|
2101
|
+
// (ehr-sync's dailyHandler has not run for it). `selected` is null in that
|
|
2102
|
+
// case — the caller sees the employer roster but no report data to render.
|
|
2103
|
+
pending: import_zod.z.boolean()
|
|
2104
|
+
});
|
|
2105
|
+
var ReportsError = class extends Error {
|
|
2106
|
+
/**
|
|
2107
|
+
* Wraps a failed reports HTTP call with the operation name and status
|
|
2108
|
+
* code so callers can branch on `status` without re-parsing the message.
|
|
2109
|
+
* Falls back to a generated message when the server response body is
|
|
2110
|
+
* empty or unreadable.
|
|
2111
|
+
*/
|
|
2112
|
+
constructor(operation, status, message) {
|
|
2113
|
+
const trimmedMessage = message == null ? void 0 : message.trim();
|
|
2114
|
+
super(trimmedMessage || `Reports ${operation} failed (HTTP ${status})`);
|
|
2115
|
+
this.name = "ReportsError";
|
|
2116
|
+
this.status = status;
|
|
2117
|
+
}
|
|
2118
|
+
};
|
|
2119
|
+
var ReportsResource = class {
|
|
2120
|
+
/**
|
|
2121
|
+
* Captures the Truth API base URL and the auth inputs (API key + optional
|
|
2122
|
+
* user-token fetcher) needed to authenticate every request this resource
|
|
2123
|
+
* makes.
|
|
2124
|
+
*/
|
|
2125
|
+
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
2126
|
+
this.baseUrl = apiBaseUrl;
|
|
2127
|
+
this.auth = { apiKey, getAuthToken };
|
|
2128
|
+
}
|
|
2129
|
+
/**
|
|
2130
|
+
* Fetches the member activation report from GET /reports/member-activation,
|
|
2131
|
+
* optionally scoped to a single employer. Requires the user JWT (not just
|
|
2132
|
+
* the API key) since the server hardens this route to
|
|
2133
|
+
* `verifiedUserProcedure` for PHI access — throws via `ReportsError` on a
|
|
2134
|
+
* non-OK response, including the response body (truncated) when present.
|
|
2135
|
+
*/
|
|
2136
|
+
memberActivation(params) {
|
|
2137
|
+
return __async(this, null, function* () {
|
|
2138
|
+
const url = new URL(`${this.baseUrl}/api/reports/member-activation`);
|
|
2139
|
+
if (params == null ? void 0 : params.employerId) {
|
|
2140
|
+
url.searchParams.set("employerId", params.employerId);
|
|
2141
|
+
}
|
|
2142
|
+
const res = yield fetch(url.toString(), {
|
|
2143
|
+
method: "GET",
|
|
2144
|
+
// PHI (member activation report) — REQUIRE the user JWT. The server
|
|
2145
|
+
// hardens this route to `verifiedUserProcedure`, so degrading to
|
|
2146
|
+
// key-only would 401. `requireUserToken` retries across the Clerk-
|
|
2147
|
+
// hydration gap and throws rather than silently sending key-only.
|
|
2148
|
+
headers: yield buildAuthHeaders(this.auth, {
|
|
2149
|
+
requireUserToken: true
|
|
2150
|
+
})
|
|
2151
|
+
});
|
|
2152
|
+
if (!res.ok) {
|
|
2153
|
+
const text = yield res.text().catch(() => "");
|
|
2154
|
+
throw new ReportsError(
|
|
2155
|
+
"member-activation",
|
|
2156
|
+
res.status,
|
|
2157
|
+
text.slice(0, 200)
|
|
2158
|
+
);
|
|
2159
|
+
}
|
|
2160
|
+
return yield res.json();
|
|
2161
|
+
});
|
|
2162
|
+
}
|
|
2163
|
+
};
|
|
2164
|
+
|
|
1669
2165
|
// src/resources/tasks.ts
|
|
1670
2166
|
var TasksResource = class {
|
|
1671
2167
|
constructor(convexClient) {
|
|
@@ -1760,7 +2256,6 @@ var TranslationError = class extends Error {
|
|
|
1760
2256
|
var TranslationResource = class {
|
|
1761
2257
|
constructor(apiBaseUrl, apiKey, getAuthToken) {
|
|
1762
2258
|
this.baseUrl = apiBaseUrl;
|
|
1763
|
-
this.apiKey = apiKey;
|
|
1764
2259
|
this.auth = { apiKey, getAuthToken };
|
|
1765
2260
|
}
|
|
1766
2261
|
post(path, body) {
|
|
@@ -2066,6 +2561,14 @@ var CONVEX_URLS = {
|
|
|
2066
2561
|
production: "https://gallant-gecko-217.convex.cloud"
|
|
2067
2562
|
};
|
|
2068
2563
|
var TruthClient = class {
|
|
2564
|
+
/**
|
|
2565
|
+
* Builds the Convex client and event tracker from `config`, then wires up
|
|
2566
|
+
* every resource (patients, appointments, EHR proxy, reports, etc.) so
|
|
2567
|
+
* each shares the same Convex connection / API base URL / auth token
|
|
2568
|
+
* fetcher. When running in a browser that supports web push and the
|
|
2569
|
+
* caller hasn't opted out, kicks off best-effort service-worker
|
|
2570
|
+
* registration and push subscription in the background.
|
|
2571
|
+
*/
|
|
2069
2572
|
constructor(config) {
|
|
2070
2573
|
this._vapidPublicKey = null;
|
|
2071
2574
|
this._webPushReady = null;
|
|
@@ -2109,6 +2612,11 @@ var TruthClient = class {
|
|
|
2109
2612
|
this.convex,
|
|
2110
2613
|
config.getAuthToken
|
|
2111
2614
|
);
|
|
2615
|
+
this.reports = new ReportsResource(
|
|
2616
|
+
apiUrl,
|
|
2617
|
+
config.apiKey,
|
|
2618
|
+
config.getAuthToken
|
|
2619
|
+
);
|
|
2112
2620
|
this.notes = new NotesResource(apiUrl, config.apiKey, config.getAuthToken);
|
|
2113
2621
|
this.physicians = new PhysiciansResource(this.convex);
|
|
2114
2622
|
this.notifications = new NotificationsResource(
|
|
@@ -2122,6 +2630,11 @@ var TruthClient = class {
|
|
|
2122
2630
|
this.convex,
|
|
2123
2631
|
config.getAuthToken
|
|
2124
2632
|
);
|
|
2633
|
+
this.careInbox = new CareInboxResource(
|
|
2634
|
+
apiUrl,
|
|
2635
|
+
config.apiKey,
|
|
2636
|
+
config.getAuthToken
|
|
2637
|
+
);
|
|
2125
2638
|
this.userSettings = new UserSettingsResource(this.convex);
|
|
2126
2639
|
this._getAuthToken = config.getAuthToken;
|
|
2127
2640
|
this._serviceWorkerPath = (_h = config.serviceWorkerPath) != null ? _h : "/truth-sw.js";
|
|
@@ -2129,9 +2642,11 @@ var TruthClient = class {
|
|
|
2129
2642
|
this._webPushReady = this.initWebPush();
|
|
2130
2643
|
}
|
|
2131
2644
|
}
|
|
2645
|
+
/** The VAPID public key fetched during web-push init, or `null` until `webPushReady` resolves (or if push is unsupported/disabled). */
|
|
2132
2646
|
get vapidPublicKey() {
|
|
2133
2647
|
return this._vapidPublicKey;
|
|
2134
2648
|
}
|
|
2649
|
+
/** Resolves once background web-push initialization (service worker registration + subscription) finishes; `null` if it was never started (SSR, unsupported browser, or opted out via config). */
|
|
2135
2650
|
get webPushReady() {
|
|
2136
2651
|
return this._webPushReady;
|
|
2137
2652
|
}
|
|
@@ -2158,6 +2673,14 @@ var TruthClient = class {
|
|
|
2158
2673
|
}
|
|
2159
2674
|
});
|
|
2160
2675
|
}
|
|
2676
|
+
/**
|
|
2677
|
+
* Best-effort web-push bootstrap: waits for auth (if configured), fetches
|
|
2678
|
+
* the VAPID key, registers the service worker, subscribes to push, and
|
|
2679
|
+
* registers the device with a placeholder `__pending__` userId (the
|
|
2680
|
+
* backend reconciles this once the real user is known). Any failure
|
|
2681
|
+
* along the way is swallowed — push notifications are opportunistic and
|
|
2682
|
+
* must never break client construction.
|
|
2683
|
+
*/
|
|
2161
2684
|
initWebPush() {
|
|
2162
2685
|
return __async(this, null, function* () {
|
|
2163
2686
|
try {
|
|
@@ -2486,7 +3009,9 @@ function TruthProvider({
|
|
|
2486
3009
|
for (let attempt = 0; attempt < 6; attempt++) {
|
|
2487
3010
|
try {
|
|
2488
3011
|
token = (_a2 = yield fetcher({ forceRefreshToken })) != null ? _a2 : null;
|
|
2489
|
-
if (token)
|
|
3012
|
+
if (token) {
|
|
3013
|
+
break;
|
|
3014
|
+
}
|
|
2490
3015
|
} catch (e) {
|
|
2491
3016
|
}
|
|
2492
3017
|
yield new Promise(
|
|
@@ -2674,6 +3199,7 @@ var listActiveRef = (0, import_server2.makeFunctionReference)("dialpadCallEvents
|
|
|
2674
3199
|
var listForConversationRef = (0, import_server2.makeFunctionReference)("dialpadCallEvents:listForConversation");
|
|
2675
3200
|
var getByCallIdRef = (0, import_server2.makeFunctionReference)("dialpadCallEvents:getByCallId");
|
|
2676
3201
|
var listLogForCallIdRef = (0, import_server2.makeFunctionReference)("dialpadCallEvents:listLogForCallId");
|
|
3202
|
+
var setUserSummaryRef = (0, import_server2.makeFunctionReference)("dialpadCallEvents:setUserSummary");
|
|
2677
3203
|
var SKIP = "skip";
|
|
2678
3204
|
function toResult(value, skipped) {
|
|
2679
3205
|
if (skipped) {
|
|
@@ -2717,10 +3243,374 @@ function useDialpadCallLog(callId, options) {
|
|
|
2717
3243
|
);
|
|
2718
3244
|
return toResult(result, skipped);
|
|
2719
3245
|
}
|
|
3246
|
+
function useSaveCallSummary() {
|
|
3247
|
+
const mutate = (0, import_react4.useMutation)(
|
|
3248
|
+
setUserSummaryRef
|
|
3249
|
+
);
|
|
3250
|
+
return (0, import_react5.useCallback)(
|
|
3251
|
+
(callId, userSummary, updatedBy) => mutate({ callId, userSummary, updatedBy }),
|
|
3252
|
+
[mutate]
|
|
3253
|
+
);
|
|
3254
|
+
}
|
|
2720
3255
|
|
|
2721
|
-
// 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
|
|
2722
3261
|
var import_server3 = require("convex/server");
|
|
2723
|
-
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");
|
|
2724
3614
|
function useConversationById(id) {
|
|
2725
3615
|
const skipped = !id;
|
|
2726
3616
|
const result = usePersistentQuery(
|
|
@@ -2738,20 +3628,23 @@ function useConversationById(id) {
|
|
|
2738
3628
|
}
|
|
2739
3629
|
|
|
2740
3630
|
// src/react/conversations.ts
|
|
2741
|
-
var
|
|
2742
|
-
var
|
|
2743
|
-
var conversationsListForUserRef = (0,
|
|
2744
|
-
var
|
|
2745
|
-
var
|
|
2746
|
-
var
|
|
2747
|
-
var
|
|
2748
|
-
var
|
|
2749
|
-
var
|
|
2750
|
-
var
|
|
2751
|
-
var
|
|
2752
|
-
var
|
|
2753
|
-
var
|
|
2754
|
-
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";
|
|
2755
3648
|
function toResult2(value, skipped) {
|
|
2756
3649
|
if (skipped) {
|
|
2757
3650
|
return { data: void 0, loading: false, error: void 0 };
|
|
@@ -2769,14 +3662,14 @@ function useConversations(filters) {
|
|
|
2769
3662
|
const skipped = !filters.userId;
|
|
2770
3663
|
const listResult = usePersistentQuery(
|
|
2771
3664
|
conversationsListForUserRef,
|
|
2772
|
-
skipped || isSearchMode ?
|
|
3665
|
+
skipped || isSearchMode ? SKIP3 : {
|
|
2773
3666
|
userId: filters.userId,
|
|
2774
3667
|
limit: filters.limit
|
|
2775
3668
|
}
|
|
2776
3669
|
);
|
|
2777
3670
|
const searchResult = usePersistentQuery(
|
|
2778
3671
|
conversationsSearchForUserRef,
|
|
2779
|
-
skipped || !isSearchMode ?
|
|
3672
|
+
skipped || !isSearchMode ? SKIP3 : {
|
|
2780
3673
|
userId: filters.userId,
|
|
2781
3674
|
search: trimmedSearch,
|
|
2782
3675
|
limit: filters.limit
|
|
@@ -2784,11 +3677,19 @@ function useConversations(filters) {
|
|
|
2784
3677
|
);
|
|
2785
3678
|
return toResult2(isSearchMode ? searchResult : listResult, skipped);
|
|
2786
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
|
+
}
|
|
2787
3688
|
function useConversationByPhonePair(phonePair) {
|
|
2788
3689
|
const skipped = !phonePair;
|
|
2789
3690
|
const result = usePersistentQuery(
|
|
2790
3691
|
conversationsGetByPhonePairRef,
|
|
2791
|
-
skipped ?
|
|
3692
|
+
skipped ? SKIP3 : { phonePair }
|
|
2792
3693
|
);
|
|
2793
3694
|
return toResult2(result, skipped);
|
|
2794
3695
|
}
|
|
@@ -2796,7 +3697,7 @@ function useMessages(conversationId, options) {
|
|
|
2796
3697
|
const skipped = !conversationId;
|
|
2797
3698
|
const result = usePersistentQuery(
|
|
2798
3699
|
conversationMessagesGetByConversationIdRef,
|
|
2799
|
-
skipped ?
|
|
3700
|
+
skipped ? SKIP3 : {
|
|
2800
3701
|
conversationId,
|
|
2801
3702
|
limit: options == null ? void 0 : options.limit
|
|
2802
3703
|
}
|
|
@@ -2807,7 +3708,7 @@ function useUnreadCount(userId) {
|
|
|
2807
3708
|
const skipped = !userId;
|
|
2808
3709
|
const result = usePersistentQuery(
|
|
2809
3710
|
conversationsGetUnreadTotalForUserRef,
|
|
2810
|
-
skipped ?
|
|
3711
|
+
skipped ? SKIP3 : { userId }
|
|
2811
3712
|
);
|
|
2812
3713
|
return toResult2(result, skipped);
|
|
2813
3714
|
}
|
|
@@ -2817,7 +3718,7 @@ function useUnreadAggregate(userId, options) {
|
|
|
2817
3718
|
const stablePhones = useMemoizedPhones(phones);
|
|
2818
3719
|
const result = usePersistentQuery(
|
|
2819
3720
|
conversationsGetUnreadAggregateForUserRef,
|
|
2820
|
-
skipped ?
|
|
3721
|
+
skipped ? SKIP3 : {
|
|
2821
3722
|
userId,
|
|
2822
3723
|
providerPhones: stablePhones
|
|
2823
3724
|
}
|
|
@@ -2826,7 +3727,7 @@ function useUnreadAggregate(userId, options) {
|
|
|
2826
3727
|
}
|
|
2827
3728
|
function useMemoizedPhones(phones) {
|
|
2828
3729
|
const key = phones ? [...phones].sort().join("|") : "";
|
|
2829
|
-
return (0,
|
|
3730
|
+
return (0, import_react8.useMemo)(
|
|
2830
3731
|
() => (phones == null ? void 0 : phones.length) ? [...phones].sort() : void 0,
|
|
2831
3732
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2832
3733
|
[key]
|
|
@@ -2836,7 +3737,7 @@ function useConversationNotes(conversationId) {
|
|
|
2836
3737
|
const skipped = !conversationId;
|
|
2837
3738
|
const result = usePersistentQuery(
|
|
2838
3739
|
conversationNotesListForConversationRef,
|
|
2839
|
-
skipped ?
|
|
3740
|
+
skipped ? SKIP3 : { conversationId }
|
|
2840
3741
|
);
|
|
2841
3742
|
return toResult2(result, skipped);
|
|
2842
3743
|
}
|
|
@@ -2844,7 +3745,7 @@ function useConversationTasks(conversationId) {
|
|
|
2844
3745
|
const skipped = !conversationId;
|
|
2845
3746
|
const result = usePersistentQuery(
|
|
2846
3747
|
conversationTasksListForConversationRef,
|
|
2847
|
-
skipped ?
|
|
3748
|
+
skipped ? SKIP3 : { conversationId }
|
|
2848
3749
|
);
|
|
2849
3750
|
return toResult2(result, skipped);
|
|
2850
3751
|
}
|
|
@@ -2852,7 +3753,7 @@ function useConversationNotesByPhonePair(phonePair) {
|
|
|
2852
3753
|
const skipped = !phonePair;
|
|
2853
3754
|
const result = usePersistentQuery(
|
|
2854
3755
|
conversationNotesListByPhonePairRef,
|
|
2855
|
-
skipped ?
|
|
3756
|
+
skipped ? SKIP3 : { phonePair }
|
|
2856
3757
|
);
|
|
2857
3758
|
return toResult2(result, skipped);
|
|
2858
3759
|
}
|
|
@@ -2860,7 +3761,7 @@ function useConversationTasksForUser(userId, options) {
|
|
|
2860
3761
|
const skipped = !userId;
|
|
2861
3762
|
const result = usePersistentQuery(
|
|
2862
3763
|
conversationTasksListForUserRef,
|
|
2863
|
-
skipped ?
|
|
3764
|
+
skipped ? SKIP3 : { userId, limit: options == null ? void 0 : options.limit }
|
|
2864
3765
|
);
|
|
2865
3766
|
return toResult2(result, skipped);
|
|
2866
3767
|
}
|
|
@@ -2868,21 +3769,37 @@ function useConversationTasksByPhonePair(phonePair) {
|
|
|
2868
3769
|
const skipped = !phonePair;
|
|
2869
3770
|
const result = usePersistentQuery(
|
|
2870
3771
|
conversationTasksListByPhonePairRef,
|
|
2871
|
-
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 }
|
|
2872
3789
|
);
|
|
2873
3790
|
return toResult2(result, skipped);
|
|
2874
3791
|
}
|
|
2875
3792
|
|
|
2876
3793
|
// src/react/hooks.ts
|
|
2877
|
-
var
|
|
2878
|
-
var
|
|
2879
|
-
var patientsListRef = (0,
|
|
2880
|
-
var patientsGetRef = (0,
|
|
2881
|
-
var patientsByElationIdRef = (0,
|
|
2882
|
-
var patientsByHintIdRef = (0,
|
|
2883
|
-
var appointmentsListRef = (0,
|
|
2884
|
-
var appointmentsGetRef = (0,
|
|
2885
|
-
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");
|
|
2886
3803
|
function usePatients(options) {
|
|
2887
3804
|
return usePersistentQuery(patientsListRef, options != null ? options : {});
|
|
2888
3805
|
}
|
|
@@ -2915,8 +3832,8 @@ function useAppointmentByElationId(elationId) {
|
|
|
2915
3832
|
elationId
|
|
2916
3833
|
});
|
|
2917
3834
|
}
|
|
2918
|
-
var physiciansGetByElationIdsRef = (0,
|
|
2919
|
-
var physiciansGetByElationIdRef = (0,
|
|
3835
|
+
var physiciansGetByElationIdsRef = (0, import_server6.makeFunctionReference)("physicians:getByElationIds");
|
|
3836
|
+
var physiciansGetByElationIdRef = (0, import_server6.makeFunctionReference)("physicians:getByElationId");
|
|
2920
3837
|
function usePhysiciansByElationIds(ids) {
|
|
2921
3838
|
return usePersistentQuery(
|
|
2922
3839
|
physiciansGetByElationIdsRef,
|
|
@@ -2929,10 +3846,10 @@ function usePhysicianByElationId(id) {
|
|
|
2929
3846
|
id !== void 0 ? { id } : "skip"
|
|
2930
3847
|
);
|
|
2931
3848
|
}
|
|
2932
|
-
var medicationsByPatientRef = (0,
|
|
2933
|
-
var problemsByPatientRef = (0,
|
|
2934
|
-
var allergiesByPatientRef = (0,
|
|
2935
|
-
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");
|
|
2936
3853
|
function postPatientRefresh(url, apiKey, getAuthToken, body, signal) {
|
|
2937
3854
|
return __async(this, null, function* () {
|
|
2938
3855
|
const headers = yield buildAuthHeaders(
|
|
@@ -2970,7 +3887,7 @@ function usePatientMedical(elationId, options) {
|
|
|
2970
3887
|
appointmentsByPatientRef,
|
|
2971
3888
|
id !== void 0 ? { elationPatientId: id } : "skip"
|
|
2972
3889
|
);
|
|
2973
|
-
(0,
|
|
3890
|
+
(0, import_react9.useEffect)(() => {
|
|
2974
3891
|
if (id === void 0 || (options == null ? void 0 : options.skipRefresh)) {
|
|
2975
3892
|
return;
|
|
2976
3893
|
}
|
|
@@ -2990,10 +3907,10 @@ function usePatientMedical(elationId, options) {
|
|
|
2990
3907
|
}, [id, apiBaseUrl, apiKey, getAuthToken, options == null ? void 0 : options.skipRefresh]);
|
|
2991
3908
|
return { medications, problems, allergies, appointments };
|
|
2992
3909
|
}
|
|
2993
|
-
var elationPatientByIdRef = (0,
|
|
2994
|
-
var hintPatientByIdRef = (0,
|
|
2995
|
-
var pharmacyByNcpdpRef = (0,
|
|
2996
|
-
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");
|
|
2997
3914
|
function usePatientBasic(input, options) {
|
|
2998
3915
|
var _a, _b, _c, _d;
|
|
2999
3916
|
const sdkContext = useTruthSdkContext();
|
|
@@ -3010,7 +3927,7 @@ function usePatientBasic(input, options) {
|
|
|
3010
3927
|
hintPatientByIdRef,
|
|
3011
3928
|
input.hintId !== void 0 ? { hintId: input.hintId } : "skip"
|
|
3012
3929
|
);
|
|
3013
|
-
(0,
|
|
3930
|
+
(0, import_react9.useEffect)(() => {
|
|
3014
3931
|
if (options == null ? void 0 : options.skipRefresh) {
|
|
3015
3932
|
return;
|
|
3016
3933
|
}
|
|
@@ -3067,7 +3984,7 @@ function usePatientPhoto(elationId, options) {
|
|
|
3067
3984
|
patientPhotoByIdRef,
|
|
3068
3985
|
id !== void 0 ? { elationPatientId: id } : "skip"
|
|
3069
3986
|
);
|
|
3070
|
-
(0,
|
|
3987
|
+
(0, import_react9.useEffect)(() => {
|
|
3071
3988
|
if (options == null ? void 0 : options.skipRefresh) {
|
|
3072
3989
|
return;
|
|
3073
3990
|
}
|
|
@@ -3090,8 +4007,8 @@ function usePatientPhoto(elationId, options) {
|
|
|
3090
4007
|
}, [id, apiBaseUrl, apiKey, getAuthToken, options == null ? void 0 : options.skipRefresh]);
|
|
3091
4008
|
return photo;
|
|
3092
4009
|
}
|
|
3093
|
-
var messagesByPhonesRef = (0,
|
|
3094
|
-
var messagesByConversationIdRef = (0,
|
|
4010
|
+
var messagesByPhonesRef = (0, import_server6.makeFunctionReference)("conversationMessages:getByPhones");
|
|
4011
|
+
var messagesByConversationIdRef = (0, import_server6.makeFunctionReference)("conversationMessages:getByConversationId");
|
|
3095
4012
|
function useConversationMessages(input, options) {
|
|
3096
4013
|
const hasPair = !!input.phoneA && !!input.phoneB;
|
|
3097
4014
|
const byPair = usePersistentQuery(
|
|
@@ -3110,7 +4027,7 @@ function useConversationMessages(input, options) {
|
|
|
3110
4027
|
}
|
|
3111
4028
|
|
|
3112
4029
|
// src/react/notifications.ts
|
|
3113
|
-
var
|
|
4030
|
+
var import_react10 = require("react");
|
|
3114
4031
|
function loadExpo() {
|
|
3115
4032
|
return __async(this, null, function* () {
|
|
3116
4033
|
try {
|
|
@@ -3126,13 +4043,13 @@ function useNotifications(options) {
|
|
|
3126
4043
|
const apiBaseUrl = (_b = (_a = options.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _b : "";
|
|
3127
4044
|
const apiKey = (_d = (_c = options.apiKey) != null ? _c : sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _d : "";
|
|
3128
4045
|
const getAuthToken = sdkContext == null ? void 0 : sdkContext.getAuthToken;
|
|
3129
|
-
const [permissionStatus, setPermissionStatus] = (0,
|
|
3130
|
-
const [devicePushToken, setDevicePushToken] = (0,
|
|
3131
|
-
const expoRef = (0,
|
|
3132
|
-
const isWebRef = (0,
|
|
3133
|
-
const vapidKeyRef = (0,
|
|
3134
|
-
const prevUserIdRef = (0,
|
|
3135
|
-
(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)(() => {
|
|
3136
4053
|
let mounted = true;
|
|
3137
4054
|
void (() => __async(null, null, function* () {
|
|
3138
4055
|
var _a2;
|
|
@@ -3188,7 +4105,7 @@ function useNotifications(options) {
|
|
|
3188
4105
|
mounted = false;
|
|
3189
4106
|
};
|
|
3190
4107
|
}, [apiBaseUrl, apiKey]);
|
|
3191
|
-
const register = (0,
|
|
4108
|
+
const register = (0, import_react10.useCallback)(() => __async(null, null, function* () {
|
|
3192
4109
|
var _a2, _b2;
|
|
3193
4110
|
if (!options.userId) {
|
|
3194
4111
|
return { ok: false, reason: "missing_userId" };
|
|
@@ -3311,7 +4228,7 @@ function useNotifications(options) {
|
|
|
3311
4228
|
options.appVersion,
|
|
3312
4229
|
options.serviceWorkerPath
|
|
3313
4230
|
]);
|
|
3314
|
-
const unregister = (0,
|
|
4231
|
+
const unregister = (0, import_react10.useCallback)(() => __async(null, null, function* () {
|
|
3315
4232
|
if (!devicePushToken) {
|
|
3316
4233
|
return;
|
|
3317
4234
|
}
|
|
@@ -3329,7 +4246,7 @@ function useNotifications(options) {
|
|
|
3329
4246
|
}
|
|
3330
4247
|
setDevicePushToken(null);
|
|
3331
4248
|
}), [apiBaseUrl, apiKey, getAuthToken, devicePushToken]);
|
|
3332
|
-
const addReceivedListener = (0,
|
|
4249
|
+
const addReceivedListener = (0, import_react10.useCallback)(
|
|
3333
4250
|
(listener) => {
|
|
3334
4251
|
if (isWebRef.current) {
|
|
3335
4252
|
if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) {
|
|
@@ -3358,7 +4275,7 @@ function useNotifications(options) {
|
|
|
3358
4275
|
},
|
|
3359
4276
|
[]
|
|
3360
4277
|
);
|
|
3361
|
-
const addResponseListener = (0,
|
|
4278
|
+
const addResponseListener = (0, import_react10.useCallback)(
|
|
3362
4279
|
(listener) => {
|
|
3363
4280
|
if (isWebRef.current) {
|
|
3364
4281
|
if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) {
|
|
@@ -3387,7 +4304,7 @@ function useNotifications(options) {
|
|
|
3387
4304
|
},
|
|
3388
4305
|
[]
|
|
3389
4306
|
);
|
|
3390
|
-
const getBadgeCount = (0,
|
|
4307
|
+
const getBadgeCount = (0, import_react10.useCallback)(() => __async(null, null, function* () {
|
|
3391
4308
|
var _a2;
|
|
3392
4309
|
const expo = expoRef.current;
|
|
3393
4310
|
if (!(expo == null ? void 0 : expo.getBadgeCountAsync)) {
|
|
@@ -3395,7 +4312,7 @@ function useNotifications(options) {
|
|
|
3395
4312
|
}
|
|
3396
4313
|
return (_a2 = yield expo.getBadgeCountAsync()) != null ? _a2 : 0;
|
|
3397
4314
|
}), []);
|
|
3398
|
-
const setBadgeCount = (0,
|
|
4315
|
+
const setBadgeCount = (0, import_react10.useCallback)((count) => __async(null, null, function* () {
|
|
3399
4316
|
const expo = expoRef.current;
|
|
3400
4317
|
if (!(expo == null ? void 0 : expo.setBadgeCountAsync)) {
|
|
3401
4318
|
return;
|
|
@@ -3403,7 +4320,7 @@ function useNotifications(options) {
|
|
|
3403
4320
|
yield expo.setBadgeCountAsync(count);
|
|
3404
4321
|
}), []);
|
|
3405
4322
|
const autoRegister = options.autoRegister !== false;
|
|
3406
|
-
(0,
|
|
4323
|
+
(0, import_react10.useEffect)(() => {
|
|
3407
4324
|
if (!autoRegister) {
|
|
3408
4325
|
return;
|
|
3409
4326
|
}
|
|
@@ -3442,7 +4359,7 @@ function useNotifications(options) {
|
|
|
3442
4359
|
remove == null ? void 0 : remove();
|
|
3443
4360
|
};
|
|
3444
4361
|
}, [autoRegister, options.userId, register]);
|
|
3445
|
-
(0,
|
|
4362
|
+
(0, import_react10.useEffect)(() => {
|
|
3446
4363
|
const prev = prevUserIdRef.current;
|
|
3447
4364
|
prevUserIdRef.current = options.userId;
|
|
3448
4365
|
if (!autoRegister) {
|
|
@@ -3453,7 +4370,7 @@ function useNotifications(options) {
|
|
|
3453
4370
|
}
|
|
3454
4371
|
void register();
|
|
3455
4372
|
}, [options.userId, autoRegister, register]);
|
|
3456
|
-
(0,
|
|
4373
|
+
(0, import_react10.useEffect)(() => {
|
|
3457
4374
|
if (!autoRegister) {
|
|
3458
4375
|
return;
|
|
3459
4376
|
}
|
|
@@ -3491,7 +4408,7 @@ function useNotificationsActions() {
|
|
|
3491
4408
|
const apiBaseUrl = (_a = sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _a : "";
|
|
3492
4409
|
const apiKey = (_b = sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _b : "";
|
|
3493
4410
|
const getAuthToken = sdkContext == null ? void 0 : sdkContext.getAuthToken;
|
|
3494
|
-
const post = (0,
|
|
4411
|
+
const post = (0, import_react10.useCallback)(
|
|
3495
4412
|
(path, body, opts) => __async(null, null, function* () {
|
|
3496
4413
|
if (!apiBaseUrl || !apiKey) {
|
|
3497
4414
|
throw new Error(
|
|
@@ -3521,7 +4438,7 @@ function useNotificationsActions() {
|
|
|
3521
4438
|
}),
|
|
3522
4439
|
[apiBaseUrl, apiKey, getAuthToken]
|
|
3523
4440
|
);
|
|
3524
|
-
const get = (0,
|
|
4441
|
+
const get = (0, import_react10.useCallback)(
|
|
3525
4442
|
(path, opts) => __async(null, null, function* () {
|
|
3526
4443
|
const headers = (opts == null ? void 0 : opts.requireUserToken) ? yield buildAuthHeaders(
|
|
3527
4444
|
{ apiKey, getAuthToken },
|
|
@@ -3541,22 +4458,22 @@ function useNotificationsActions() {
|
|
|
3541
4458
|
}),
|
|
3542
4459
|
[apiBaseUrl, apiKey, getAuthToken]
|
|
3543
4460
|
);
|
|
3544
|
-
const send = (0,
|
|
4461
|
+
const send = (0, import_react10.useCallback)(
|
|
3545
4462
|
(input) => post("/notifications/send", input),
|
|
3546
4463
|
[post]
|
|
3547
4464
|
);
|
|
3548
|
-
const schedule = (0,
|
|
4465
|
+
const schedule = (0, import_react10.useCallback)(
|
|
3549
4466
|
(input) => post("/notifications/schedule", input),
|
|
3550
4467
|
[post]
|
|
3551
4468
|
);
|
|
3552
|
-
const getPreferences = (0,
|
|
4469
|
+
const getPreferences = (0, import_react10.useCallback)(
|
|
3553
4470
|
(userId) => get(
|
|
3554
4471
|
`/notifications/preferences/${encodeURIComponent(userId)}`,
|
|
3555
4472
|
{ requireUserToken: true }
|
|
3556
4473
|
),
|
|
3557
4474
|
[get]
|
|
3558
4475
|
);
|
|
3559
|
-
const updatePreferences = (0,
|
|
4476
|
+
const updatePreferences = (0, import_react10.useCallback)(
|
|
3560
4477
|
(userId, prefs) => post(
|
|
3561
4478
|
`/notifications/preferences/${encodeURIComponent(userId)}`,
|
|
3562
4479
|
prefs,
|
|
@@ -3592,14 +4509,14 @@ function detectPlatform(tokenType) {
|
|
|
3592
4509
|
}
|
|
3593
4510
|
|
|
3594
4511
|
// src/react/patient-family.ts
|
|
3595
|
-
var
|
|
3596
|
-
var patientsFamilyMembersRef = (0,
|
|
3597
|
-
var
|
|
4512
|
+
var import_server7 = require("convex/server");
|
|
4513
|
+
var patientsFamilyMembersRef = (0, import_server7.makeFunctionReference)("patients:listFamilyMembers");
|
|
4514
|
+
var SKIP4 = "skip";
|
|
3598
4515
|
function usePatientFamilyMembers(input) {
|
|
3599
4516
|
const hasFamilyId = !!(input == null ? void 0 : input.familyId);
|
|
3600
4517
|
const hasPhoneNumbers = !!((input == null ? void 0 : input.phoneNumbers) && input.phoneNumbers.length > 0);
|
|
3601
4518
|
const shouldQuery = hasFamilyId || hasPhoneNumbers;
|
|
3602
|
-
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;
|
|
3603
4520
|
const result = usePersistentQuery(
|
|
3604
4521
|
patientsFamilyMembersRef,
|
|
3605
4522
|
args
|
|
@@ -3615,16 +4532,16 @@ function usePatientFamilyMembers(input) {
|
|
|
3615
4532
|
}
|
|
3616
4533
|
|
|
3617
4534
|
// src/react/patient-search.ts
|
|
3618
|
-
var
|
|
3619
|
-
var patientsSearchRef = (0,
|
|
3620
|
-
var
|
|
4535
|
+
var import_server8 = require("convex/server");
|
|
4536
|
+
var patientsSearchRef = (0, import_server8.makeFunctionReference)("patients:search");
|
|
4537
|
+
var SKIP5 = "skip";
|
|
3621
4538
|
function usePatientSearch(options) {
|
|
3622
4539
|
var _a;
|
|
3623
4540
|
const trimmedQuery = ((_a = options.query) != null ? _a : "").trim();
|
|
3624
4541
|
const skipped = trimmedQuery.length === 0;
|
|
3625
4542
|
const result = usePersistentQuery(
|
|
3626
4543
|
patientsSearchRef,
|
|
3627
|
-
skipped ?
|
|
4544
|
+
skipped ? SKIP5 : __spreadValues(__spreadValues(__spreadValues({
|
|
3628
4545
|
query: trimmedQuery
|
|
3629
4546
|
}, options.officeId ? { officeId: options.officeId } : {}), options.mode ? { mode: options.mode } : {}), options.limit !== void 0 ? { limit: options.limit } : {})
|
|
3630
4547
|
);
|
|
@@ -3639,22 +4556,22 @@ function usePatientSearch(options) {
|
|
|
3639
4556
|
}
|
|
3640
4557
|
|
|
3641
4558
|
// src/react/patients-bulk.ts
|
|
3642
|
-
var
|
|
3643
|
-
var
|
|
3644
|
-
var patientsGetByIdsRef = (0,
|
|
3645
|
-
var patientsGetByPhonesRef = (0,
|
|
3646
|
-
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";
|
|
3647
4564
|
function usePatientsByIds(ids) {
|
|
3648
|
-
const stableIds = (0,
|
|
4565
|
+
const stableIds = (0, import_react11.useMemo)(() => {
|
|
3649
4566
|
const arr = ids != null ? ids : [];
|
|
3650
4567
|
return [...new Set(arr)].sort();
|
|
3651
4568
|
}, [ids]);
|
|
3652
4569
|
const skipped = stableIds.length === 0;
|
|
3653
4570
|
const result = usePersistentQuery(
|
|
3654
4571
|
patientsGetByIdsRef,
|
|
3655
|
-
skipped ?
|
|
4572
|
+
skipped ? SKIP6 : { ids: stableIds }
|
|
3656
4573
|
);
|
|
3657
|
-
const mapped = (0,
|
|
4574
|
+
const mapped = (0, import_react11.useMemo)(() => {
|
|
3658
4575
|
if (result === void 0) {
|
|
3659
4576
|
return void 0;
|
|
3660
4577
|
}
|
|
@@ -3676,7 +4593,7 @@ function usePatientsByIds(ids) {
|
|
|
3676
4593
|
};
|
|
3677
4594
|
}
|
|
3678
4595
|
function usePatientsByPhones(phones) {
|
|
3679
|
-
const stableDigits = (0,
|
|
4596
|
+
const stableDigits = (0, import_react11.useMemo)(() => {
|
|
3680
4597
|
const arr = phones != null ? phones : [];
|
|
3681
4598
|
const digits = arr.map((p) => p.replace(/\D+/g, "")).filter((s) => s.length > 0);
|
|
3682
4599
|
return [...new Set(digits)].sort();
|
|
@@ -3684,9 +4601,9 @@ function usePatientsByPhones(phones) {
|
|
|
3684
4601
|
const skipped = stableDigits.length === 0;
|
|
3685
4602
|
const result = usePersistentQuery(
|
|
3686
4603
|
patientsGetByPhonesRef,
|
|
3687
|
-
skipped ?
|
|
4604
|
+
skipped ? SKIP6 : { phoneDigits: stableDigits }
|
|
3688
4605
|
);
|
|
3689
|
-
const mapped = (0,
|
|
4606
|
+
const mapped = (0, import_react11.useMemo)(() => {
|
|
3690
4607
|
if (result === void 0) {
|
|
3691
4608
|
return void 0;
|
|
3692
4609
|
}
|
|
@@ -3703,15 +4620,15 @@ function usePatientsByPhones(phones) {
|
|
|
3703
4620
|
}
|
|
3704
4621
|
|
|
3705
4622
|
// src/react/reminders.ts
|
|
3706
|
-
var
|
|
3707
|
-
var remindersListPendingByConversationIdsRef = (0,
|
|
3708
|
-
var
|
|
4623
|
+
var import_server10 = require("convex/server");
|
|
4624
|
+
var remindersListPendingByConversationIdsRef = (0, import_server10.makeFunctionReference)("reminders:listPendingByConversationIds");
|
|
4625
|
+
var SKIP7 = "skip";
|
|
3709
4626
|
function useRemindersForConversations(conversationIds) {
|
|
3710
4627
|
const ids = conversationIds != null ? conversationIds : [];
|
|
3711
4628
|
const skipped = ids.length === 0;
|
|
3712
4629
|
const result = usePersistentQuery(
|
|
3713
4630
|
remindersListPendingByConversationIdsRef,
|
|
3714
|
-
skipped ?
|
|
4631
|
+
skipped ? SKIP7 : { conversationIds: ids }
|
|
3715
4632
|
);
|
|
3716
4633
|
const mapped = result === void 0 ? void 0 : Object.fromEntries(result.map((r) => [r.conversationId, r]));
|
|
3717
4634
|
if (skipped) {
|
|
@@ -3725,23 +4642,23 @@ function useRemindersForConversations(conversationIds) {
|
|
|
3725
4642
|
}
|
|
3726
4643
|
|
|
3727
4644
|
// src/react/tasks.ts
|
|
3728
|
-
var
|
|
3729
|
-
var
|
|
3730
|
-
var
|
|
3731
|
-
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");
|
|
3732
4649
|
function useConversationTaskMarkSeen() {
|
|
3733
|
-
const mutate = (0,
|
|
4650
|
+
const mutate = (0, import_react12.useMutation)(
|
|
3734
4651
|
conversationTasksMarkSeenRef
|
|
3735
4652
|
);
|
|
3736
|
-
return (0,
|
|
4653
|
+
return (0, import_react13.useCallback)(
|
|
3737
4654
|
(taskId, userId) => mutate({ taskId, userId }),
|
|
3738
4655
|
[mutate]
|
|
3739
4656
|
);
|
|
3740
4657
|
}
|
|
3741
4658
|
|
|
3742
4659
|
// src/react/tracking.ts
|
|
3743
|
-
var
|
|
3744
|
-
var TruthTrackingContext = (0,
|
|
4660
|
+
var import_react14 = require("react");
|
|
4661
|
+
var TruthTrackingContext = (0, import_react14.createContext)(
|
|
3745
4662
|
null
|
|
3746
4663
|
);
|
|
3747
4664
|
function TruthTrackingProvider({
|
|
@@ -3754,7 +4671,7 @@ function TruthTrackingProvider({
|
|
|
3754
4671
|
}) {
|
|
3755
4672
|
var _a, _b;
|
|
3756
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 : "";
|
|
3757
|
-
const value = (0,
|
|
4674
|
+
const value = (0, import_react14.useMemo)(() => {
|
|
3758
4675
|
const tracker = new Tracker({
|
|
3759
4676
|
apiKey: resolvedApiKey,
|
|
3760
4677
|
environment,
|
|
@@ -3773,10 +4690,10 @@ function TruthTrackingProvider({
|
|
|
3773
4690
|
}
|
|
3774
4691
|
};
|
|
3775
4692
|
}, [resolvedApiKey, environment, source, sourceVersion, tenantId]);
|
|
3776
|
-
return (0,
|
|
4693
|
+
return (0, import_react14.createElement)(TruthTrackingContext.Provider, { value }, children);
|
|
3777
4694
|
}
|
|
3778
4695
|
function useTruth() {
|
|
3779
|
-
const ctx = (0,
|
|
4696
|
+
const ctx = (0, import_react14.useContext)(TruthTrackingContext);
|
|
3780
4697
|
if (!ctx) {
|
|
3781
4698
|
throw new Error("useTruth must be used within a TruthTrackingProvider");
|
|
3782
4699
|
}
|
|
@@ -3784,14 +4701,14 @@ function useTruth() {
|
|
|
3784
4701
|
}
|
|
3785
4702
|
|
|
3786
4703
|
// src/react/user-settings.ts
|
|
3787
|
-
var
|
|
3788
|
-
var userSettingsGetByUserIdRef = (0,
|
|
3789
|
-
var
|
|
4704
|
+
var import_server12 = require("convex/server");
|
|
4705
|
+
var userSettingsGetByUserIdRef = (0, import_server12.makeFunctionReference)("userSettings:getByUserId");
|
|
4706
|
+
var SKIP8 = "skip";
|
|
3790
4707
|
function useUserSettings(userId) {
|
|
3791
4708
|
const skip = !userId;
|
|
3792
4709
|
const result = usePersistentQuery(
|
|
3793
4710
|
userSettingsGetByUserIdRef,
|
|
3794
|
-
skip ?
|
|
4711
|
+
skip ? SKIP8 : { userId }
|
|
3795
4712
|
);
|
|
3796
4713
|
if (skip) {
|
|
3797
4714
|
return { data: null, loading: false, error: void 0 };
|
|
@@ -3804,16 +4721,16 @@ function useUserSettings(userId) {
|
|
|
3804
4721
|
}
|
|
3805
4722
|
|
|
3806
4723
|
// src/react/users.ts
|
|
3807
|
-
var
|
|
4724
|
+
var import_react15 = require("react");
|
|
3808
4725
|
function useUserSync(input) {
|
|
3809
4726
|
var _a, _b, _c, _d;
|
|
3810
4727
|
const sdkContext = useTruthSdkContext();
|
|
3811
4728
|
const apiBaseUrl = (_b = (_a = input.apiBaseUrl) != null ? _a : sdkContext == null ? void 0 : sdkContext.apiBaseUrl) != null ? _b : "";
|
|
3812
4729
|
const apiKey = (_d = (_c = input.apiKey) != null ? _c : sdkContext == null ? void 0 : sdkContext.apiKey) != null ? _d : "";
|
|
3813
4730
|
const getAuthToken = sdkContext == null ? void 0 : sdkContext.getAuthToken;
|
|
3814
|
-
const [status, setStatus] = (0,
|
|
3815
|
-
const [error, setError] = (0,
|
|
3816
|
-
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);
|
|
3817
4734
|
const sync = () => __async(null, null, function* () {
|
|
3818
4735
|
if (!input.userId) {
|
|
3819
4736
|
return { ok: false, reason: "missing_userId" };
|
|
@@ -3857,7 +4774,7 @@ function useUserSync(input) {
|
|
|
3857
4774
|
return { ok: false, reason: message };
|
|
3858
4775
|
}
|
|
3859
4776
|
});
|
|
3860
|
-
(0,
|
|
4777
|
+
(0, import_react15.useEffect)(() => {
|
|
3861
4778
|
var _a2, _b2, _c2, _d2, _e;
|
|
3862
4779
|
if (!input.userId) {
|
|
3863
4780
|
return;
|
|
@@ -3896,13 +4813,13 @@ function useUserSync(input) {
|
|
|
3896
4813
|
}
|
|
3897
4814
|
|
|
3898
4815
|
// src/react/voicemail.ts
|
|
3899
|
-
var
|
|
4816
|
+
var import_react16 = require("react");
|
|
3900
4817
|
function useVoicemailUrl(client) {
|
|
3901
|
-
const [url, setUrl] = (0,
|
|
3902
|
-
const [isLoading, setIsLoading] = (0,
|
|
3903
|
-
const [error, setError] = (0,
|
|
3904
|
-
const inFlightRef = (0,
|
|
3905
|
-
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)(
|
|
3906
4823
|
(voicemailLink) => __async(null, null, function* () {
|
|
3907
4824
|
if (inFlightRef.current) {
|
|
3908
4825
|
return null;
|
|
@@ -3933,25 +4850,41 @@ function useVoicemailUrl(client) {
|
|
|
3933
4850
|
API_BASE_URLS,
|
|
3934
4851
|
CONNECTED_CALL_STATES,
|
|
3935
4852
|
CONVEX_URLS,
|
|
4853
|
+
CareInboxError,
|
|
3936
4854
|
DialpadCallState,
|
|
3937
4855
|
NoopStore,
|
|
3938
4856
|
RINGING_CALL_STATES,
|
|
3939
4857
|
TERMINAL_CALL_STATES,
|
|
3940
4858
|
TruthProvider,
|
|
3941
4859
|
TruthTrackingProvider,
|
|
4860
|
+
careInboxErrorInfo,
|
|
4861
|
+
careInboxRefs,
|
|
4862
|
+
createCareInboxSource,
|
|
3942
4863
|
getTruthClient,
|
|
4864
|
+
isCareInboxError,
|
|
3943
4865
|
readPersistedSavedAt,
|
|
3944
4866
|
resolveApiBaseUrl,
|
|
3945
4867
|
resolveConvexUrl,
|
|
4868
|
+
toCareInboxError,
|
|
4869
|
+
toEmailMailbox,
|
|
4870
|
+
toEmailMessage,
|
|
4871
|
+
toEmailThreadDetail,
|
|
4872
|
+
toEmailThreadSummary,
|
|
4873
|
+
toMailboxAccess,
|
|
4874
|
+
toMarkReadResult,
|
|
4875
|
+
toThreadPage,
|
|
4876
|
+
toUnlinkedMessagePage,
|
|
3946
4877
|
useActiveCalls,
|
|
3947
4878
|
useAppointment,
|
|
3948
4879
|
useAppointmentByElationId,
|
|
3949
4880
|
useAppointments,
|
|
4881
|
+
useCareInboxSource,
|
|
3950
4882
|
useConversationById,
|
|
3951
4883
|
useConversationByPhonePair,
|
|
3952
4884
|
useConversationMessages,
|
|
3953
4885
|
useConversationNotes,
|
|
3954
4886
|
useConversationNotesByPhonePair,
|
|
4887
|
+
useConversationTaskHistory,
|
|
3955
4888
|
useConversationTaskMarkSeen,
|
|
3956
4889
|
useConversationTasks,
|
|
3957
4890
|
useConversationTasksByPhonePair,
|
|
@@ -3960,11 +4893,19 @@ function useVoicemailUrl(client) {
|
|
|
3960
4893
|
useDialpadCallByCallId,
|
|
3961
4894
|
useDialpadCallLog,
|
|
3962
4895
|
useDialpadCallsForConversation,
|
|
4896
|
+
useEmailThread,
|
|
4897
|
+
useEmailThreads,
|
|
4898
|
+
useEmailUnreadCount,
|
|
4899
|
+
useLinkEmailMessage,
|
|
4900
|
+
useMailboxes,
|
|
4901
|
+
useMarkEmailThreadRead,
|
|
3963
4902
|
useMessages,
|
|
3964
4903
|
useNotifications,
|
|
3965
4904
|
useNotificationsActions,
|
|
3966
4905
|
useOfflineEnabled,
|
|
3967
4906
|
useOfflineStore,
|
|
4907
|
+
useOpenEmailThreadBodies,
|
|
4908
|
+
usePaginatedEmailThreads,
|
|
3968
4909
|
usePatient,
|
|
3969
4910
|
usePatientBasic,
|
|
3970
4911
|
usePatientByElationId,
|
|
@@ -3980,11 +4921,17 @@ function useVoicemailUrl(client) {
|
|
|
3980
4921
|
usePhysicianByElationId,
|
|
3981
4922
|
usePhysiciansByElationIds,
|
|
3982
4923
|
useRemindersForConversations,
|
|
4924
|
+
useSaveCallSummary,
|
|
4925
|
+
useSearchPatientsForLink,
|
|
4926
|
+
useTaskHistory,
|
|
3983
4927
|
useTruth,
|
|
3984
4928
|
useTruthClient,
|
|
3985
4929
|
useTruthSdkContext,
|
|
4930
|
+
useUnlinkEmailMessage,
|
|
4931
|
+
useUnlinkedEmails,
|
|
3986
4932
|
useUnreadAggregate,
|
|
3987
4933
|
useUnreadCount,
|
|
4934
|
+
useUrgentConversations,
|
|
3988
4935
|
useUserSettings,
|
|
3989
4936
|
useUserSync,
|
|
3990
4937
|
useVoicemailUrl
|