@peopl-health/nexus 5.48.0-dev.7382 → 5.48.0-dev.7384
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.
|
@@ -140,14 +140,20 @@ const taskFilter = (kind, whatsappId) => {
|
|
|
140
140
|
|
|
141
141
|
const byOpenThenNewest = (a, b) => (b.isOpen - a.isOpen) || (b.createdAt || '').localeCompare(a.createdAt || '');
|
|
142
142
|
|
|
143
|
+
const needsUrgentAttention = (task) => task.needsAttention && task.isUrgent;
|
|
144
|
+
|
|
143
145
|
async function readTasks(kind, whatsappId) {
|
|
144
146
|
const { table, fields, toTask } = TASK_KINDS[kind];
|
|
145
147
|
const rows = await getRecordByFilter(Monitoreo_ID, table, taskFilter(kind, whatsappId), null, fields, true);
|
|
146
148
|
const tasks = rows.map(toTask).sort(byOpenThenNewest);
|
|
149
|
+
const capped = [...tasks.filter(needsUrgentAttention), ...tasks.filter((task) => !needsUrgentAttention(task))]
|
|
150
|
+
.slice(0, MAX_ROWS)
|
|
151
|
+
.sort(byOpenThenNewest);
|
|
147
152
|
return {
|
|
148
|
-
tasks:
|
|
153
|
+
tasks: capped,
|
|
149
154
|
openCount: tasks.filter((task) => task.isOpen).length,
|
|
150
155
|
attentionCount: tasks.filter((task) => task.needsAttention).length,
|
|
156
|
+
isUrgent: tasks.some(needsUrgentAttention),
|
|
151
157
|
};
|
|
152
158
|
}
|
|
153
159
|
|
|
@@ -159,7 +165,11 @@ async function getPatientTasks(code) {
|
|
|
159
165
|
cases: cases.tasks,
|
|
160
166
|
openCount: requests.openCount + cases.openCount,
|
|
161
167
|
attentionCount: requests.attentionCount + cases.attentionCount,
|
|
162
|
-
attention: {
|
|
168
|
+
attention: {
|
|
169
|
+
cases: cases.attentionCount,
|
|
170
|
+
requests: requests.attentionCount,
|
|
171
|
+
isUrgent: requests.isUrgent || cases.isUrgent,
|
|
172
|
+
},
|
|
163
173
|
options: { requestStatus: REQUEST_STATUSES, caseStatus: CASE_STATUSES, operationsStatus: OPERATIONS_STATUSES },
|
|
164
174
|
};
|
|
165
175
|
}
|