33import os
44
55sys .path .insert (0 , os .path .abspath (os .path .join (os .path .dirname (__file__ ), "../.." )))
6- # print("PYTHONPATH set to:", sys.path[0]) # Uncomment for local debug
76from classes .selection_builder_exception import SelectionBuilderException
87
98
109class MockSelectionBuilder :
1110 """
1211 Lightweight test harness that mimics SubjectSelectionQueryBuilder behavior.
1312
14- This class is meant for local testing of SQL fragment builders without the full
15- application context. Developers can copy/paste individual _add_criteria_* methods
16- from the real builder and test inputs/outputs directly .
13+ This class is used for local testing of SQL fragment builder methods without requiring
14+ the full application context. Developers can reimplement individual _add_criteria_*
15+ methods here for isolated evaluation .
1716
1817 Usage:
19- - Create an instance with a criteria key and value
20- - Call the appropriate criteria builder method
21- - Use dump_sql() to inspect the resulting SQL
18+ - Add your _add_criteria_* method to this class
19+ - Then create tests in utils/oracle/test_subject_criteria_dev.py to run it
20+ - Use dump_sql() to inspect the generated SQL fragment
2221 """
2322
2423 def __init__ (self , criteria_key , criteria_value , criteria_comparator = ">=" ):
@@ -28,31 +27,30 @@ def __init__(self, criteria_key, criteria_value, criteria_comparator=">="):
2827 self .criteria_comparator = criteria_comparator
2928 self .sql_where = []
3029
31- # === Example testable method ===
30+ def dump_sql (self ):
31+ return "\n " .join (self .sql_where )
32+
33+ # === Example testable method below ===
3234 # Replace this with the one you want to test,
3335 # then use utils/oracle/test_subject_criteria_dev.py to run your scenarios
3436
35- def _add_criteria_subject_lower_fobt_age (self ) -> None :
37+ def _add_criteria_subject_lower_lynch_age (self ) -> None :
3638 """
37- Adds a SQL constraint that compares a subject's lower FOBT age eligibility
38- using a comparator and a value (e.g. '>= 55' or '>= default').
39+ Adds a SQL constraint for Lynch syndrome lower-age eligibility.
3940
40- If value is 'default', it's replaced with a national parameter lookup:
41- pkg_parameters.f_get_national_param_val(10)
41+ If value is 'default', it's replaced with '35'.
42+ Uses comparator to build the WHERE clause.
4243 """
4344 try :
4445 value = self .criteria_value
4546 comparator = self .criteria_comparator
4647
4748 if value .lower () == "default" :
48- value = "pkg_parameters.f_get_national_param_val (10) "
49+ value = "35 "
4950
5051 self .sql_where .append (
51- f"AND pkg_bcss_common.f_get_ss_lower_age_limit (ss.screening_subject_id) "
52+ f"AND pkg_bcss_common.f_get_lynch_lower_age_limit (ss.screening_subject_id) "
5253 f"{ comparator } { value } "
5354 )
5455 except Exception :
5556 raise SelectionBuilderException (self .criteria_key_name , self .criteria_value )
56-
57- def dump_sql (self ):
58- return "\n " .join (self .sql_where )
0 commit comments