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 function check_login($username = '', $password = '', $type = 1)
 {
     $query = $this->db->get_where($this::DB_TABLE, array('username' => $username, 'password' => $password, 'type' => $type), 1);
     $user = new self();
     $user->populate($query->row());
     return $query->row() ? $user : false;
 }
Example #3
0
 public static function plant($mixedId, $mixedKind = "WP_Post", $dataset = array())
 {
     $tree = new self();
     $tree->setQuerier(Strata::I18n()->query());
     $tree->setContext($mixedId, $mixedKind);
     $tree->populate($dataset);
     return $tree;
 }
 /**
  * Handles loading a question, populating it with the given data
  * 
  * This will return a clean copy of the plugin, populated with the values
  * from the data array
  * 
  * @param array $data
  * @return \self
  */
 public function loadQuestion($data)
 {
     $question = new self($this->pluginManager, $this->id);
     $question->populate($data);
     $question->isQuestion(true);
     // Signal this is not the plugin, but a question object
     return $question;
 }
Example #5
0
 public static function fetch($pidm, $aid_year)
 {
     $statuses = array();
     $rset = self::get_status($pidm, $aid_year);
     foreach ($rset as $row) {
         $status = new self();
         $status->populate($row);
         $statuses[] = $status;
     }
     return $statuses;
 }
Example #6
0
 public function make(array $array)
 {
     $return = array();
     foreach ($array as $k => $v) {
         if (Arrays::is($v)) {
             $o = new self();
             $return[$k] = $o->populate($v);
         } else {
             $return[$k] = $v;
         }
     }
     return $return;
 }
 public static function generateVitalSignsTemplateKeyValue($vitalSignTemplateId = 1)
 {
     $vitalSignTemplate = new self();
     $vitalSignTemplate->vitalSignTemplateId = $vitalSignTemplateId;
     $vitalSignTemplate->populate();
     $vitals = array();
     try {
         $template = new SimpleXMLElement($vitalSignTemplate->template);
         foreach ($template as $vital) {
             $title = (string) $vital->attributes()->title;
             $vitals[$title] = (string) $vital->attributes()->label;
         }
     } catch (Exception $e) {
         WebVista::debug($e->getMessage());
     }
     return $vitals;
 }
Example #8
0
 public function persist()
 {
     $visit = new self();
     $visit->visitId = $this->encounter_id;
     $visit->populate();
     $oldClosed = $visit->closed;
     $ret = parent::persist();
     $newClosed = $this->closed;
     if ($newClosed) {
         $newClaim = false;
         if ($newClosed && $oldClosed !== $newClosed && !ClaimLine::mostRecentClaim($this->encounter_id, true) > 0) {
             // recalculate claim lines if closed visit is new/reopened
             $newClaim = true;
         }
         $ret = self::recalculateClaims($this, $newClaim);
     }
     return $ret;
 }
Example #9
0
 public function populate(array $datas, $namespace = null)
 {
     if (null !== $namespace) {
         if (!isset($this->{$namespace})) {
             $this->{$namespace} = array();
         }
         foreach ($datas as $k => $v) {
             if (Arrays::is($k)) {
                 $this->populate($k, $namespace);
             } else {
                 $this->{$namespace} = array_merge($this->{$namespace}, array($k => $v));
             }
         }
     } else {
         foreach ($datas as $k => $v) {
             if (Arrays::is($v)) {
                 $o = new self();
                 $o->populate($v);
                 $this->{$k} = $o;
             } else {
                 $this->{$k} = $v;
             }
             if (!Arrays::inArray($k, $this->_fields)) {
                 $this->_fields[] = $k;
             }
         }
     }
     return $this;
 }
 public static function instance(array $data)
 {
     $object = new self();
     $object->populate($data);
     return $object;
 }
 public static function refillRequestDatasourceHandler(Audit $auditOrm, $eachTeam = true)
 {
     $ret = array();
     if ($auditOrm->objectClass != 'MedicationRefillRequest') {
         WebVista::debug('Audit:objectClass is not MedicationRefillRequest');
         return $ret;
     }
     $orm = new self();
     $orm->messageId = $auditOrm->objectId;
     if (!$orm->populate()) {
         WebVista::debug('Failed to populate');
         return $ret;
     }
     $objectClass = get_class($orm);
     $messaging = new Messaging();
     $messaging->messagingId = $orm->messageId;
     $messaging->populate();
     $medicationId = (int) $orm->medicationId;
     $providerId = (int) $messaging->providerId;
     $personId = (int) $messaging->personId;
     //if (!$personId > 0 || !$medicationId > 0) {
     if (!$personId > 0) {
         WebVista::debug('Refill request needs manual matching');
         return $ret;
     }
     $patient = new Patient();
     $patient->personId = $personId;
     $patient->populate();
     $teamId = (string) $patient->teamId;
     $alert = new GeneralAlert();
     $alertTable = $alert->_table;
     $msgTable = $messaging->_table;
     $db = Zend_Registry::get('dbAdapter');
     $sqlSelect = $db->select()->from($msgTable, null)->join($alertTable, $alertTable . '.objectId = ' . $msgTable . '.messagingId')->where($msgTable . '.objectType = ?', Messaging::TYPE_EPRESCRIBE)->where($msgTable . '.messageType = ?', 'RefillRequest')->where("{$alertTable}.status = 'new'")->where($alertTable . '.objectClass = ?', $objectClass)->where($alertTable . '.userId = ?', $providerId)->where($msgTable . '.personId = ?', $personId)->limit(1);
     if ($eachTeam) {
         $sqlSelect->where($alertTable . '.teamId = ?', $teamId);
     }
     $alert->populateWithSql($sqlSelect->__toString());
     $messages = array();
     if ($alert->generalAlertId > 0) {
         // existing general alert
         $messages[] = $alert->message;
     } else {
         // new general alert
         $alert->urgency = 'High';
         $alert->status = 'new';
         $alert->dateTime = date('Y-m-d H:i:s');
         $alert->objectClass = $objectClass;
         $alert->objectId = $auditOrm->objectId;
         $alert->userId = (int) $providerId;
         if ($eachTeam) {
             $alert->teamId = $teamId;
         }
     }
     $messages[] = 'Refill request pending. ' . $orm->details;
     $alert->message = implode("\n", $messages);
     return $alert->toArray();
 }
Example #12
0
 public function populate(array $datas, $namespace = null)
 {
     if (null !== $namespace) {
         if (!isset($this->{$namespace})) {
             $this->{$namespace} = [];
         }
         foreach ($datas as $k => $v) {
             if (Arrays::is($k)) {
                 $this->populate($k, $namespace);
             } else {
                 $this->{$namespace} = array_merge($this->{$namespace}, [$k => $v]);
             }
         }
     } else {
         foreach ($datas as $k => $v) {
             $id = isAke($datas, 'id', false);
             if (Arrays::is($v) && false === $id) {
                 if (Arrays::isAssoc($v)) {
                     $o = new self();
                     $o->populate($v);
                     $this->{$k} = $o;
                 } else {
                     $this->{$k} = $v;
                 }
             } else {
                 $this->{$k} = $v;
             }
             if (!Arrays::in($k, $this->_fields)) {
                 $this->_fields[] = $k;
             }
         }
     }
     return $this;
 }
Example #13
0
 public static function factory($orderId)
 {
     $orm = new self();
     $orm->orderId = (int) $orderId;
     $orm->populate();
     if ($orm->type == self::TYPE_LAB_TEST) {
         $ormObj = new OrderLabTest();
         $ormObj->orderId = $orm->orderId;
         $ormObj->populate();
     } else {
         if ($orm->type == self::TYPE_IMAGING) {
             $ormObj = new OrderImaging();
             $ormObj->orderId = $orm->orderId;
             $ormObj->populate();
         } else {
             $ormObj = $orm;
         }
     }
     return $ormObj;
 }
Example #14
0
 public static function getAttending($teamId)
 {
     $name = TeamMember::ENUM_PARENT_NAME;
     $enumeration = new Enumeration();
     $enumeration->populateByUniqueName($name);
     $enumerationsClosure = new EnumerationsClosure();
     $rowset = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1);
     $ret = 0;
     foreach ($rowset as $row) {
         if ($teamId == $row->key) {
             $attendings = $enumerationsClosure->getAllDescendants($row->enumerationId, 1);
             foreach ($attendings as $attending) {
                 $teamMember = new self();
                 $teamMember->teamMemberId = (int) $attending->ormId;
                 $teamMember->populate();
                 $ret = $teamMember->personId;
                 break 2;
             }
         }
     }
     return $ret;
 }
 /**
  * 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);
         }
     }
 }
 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 #17
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 #18
0
 public static function location($roomId, $raw = false)
 {
     $location = '';
     if ($raw) {
         $location = array('practice' => '', 'building' => '', 'room' => '');
     }
     $roomId = (int) $roomId;
     if ($roomId > 0) {
         $room = new self();
         $room->roomId = (int) $roomId;
         $room->populate();
         if ($raw) {
             $location['practice'] = $room->building->practice->name;
             $location['building'] = $room->building->name;
             $location['room'] = $room->name;
         } else {
             $location = $room->building->practice->name . '->' . $room->building->name . '->' . $room->name;
         }
     }
     return $location;
 }
Example #19
0
 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();
 }
Example #20
0
 public static function log($fromEmail, $fromName, $toEmail, $toName, $subject, $body, $status = 0)
 {
     $mailerlog = new self();
     $mailerlog->populate(['from_name' => $fromName, 'from_email' => $fromEmail, 'to_name' => $toName, 'to_email' => $toEmail, 'subject' => $subject, 'body' => $body, 'status' => $status]);
     return $mailerlog->insert();
 }