Example #1
0
 /**
  * Reorder macro
  */
 public function reorder($from, $to)
 {
     $from = preg_replace('/[^0-9a-z_A-Z- \\.]/', '', $from);
     $to = preg_replace('/[^0-9a-z_A-Z- \\.]/', '', $to);
     $barcodeMacroFrom = new self();
     $barcodeMacroFrom->name = $from;
     $barcodeMacroFrom->populate();
     if (!strlen($barcodeMacroFrom->macro) > 0) {
         return;
     }
     $barcodeMacroTo = new self();
     $barcodeMacroTo->name = $to;
     $barcodeMacroTo->populate();
     if (!strlen($barcodeMacroTo->macro) > 0) {
         return;
     }
     $db = Zend_Registry::get("dbAdapter");
     $db->beginTransaction();
     try {
         $orderFrom = $barcodeMacroFrom->order;
         $barcodeMacroFrom->order = $barcodeMacroTo->order;
         $barcodeMacroFrom->persist();
         $barcodeMacroTo->order = $orderFrom;
         $barcodeMacroTo->persist();
         $db->commit();
     } catch (Exception $e) {
         $db->rollBack();
         trigger_error($e->getMessage(), E_USER_NOTICE);
     }
 }
Example #2
0
 public static function generateTestData()
 {
     $message = new self();
     $message->message = 'PID|1234|doe^john^h';
     $message->type = 'HL7';
     $message->persist();
 }
Example #3
0
 /** Return an User instance given its id (or null if it's not found)
  * @param int $uID The id of the user
  * @param bool $login = false Set to true to make the user the current one
  * @param bool $cacheItemsOnLogin = false Set to true to cache some items when $login is true
  *
  * @return User|null
  */
 public static function getByUserID($uID, $login = false, $cacheItemsOnLogin = true)
 {
     $app = Application::getFacadeApplication();
     $db = $app['database']->connection();
     $v = array($uID);
     $q = "SELECT uID, uName, uIsActive, uLastOnline, uTimezone, uDefaultLanguage, uLastPasswordChange FROM Users WHERE uID = ? LIMIT 1";
     $r = $db->query($q, $v);
     $row = $r ? $r->FetchRow() : null;
     $nu = null;
     if ($row) {
         $nu = new self();
         $nu->setPropertiesFromArray($row);
         $nu->uGroups = $nu->_getUserGroups(true);
         $nu->superUser = $nu->getUserID() == USER_SUPER_ID;
         if ($login) {
             $nu->persist($cacheItemsOnLogin);
             $nu->recordLogin();
         }
     }
     return $nu;
 }
 public static function loadLOINC($filename)
 {
     if (!file_exists($filename)) {
         trigger_error('Filename ' . $filename . ' does not exists.');
         return;
     }
     $lines = file($filename);
     if ($lines === false || !isset($lines[0])) {
         return;
     }
     // first line MUST be a header
     $headers = array();
     $headerLine = array_shift($lines);
     foreach (explode("\t", $headerLine) as $val) {
         $headers[] = trim(strtolower(str_replace('"', '', $val)));
     }
     $lengths = array();
     foreach ($lines as $line) {
         $orm = new self();
         foreach (explode("\t", $line) as $key => $value) {
             $value = trim($value);
             $len = strlen($value);
             if ($len > 0) {
                 $value = substr($value, 1, $len - 2);
             }
             // removed double quotes
             if (!isset($headers[$key])) {
                 continue;
             }
             $field = $headers[$key];
             if (!isset($lengths[$field])) {
                 $lengths[$field] = 0;
             }
             $len = strlen($value);
             if ($len > $lengths[$field]) {
                 $lengths[$field] = $len;
             }
             $orm->{$field} = $value;
         }
         $orm->persist();
     }
     //file_put_contents('/tmp/lengths.txt',print_r($lengths,true));
 }
 public static function generateMenuEnum($force = false)
 {
     $ret = false;
     do {
         $name = 'Menu';
         $key = 'MENU';
         $enumeration = new self();
         $enumeration->populateByEnumerationName($name);
         // check for key existence
         if (strlen($enumeration->key) > 0 && $enumeration->key == $key) {
             if (!$force) {
                 break;
             }
             $enumerationClosure = new EnumerationsClosure();
             $enumerationClosure->deleteEnumeration($enumeration->enumerationId);
         }
         $enums = array('file' => array('key' => 'FILE', 'name' => 'File', 'active' => 1, 'data' => array('addPatient' => array('key' => 'ADDPATIENT', 'name' => 'Add Patient', 'active' => 1), 'selectPatient' => array('key' => 'SELPATIENT', 'name' => 'Select Patient', 'active' => 1), 'reviewSignChanges' => array('key' => 'RSC', 'name' => 'Review / Sign Changes', 'active' => 1), 'changePassword' => array('key' => 'CHANGEPW', 'name' => 'Change Password', 'active' => 1), 'editSigningKey' => array('key' => 'SIGNINGKEY', 'name' => 'Edit Signing Key', 'active' => 1), 'myPreferences' => array('key' => 'MYPREF', 'name' => 'My Preferences', 'active' => 1), 'quit' => array('key' => 'QUIT', 'name' => 'Quit', 'active' => 1))), 'action' => array('key' => 'ACTION', 'name' => 'Action', 'active' => 1, 'data' => array('addVitals' => array('key' => 'ADDVITALS', 'name' => 'Add Vitals', 'active' => 1), 'print' => array('key' => 'PRINT', 'name' => 'Print', 'active' => 1, 'data' => array('flowSheet' => array('key' => 'FLOWSHEET', 'name' => 'Flow Sheet', 'active' => 1))), 'manageSchedule' => array('key' => 'MANSCHED', 'name' => 'Manage Schedules', 'active' => 1))));
         $level0 = array();
         $level0['key'] = $key;
         $level0['name'] = $name;
         $level0['category'] = 'System';
         $level0['active'] = 1;
         $level0['ormClass'] = 'MenuItem';
         $level0['ormEditMethod'] = 'ormEditMethod';
         $level0['data'] = $enums;
         $data = array();
         $data[] = $level0;
         self::_saveEnumeration($data);
         $enumeration = new self();
         $enumeration->populateByEnumerationName($name);
         $menu = new MenuItem();
         $menu->siteSection = 'All';
         $menu->type = 'freeform';
         $menu->active = 1;
         $menu->title = $enumeration->name;
         $menu->displayOrder = 0;
         $menu->parentId = 0;
         $menu->persist();
         $enumeration->ormId = $menu->menuId;
         $enumeration->persist();
         self::_generateMenuEnumerationTree($enumeration);
         $ret = true;
     } while (false);
     return $ret;
 }
 public function addNamespace($namespace, $ORMClass = '', $aliasFor = '', $recursive = true)
 {
     if ($recursive) {
         $x = explode('.', $namespace);
         $ns = array();
         foreach ($x as $n) {
             $ns[] = $n;
             $tmpNamespace = implode('.', $ns);
             if ($this->isNamespaceExists($tmpNamespace)) {
                 continue;
             }
             $this->addNamespace($tmpNamespace, $ORMClass, $aliasFor, false);
         }
         return true;
     }
     $nsdrDefinition = new self();
     $nsdrDefinition->namespace = $namespace;
     $nsdrDefinition->aliasFor = $aliasFor;
     $nsdrDefinition->ORMClass = $ORMClass;
     $nsdrDefinition->uuid = NSDR::create_guid();
     // random uuid
     $nsdrDefinition->persist();
     return true;
 }
 /**
  * Create ConfigItem for default formulary table
  *
  * @return void
  */
 public static function createDefaultConfigIfNotExists()
 {
     $defaultTable = self::getDefaultFormularyTable();
     if ($defaultTable !== false) {
         $formulary = new self($defaultTable);
         if (!$formulary->populate(false)) {
             $formulary->activate();
             $formulary->setDefault();
             $formulary->persist(false);
         }
     }
 }
Example #8
0
 public static function reorderViews($baseId, $from, $to)
 {
     $db = Zend_Registry::get('dbAdapter');
     $viewFrom = new self();
     $viewFrom->reportViewId = (int) $from;
     $viewFrom->populate();
     $viewTo = new self();
     $viewTo->reportViewId = (int) $to;
     $viewTo->populate();
     $viewFrom->viewOrder = $viewTo->viewOrder + 1;
     $viewFrom->persist();
     $sql = 'UPDATE `' . $viewFrom->_table . '` SET viewOrder = (viewOrder + 1) WHERE reportBaseId = ' . (int) $baseId . ' AND viewOrder > ' . $viewFrom->viewOrder;
     $db->query($sql);
 }
Example #9
0
 public function nsdrPersist($tthis, $context, $data)
 {
     $context = (int) $context;
     $attributes = $tthis->_attributes;
     $nsdrNamespace = $tthis->_nsdrNamespace;
     $aliasedNamespace = $tthis->_aliasedNamespace;
     if ($context == '*') {
         if (isset($attributes['isDefaultContext']) && $attributes['isDefaultContext']) {
             // get genericData
             $objectClass = 'ClinicalNote';
             $clinicalNoteId = 0;
             if (isset($attributes['clinicalNoteId'])) {
                 $clinicalNoteId = (int) $attributes['clinicalNoteId'];
             }
             $revisionId = 0;
             if (isset($attributes['revisionId'])) {
                 $revisionId = (int) $attributes['revisionId'];
             }
             $gd = new self();
             $gd->objectClass = $objectClass;
             $gd->objectId = $clinicalNoteId;
             $gd->name = $nsdrNamespace;
             $gd->revisionId = $revisionId;
             $gd->loadValue();
             $gd->dateTime = date('Y-m-d H:i:s');
             if (is_array($data)) {
                 $data = array_shift($data);
             }
             $gd->value = $data;
             return $gd->persist();
         } else {
             // all
             $ret = false;
             if (isset($data[0])) {
                 $ret = true;
                 foreach ($data as $row) {
                     $gd = new self();
                     $gd->populateWithArray($row);
                     $gd->persist();
                 }
             }
             return $ret;
         }
     }
     $gd = new self();
     $gd->genericDataId = $context;
     $gd->populate();
     $gd->populateWithArray($data);
     return $gd->persist();
 }
 public static function eligibilityCheck($insuredRelationshipId)
 {
     $ir = new self();
     $ir->insured_relationship_id = $insuredRelationshipId;
     $ir->populate();
     $result = self::_dummyHook();
     $ir->effectiveStart = $result['start'];
     $ir->effectiveEnd = $result['end'];
     $ir->desc = $result['desc'];
     $ir->dateLastVerified = date('Y-m-d H:i:s');
     $ir->persist();
     return $ir;
 }
Example #11
0
 public function checkInbounds()
 {
     $ctr = 0;
     $url = Zend_Registry::get('config')->healthcloud->eFax->getInboundUrl;
     $url .= '?apiKey=' . Zend_Registry::get('config')->healthcloud->apiKey;
     $data = array();
     $dateTime = $this->getLatestDateReceived();
     if ($dateTime !== false) {
         $data = array('dateTime' => $dateTime);
     }
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     $output = curl_exec($ch);
     trigger_error('RESPONSE: ' . $output, E_USER_NOTICE);
     try {
         $xml = new SimpleXMLElement($output);
         if (isset($xml->inbounds)) {
             $inbounds = $xml->inbounds;
             foreach ($inbounds->inbound as $item) {
                 $inbound = new self();
                 $inbound->dateRequested = (string) $item->dateRequested;
                 $inbound->requestType = (string) $item->requestType;
                 $inbound->accountId = (string) $item->accountId;
                 $inbound->numberDialed = (string) $item->numberDialed;
                 $inbound->dateReceived = (string) $item->dateReceived;
                 $inbound->faxName = (string) $item->faxName;
                 $inbound->fileType = (string) $item->fileType;
                 $inbound->pageCount = (string) $item->pageCount;
                 $inbound->CSID = (string) $item->CSID;
                 $inbound->ANI = (string) $item->ANI;
                 $inbound->status = (string) $item->status;
                 $inbound->MCFID = (string) $item->MCFID;
                 $inbound->fileContents = (string) $item->fileContents;
                 $inbound->persist();
                 $ctr++;
             }
         } else {
             if (isset($xml->error)) {
                 trigger_error('Error: ' . (string) $xml->error, E_USER_NOTICE);
             }
         }
     } catch (Exception $e) {
         trigger_error('Error: ' . $e->getMessage(), E_USER_NOTICE);
     }
     curl_close($ch);
     return $ctr;
 }