Query Management Workflow¶
The QueryManagementWorkflow plugin
(registered under imednet.workflows as query_management and accessible via
sdk.workflows.query_management) streamlines Query monitoring across a
Study, Site, or Subject.
Fetching Open Queries and State Counts¶
get_open_queries()returns activeQueryitems whose normalizedQueryStatusisOPEN(including legacy payload evaluation fromquery_commentswhen explicit status fields are absent).get_query_state_counts()aggregatesQuerytotals into aQueryStateCountsmapping supporting case-insensitive string keys ("open","OPEN") andQueryStatusenum members.
from typing import Any, cast
from imednet import ImednetSDK
from imednet.models.queries import QueryStatus
from imednet_workflows.query_management import QueryManagementWorkflow
sdk = ImednetSDK(simulation_mode=True)
workflow = QueryManagementWorkflow(cast(Any, sdk))
open_queries = workflow.get_open_queries("STUDY")
counts = workflow.get_query_state_counts("STUDY")
assert len(open_queries) == 2
assert counts["open"] == counts[QueryStatus.OPEN] == 2
print(len(open_queries), counts["OPEN"], counts["CLOSED"])
Filtering Queries by Subject or Site¶
Use get_queries_for_subject()
to inspect all Query items attached to a single Subject, or
get_queries_by_site()
to resolve enrolled Subject keys at a Site and retrieve every associated
Query:
from typing import Any, cast
from imednet import ImednetSDK
from imednet_workflows.query_management import QueryManagementWorkflow
scoped_sdk = ImednetSDK(simulation_mode=True)
scoped_workflow = QueryManagementWorkflow(cast(Any, scoped_sdk))
subject_queries = scoped_workflow.get_queries_for_subject("STUDY", "SUB1")
site_queries = scoped_workflow.get_queries_by_site("STUDY", "SITE")
assert len(subject_queries) == 2
assert len(site_queries) == 2
print(len(subject_queries), len(site_queries))
CLI Query Filtering and Workflow Commands¶
Clinical Data Managers can filter Query items directly from the terminal
without writing Python scripts. Because the upstream iMednet Queries REST API
does not accept top-level status filters, imednet queries list splits
upstream attributes (such as subjectKey or variable) from local
QueryStatus predicates while keeping
--mask-phi enabled by default:
# Filter open queries for a study via --status or -f/--filter
imednet queries list DEMO-STUDY --status OPEN --simulation
imednet queries list DEMO-STUDY -f subjectKey==SUBJ-001 -f status==OPEN --simulation
Use imednet workflows queries to inspect discrepancy counts grouped by
OPEN, ANSWERED, CLOSED, and CANCELLED or synchronize unresolved
queries into a local SQLite review queue:
# List open or subject-scoped queries through QueryManagementWorkflow
imednet workflows queries list DEMO-STUDY --status OPEN --simulation
imednet workflows queries list DEMO-STUDY --subject-key SUBJ-001 --unresolved --simulation
# Emit QueryStatus state counts as JSON
imednet workflows queries counts DEMO-STUDY --simulation --format json
# Synchronize unresolved queries into the local SQLite TriageStore
imednet workflows queries sync DEMO-STUDY --unresolved --simulation
For persistent local review queues, assignment tracking, and transition history,
pair QueryManagementWorkflow with Triage Store Guide.