Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 public function getDiscountTypes()
 {
     $discountTypes = array();
     $enumeration = new Enumeration();
     $enumeration->populateByUniqueName(self::DISCOUNT_TYPE_ENUM_NAME);
     $enumerationClosure = new EnumerationClosure();
     $enumerationIterator = $enumerationClosure->getAllDescendants($enumeration->enumerationId, 1);
     foreach ($enumerationIterator as $enum) {
         $discountTypes[$enum->key] = $enum->name;
     }
     return $discountTypes;
 }
 protected function _getEnumerationByName($name)
 {
     $enumeration = new Enumeration();
     $enumeration->populateByUniqueName($name);
     $enumerationsClosure = new EnumerationsClosure();
     $enumerationIterator = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1);
     $ret = array();
     foreach ($enumerationIterator as $enumeration) {
         $ret[$enumeration->key] = $enumeration->name;
     }
     return $ret;
 }
 protected function _edit($groupId = null)
 {
     $groupId = (int) $groupId;
     $claimRule = new ClaimRule();
     $claimRule->event = ClaimRule::EVENT_WARNING;
     $action = 'add';
     if ($groupId > 0) {
         $claimRule->groupId = $groupId;
         $claimRule->populateWithGroupId();
         $claim = new ClaimRule();
         $claim->title = $claimRule->title;
         $claim->message = $claimRule->message;
         $claim->groupId = $claimRule->groupId;
         $claim->event = $claimRule->event;
         $claimRule = $claim;
         // swap, we only need the hidden fields
         $action = 'edit';
     }
     $this->view->action = $action;
     $form = new WebVista_Form(array('name' => 'claimRule'));
     $form->setAction(Zend_Registry::get('baseUrl') . 'claim-rules.raw/process-' . $action);
     $form->loadORM($claimRule, 'claimRule');
     $form->setWindow('windowEditClaimRuleId');
     $this->view->form = $form;
     $this->view->claimRule = $claimRule;
     $modifiers = array('' => '');
     $enumeration = new Enumeration();
     $enumeration->populateByUniqueName('Procedure Modifiers');
     $closure = new EnumerationClosure();
     $descendants = $closure->getAllDescendants($enumeration->enumerationId, 1, true);
     foreach ($descendants as $row) {
         $modifiers[$row->key] = $row->key . ': ' . $row->name;
     }
     $this->view->modifiers = $modifiers;
     $insurancePrograms = array('' => '');
     foreach (InsuranceProgram::getInsurancePrograms() as $key => $value) {
         $insurancePrograms[$key] = $value;
     }
     $this->view->insurancePrograms = $insurancePrograms;
     $this->render('edit');
 }
 public function educationAction()
 {
     $enumerationsClosure = new EnumerationsClosure();
     $othersId = 0;
     $levels = array();
     $sections = array();
     $parentName = PatientEducation::ENUM_EDUC_PARENT_NAME;
     $enumeration = new Enumeration();
     $enumeration->populateByUniqueName($parentName);
     $enumerationIterator = $enumerationsClosure->getAllDescendants($enumeration->enumerationId, 1);
     foreach ($enumerationIterator as $enum) {
         switch ($enum->name) {
             case PatientEducation::ENUM_EDUC_LEVEL_NAME:
                 $enumIterator = $enumerationsClosure->getAllDescendants($enum->enumerationId, 1);
                 foreach ($enumIterator as $item) {
                     $levels[$item->enumerationId] = $item->name;
                 }
                 break;
             case PatientEducation::ENUM_EDUC_SECTION_NAME:
                 $enumIterator = $enumerationsClosure->getAllDescendants($enum->enumerationId, 1);
                 foreach ($enumIterator as $item) {
                     if ($item->name == PatientEducation::ENUM_EDUC_SECTION_OTHER_NAME) {
                         $othersId = $item->enumerationId;
                         continue;
                     }
                     $sections[$item->enumerationId] = $item->name;
                 }
                 break;
         }
     }
     $this->view->othersId = $othersId;
     $this->view->levels = $levels;
     $this->view->sections = $sections;
     $this->render();
 }
Esempio n. 6
0
 public function setFilters(array $filters)
 {
     if (!is_array($filters) || empty($filters)) {
         throw new Exception(__('Invalid filters'));
     }
     $filtersArray = array();
     foreach ($filters as $filter) {
         if (!class_exists($filter)) {
             $msg = __("Filter {$filter} does not exists");
             throw new Exception($msg);
         }
         $class = new $filter();
         if (!$class instanceof WebVista_Model_ORM) {
             $msg = __("Filter {$filter} is not an instance of WebVista_Model_ORM");
             throw new Exception($msg);
         }
         $filtersArray[$filter] = $filter;
     }
     $this->_rows = array();
     $enumeration = new Enumeration();
     $enumeration->populateByUniqueName(self::ENUM_NAME);
     $enumerationClosure = new EnumerationClosure();
     if (isset($filtersArray['Practice'])) {
         $practices = $enumerationClosure->getAllDescendants($enumeration->enumerationId, 1);
         foreach ($practices as $enumPractice) {
             if (!$enumPractice->ormId > 0 || $enumPractice->ormClass != 'Practice') {
                 continue;
             }
             $practice = new Practice();
             $practice->practiceId = $enumPractice->ormId;
             $practice->populate();
             if (isset($filtersArray['Building'])) {
                 $buildings = $enumerationClosure->getAllDescendants($enumPractice->enumerationId, 1);
                 foreach ($buildings as $enumBuilding) {
                     if (!$enumBuilding->ormId > 0 || $enumBuilding->ormClass != 'Building') {
                         continue;
                     }
                     $building = new Building();
                     $building->buildingId = $enumBuilding->ormId;
                     $building->populate();
                     if (isset($filtersArray['Room'])) {
                         $rooms = $enumerationClosure->getAllDescendants($enumBuilding->enumerationId, 1);
                         foreach ($rooms as $enumRoom) {
                             if (!$enumRoom->ormId > 0 || $enumRoom->ormClass != 'Room') {
                                 continue;
                             }
                             $room = new Room();
                             $room->roomId = $enumRoom->ormId;
                             $room->populate();
                             $this->_rows[] = array('Practice' => $practice, 'Building' => $building, 'Room' => $room);
                         }
                     } else {
                         $this->_rows[] = array('Practice' => $practice, 'Building' => $building);
                     }
                 }
             } else {
                 $this->_rows[] = $practice;
             }
         }
     } else {
         if (isset($filtersArray['Building'])) {
             $buildings = $enumerationClosure->getAllDescendants($enumPractice->enumerationId, 1);
             foreach ($buildings as $enumBuilding) {
                 if (!$enumBuilding->ormId > 0 || $enumBuilding->ormClass != 'Building') {
                     continue;
                 }
                 $building = new Building();
                 $building->buildingId = $enumBuilding->ormId;
                 $building->populate();
                 if (isset($filtersArray['Room'])) {
                     $rooms = $enumerationClosure->getAllDescendants($enumBuilding->enumerationId, 1);
                     foreach ($rooms as $enumRoom) {
                         if (!$enumRoom->ormId > 0 || $enumRoom->ormClass != 'Room') {
                             continue;
                         }
                         $room = new Room();
                         $room->roomId = $enumRoom->ormId;
                         $room->populate();
                         $this->_rows[] = array('Building' => $building, 'Room' => $room);
                     }
                 } else {
                     $this->_rows[] = $building;
                 }
             }
         } else {
             if (isset($filtersArray['Room'])) {
                 $rooms = $enumerationClosure->getAllDescendants($enumBuilding->enumerationId, 1);
                 foreach ($rooms as $enumRoom) {
                     if (!$enumRoom->ormId > 0 || $enumRoom->ormClass != 'Room') {
                         continue;
                     }
                     $room = new Room();
                     $room->roomId = $enumRoom->ormId;
                     $room->populate();
                     $this->_rows[] = $room;
                 }
             }
         }
     }
     return $this;
 }
 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();
 }
Esempio n. 8
0
 public function imagingAction()
 {
     $personId = (int) $this->_getParam('personId');
     $orderId = (int) $this->_getParam('orderId');
     $copy = (int) $this->_getParam('copy');
     $orderImaging = new OrderImaging();
     $orderImaging->orderId = $orderId;
     if (!$orderId > 0 || !$orderImaging->populate()) {
         $orderImaging->order->patientId = $personId;
     }
     if ($copy) {
         $orderImaging->orderId = 0;
     }
     $form = new WebVista_Form(array('name' => 'imagingId'));
     $form->setAction(Zend_Registry::get('baseUrl') . 'orders.raw/process-imaging');
     $form->loadORM($orderImaging, 'imaging');
     $form->setWindow('windowImagingId');
     $this->view->form = $form;
     $namespace = $personId . '::com.clearhealth.person.examsOver7days';
     $this->view->examsOver7days = NSDR2::populate($namespace);
     $imagingList = array();
     $categories = array();
     $urgencies = array();
     $transports = array();
     $pregnants = array();
     $enumeration = new Enumeration();
     $enumeration->populateByUniqueName(OrderImaging::IMAGING_ENUM_NAME);
     $enumerationClosure = new EnumerationClosure();
     $imagingEnums = $enumerationClosure->getAllDescendants($enumeration->enumerationId, 1, true);
     foreach ($imagingEnums as $imagingEnum) {
         $rowset = $enumerationClosure->getAllDescendants($imagingEnum->enumerationId, 1, true);
         if ($imagingEnum->key == OrderImaging::IMAGING_TYPES_ENUM_KEY) {
             foreach ($rowset as $enum) {
                 $enumKey = $enum->enumerationId;
                 $imagingList[$enumKey] = array();
                 $imagingList[$enumKey]['name'] = $enum->name;
                 $imagingList[$enumKey]['procedures'] = array();
                 $imagingList[$enumKey]['modifiers'] = array();
                 $rows = $enumerationClosure->getAllDescendants($enum->enumerationId, 1, true);
                 foreach ($rows as $row) {
                     if ($row->name == 'Procedures') {
                         $rowsProcedures = $enumerationClosure->getAllDescendants($row->enumerationId, 1, true);
                         foreach ($rowsProcedures as $rowProcedure) {
                             $rowProcedureKey = $rowProcedure->enumerationId;
                             $imagingList[$enumKey]['procedures'][$rowProcedureKey]['procedure'] = $rowProcedure->name;
                             $rowsUnitComment = $enumerationClosure->getAllDescendants($rowProcedure->enumerationId, 1, true);
                             $comment = '';
                             foreach ($rowsUnitComment as $unitComment) {
                                 $comment = $unitComment->name;
                                 break;
                                 // only one comment is expected
                             }
                             $imagingList[$enumKey]['procedures'][$rowProcedureKey]['comment'] = $comment;
                         }
                     } else {
                         if ($row->name == 'Modifiers') {
                             $rowsModifiers = $enumerationClosure->getAllDescendants($row->enumerationId, 1, true);
                             foreach ($rowsModifiers as $rowModifier) {
                                 $rowModifierKey = $rowModifier->enumerationId;
                                 $imagingList[$enumKey]['modifiers'][$rowModifierKey] = $rowModifier->name;
                             }
                         }
                     }
                 }
             }
         } else {
             if ($imagingEnum->key == OrderImaging::IMAGING_CATEGORIES_ENUM_KEY) {
                 foreach ($rowset as $enum) {
                     $categories[$enum->key] = $enum->name;
                 }
             } else {
                 if ($imagingEnum->key == OrderImaging::IMAGING_URGENCIES_ENUM_KEY) {
                     foreach ($rowset as $enum) {
                         $urgencies[$enum->key] = $enum->name;
                     }
                 } else {
                     if ($imagingEnum->key == OrderImaging::IMAGING_TRANSPORTS_ENUM_KEY) {
                         foreach ($rowset as $enum) {
                             $transports[$enum->key] = $enum->name;
                         }
                     } else {
                         if ($imagingEnum->key == OrderImaging::IMAGING_PREGNANTS_ENUM_KEY) {
                             foreach ($rowset as $enum) {
                                 $pregnants[$enum->key] = $enum->name;
                             }
                         }
                     }
                 }
             }
         }
     }
     $this->view->imagingList = $imagingList;
     $this->view->categories = $categories;
     $this->view->urgencies = $urgencies;
     $this->view->transports = $transports;
     $this->view->pregnants = $pregnants;
     $this->view->imagingSubmitTo = array('CLEARHEALTH HOSPITAL');
     // temporarily hard-coded
     $this->render();
 }
Esempio n. 9
0
 protected function _populateLabTests()
 {
     if ($this->_labTests !== null) {
         return;
     }
     $enumeration = new Enumeration();
     $enumeration->populateByUniqueName(self::LAB_ENUM_NAME);
     $enumerationClosure = new EnumerationClosure();
     $labEnums = $enumerationClosure->getAllDescendants($enumeration->enumerationId, 1);
     $this->_labTests = array();
     foreach ($labEnums as $labEnum) {
         $this->_labTests[$labEnum->key] = $labEnum;
     }
 }
Esempio n. 10
0
 public static function generateEducationPreferencesEnum($force = false)
 {
     $ret = false;
     do {
         $name = PatientEducation::ENUM_EDUC_PARENT_NAME;
         $key = 'EduPref';
         $enumeration = new Enumeration();
         $enumeration->populateByUniqueName($name);
         // check for key existence
         if (strlen($enumeration->key) > 0 && $enumeration->key == $key) {
             if (!$force) {
                 break;
             }
             $enumerationClosure = new EnumerationsClosure();
             $enumerationClosure->deleteEnumeration($enumeration->enumerationId);
         }
         $enums = array('section' => array('key' => 'SECTION', 'name' => PatientEducation::ENUM_EDUC_SECTION_NAME, 'active' => 1, 'guid' => '09d0f1e5-715d-4c87-9ead-8169cf8ebf13', 'data' => array('other' => array('key' => 'OTHER', 'name' => PatientEducation::ENUM_EDUC_SECTION_OTHER_NAME, 'active' => 1, 'guid' => 'ad3cfda0-b93b-4bec-ab7b-d69b4caaa1fd', 'data' => array(array('key' => 'HFA', 'name' => 'HF ACTIVITY', 'active' => 1, 'guid' => 'a6ad54bf-0b62-4f27-a723-d85968dfa899'), array('key' => 'HFD', 'name' => 'HF DIET', 'active' => 1, 'guid' => 'f6e870af-a874-43fe-890b-f00908558d34'), array('key' => 'HFDM', 'name' => 'HF DISCHARGE MEDS', 'active' => 1, 'guid' => 'de847c7c-efa8-4fe5-aa74-5677b05ec199'), array('key' => 'HFF', 'name' => 'HF FOLLOWUP', 'active' => 1, 'guid' => '261dd2c8-d476-48a8-8b2c-478f6756ea27'), array('key' => 'HFS', 'name' => 'HF SYMPTOMS', 'active' => 1, 'guid' => '8e110ae8-c302-43be-852a-1c1d319e04d4'))), 'common' => array('key' => 'COMMON', 'name' => PatientEducation::ENUM_EDUC_SECTION_COMMON_NAME, 'active' => 1, 'guid' => 'c58d0def-0dfc-4e64-9765-aa3962c2f7f8', 'data' => array(array('key' => 'HYPER', 'name' => 'Hypertension', 'active' => 1, 'guid' => '24c2c962-86e5-462d-ae4d-7d78d6d2ca64'))))), 'level' => array('key' => 'LEVEL', 'name' => PatientEducation::ENUM_EDUC_LEVEL_NAME, 'active' => 1, 'guid' => 'e23beb46-4534-4a1d-88d7-175c3c55171e', 'data' => array(array('key' => 'POOR', 'name' => 'Poor', 'active' => 1, 'guid' => 'f5a283fe-e617-4aa1-b422-0abfedd2bf89'), array('key' => 'FAIR', 'name' => 'Fair', 'active' => 1, 'guid' => '35b9d1ca-f40e-4968-bb5b-b15b8b481ff8'), array('key' => 'GOOD', 'name' => 'Good', 'active' => 1, 'guid' => 'c4f1b8a8-49ba-4212-892b-4418b62f7dfc'), array('key' => 'GNA', 'name' => 'Group-no assessment', 'active' => 1, 'guid' => 'b5a37abd-69cb-480e-9c92-3b4110620cd1'), array('key' => 'REFUSED', 'name' => 'Refused', 'active' => 1, 'guid' => 'cf97b57c-506f-44dd-8770-00bbf76f5128'))));
         $level = array();
         $level['guid'] = '3cef009a-9562-4355-91ef-bfec93244027';
         $level['key'] = $key;
         $level['name'] = $name;
         $level['category'] = 'System';
         $level['active'] = 1;
         $level['data'] = $enums;
         $data = array($level);
         self::_saveEnumeration($data);
         $ret = true;
     } while (false);
     return $ret;
 }
Esempio n. 11
0
 public static function generateChargeTypesEnum($force = false)
 {
     $ret = false;
     do {
         $name = 'Charge Types';
         $key = 'CHG_TYPES';
         $enumeration = new Enumeration();
         $enumeration->populateByUniqueName($name);
         // check for key existence
         if (strlen($enumeration->key) > 0 && $enumeration->key == $key) {
             if (!$force) {
                 break;
             }
             $enumerationClosure = new EnumerationsClosure();
             $enumerationClosure->deleteEnumeration($enumeration->enumerationId);
         }
         $enums = array(array('key' => 'CORRCHARGE', 'name' => 'Correction Charge', 'active' => 1, 'guid' => '46c4a502-01d5-4de6-93fa-443d53b7b33d'), array('key' => 'LABCHARGE', 'name' => 'Labs Charge', 'active' => 1, 'guid' => '427b5de7-8e77-4019-8152-09d7edbe63c6'), array('key' => 'MEDCHARGE', 'name' => 'Medication Charge', 'active' => 1, 'guid' => '1a0b97d2-5a8f-471b-bb90-2ec2d1aacc7b'), array('key' => 'VISITCHG', 'name' => 'Visit Charge', 'active' => 1, 'guid' => 'b73106f0-fbd4-435f-94f3-2e2e02293aae'), array('key' => 'OTHER', 'name' => 'Other', 'active' => 1, 'guid' => 'b309495a-8f4c-4eb0-b558-a81cf79acf13'));
         $level = array();
         $level['guid'] = '5ca94c8c-5198-4461-957b-fa568be9c79e';
         $level['key'] = $key;
         $level['name'] = $name;
         $level['category'] = 'System';
         $level['active'] = 1;
         $level['data'] = $enums;
         $data = array($level);
         self::_saveEnumeration($data);
         $ret = true;
     } while (false);
     return $ret;
 }
 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->populateByUniqueName($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();
 }
Esempio n. 13
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;
 }
Esempio n. 14
0
 protected static function _generate4010A1($claimId, array $claim)
 {
     static $ctr = 0;
     static $visits = array();
     static $practices = array();
     static $insurancePrograms = array();
     static $providers = array();
     static $patients = array();
     $claimId = (int) $claimId;
     $claimLine = new ClaimLine();
     $claimLine->populateByClaimId($claimId);
     $visitId = (int) $claimLine->visitId;
     if (!isset($visits[$visitId])) {
         $visit = new Visit();
         $visit->visitId = $visitId;
         $visit->populate();
         $visits[$visitId] = $visit;
     }
     $visit = $visits[$visitId];
     $patientId = (int) $visit->patientId;
     if (!isset($patients[$patientId])) {
         $patient = new Patient();
         $patient->personId = $patientId;
         $patient->populate();
         $patients[$patientId] = $patient;
     }
     $patient = $patients[$patientId];
     $practiceId = (int) $visit->practiceId;
     if (!isset($practices[$practiceId])) {
         $practice = new Practice();
         $practice->practiceId = $practiceId;
         $practice->populate();
         $practices[$practiceId] = $practice;
     }
     $practice = $practices[$practiceId];
     $insuranceProgramId = (int) $visit->activePayerId;
     if (!isset($insurancePrograms[$insuranceProgramId])) {
         $insurance = new InsuranceProgram();
         $insurance->insuranceProgramId = $insuranceProgramId;
         $insurance->populate();
         $insurancePrograms[$insuranceProgramId] = $insurance;
     }
     $insuranceProgram = $insurancePrograms[$insuranceProgramId];
     $providerId = (int) $visit->treatingPersonId;
     if (!isset($providers[$providerId])) {
         $provider = new Provider();
         $provider->personId = $providerId;
         $provider->populate();
         $providers[$providerId] = $provider;
     }
     $provider = $providers[$providerId];
     $billAs = (int) $provider->billAs;
     if ($billAs > 0) {
         $providerId = $billAs;
         if (!isset($providers[$providerId])) {
             $provider = new Provider();
             $provider->personId = $providerId;
             $provider->populate();
             $providers[$providerId] = $provider;
         }
         $provider = $providers[$providerId];
     }
     $subscribers = array();
     $enumeration = new Enumeration();
     $enumeration->populateByUniqueName(InsuranceProgram::INSURANCE_ENUM_NAME);
     $enumerationClosure = new EnumerationClosure();
     foreach ($enumerationClosure->getAllDescendants($enumeration->enumerationId, 1, true) as $enum) {
         $rowset = $enumerationClosure->getAllDescendants($enum->enumerationId, 1, true);
         if ($enum->key == InsuranceProgram::INSURANCE_SUBSCRIBER_ENUM_KEY) {
             foreach ($rowset as $row) {
                 $subscribers[$row->key] = $row->name;
             }
             break;
         }
     }
     $insuredRelationship = new InsuredRelationship();
     $db = Zend_Registry::get('dbAdapter');
     $sqlSelect = $db->select()->from($insuredRelationship->_table)->where('insurance_program_id = ?', (int) $insuranceProgram->insuranceProgramId)->where('person_id = ?', (int) $patientId)->where('active = 1')->order('program_order')->limit(1);
     if ($row = $db->fetchRow($sqlSelect)) {
         $insuredRelationship->populateWithArray($row);
     }
     $subs = $insuredRelationship->subscriber;
     $subscriberAddr = $subs->address;
     $relationship = null;
     $relationshipCode = $insuredRelationship->subscriberToPatientRelationship;
     if (isset($subscribers[$relationshipCode])) {
         $relationship = $subscribers[$relationshipCode];
     }
     if ($relationship === null) {
         $relationship = 'Self';
         $relationshipCode = 18;
         $subs = new Person();
         $subs->personId = $insuredRelationship->personId;
         $subs->populate();
     }
     $subscriber = array('id' => (int) $subs->personId, 'relationship_code' => $relationshipCode, 'group_number' => $insuredRelationship->groupNumber, 'group_name' => $insuredRelationship->groupName, 'relationship' => $relationship, 'last_name' => $subs->lastName, 'first_name' => $subs->firstName, 'middle_name' => $subs->middleName, 'address' => array('line1' => $subscriberAddr->line1, 'line2' => $subscriberAddr->line2, 'city' => $subscriberAddr->city, 'state' => $subscriberAddr->state, 'zip' => $subscriberAddr->zipCode), 'date_of_birth' => date('Ymd', strtotime($subs->dateOfBirth)), 'gender' => $subs->gender, 'contract_type_code' => '', 'contract_amount' => '', 'contract_percent' => '', 'contract_code' => '', 'contract_discount_percent' => '', 'contract_version' => '');
     $practiceAddr = $practice->primaryAddress;
     $room = new Room();
     $room->roomId = (int) $visit->roomId;
     $room->populate();
     $facility = $room->building;
     $phoneNumber = PhoneNumber::autoFixNumber($practice->mainPhone->number);
     $phoneLen = strlen($phoneNumber);
     if ($phoneLen < 10) {
         $phoneNumber = str_pad($phoneNumber, 10, '0', STR_PAD_LEFT);
     } else {
         if ($phoneLen > 10) {
             $phoneNumber = substr($phoneNumber, -10);
         }
     }
     $identifierType = '';
     $identifier = $practice->identifier;
     if (strlen($identifier) > 0) {
         $identifierType = 'XX';
     }
     //24';
     $data = array('hlCount' => ++$ctr);
     $data['practice'] = array('name' => $practice->name, 'identifier_type' => $identifierType, 'identifier' => $identifier, 'address' => array('line1' => $practiceAddr->line1, 'line2' => $practiceAddr->line2, 'city' => $practiceAddr->city, 'state' => $practiceAddr->state, 'zip' => $practiceAddr->zipCode), 'phoneNumber' => $phoneNumber);
     $data['treating_facility'] = array('identifier' => $facility->identifier);
     $dateOfTreatment = date('Ymd', strtotime($visit->dateOfTreatment));
     $payer2Id = $insuranceProgram->insuranceProgramId;
     if (strlen($payer2Id) < 2) {
         $payer2Id = str_pad($payer2Id, 2, '0', STR_PAD_LEFT);
     }
     $identifierType = '';
     $identifier = $provider->person->identifier;
     if (strlen($identifier) > 0) {
         $identifierType = 'XX';
     }
     //34';
     $claimData = array('claim' => $claim, 'patient' => array('date_of_initial_treatment' => $dateOfTreatment, 'date_of_onset' => $dateOfTreatment, 'comment_type' => '', 'comment' => ''), 'treating_facility' => array('facility_code' => $facility->facilityCodeId, 'name' => $facility->name, 'address' => array('line1' => $facility->line1, 'line2' => $facility->line2, 'city' => $facility->city, 'state' => $facility->state, 'zip' => $facility->zipCode)), 'provider' => array('signature_on_file' => 'Y', 'accepts_assignment' => 'A', 'last_name' => $provider->person->lastName, 'first_name' => $provider->person->firstName, 'identifier_type' => $identifierType, 'identifier' => $identifier, 'identifier_2' => ''), 'billing_facility' => array('clia_number' => ''), 'subscriber' => $subscriber, 'clearing_house' => array('credit_max_amount' => '', 'repricing_method' => '', 'allowed_amount' => '', 'savings_amount' => '', 'identifier' => '', 'rate' => '', 'apg_code' => '', 'apg_amount' => '', 'reject_code' => '', 'compliance_code' => '', 'exception_code' => ''), 'referring_provider' => array('last_name' => '', 'first_name' => '', 'referral_type' => '', 'identifier_type' => '', 'identifier' => '', 'taxonomy_code' => ''), 'supervising_provider' => array('last_name' => '', 'first_name' => '', 'identifier_type' => '', 'identifier' => ''), 'payer2' => array('id' => $payer2Id, 'name' => $insuranceProgram->name));
     $clm = array();
     $iterator = new ClaimLineIterator();
     $iterator->setFilters(array('claimId' => $claimId));
     foreach ($iterator as $row) {
         $baseFee = (double) $row->baseFee;
         $adjustedFee = (double) $row->adjustedFee;
         $paid = (double) $row->paid;
         $billed = $row->totalMiscCharge;
         if ($baseFee > 0) {
             $billed += $baseFee - $adjustedFee;
         }
         $balance = abs($billed) - $paid;
         $clm[] = array('claim' => $claimData['claim'], 'patient' => $claimData['patient'], 'claim_line' => array('amount' => $balance, 'diagnosis1' => preg_replace('/[\\.]/', '', $row->diagnosisCode1), 'diagnosis2' => preg_replace('/[\\.]/', '', $row->diagnosisCode2), 'diagnosis3' => preg_replace('/[\\.]/', '', $row->diagnosisCode3), 'diagnosis4' => preg_replace('/[\\.]/', '', $row->diagnosisCode4), 'diagnosis5' => preg_replace('/[\\.]/', '', $row->diagnosisCode5), 'diagnosis6' => preg_replace('/[\\.]/', '', $row->diagnosisCode6), 'diagnosis7' => preg_replace('/[\\.]/', '', $row->diagnosisCode7), 'diagnosis8' => preg_replace('/[\\.]/', '', $row->diagnosisCode8), 'procedure' => $row->procedureCode, 'modifier1' => $row->modifier1, 'modifier2' => $row->modifier2, 'modifier3' => $row->modifier3, 'modifier4' => $row->modifier4, 'units' => str_replace('.00', '', $row->units), 'date_of_treatment' => $dateOfTreatment, 'clia_number' => ''), 'treating_facility' => $claimData['treating_facility'], 'provider' => $claimData['provider'], 'billing_facility' => $claimData['billing_facility'], 'subscriber' => $subscriber, 'clearing_house' => $claimData['clearing_house'], 'referring_provider' => $claimData['referring_provider'], 'supervising_provider' => $claimData['supervising_provider'], 'payer2' => $claimData['payer2']);
     }
     $hl2 = array();
     $hl2[] = array('hlCount' => $ctr, 'hlCount2' => ++$ctr, 'payer' => array('responsibility' => 'P'), 'subscriber' => $subscriber, 'patient' => array('weight' => '', 'last_name' => $patient->lastName, 'first_name' => $patient->firstName), 'responsible_party' => array('last_name' => '', 'first_name' => '', 'address' => array('line1' => '', 'line2' => '', 'city' => '', 'state' => '', 'zip' => '')), 'CLM' => $clm);
     $data['HL2'] = $hl2;
     return $data;
 }
Esempio n. 15
0
 public function listModifiersAction()
 {
     $visitId = (int) $this->_getParam('visitId');
     $id = (int) $this->_getParam('id');
     $rows = array();
     if ($visitId > 0) {
         $visit = new Visit();
         $visit->visitId = $visitId;
         $visit->populate();
         $patientProcedure = new PatientProcedure();
         $patientProcedure->patientProcedureId = $id;
         $patientProcedure->populate();
         $modifiers = array();
         for ($i = 1; $i <= 4; $i++) {
             $field = 'modifier' . $i;
             $key = $patientProcedure->{$field};
             if (strlen($key) > 0) {
                 $modifiers[$key] = $key;
             }
         }
         $enabled = array();
         $disabled = array();
         $enumeration = new Enumeration();
         $enumeration->populateByUniqueName('Procedure Modifiers');
         $closure = new EnumerationClosure();
         $descendants = $closure->getAllDescendants($enumeration->enumerationId, 1, true);
         foreach ($descendants as $row) {
             $tmp = array();
             $tmp['id'] = $row->key;
             $tmp['data'] = array();
             $tmp['data'][] = isset($modifiers[$row->key]) ? '1' : '';
             $tmp['data'][] = $row->key . ': ' . $row->name;
             if ($tmp['data'][0] == '1') {
                 $enabled[$modifiers[$row->key]] = $tmp;
             } else {
                 $disabled[] = $tmp;
             }
         }
         $tmp = $enabled;
         $enabled = array();
         foreach ($modifiers as $modifier) {
             $enabled[] = $tmp[$modifier];
         }
         $rows = array_merge($enabled, $disabled);
     }
     $data = array();
     $data['rows'] = $rows;
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct($data);
 }
Esempio n. 16
0
 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;
 }
Esempio n. 17
0
 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;
 }
Esempio n. 18
0
 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;
 }
Esempio n. 19
0
 public static function patient($personId)
 {
     $newPatient = true;
     $db = Zend_Registry::get('dbAdapter');
     $sqlSelect = $db->select()->from('audits', 'COUNT(*) AS ctr')->where("objectClass = 'Patient' AND objectId = ?", (int) $personId);
     if (($row = $db->fetchRow($sqlSelect)) && $row['ctr'] > 1) {
         $newPatient = false;
     }
     $data = self::_getPatientData($personId);
     $subscribersEnum = array();
     $enumeration = new Enumeration();
     $enumeration->populateByUniqueName(InsuranceProgram::INSURANCE_ENUM_NAME);
     $enumerationClosure = new EnumerationClosure();
     foreach ($enumerationClosure->getAllDescendants($enumeration->enumerationId, 1, true) as $enum) {
         $rowset = $enumerationClosure->getAllDescendants($enum->enumerationId, 1, true);
         if ($enum->key != InsuranceProgram::INSURANCE_SUBSCRIBER_ENUM_KEY) {
             continue;
         }
         foreach ($rowset as $row) {
             $subscribersEnum[$row->key] = $row->name;
         }
     }
     $insuredRelationship = new InsuredRelationship();
     $sqlSelect = $db->select()->from($insuredRelationship->_table)->where('person_id = ?', $personId)->where('active = 1')->order('program_order');
     $insuredRelationshipIterator = $insuredRelationship->getIterator($sqlSelect);
     $subscribers = array();
     $insurances = array();
     $guarantors = array();
     foreach ($insuredRelationshipIterator as $item) {
         $subscriberId = (int) $item->subscriberId;
         $subscriberToPatientRelationship = $item->subscriberToPatientRelationship;
         if (!$subscriberId > 0) {
             $subscriberId = $personId;
             $subscriberToPatientRelationship = 'SELF';
         }
         if (isset($subscribersEnum[$subscriberToPatientRelationship])) {
             $subscriberToPatientRelationship = $subscribersEnum[$subscriberToPatientRelationship];
         }
         if (!isset($subscribers[$subscriberId])) {
             $patient = new Patient();
             $patient->personId = $subscriberId;
             $patient->populate();
             $subscribers[$subscriberId] = $patient;
         }
         $subscriber = self::_getPatientData($subscribers[$subscriberId], false);
         $subscriber['relation'] = strtoupper(substr($subscriberToPatientRelationship, 0, 1));
         $insuranceProgram = $item->insuranceProgram;
         $companyId = (int) $insuranceProgram->companyId;
         $phoneNumber = new PhoneNumber();
         $sqlSelect = $db->select()->from(array('cn' => 'company_number'))->join(array('n' => 'number'), 'n.number_id = cn.number_id')->where('n.active = 1')->where('cn.company_id = ?', $companyId)->order('n.displayOrder')->limit(1);
         $phoneNumber->populateWithSql($sqlSelect->__toString());
         $insurance = array();
         $insurance['companyId'] = $companyId;
         $insurance['companyName'] = $insuranceProgram->company->name;
         $address = $insuranceProgram->address;
         $insurance['line1'] = $address->line1;
         $insurance['line2'] = $address->line2;
         $insurance['city'] = $address->city;
         $insurance['state'] = $address->state;
         $insurance['zip'] = $address->postalCode;
         $insurance['phoneNumber'] = $phoneNumber->number;
         $insurance['groupNumber'] = $item->groupName;
         $insurance['groupName'] = '';
         $insurance['policyNumber'] = $item->groupNumber;
         //$insurance['ssn'] = $insuranceProgram->payerIdentifier;
         $insurances[] = array('subscriber' => $subscriber, 'insurance' => $insurance);
         $guarantors[] = $subscriber;
     }
     $adt = $newPatient ? 'A04' : 'A08';
     $t = microtime();
     $x = explode(' ', $t);
     $date = date('YmdHis', $x[1]);
     $messageId = $date . str_replace('.', '0', $x[0]);
     $id = 0;
     $hl7Guarantors = array();
     foreach ($guarantors as $key => $guarantor) {
         $ctr = $key + 1;
         $hl7Guarantors[] = "GT1|{$ctr}|{$guarantor['recordNumber']}|{$guarantor['lastName']}^{$guarantor['firstName']}^{$guarantor['middleName']}^{$guarantor['suffix']}^^||{$guarantor['line1']}^{$guarantor['line2']}^{$guarantor['city']}^{$guarantor['state']}^{$guarantor['zip']}|{$guarantor['homePhone']}|{$guarantor['businessPhone']}|{$guarantor['dateOfBirth']}|{$guarantor['gender']}||S|{$guarantor['ssn']}|";
     }
     $hl7Insurances = array();
     foreach ($insurances as $key => $value) {
         $ctr = $key + 1;
         $subscriber = $value['subscriber'];
         $insurance = $value['insurance'];
         $hl7Insurances[] = "IN1|{$ctr}|{$insurance['companyId']}^{$insurance['companyName']}|{$insurance['companyId']}|{$insurance['companyName']}|{$insurance['line1']}^{$insurance['line2']}^{$insurance['city']}^{$insurance['state']}^{$insurance['zip']}||{$insurance['phoneNumber']}|{$insurance['groupNumber']}|{$insurance['groupName']}|||||||{$subscriber['lastName']}^{$subscriber['firstName']}^{$subscriber['middleName']}^{$subscriber['suffix']}^^|{$subscriber['relation']}|{$subscriber['dateOfBirth']}|{$subscriber['line1']}^{$subscriber['line2']}^{$subscriber['city']}^{$subscriber['state']}^{$subscriber['zip']}|Y||{$ctr}||||||||||||||{$insurance['policyNumber']}|0||||||{$subscriber['gender']}||||||{$subscriber['ssn']}|";
         if (!strlen($subscriber['ssn']) > 0) {
             continue;
         }
         $hl7Insurances[] = "IN2|{$ctr}|{$subscriber['ssn']}";
     }
     $patient = $data['patient'];
     $provider = $data['provider'];
     $hl7Message = array();
     $hl7Message[] = "MSH|^~\\&|MedMgr|989801|aroeshl7_prod|HEST|{$date}||ADT^{$adt}|{$messageId}|P|2.3|{$id}|";
     $hl7Message[] = "EVN|{$adt}|{$date}|||38|";
     $hl7Message[] = self::_PID($patient);
     $hl7Message[] = self::_PV1($provider);
     foreach ($hl7Guarantors as $hl7Guarantor) {
         $hl7Message[] = $hl7Guarantor;
     }
     foreach ($hl7Insurances as $hl7Insurance) {
         $hl7Message[] = $hl7Insurance;
     }
     $separator = "\r\n";
     return implode($separator, $hl7Message);
 }
Esempio n. 20
0
 public function editInsurerAction()
 {
     $patientId = (int) $this->_getParam('patientId');
     $id = (int) $this->_getParam('id');
     $insurer = new InsuredRelationship();
     $insurer->personId = $patientId;
     $time = time();
     $insurer->effectiveStart = date('Y-m-d', $time);
     $insurer->effectiveEnd = date('Y-m-d', strtotime('+1 year', $time));
     if ($id > 0) {
         $insurer->insuredRelationshipId = $id;
         $insurer->populate();
     }
     $this->view->subscriber = $insurer->subscriber;
     $this->view->subscriberPhone = $insurer->subscriber->phoneNumber;
     $this->view->subscriberAddress = $insurer->subscriber->address;
     $this->_form = new WebVista_Form(array('name' => 'edit-insurer'));
     $this->_form->setAction(Zend_Registry::get('baseUrl') . 'patient.raw/process-edit-insurer');
     $this->_form->loadORM($insurer, 'Insurer');
     $this->_form->setWindow('winEditInsurerId');
     $this->view->form = $this->_form;
     $insuranceProgram = new InsuranceProgram();
     $insurancePrograms = array('' => '');
     foreach (InsuranceProgram::getInsurancePrograms() as $id => $val) {
         $insurancePrograms[$id] = $val;
     }
     $this->view->insurancePrograms = $insurancePrograms;
     $assignings = array();
     $subscribers = array();
     $enumeration = new Enumeration();
     $enumeration->populateByUniqueName(InsuranceProgram::INSURANCE_ENUM_NAME);
     $enumerationClosure = new EnumerationClosure();
     foreach ($enumerationClosure->getAllDescendants($enumeration->enumerationId, 1, true) as $enum) {
         $rowset = $enumerationClosure->getAllDescendants($enum->enumerationId, 1, true);
         if ($enum->key == InsuranceProgram::INSURANCE_ASSIGNING_ENUM_KEY) {
             foreach ($rowset as $row) {
                 $assignings[$row->key] = $row->name;
             }
         } else {
             if ($enum->key == InsuranceProgram::INSURANCE_SUBSCRIBER_ENUM_KEY) {
                 foreach ($rowset as $row) {
                     $subscribers[$row->key] = $row->name;
                 }
             }
         }
     }
     $this->view->assignings = $assignings;
     $this->view->subscribers = $subscribers;
     $this->view->listVerified = InsuredRelationship::getVerifiedOptions();
     $this->render('edit-insurer');
 }