The same patient had a CT (computed tomography) scan last month and another today. The doctor opens today’s report and clicks “View original images.” If the page searches by patient ID and displays the first item in the results, which scan will it open?
After looking at the diagram of how a hospital order travels between systems, I asked how a doctor views the images in the frontend. The code I received searched by patient ID and read studies[0]. Those lines illustrate an important distinction: the search finds studies belonging to the patient, but the button promises to open the study associated with this report. Even if the server puts the latest study first, the button will be wrong when the doctor goes back to last month’s report.
How does a report point to a particular study?
A PACS is the hospital system for archiving and retrieving medical images. DICOM is a family of standards for storing, identifying, and exchanging medical images and related information. An examination is a Study, identified by a unique StudyInstanceUID (UID means unique identifier). A CT scanner can produce multiple series from one scan, for instance two different reconstructions of the same chest examination. Each series has one or more instances, and an instance may contain one or more image frames. A slice on the browser screen sits within that hierarchy.1
| Report the doctor is reading | Patient ID | Associated examination | Study UID (fictional) |
|---|---|---|---|
| Last month’s CT | P42 | CT-0714 | 2.25.1701 |
| Today’s CT | P42 | CT-0814 | 2.25.1702 |
How do today’s report and images get linked? Start before image acquisition. The radiology information system handles scheduling. With a DICOM Modality Worklist, the CT scanner can query scheduled procedures. The technologist verifies the patient and selects today’s procedure, allowing the scanner to carry the relevant identifiers into the images. After acquisition, original images enter the archive. A radiologist reviews them and signs the report, which returns to the medical record. The diagram uses the fictional identifiers above to trace those two paths.23
sequenceDiagram
participant E as 电子病历
participant R as 放射信息系统
participant C as CT 设备
participant P as 影像档案
E->>R: 发送今天的检查申请 CT-0814
C->>R: 查询待做检查
R-->>C: 返回排程及患者、申请标识
C->>P: 归档本次影像,检查 UID 为 2.25.1702
R-->>E: 回传已签发的报告,关联本次检查
When opening the report, the browser can therefore receive just the report text and an examination identifier. The imaging system still supplies the original images. The next task is to find the UID in the diagram from that report.
If the hospital exposes a FHIR R4 healthcare data exchange interface, one option is to follow the imagingStudy reference on a DiagnosticReport to the corresponding ImagingStudy, then read its DICOM study identifier. In ImagingStudy/83, for example, 83 is a resource ID assigned by that FHIR server. Look in the record’s identifier entries for one with system equal to urn:dicom:uid. If its value is urn:oid:2.25.1702, the imaging service uses UID 2.25.1702. The reference can be empty or have several entries. Integration depends on what the hospital actually supplies.3
If the report only provides an Accession Number, match it to the archive using the agreed issuing authority, accession number, and patient context. In the table, P42 and CT-0814 narrow the search to today. With zero matches, the UI should explain that no images have been linked yet. With multiple matches, present candidates for the doctor to confirm, or use a mapping the hospital has verified. A date alone is insufficient: a person may have two examinations in one day.4
Should the button launch an existing viewer or should your page retrieve the images?
If the requirement is for a doctor to open today’s original images from the medical record, you can integrate the hospital’s existing viewer, software that displays slices, adjusts grayscale, and browses series. Confirm the launch mechanism with the hospital, pass the verified study identifier, and keep the existing login and authorization workflow. For example, the open-source OHIF 3.9 viewer’s sample URL uses /viewer?StudyInstanceUIDs=2.25.1702. That URL is a convention of this viewer. Check the supported launch protocol for a different product. Knowing a UID identifies the study. The server must still verify read permission.5
For example, if an authorized backend has supplied the current report’s study UID, the JavaScript below builds the button URL. It assumes the viewer is installed at /viewer on the same site. Regenerate the URL when switching reports and disable the button until the association is confirmed.
function viewerLink(report, origin) {
if (!report.studyUID) return null;
const url = new URL("/viewer", origin);
url.searchParams.set("StudyInstanceUIDs", report.studyUID);
return url.href;
}
const report = { accessionNumber: "CT-0814", studyUID: "2.25.1702" };
console.log(viewerLink(report, "https://imaging.example"));
// https://imaging.example/viewer?StudyInstanceUIDs=2.25.1702
If the doctor must remain on your page, reading the report on the left and paging through images on the right, embed a viewing component. The hospital needs DICOMweb for searching and retrieving images via HTTP requests a web page can send. A hospital-hosted gateway can adapt an older PACS that supports only traditional DICOM communication. On this path developers must pass the correct context, handle authorization failures, load metadata and pixels, and switch both panels together when the report changes. For simply counting CT orders earlier, SQL access to requests and medical orders was sufficient.
What requests does the browser send when retrieving images itself?
Suppose the backend has confirmed today’s study is 2.25.1702 and authorized the current doctor to read it. Use QIDO-RS first to discover series and instances. The following paths are relative to the hospital’s DICOMweb service. The series UID returned by the first request and the instance UID from the second are the values to use in subsequent paths.4
GET /studies/2.25.1702/series
Accept: application/dicom+json
Suppose the doctor selects series 2.25.1802. To list its instances, send:
GET /studies/2.25.1702/series/2.25.1802/instances
Accept: application/dicom+json
Then use WADO-RS to retrieve content. For selected instance 2.25.1902, read the metadata describing the image, then fetch the pixels of frame 1. The next two requests use response formats the service and viewer have agreed to support. The second response can be a multipart body with boundary delimiters.6
GET /studies/2.25.1702/series/2.25.1802/instances/2.25.1902/metadata
Accept: application/dicom+json
GET /studies/2.25.1702/series/2.25.1802/instances/2.25.1902/frames/1
Accept: multipart/related; type="application/octet-stream"
Why do you need a viewer after receiving the bytes? For uncompressed grayscale pixels, the viewer needs the row and column counts, the bits per pixel, and the mapping from numbers to screen brightness. When the doctor adjusts window width and level, they change the range and center of values mapped to grayscale. Multiple slices must also be organized by image position and orientation. The metadata, transfer encoding, and pixels must agree to produce a browsable series. If only a preview is required, a supporting service can return an already rendered image. That is simpler than interactive slice browsing.67
Connect these requests and you have a complete round trip from medical record to imaging service. The diagram shows a gateway-based version. OIDC uses the login identity to establish who is visiting. The gateway can also authenticate itself to the imaging service with mutual TLS, in which both ends present certificates. If you already have the study UID, begin at the series query.46
sequenceDiagram
participant A as 病历前端与阅片器
participant G as 访问网关
participant D as DICOMweb 服务与影像档案
A->>G: 若缺检查 UID,按报告申请号及患者上下文查检查
G->>D: 验权后转发 QIDO 查询
D-->>G: 匹配的检查及 UID
G-->>A: 返回候选,确认对应检查
A->>G: 查询选中检查的序列及实例
G->>D: 转发序列查询,再按选中序列查询实例
D-->>G: 返回序列及实例 UID
G-->>A: 返回列表,选择要显示的实例
A->>G: 读取实例元数据
G->>D: 转发 WADO metadata 请求
D-->>G: 返回图像说明
G-->>A: 返回元数据
A->>G: 请求实例的一个或多个帧
G->>D: 请求约定格式的像素
D-->>G: 返回帧及传输格式
G-->>A: 返回像素
A->>A: 按格式解码并渲染,调窗或翻阅切片
To test this button, I would keep both reports from the table. Click today’s and then last month’s and deliberately return the two requests in reverse order. The UI should end on last month’s study. Late images must not overwrite the current examination. Also try a report that has no matching images and check that a clear empty state appears. This tests both the report-to-image association and whether the browser really displays the doctor’s last selection.
Footnotes
-
National Electrical Manufacturers Association. (2025). DICOM PS3.18 2025a: Web services. DICOM Standard. §10.1.1, Study, Series, and Instance resource hierarchy. ↩
-
National Electrical Manufacturers Association. (2025). DICOM PS3.4 2025a: Service class specifications. DICOM Standard. §K.6.1.1, modality retrieval of scheduled procedures and association with patients and images. ↩
-
Health Level Seven International. (2019). DiagnosticReport and ImagingStudy. FHIR R4 v4.0.1. Meaning and cardinality of DiagnosticReport.imagingStudy · DICOM UID convention for ImagingStudy.identifier. ↩ ↩2
-
National Electrical Manufacturers Association. (2025). Search transaction. DICOM PS3.18 2025a. §10.6.1, target resources, matching fields, and responses. ↩ ↩2 ↩3
-
Open Health Imaging Foundation. (n.d.). URL. OHIF Viewer 3.9 Documentation. Example opening a study with StudyInstanceUIDs. ↩
-
National Electrical Manufacturers Association. (2025). Retrieve transaction. DICOM PS3.18 2025a. §10.4.1, instance metadata, frames, and rendered resources. ↩ ↩2 ↩3
-
National Electrical Manufacturers Association. (2025). VOI LUT module. DICOM PS3.3 2025a. §C.11.2.1.2, mapping grayscale using Window Center and Window Width. ↩