Пример #1
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;
 }