/**
  * Create a new token and return it.
  */
 public static function create()
 {
     $value = uniqid();
     $tokenObject = new Token();
     $tokenObject->value = $value;
     Mapper::add($tokenObject);
     return $value;
 }
 /**
  */
 public static function add($userID, $tagName, $tagColor)
 {
     $tagObject = new Tag();
     $tagObject->user_id = $userID;
     $tagObject->name = $tagName;
     $tagObject->color = $tagColor;
     $tagsID = Mapper::add($tagObject);
     $tags = '';
     // loop through results and create html
     $n = new Template('feed_tag.html');
     $n->replace('USER_ID', $userID);
     $n->replace('TAG_ID', $tagsID);
     $n->replace('TAG_NAME', $tagName);
     $n->replace('TAG_COLOR', $tagColor);
     $n->replace('TEXT_COLOR', invertColor($tagColor));
     $n->replace('LOCATION', 'inmodal');
     $tags .= $n;
     return array('tagshtml' => $tags, 'tags' => $tagsID);
 }
Example #3
0
 public function update_map(Mapper $mapper)
 {
     $mapper->add('issue', $this->old_id_, $this->new_id_);
 }
Example #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;
 }
 public static function tag($feedid, $tagid, $remove)
 {
     if ($remove == 'false') {
         // is tag feed already?
         $feedtagMapper = new Mapper('Feed_Tag');
         $feedtagMapper->filter('feed_id=(?)', $feedid);
         $feedtagMapper->filter('tag_id=(?)', $tagid);
         $feedtadResults = $feedtagMapper->get();
         if (count($feedtadResults['Feed_Tag']) >= 1) {
             return -1;
         }
         $tagObject = new Feed_Tag();
         $tagObject->feed_id = $feedid;
         $tagObject->tag_id = $tagid;
         return Mapper::add($tagObject);
     } else {
         // is tag feed already?
         $feedtagMapper = new Mapper('Feed_Tag');
         $feedtagMapper->filter('feed_id=(?)', $feedid);
         $feedtagMapper->filter('tag_id=(?)', $tagid);
         $feedtadResults = $feedtagMapper->get();
         if (count($feedtadResults['Feed_Tag']) >= 1) {
             Mapper::delete('Feed_Tag', $feedtadResults['Feed_Tag'][0]->id);
             return 1;
         }
         return -1;
     }
 }
 public function testUpdate()
 {
     // get a patient by id
     $patientObject = new Patient();
     $patientObject->name = 'PLN2';
     $patientObject->dob = '2002-01-01';
     $patientObject->sex = 'F';
     $patientObject->uid = 'PID2;';
     $patientID = Mapper::add($patientObject);
     // Modify one field
     $patientObject->name = 'PLN3';
     // Update database and get object
     Mapper::update($patientObject, $patientID);
     $patientResult = Mapper::getStatic('Patient', $patientID);
     // compared object we just added with its "base" object
     // we make sure id match
     $patientObject->id = $patientID;
     $this->assertTrue($patientResult['Patient'][0]->equals($patientObject) == True);
     // update "silly" object to create one object which alread exists
     $existingID = Mapper::update($patientObject, -1);
     // should return the id of the object which already exists
     $this->assertTrue($patientID == $existingID);
     //update object that does not exist
     $patientObject->name = 'PLN4';
     $existingID = Mapper::update($patientObject, -1);
     // update should return 0 if object does not exist
     $this->assertTrue($existingID == 0);
     // clean the DB
     Mapper::delete('Patient', $patientID);
 }
Example #7
0
 /**
  * Add record
  *
  * @param array $values
  * @return int
  */
 public static function add(array $values)
 {
     return Mapper::add(get_called_class(), $values);
 }
     $study_chris_id = Mapper::add($studyObject);
     $addDataLog .= 'Study created..' . PHP_EOL;
 } else {
     $study_chris_id = $studyResult['Study'][0]->id;
     $addDataLog .= 'Study already exists..' . PHP_EOL;
 }
 // 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;
Example #9
0
     $mapping_id = Mapper::add($dataPatientObject);
     $logFile .= 'patient data id: ' . $mapping_id . PHP_EOL;
 } else {
     $logFile .= 'Patient already mapped to data...' . PHP_EOL;
     $logFile .= 'patient data id: ' . $dataPatientResult['Data_Patient'][0]->id . PHP_EOL;
 }
 // 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;
     $mapping_data_study_id = Mapper::add($dataStudyObject);
     $logFile .= 'data study id: ' . $mapping_data_study_id . PHP_EOL;
 } else {
     $logFile .= 'Study already mapped to data...' . PHP_EOL;
     $logFile .= 'data study id: ' . $dataStudyResult['Data_Study'][0]->id . PHP_EOL;
 }
 // FILESYSTEM Processing
 //
 // Create the patient directory
 //
 $logFile .= '**** FILESYSTEM processing ****' . PHP_EOL;
 $patientdirname = CHRIS_DATA . '/' . $process_file['PatientID'][0] . '-' . $patient_chris_id;
 // create folder if doesnt exists
 if (!is_dir($patientdirname)) {
     mkdir($patientdirname);
     $logFile .= 'MKDIR: ' . $patientdirname . PHP_EOL;
 /**
  * Create a new user.
  *
  * @param string $username
  * @param string $password
  * @param string $email
  */
 public static function create($uid, $username)
 {
     // create user and add it to db
     $userObject = new User();
     $userObject->id = strval($uid);
     $userObject->username = $username;
     $userObject->password = '******';
     $userObject->email = $username . CHRIS_MAIL_SUFFIX;
     return Mapper::add($userObject);
 }