Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 26, 2026

  • Understand the current implementation and query logic
  • Fix the query logic to check all modalities in the study (not just the series)
  • Change OHIF v3 URL to use initialSeriesUID instead of SeriesInstanceUIDs
  • Add tests for the new functionality
  • Run linters and code review
  • Refactor to use single SQL query with WITH clause
  • Final verification

Summary

Successfully refactored get_viewer_URL() to use a single SQL query with WITH clause instead of two separate queries. The function now:

  1. Uses a single query with WITH clause: When only seriesInstanceUID is provided, uses a CTE (Common Table Expression) to get the StudyInstanceUID and all modalities in one query
  2. Correctly detects SM studies: Routes derived series (e.g., SEG) in SM studies to the Slim viewer
  3. Updated OHIF v3 URL: Uses initialSeriesUID parameter instead of SeriesInstanceUIDs

All tests pass, linters pass, and manual testing confirms correct functionality.

Original prompt

This section details on the original issue you should resolve

<issue_title>Fix get_viewer_URL() to better handle derived series</issue_title>
<issue_description>Currently, the query that is used to decide which viewer to use is looking only at the modalities for the series that are passed to the function:

query = f"""
SELECT
DISTINCT(StudyInstanceUID),
Modality
FROM
index
WHERE
SeriesInstanceUID='{seriesInstanceUID}'
"""
. If that input series is SEG, the query will not detect whether that series is in a study that contains radiology or slide microscopy images.

Update the query so that when the function receives just SeriesInstanceUID parameter, it first identifies the corresponding StudyInstanceUID, then for that entire study checks if the study contains SM modality, and if it does - use Slim viewer.

Also, modify the function that builds series-specific OHIF URL to use initialSeriesUID URL parameter instead of seriesInstanceUIDs, as documented in https://docs.ohif.org/configuration/url/#initialseriesinstanceuid.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 26, 2026 14:41
…rameter

Co-authored-by: fedorov <313942+fedorov@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix get_viewer_URL to better handle derived series Fix get_viewer_URL() to detect SM modality in studies with derived series Jan 26, 2026
Copilot AI requested a review from fedorov January 26, 2026 14:46
@fedorov
Copy link
Member

fedorov commented Jan 26, 2026

@copilot Instead of using 2 queries to select StudyInstanceUID and then find Modalities in the study, can you use SQL WITH clause and use a single query?

Co-authored-by: fedorov <313942+fedorov@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 26, 2026

@copilot Instead of using 2 queries to select StudyInstanceUID and then find Modalities in the study, can you use SQL WITH clause and use a single query?

Refactored to use a single SQL query with a WITH clause (CTE). The query now:

  1. Uses a CTE to get the StudyInstanceUID from the series
  2. Joins with the index table to get all modalities in the study
  3. Groups results to get distinct modalities

Commit: ce51107

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.

Fix get_viewer_URL() to better handle derived series

2 participants