class_dicom.php Example: Send all DICOM files in a directory

The script below will look in the directory you specify in $temp_dir and send any images it finds to a DICOM host. When it is done sending it will move the DICOM file to a back up directory.

#!/usr/bin/php
file = "$temp_dir/$file";
      $ret = $d->send_dcm($target_host, $target_port, $my_ae, $target_ae);
      if($ret) {
        print "Send Error: $ret\n";
        continue;
      }
      else {
        print "Good Send\n";
        print "Moving $temp_dir/$file\n";
        rename("$temp_dir/$file", "bk/$file");
      }

    }
  }
  closedir($handle);
}

?>

7 thoughts on “class_dicom.php Example: Send all DICOM files in a directory

  1. I have some problemas when I try to send:

    E: Store SCP Failed: 0006:0207 DIMSE No data available (timeout in non-blocking mode)
    W: DcmItem: Length of element (bc5c,abca) is odd
    E: DIMSE failure (aborting association): 0006:020d DIMSE Failed to receive message

    and

    E: DcmElement: Unknown Tag & Data (a6f5,18ca) larger (2895592401) than remaining bytes (461587) in file, premature end of stream

Leave a Reply

Your email address will not be published. Required fields are marked *