@@ -203,6 +203,8 @@ def _add_variable_selection_criteria(
203203 self ._add_criteria_subject_age ()
204204 case SubjectSelectionCriteriaKey .SUBJECT_HUB_CODE :
205205 self ._add_criteria_subject_hub_code (user )
206+ case SubjectSelectionCriteriaKey .DEMOGRAPHICS_TEMPORARY_ADDRESS :
207+ self ._add_criteria_has_temporary_address ()
206208 # ------------------------------------------------------------------------
207209 # 🏥 Screening Centre & GP Linkage Criteria
208210 # ------------------------------------------------------------------------
@@ -481,12 +483,9 @@ def _add_variable_selection_criteria(
481483 SubjectSelectionCriteriaKey .LATEST_EPISODE_DATASET_INTENDED_EXTENT
482484 ):
483485 self ._add_criteria_latest_episode_intended_extent ()
484- case SubjectSelectionCriteriaKey .SURVEILLANCE_REVIEW_STATUS :
485- self ._add_criteria_surveillance_review_status ()
486- case (
487- SubjectSelectionCriteriaKey .HAS_EXISTING_SURVEILLANCE_REVIEW_CASE
488- ):
489- self ._add_criteria_does_subject_have_surveillance_review_case ()
486+ # ------------------------------------------------------------------------
487+ # 📆 Clinical Milestones, Dates & Case History
488+ # ------------------------------------------------------------------------
490489 case SubjectSelectionCriteriaKey .SURVEILLANCE_REVIEW_CASE_TYPE :
491490 self ._add_criteria_surveillance_review_type ()
492491 case SubjectSelectionCriteriaKey .DATE_OF_DEATH :
@@ -501,6 +500,19 @@ def _add_variable_selection_criteria(
501500 self ._add_criteria_invited_since_age_extension ()
502501 case SubjectSelectionCriteriaKey .NOTE_COUNT :
503502 self ._add_criteria_note_count ()
503+ case SubjectSelectionCriteriaKey .SURVEILLANCE_REVIEW_STATUS :
504+ self ._add_criteria_surveillance_review_status ()
505+ case (
506+ SubjectSelectionCriteriaKey .HAS_EXISTING_SURVEILLANCE_REVIEW_CASE
507+ ):
508+ self ._add_criteria_does_subject_have_surveillance_review_case ()
509+ case SubjectSelectionCriteriaKey .SUBJECT_75TH_BIRTHDAY :
510+ self ._add_criteria_date_field (
511+ subject , "ALL_PATHWAYS" , "SEVENTY_FIFTH_BIRTHDAY"
512+ )
513+ # ------------------------------------------------------------------------
514+ # 🧪 Latest Episode Results & Symptomatic Pathway
515+ # ------------------------------------------------------------------------
504516 case (
505517 SubjectSelectionCriteriaKey .LATEST_EPISODE_ACCUMULATED_RESULT
506518 ):
@@ -519,6 +531,9 @@ def _add_variable_selection_criteria(
519531 )
520532 case SubjectSelectionCriteriaKey .SCREENING_REFERRAL_TYPE :
521533 self ._add_criteria_screening_referral_type ()
534+ # ------------------------------------------------------------------------
535+ # 🧬 Lynch Pathway Due Dates & Diagnosis Tracking
536+ # ------------------------------------------------------------------------
522537 case SubjectSelectionCriteriaKey .CALCULATED_LYNCH_DUE_DATE :
523538 self ._add_criteria_date_field (
524539 subject , "LYNCH" , "CALCULATED_DUE_DATE"
@@ -541,10 +556,6 @@ def _add_variable_selection_criteria(
541556 self ._add_criteria_date_field (
542557 subject , "LYNCH" , "LAST_COLONOSCOPY_DATE"
543558 )
544- case SubjectSelectionCriteriaKey .SUBJECT_75TH_BIRTHDAY :
545- self ._add_criteria_date_field (
546- subject , "ALL_PATHWAYS" , "SEVENTY_FIFTH_BIRTHDAY"
547- )
548559 # ------------------------------------------------------------------------
549560 # 🧬 CADS Clinical Dataset Filters
550561 # ------------------------------------------------------------------------
@@ -604,16 +615,23 @@ def _add_variable_selection_criteria(
604615 self ._add_criteria_cads_treatment_given ()
605616 case SubjectSelectionCriteriaKey .CADS_CANCER_TREATMENT_INTENT :
606617 self ._add_criteria_cads_cancer_treatment_intent ()
618+ case SubjectSelectionCriteriaKey .HAS_PREVIOUSLY_HAD_CANCER :
619+ self ._add_criteria_has_previously_had_cancer ()
620+ # ------------------------------------------------------------------------
621+ # 🧪 Screening Flow & Pathway Classification
622+ # ------------------------------------------------------------------------
607623 case SubjectSelectionCriteriaKey .FOBT_PREVALENT_INCIDENT_STATUS :
608624 self ._add_criteria_fobt_prevalent_incident_status ()
625+ # ------------------------------------------------------------------------
626+ # 📨 Notify Message Status Filters
627+ # ------------------------------------------------------------------------
609628 case SubjectSelectionCriteriaKey .NOTIFY_QUEUED_MESSAGE_STATUS :
610629 self ._add_criteria_notify_queued_message_status ()
611630 case SubjectSelectionCriteriaKey .NOTIFY_ARCHIVED_MESSAGE_STATUS :
612631 self ._add_criteria_notify_archived_message_status ()
613- case SubjectSelectionCriteriaKey .HAS_PREVIOUSLY_HAD_CANCER :
614- self ._add_criteria_has_previously_had_cancer ()
615- case SubjectSelectionCriteriaKey .DEMOGRAPHICS_TEMPORARY_ADDRESS :
616- self ._add_criteria_has_temporary_address ()
632+ # ------------------------------------------------------------------------
633+ # 🛑 Fallback: Unmatched Criteria Key
634+ # ------------------------------------------------------------------------
617635 case _:
618636 raise SelectionBuilderException (
619637 f"Invalid subject selection criteria key: { self .criteria_key_name } "
@@ -1632,10 +1650,6 @@ def _add_criteria_appointment_status(self) -> None:
16321650 except Exception :
16331651 raise SelectionBuilderException (self .criteria_key_name , self .criteria_value )
16341652
1635- # ------------------------------------------------------------------------
1636- # 🧪 Diagnostic Test Selection & Join Logic
1637- # ------------------------------------------------------------------------
1638-
16391653 def _add_join_to_diagnostic_tests (self ) -> None :
16401654 try :
16411655 which = WhichDiagnosticTest .from_description (self .criteria_value )
0 commit comments