Skip to content

Add subject include-list support to search_specs query mode - #121

Merged
akhanf merged 6 commits into
mainfrom
copilot/implement-subject-include-list
Oct 2, 2026
Merged

akhanf merged 6 commits into
mainfrom
copilot/implement-subject-include-list

Conversation

Copilot AI commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

DICOM queries previously required one explicit dicom_query block per search (date range, study description, etc.), with no way to target a known list of subjects while excluding everything else — and PACS can't be queried for multiple subjects in a single request.

Query expansion

  • Added expand_search_specs() in workflow/lib/query_filter.py: detects a select key on a search spec and expands it into one explicit per-subject dicom_query, merging shared filters with the subject ID under patient_id (configurable via subject_query_field).
  • query_dicoms() now runs expansion first, so each subject is queried individually and results are concatenated as before — downstream behavior is unchanged.

Backward compatibility

  • Specs without select pass through untouched; select-list specs can be freely mixed with legacy explicit-query specs in the same search_specs list.

Validation

  • Raises ValueError with clear messages for missing/non-list/empty select, and for blank or non-string select entries.

Docs & tests

  • Updated README.md and config/config.yml with an example of the new mode.
  • Added tests covering legacy mode, expansion, select_from_field override, mixed specs, and all validation error paths.

Example config:

search_specs:
  - dicom_query:
      study_description: YourStudy^*
      study_date: 20230101-
    select:
      - SUBJ001
      - SUBJ002
      - SUBJ003
    metadata_mappings:
      subject:
        source: PatientID
      session:
        source: StudyDate

This expands internally into three per-subject queries (each with patient_name: SUBJ00N merged into dicom_query), with results concatenated into a single study list.

Co-authored-by: akhanf <11492701+akhanf@users.noreply.github.com>
Copilot AI changed the title [WIP] Add subject include list for DICOM search specs Add subject include-list support to search_specs query mode Oct 2, 2026
Copilot AI requested a review from akhanf October 2, 2026 02:01
@akhanf

akhanf commented Oct 2, 2026

Copy link
Copy Markdown
Member

@copilot: works great - but upon reflection this config field should be named "select" instead of "subjects", and the "subject_query_field" can be called "select_from_field". Also make the default select_from_field to be "patient_name" instead of "patient_id". Make those changes throughout.

@akhanf
akhanf marked this pull request as ready for review October 2, 2026 16:32
@akhanf
akhanf merged commit 7bbd3ae into main Oct 2, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants