public function listRulesAction() { $groupId = (int) $this->_getParam('groupId'); $rows = array(); $iterator = new ClaimRuleIterator(); $iterator->setFilters(array('groupId' => $groupId)); foreach ($iterator as $claimRule) { $row = array(); $row['id'] = $claimRule->claimRuleId; $row['data'] = array(); $row['data'][] = ''; $row['data'][] = ''; $row['data'][] = ''; $row['data'][] = ''; $row['userdata']['type'] = $claimRule->type; $row['userdata']['operator'] = $claimRule->operator; $row['userdata']['code'] = $claimRule->code; $row['userdata']['value'] = $claimRule->value; $row['userdata']['operand'] = $claimRule->operand; $rows[] = $row; } $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct(array('rows' => $rows)); }
public static function checkRules(Visit $visit, array $fees = array()) { if (!isset($fees['details'])) { $fees = $visit->calculateFees(true); } $visitId = (int) $visit->visitId; $payerId = (int) $visit->activePayerId; $procedures = null; $iterator = new ClaimRuleIterator(); foreach (self::listGroups() as $groupId => $values) { // TODO: use operators $matched = false; $iterator->setFilters(array('groupId' => $groupId)); foreach ($iterator as $claimRule) { $type = $claimRule->type; switch ($type) { case self::TYPE_PROCEDURE: case self::TYPE_DIAGNOSIS: if ($procedures === null) { $procedures = array(); $patientProcedureIterator = new PatientProcedureIterator(); $patientProcedureIterator->setFilters(array('visitId' => $visitId)); foreach ($patientProcedureIterator as $patientProcedure) { $procedures[] = $patientProcedure; } } $code = $claimRule->code; foreach ($procedures as $procedure) { if ($type == self::TYPE_PROCEDURE) { if ($procedure->code == $code) { $matched = true; break; } } else { for ($i = 1; $i <= 8; $i++) { $key = 'diagnosisCode' . $i; if ($procedure->{$key} == $code) { $matched = true; break 2; } } } } break; case self::TYPE_INSURANCE_PROGRAM: if ($claimRule->value == $payerId) { $matched = true; } break; case self::TYPE_MODIFIER: break; case self::TYPE_LINE_AMOUNT: break; case self::TYPE_CLAIM_TOTAL: break; } } if ($matched) { $visit->_claimRule = $values; } } return $visit; }