public function editAction()
 {
     $personId = (int) $this->_getParam('personId');
     if (isset($this->_session->messages)) {
         $this->view->messages = $this->_session->messages;
     }
     $this->_form = new WebVista_Form(array('name' => 'user-detail'));
     $this->_form->setAction(Zend_Registry::get('baseUrl') . "admin-users.raw/edit-process");
     $this->_user = new User();
     $this->_user->personId = $personId;
     $this->_user->populateWithPersonId();
     $this->_form->loadORM($this->_user, "User");
     //var_dump($this->_form);
     $this->view->form = $this->_form;
     $this->view->user = $this->_user;
     $permissionTemplate = new PermissionTemplate();
     $permissionTemplateIterator = $permissionTemplate->getIterator();
     $permissionTemplates = $permissionTemplateIterator->toArray('permissionTemplateId', 'name');
     $permissionTemplates['superadmin'] = 'Super Administrator';
     $this->view->permissionTemplates = $permissionTemplates;
     $this->render('edit-user');
 }
Пример #2
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $auth = Zend_Auth::getInstance();
     $publicPages = array();
     $publicPages['controllers'] = array('login', 'logout');
     $publicPages['actions'] = array();
     $controllerName = $request->getControllerName();
     $actionName = $request->getActionName();
     if (in_array($controllerName, $publicPages['controllers'])) {
         return true;
     }
     PermissionTemplate::auditAccess($controllerName, $actionName);
     if (!$auth->hasIdentity() && $controllerName != 'index') {
         // this MUST be placed before checking permission
         do {
             if (isset($_SERVER['PHP_AUTH_USER']) && strlen($_SERVER['PHP_AUTH_USER']) > 0) {
                 User::processLogin($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
                 if ($auth->hasIdentity()) {
                     break;
                     // allow to check permission below
                 }
             }
             header('WWW-Authenticate: Basic realm="Unauthorized Access Prohibited (ClearHealth)"');
             header('HTTP/1.0 401 Unauthorized');
             die(__('You must enter a valid username and password to access.'));
         } while (false);
     }
     if ($auth->hasIdentity()) {
         $permissionTemplateId = $auth->getIdentity()->permissionTemplateId;
         if (file_exists('/tmp/emergency') && $controllerName != 'admin-persons' && PermissionTemplate::hasAccess($permissionTemplateId, 'emergency-access', 'allow-emergency-access')) {
             if (!($controllerName == "emergency-access" && $actionName == 'index')) {
                 return true;
             }
         }
         if ($permissionTemplateId != 'superadmin' && !PermissionTemplate::hasAccess($permissionTemplateId, $controllerName, $actionName)) {
             $error = 'Access denied. ' . $controllerName . '/' . $actionName . '. ';
             $error .= 'Please <a href="' . $request->getBaseUrl() . '/logout" title="Login">Login</a>.';
             trigger_error($error, E_USER_NOTICE);
             throw new WebVista_App_AuthException($error);
         } else {
             return true;
         }
     }
     throw new WebVista_App_AuthException('You must be authenticated to access the system.');
 }
Пример #3
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $auth = Zend_Auth::getInstance();
     $publicPages = array();
     $publicPages['controllers'] = array('login');
     $publicPages['actions'] = array();
     $controllerName = $request->getControllerName();
     $actionName = $request->getActionName();
     if (in_array($controllerName, $publicPages['controllers'])) {
         return true;
     }
     PermissionTemplate::auditAccess($controllerName, $actionName);
     if ($auth->hasIdentity()) {
         //$permissionTemplateId = $auth->getIdentity()->permissionTemplateId;
         $userId = $auth->getIdentity()->userId;
         $user = new User();
         $user->userId = (int) $auth->getIdentity()->userId;
         $user->populate();
         $permissionTemplateId = $user->permissionTemplateId;
         if ($permissionTemplateId != 'superadmin' && !PermissionTemplate::hasAccess($permissionTemplateId, $controllerName, $actionName)) {
             $error = __('Access denied');
             trigger_error($error, E_USER_NOTICE);
             throw new WebVista_App_AuthException($error);
         } else {
             return true;
         }
     }
     if (isset($_SERVER['PHP_AUTH_USER'])) {
         $_POST['username'] = $_SERVER['PHP_AUTH_USER'];
         $_POST['password'] = $_SERVER['PHP_AUTH_PW'];
         $zvah = new Zend_View_Helper_Action();
         $zvah->action('process', 'login');
         if ($auth->hasIdentity() || in_array($controllerName, $publicPages['controllers'])) {
             return true;
         }
     }
     /*else if ($actionName != 'index' && $controllerName != 'index') {
     			header('WWW-Authenticate: Basic realm="Unauthorize Access Prohibited"');
     			header('HTTP/1.0 401 Unauthorized');
     		}*/
     throw new WebVista_App_AuthException('You must be authenticated to access the system.');
 }
Пример #4
0
 public function permissionUnload()
 {
     return PermissionTemplate::serviceStop();
 }
Пример #5
0
 public static function getServices()
 {
     $ok = true;
     $services = array();
     $service = array();
     $id = 'nsdr';
     $service['id'] = $id;
     $service['name'] = 'NSDR';
     $nsdrStatus = NSDR2::systemStatus();
     if ($nsdrStatus === false) {
         $ok = false;
         $nsdrStatus = 'stopped';
     }
     if ($nsdrStatus != 'started' && $nsdrStatus != 'reloaded') {
         $ok = false;
     }
     $service['status'] = ucwords($nsdrStatus);
     $services[$id] = $service;
     $service = array();
     $id = 'hl7d';
     $service['id'] = $id;
     $service['name'] = 'Processing Daemon';
     $hl7Status = false;
     // temporarily set to false
     if ($hl7Status === false) {
         $hl7Status = 'stopped';
     }
     $hl7Status = 'Stopped';
     if (file_exists('/tmp/CHProcessingDaemon.lock')) {
         $hl7Status = 'Started';
     }
     $service['status'] = ucwords($hl7Status);
     $services[$id] = $service;
     $service = array();
     $id = 'menu';
     $service['id'] = $id;
     $service['name'] = 'Menu';
     $configItem = new ConfigItem();
     $configItem->configId = 'enableCache';
     $configItem->populate();
     $menuStatus = __('Disable');
     if ($configItem->value) {
         $menuStatus = __('Enable');
     } else {
         $ok = false;
     }
     $service['status'] = $menuStatus;
     $services[$id] = $service;
     $service = array();
     $id = 'permissions';
     $service['id'] = $id;
     $service['name'] = 'Permissions';
     $status = PermissionTemplate::serviceStatus();
     if ($status === false) {
         $ok = false;
         $status = 'stopped';
     }
     if ($status != 'started' && $status != 'reloaded') {
         $ok = false;
     }
     $service['status'] = ucwords($status);
     $services[$id] = $service;
     $memcache = Zend_Registry::get('memcache');
     $serviceNominal = $memcache->get(self::SERVICE_NOMINAL);
     if ($ok) {
         $memcache = Zend_Registry::get('memcache');
         $memcache->set(self::SERVICE_NOMINAL, true);
     } else {
         if ($serviceNominal !== false) {
             $memcache->delete(self::SERVICE_NOMINAL, 0);
         }
     }
     return $services;
 }
Пример #6
0
 public function processAddAction()
 {
     $permissionTemplateId = (int) $this->_getParam('aclTemplateId');
     $type = $this->_getParam('type');
     $value = preg_replace('/[^a-zA-Z]+/', '', ucwords(strtolower($this->_getParam('value', ''))));
     $prettyName = ucwords(preg_replace('/([A-Z]{1})/', ' \\1', $value));
     $data = false;
     $isDefault = false;
     $permissionTemplate = new PermissionTemplate();
     $permissionTemplate->permissionTemplateId = $permissionTemplateId;
     if ($permissionTemplate->populate()) {
         $xml = new SimpleXMLElement($permissionTemplate->template);
     } else {
         $xml = $this->_generateDefaultTemplateXML();
         $isDefault = true;
     }
     $defaultModule = 'default';
     $error = '';
     switch ($type) {
         case 'resource':
             if (isset($xml->{$defaultModule}->{$value})) {
                 $error = __('Resource already exists') . ': ' . $value;
                 trigger_error($error, E_USER_NOTICE);
                 break;
             }
             $xml->{$defaultModule}->addChild($value);
             $data['id'] = $value;
             $data['name'] = $prettyName;
             break;
         case 'permission':
             $resourceId = $this->_getParam('resourceId');
             $mode = strtolower($this->_getParam('mode'));
             if (!isset($xml->{$defaultModule}->{$resourceId})) {
                 $error = __('Resource not exists') . ': ' . $resourceId;
                 trigger_error($error, E_USER_NOTICE);
                 break;
             }
             $action = $xml->{$defaultModule}->{$resourceId}->addChild($mode, lcfirst($value));
             $action->addAttribute('access', '0');
             $newMode = ucfirst($mode);
             $chkMode = '_chkLabel' . $newMode;
             $data = $this->_generateCheckboxInputs($this->{$chkMode}, array(array('name' => $value, 'prettyName' => $prettyName, 'value' => 0)), $resourceId);
             break;
         default:
             $error = __('Invalid type') . ': ' . $type;
             trigger_error($error, E_USER_NOTICE);
     }
     if (strlen($error) > 0) {
         $data['error'] = $error;
     } else {
         if ($isDefault) {
             $aclMemKey = PermissionTemplate::ACL_MEMKEY . '_default';
             $this->_memcache->set($aclMemKey, $xml->asXML());
         } else {
             $permissionTemplate->template = $xml->asXML();
             $permissionTemplate->persist();
         }
     }
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct($data);
 }
Пример #7
0
 public function ajaxListInteractionsAction()
 {
     $severeNotify = PermissionTemplate::hasPermission('medication-alerts', 'severe-notification') ? true : false;
     $criticalNotify = PermissionTemplate::hasPermission('medication-alerts', 'critical-notification') ? true : false;
     $allergyNotify = PermissionTemplate::hasPermission('medication-alerts', 'allergy-notification') ? true : false;
     $personId = (int) $this->_getParam('personId');
     $md5 = preg_replace('/[^A-Za-z0-9]/', '', $this->_getParam('md5'));
     $vaclass = preg_replace('/[^A-Za-z0-9]/', '', $this->_getParam('vaclass'));
     // regular allergies search
     $interactionIterator = new BaseMed24InteractionIterator();
     $interactionIterator->setFilters(array('personId' => $personId, 'md5' => $md5));
     $regularAllergies = $interactionIterator->toJsonArray('hipaa_ndc', array('tradename', 'fda_drugname', 'notice'));
     $tmpArray = $regularAllergies;
     $regularAllergies = array();
     foreach ($tmpArray as $key => $value) {
         // notice: S, C, Y, ^
         if (!$severeNotify && $value['data'][2] == 'SIGNIFICANT' || !$criticalNotify && $value['data'][2] == 'CRITICAL') {
             continue;
         }
         $regularAllergies[] = $value;
     }
     $listSymptoms = array();
     $enumeration = new Enumeration();
     $enumeration->populateByEnumerationName(PatientAllergy::ENUM_SYMPTOM_PARENT_NAME);
     $enumerationsClosure = new EnumerationsClosure();
     $enumerationIterator = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1);
     $ctr = 0;
     foreach ($enumerationIterator as $enum) {
         $listSymptoms[$enum->key] = $enum->name;
     }
     $listSeverities = array();
     $enumeration->populateByEnumerationName(PatientAllergy::ENUM_SEVERITY_PARENT_NAME);
     $enumerationsClosure = new EnumerationsClosure();
     $enumerationIterator = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1);
     $ctr = 0;
     foreach ($enumerationIterator as $enum) {
         $listSeverities[$enum->key] = $enum->name;
     }
     // drug class search
     $patientAllergyIterator = new PatientAllergyIterator();
     $patientAllergyIterator->setFilters(array('patientId' => $personId, 'enteredInError' => 0, 'drugAllergy' => $vaclass, 'reactionType' => 'Drug Class Allergy'));
     $drugClassAllergies = array();
     foreach ($patientAllergyIterator as $allergy) {
         if (!$allergyNotify) {
             break;
         }
         /*if ((!$severeNotify && $allergy->severity == 'SEVERE') ||
           (!$criticalNotify && $allergy->severity == 'MOD')) continue;*/
         $symptoms = explode(',', $allergy->symptoms);
         $symptom = array();
         foreach ($symptoms as $sym) {
             $symptom[] = $listSymptoms[$sym];
         }
         $tmpArray = array();
         $tmpArray['id'] = $allergy->patientAllergyId;
         $tmpArray['data'][] = $allergy->causativeAgent;
         $tmpArray['data'][] = $allergy->reactionType;
         $tmpArray['data'][] = $listSeverities[$allergy->severity] . ' - ' . implode(',', $symptom);
         $drugClassAllergies[] = $tmpArray;
     }
     // specific drug search
     $patientAllergyIterator->setFilters(array('patientId' => $personId, 'enteredInError' => 0, 'drugAllergy' => $md5, 'reactionType' => 'Specific Drug Allergy'));
     $specificDrugAllergies = array();
     foreach ($patientAllergyIterator as $allergy) {
         if (!$allergyNotify) {
             break;
         }
         /*if ((!$severeNotify && $allergy->severity == 'SEVERE') ||
           (!$criticalNotify && $allergy->severity == 'MOD')) continue;*/
         $symptoms = explode(',', $allergy->symptoms);
         $symptom = array();
         foreach ($symptoms as $sym) {
             $symptom[] = $listSymptoms[$sym];
         }
         $tmpArray = array();
         $tmpArray['id'] = $allergy->patientAllergyId;
         $tmpArray['data'][] = $allergy->causativeAgent;
         $tmpArray['data'][] = $allergy->reactionType;
         $tmpArray['data'][] = $listSeverities[$allergy->severity] . ' - ' . implode(',', $symptom);
         $specificDrugAllergies[] = $tmpArray;
     }
     $interactions = array_merge_recursive($regularAllergies, $drugClassAllergies, $specificDrugAllergies);
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct(array('rows' => $interactions));
 }