public function editAction() { $ormId = (int) $this->_getParam('ormId'); $enumerationId = (int) $this->_getParam('enumerationId'); $enumerationsClosure = new EnumerationsClosure(); $depth = (int) $enumerationsClosure->getDepthById($enumerationId); if ($depth === 0) { $this->view->message = __('Only appointment template entries can be edited'); } else { $this->_appointmentTemplate = new AppointmentTemplate(); $this->_appointmentTemplate->appointmentTemplateId = $ormId; $this->_appointmentTemplate->populate(); $breakdowns = array(); if (strlen($this->_appointmentTemplate->breakdown) > 0) { $breakdowns = unserialize($this->_appointmentTemplate->breakdown); } $this->view->breakdowns = $breakdowns; $this->_form = new WebVista_Form(array('name' => 'edit')); $this->_form->setAction(Zend_Registry::get('baseUrl') . 'appointment-templates.raw/process-edit'); $this->_form->loadORM($this->_appointmentTemplate, 'appointmentTemplate'); $this->_form->setWindow('windowEditORMObjectId'); $this->view->form = $this->_form; $this->view->enumerationId = $enumerationId; } $this->render('edit'); }
public static function listReasons() { $reasons = array(); $enumeration = new Enumeration(); $enumeration->populateByUniqueName(self::ENUM_REASON_PARENT_NAME); $enumerationsClosure = new EnumerationsClosure(); $enumerationIterator = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1); foreach ($enumerationIterator as $enum) { $reasons[$enum->key] = $enum->name; } return $reasons; }
public function listSectionAction() { $sectionId = (int) $this->_getParam('section'); $enumerationsClosure = new EnumerationsClosure(); $enumerationIterator = $enumerationsClosure->getAllDescendants($sectionId, 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; } $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct(array('rows' => $rows), true); }
public function editAction() { $tableName = preg_replace('/[^a-zA-Z]+/', '', $this->_getParam("id", "")); $prettyName = preg_replace('/([A-Z]{1})/', ' \\1', substr($tableName, 9)); $this->view->tableName = $tableName; $this->view->prettyName = $prettyName; $this->view->chBaseMed24Url = Zend_Registry::get('config')->healthcloud->CHMED->chBaseMed24Url; $this->view->chBaseMed24DetailUrl = Zend_Registry::get('config')->healthcloud->CHMED->chBaseMed24DetailUrl; $name = Medication::ENUM_ADMIN_SCHED; $enumeration = new Enumeration(); $enumeration->populateByEnumerationName($name); $enumerationsClosure = new EnumerationsClosure(); $rowset = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1); $scheduleOptions = array(); $adminSchedules = array(); foreach ($rowset as $row) { $scheduleOptions[] = $row->key; $adminSchedules[$row->key] = $row->name; } $this->view->scheduleOptions = $scheduleOptions; $this->view->quantityQualifiers = Medication::listQuantityQualifiersMapping(); $this->render(); }
protected function _getReasons() { $reasons = array(); $enumeration = new Enumeration(); $enumeration->populateByEnumerationName(PatientNote::ENUM_REASON_PARENT_NAME); $enumerationsClosure = new EnumerationsClosure(); $enumerationIterator = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1); $ctr = 0; foreach ($enumerationIterator as $enum) { // since data type of patient_note.reason is tinyint we simply use the counter as id $reasons[$ctr++] = $enum->name; } return $reasons; }
public function indexAction() { $memcache = Zend_Registry::get('memcache'); $defaultQuickList = $memcache->get('defaultQuickList'); if ($defaultQuickList === false) { $defaultQuickList = array(); $defaultQuickList['type'] = 'mostRecent'; $defaultQuickList['id'] = 'mostRecent'; $defaultQuickList['text'] = 'Most Recent'; } else { $defaultQuickList = unserialize($defaultQuickList); } $this->view->defaultQuickList = $defaultQuickList; $this->view->quickList = $this->_getQuickList(); $providerIterator = new ProviderIterator(); $this->view->providerIterator = $providerIterator; $name = TeamMember::ENUM_PARENT_NAME; $enumeration = new Enumeration(); $enumeration->populateByEnumerationName($name); $enumerationsClosure = new EnumerationsClosure(); $enumerationIterator = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1); $this->view->teamList = $enumerationIterator; $this->render(); }
protected function _generateEnumerationTree(SimpleXMLElement $xml, $enumerationId) { static $enumerationList = array(); $enumerationsClosure = new EnumerationsClosure(); $descendants = $enumerationsClosure->getEnumerationTreeById($enumerationId); $item = null; foreach ($descendants as $enum) { if (in_array($enum->enumerationId, $enumerationList)) { continue; } $icon = ''; if (strlen($enum->ormClass) > 0 && class_exists($enum->ormClass)) { $icon = "<a onclick=\"enumEditObject({$enum->enumerationId})\" title=\"Edit Object\"><img src=\"" . Zend_Registry::get('baseUrl') . "img/sm-editproblem.png\" alt=\"Edit Object\" /></a>"; } $category = ''; if ($item === null) { //$item = $xml->addChild("row"); $item = $xml; $category = $enum->category; } $leaf = $item->addChild("row"); $leaf->addAttribute('id', $enum->enumerationId); $leaf->addChild('cell', htmlspecialchars($enum->name)); $leaf->addChild('cell', $category); $leaf->addChild('cell', $enum->active); $leaf->addChild('cell', $icon); $enumerationList[] = $enum->enumerationId; if ($enumerationId != $enum->enumerationId) { // prevents infinite loop $this->_generateEnumerationTree($leaf, $enum->enumerationId); } } }
public function selectAction() { $patientId = (int) $this->_getParam("patientId"); $patient = new Patient(); $patient->personId = $patientId; $patient->populate(); $patient->person->populate(); $hasTeam = false; if (strlen($patient->teamId) > 0) { $hasTeam = true; } $name = TeamMember::ENUM_PARENT_NAME; $enumeration = new Enumeration(); $enumeration->populateByEnumerationName($name); $enumerationsClosure = new EnumerationsClosure(); $rowset = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1); $teamList = array('' => ''); //trigger_error('sql: '.$dbSelect->__toString(),E_USER_NOTICE); $patientEnumerationId = 0; foreach ($rowset as $row) { if ($patient->teamId == $row->key) { $patientEnumerationId = $row->enumerationId; } $teamList[$row->key] = $row->name; } $this->view->teamList = $teamList; $this->view->hasTeam = $hasTeam; //$this->view->hasTeam = true; $this->view->patient = $patient; $teamMemberList = ''; if ($patientEnumerationId !== 0) { $teamMemberList = TeamMember::generateTeamTree($patientEnumerationId); } $this->view->teamMemberList = $teamMemberList; $this->render(); }
public function _setActivePatient($personId, $visitId) { if (!$personId > 0) { return; } $memcache = Zend_Registry::get('memcache'); $patient = new Patient(); $patient->personId = (int) $personId; $patient->populate(); $patient->person->populate(); $this->_patient = $patient; $this->view->patient = $this->_patient; $mostRecentRaw = $memcache->get('mostRecent'); $currentUserId = (int) Zend_Auth::getInstance()->getIdentity()->personId; $personId = $patient->personId; $teamId = $patient->teamId; if ($mostRecentRaw === false) { $mostRecent = array(); } else { $mostRecent = unserialize($mostRecentRaw); } if (!array_key_exists($currentUserId, $mostRecent)) { $mostRecent[$currentUserId] = array(); } if (array_key_exists($personId, $mostRecent[$currentUserId])) { unset($mostRecent[$currentUserId][$personId]); } $name = $patient->person->last_name . ', ' . $patient->person->first_name . ' ' . substr($patient->person->middle_name, 0, 1) . ' #' . $patient->record_number; $mostRecent[$currentUserId][$patient->personId] = array('name' => $name, 'teamId' => $teamId); $memcache->set('mostRecent', serialize($mostRecent)); if (strlen($patient->teamId) > 0) { $name = TeamMember::ENUM_PARENT_NAME; $enumeration = new Enumeration(); $enumeration->populateByEnumerationName($name); $enumerationsClosure = new EnumerationsClosure(); $rowset = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1); $patientEnumerationId = 0; foreach ($rowset as $row) { if ($patient->teamId == $row->key) { $patientEnumerationId = $row->enumerationId; break; } } if ($patientEnumerationId !== 0) { $this->view->team = TeamMember::generateTeamTree($patientEnumerationId); } } // POSTINGS $allergies = array(); $patientAllergy = new PatientAllergy(); $patientAllergyIterator = $patientAllergy->getIteratorByPatient($personId); foreach ($patientAllergyIterator as $allergy) { if ($allergy->noKnownAllergies) { continue; } $allergies[] = $allergy->toArray(); } $this->view->allergies = $allergies; $notes = array(); $patientNote = new PatientNote(); $patientNoteIterator = $patientNote->getIterator(); $filters = array(); $filters['patient_id'] = $personId; $filters['active'] = 1; $filters['posting'] = 1; $patientNoteIterator->setFilters($filters); foreach ($patientNoteIterator as $note) { $notes[] = $note->toArray(); } $this->view->notes = $notes; //REMINDERS $ctr = 0; $hsa = new HealthStatusAlert(); $hsaIterator = $hsa->getIteratorByStatusWithPatientId('active', $personId); foreach ($hsaIterator as $row) { $ctr++; } if ($ctr > 0) { $this->view->reminders = $ctr; } // VISITS //$this->_visit = null; if (!$visitId > 0) { return; } $visit = new Visit(); $visit->encounter_id = (int) $visitId; $visit->populate(); $this->_visit = $visit; $this->view->visit = $this->_visit; }
public function editMedicationAction() { $personId = (int) $this->_getParam('personId'); $medicationId = (int) $this->_getParam('medicationId'); $copy = $this->_getParam('copy'); $patient = new Patient(); $patient->personId = $personId; $patient->populate(); if (strlen($copy) > 0) { $this->view->copy = $copy; } $name = Medication::ENUM_ADMIN_SCHED; $enumeration = new Enumeration(); $enumeration->populateByEnumerationName($name); $enumerationsClosure = new EnumerationsClosure(); $rowset = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1); $scheduleOptions = array(); $adminSchedules = array(); foreach ($rowset as $row) { $scheduleOptions[] = $row->key; $adminSchedules[$row->key] = $row->name; } $this->view->scheduleOptions = $scheduleOptions; $this->view->adminSchedules = $adminSchedules; $this->view->chBaseMed24Url = Zend_Registry::get('config')->healthcloud->CHMED->chBaseMed24Url; $this->view->chBaseMed24DetailUrl = Zend_Registry::get('config')->healthcloud->CHMED->chBaseMed24DetailUrl; $this->_form = new WebVista_Form(array('name' => 'new-medication')); $this->_form->setAction(Zend_Registry::get('baseUrl') . "medications.raw/process-add-medication"); $this->_medication = new Medication(); $this->_medication->personId = $personId; if ($medicationId > 0) { $this->_medication->medicationId = (int) $medicationId; $this->_medication->populate(); } if (!strlen($this->_medication->pharmacyId) > 0) { $this->_medication->pharmacyId = $patient->defaultPharmacyId; } if (strlen($copy) > 0) { $this->_medication->medicationId = 0; } $this->_form->loadORM($this->_medication, "Medication"); $this->_form->setWindow('windowNewMedication'); $this->view->form = $this->_form; $this->view->medication = $this->_medication; $this->render('new-medication'); }
public function lookupAction() { $sectionId = (int) $this->_getParam('section'); $enumerationsClosure = new EnumerationsClosure(); $enumerationIterator = $enumerationsClosure->getAllDescendants($sectionId, 1); $rows = array(); foreach ($enumerationIterator as $enum) { $name = $enum->name; $edu = new EducationResource(); $edu->educationResourceId = (int) $enum->enumerationId; if ($edu->populate() && strlen($edu->resource) > 0) { $name = '<a href="' . $edu->resource . '" target="_blank">' . $name . '</a>'; } $rows[$enum->key] = array('name' => $enum->name, 'displayName' => $name); } $this->view->jsCallback = $this->_getParam('callback', ''); $this->view->listEducationTopics = $rows; $this->render('lookup'); }
public static function getEnumById($enumId) { $enumerationClosure = new EnumerationsClosure(); $enumerationClosureIterator = $enumerationClosure->getAllDescendants($enumId); foreach ($enumerationClosureIterator as $enum) { $children = self::getEnumById($enum->enumerationId); if (!count($children) > 0) { } $ret[$enum->enumerationId] = $enum->name; } }
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)); }
public static function getListIdentifierTypes() { $enumeration = new Enumeration(); $enumeration->populateByUniqueName('Identifier Type'); $enumerationsClosure = new EnumerationsClosure(); $ret = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1)->toArray('key', 'name'); return $ret; }
public function addAppointmentAction() { $appointmentId = $this->_getParam('appointmentId'); $appointment = new Appointment(); if (strlen($appointmentId) > 0) { $filter = $this->getCurrentDisplayFilter(); $appointment->appointmentId = (int) $appointmentId; $appointment->populate(); $this->view->start = date('H:i', strtotime($appointment->start)); $this->view->end = date('H:i', strtotime($appointment->end)); foreach ($filter->columns as $index => $col) { if ($col['providerId'] > 0 && $col['roomId'] > 0 && $col['providerId'] == $appointment->providerId && $col['roomId'] == $appointment->roomId || $col['providerId'] > 0 && $col['providerId'] == $appointment->providerId || $col['roomId'] > 0 && $col['roomId'] == $appointment->roomId) { $this->view->columnId = $index; break; } } $recordNumber = $appointment->patient->record_number; $lastName = $appointment->patient->last_name; $firstName = $appointment->patient->first_name; $middleInitial = ''; if (strlen($appointment->patient->middle_name) > 0) { $middleInitial = $appointment->patient->middle_name[0]; } $this->view->patient = "{$lastName}, {$firstName} {$middleInitial} #{$recordNumber} PID:{$appointment->patient->person_id}"; } else { $columnId = $this->_getParam('columnId'); $rowId = $this->_getParam('rowId'); $start = $this->_getParam('start'); if (strlen($columnId) > 0) { $this->view->columnId = $columnId; $filter = $this->getCurrentDisplayFilter(); if (!isset($filter->columns[$columnId])) { throw new Exception(__("Cannot generate column with that index, there is no filter defined for that column Index: ") . $columnId); } $column = $filter->columns[$columnId]; $appointment->providerId = isset($column['providerId']) ? $column['providerId'] : 0; $appointment->roomId = isset($column['roomId']) ? $column['roomId'] : 0; } if (strlen($start) > 0) { $this->view->start = $start; $this->view->end = date('H:i', strtotime('+1 hour', strtotime($start))); } } $form = new WebVista_Form(array('name' => 'add-appointment')); $form->setAction(Zend_Registry::get('baseUrl') . "calendar.raw/process-add-appointment"); $form->loadORM($appointment, "Appointment"); $form->setWindow('windowNewAppointment'); $this->view->form = $form; $reasons = array(); $enumeration = new Enumeration(); $enumeration->populateByEnumerationName(PatientNote::ENUM_REASON_PARENT_NAME); $enumerationsClosure = new EnumerationsClosure(); $enumerationIterator = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1); $ctr = 0; foreach ($enumerationIterator as $enum) { // since data type of patient_note.reason is tinyint we simply use the counter as id $reasons[$ctr++] = $enum->name; } /* $patientNotes = array(); $patientNote = new PatientNote(); $patientNoteIterator = $patientNote->getIterator(); $filters = array(); $filters['patient_id'] = (int)$appointment->patientId; $filters['active'] = 1; $filters['posting'] = 0; $patientNoteIterator->setFilters($filters); foreach ($patientNoteIterator as $row) { $patientNotes[$row->patientNoteId] = $reasons[$row->reason]; } $this->view->patientNotes = $patientNotes; */ $phones = array(); $phone = new PhoneNumber(); $phoneIterator = $phone->getIteratorByPatientId($appointment->patientId); foreach ($phoneIterator as $row) { $phones[] = $row->number; } $this->view->phones = $phones; $appointmentTemplate = new AppointmentTemplate(); $appointmentReasons = $appointmentTemplate->getAppointmentReasons(); $this->view->appointmentReasons = $appointmentReasons; $this->view->appointment = $appointment; $this->render('add-appointment'); }
public function bulkEntryAction() { $othersId = 0; $series = array(); $sites = array(); $reactions = array(); $routes = array(); $enumerationsClosure = new EnumerationsClosure(); $parentName = PatientImmunization::ENUM_PARENT_NAME; $enumeration = new Enumeration(); $enumeration->populateByUniqueName($parentName); $enumerationIterator = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1); foreach ($enumerationIterator as $enum) { switch ($enum->name) { case PatientImmunization::ENUM_SERIES_NAME: $enumIterator = $enumerationsClosure->getAllDescendants($enum->enumerationId, 1); $series = $enumIterator->toArray('key', 'name'); break; case PatientImmunization::ENUM_BODY_SITE_NAME: $enumIterator = $enumerationsClosure->getAllDescendants($enum->enumerationId, 1); $sites = $enumIterator->toArray('key', 'name'); break; case PatientImmunization::ENUM_SECTION_NAME: $enumIterator = $enumerationsClosure->getAllDescendants($enum->enumerationId, 1); foreach ($enumIterator as $item) { if ($item->name == PatientImmunization::ENUM_SECTION_OTHER_NAME) { $othersId = $item->enumerationId; break; } } break; case PatientImmunization::ENUM_REACTION_NAME: $enumIterator = $enumerationsClosure->getAllDescendants($enum->enumerationId, 1); $reactions = $enumIterator->toArray('key', 'name'); break; case PatientImmunization::ENUM_ADMINISTRATION_ROUTE_NAME: $enumIterator = $enumerationsClosure->getAllDescendants($enum->enumerationId, 1); $routes = $enumIterator->toArray('key', 'name'); break; } } $enumerationsClosure = new EnumerationsClosure(); $enumerationIterator = $enumerationsClosure->getAllDescendants($othersId, 1); $lists = array(); foreach ($enumerationIterator as $enum) { $lists[$enum->key] = $enum->name; } $this->view->lists = $lists; $this->view->series = $series; $this->view->sites = $sites; $this->view->reactions = $reactions; $this->view->routes = $routes; $this->render(); }
public static function enumerationToJson($name) { $enumeration = new self(); $enumeration->populateByEnumerationName($name); $enumerationsClosure = new EnumerationsClosure(); $enumerationIterator = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1); return $enumerationIterator->toJsonArray('enumerationId', array('name')); }
public function processImport2xFacilitiesAction() { $import = (int) $this->_getParam('import'); $parentId = (int) $this->_getParam('parentId'); $data = false; if ($import > 0 && $parentId > 0) { $db = Zend_Registry::get('dbAdapter'); $enumClosure = new EnumerationsClosure(); $sql = 'SELECT * FROM practices'; $practices = $db->fetchAll($sql); $ctr = 1; foreach ($practices as $practice) { $p = new Practice(); $p->name = $practice['name']; $p->website = $practice['website']; $p->identifier = $practice['identifier']; //$p->persist(); // add addresses (primary = 4, secondary = 5) $sql = 'SELECT * FROM practice_address AS pa INNER JOIN address a ON a.address_id=pa.address_id WHERE pa.practice_id=' . $practice['id'] . ' AND (pa.address_type=4 OR pa.address_type=5)'; $addresses = $db->fetchAll($sql); foreach ($addresses as $address) { if ($address['address_type'] == 4) { $addr = $p->primaryAddress; } else { if ($address['address_type'] == 5) { $addr = $p->secondaryAddress; } else { continue; } } $addr->populateWithArray($address); $addr->addressId = 0; $addr->type = $address['address_type']; $addr->active = 1; $addr->practiceId = $practice['id']; //$addr->persist(); } // add phones (main = 3, secondary = 1, fax = 5) $sql = 'SELECT * FROM practice_number AS pn INNER JOIN number n ON n.number_id=pn.number_id WHERE pn.practice_id=' . $practice['id'] . ' AND (n.number_type=1 OR n.number_type=3 OR n.number_type=5)'; $phones = $db->fetchAll($sql); foreach ($phones as $phone) { $pn = new PhoneNumber(); $pn->populateWithArray($phone); $pn->type = $phone['number_type']; $pn->numberId = 0; //$pn->persist(); } //$practiceId = $p->practiceId; $practiceId = $practice['id']; $params = array(); $params['name'] = $practice['name']; $params['key'] = $ctr++; $params['active'] = '1'; $params['ormClass'] = 'Practice'; $params['ormId'] = $practiceId; $params['ormEditMethod'] = 'ormEditMethod'; $buildingParentId = $enumClosure->insertEnumeration($params, $parentId); $sql = 'SELECT * FROM buildings WHERE practice_id=' . $practice['id']; $buildings = $db->fetchAll($sql); foreach ($buildings as $building) { $b = new Building(); $b->description = $building['description']; $b->name = $building['name']; $b->practiceId = $p->practiceId; $b->identifier = $building['identifier']; $b->facilityCodeId = $building['facility_code_id']; //$b->phoneNumber = $building['']; //$b->persist(); //$buildingId = $b->buildingId; $buildingId = $building['id']; $params = array(); $params['name'] = $building['name']; $params['key'] = $ctr++; $params['active'] = '1'; $params['ormClass'] = 'Building'; $params['ormId'] = $buildingId; $params['ormEditMethod'] = 'ormEditMethod'; $roomParentId = $enumClosure->insertEnumeration($params, $buildingParentId); // add phone number // add address $sql = 'SELECT * FROM building_address AS ba INNER JOIN address a ON a.address_id=ba.address_id WHERE ba.building_id=' . $building['id']; $addresses = $db->fetchAll($sql); foreach ($addresses as $address) { $addr = new Address(); $addr->populateWithArray($address); $addr->addressId = 0; $addr->type = $address['address_type']; $addr->active = 1; $addr->practiceId = $practice['id']; //$addr->persist(); } $sql = 'SELECT * FROM rooms WHERE building_id=' . $building['id']; $rooms = $db->fetchAll($sql); foreach ($rooms as $room) { $r = new Room(); $r->populateWithArray($room); $r->roomId = 0; //$r->persist(); //$roomId = $r->roomId; $roomId = $room['id']; $params = array(); $params['name'] = $room['name']; $params['key'] = $ctr++; $params['active'] = '1'; $params['ormClass'] = 'Room'; $params['ormId'] = $roomId; $params['ormEditMethod'] = 'ormEditMethod'; $enumerationId = $enumClosure->insertEnumeration($params, $roomParentId); } } } $data = true; } $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct($data); }
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 static function populate(CCD $base, SimpleXMLElement $xml) { $component = $xml->addChild('component'); $section = $component->addChild('section'); $templateId = $section->addChild('templateId'); $templateId->addAttribute('root', '2.16.840.1.113883.3.88.11.83.102'); $templateId->addAttribute('assigningAuthorityName', 'HITSP/C83'); $templateId = $section->addChild('templateId'); $templateId->addAttribute('root', '1.3.6.1.4.1.19376.1.5.3.1.3.13'); $templateId->addAttribute('assigningAuthorityName', 'IHE PCC'); $templateId = $section->addChild('templateId'); $templateId->addAttribute('root', '2.16.840.1.113883.10.20.1.2'); $templateId->addAttribute('assigningAuthorityName', 'HL7 CCD'); // <!--Allergies/Reactions section template--> $code = $section->addChild('code'); $code->addAttribute('code', '48765-2'); $code->addAttribute('codeSystem', '2.16.840.1.113883.6.1'); $code->addAttribute('codeSystemName', 'LOINC'); $code->addAttribute('displayName', 'Allergies'); $section->addChild('title', 'Allergies and Adverse Reactions'); $enumeration = new Enumeration(); $listSymptoms = array(); $enumeration->populateByEnumerationName(PatientAllergy::ENUM_SYMPTOM_PARENT_NAME); $enumerationsClosure = new EnumerationsClosure(); $enumerationIterator = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1); foreach ($enumerationIterator as $enum) { $listSymptoms[$enum->key] = $enum->name; } $filters = array('patientId' => $base->patient->personId); $base->setFiltersDateRange($filters); $rows = array(); $allergies = PatientAllergy::listMedicationAllergies($filters); foreach ($allergies as $key => $allergy) { $exp = explode(',', $allergy['symptoms']); $symptoms = array(); foreach ($exp as $symp) { $symptoms[] = isset($listSymptoms[$symp]) ? $listSymptoms[$symp] : ''; } $reactionType = $allergy['reactionType']; if (!strlen($reactionType) > 0) { $reactionType = 'Unknown'; } $active = (int) $allergy['active'] ? 'Active' : 'Inactive'; $snomed = ''; $row = array(); $row['type'] = $reactionType; //'Drug Allergy'; if ($reactionType == 'Specific Drug Allergy') { $snomed = '416098002'; } $row['snomed'] = $snomed; $row['substance'] = html_convert_entities($allergy['causativeAgent']); $row['rxnorm'] = html_convert_entities($allergy['rxnorm_cuid']); $row['reaction'] = array('id' => 'ReactionID-' . $key, 'value' => html_convert_entities(implode(', ', $symptoms))); $row['date'] = date('M d, Y', strtotime($allergy['dateTimeReaction'])); $row['status'] = html_convert_entities($active); $rows[] = $row; } /* -**SNOMED Allergy Type Code** (note from NIST: "The SNOMED Allergy Type Code is required by HITSP/C83, which is a component of the HITSP/C32 implementation guide specified by ONC in the Final Rule") -**Medication/Agent Allergy** (including medication/agent allergy and associated RxNorm code) */ $text = $section->addChild('text'); if ($rows) { $table = $text->addChild('table'); $thead = $table->addChild('thead'); $tr = $thead->addChild('tr'); $tr->addChild('th', 'Type'); $tr->addChild('th', 'Drug allergy SNOMED code'); $tr->addChild('th', 'Substance'); $tr->addChild('th', 'Substance RxNorm code'); $tr->addChild('th', 'Reaction'); $tr->addChild('th', 'Date Identified'); $tr->addChild('th', 'Status'); $tbody = $table->addChild('tbody'); foreach ($rows as $row) { $tr = $tbody->addChild('tr'); $tr->addChild('td', $row['type']); $tr->addChild('td', $row['snomed']); $tr->addChild('td', $row['substance']); $tr->addChild('td', $row['rxnorm']); $td = $tr->addChild('td', $row['reaction']['value']); $td->addAttribute('ID', $row['reaction']['id']); $tr->addChild('td', $row['date']); $tr->addChild('td', $row['status']); } } foreach ($allergies as $allergy) { $type = $allergy['reactionType']; if (!strlen($type) > 0) { $type = 'Unknown'; } $substance = html_convert_entities($allergy['causativeAgent']); $exp = explode(',', $allergy['symptoms']); $symptoms = array(); foreach ($exp as $symp) { $symptoms[] = isset($listSymptoms[$symp]) ? $listSymptoms[$symp] : ''; } $reaction = ''; if ($symptoms) { $reaction = html_convert_entities(implode(', ', $symptoms)); } $status = 'Inactive'; $statusCode = 'completed'; $effectiveTimeHigh = '<high nullFlavor="UNK"/>'; if ((int) $allergy['active']) { $status = 'Active'; $statusCode = 'active'; $effectiveTimeHigh = ''; } $status = (int) $allergy['active'] ? 'Active' : 'Inactive'; // STATUS CODES: active, suspended, aborted, completed $statusCode = (int) $allergy['active'] ? 'active' : 'completed'; $entry = '<act classCode="ACT" moodCode="EVN"> <templateId root="2.16.840.1.113883.3.88.11.83.6" assigningAuthorityName="HITSP C83"/> <templateId root="2.16.840.1.113883.10.20.1.27" assigningAuthorityName="CCD"/> <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.5.1" assigningAuthorityName="IHE PCC"/> <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.5.3" assigningAuthorityName="IHE PCC"/> <id root="' . NSDR::create_guid() . '"/> <code nullFlavor="NA"/> <statusCode code="' . $statusCode . '"/> <effectiveTime> <low nullFlavor="UNK"/>' . $effectiveTimeHigh . ' </effectiveTime> <entryRelationship typeCode="SUBJ" inversionInd="false"> <observation classCode="OBS" moodCode="EVN"> <templateId root="2.16.840.1.113883.10.20.1.18" assigningAuthorityName="CCD"/> <templateId root="2.16.840.1.113883.10.20.1.28" assigningAuthorityName="CCD"/> <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.5" assigningAuthorityName="IHE PCC"/> <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.6" assigningAuthorityName="IHE PCC"/> <id root="' . NSDR::create_guid() . '"/> <code code="416098002" codeSystem="2.16.840.1.113883.6.96" displayName="drug allergy" codeSystemName="SNOMED CT" /> <text> <reference value="PtrToValueInSectionText"/> </text> <statusCode code="completed"/> <effectiveTime> <low nullFlavor="UNK"/> </effectiveTime> <value xsi:type="CD"/> <participant typeCode="CSM"> <participantRole classCode="MANU"> <addr/> <telecom/> <playingEntity classCode="MMAT"> <code code="70618" codeSystem="2.16.840.1.113883.6.88" displayName="' . $substance . '"> <originalText> <reference value="PointrToSectionText"/> </originalText> </code> <name>' . $substance . '</name> </playingEntity> </participantRole>'; if ($reaction != '' && false) { $entry .= ' <entryRelationship typeCode="MFST" inversionInd="true"> <observation classCode="OBS" moodCode="EVN"> <templateId root="2.16.840.1.113883.10.20.1.54" assigningAuthorityName="CCD"/> <!--Reaction observation template --> <code code="ASSERTION" codeSystem="2.16.840.1.113883.5.4"/> <text/> <statusCode code="completed"/> <value xsi:type="CD" code="247472004" codeSystem="2.16.840.1.113883.6.96" displayName="' . $reaction . '"/> <entryRelationship typeCode="SUBJ"> <observation classCode="OBS" moodCode="EVN"> <templateId root="2.16.840.1.113883.10.20.1.55" assigningAuthorityName="CCD"/> <code code="SEV" displayName="Severity" codeSystemName="HL7 ActCode" codeSystem="2.16.840.1.113883.5.4"/> <text>Required by HITSP C-83</text> <statusCode code="completed"/> <value xsi:type="CE" displayName="moderate" code="6736007" codeSystemName="SNOMED" codeSystem="2.16.840.1.113883.6.96"/> </observation> </entryRelationship> </observation> </entryRelationship>'; } $entry .= ' <!--<entryRelationship typeCode="REFR"> <observation classCode="OBS" moodCode="EVN"> <templateId root="2.16.840.1.113883.10.20.1.39"/> <code code="33999-4" codeSystem="2.16.840.1.113883.6.1" displayName="Status"/> <statusCode code="completed"/> <value xsi:type="CE" code="55561003" codeSystem="2.16.840.1.113883.6.96" displayName="' . $status . '"/> </observation> </entryRelationship>--> </participant> </observation> </entryRelationship> </act>'; $entry = $section->addChild('entry', $entry); $entry->addAttribute('typeCode', 'DRIV'); } }
public static function getListPhoneTypes() { $enumeration = new Enumeration(); $enumeration->populateByUniqueName('Contact Preferences'); $enumerationsClosure = new EnumerationsClosure(); $enumerationIterator = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1); $ret = array(); foreach ($enumerationIterator as $enum) { if ($enum->name != 'Phone Types') { continue; } $ret = $enumerationsClosure->getAllDescendants($enum->enumerationId, 1)->toArray('key', 'name'); break; } return $ret; }
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 static function getListInsurancePreferences() { $enumeration = new Enumeration(); $enumeration->populateByUniqueName(self::INSURANCE_ENUM_NAME); $enumerationsClosure = new EnumerationsClosure(); $enumerationIterator = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1); $ret = array(); foreach ($enumerationIterator as $enum) { $ret[$enum->key] = $enumerationsClosure->getAllDescendants($enum->enumerationId, 1)->toArray('key', 'name'); } return $ret; }
public function addAction() { $this->_patientNote = new PatientAllergy(); $this->_patientNote->patientId = (int) $this->_getParam('personId'); $this->_patientNote->causativeAgent = $this->_getParam('allergy', ''); $this->_form = new WebVista_Form(array('name' => 'add')); $this->_form->setAction(Zend_Registry::get('baseUrl') . 'allergies.raw/process-add'); $this->_form->loadORM($this->_patientNote, 'allergy'); $this->_form->setWindow('winAddAllergyId'); $this->view->form = $this->_form; $patientNoteIterator = $this->_patientNote->getIteratorByPatient(); $ctr = 0; foreach ($patientNoteIterator as $allergy) { $ctr++; } $this->view->disableNoKnownAllergies = $ctr > 0 ? true : false; $listReactionTypes = array('' => ''); $enumeration = new Enumeration(); $enumeration->populateByEnumerationName(PatientAllergy::ENUM_REACTION_TYPE_PARENT_NAME); $enumerationsClosure = new EnumerationsClosure(); $enumerationIterator = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1); $ctr = 0; foreach ($enumerationIterator as $enum) { $listReactionTypes[$enum->key] = $enum->name; } $this->view->listReactionTypes = $listReactionTypes; $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; } $this->view->listSeverities = $listSeverities; $listSymptoms = array(); $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; } $this->view->listSymptoms = $listSymptoms; $listObservers = array('' => ''); $providerIterator = new ProviderIterator(); foreach ($providerIterator as $provider) { $listObservers[$provider->personId] = $provider->displayName; } $this->view->listObservers = $listObservers; $this->render('add'); }
public function examsAction() { $name = PatientExam::ENUM_RESULT_PARENT_NAME; $enumeration = new Enumeration(); $enumeration->populateByEnumerationName($name); $enumerationsClosure = new EnumerationsClosure(); $enumerationIterator = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1); foreach ($enumerationIterator as $enumeration) { $listResults[$enumeration->key] = $enumeration->name; } $this->view->listResults = $listResults; $this->render(); }
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; }
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 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 function editRoomAction() { $id = (int) $this->_getParam('id'); $enumerationId = (int) $this->_getParam('enumerationId'); $enumerationsClosure = new EnumerationsClosure(); $parentId = $enumerationsClosure->getParentById($enumerationId); $enumeration = new Enumeration(); $enumeration->enumerationId = $parentId; $enumeration->populate(); $orm = new Room(); if ($id > 0) { $orm->roomId = $id; $orm->populate(); } $orm->buildingId = $enumeration->ormId; $form = new WebVista_Form(array('name' => 'edit-room')); $form->setAction(Zend_Registry::get('baseUrl') . 'facilities.raw/process-edit-room'); $form->loadORM($orm, 'Room'); $form->setWindow('windowEditRoomId'); $this->view->form = $form; $routingStations = LegacyEnum::getEnumArray('routing_stations'); $routingStations = array_merge(array('' => ''), $routingStations); $this->view->colors = Room::getColorList(); $this->view->routingStations = $routingStations; $this->view->enumerationId = $enumerationId; $this->render('edit-room'); }
protected static function _getEnumerationIterator($name) { $enumeration = new Enumeration(); $enumeration->populateByEnumerationName($name); $enumeration->populate(); $enumerationsClosure = new EnumerationsClosure(); return $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1); }