public function generatePathsKeyName($id)
 {
     $db = Zend_Registry::get('dbAdapter');
     $className = $this->_ormClass;
     $ormClass = new $className();
     $ormKey = $ormClass->_primaryKeys[0];
     $whrSelect = $db->select()->from(array('ccc' => $this->_table), 'ccc.ancestor')->where('ccc.depth != 0')->where('ccc.ancestor = ?', (int) $id);
     $sqlSelect = $db->select()->from(array('c' => $this->_table), "c.descendant AS node, GROUP_CONCAT(n.name ORDER BY n.enumerationId SEPARATOR ' -> ') AS path")->join(array('cc' => $this->_table), 'cc.descendant = c.descendant', array())->join(array('n' => $ormClass->_table), 'n.' . $ormKey . ' = cc.ancestor', array())->where('c.ancestor = ?', (int) $id)->where('c.descendant != c.ancestor')->group('c.descendant');
     $ret = array();
     $rows = $db->fetchAll($sqlSelect);
     if ($rows) {
         $statisticsStoreKeyAsValue = (string) Zend_Registry::get('config')->statisticsStoreKeyAsValue == 'true' ? true : false;
         foreach ($rows as $row) {
             $enumeration = new Enumeration();
             $enumeration->enumerationId = (int) $row['node'];
             $enumeration->populate();
             if ($statisticsStoreKeyAsValue) {
                 $ret[$enumeration->key] = $row['path'];
             } else {
                 $ret[$enumeration->name] = $row['path'];
             }
         }
     }
     return $ret;
 }
 /**
  * Default action to dispatch
  */
 public function indexAction()
 {
     $enumerationId = (int) $this->_getParam("enumerationId");
     $enumeration = new Enumeration();
     $enumeration->enumerationId = $enumerationId;
     $enumeration->populate();
     $ormClass = $enumeration->ormClass;
     $ormId = $enumeration->ormId;
     $ormEditMethod = $enumeration->ormEditMethod;
     if (!class_exists($ormClass)) {
         throw new Exception("ORM Class {$ormClass} does not exists");
     }
     $ormObject = new $ormClass();
     if (!$ormObject instanceof ORM) {
         throw new Exception("ORM Class {$ormClass} is not an instance of an ORM");
     }
     if (strlen($ormEditMethod) > 0 && method_exists($ormObject, $ormEditMethod)) {
         $form = $ormObject->{$ormEditMethod}($ormId);
     } else {
         foreach ($ormObject->_primaryKeys as $key) {
             $ormObject->{$key} = $ormId;
         }
         $ormObject->populate();
         $form = new WebVista_Form(array('name' => 'edit-object'));
         $form->setAction(Zend_Registry::get('baseUrl') . "generic-edit.raw/process-edit?enumerationId={$enumerationId}");
         $form->loadORM($ormObject, "ormObject");
         $form->setWindow('windowEditORMObjectId');
     }
     $this->_ormObject = $ormObject;
     $this->view->ormObject = $this->_ormObject;
     $this->view->form = $form;
     $this->render('index');
 }
 public function getDisplayedValue()
 {
     $ret = null;
     if ($this->type != self::TYPE_ENUM) {
         return $ret;
     }
     $enumeration = new Enumeration();
     $enumeration->enumerationId = (int) $this->value;
     $enumeration->populate();
     return $enumeration->name;
 }
 public function processEditAction()
 {
     $enumerationId = (int) $this->_getParam('enumerationId');
     $params = $this->_getParam('diagnosis');
     $diagnosis = new DiagnosisCodesICD();
     $diagnosis->populateWithArray($params);
     $diagnosis->persist();
     if ($enumerationId > 0) {
         $enumeration = new Enumeration();
         $enumeration->enumerationId = $enumerationId;
         $enumeration->populate();
         $enumeration->ormId = $diagnosis->code;
         $enumeration->persist();
     }
     $data = true;
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct($data);
 }
Exemple #5
0
 public function getDisplayGender()
 {
     $enumeration = new Enumeration();
     $enumeration->enumerationId = $this->gender;
     $enumeration->populate();
     return $enumeration->name;
     $gender = "";
     switch ($this->gender) {
         case "1":
             $gender = "M";
             break;
         case "2":
             $gender = "F";
             break;
         case "3":
             $gender = "O";
             break;
     }
     return $gender;
 }
 public function editAction()
 {
     $ormId = (int) $this->_getParam('ormId');
     $enumerationId = (int) $this->_getParam('enumerationId');
     $enumeration = new Enumeration();
     $enumeration->enumerationId = $enumerationId;
     $enumeration->populate();
     $inventory = new ImmunizationInventory();
     $inventory->immunization = $enumeration->name;
     $inventory->expiration = date('Y-m-d', strtotime('+1 year'));
     $form = new WebVista_Form(array('name' => 'edit'));
     $form->setAction(Zend_Registry::get('baseUrl') . 'immunization-inventory.raw/process-edit');
     $form->loadORM($inventory, 'inventory');
     $form->setWindow('windowEditORMObjectId');
     $this->view->form = $form;
     $this->view->enumerationId = $enumerationId;
     $this->view->totalInStock = 0;
     //$inventory->totalInStock;
     $this->view->totalExpired = 0;
     //$inventory->totalExpired;
     $this->render('edit');
 }
 public function processEditAction()
 {
     $this->editAction();
     $enumerationId = (int) $this->_getParam('enumerationId');
     $params = $this->_getParam('appointmentTemplate');
     $appointmentTemplateId = (int) $params['appointmentTemplateId'];
     $this->_appointmentTemplate->populateWithArray($params);
     $breakdownNames = $this->_getParam('breakdownName');
     $breakdownLength = $this->_getParam('breakdownLength');
     $breakdownType = $this->_getParam('breakdownType');
     $breakdowns = array();
     if (is_array($breakdownNames) && is_array($breakdownLength) && is_array($breakdownType)) {
         foreach ($breakdownNames as $key => $value) {
             if (!isset($breakdownLength[$key]) || !isset($breakdownType[$key])) {
                 continue;
             }
             $data = array();
             $data['n'] = $value;
             $data['l'] = (int) $breakdownLength[$key];
             $data['t'] = $breakdownType[$key];
             $breakdowns[] = $data;
         }
         if (count($breakdowns) > 0) {
             $this->_appointmentTemplate->breakdown = serialize($breakdowns);
         }
     }
     $this->_appointmentTemplate->persist();
     if ($appointmentTemplateId === 0 && $enumerationId !== 0) {
         $enumeration = new Enumeration();
         $enumeration->enumerationId = $enumerationId;
         $enumeration->populate();
         $enumeration->ormId = $this->_appointmentTemplate->appointmentTemplateId;
         $enumeration->persist();
     }
     $this->view->message = __("Record saved successfully");
     $this->render('edit');
 }
 public function processEditAction()
 {
     $enumerationId = (int) $this->_getParam("enumerationId");
     $params = $this->_getParam("team");
     $teamMemberId = (int) $params['teamMemberId'];
     $teamMember = new TeamMember();
     if ($teamMemberId !== 0) {
         $teamMember->teamMemberId = $teamMemberId;
         $teamMember->populate();
     }
     $teamMember->populateWithArray($params);
     $teamMember->persist();
     if ($teamMemberId === 0 && $enumerationId !== 0) {
         $enumeration = new Enumeration();
         $enumeration->enumerationId = $enumerationId;
         $enumeration->populate();
         $enumeration->ormId = $teamMember->teamMemberId;
         $enumeration->persist();
     }
     $data = array();
     $data['msg'] = __("Record saved successfully");
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct($data);
 }
 public function getTeamByPersonId($personId = null)
 {
     $db = Zend_Registry::get('dbAdapter');
     $ret = '';
     if ($personId === null) {
         $personId = $this->personId;
     }
     $dbSelect = $db->select()->from(array('t' => $this->_table))->joinLeft(array('e' => 'enumerations'), 't.teamMemberId = e.ormId')->where('t.personId = ?', (int) $personId);
     $row = $db->fetchRow($dbSelect);
     if (isset($row['enumerationId'])) {
         $enumerationId = $row['enumerationId'];
         $enumerationsClosure = new EnumerationsClosure();
         $parentId = $enumerationsClosure->getParentById($enumerationId);
         $enumeration = new Enumeration();
         $enumeration->enumerationId = $parentId;
         $enumeration->populate();
         $ret = $enumeration->key;
     }
     return $ret;
 }
 public static function handlerSSSourceData(Audit $audit)
 {
     $data = array();
     if ($audit->objectClass != 'ESignature') {
         return $data;
     }
     $eSignature = new ESignature();
     $eSignature->eSignatureId = $audit->objectId;
     $eSignature->populate();
     if ($eSignature->objectClass != 'Medication') {
         return $data;
     }
     $data['_audit'] = $audit;
     $medication = new Medication();
     $medication->medicationId = (int) $eSignature->objectId;
     $medication->populate();
     $data['PrescriberOrderNumber'] = $medication->medicationId;
     $medData = array();
     $medData['DrugDescription'] = $medication->description;
     $medData['Strength'] = $medication->strength;
     $medData['StrengthUnits'] = $medication->unit;
     $medData['Quantity'] = $medication->quantity;
     $medData['Directions'] = $medication->directions;
     $medData['Refills'] = $medication->refills;
     $medData['Substitutions'] = $medication->substitution;
     $medData['WrittenDate'] = date('Ymd', strtotime($medication->datePrescribed));
     $data['medication'] = $medData;
     $pharmacy = new Pharmacy();
     $pharmacy->pharmacyId = $medication->pharmacyId;
     $pharmacy->populate();
     $pharmacyData = array();
     $pharmacyData['NCPDPID'] = $pharmacy->NCPDPID;
     $pharmacyData['StoreName'] = $pharmacy->StoreName;
     $pharmacyData['AddressLine1'] = $pharmacy->AddressLine1 . ' ' . $pharmacy->AddressLine2;
     $pharmacyData['City'] = $pharmacy->City;
     $pharmacyData['State'] = $pharmacy->State;
     $pharmacyData['ZipCode'] = $pharmacy->Zip;
     $pharmacyData['PhoneNumber'] = $pharmacy->PhonePrimary;
     $data['pharmacy'] = $pharmacyData;
     $provider = new Provider();
     $provider->personId = $medication->prescriberPersonId;
     $provider->populate();
     $prescriberData = array();
     $prescriberData['DEANumber'] = $provider->deaNumber;
     $prescriberData['SPI'] = $provider->sureScriptsSPI;
     $prescriberData['ClinicName'] = '';
     $prescriberData['LastName'] = $provider->person->lastName;
     $prescriberData['FirstName'] = $provider->person->firstName;
     $prescriberData['Suffix'] = '';
     $address = new Address();
     $address->personId = $provider->personId;
     $address->populateWithPersonId();
     $prescriberData['AddressLine1'] = $address->line1 . ' ' . $address->line2;
     $prescriberData['City'] = $address->city;
     $prescriberData['State'] = 'AZ';
     //$address->state;
     $prescriberData['ZipCode'] = $address->postalCode;
     $phoneNumber = new PhoneNumber();
     $phoneNumber->personId = $provider->personId;
     $phoneNumber->populateWithPersonId();
     $prescriberData['PhoneNumber'] = $phoneNumber->number;
     $data['prescriber'] = $prescriberData;
     $patient = new Patient();
     $patient->personId = $medication->personId;
     $patient->populate();
     $patientData = array();
     $patientData['LastName'] = $patient->person->lastName;
     $patientData['FirstName'] = $patient->person->firstName;
     $enumeration = new Enumeration();
     $enumeration->enumerationId = $patient->person->gender;
     $enumeration->populate();
     $gender = $enumeration->key;
     $patientData['Gender'] = $gender;
     $patientData['DateOfBirth'] = date('Ymd', strtotime($patient->person->dateOfBirth));
     $address = new Address();
     $address->personId = $patient->personId;
     $address->populateWithPersonId();
     $patientData['AddressLine1'] = $address->line1 . ' ' . $address->line2;
     $patientData['City'] = $address->city;
     $patientData['State'] = 'AZ';
     //$address->state;
     $patientData['ZipCode'] = $address->postalCode;
     $phoneNumber = new PhoneNumber();
     $phoneNumber->personId = $patient->personId;
     $phoneNumber->populateWithPersonId();
     $patientData['PhoneNumber'] = $phoneNumber->number;
     $data['patient'] = $patientData;
     return $data;
     $ret = array();
     foreach ($data as $type => $row) {
         if (is_array($row)) {
             foreach ($row as $field => $value) {
                 $key = $type . '[' . $field . ']';
                 $ret[$key] = $value;
             }
         } else {
             $ret[$type] = $row;
         }
     }
     return $ret;
 }
 function editProcessAction()
 {
     $enumerationId = (int) $this->_getParam('enumerationId');
     $menuParams = $this->_getParam('menuItem');
     $menuId = (int) $menuParams['menuId'];
     $origMenuId = $menuId;
     $menuParams['menuId'] = $menuId;
     $objMenu = new MenuItem();
     if ($menuId !== 0) {
         $objMenu->menuId = $menuId;
         $objMenu->populate();
     }
     $menuParams['action'] = '';
     if (isset($menuParams['type'])) {
         switch ($menuParams['type']) {
             case 'freeform':
                 if ($this->_getParam('typefreeform') !== NULL) {
                     $menuParams['action'] = $this->_getParam('typefreeform');
                 }
                 break;
             case 'report':
                 if ($this->_getParam('typereport') !== NULL) {
                     $x = explode('-', $this->_getParam('typereport'));
                     $x[0] = (int) $x[0];
                     $x[1] = (int) $x[1];
                     $menuParams['action'] = "Report/report?reportId={$x[0]}&templateId={$x[1]}";
                 }
                 break;
             case 'form':
                 if ($this->_getParam('typeform') !== NULL) {
                     $typeForm = (int) $this->_getParam('typeform');
                     $menuParams['action'] = "Form/fillout?formId={$typeForm}";
                 }
                 break;
         }
     }
     $menuParams['active'] = (int) $this->_getParam('active');
     if ($this->_getParam('chSiteSection') !== NULL) {
         $menuParams['siteSection'] = $this->_getParam('chSiteSection');
     }
     $menuParams['parentId'] = (int) $menuParams['parentId'];
     $objMenu->populateWithArray($menuParams);
     if ($enumerationId !== 0) {
         // update its parent
         $enumerationsClosure = new EnumerationsClosure();
         $objMenu->parentId = $enumerationsClosure->getParentById($enumerationId);
     }
     $objMenu->persist();
     if ($menuId === 0 && $enumerationId !== 0) {
         $enumeration = new Enumeration();
         $enumeration->enumerationId = $enumerationId;
         $enumeration->populate();
         $enumeration->ormId = $objMenu->menuId;
         $enumeration->persist();
     }
     $msg = __("Record Saved for Menu: " . ucfirst($objMenu->title));
     $data = array();
     $data['msg'] = $msg;
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct($data);
 }
 public function listItemsAction()
 {
     $enumerationId = (int) $this->_getParam("enumerationId");
     $baseStr = "<?xml version='1.0' standalone='yes'?><rows></rows>";
     $xml = new SimpleXMLElement($baseStr);
     $enumeration = new Enumeration();
     $enumeration->enumerationId = $enumerationId;
     $enumeration->populate();
     $icon = '';
     if (strlen($enumeration->ormClass) > 0 && class_exists($enumeration->ormClass)) {
         $icon = "<a onclick=\"enumEditObject({$enumeration->enumerationId})\" title=\"Edit Object\"><img src=\"" . Zend_Registry::get('baseUrl') . "img/sm-editproblem.png\" alt=\"Edit Object\" /></a>";
     }
     $item = $xml->addChild("row");
     $item->addAttribute('id', $enumeration->enumerationId);
     $item->addChild('cell', $enumeration->name);
     $item->addChild('cell', $enumeration->category);
     $item->addChild('cell', $enumeration->active);
     $item->addChild('cell', $icon);
     $this->_generateEnumerationTree($item, $enumerationId);
     header('content-type: text/xml');
     $this->view->content = $xml->asXml();
     $this->render();
 }
Exemple #13
0
 public static function getColorList()
 {
     $name = self::ENUM_COLORS_NAME;
     $enumeration = new Enumeration();
     $enumeration->populateByEnumerationName($name);
     $enumeration->populate();
     $enumerationsClosure = new EnumerationsClosure();
     $descendants = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1);
     $colors = array();
     foreach ($descendants as $descendant) {
         $colors[$descendant->key] = $descendant->name;
     }
     return $colors;
 }
 public function hsaSectionJsonAction()
 {
     $hsa = $this->_getParam('hsa');
     $enumeration = new Enumeration();
     $enumeration->enumerationId = (int) $hsa;
     $enumeration->populate();
     $enumerationsClosure = new EnumerationsClosure();
     $enumerationIterator = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1);
     $rows = array();
     foreach ($enumerationIterator as $enum) {
         $tmp = array();
         $tmp['id'] = $enum->enumerationId;
         $tmp['data'][] = '';
         $tmp['data'][] = $enum->name;
         $tmp['data'][] = $enum->key;
         $rows[] = $tmp;
     }
     // temporarily set rows to all defined HSA handlers
     $rows = array();
     $handler = new Handler(Handler::HANDLER_TYPE_HSA);
     $handlerIterator = $handler->getIterator();
     foreach ($handlerIterator as $row) {
         $tmp = array();
         $tmp['id'] = $row->handlerId;
         $tmp['data'][] = '';
         $tmp['data'][] = $row->name;
         $tmp['data'][] = $row->timeframe;
         $rows[] = $tmp;
     }
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct(array('rows' => $rows), true);
 }
 public function insertEnumeration($data, $parentId = 0)
 {
     $db = Zend_Registry::get("dbAdapter");
     $enumParent = new Enumeration();
     $enumParent->enumerationId = $parentId;
     $enumParent->populate();
     $enumeration = new Enumeration();
     $fields = $enumeration->ormFields();
     foreach ($data as $key => $value) {
         if (!in_array($key, $fields)) {
             continue;
         }
         $enumeration->{$key} = $value;
     }
     if (!strlen($enumeration->ormClass) > 0) {
         // check if parent item has an ormClass and id defined and use that to its child
         if (strlen($enumParent->ormClass) > 0) {
             $enumeration->ormClass = $enumParent->ormClass;
             // we only need to use the parent ormId if child's ormId less than or equal to 0
             if ($enumeration->ormId <= 0) {
                 // temporarily comment out
                 //$enumeration->ormId = $enumParent->ormId;
             }
         }
     }
     // we only need to use the parent ormEditMethod if child's ormEditMethod not defined
     if (!strlen($enumeration->ormEditMethod) > 0) {
         $enumeration->ormEditMethod = $enumParent->ormEditMethod;
     }
     $enumeration->persist();
     $enumerationId = $enumeration->enumerationId;
     $sql = "INSERT INTO enumerationsClosure (ancestor,descendant,depth)\n\t\t\t  SELECT ancestor,{$enumerationId},depth+1 FROM enumerationsClosure\n\t\t\t  WHERE descendant = {$parentId}\n\t\t\t  UNION ALL\n\t\t\t  SELECT {$enumerationId},{$enumerationId},0";
     $db->query($sql);
     return $enumerationId;
 }
Exemple #16
0
 protected static function _getEnumerationIterator($name)
 {
     $enumeration = new Enumeration();
     $enumeration->populateByEnumerationName($name);
     $enumeration->populate();
     $enumerationsClosure = new EnumerationsClosure();
     return $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1);
 }
 private function _populateAndPersist($class, $id, $data, $enumerationId)
 {
     // this method assumes that is being called in this controller only and that $class is valid and exists
     $orm = new $class();
     if ($id > 0) {
         $orm->id = $id;
         $orm->populate();
     }
     $orm->populateWithArray($data);
     $orm->persist();
     if (!$id > 0 && $enumerationId > 0) {
         $enumeration = new Enumeration();
         $enumeration->enumerationId = $enumerationId;
         $enumeration->populate();
         $enumeration->ormId = $orm->id;
         $enumeration->persist();
     }
     return $orm;
 }
Exemple #18
0
 protected function _applyTransforms(array $transforms, $data)
 {
     $ret = $data;
     if (!$transforms) {
         return $ret;
     }
     foreach ($transforms as $id => $transform) {
         // id, displayName, systemName, options
         $options = array();
         if (isset($transform->options)) {
             $options = $transform->options;
         }
         switch ($transform->systemName) {
             case 'ucase':
                 $ret = strtoupper($ret);
                 break;
             case 'lcase':
                 $ret = strtolower($ret);
                 break;
             case 'ucwords':
                 $ret = ucwords($ret);
                 break;
             case 'squote':
                 $ret = "'" . $ret . "'";
                 break;
             case 'dquote':
                 $ret = '"' . $ret . '"';
                 break;
             case 'pad':
                 $ret = str_pad($ret, $options['len'], $options['char'], $options['type']);
                 break;
             case 'truncate':
                 $ret = substr($ret, 0, $options['len']);
                 break;
             case 'customLink':
                 $href = str_replace('{{value}}', $ret, $options['href']);
                 $ret = '<a href="' . $href . '" onclick="' . $options['onclick'] . '" target="_blank">' . $ret . '</a>';
                 break;
             case 'regex':
                 $ret = preg_replace('/' . $options['pattern'] . '/', $options['replacement'], $ret);
                 break;
             case 'enumLookup':
                 $enumKey = $options['enumKey'];
                 $enumValue = $options['enumValue'];
                 $direction = $options['direction'];
                 $enumeration = new Enumeration();
                 $enumeration->enumerationId = (int) $enumKey;
                 $enumeration->populate();
                 $enumerationClosure = new EnumerationClosure();
                 $descendants = $enumerationClosure->getAllDescendants($enumeration->enumerationId, 1);
                 // get the first level descendants
                 foreach ($descendants as $descendant) {
                     if ($direction == 'displayName' && ($descendant->enumerationId == $ret || $descendant->key == $ret)) {
                         $ret = $descendant->name;
                         break;
                     } else {
                         if ($direction == 'key' && $descendant->name == $ret) {
                             $ret = $descendant->key;
                             break;
                         }
                     }
                 }
                 break;
             case 'dateFormat':
                 $ret = date($options['format'], strtotime($ret));
                 break;
             case 'total':
                 break;
         }
     }
     return $ret;
 }