@peopl-health/nexus 5.61.0 → 5.61.1
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.
|
@@ -23,7 +23,7 @@ const { isWithin24HourWindow } = require('../helpers/conversationWindowHelper');
|
|
|
23
23
|
const { ensureWhatsAppFormat } = require('../helpers/twilioHelper');
|
|
24
24
|
const { sendMessage } = require('../core/NexusMessaging');
|
|
25
25
|
const { generateEscalationDraft } = require('../clinical/services/escalationDraftService');
|
|
26
|
-
const { recordEmergency, writeUnresolvedRequest } = require('../clinical/services/clinicalAirtableService');
|
|
26
|
+
const { conversationLink, recordEmergency, writeUnresolvedRequest } = require('../clinical/services/clinicalAirtableService');
|
|
27
27
|
const { renderDoctorMessage, templateSummary, withIdentity } = require('../clinical/helpers/doctorReviewMessageHelper');
|
|
28
28
|
const { generateKeyQuestions } = require('../clinical/services/escalationQuestionsService');
|
|
29
29
|
const { drugsNamedIn } = require('../clinical/services/treatmentProposalService');
|
|
@@ -57,6 +57,7 @@ const DECIDABLE_STATUSES = ['draft_ready', 'awaiting_doctor'];
|
|
|
57
57
|
const FOLLOWUP_STATUSES = ['indications_sent', 'indications_queued'];
|
|
58
58
|
const SETTLED_TRAJECTORIES = ['improving', 'stable'];
|
|
59
59
|
const ALERTED_URGENCIES = ['stat', 'asap'];
|
|
60
|
+
const ALERT_MARKS = { stat: '🔴', asap: '🟠' };
|
|
60
61
|
const DEFAULT_STAT_REALERT_MINUTES = 15;
|
|
61
62
|
const PRE_DECISION_STATUSES = ['open', 'documenting', 'draft_ready', 'handing_off', 'awaiting_doctor'];
|
|
62
63
|
const ALERT_OPERATOR = 'bot:escalationAlert';
|
|
@@ -823,12 +824,15 @@ async function prepareDoctorAlert(review, kind, urgencyLevel) {
|
|
|
823
824
|
const identity = await readDoctorIdentity(review);
|
|
824
825
|
if (identity.missing.length) throw new Error(`missing ${identity.missing.join(' and ')}`);
|
|
825
826
|
const approver = await soleApprover();
|
|
826
|
-
const link =
|
|
827
|
-
|
|
828
|
-
const
|
|
827
|
+
const link = conversationLink(review.patientCode);
|
|
828
|
+
if (!link) throw new Error('missing the interface URL for the chat link');
|
|
829
|
+
const alarm = (review.alarms ?? []).findLast((raised) => raised.urgencyLevel === urgencyLevel) ?? review.alarms?.at(-1);
|
|
830
|
+
const symptom = inlineOf(alarm?.symptom);
|
|
831
|
+
const urgency = [kind === 'realert' && 'Sigue pendiente', urgencyLevel.toUpperCase()].filter(Boolean).join(' · ');
|
|
832
|
+
const patient = `${identity.patientName} (${identity.treatingDoctor})`;
|
|
829
833
|
const message = {
|
|
830
|
-
body: `${
|
|
831
|
-
template: { 1: identity.patientName, 2: identity.treatingDoctor, 3:
|
|
834
|
+
body: `${ALERT_MARKS[urgencyLevel]} ${[urgency, patient, symptom].filter(Boolean).join(' · ')}\n${link}`,
|
|
835
|
+
template: { 1: identity.patientName, 2: identity.treatingDoctor, 3: [urgency, symptom].filter(Boolean).join(' · '), 4: link },
|
|
832
836
|
};
|
|
833
837
|
return { approver, message };
|
|
834
838
|
}
|