예제 #1
0
 public static function AddData(&$db, &$process_file, &$data_chris_id, &$series_description)
 {
     $db->lock('data', 'WRITE');
     // Does data exist: SeriesInstanceUID
     if (array_key_exists('SeriesInstanceUID', $process_file)) {
         // does data (series) exist??
         $dataMapper = new Mapper('Data');
         $dataMapper->filter('uid = (?)', $process_file['SeriesInstanceUID'][0]);
         $dataResult = $dataMapper->get();
         // if doesnt exist, add data
         if (count($dataResult['Data']) == 0) {
             // create object
             // create data model
             $dataObject = new Data();
             //
             // get data uid
             //
             $dataObject->uid = $process_file['SeriesInstanceUID'][0];
             //
             // get data name (protocol name)
             //
             if (array_key_exists('ProtocolName', $process_file)) {
                 $dataObject->name = sanitize($process_file['ProtocolName'][0]);
             } else {
                 $dataObject->name = 'NoProtocolName';
             }
             //
             // get data description (series description)
             //
             if (array_key_exists('SeriesDescription', $process_file)) {
                 $dataObject->description = sanitize($process_file['SeriesDescription'][0]);
             } else {
                 $dataObject->description = 'NoSeriesDescription';
             }
             $series_description = $dataObject->description . '-' . $dataObject->name;
             //
             // get data time ContentDate-ContentTime
             //
             // date
             $dataObject->time = PACS::getTime($process_file);
             //
             // add the data model to db and get its id
             //
             $data_chris_id = Mapper::add($dataObject);
         } else {
             // todo: update time and status here...!
             if ($dataResult['Data'][0]->name == '') {
                 if (array_key_exists('ProtocolName', $process_file)) {
                     $dataResult['Data'][0]->name = sanitize($process_file['ProtocolName'][0]);
                 } else {
                     $dataResult['Data'][0]->name = 'NoProtocolName';
                 }
                 $series_description = $dataResult['Data'][0]->description . '-' . $dataResult['Data'][0]->name;
                 Mapper::update($dataResult['Data'][0], $dataResult['Data'][0]->id);
             } else {
                 $series_description = $dataResult['Data'][0]->description . '-' . $dataResult['Data'][0]->name;
             }
             $data_chris_id = $dataResult['Data'][0]->id;
         }
     } else {
         echo 'Data UID not provided in DICOM file' . PHP_EOL;
         // finish data table lock
         $db->unlock();
         return 0;
     }
     // finish data table lock
     $db->unlock();
     return 1;
 }
예제 #2
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);