Conversation
Adds basic CRUD operations for worklist_items
9c237de to
19d6a04
Compare
7bca5a3 to
83b3027
Compare
Also fix return type of find_worklist_items
These differ slightly from Dict.
abbeb6a to
ec431c8
Compare
And an ADR for our threading policy
As opposed to separate threads
There was a problem hiding this comment.
Have a few suggestions inline, but overall looks good. Would you mind squashing the ADR commits as the earlier one is redundant now?
It was a bit hard for me to spot whether we are diverging from spec at all... I'm not sure if there is somebody who is more familiar who can look at it from that angle, or if there is tooling we can use or are already using to check conformance?
src/services/init_worklist_db.sql
Outdated
|
|
||
| -- Scheduling information | ||
| scheduled_date TEXT NOT NULL, -- YYYYMMDD format | ||
| scheduled_time TEXT NOT NULL, -- HHMMSS format |
There was a problem hiding this comment.
does the protocol have a timezone to go with this time? If not it might be helpful to include in the comment what we expect it to be when stored in this db (e.g. UTC).
src/services/init_worklist_db.sql
Outdated
|
|
||
| -- DICOM identifiers | ||
| study_instance_uid TEXT, | ||
| mpps_instance_uid TEXT, |
There was a problem hiding this comment.
could we define the acronym MPPS in a comment?
| CREATE INDEX IF NOT EXISTS idx_worklist_status | ||
| ON worklist_items(status); | ||
|
|
||
| -- Index for MPPS lookups by study instance UID |
There was a problem hiding this comment.
do we want an index on mpps_instance_uid as well?
| """ | ||
| Add a new worklist item. | ||
|
|
||
| Args: |
There was a problem hiding this comment.
How about extracting this long list of args into a dataclass for the worklist item?
This method then becomes add_worklist_item(self, item: WorklistItem)
find_worklist_item could then return list[WorklistItem] rather than list[Dict], pywright will be able to fully type check it, and intellisense will be able to autocomplete the individual attributes of the return object.
It looks like since 3.14, if you use dataclass.field you can pass a doc attribute as well so you can document the fields individually https://docs.python.org/3/library/dataclasses.html#dataclasses.field
There was a problem hiding this comment.
9159198 a lot cleaner than working with a dictionary 👍
src/services/storage.py
Outdated
| patient_sex, scheduled_date, scheduled_time, modality, | ||
| study_description, procedure_code, study_instance_uid, | ||
| source_message_id | ||
| ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) |
There was a problem hiding this comment.
sqlite3 and the python db api also support a named placeholder style, which is a bit less error prone when you have a lot of params.
Example from the docs:
# This is the named style used with executemany():
data = (
{"name": "C", "year": 1972},
{"name": "Fortran", "year": 1957},
{"name": "Python", "year": 1991},
{"name": "Go", "year": 2009},
)
cur.executemany("INSERT INTO lang VALUES(:name, :year)", data)| - **Operational simplicity** - Single container to deploy, monitor, and manage | ||
| - **Shared resources** - Both services share the same volume mounts and environment configuration | ||
| - **pynetdicom compatibility** - The library's `AE.start_server()` is designed to block and handle connections, making threads a natural fit | ||
| - **Lower overhead** - Threads have less overhead than separate processes or containers |
There was a problem hiding this comment.
What resources were we concerned about here?
| **Why this approach:** | ||
|
|
||
| - **Operational simplicity** - Single container to deploy, monitor, and manage | ||
| - **Shared resources** - Both services share the same volume mounts and environment configuration |
There was a problem hiding this comment.
Is this a circular argument? If we picked one of the other options I don't think this would be true?
Do we need to share the same volume mounts, and environment configuration? Or is this just the same argument of operational simplicity?
|
|
||
| - **No independent scaling or deployment** - Cannot scale or deploy PACS and MWL separately if one receives significantly more load | ||
| - **Restart granularity** - Cannot restart one service without restarting both | ||
|
|
There was a problem hiding this comment.
Another issue is they share a logging configuration, and potentially configuration for other instrumentation. Maybe this can be mitigated by including the thread name in the format if you haven't done so already Never mind- this is addressed in the final ADR
Using a dataclass allows us to document and formalise the structure of data we store and retrieve from the database. "
Description
Jira link
https://nhsd-jira.digital.nhs.uk/browse/DTOSS-11839
Review notes
Review checklist