public function xmlAction() { $personId = (int) $this->_getParam('personId'); $visitId = (int) $this->_getParam('visitId'); $providerId = (int) Zend_Auth::getInstance()->getIdentity()->personId; $auditType = GenericAccessAudit::CCD_ALL_XML; $filename = 'ccd-' . $personId; $visit = new Visit(); $visit->visitId = $visitId; if ($visitId > 0 && $visit->populate()) { $filename .= '-visit-' . $visitId; $auditType = GenericAccessAudit::CCD_VISIT_XML; } $this->_createAudit($providerId, $personId, $visitId, $auditType); $ccd = new CCD(); $contents = $ccd->populate($personId, $providerId, $visitId); $this->getResponse()->setHeader('Content-Type', 'text/xml'); $this->getResponse()->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '.xml"'); $this->view->contents = $contents; $this->render(); }
public function populate($patientId, $userId, $visitId) { $this->_patientId = (int) $patientId; $patient = new Patient(); $patient->personId = $this->_patientId; $patient->populate(); $this->_title = $patient->displayName . ' Healthcare Record'; $this->patient = $patient; $this->_userId = (int) $userId; $user = new User(); $user->personId = $this->_userId; $user->populate(); $this->user = $user; $visit = new Visit(); $visit->visitId = (int) $visitId; if ($visit->visitId > 0 && $visit->populate()) { $this->visit = $visit; } $this->building = Building::getBuildingDefaultLocation($this->user->personId); $performers = array(); $problemList = new ProblemList(); $filters = array(); $filters['personId'] = $this->_patientId; $this->setFiltersDateRange($filters); $problems = array(); $problemListIterator = new ProblemListIterator(); $problemListIterator->setFilters($filters); foreach ($problemListIterator as $problem) { $problems[] = $problem; $providerId = (int) $problem->providerId; if (!isset($performers[$providerId])) { $provider = new Provider(); $provider->personId = $providerId; $provider->populate(); $performers[$providerId] = $provider; } } $this->problemLists = $problems; unset($filters['personId']); $filters['patientId'] = $this->_patientId; $labResults = array(); $labTests = array(); $labOrderTests = array(); $labsIterator = new LabsIterator(); $labsIterator->setFilters($filters); foreach ($labsIterator as $lab) { // get the lab order $labTestId = (int) $lab->labTestId; if (!isset($labTests[$labTestId])) { $labTest = new LabTest(); $labTest->labTestId = (int) $lab->labTestId; $labTest->populate(); $labTests[$labTestId] = $labTest; } $labTest = $labTests[$labTestId]; $orderId = (int) $labTest->labOrderId; if (!isset($labOrderTests[$orderId])) { $orderLabTest = new OrderLabTest(); $orderLabTest->orderId = $orderId; $orderLabTest->populate(); $labOrderTests[$orderId] = $orderLabTest; } $orderLabTest = $labOrderTests[$orderId]; $providerId = (int) $orderLabTest->order->providerId; if (!isset($performers[$providerId])) { $provider = new Provider(); $provider->personId = $providerId; $provider->populate(); $performers[$providerId] = $provider; } if (!isset($labResults[$orderId])) { $labResults[$orderId] = array(); $labResults[$orderId]['results'] = array(); $labResults[$orderId]['labTest'] = $labTest; $labResults[$orderId]['orderLabTest'] = $orderLabTest; } $labResults[$orderId]['results'][] = $lab; } $this->labResults = $labResults; $this->performers = $performers; $this->populateHeader($this->_xml); $this->populateBody($this->_xml); return $this->_xml->asXML(); }
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; }
protected function _processSetVisit($closed = null, $void = null) { $visitParams = $this->_getParam('visit'); $visitParams['lastChangeUserId'] = (int) Zend_Auth::getInstance()->getIdentity()->personId; //$visitParams['timestamp'] = date('Y-m-d h:i:s'); if ($closed !== null) { $visitParams['closed'] = (int) $closed; } $visit = new Visit(); $visit->visitId = (int) $visitParams['visitId']; $data = 'Visit ID ' . $visit->visitId . ' is invalid'; if ($visit->populate()) { if ($void !== null) { $visit->void = (int) $void; if ($visit->void && $visit->hasPayments()) { $error = 'Cannot void visit with payments'; } } else { $visit->populateWithArray($visitParams); } if (isset($error)) { $data = $error; } else { $visit->persist(); $data = $this->_generateVisitRowData($visit); } } $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct($data); }
public function getVisitInfoAction() { $visitId = (int) $this->_getParam('visitId'); $visit = new Visit(); $visit->visitId = $visitId; $visit->populate(); $practice = new Practice(); $practice->practiceId = $visit->practiceId; $practice->populate(); $data = array(); $data['currentPractice'] = $practice->name . ''; $data['selectedVisit'] = substr($visit->dateOfTreatment, 0, 10) . ''; $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct($data); }
public function listPatientAccountDetailsAction() { $visitId = (int) $this->_getParam('visitId'); $visit = new Visit(); $visit->visitId = $visitId; $visit->populate(); $facility = $visit->facility; // Facility $providerDisplayName = $visit->providerDisplayName; // Provider $summary = $visit->accountDetails; $rows = array(); foreach ($summary['claimFiles']['details'] as $data) { $claimFile = $data['claimFile']; $visit = $data['visit']; $claimFileId = (int) $claimFile->claimFileId; $row = array(); $row['id'] = $visitId; $row['data'] = array(); $row['data'][] = $claimFileId; // Id $row['data'][] = InsuranceProgram::getInsuranceProgram($claimFile->payerId); // Payer Name $row['data'][] = substr($claimFile->dateBilled, 0, 10); // Date Billed $row['data'][] = substr($claimFile->dateTime, 0, 10); // Date $row['data'][] = '$' . $claimFile->billed; // Billed $row['data'][] = '$' . $claimFile->paid; // Paid $row['data'][] = '$' . $claimFile->writeOff; // Write Off $row['data'][] = '$' . $claimFile->balance; // Balance $row['data'][] = ''; // Chk # $row['data'][] = $facility; // Facility $row['data'][] = $providerDisplayName; // Provider $row['data'][] = $claimFile->enteredBy; // Entered By if (!isset($rows[$id])) { $rows[$id] = array(); } $rows[$id][] = $row; } $ctr = 0; // charges foreach ($summary['charges']['details'] as $row) { $amount = (double) $row->baseFee; $id = $row->visitId; if (!isset($rows[$id])) { $rows[$id] = array(); } $rows[$id]['info'][] = array('amount' => $amount, 'type' => 'debit'); $rows[$id][] = array('id' => $id . '-' . $ctr++, 'data' => array('Charge', InsuranceProgram::getInsuranceProgram($row->insuranceProgramId), substr($row->dateTime, 0, 10), '', '$' . $amount, '', '', '', '', $facility, $providerDisplayName, $row->enteredBy)); } // misc charges foreach ($summary['miscCharges']['details'] as $row) { $amount = (double) $row->amount; $id = $row->miscChargeId; if (!isset($rows[$id])) { $rows[$id] = array(); } $rows[$id]['info'][] = array('amount' => $amount, 'type' => 'debit'); $rows[$id][] = array('id' => $id, 'data' => array('Misc Charge', '', substr($row->chargeDate, 0, 10), '', '$' . $amount, '', '', '', '', $facility, $providerDisplayName, $row->enteredBy)); } // payments foreach ($summary['payments']['details'] as $row) { if ($row instanceof PostingJournal) { $amount = (double) $row->amount; $id = $row->postingJournalId; $datePosted = $row->datePosted; $refNum = $row->payment->refNum; } else { $amount = (double) $row->unallocated; $id = $row->paymentId; $datePosted = $row->paymentDate; $refNum = $row->refNum; } if (!isset($rows[$id])) { $rows[$id] = array(); } $rows[$id]['info'][] = array('amount' => $amount, 'type' => 'credit'); $rows[$id][] = array('id' => $id, 'data' => array('Payment', InsuranceProgram::getInsuranceProgram($row->payerId), '', substr($datePosted, 0, 10), '', '$' . $amount, '', '', $refNum, $facility, $providerDisplayName, $row->enteredBy)); } // writeoffs foreach ($summary['writeOffs']['details'] as $row) { $amount = (double) $row->amount; $id = $row->writeOffId; if (!isset($rows[$id])) { $rows[$id] = array(); } $rows[$id]['info'][] = array('amount' => $amount, 'type' => 'credit'); $rows[$id][] = array('id' => $id, 'data' => array('Write Off', InsuranceProgram::getInsuranceProgram($row->payerId), '', substr($row->timestamp, 0, 10), '', '', '$' . $amount, '', '', $facility, $providerDisplayName, $row->enteredBy)); } ksort($rows); $data = array('rows' => array()); $balance = 0; foreach ($rows as $values) { $info = $values['info']; unset($values['info']); foreach ($values as $key => $value) { $amount = $info[$key]['amount']; if ($info[$key]['type'] == 'debit') { $balance += $amount; } else { $balance -= $amount; } $value['data'][7] = '$' . abs($balance); $data['rows'][] = $value; } } $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct($data); }
public function paymentReceiptAction() { // d96de46c-be90-45b0-b5f9-0b4abee76483 $referenceId = $this->_getParam('referenceId'); $personId = (int) $this->_getParam('personId'); $visitId = (int) $this->_getParam('visitId'); $data = $this->_getAttachmentData($referenceId); $patient = new Patient(); $patient->personId = $personId; if ($personId > 0) { $patient->populate(); } $person = $patient->person; $visit = new Visit(); $visit->visitId = $visitId; if ($visitId > 0) { $visit->populate(); } $practiceId = (int) $visit->practiceId; if (!$practiceId > 0) { $buildingId = (int) $visit->buildingId; if ($buildingId > 0) { $building = new Building(); $building->buildingId = $buildingId; $building->populate(); $practiceId = (int) $building->practiceId; } else { $roomId = (int) $visit->roomId; if ($roomId > 0) { $room = new Room(); $room->roomId = $roomId; $room->populate(); $practiceId = (int) $room->building->practiceId; } } } $practice = new Practice(); $practice->practiceId = $practiceId; if ($practiceId > 0) { $practice->populate(); } $primaryAddress = $practice->primaryAddress; $xml = new SimpleXMLElement('<data/>'); $xmlPractice = $xml->addChild('practice'); $this->_addChild($xmlPractice, 'name', $practice->name); $this->_addChild($xmlPractice, 'primaryLine1', $primaryAddress->line1); $primaryCityStateZip = $primaryAddress->city . ' ' . $primaryAddress->state . ' ' . $primaryAddress->postalCode; $this->_addChild($xmlPractice, 'primaryCityStateZip', $primaryCityStateZip); $this->_addChild($xmlPractice, 'mainPhone', $practice->mainPhone->number); $xmlPatient = $xml->addChild('patient'); $name = $person->firstName . ' ' . $person->middleName . ' ' . $person->lastName; $this->_addChild($xmlPatient, 'name', $name); $addresses = Address::listAddresses($personId); if (isset($addresses[Address::TYPE_BILLING])) { $address = $addresses[Address::TYPE_BILLING]; } else { if (isset($addresses[Address::TYPE_HOME])) { $address = $addresses[Address::TYPE_HOME]; } else { if (isset($addresses[Address::TYPE_MAIN])) { $address = $addresses[Address::TYPE_MAIN]; } else { if (isset($addresses[Address::TYPE_SEC])) { $address = $addresses[Address::TYPE_SEC]; } else { if (isset($addresses[Address::TYPE_OTHER])) { $address = $addresses[Address::TYPE_OTHER]; } else { $address = array_pop($addresses); } } } } } $billingCityStateZip = $address->city . ' ' . $address->state . ' ' . $address->postalCode; $this->_addChild($xmlPatient, 'billingLine1', $address->line1); $this->_addChild($xmlPatient, 'billingCityStateZip', $billingCityStateZip); $iterator = new PatientProcedureIterator(); $iterator->setFilters(array('visitId' => $visitId)); $procedures = array(); foreach ($iterator as $row) { $procedures[] = $row->code; } $iterator = new PatientDiagnosisIterator(); $iterator->setFilters(array('visitId' => $visitId)); $diagnoses = array(); foreach ($iterator as $row) { $diagnoses[] = $row->code; } $xmlNotes = $xmlPatient->addChild('notes'); $note = implode(',', $procedures) . " \t " . implode(',', $diagnoses) . " \t " . date('m/d/y', strtotime($visit->dateOfTreatment)); $this->_addChild($xmlNotes, 'note', $note); $today = date('Y-m-d'); $todaysTotal = 0; $iterator = new PaymentIterator(); $iterator->setFilters(array('visitId' => $visitId, 'company' => 'System', 'paymentDate' => $today)); $payments = array(); foreach ($iterator as $row) { $payments[] = $row; } $iterator->setFilters(array('personId' => $personId, 'unallocated' => true, 'paymentDate' => $today)); foreach ($iterator as $row) { $payments[] = $row; } foreach ($payments as $row) { $xmlPayment = $xmlPatient->addChild('payments'); $paymentDate = date('m/d/y', strtotime($row->paymentDate)); $this->_addChild($xmlPayment, 'date', $paymentDate); $this->_addChild($xmlPayment, 'description', $row->title . ' .... Thank You'); $this->_addChild($xmlPayment, 'method', $row->paymentType); $amount = (double) $row->amount; $todaysTotal += $amount; $this->_addChild($xmlPayment, 'amount', '-' . number_format($amount, 2)); $this->_addChild($xmlPayment, 'insurance', $row->insuranceDisplay); } $fees = $visit->calculateFees(); $previousBalance = $fees['total']; $this->_addChild($xmlPatient, 'previousBalance', number_format($previousBalance, 2)); $this->_addChild($xmlPatient, 'todaysTotal', '-' . number_format($todaysTotal, 2)); $totalDue = $previousBalance - $todaysTotal; $this->_addChild($xmlPatient, 'totalDue', number_format($totalDue, 2)); $totalDueFromPatient = $previousBalance; $this->_addChild($xmlPatient, 'totalDueFromPatient', number_format($totalDueFromPatient, 2)); try { $content = ReportBase::mergepdfset($xml, $data); $this->getResponse()->setHeader('Content-Type', 'application/pdf'); } catch (Exception $e) { $content = '<script>alert("' . $e->getMessage() . '")</script>'; } $this->view->content = $content; $this->render('binary-template'); }
public function populateWithPatientProcedure(PatientProcedure $patientProcedure, Visit $visit = null) { $db = Zend_Registry::get('dbAdapter'); $visitId = $patientProcedure->visitId; if ($visit === null) { $visit = new Visit(); $visit->visitId = $visitId; $visit->populate(); } $this->visitId = $visitId; $this->procedureCode = $patientProcedure->code; // populate with the latest claim line $sqlSelect = $db->select()->from($this->_table)->where('visitId = ?', $visitId)->where('procedureCode = ?', $this->procedureCode)->order('claimId DESC')->limit(1); $this->populateWithSql($sqlSelect->__tostring()); $this->insuranceProgramId = (int) $visit->activePayerId; $this->units = $patientProcedure->quantity; $this->diagnosisCode1 = $patientProcedure->diagnosisCode1; $this->diagnosisCode2 = $patientProcedure->diagnosisCode2; $this->diagnosisCode3 = $patientProcedure->diagnosisCode3; $this->diagnosisCode4 = $patientProcedure->diagnosisCode4; $this->diagnosisCode5 = $patientProcedure->diagnosisCode5; $this->diagnosisCode6 = $patientProcedure->diagnosisCode6; $this->diagnosisCode7 = $patientProcedure->diagnosisCode7; $this->diagnosisCode8 = $patientProcedure->diagnosisCode8; $this->modifier1 = $patientProcedure->modifier1; $this->modifier2 = $patientProcedure->modifier2; $this->modifier3 = $patientProcedure->modifier3; $this->modifier4 = $patientProcedure->modifier4; }
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 checkRulesAction() { $visitId = (int) $this->_getParam('visitId'); $data = array(); $visit = new Visit(); $visit->visitId = $visitId; if ($visitId > 0 && $visit->populate()) { $retVisit = ClaimRule::checkRules($visit); $data = $retVisit->_claimRule; } $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct($data); }