@peopl-health/nexus 6.2.0-dev.18343 → 6.2.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.
|
@@ -57,7 +57,6 @@ const graveDueAt = (review, clock, flag) => {
|
|
|
57
57
|
function outcomeOf(review, clock, now) {
|
|
58
58
|
const wait = pendingWaitMinutes(clock?.level);
|
|
59
59
|
if (!wait || !OUTCOME_LEVELS.includes(clock.level) || !['draft_ready', 'awaiting_doctor'].includes(review.status)) return null;
|
|
60
|
-
// Handoffs count since the last decision, so a higher alarm on a case already with the doctor goes as an update.
|
|
61
60
|
const decidedAt = Math.max(0, ...(review.decisions ?? []).map((decision) => timeOf(decision.createdAt)));
|
|
62
61
|
const handoffs = (review.doctorHandoffs ?? []).filter((handoff) => timeOf(handoff.createdAt) > decidedAt);
|
|
63
62
|
const last = handoffs.at(-1);
|
|
@@ -74,7 +73,7 @@ function outcomeOf(review, clock, now) {
|
|
|
74
73
|
const present = latest.urgentPresentRedFlags ?? [];
|
|
75
74
|
// An update reaches the doctor's phone only with a grave flag the draft they have did not show; the panel always shows the latest draft.
|
|
76
75
|
const handedPresent = new Set((update ? review.drafts[last.draftNumber - 1]?.urgentPresentRedFlags ?? [] : []).map(flagKey));
|
|
77
|
-
//
|
|
76
|
+
// Airtable's alert reaches the team, not the doctor's phone.
|
|
78
77
|
const raisedSince = (level) => (review.alarms ?? []).some((alarm) => alarm.urgencyLevel === level && timeOf(alarm.raisedAt) > timeOf(last.createdAt));
|
|
79
78
|
const rangSince = update && (review.doctorAlerts ?? []).some((sent) => sent.kind === 'initial' && !sent.error
|
|
80
79
|
&& sent.transport && sent.transport !== 'airtable' && timeOf(sent.sentAt) > timeOf(last.createdAt) && raisedSince(sent.urgencyLevel));
|
|
@@ -1030,7 +1030,7 @@ async function caseTakenReason(review, from, level) {
|
|
|
1030
1030
|
const changes = review.urgencyReclassifications ?? [];
|
|
1031
1031
|
const levelsAt = (at) => levelsOf(currentAlarms(review).filter((alarm) => new Date(alarm.raisedAt) <= new Date(at)), changes.filter((change) => new Date(change.at) < new Date(at)), appliedLevelOf);
|
|
1032
1032
|
if (level !== 'stat' && levelsAt(new Date(8.64e15)).some((entry) => entry.level === 'stat')) return 'stat_alarm';
|
|
1033
|
-
//
|
|
1033
|
+
// A lowering means someone looked at the case; a raise restarts the clock instead.
|
|
1034
1034
|
const lowered = (change) => (URGENCY_RANK[change.toLevel] || 0) < Math.max(0, ...levelsAt(change.at).map((entry) => URGENCY_RANK[entry.level] || 0));
|
|
1035
1035
|
if (changes.some((change) => atOrAfter(change.at) && lowered(change))) return 'reclassified';
|
|
1036
1036
|
if ((review.callLogs ?? []).some((call) => call.outcome === 'contacted' && atOrAfter(call.calledAt))) return 'call_contacted';
|
|
@@ -20,7 +20,6 @@ function pendingFlagsOf(review, since) {
|
|
|
20
20
|
return { latest: drafts.at(-1) ?? null, flags: [...firstSeen].map(([flag, firstSeenAt]) => ({ flag, firstSeenAt, unobtainable: unobtainable.includes(flag) })) };
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
// The bot keeps documenting a case it handed to the doctor itself while it still redrafts it, so its grave questions still wait for the patient there.
|
|
24
23
|
const stillDocumented = (review) => DOCUMENTING_STATUSES.includes(review.status) || updatesDoctor(review);
|
|
25
24
|
|
|
26
25
|
// The latest draft speaks for the case only while no newer patient turn or redraft is waiting to replace it.
|
|
@@ -45,7 +45,7 @@ function responseDeadlinePolicy() {
|
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
//
|
|
48
|
+
// A raise restarts the alarm's clock; a lowering keeps it.
|
|
49
49
|
function levelsOf(alarms, reclassifications, startLevel = (alarm) => alarm.urgencyLevel) {
|
|
50
50
|
const changes = [...(reclassifications ?? [])].sort((a, b) => timeOf(a.at) - timeOf(b.at));
|
|
51
51
|
return (alarms ?? []).map((alarm) => changes
|
|
@@ -34,8 +34,7 @@ const duration = (minutes) => {
|
|
|
34
34
|
return rest ? `${hours} h ${rest} min` : `${hours} h`;
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
//
|
|
38
|
-
// The episode keeps the start the alarms' own levels give it, so a reclassification never re-keys its drafts or grave alerts.
|
|
37
|
+
// Only the stages restart on a raise; the episode start ignores reclassifications so drafts and grave alerts keep their key.
|
|
39
38
|
function episodeStartOf(alarms) {
|
|
40
39
|
const top = alarms.reduce((level, alarm) => ((URGENCY_RANK[appliedLevelOf(alarm)] || 0) > (URGENCY_RANK[level] || 0) ? appliedLevelOf(alarm) : level), null);
|
|
41
40
|
return new Date(Math.min(...alarms.filter((alarm) => appliedLevelOf(alarm) === top).map((alarm) => new Date(alarm.raisedAt).getTime())));
|