Skip to content

Commit 8ef020c

Browse files
Swap to 'complete' status
1 parent 4977cab commit 8ef020c

File tree

7 files changed

+35
-20
lines changed

7 files changed

+35
-20
lines changed

app/lib/generators/event-generator.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const determineEventStatus = (slotDateTime, currentDateTime, attendanceWeights)
2929
}
3030

3131
if (slotDate.isBefore(currentDate)){
32-
const finalStatuses = ['attended', 'did_not_attend', 'attended_not_screened'];
32+
const finalStatuses = ['complete', 'did_not_attend', 'attended_not_screened'];
3333
return weighted.select(finalStatuses, attendanceWeights);
3434
}
3535

@@ -41,14 +41,14 @@ const determineEventStatus = (slotDateTime, currentDateTime, attendanceWeights)
4141
// Within 30 mins of appointment
4242
return weighted.select({
4343
'checked_in': 0.6,
44-
'attended': 0.1,
44+
'complete': 0.1,
4545
'attended_not_screened': 0.1,
4646
'scheduled': 0.2,
4747
});
4848
} else {
4949
// More than 30 mins after appointment
5050
return weighted.select({
51-
'attended': 0.6,
51+
'complete': 0.6,
5252
'attended_not_screened': 0.1,
5353
'scheduled': 0.2,
5454
});
@@ -120,15 +120,15 @@ const generateEvent = ({ slot, participant, clinic, outcomeWeights }) => {
120120
status,
121121
details: {
122122
...eventBase.details,
123-
imagesTaken: status === 'attended' ?
123+
imagesTaken: status === 'complete' ?
124124
['RCC', 'LCC', 'RMLO', 'LMLO'] : null,
125125
notScreenedReason: status === 'attended_not_screened' ?
126126
faker.helpers.arrayElement(NOT_SCREENED_REASONS) : null
127127
},
128128
statusHistory: generateStatusHistory(status, slotDateTime)
129129
};
130130

131-
if (status === 'attended') {
131+
if (status === 'complete') {
132132
const actualStartOffset = faker.number.int({ min: -5, max: 5 });
133133

134134
// For special events, allow more time variation
@@ -161,7 +161,7 @@ const generateStatusHistory = (finalStatus, dateTime) => {
161161
});
162162

163163
// Add intermediate statuses based on final status
164-
if (finalStatus === 'attended') {
164+
if (finalStatus === 'complete') {
165165
history.push(
166166
{
167167
status: 'checked_in',

app/lib/utils/status.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const getStatusTagColour = (status) => {
1515

1616
// Event statuses
1717
checked_in: 'yellow',
18-
attended: 'green',
18+
complete: 'green',
1919
did_not_attend: 'red',
2020
attended_not_screened: 'orange'
2121
};
@@ -38,7 +38,7 @@ const getStatusDescription = (status) => {
3838
scheduled: 'Appointment is booked',
3939
pre_screening: 'Patient is completing pre-screening',
4040
in_progress: 'Screening in progress',
41-
attended: 'Patient attended and was screened',
41+
complete: 'Patient attended and was screened',
4242
did_not_attend: 'Patient did not attend',
4343
attended_not_screened: 'Patient attended but was not screened'
4444
};
@@ -52,8 +52,8 @@ const getStatusDescription = (status) => {
5252
return events.filter(e => e.status === 'scheduled');
5353
case 'checked-in':
5454
return events.filter(e => e.status === 'checked_in');
55-
case 'attended':
56-
return events.filter(e => ['attended', 'attended_not_screened'].includes(e.status));
55+
case 'complete':
56+
return events.filter(e => ['complete', 'attended_not_screened'].includes(e.status));
5757
default:
5858
return events;
5959
}

app/routes/clinics.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,15 +261,15 @@ module.exports = router => {
261261
case 'checked-in':
262262
console.log('filtering checked in')
263263
return events.filter(e => e.status === 'checked_in');
264-
case 'attended':
265-
return events.filter(e => ['attended', 'attended_not_screened'].includes(e.status));
264+
case 'complete':
265+
return events.filter(e => ['complete', 'attended_not_screened'].includes(e.status));
266266
default:
267267
return events;
268268
}
269269
}
270270

271271
// Single clinic view
272-
const VALID_FILTERS = ['scheduled', 'checked-in', 'attended', 'all'];
272+
const VALID_FILTERS = ['scheduled', 'checked-in', 'complete', 'all'];
273273

274274
// Support both /clinics/:id and /clinics/:id/:filter
275275
router.get(['/clinics/:id', '/clinics/:id/:filter'], (req, res) => {

app/routes/events.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ module.exports = router => {
4747

4848
// Set clinics to active in nav for all urls starting with /clinics
4949
router.use('/clinics/:clinicId/events/:eventId', (req, res, next) => {
50+
const data = req.session.data
5051
const eventData = getEventData(req.session.data, req.params.clinicId, req.params.eventId)
5152

5253
if (!eventData) {
@@ -55,6 +56,20 @@ module.exports = router => {
5556
return
5657
}
5758

59+
// An idea for how we could automate saving back to participant
60+
// if (data.saveToParticipant){
61+
// const participantIndex = data.participants.findIndex(p => p.id === eventData.participant.id);
62+
// if (participantIndex !== -1) {
63+
// // Update participant record with questionnaire data
64+
// data.participants[participantIndex] = {
65+
// ...data.participants[participantIndex],
66+
// ...data.saveToParticipant
67+
// };
68+
69+
// delete data.saveToParticipant
70+
// }
71+
// }
72+
5873
res.locals.eventData = eventData
5974
res.locals.clinic = eventData.clinic,
6075
res.locals.event = eventData.event,
@@ -116,7 +131,7 @@ module.exports = router => {
116131
})
117132

118133
// // Advance status to attened / complete
119-
// router.post('/clinics/:clinicId/events/:eventId/attended', (req, res) => {
134+
// router.post('/clinics/:clinicId/events/:eventId/complete', (req, res) => {
120135

121136
// res.redirect(`/clinics/${req.params.clinicId}/events/${req.params.eventId}`, {
122137
// })
@@ -144,7 +159,7 @@ module.exports = router => {
144159
const eventIndex = req.session.data.events.findIndex(e => e.id === eventId)
145160
req.session.data.events[eventIndex] = updateEventStatus(
146161
req.session.data.events[eventIndex],
147-
'attended'
162+
'complete'
148163
)
149164

150165
res.redirect(`/clinics/${clinicId}/events/${eventId}`)

app/views/clinics/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ <h1>{{pageHeading}}</h1>
8787
<td>{{ clinic.clinicType | sentenceCase }}</td>
8888
<td class="nhsuk-table__cell--numeric">
8989
{{ tag({
90-
text: clinic.status | formatWords | sentenceCase,
90+
html: clinic.status | formatWords | sentenceCase | noWrap,
9191
classes: "nhsuk-tag--" + clinic.status | getStatusTagColour
9292
})}}
9393
</td>

app/views/clinics/show.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ <h1 class="nhsuk-heading-l">
2828
{ id: 'all', label: 'All participants' },
2929
{ id: 'scheduled', label: 'Scheduled' },
3030
{ id: 'checked-in', label: 'Checked in' },
31-
{ id: 'attended', label: 'Attended' }
31+
{ id: 'complete', label: 'Complete' }
3232
] %}
3333
{% set href -%}
3434
/clinics/{{ clinicId }}/{{ filter.id if filter.id !== 'all' }}

app/views/events/show.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
{% set activeTab = 'all' %}
2323

24-
{% if event.status == "attended" %}
24+
{% if event.status == "complete" %}
2525
{% include "event-navigation.njk" %}
2626
{% endif %}
2727

@@ -45,7 +45,7 @@
4545

4646
{% set appointmentTimeHtml -%}
4747
<p>{{ clinic.date | formatDate }} ({{ clinic.date | formatRelativeDate }})</p>
48-
<p>{{ event.timing | formatTimeRange }} ({{ event.timing.duration }} minutes)</p>
48+
<p>{{ event.timing.startTime | formatTime }} ({{ event.timing.duration }} minutes)</p>
4949

5050
{% endset %}
5151

@@ -163,7 +163,7 @@
163163
{% set lastMammogram = null %}
164164

165165
{% for record in clinicHistory %}
166-
{% if record.event.status === 'attended' and (not lastMammogram or record.event.timing.startTime > lastMammogram.event.timing.startTime) %}
166+
{% if record.event.status === 'complete' and (not lastMammogram or record.event.timing.startTime > lastMammogram.event.timing.startTime) %}
167167
{% set lastMammogram = record %}
168168
{% endif %}
169169
{% endfor %}

0 commit comments

Comments
 (0)