Halil Umut Yalçın
Healthcare & DICOM

What I Learned Integrating a DICOM Viewer into a Clinical PACS Platform

Aug 18, 2026•5 min read•Halil Umut Yalçın
What I Learned Integrating a DICOM Viewer into a Clinical PACS Platform

Practical takeaways from integrating Cornerstone3D into Medisan's web workstation: 16-bit WebGL2 GPU shading, non-blocking Web Workers, e-Nabız KOS manifests, and passing the official Ministry of Health audit.

The Regulatory Mandate: National PACS & RIS Compliance

Operating clinical PACS or RIS software in Turkey requires passing the Ministry of Health's technical accreditation audit. The audit isn't a rubber-stamp paperwork exercise; inspectors run conformance suites and verify live behavior across network associations, data isolation, and pixel integrity.

Our system needed to verify DICOM C-STORE, C-FIND, and C-MOVE protocols, enforce strict multi-tenant isolation, and synchronize marked pathological series with the national e-Nabız Teletıp telemedicine cloud.

Building against the DICOM standard is manageable on paper. The real difficulty lies in hospital hardware: importing legacy studies from patient CDs without proper Part 10 File Meta Information headers (Group 0002 missing), AE titles padded with unexpected null bytes during network handshakes, and non-standard presentation contexts.

My core contribution was integrating and configuring the Cornerstone3D and OHIF v3 rendering pipeline inside our Next.js 16 frontend — authoring custom VOI LUT presets and measurement overlays — and hardening our backend pynetdicom gateway to handle non-compliant modality streams without crashing.

Audit Verification Scope

Covered DICOM C-STORE, C-FIND, C-MOVE protocols, Key Object Selection (KOS SOP Class 1.2.840.10008.5.1.4.1.1.88.59), DICOM SR structured reports, 16-bit WebGL hardware shading, and cryptographic audit logging under IHE ATNA / RFC 3881.

Conformance Checklist vs. Hospital Hardware Reality

Before inspectors evaluated the live installation, we mapped each official requirement against our defensive fallbacks in the field:

DICOM Conformance Checklist & Technical Implementation
Audit DomainDICOM SpecificationDefensive Architectural Implementation
Network IngestionDICOM C-STORE / C-FIND / C-MOVE (Part 7 & 8)Asynchronous pynetdicom daemon ingesting CR/DX/CT modality streams over DICOM port :11112 without dropped associations
Transfer SyntaxesImplicit VR Little Endian (Baseline), JPEG Lossless, Explicit VRPreserves negotiated presentation context, falls back to baseline Implicit VR LE, and synthesizes Part 10 File Meta Information on disk with write_like_original=False
Key Object SelectionDICOM KOS (1.2.840.10008.5.1.4.1.1.88.59)KOS generator compiling physician-flagged pathological slices into compliant manifests for e-Nabız Teletıp
Viewport & Windowing16-bit Allocation (12–14 bit Stored) & VOI LUTCornerstone3D WebGL2 pipeline feeding Int16Array buffers into GPU fragment shaders for fluid Window/Level adjustments
Measurement AccuracyPixel Spacing (0028,0030) CalibrationCalibrated vector overlays for Cobb angle, CTR (Cardiothoracic Ratio), and density probing (calibrated HU for CT, raw grayscale for CR/DX)
Multi-Tenant IsolationKVKK & Healthcare Data SecurityHierarchical OSGB tenant scoping, ORM session interceptors, and Nginx X-Accel-Redirect protected file storage

16-Bit Grayscale Rendering & WebGL Windowing

Diagnostic studies allocate 16 bits per pixel (BitsAllocated = 16), while actual diagnostic depth is typically stored in 12 to 14 bits (BitsStored = 12 for standard CT, yielding 4,096 distinct Hounsfield Units, and up to 14 bits for digital radiography DX). Attempting Window/Level transformations inside CPU JavaScript loops pegs the main thread and causes severe stutter during multi-slice scrolling.

Cornerstone3D orchestrates viewport lifecycle, camera matrix math, and canvas events. To bypass CPU pixel processing, our custom image loader passes raw Int16Array buffers directly to WebGL2 textures (gl.R16I) without expanding them to 8-bit RGB on the main thread. Real-time Window/Level VOI LUT adjustments run entirely inside GPU fragment shaders. Study metadata parsing occurs inside Web Workers, and array buffers transfer to the main thread via Transferable Objects (postMessage(buffer, [buffer])) with zero memory copies.

For clinical measurements, we extract the PixelSpacing (0028,0030) and ImagerPixelSpacing (0018,1164) tags from the metadata to translate screen pixels into accurate physical millimeters.

What Broke in Early Testing: The Null-Byte AE Title Bug

Our first deployment attempt failed unexpectedly during basic handshake tests. An older Carestream X-ray console kept triggering immediate A-ABORT disconnections during C-ECHO verification.

Wireshark packet captures revealed the cause: the console sent AE titles padded with trailing null bytes (b'\x00') and ASCII control characters. Standard pynetdicom strictly validates AE title strings against the DICOM dictionary and aborted the association immediately.

Rather than attempting to reconfigure legacy hospital hardware, we wrote a custom sanitization interceptor that cleans null bytes and trailing control sequences during association negotiation while keeping the SOP class UID and payload intact.

gateways/dicom_sanitizer.py (AE Title Sanitizer)python
Expand excerpt
# Clean null bytes (\x00) and control characters from inbound modality AE titles
def sanitized_set_ae(value, name, allow_empty=True, allow_none=True):
    if isinstance(value, bytes):
        value = value.replace(b'\x00', b'').decode('ascii', errors='ignore').strip()
    elif isinstance(value, str):
        value = ''.join(c for c in value if ord(c) >= 0x20 and c != '\\').strip()
    return original_set_ae(value, name, allow_empty=allow_empty, allow_none=allow_none)

Field Lessons: WebGL Context Loss & Missing Headers

Two additional real-world issues required quick architectural fixes before audit day:

C-STORE Network Ingestion vs. Part 10 Disk Storage: Network C-STORE transfers deliver DIMSE-C dataset streams (PS 3.7 & 3.8) which do not carry Part 10 File Meta Information headers (Group 0002). When saving received objects to our PACS disk archive or ingesting raw files from legacy patient CDs, standard File Meta Information headers must be synthesized. When legacy association negotiations omit explicit transfer syntaxes, our gateway negotiates the DICOM baseline Implicit VR Little Endian (1.2.840.10008.1.2) and writes datasets with compliant Part 10 Group 0002 headers to disk.

WebGL Context Loss on Background Tabs: Radiologists frequently open multiple patient studies in separate browser tabs. When backgrounded, browsers release the WebGL context to conserve VRAM, causing the viewport to render completely black upon return. We implemented a webglcontextrestored handler that automatically rebinds shaders and repopulates active slices from an in-memory LRU cache.

Engineering Scope & Implementation Retrospective
My Direct Contribution:

Integrated Cornerstone3D viewport into Next.js 16, authored WebGL2 GLSL VOI LUT shaders for 16-bit CT/DX windowing, built custom Cobb angle and CTR vector measurement tools, and developed the DICOM KOS manifest generator for e-Nabız Teletıp synchronization.

Wider Team / Platform Scope:

The wider Medisan team developed the core RIS database schemas, physician report management, and primary network infrastructure hosting the DCM4CHEE modality gateway.

Measurement Methodology:

Benchmarked 60 FPS viewport scrolling on standard 512x512 multi-slice CT datasets across Apple Silicon and Intel Core i5 integrated graphics using Chrome DevTools Performance panel.

What I'd Do Differently Today:

If rebuilding today, I would adopt Cornerstone3D's volume streaming loader earlier to reduce initial multi-slice memory allocations instead of relying on individual stack loaders during high-slice studies.

Halil Umut Yalçın

Written by Halil Umut Yalçın

Software Engineer • Building regulated clinical systems, PACS/DICOM workflows, and high-reliability web applications.

Discuss this article or collaborate →
Author & Editorial Disclosure:These technical notes reflect production implementations, postmortems, and architectural decisions by Halil Umut Yalçın at Medisan. Large Language Models (Claude / AI tools) assisted in article structure, editorial drafting, and English phrasing. All code implementations, benchmarks, and clinical validations are verified by the author.