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; }
public function listAction() { $rows = array(); $guid = '8e6a2456-1710-46be-a018-2afb0ec2829f'; $enumeration = new Enumeration(); $enumeration->populateByGuid($guid); $closure = new EnumerationClosure(); $enumerationIterator = $closure->getAllDescendants($enumeration->enumerationId, 1, true); foreach ($enumerationIterator as $enum) { $row = array(); $row['id'] = $enum->enumerationId; $row['data'] = array(); $row['data'][] = $enum->name; $rows[] = $row; } $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct(array('rows' => $rows), true); }
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 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 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(); }
public function editBuildingAction() { $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 Building(); if ($id > 0) { $orm->buildingId = $id; $orm->populate(); } $orm->practiceId = $enumeration->ormId; $form = new WebVista_Form(array('name' => 'edit-building')); $form->setAction(Zend_Registry::get('baseUrl') . 'facilities.raw/process-edit-building'); $form->loadORM($orm, 'Building'); $form->setWindow('windowEditBuildingId'); $this->view->form = $form; $this->view->enumerationId = $enumerationId; $this->view->statesList = Address::getStatesList(); $enumeration = new Enumeration(); $enumeration->guid = '22fb4e1e-a37a-4e7a-9dae-8e220ba939e8'; $enumeration->populateByGuid(); $enumerationClosure = new EnumerationClosure(); $descendants = $enumerationClosure->getAllDescendants($enumeration->enumerationId, 1, true); $facilityCodes = array('' => ''); foreach ($descendants as $descendant) { $facilityCodes[$descendant->key] = $descendant->key . ' : ' . $descendant->name; } $this->view->facilityCodes = $facilityCodes; $this->render('edit-building'); }
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); }
protected function _populateTypes() { $this->_populateLabTests(); if ($this->_types !== null) { return; } $this->_types = array(); $enumerationClosure = new EnumerationClosure(); foreach ($this->_labTests as $key => $value) { if ($key != OrderLabTest::LAB_TYPES_ENUM_KEY) { continue; } foreach ($enumerationClosure->getAllDescendants($value->enumerationId, 1) as $enum) { $this->_types[$enum->key] = $enum; } break; } }
public function listModifiersAction() { $guid = $this->_getParam('guid'); $code = $this->_getParam('code'); $fs = new FeeSchedule(); $fs->guid = $guid; $fs->procedureCode = $code; $fs->populateByGuidCode(); // ab377de7-8ea7-4912-a27b-2f9749499204 = coding preferences, 9eb793f8-1d5d-4ed5-959d-1e238361e00a = visit type section $enumeration = new Enumeration(); $enumeration->guid = '2b15d494-dce4-4d27-89b5-ddd6f6fc1439'; $enumeration->populateByGuid(); $closure = new EnumerationClosure(); $descendants = $closure->getAllDescendants($enumeration->enumerationId, 1, true); $rows = array(); foreach ($descendants as $enum) { $mod = ''; $fee = ''; switch ($enum->key) { case $fs->modifier1: $fee = $fs->modifier1fee; break; case $fs->modifier2: $fee = $fs->modifier2fee; break; case $fs->modifier3: $fee = $fs->modifier3fee; break; case $fs->modifier4: $fee = $fs->modifier4fee; break; } if ($fee != '') { $mod = '1'; } else { $fee = '0.00'; } $row = array(); $row['id'] = $enum->key; $row['data'] = array(); $row['data'][] = $mod; $row['data'][] = $enum->key . ': ' . $enum->name; $row['data'][] = $fee; $rows[] = $row; } $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct(array('rows' => $rows)); }
public function paymentAction() { $personId = (int) $this->_getParam('personId'); $payment = new Payment(); $payment->personId = $personId; $form = new WebVista_Form(array('name' => 'paymentId')); $form->setAction(Zend_Registry::get('baseUrl') . 'accounts.raw/process-payment'); $form->loadORM($payment, 'Payment'); $form->setWindow('windowUnallocPayment'); $this->view->form = $form; $guid = 'd1d9039a-a21b-4dfb-b6fa-ec5f41331682'; $enumeration = new Enumeration(); $enumeration->populateByGuid($guid); $closure = new EnumerationClosure(); $this->view->paymentTypes = $closure->getAllDescendants($enumeration->enumerationId, 1, true)->toArray('key', 'name'); $this->render(); }
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; }
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); }
protected function _applyTransforms(array $transforms, $data) { $ret = $data; if (!$transforms) { return $ret; } foreach ($transforms as $id => $transform) { // id, displayName, systemName, options $options = array(); if (isset($transform->options)) { $options = $transform->options; } switch ($transform->systemName) { case 'ucase': $ret = strtoupper($ret); break; case 'lcase': $ret = strtolower($ret); break; case 'ucwords': $ret = ucwords($ret); break; case 'squote': $ret = "'" . $ret . "'"; break; case 'dquote': $ret = '"' . $ret . '"'; break; case 'pad': $ret = str_pad($ret, $options['len'], $options['char'], $options['type']); break; case 'truncate': $ret = substr($ret, 0, $options['len']); break; case 'customLink': $href = str_replace('{{value}}', $ret, $options['href']); $ret = '<a href="' . $href . '" onclick="' . $options['onclick'] . '" target="_blank">' . $ret . '</a>'; break; case 'regex': $ret = preg_replace('/' . $options['pattern'] . '/', $options['replacement'], $ret); break; case 'enumLookup': $enumKey = $options['enumKey']; $enumValue = $options['enumValue']; $direction = $options['direction']; $enumeration = new Enumeration(); $enumeration->enumerationId = (int) $enumKey; $enumeration->populate(); $enumerationClosure = new EnumerationClosure(); $descendants = $enumerationClosure->getAllDescendants($enumeration->enumerationId, 1); // get the first level descendants foreach ($descendants as $descendant) { if ($direction == 'displayName' && ($descendant->enumerationId == $ret || $descendant->key == $ret)) { $ret = $descendant->name; break; } else { if ($direction == 'key' && $descendant->name == $ret) { $ret = $descendant->key; break; } } } break; case 'dateFormat': $ret = date($options['format'], strtotime($ret)); break; case 'total': break; } } return $ret; }
public function addPaymentAction() { $columnId = -1; $appointmentId = (int) $this->_getParam('appointmentId'); $visitId = (int) $this->_getParam('visitId'); $appointment = new Appointment(); $appointment->appointmentId = $appointmentId; $appointment->populate(); $payment = new Payment(); $payment->visitId = $visitId; $payment->personId = (int) $appointment->patientId; $payment->appointmentId = $appointmentId; if (!$visitId > 0) { $columnId = (int) $this->_getParam('columnId'); } $form = new WebVista_Form(array('name' => 'paymentId')); $form->setAction(Zend_Registry::get('baseUrl') . 'appointment.raw/process-add-payment'); $form->loadORM($payment, 'Payment'); $form->setWindow('winPaymentId'); $this->view->form = $form; $this->view->visitId = $visitId; $guid = 'd1d9039a-a21b-4dfb-b6fa-ec5f41331682'; $enumeration = new Enumeration(); $enumeration->populateByGuid($guid); $closure = new EnumerationClosure(); $this->view->paymentTypes = $closure->getAllDescendants($enumeration->enumerationId, 1, true)->toArray('key', 'name'); $this->view->columnId = $columnId; $this->render('add-payment'); }
public function processAddVisitTypesAction() { $personId = (int) $this->_getParam('personId'); $visitId = (int) $this->_getParam('visitId'); $id = (int) $this->_getParam('id'); $ret = false; $closure = new EnumerationClosure(); $diagnoses = array(); $procedures = array(); foreach ($closure->getAllDescendants($id, 1, true) as $enum) { switch ($enum->ormClass) { case 'DiagnosisCodesICD': $diagnoses[] = $enum; break; case 'ProcedureCodesCPT': $procedures[] = $enum; break; } } $providerId = (int) Zend_Auth::getInstance()->getIdentity()->personId; foreach ($procedures as $procedure) { $patientProcedure = new PatientProcedure(); $patientProcedure->code = $procedure->key; $patientProcedure->quantity = 1; // default to 1 $patientProcedure->procedure = $procedure->name; $patientProcedure->patientId = $personId; $patientProcedure->providerId = $providerId; $patientProcedure->visitId = $visitId; $diagCtr = 1; foreach ($diagnoses as $diagnosis) { $key = $diagnosis->key; $patientDiagnosis = new PatientDiagnosis(); $patientDiagnosis->code = $key; $patientDiagnosis->dateTime = date('Y-m-d H:i:s'); $patientDiagnosis->diagnosis = $diagnosis->name; $patientDiagnosis->patientId = $personId; $patientDiagnosis->providerId = $providerId; $patientDiagnosis->visitId = $visitId; $patientDiagnosis->persist(); $diag = 'diagnosisCode' . $diagCtr++; $patientProcedure->{$diag} = $key; } $patientProcedure->persist(); $ret = true; } $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct($ret); }
public function listSectionAction() { $rows = array(); $diagnosis = (int) $this->_getParam('diagnosis'); $closure = new EnumerationClosure(); foreach ($closure->getAllDescendants($diagnosis, 1, true) as $enum) { $row['id'] = $enum->key; $row['data'] = array(); $row['data'][] = ''; $row['data'][] = $enum->name; $row['data'][] = $enum->key; $rows[] = $row; } $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct(array('rows' => $rows), true); }
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'); }