Skip to content

Commit 978a6cd

Browse files
Update review page to include all medical info as summaries (#198)
* Clean up summary lists * Add medical history to review page * Add utils for summarising medical history * Add medical history type selection page * Include condensed summaries on review page * Add summaries of breast features and symptoms * Add summaries for other relevant medical information * Add individual confirm pages * Rename review to check information * Add special appointment reasons * Hide previous address * Guard link so that it only shows for appointments before images
1 parent 5f1a9e8 commit 978a6cd

27 files changed

+1819
-571
lines changed

app/data/session-data-defaults.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ const defaultSettings = {
6464
screening: {
6565
confirmIdentityOnCheckIn: 'true',
6666
manualImageCollection: 'true',
67-
showParticipantSection: 'false'
67+
showParticipantSection: 'false',
68+
useCondensedReviewSummaries: 'true'
6869
},
6970
reading: {
7071
blindReading: config.reading.blindReading,

app/data/test-scenarios.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,38 @@ module.exports = [
9292
config: {
9393
eventId: '0gdof6fh',
9494
defaultRiskLevel: 'routine',
95-
missingViews: ['RMLO', 'RCC'], // ensure all views are present
95+
repeatViews: [],
96+
missingViews: [],
9697
scheduling: {
9798
whenRelativeToToday: 0,
98-
status: 'event_scheduled',
99+
status: 'event_in_progress',
99100
approximateTime: '11:30'
100101
// slotIndex: 20,
102+
},
103+
workflowStatus: {
104+
'appointment': 'started',
105+
'confirm-identity': 'completed',
106+
'review-medical-information': 'completed',
107+
'awaiting-images': 'completed',
108+
'take-images': 'completed'
109+
},
110+
// Force 100% of all medical information types for testing
111+
medicalInformation: {
112+
probabilityOfSymptoms: 1.0,
113+
probabilityOfHRT: 1.0,
114+
probabilityOfPregnancyBreastfeeding: 1.0,
115+
probabilityOfOtherMedicalInfo: 1.0,
116+
probabilityOfBreastFeatures: 1.0,
117+
probabilityOfMedicalHistory: 1.0,
118+
forceMedicalHistoryTypes: [
119+
'breastCancer',
120+
'implantedMedicalDevice',
121+
'breastImplantsAugmentation',
122+
'mastectomyLumpectomy',
123+
'cysts',
124+
'benignLumps',
125+
'otherProcedures'
126+
]
101127
}
102128
}
103129
}

app/lib/generators/event-generator.js

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,21 +147,29 @@ const generateEvent = ({
147147

148148
// For in-progress events, add session details with current time
149149
if (eventStatus === 'event_in_progress') {
150-
// Pick a random clinical user (not the first one)
151150
const clinicalUsers = users.filter((user) =>
152151
user.role.includes('clinician')
153152
)
154-
const randomUser = faker.helpers.arrayElement(clinicalUsers.slice(1)) // Skip first user
153+
// For forced in-progress (test scenarios), use first user; otherwise random
154+
const randomUser =
155+
forceStatus === 'event_in_progress'
156+
? clinicalUsers[0]
157+
: faker.helpers.arrayElement(clinicalUsers.slice(1))
155158

156159
eventBase.sessionDetails = {
157160
startedAt: dayjs()
158161
.subtract(faker.number.int({ min: 5, max: 45 }), 'minutes')
159162
.toISOString(),
160163
startedBy: randomUser.id
161164
}
165+
166+
// Add workflow status from participant config if provided
167+
if (participant.config?.workflowStatus) {
168+
eventBase.workflowStatus = participant.config.workflowStatus
169+
}
162170
}
163171

164-
if (!isPast && !forceInProgress) {
172+
if (!isPast && !forceInProgress && forceStatus !== 'event_in_progress') {
165173
// Generate appointment note for scheduled events (5% probability)
166174
const appointmentNote = generateAppointmentNote({
167175
isScheduled: true,
@@ -258,6 +266,31 @@ const generateEvent = ({
258266
}
259267
}
260268

269+
// Generate medical information for in-progress events too
270+
// (they would have collected this during check-in/pre-screening)
271+
if (eventStatus === 'event_in_progress' && event.sessionDetails) {
272+
const medicalInformation = generateMedicalInformation({
273+
addedByUserId: event.sessionDetails.startedBy,
274+
config: participant.config,
275+
// Allow config to override probabilities for test scenarios
276+
...(participant.config?.medicalInformation || {})
277+
})
278+
279+
// Store medical information if any was generated
280+
if (Object.keys(medicalInformation).length > 0) {
281+
event.medicalInformation = medicalInformation
282+
}
283+
284+
// Generate mammogram images if workflow indicates images have been taken
285+
if (event.workflowStatus?.['take-images'] === 'completed') {
286+
event.mammogramData = generateMammogramImages({
287+
startTime: dayjs(event.sessionDetails.startedAt),
288+
isSeedData: true,
289+
config: participant.config
290+
})
291+
}
292+
}
293+
261294
// Add session details for attended-not-screened events
262295
if (eventStatus === 'event_attended_not_screened') {
263296
const clinicalUsers = users.filter((user) =>
@@ -328,4 +361,4 @@ const generateStatusHistory = (finalStatus, dateTime) => {
328361

329362
module.exports = {
330363
generateEvent
331-
}
364+
}

app/lib/generators/medical-information/medical-history-generator.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ const generateBreastCancerItem = (options = {}) => {
119119

120120
const item = {
121121
id: generateId(),
122+
medicalHistoryType: 'breastCancer',
122123
dateAdded: new Date().toISOString(),
123124
addedBy: addedByUserId || null
124125
}
@@ -306,6 +307,7 @@ const generateBreastImplantsItem = (options = {}) => {
306307

307308
const item = {
308309
id: generateId(),
310+
medicalHistoryType: 'breastImplantsAugmentation',
309311
dateAdded: new Date().toISOString(),
310312
addedBy: addedByUserId || null
311313
}
@@ -373,6 +375,7 @@ const generateMastectomyLumpectomyItem = (options = {}) => {
373375

374376
const item = {
375377
id: generateId(),
378+
medicalHistoryType: 'mastectomyLumpectomy',
376379
dateAdded: new Date().toISOString(),
377380
addedBy: addedByUserId || null
378381
}
@@ -467,6 +470,7 @@ const generateImplantedDeviceItem = (options = {}) => {
467470

468471
const item = {
469472
id: generateId(),
473+
medicalHistoryType: 'implantedMedicalDevice',
470474
dateAdded: new Date().toISOString(),
471475
addedBy: addedByUserId || null
472476
}
@@ -518,6 +522,7 @@ const generateCystsItem = (options = {}) => {
518522

519523
const item = {
520524
id: generateId(),
525+
medicalHistoryType: 'cysts',
521526
dateAdded: new Date().toISOString(),
522527
addedBy: addedByUserId || null
523528
}
@@ -558,6 +563,7 @@ const generateBenignLumpsItem = (options = {}) => {
558563

559564
const item = {
560565
id: generateId(),
566+
medicalHistoryType: 'benignLumps',
561567
dateAdded: new Date().toISOString(),
562568
addedBy: addedByUserId || null
563569
}
@@ -692,6 +698,7 @@ const generateOtherProceduresItem = (options = {}) => {
692698

693699
const item = {
694700
id: generateId(),
701+
medicalHistoryType: 'otherProcedures',
695702
dateAdded: new Date().toISOString(),
696703
addedBy: addedByUserId || null
697704
}

0 commit comments

Comments
 (0)