public function testMoveSeries()
 {
     // move on MRN + Study Date
     $server_ip = '134.174.12.21';
     $server_port = 104;
     $user_aetitle = 'FNNDSC-CHRISDEV';
     $pacs = new PACS($server_ip, $server_port, $user_aetitle);
     $pacs->addParameter('StudyInstanceUID', '1.2.840.113845.11.1000000001785349915.20120508133531.5943861');
     $pacs->addParameter('SeriesInstanceUID', '1.2.840.113619.2.256.896737926219.1336498845.3088');
     $result = $pacs->moveSeries();
     // should return null (no error message)
     $this->assertTrue($result == null);
     // missing StudyInstanceUID
     $server_ip = '134.174.12.21';
     $server_port = 104;
     $user_aetitle = 'FNNDSC-CHRISDEV';
     $pacs_miss_study = new PACS($server_ip, $server_port, $user_aetitle);
     $pacs_miss_study->addParameter('SeriesInstanceUID', '1.2.840.113619.2.256.896737926219.1336498845.3088');
     $result_miss_study = $pacs_miss_study->moveSeries();
     // should return an error message
     $this->assertTrue($result_miss_study != null);
     // missing SeriesInstanceUID
     $server_ip = '134.174.12.21';
     $server_port = 104;
     $user_aetitle = 'FNNDSC-CHRISDEV';
     $pacs_miss_series = new PACS($server_ip, $server_port, $user_aetitle);
     $pacs_miss_series->addParameter('StudyInstanceUID', '1.2.840.113845.11.1000000001785349915.20120508133531.5943861');
     $result_miss_series = $pacs_miss_series->moveSeries();
     // should return an error message
     $this->assertTrue($result_miss_series != null);
     // missing AE Title
     $pacs_missing_aetitle = new PACS($server_ip, $server_port);
     $pacs_missing_aetitle->addParameter('StudyInstanceUID', '1.2.840.113845.11.1000000001785349915.20120508133531.5943861');
     $pacs_missing_aetitle->addParameter('SeriesInstanceUID', '1.2.840.113619.2.256.896737926219.1336498845.3088');
     $result_missing_aetitle = $pacs_missing_aetitle->moveSeries();
     // should return null (no error message)
     $this->assertTrue($result_missing_aetitle != null);
 }
Пример #2
0
// include chris user_data models
require_once joinPaths(CHRIS_MODEL_FOLDER, 'data_patient.model.php');
// main function
$shortopts = "d:l:";
$options = getopt($shortopts);
// local vars
$output_directory = $options['d'];
$study_directory = $options['d'] . '/' . $options['l'];
// parse files in directory to know who we should email
if ($handle2 = opendir($study_directory)) {
    /* This is the correct way to loop over the directory. */
    // make an array from scanners name/conact
    while (false !== ($entry2 = readdir($handle2))) {
        if ($entry2 != "." && $entry2 != "..") {
            // get DCM file information
            $process_file = PACS::process($study_directory . '/' . $entry2);
            // find location in DB
            // process series (data)
            // wait for all files to be received
            $waiting = true;
            $counter = 0;
            $timeout = 10;
            //(10s)
            $maxtimeout = 3600;
            //(3600s)
            echo "file: " . $study_directory . '/' . $entry2 . PHP_EOL;
            echo "series uid: " . $process_file['SeriesInstanceUID'][0] . PHP_EOL;
            if ($process_file['SeriesInstanceUID'][0] == '') {
                echo "no series uid - skipping file" . PHP_EOL;
                $counter = $maxtimeout;
            }
Пример #3
0
    $studydescription = '';
    if (array_key_exists('y', $options)) {
        $studydescription = sanitize($options['y']);
    } elseif (array_key_exists('studydescription', $options)) {
        $studydescription = sanitize($options['studydescription']);
    }
    // is $station given?
    $seriesdescription = '';
    if (array_key_exists('e', $options)) {
        $seriesdescription = sanitize($options['e']);
    } elseif (array_key_exists('seriesdescription', $options)) {
        $seriesdescription = sanitize($options['seriesdescription']);
    }
}
// instantiate PACS class
$pacs = new PACS($serverip, $serverport, $useraetitle, $useraec);
// create study filters
$study_parameter = array();
$study_parameter['PatientID'] = $patientid;
$study_parameter['PatientName'] = $patientname;
$study_parameter['PatientBirthDate'] = '';
$study_parameter['PatientSex'] = '';
$study_parameter['StudyDate'] = $studydate;
$study_parameter['StudyDescription'] = '';
$study_parameter['ModalitiesInStudy'] = $modality;
$study_parameter['PerformedStationAETitle'] = '';
// create series filters
$series_parameter = array();
$series_parameter['NumberOfSeriesRelatedInstances'] = '';
$series_parameter['SeriesDescription'] = '';
// run query
Пример #4
0
 public static function AddStudy(&$db, &$process_file, &$study_chris_id, &$study_description)
 {
     $db->lock('study', 'WRITE');
     // Does data exist: SeriesInstanceUID
     if (array_key_exists('StudyInstanceUID', $process_file)) {
         // does study exist??
         $studyMapper = new Mapper('Study');
         $studyMapper->filter('uid = (?)', $process_file['StudyInstanceUID'][0]);
         $studyResult = $studyMapper->get();
         // if study doesn't exist, create it
         if (count($studyResult['Study']) == 0) {
             // create object
             // create data model
             $studyObject = new Study();
             //
             // get data uid
             //
             $studyObject->uid = $process_file['StudyInstanceUID'][0];
             //
             // get data name (series description)
             //
             if (array_key_exists('StudyDescription', $process_file)) {
                 $studyObject->description = sanitize($process_file['StudyDescription'][0]);
             } else {
                 $studyObject->description = 'NoStudyDescription';
             }
             if (array_key_exists('Modality', $process_file)) {
                 $studyObject->modality = sanitize($process_file['Modality'][0]);
             } else {
                 $studyObject->modality = 'NoModality';
             }
             if (array_key_exists('StudyDate', $process_file)) {
                 $studyObject->date = PACS::getDate($process_file);
             }
             $studyObject->age = PACS::getAge($process_file);
             $studyObject->location = PACS::getLocation($process_file);
             $study_description = formatStudy($studyObject->date, $studyObject->age, $studyObject->description);
             $study_chris_id = Mapper::add($studyObject);
         } else {
             // Content to be updated
             if ($studyResult['Study'][0]->age == -1) {
                 //
                 // get data name (series description)
                 //
                 if (array_key_exists('StudyDescription', $process_file)) {
                     $studyResult['Study'][0]->description = sanitize($process_file['StudyDescription'][0]);
                 } else {
                     $studyResult['Study'][0]->description = 'NoStudyDescription';
                 }
                 if (array_key_exists('Modality', $process_file)) {
                     $studyResult['Study'][0]->modality = sanitize($process_file['Modality'][0]);
                 } else {
                     $studyResult['Study'][0]->modality = 'NoModality';
                 }
                 $studyResult['Study'][0]->date = PACS::getDate($process_file);
                 $studyResult['Study'][0]->age = PACS::getAge($process_file);
                 $studyResult['Study'][0]->location = PACS::getLocation($process_file);
                 $study_description = formatStudy($studyResult['Study'][0]->date, $studyResult['Study'][0]->age, $studyResult['Study'][0]->description);
                 $study_chris_id = $studyResult['Study'][0]->id;
                 Mapper::update($studyResult['Study'][0], $studyResult['Study'][0]->id);
             } else {
                 $study_chris_id = $studyResult['Study'][0]->id;
                 $study_description = formatStudy($studyResult['Study'][0]->date, $studyResult['Study'][0]->age, $studyResult['Study'][0]->description);
             }
         }
     } else {
         echo 'Study UID not provided in DICOM file' . PHP_EOL;
         // finish data table lock
         $db->unlock();
         return 0;
     }
     // finish data table lock
     $db->unlock();
     return 1;
 }
 // MAP DATA TO STUDY
 $dataStudyMapper = new Mapper('Data_Study');
 $dataStudyMapper->filter('data_id = (?)', $data_chris_id);
 $dataStudyMapper->filter('study_id = (?)', $study_chris_id);
 $dataStudyResult = $dataStudyMapper->get();
 if (count($dataStudyResult['Data_Study']) == 0) {
     $dataStudyObject = new Data_Study();
     $dataStudyObject->data_id = $data_chris_id;
     $dataStudyObject->study_id = $study_chris_id;
     Mapper::add($dataStudyObject);
     $addDataLog .= 'Map data to its study...' . PHP_EOL;
 }
 // move series (data)
 $try = 0;
 while ($request_data && $try < 5) {
     $pacs2 = new PACS($server, $port, $aetitle, $aec);
     echo $server . PHP_EOL;
     echo $port . PHP_EOL;
     echo $aetitle . PHP_EOL;
     $pacs2->addParameter('StudyInstanceUID', $results[1]['StudyInstanceUID'][$key]);
     $pacs2->addParameter('SeriesInstanceUID', $results[1]['SeriesInstanceUID'][$key]);
     $push_request = $pacs2->moveSeries();
     $addDataLog .= $push_request['command'] . PHP_EOL;
     if ($push_request['output'] == '') {
         $addDataLog .= 'Move data success...' . PHP_EOL;
         $request_data = False;
     } else {
         $addDataLog .= 'Move data failure...' . PHP_EOL;
         $addDataLog .= $push_request['output'] . PHP_EOL;
         $addDataLog .= 'New attemp in 5 seconds...' . PHP_EOL;
         sleep(5);
Пример #6
0
         $instance_nb = sprintf('%04d', intval($process_file['InstanceNumber'][0]));
         $filename = $datadirname . '/' . $instance_nb . '-' . $process_file['SOPInstanceUID'][0] . '.dcm';
         if (!is_file($filename)) {
             copy($study_directory . '/' . $entry . '/' . $sub_entry, $filename);
             $logFile .= 'COPY: ' . $filename . PHP_EOL;
             // if file doesnt exist, +1 status
             // +1 increase data status
             //to do in pacs class (less sql queries)
             $dataMapper = new Mapper('Data');
             $dataMapper->filter('id = (?)', $data_chris_id);
             $dataResult = $dataMapper->get();
             //
             // update time if time == '0000-00-00 00:00:00'
             //
             if ($dataResult['Data'][0]->time == '0000-00-00 00:00:00') {
                 $dataResult['Data'][0]->time = PACS::getTime($process_file);
             }
             // update status
             $dataResult['Data'][0]->status += 1;
             // Update database and get object
             Mapper::update($dataResult['Data'][0], $data_chris_id);
             $logFile .= '+1 STATUS: ' . $filename . PHP_EOL;
         } else {
             $logFile .= $filename . ' already exists' . PHP_EOL;
         }
         // delete file
         $logFile .= 'delete: ' . $study_directory . '/' . $entry . '/' . $sub_entry . PHP_EOL;
         unlink($study_directory . '/' . $entry . '/' . $sub_entry);
     }
 }
 closedir($sub_handle);
Пример #7
0
/**
 * Avoids direct execution of the script
 */
if (!defined('DCMGW_INCLUDE')) {
    header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
    die;
}
// ******* ********* ********* ********* ********* ********* ********* *********
// Configuration: Change values to fit your environment
// ******* ********* ********* ********* ********* ********* ********* *********
// You should end up having a variable $pacs pointing to your PACS server.
// You can find below some configuration samples for public servers
// Please, for testing purposes use your own server (if possible) to avoid overloading the public servers
// http://www.dicomserver.co.uk/
// http://wado.medicalconnections.co.uk/WADO/WADO.asp
$pacsMedicalConnections = new PACS('TEST', 'www.dicomserver.co.uk', '11112');
$pacsMedicalConnections->setWado('http', 'www.dicomserver.co.uk', '80', 'wado/WADO.asp');
// DC's public PixelMed PACS.
// No WADO?
$pacsPixelMed = new PACS('AWSPIXELMEDPUB', '184.73.255.26', '11112');
// Public JVSdicom Server. Not sure if this one has any contents.
// No WADO ?
// More information: http://153.1.200.58/?q=dicom_images
$pacsJVSdicom = new PACS('JVSDICOM', '153.1.200.58', '104');
// My own PACS
$pacsHome = new DCM4CHEE('DCMTEST', '192.168.1.44');
$pacs = $pacsHome;
// ******* ********* ********* ********* ********* ********* ********* *********
// This script makes use of dcmqr, from the dcm4che2 Dicom toolkit
// dcm4che2 Dicom toolkit: http://www.dcm4che.org/confluence/display/d2/dcm4che2+DICOM+Toolkit
// dcmqr: http://www.dcm4che.org/confluence/display/d2/dcmqr
Пример #8
0
 function __construct($AETitle, $host, $port)
 {
     parent::__construct($AETitle, $host, $port);
     $this->wadoPort = '1000';
     $this->setWadoScript('wado/' . $AETitle);
 }