public static function serviceStart() { $memcache = Zend_Registry::get('memcache'); $memcache->set(self::$_statusKey, self::$_states[1]); $permissionTemplate = new self(); $permissionTemplateIterator = $permissionTemplate->getIterator(); foreach ($permissionTemplateIterator as $permission) { try { $xml = new SimpleXMLElement($permission->template); foreach ($xml as $moduleName => $modules) { foreach ($modules as $resourceName => $resources) { $arrResources = array(); foreach ($resources as $key => $value) { $access = (int) $value->attributes()->access; $value = (string) $value; $arrResources[$value] = array($key => $access); } $memKey = hash('sha256', self::ACL_MEMKEY . '_' . $permission->permissionTemplateId . '_' . $resourceName); $memcache->set($memKey, $arrResources); } } } catch (Exception $e) { trigger_error($e->getMessage(), E_USER_NOTICE); } } $memcache->set(self::$_statusKey, self::$_states[0]); }
/** * Get an iterator for all the prequery filters * * Rebuilds a copy of the existing queue that is limited only to the * positive-priority entries. * @todo Find a more efficient implementation * * @return \SplPriorityQueue */ public function getPreQueryIterator() { $filterQueue = new self(); foreach ($this->getIterator() as $filter) { if ($filter['priority'] > 0) { $filterQueue->insert($filter['data']['name'], $filter['data']['callback'], $filter['priority']); } } return $filterQueue->getIterator(); }
public static function checkDuplicates() { $ret = array(); $db = Zend_Registry::get('dbAdapter'); $enumeration = new self(); $enumerationIterator = $enumeration->getIterator(); foreach ($enumerationIterator as $enum) { $sqlSelect = $db->select()->from($enumeration->_table, array('COUNT(`key`) AS ctr'))->where('`key` = ?', $enum->key); if ($row = $db->fetchRow($sqlSelect)) { if ($row['ctr'] >= 2) { $ret[] = $enum->key; } } } return $ret; }
public static function recalculate($vitalSignGroupId) { $db = Zend_Registry::get('dbAdapter'); $orm = new self(); $sqlSelect = $db->select()->from($orm->_table)->where('vitalSignGroupId = ?', (int) $vitalSignGroupId); $factor = 1; $bmi = null; $bsa = null; $height = null; $weight = null; $iterator = $orm->getIterator($sqlSelect); foreach ($iterator as $vital) { if ($vital->vital == 'BMI') { $bmi = $vital; } else { if ($vital->vital == 'BSA') { $bsa = $vital; } else { if ($vital->vital == 'height') { $height = $vital; } else { if ($vital->vital == 'weight') { $weight = $vital; } } } } } // recalculate BMI if ($bmi !== null && ($height !== null && $height->value > 0) && ($weight !== null && $weight->value > 0)) { $h = $height->value; $w = $weight->value; if ($height->units == 'IN' && $weight->units == 'LB') { $factor = 703; } $bmi->value = round($w / ($h * $h) * $factor * 100) / 100; $bmi->persist(); } // recalculate BSA if ($bsa !== null && ($height !== null && $height->value > 0) && ($weight !== null && $weight->value > 0)) { $h = $height->value; $w = $weight->value; if ($height->units == 'IN' && $weight->units == 'LB') { $factor = 3131; } else { if ($height->units == 'CM' && $weight->units == 'KG') { // TODO: it SHALL be meter and not CM $factor = 3600; } } $bsa->value = round(sqrt($h * $w / $factor) * 100) / 100; $bsa->persist(); } }
/** * Get Enumeration Iterator by name given an enumeration's name * * @param string $name Enumeration's name * @return WebVista_Model_ORMIterator * @access public static */ public static function getIterByName($name) { $name = preg_replace('/[^a-z_0-9-]/i', '', $name); $enumeration = new self(); $db = Zend_Registry::get('dbAdapter'); $dbSelect = $db->select()->from($enumeration->_table)->where('name = ?', $name); //trigger_error($dbSelect,E_USER_NOTICE); return $enumeration->getIterator($dbSelect); }
public function nsdrPopulate($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(); return $gd->value; } else { // all $ret = array(); $gd = new self(); $gdIterator = $gd->getIterator(); foreach ($gdIterator as $g) { $ret[] = $g->toArray(); } return $ret; } } $gd = new self(); $gd->genericDataId = $context; $gd->populate(); return $gd->toArray(); }
public static function getIteratorByIds(Visit $visit) { $orm = new self(); $db = Zend_Registry::get('dbAdapter'); $sqlSelect = $db->select()->from($orm->_table)->where('(encounter_id = ' . (int) $visit->visitId . ') OR (encounter_id = 0 AND appointmentId = ' . (int) $visit->appointmentId . ' AND personId = ' . (int) $visit->patientId . ')'); return $orm->getIterator($sqlSelect); }
public static function listActiveUsers() { $db = Zend_Registry::get('dbAdapter'); $orm = new self(); $sqlSelect = $db->select()->from($orm->_table)->join('person', 'person.person_id = ' . $orm->_table . '.person_id', null)->where('person.active = 1'); return $orm->getIterator($sqlSelect); }