@@ -405,14 +405,16 @@ router.post('/reading/batch/:batchId/events/:eventId/annotation/save', (req, res
405405 const errors = [ ]
406406 const annotationTemp = data . imageReadingTemp ?. annotationTemp
407407
408+ console . log ( `annotation temp: ${ JSON . stringify ( annotationTemp ) } ` )
409+
408410 if ( ! annotationTemp ) {
409411 return res . redirect ( `/reading/batch/${ batchId } /events/${ eventId } /recall-for-assessment-details` )
410412 }
411413
412414 // Validate that marker positions are set for both views
413415 if ( ! annotationTemp . markerPositions || annotationTemp . markerPositions === '{}' || annotationTemp . markerPositions === '' ) {
414416 errors . push ( {
415- text : `Mark the location on both ${ annotationTemp . side } breast views ` ,
417+ text : `Mark the location on at least one ${ annotationTemp . side } breast view ` ,
416418 name : 'markerPositions' ,
417419 href : '#mammogram-section'
418420 } )
@@ -425,37 +427,38 @@ router.post('/reading/batch/:batchId/events/:eventId/annotation/save', (req, res
425427
426428 if ( ! positions || Object . keys ( positions ) . length === 0 ) {
427429 errors . push ( {
428- text : `Mark the location on both ${ annotationTemp . side } breast views ` ,
430+ text : `Mark the location on at least one ${ annotationTemp . side } breast view ` ,
429431 name : 'markerPositions' ,
430432 href : '#mammogram-section'
431433 } )
432- } else {
433- // Check we have markers for both image-0 and image-1 (both views)
434- const hasImage0 = positions [ 'image-0' ]
435- const hasImage1 = positions [ 'image-1' ]
436-
437- if ( ! hasImage0 && ! hasImage1 ) {
438- errors . push ( {
439- text : `Mark the location on both ${ annotationTemp . side } breast views` ,
440- name : 'markerPositions' ,
441- href : '#mammogram-section'
442- } )
443- } else if ( ! hasImage0 ) {
444- const viewName = annotationTemp . side === 'right' ? 'RMLO' : 'LMLO'
445- errors . push ( {
446- text : `Mark the location on the ${ annotationTemp . side } ${ viewName } view` ,
447- name : 'markerPositions' ,
448- href : '#mammogram-section'
449- } )
450- } else if ( ! hasImage1 ) {
451- const viewName = annotationTemp . side === 'right' ? 'RCC' : 'LCC'
452- errors . push ( {
453- text : `Mark the location on the ${ annotationTemp . side } ${ viewName } view` ,
454- name : 'markerPositions' ,
455- href : '#mammogram-section'
456- } )
457- }
458434 }
435+ // else {
436+ // // Check we have markers for both image-0 and image-1 (both views)
437+ // const hasImage0 = positions['image-0']
438+ // const hasImage1 = positions['image-1']
439+
440+ // if (!hasImage0 && !hasImage1) {
441+ // errors.push({
442+ // text: `Mark the location on both ${annotationTemp.side} breast views`,
443+ // name: 'markerPositions',
444+ // href: '#mammogram-section'
445+ // })
446+ // } else if (!hasImage0) {
447+ // const viewName = annotationTemp.side === 'right' ? 'RMLO' : 'LMLO'
448+ // errors.push({
449+ // text: `Mark the location on the ${annotationTemp.side} ${viewName} view`,
450+ // name: 'markerPositions',
451+ // href: '#mammogram-section'
452+ // })
453+ // } else if (!hasImage1) {
454+ // const viewName = annotationTemp.side === 'right' ? 'RCC' : 'LCC'
455+ // errors.push({
456+ // text: `Mark the location on the ${annotationTemp.side} ${viewName} view`,
457+ // name: 'markerPositions',
458+ // href: '#mammogram-section'
459+ // })
460+ // }
461+ // }
459462 } catch ( e ) {
460463 errors . push ( {
461464 text : `Mark the location on both ${ annotationTemp . side } breast views` ,
@@ -466,13 +469,15 @@ router.post('/reading/batch/:batchId/events/:eventId/annotation/save', (req, res
466469 }
467470
468471 // Validate required fields
469- if ( ! annotationTemp . location || annotationTemp . location . trim ( ) === '' ) {
470- errors . push ( {
471- text : 'Enter the location of the abnormality' ,
472- name : 'imageReadingTemp[annotationTemp][location]' ,
473- href : '#location'
474- } )
475- }
472+
473+ // Text location not in use
474+ // if (!annotationTemp.location || annotationTemp.location.trim() === '') {
475+ // errors.push({
476+ // text: 'Enter the location of the abnormality',
477+ // name: 'imageReadingTemp[annotationTemp][location]',
478+ // href: '#location'
479+ // })
480+ // }
476481
477482 if ( ! annotationTemp . abnormalityType || annotationTemp . abnormalityType . length === 0 ) {
478483 errors . push ( {
@@ -506,27 +511,27 @@ router.post('/reading/batch/:batchId/events/:eventId/annotation/save', (req, res
506511 }
507512
508513 // Check other conditional fields using the same camelCase logic as the template
509- const conditionalTypes = [
510- 'Mass well-defined' ,
511- 'Mass ill-defined' ,
512- 'Architectural distortion' ,
513- 'Asymetric density' ,
514- 'Microcalcification outside a mass' ,
515- 'Clinical abnormality' ,
516- 'Lymph node abnormality'
517- ]
518-
519- if ( conditionalTypes . includes ( type ) ) {
520- const detailsFieldName = camelCase ( type ) + 'Details'
521-
522- if ( ! annotationTemp [ detailsFieldName ] || annotationTemp [ detailsFieldName ] . trim ( ) === '' ) {
523- errors . push ( {
524- text : `Provide details for ${ type . toLowerCase ( ) } ` ,
525- name : `imageReadingTemp[annotationTemp][${ detailsFieldName } ]` ,
526- href : `#${ detailsFieldName } `
527- } )
528- }
529- }
514+ // const conditionalTypes = [
515+ // 'Mass well-defined',
516+ // 'Mass ill-defined',
517+ // 'Architectural distortion',
518+ // 'Asymetric density',
519+ // 'Microcalcification outside a mass',
520+ // 'Clinical abnormality',
521+ // 'Lymph node abnormality'
522+ // ]
523+
524+ // if (conditionalTypes.includes(type)) {
525+ // const detailsFieldName = camelCase(type) + 'Details'
526+
527+ // if (!annotationTemp[detailsFieldName] || annotationTemp[detailsFieldName].trim() === '') {
528+ // errors.push({
529+ // text: `Provide details for ${type.toLowerCase()}`,
530+ // name: `imageReadingTemp[annotationTemp][${detailsFieldName}]`,
531+ // href: `#${detailsFieldName}`
532+ // })
533+ // }
534+ // }
530535 } )
531536 }
532537
@@ -539,6 +544,7 @@ router.post('/reading/batch/:batchId/events/:eventId/annotation/save', (req, res
539544 // Continue with existing save logic...
540545 if ( data . imageReadingTemp ?. annotationTemp ) {
541546 const side = annotationTemp . side
547+ const comment = annotationTemp . comment
542548 const isNewAnnotation = ! annotationTemp . id
543549
544550 if ( ! side ) {
@@ -569,6 +575,7 @@ router.post('/reading/batch/:batchId/events/:eventId/annotation/save', (req, res
569575 const annotation = {
570576 id : annotationTemp . id || generateId ( ) ,
571577 side : side ,
578+ comment : comment ,
572579 location : annotationTemp . location ,
573580 abnormalityType : annotationTemp . abnormalityType ,
574581 levelOfConcern : annotationTemp . levelOfConcern ,
0 commit comments