|
7 | 7 |
|
8 | 8 |
|
9 | 9 | # Add helper class stubs below |
10 | | -class DiagnosticTestType: |
| 10 | +class DiagnosticTestIsVoid: |
11 | 11 | """ |
12 | | - Mock mapping of diagnostic test type names to valid value IDs. |
| 12 | + Maps yes/no descriptions to boolean flags for test void criteria. |
13 | 13 | """ |
14 | 14 |
|
| 15 | + YES = "yes" |
| 16 | + NO = "no" |
| 17 | + |
15 | 18 | _mapping = { |
16 | | - "pcr": 3001, |
17 | | - "antigen": 3002, |
18 | | - "lateral flow": 3003, |
| 19 | + "yes": YES, |
| 20 | + "no": NO, |
19 | 21 | } |
20 | 22 |
|
21 | 23 | @classmethod |
22 | | - def get_valid_value_id(cls, description: str) -> int: |
| 24 | + def from_description(cls, description: str) -> str: |
23 | 25 | key = description.strip().lower() |
24 | 26 | if key not in cls._mapping: |
25 | | - raise ValueError(f"Unknown diagnostic test type: {description}") |
| 27 | + raise ValueError(f"Unknown void flag: {description}") |
26 | 28 | return cls._mapping[key] |
27 | 29 |
|
28 | 30 |
|
@@ -73,35 +75,22 @@ def _add_join_to_latest_episode(self) -> None: |
73 | 75 | # Replace this with the one you want to test, |
74 | 76 | # then use utils/oracle/test_subject_criteria_dev.py to run your scenarios |
75 | 77 |
|
76 | | - def _add_criteria_diagnostic_test_type(self, proposed_or_confirmed: str) -> None: |
| 78 | + def _add_criteria_diagnostic_test_is_void(self) -> None: |
77 | 79 | """ |
78 | | - Filters diagnostic tests by type—proposed or confirmed. |
79 | | - Requires prior join to external_tests_t (xt aliasing assumed). |
| 80 | + Adds WHERE clause to check whether diagnostic test is voided ('Y' or 'N'). |
| 81 | + Requires prior join to external_tests_t using alias xtN. |
80 | 82 | """ |
81 | 83 | try: |
82 | 84 | idx = getattr(self, "criteria_index", 0) |
83 | 85 | xt = f"xt{idx}" |
| 86 | + value = DiagnosticTestIsVoid.from_description(self.criteria_value) |
84 | 87 |
|
85 | | - if proposed_or_confirmed == "proposed": |
86 | | - column = f"{xt}.proposed_type_id" |
87 | | - elif proposed_or_confirmed == "confirmed": |
88 | | - column = f"{xt}.confirmed_type_id" |
89 | | - else: |
90 | | - raise SelectionBuilderException( |
91 | | - self.criteria_key_name, self.criteria_value |
92 | | - ) |
93 | | - |
94 | | - self.sql_where.append(f"AND {column} ") |
95 | | - |
96 | | - value = self.criteria_value.strip().lower() |
97 | | - if value == "null": |
98 | | - self.sql_where.append("IS NULL") |
99 | | - elif value == "not null": |
100 | | - self.sql_where.append("IS NOT NULL") |
| 88 | + if value == DiagnosticTestIsVoid.YES: |
| 89 | + self.sql_where.append(f"AND {xt}.void = 'Y'") |
| 90 | + elif value == DiagnosticTestIsVoid.NO: |
| 91 | + self.sql_where.append(f"AND {xt}.void = 'N'") |
101 | 92 | else: |
102 | | - comparator = self.criteria_comparator |
103 | | - type_id = DiagnosticTestType.get_valid_value_id(self.criteria_value) |
104 | | - self.sql_where.append(f"{comparator} {type_id}") |
| 93 | + raise SelectionBuilderException(self.criteria_key_name, self.criteria_value) |
105 | 94 |
|
106 | 95 | except Exception: |
107 | 96 | raise SelectionBuilderException(self.criteria_key_name, self.criteria_value) |
0 commit comments