Skip to content

Commit e733bea

Browse files
rivaleecolinrotherhamedwardhorsford
authored
Special appointments (#106)
* Add routes for special appointments * Add special appointments flow * Get summary list working in the special appointment callout * Update content to include implanted medical devices * Get banners working on page * Make sure we use the right data for tags * Clear temporary reasons list if none are temporary --------- Co-authored-by: Colin Rotherham <[email protected]> Co-authored-by: Ed Horsford <[email protected]>
1 parent 2d21780 commit e733bea

File tree

17 files changed

+754
-105
lines changed

17 files changed

+754
-105
lines changed

app/assets/sass/_misc.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,5 @@
5656

5757
.nhsuk-card--feature {
5858
@include nhsuk-responsive-margin(5, "top");
59-
}
59+
60+
}

app/data/test-scenarios.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,16 @@ module.exports = [
1919
ethnicGroup: null,
2020
ethnicBackground: null,
2121
},
22-
extraNeeds: ['Wheelchair user'],
2322
config: {
2423
eventId: '5gpn41oi',
2524
defaultRiskLevel: 'routine',
2625
repeatViews: ['RMLO'],
2726
missingViews: [], // ensure all views are present
27+
specialAppointment: {
28+
supportTypes: ['Physical restriction'],
29+
physicalRestrictionDetails: 'Uses wheelchair, needs accessible positioning and additional time for transfers',
30+
temporaryReasons: 'no'
31+
},
2832
scheduling: {
2933
whenRelativeToToday: 0,
3034
status: 'event_scheduled',
@@ -58,4 +62,4 @@ module.exports = [
5862
},
5963
},
6064
},
61-
]
65+
]

app/lib/generate-seed-data.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ const generateClinicsForDay = (date, allParticipants, unit, usedParticipantsInSn
147147
id: scenario?.participant?.config?.eventId,
148148
outcomeWeights: config.screening.outcomes[firstClinic.clinicType],
149149
forceStatus: scenario.participant.config.scheduling.status,
150+
specialAppointmentOverride: scenario?.participant?.config?.specialAppointment,
150151
})
151152

152153
events.push(event)

app/lib/generators/event-generator.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const config = require('../../config')
88
const { STATUS_GROUPS, isCompleted, isFinal } = require('../utils/status')
99
const { generateMammogramImages } = require('./mammogram-generator')
1010
const { generateSymptoms } = require('./symptoms-generator')
11+
const { generateSpecialAppointment } = require('./special-appointment-generator')
1112
const { users } = require('../../data/users')
1213

1314
const NOT_SCREENED_REASONS = [
@@ -60,18 +61,19 @@ const determineEventStatus = (slotDateTime, currentDateTime, attendanceWeights)
6061
}
6162
}
6263

63-
const generateEvent = ({ slot, participant, clinic, outcomeWeights, forceStatus = null, id = null }) => {
64+
const generateEvent = ({ slot, participant, clinic, outcomeWeights, forceStatus = null, id = null, specialAppointmentOverride = null }) => {
6465
// Parse dates once
6566
const [hours, minutes] = config.clinics.simulatedTime.split(':')
6667
const simulatedDateTime = dayjs().hour(parseInt(hours)).minute(parseInt(minutes))
6768
const slotDateTime = dayjs(slot.dateTime)
6869
const isPast = slotDateTime.isBefore(simulatedDateTime)
6970

70-
// Check if this is a special event (participant has extra needs)
71-
const isSpecialAppointment = Boolean(participant.extraNeeds?.length)
71+
// Generate special appointment requirements for this event
72+
const specialAppointment = specialAppointmentOverride || generateSpecialAppointment()
73+
const hasSpecialAppointment = Boolean(specialAppointment?.supportTypes?.length)
7274

73-
// Double the duration for participants with extra needs
74-
const duration = isSpecialAppointment ? slot.duration * 2 : slot.duration
75+
// Double the duration for special appointments
76+
const duration = hasSpecialAppointment ? slot.duration * 2 : slot.duration
7577
const endDateTime = dayjs(slot.dateTime).add(duration, 'minute')
7678

7779
const attendanceWeights = clinic.clinicType === 'assessment'
@@ -96,8 +98,6 @@ const generateEvent = ({ slot, participant, clinic, outcomeWeights, forceStatus
9698
details: {
9799
screeningType: 'mammogram',
98100
machineId: generateId(),
99-
isSpecialAppointment,
100-
extraNeeds: participant.extraNeeds,
101101
},
102102
statusHistory: [
103103
{
@@ -107,6 +107,11 @@ const generateEvent = ({ slot, participant, clinic, outcomeWeights, forceStatus
107107
],
108108
}
109109

110+
// Add special appointment data if present
111+
if (specialAppointment) {
112+
eventBase.specialAppointment = specialAppointment
113+
}
114+
110115
if (!isPast) {
111116
return eventBase
112117
}
@@ -123,12 +128,17 @@ const generateEvent = ({ slot, participant, clinic, outcomeWeights, forceStatus
123128
},
124129
}
125130

131+
// Add special appointment data if present
132+
if (specialAppointment) {
133+
event.specialAppointment = specialAppointment
134+
}
135+
126136
// Add timing details for completed appointments
127137
if (isCompleted(eventStatus)) {
128138

129139
// if (eventStatus === 'event_complete' || eventStatus === 'event_partially_screened') {
130140
const actualStartOffset = faker.number.int({ min: -5, max: 5 })
131-
const durationOffset = isSpecialAppointment
141+
const durationOffset = hasSpecialAppointment
132142
? faker.number.int({ min: -3, max: 10 })
133143
: faker.number.int({ min: -3, max: 5 })
134144

@@ -212,4 +222,4 @@ const generateStatusHistory = (finalStatus, dateTime) => {
212222

213223
module.exports = {
214224
generateEvent,
215-
}
225+
}

app/lib/generators/participant-generator.js

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ const generateEthnicity = (ethnicities) => {
6262
}
6363
}
6464

65-
6665
// Pick a random risk level based on configured weights
6766
const pickRiskLevel = () => {
6867
// Create weights object from risk levels
@@ -76,40 +75,6 @@ const pickRiskLevel = () => {
7675
return weighted.select(weights)
7776
}
7877

79-
// List of possible extra needs
80-
const EXTRA_NEEDS = [
81-
'Agoraphobia',
82-
// 'Breast implants', // needs consent journey that isn't designed yet
83-
'Learning difficulties',
84-
'Physical restriction',
85-
'Registered disabled',
86-
'Social reasons',
87-
'Wheelchair user',
88-
'Transgender',
89-
// 'Other' // need to come up with some free text replies before using this
90-
]
91-
92-
// Generate extra needs for a participant
93-
const generateExtraNeeds = (config = { probability: 0.08 }) => {
94-
// Check if they should have extra needs
95-
if (Math.random() > config.probability) {
96-
return null
97-
}
98-
99-
// Use weighted to determine how many needs they should have
100-
const needCount = weighted.select({
101-
1: 0.7, // 70% chance of 1 need
102-
2: 0.2, // 20% chance of 2 needs
103-
3: 0.1, // 10% chance of 3 needs
104-
})
105-
106-
// Select that many random needs
107-
return faker.helpers.arrayElements(EXTRA_NEEDS, {
108-
min: needCount,
109-
max: needCount,
110-
})
111-
}
112-
11378
// Generate a UK mobile phone number
11479
const generateUKMobileNumber = () => {
11580
const suffix = faker.number.int({ min: 900000, max: 900999 })
@@ -280,7 +245,6 @@ const generateNonCancerousProcedures = () => {
280245
const generateParticipant = ({
281246
ethnicities,
282247
breastScreeningUnits,
283-
extraNeedsConfig = { probability: 0.08 },
284248
riskLevel = null,
285249
overrides = null,
286250
}) => {
@@ -306,7 +270,6 @@ const generateParticipant = ({
306270
id: id,
307271
sxNumber: generateSXNumber(faker.helpers.arrayElement(breastScreeningUnits).abbreviation),
308272
assignedBSU: assignedBSU.id,
309-
extraNeeds: generateExtraNeeds(extraNeedsConfig),
310273
hasRiskFactors: participantRiskLevel !== 'routine',
311274
seedRiskLevel: participantRiskLevel,
312275
demographicInformation: {
@@ -456,4 +419,4 @@ const generateMedications = () => {
456419

457420
module.exports = {
458421
generateParticipant,
459-
}
422+
}

0 commit comments

Comments
 (0)