You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/utility-guides/SubjectSelectionQueryBuilder.md
+16-5Lines changed: 16 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -146,17 +146,28 @@ This means “filter by the hub assigned to this user’s organisation,” not a
146
146
147
147
### 3. subject (Subject)
148
148
149
-
This is used when a filter wants to compare the current value in the database to an existing value on file—often represented by the "UNCHANGED" keyword.
149
+
This is an optional parameter that provides context about the subject being queried. It’s particularly important for criteria that require comparison against existing values in the database, such as "unchanged" logic.
150
+
It allows the builder to determine if a subject's current value matches a previously recorded value.
150
151
151
-
Example:
152
+
If you want to filter subjects based on their current screening status, for example, you would need to provide a `Subject` object.
153
+
To know if you need to populate an attribute like `screening_status_id`, you can do so by looking if the method requires the Subject class.
154
+
155
+
For example, if you look at the following python code for a screening status, you can see that the Subject class is required.
152
156
153
157
```python
154
-
"SCREENING_STATUS": "unchanged"
158
+
case SubjectSelectionCriteriaKey.SCREENING_STATUS:
159
+
self._add_criteria_screening_status(subject)
155
160
```
156
161
157
-
That’s saying: “Only return subjects whose screening status has not changed compared to what’s currently recorded on the subject object.”
162
+
You can set attributes on the `Subject` object like this:
163
+
164
+
```python
165
+
subject = Subject()
166
+
subject.set_nhs_number("1234567890")
167
+
subject.set_screening_status_id(1001)
168
+
```
158
169
159
-
Without a subject, "unchanged" logic isn’t possible and will raise a validation error.
170
+
This allows the builder to use the subject's current screening status in the query.
160
171
161
172
Together, these three inputs give the builder all it needs to translate human-friendly selection criteria into valid, safe, dynamic SQL.
0 commit comments