Skip to content

Commit a49c0b5

Browse files
General code cleanup
1 parent ebcc0f5 commit a49c0b5

10 files changed

Lines changed: 115 additions & 666 deletions

File tree

app/config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ module.exports = {
4242
},
4343
reading: {
4444
blindReading: 'true', // Enable blind reading
45+
urgentThreshold: 10, // 10 days and over
46+
priorityThreshold: 7, // 7 days and over
4547
},
4648
screening: {
4749
outcomes: {

app/lib/utils/dates.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,23 +114,28 @@ const formatDateTime = (dateString, format = 'D MMMM YYYY, HH:mm') => {
114114
*/
115115
const formatRelativeDate = (dateString, withoutSuffix = false) => {
116116
if (!dateString) return ''
117+
118+
// Use the same calculation as daysSince for consistency
119+
const daysDiff = daysSince(dateString)
120+
121+
// Special cases for today, yesterday, tomorrow
117122
const date = dayjs(dateString).startOf('day')
118123
const now = dayjs().startOf('day')
119124

120125
if (date.isToday()) return 'today'
121-
if (date.isTomorrow()) return 'tomorrow'
122126
if (date.isYesterday()) return 'yesterday'
127+
if (date.isTomorrow()) return 'tomorrow'
123128

124-
// Calculate days difference for near dates
125-
const daysDiff = date.diff(now, 'day')
126-
if (daysDiff > 0 && daysDiff <= 6) {
127-
return `in ${daysDiff} day${daysDiff > 1 ? 's' : ''}`
128-
}
129+
// Calculate near future/past dates using same logic as daysSince
129130
if (daysDiff < 0 && daysDiff >= -6) {
130-
return `${Math.abs(daysDiff)} day${Math.abs(daysDiff) > 1 ? 's' : ''} ago`
131+
return `in ${Math.abs(daysDiff)} day${Math.abs(daysDiff) > 1 ? 's' : ''}`
132+
}
133+
if (daysDiff > 0 && daysDiff <= 6) {
134+
return `${daysDiff} day${daysDiff > 1 ? 's' : ''} ago`
131135
}
132136

133-
return date.fromNow(withoutSuffix)
137+
// Avoiding date.fromNow() as it seems to use the time of day and not just the date
138+
return date.from(now, withoutSuffix)
134139
}
135140

136141
/**

app/lib/utils/status.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,39 @@ const getStatusTagColour = (status) => {
119119
images_requested: 'orange',
120120
not_in_pacs: 'grey',
121121

122+
// Metadata
123+
has_symptoms: 'yellow',
124+
has_repeat: 'yellow',
125+
122126
// Reading statuses
127+
waiting_for_1st_read: 'grey',
128+
waiting_for_2nd_read: 'grey',
123129
not_started: 'grey',
130+
skipped: 'grey',
131+
not_read: 'grey',
132+
complete: 'green',
124133
partial_first_read: 'blue',
125134
first_read_complete: 'yellow',
126135
partial_second_read: 'blue',
127136
mixed_reads: 'yellow',
128137
mixed_with_arbitration: 'yellow',
129-
needs_arbitration: 'orange',
130-
complete: 'green',
138+
139+
131140
no_events: 'grey',
132141

142+
// Outcomes
143+
normal: 'green',
144+
recall_for_assessment: 'red',
145+
technical_recall: 'grey',
146+
arbitration: 'orange',
147+
'completed_(blind)': 'grey',
148+
149+
first_read: 'blue',
150+
second_read: 'blue',
151+
152+
urgent: 'red',
153+
due_soon: 'orange',
154+
133155
}
134156
return colourMap[status.toLowerCase()] || ''
135157
}

0 commit comments

Comments
 (0)