CODE
Oracle Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
PSOUG Home Code Snippets Oracle Reference Oracle Functions PSOUG Forum Oracle Blogs Bookmark and Share
 
 Search the Reference Library pages:  

Free
Oracle Magazine
Subscriptions
and Oracle White Papers

Oracle DICOM

Version 11.1
 
General Information
Source $ORACLE_HOME/ord/im/admin/ordcpksp.sql
$ORACLE_HOME/ord/im/admin/ordcrpsp.sql
First Available 11.1.0.6

Dependencies
SELECT object_name
FROM dba_objects
WHERE lower(object_name) LIKE '%dicom%';

SELECT object_type, COUNT(*)
FROM dba_objects
WHERE lower(object_name) LIKE '%dicom%'
GROUP BY object_type;

OBJECT_TYPE     COUNT(*)
------------    --------
PACKAGE                5
PACKAGE BODY           5
TYPE BODY              1
SYNONYM              164
JAVA CLASS           161
TYPE                   7

SELECT owner, object_name
FROM dba_objects
WHERE lower(object_name) LIKE '%dicom%'
AND object_type = 'PACKAGE';

OWNER   OBJECT_NAME
-----   -------------------
ORDSYS  ORD_DICOM
ORDSYS  ORD_DICOM_ADMIN
ORDSYS  ORD_DICOM_ADMIN_PRV
ORDSYS  ORD_DICOM_CT
ORDSYS  ORD_DICOM_PKG

Storage Structure
DICOM_IMAGE
  ORD_DICOM_HEADER
    VERSION
    DICOM_STANDARD_VERSION
    DICOM_STANDARD_RELEASE
  FILE_META_HEADER
    MEDIA_STORAGE_SOP_CLASS_UID
    MEDIA_STORAGE_SOP_INSTANCE_UID
    TRANSFER_SYNTAX_UID
    IMPLEMENTATION_CLASS_UID
    IMPLEMENTATION_VERSION_NAME
    SOURCE_APPLICATION_ENTITY_TITLE
  PATIENT
    NAME
    ID
    BIRTH_DATE
    SEX
  GENERAL_STUDY
    INSTANCE_UID
    DATE
    TIME
    REFERING_PHYSICIANS_NAME
    ID
    ACCESSION_NUMBER
    DESCRIPTION?
  PATIENT_STUDY?
    ADMITTING_DIAGNOSES_DESCRIPTION
    ADMITTING_DIAGNOSES_CODE_SEQUENCE
  GENERAL_SERIES
    MODALITY
    INSTANCE_UID
    DATE
    TIME
    PERFORMING_PHYSICIANS_NAME
    BODY_PART_EXAMINED
    PATIENT_POSITION
    PERFORMED_PROCEDURE_STEP_ID
    PERFORMED_PROCEDURE_STEP_START_DATE
    PERFORMED_PROCEDURE_STEP_START_TIME
    PERFORMED_PROCEDURE_STEP_DESCRIPTION
    PERFORMED_PROTOCOL_CODE_SEQUENCE
  GENERAL_EQUIPMENT?
    MANUFACTURER
  GENERAL_IMAGE?
    INSTANCE_NUMBER
    ACQUISITION_NUMBER
    ACQUISITION_DATE
    ACQUISITION_TIME
    ACQUISITION_DATETIME
    PATIENT_ORIENTATION
    FRAME_LATERALITY
    ANATOMIC_REGION
  IMAGE_PIXEL?
    SAMPLES_PER_PIXEL
    PHOTOMETRIC_INTERPRETATION
    ROWS
    COLUMNS
    BIT_ALLOCATED
    BIT_STORED
    HIGH_BIT
    PIXEL_REPRESENTATION
    PLANAR_CONFIGURATION
    PIXEL_ASPECT_RATIO
  SOP_COMMON
    CLASS_UID
    INSTANCE_UID 
    SPECIFIC_CHARACTER_SET
 
DICOM Demo
Sample DICOM Image Files Download the free DICOM images [Click Here]
 
Download a free DICOM image viewer [Click Here]
Create Directory Object CREATE OR REPLACE DIRECTORY ctemp AS 'c: emp';

GRANT read ON DIRECTORY ctemp TO uwclass;

Create table to hold DICOM images
conn uwclass/uwclass

CREATE TABLE medicalImages(
image_id    NUMBER,
description VARCHAR2(40),
metadata    XMLType,
image       ORDSYS.ORDIMAGE,
thumb       ORDSYS.ORDIMAGE)
LOB (image.source.localdata) STORE AS (chunk 32K)
-- store images with 32K chunk

LOB (thumb.source.localdata) STORE AS (chunk 16K)
-- but the thumbnails with only 16K

-- bind the XMLType columns to the interMedia metadata columns
XMLType column metadata
XMLSCHEMA "http://xmlns.oracle.com/ord/meta/dicomImage"
ELEMENT "DICOM_IMAGE";

ALTER TABLE medicalimages
ADD CONSTRAINT pk_medicalimages
PRIMARY KEY(image_id)
USING INDEX;

desc medicalImages

set describe depth all linenum on indent on

desc medicalImages

set describe depth 1

SELECT object_name, object_type
FROM user_objects
ORDER BY 1,2;

desc user_lobs

SELECT table_name, segment_name, index_name, chunk, in_row
FROM user_lobs;

SELECT index_name, index_type, table_type
FROM user_indexes
WHERE table_name = 'MEDICALIMAGES'
ORDER BY 1;

-- explore what ORDDICOM is
conn ordsys/ordsys

SELECT object_type
FROM user_objects
WHERE object_name = 'ORDDICOM';

SELECT DISTINCT object_name
FROM user_arguments
WHERE package_name = 'ORDDICOM';

Load DICOM image file
conn uwclass/uwclass

INSERT INTO
medicalimages
(image_id, description, metadata, image)

VALUES
(1, 'TEST',  NULL, ordsys.ordimage.init());

-- this does not work
SELECT *
FROM medicalimages;

SELECT image_id, description
FROM medicalimages;

set serveroutput on

DECLARE
 obj1 ordsys.ordimage;
BEGIN
  SELECT image
  INTO obj1
  FROM
medicalImages
  WHERE image_id = 1
  FOR UPDATE;

  obj1.setSource('FILE', 'CTEMP', 'image1.dcm');

  dbms_output.put_line(obj1.getSource || ' has been loaded');

  UPDATE
medicalImages
  SET image=obj1
  WHERE image_id=1;

  COMMIT;
END;
/

-- this does not work
SELECT dbms_lob.getlength(image)
FROM medicalimages;
-- remember this is being stored as ordsys.ordimage not as a BLOB

Create metadata extract procedure
CREATE OR REPLACE PROCEDURE extractDicomMetadata(inID IN INTEGER) IS
 local_image    ORDSYS.ORDIMAGE;
 local_id       INTEGER;
 dicom_metadata XMLType := NULL;
BEGIN
  SELECT image
  INTO local_image
  FROM medicalImages
  WHERE image_id = inID;

  -- extract DICOM metadata
  dicom_metadata := local_image.getDicomMetadata('imageGeneral');
  IF (dicom_metadata IS NULL) THEN
    dbms_output.put_line('metadata is NULL');
  ELSE
    UPDATE medicalImages
    SET metadata = dicom_metadata
    WHERE image_id = inID;
  END IF;

  -- let us print the namespace of the XML document containing the
  -- DICOM metadata that we just extracted
  dbms_output.put_line('namespace: ' || dicom_metadata.getNamespace());
END extractDicomMetadata;
/

exec extractDicomMetadata(1);

View metadata
SELECT DISTINCT package_name, object_name
FROM all_arguments
WHERE package_name LIKE '%DICOM%'
ORDER BY 1;

set long 1000000

SELECT metadata FROM medicalimages;
 

Alternative:
Load from existing BLOB column
DECLARE
 dest BLOB;
BEGIN
  SELECT blob_dest
  INTO dest
  FROM medical_image_rel
  WHERE image_id = 1
  FOR UPDATE;

  ord_dicom.importFrom(dest, 'file', 'DICOMDIR', 'example.dcm');
END;
/

Remove patient identifying information from the embedded DICOM content stored in a BLOB
DECLARE
 src  BLOB;
 dest BLOB;
 dest_sop_instance_uid VARCHAR2(128) := '<unique-UID>';
BEGIN
  select blob_src, blob_dest
  INTO src, dest
  FROM medical_image_rel
  WHERE image_id = 1
  FOR UPDATE;

  ord_dicom.makeAnonymous(src, dest_sop_instance_uid, dest,
  'ordcman.xml');
END;
/
 
Related Topics
DBMS_LOB
Directories
Intermedia Audio
Intermedia Video
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us [218 users online]    © 2010 psoug.org