Skip to content

Commit 112a5b3

Browse files
Updated the subject section
1 parent 7a8e0e1 commit 112a5b3

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

docs/utility-guides/SubjectSelectionQueryBuilder.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,28 @@ This means “filter by the hub assigned to this user’s organisation,” not a
146146

147147
### 3. subject (Subject)
148148

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.
150151

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.
152156

153157
```python
154-
"SCREENING_STATUS": "unchanged"
158+
case SubjectSelectionCriteriaKey.SCREENING_STATUS:
159+
self._add_criteria_screening_status(subject)
155160
```
156161

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+
```
158169

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.
160171

161172
Together, these three inputs give the builder all it needs to translate human-friendly selection criteria into valid, safe, dynamic SQL.
162173

0 commit comments

Comments
 (0)