@@ -1462,12 +1462,16 @@ module.exports = (router) => {
14621462 const data = req . session . data
14631463 const isPartialMammography = data . event . mammogramData . isPartialMammography
14641464
1465- if ( ! isPartialMammography ) {
1466- res . redirect ( `/clinics/${ clinicId } /events/${ eventId } /imaging` )
1467- } else {
1468- data . event . workflowStatus [ 'take-images' ] = 'completed'
1469- res . redirect ( `/clinics/${ clinicId } /events/${ eventId } /review` )
1470- }
1465+ // Check if array includes 'yes' (checkbox format) or equals 'yes' (string format from manual entry)
1466+ const hasPartialMammography = Array . isArray ( isPartialMammography )
1467+ ? isPartialMammography . includes ( 'yes' )
1468+ : isPartialMammography === 'yes'
1469+
1470+ // Mark the workflow step as completed regardless of partial mammography status
1471+ data . event . workflowStatus [ 'take-images' ] = 'completed'
1472+
1473+ // Redirect to review page
1474+ res . redirect ( `/clinics/${ clinicId } /events/${ eventId } /review` )
14711475 }
14721476 )
14731477
@@ -1559,44 +1563,16 @@ module.exports = (router) => {
15591563 machineRoom : mammogramData . machineRoom ,
15601564 isPartialMammography :
15611565 mammogramData . isPartialMammography === 'yes' ? [ 'yes' ] : [ ] ,
1566+ partialMammographyReasonSelect :
1567+ mammogramData . partialMammographyReasonSelect ,
1568+ partialMammographyReasonComment :
1569+ mammogramData . partialMammographyReasonComment ,
1570+ partialMammographyShouldReinvite :
1571+ mammogramData . partialMammographyShouldReinvite === 'yes' ? [ 'yes' ] : [ ] ,
15621572 additionalDetails : mammogramData . additionalDetails ,
15631573 viewsRightBreast : [ ] ,
15641574 viewsLeftBreast : [ ]
1565- }
1566-
1567- // Split the combined partial mammography reason back into select and comment
1568- if ( mammogramData . partialMammographyReason ) {
1569- const reason = mammogramData . partialMammographyReason
1570- // Check if it contains a colon (meaning it was a select + comment)
1571- if ( reason . includes ( ':' ) ) {
1572- const parts = reason . split ( ':' )
1573- formData . partialMammographyReasonSelect = parts [ 0 ] . trim ( )
1574- formData . partialMammographyReasonComment = parts
1575- . slice ( 1 )
1576- . join ( ':' )
1577- . trim ( )
1578- } else {
1579- // Could be either just select or just comment
1580- // Check if it matches one of the predefined reasons
1581- const predefinedReasons = [
1582- 'Exam limited due to chronic disease condition' ,
1583- 'Withdrew consent' ,
1584- 'Unable to co-operate due to limited understanding of the procedure' ,
1585- 'Exam limited due to implanted medical device' ,
1586- 'Restricted mobility - unable to attain / maintain position' ,
1587- 'Exam performed in a wheelchair which restricted positioning' ,
1588- 'Other'
1589- ]
1590-
1591- if ( predefinedReasons . includes ( reason ) ) {
1592- formData . partialMammographyReasonSelect = reason
1593- } else {
1594- formData . partialMammographyReasonComment = reason
1595- }
1596- }
1597- }
1598-
1599- // Convert views back to checkbox/input format
1575+ } // Convert views back to checkbox/input format
16001576 for ( const [ viewKey , viewData ] of Object . entries ( mammogramData . views ) ) {
16011577 const breastKey =
16021578 viewData . side === 'right' ? 'viewsRightBreast' : 'viewsLeftBreast'
@@ -1699,6 +1675,8 @@ module.exports = (router) => {
16991675
17001676 // Handle partial mammography reason - combine select and comment
17011677 let partialMammographyReason = null
1678+ let partialMammographyShouldReinvite = null
1679+
17021680 if ( formData . isPartialMammography ?. includes ( 'yes' ) ) {
17031681 const reasonSelect = formData . partialMammographyReasonSelect
17041682 const reasonComment = formData . partialMammographyReasonComment
@@ -1710,6 +1688,12 @@ module.exports = (router) => {
17101688 } else if ( reasonComment ) {
17111689 partialMammographyReason = reasonComment
17121690 }
1691+
1692+ // Convert checkbox array to string for consistency
1693+ partialMammographyShouldReinvite =
1694+ formData . partialMammographyShouldReinvite ?. includes ( 'yes' )
1695+ ? 'yes'
1696+ : null
17131697 }
17141698
17151699 return {
@@ -1720,6 +1704,9 @@ module.exports = (router) => {
17201704 ? 'yes'
17211705 : null ,
17221706 partialMammographyReason,
1707+ partialMammographyReasonSelect : formData . partialMammographyReasonSelect ,
1708+ partialMammographyReasonComment : formData . partialMammographyReasonComment ,
1709+ partialMammographyShouldReinvite,
17231710 additionalDetails : formData . additionalDetails ,
17241711 metadata : {
17251712 totalImages,
0 commit comments