continue; } list($codetype, $code) = explode(':', $codestring); if ($codetype !== 'IPPF') { continue; } if (preg_match('/^25222/', $code)) { $gcac_related_visit = true; } } } } // End IPPF stuff } // end while $copays -= getPatientCopay($patient_id, $encounter); // The following is removed, perhaps temporarily, because gcac reporting // no longer depends on gcac issues. -- Rod 2009-08-11 /****************************************************************** // More custom code for IPPF. Generates an error message if a // GCAC issue is required but is not linked to this visit. if (!$errmsg && $gcac_related_visit) { $grow = sqlQuery("SELECT l.id, l.title, l.begdate, ie.pid " . "FROM lists AS l " . "LEFT JOIN issue_encounter AS ie ON ie.pid = l.pid AND " . "ie.encounter = '$encounter' AND ie.list_id = l.id " . "WHERE l.pid = '$patient_id' AND " . "l.activity = 1 AND l.type = 'ippf_gcac' " . "ORDER BY ie.pid DESC, l.begdate DESC LIMIT 1"); // Note that reverse-ordering by ie.pid is a trick for sorting // issues linked to the encounter (non-null values) first.
list($codetype, $code) = explode(':', $codestring); if ($codetype !== 'IPPF') { continue; } if (preg_match('/^25222/', $code)) { $gcac_related_visit = true; if (preg_match('/^25222[34]/', $code)) { $gcac_service_provided = true; } } } } } // Process copays // $totalCopay = getPatientCopay($patient_id, $encounter); if ($totalCopay < 0) { write_form_line("COPAY", "", "", "", "", $totalCopay, "", ""); } // Process drug sales / products. // while ($drow = sqlFetchArray($dres)) { if ($inv_encounter && $drow['encounter'] && $drow['encounter'] != $inv_encounter) { continue; } $thisdate = $drow['sale_date']; if (!$inv_encounter) { $inv_encounter = $drow['encounter']; } if (!$inv_provider && !empty($arr_users[$drow['provider_id']])) { $inv_provider = $drow['provider_id'] + 0;
// if (!$gottoday) { echoLine("form_upay[0]", date("Y-m-d"), 0, 0, 0, 0); //No encounter yet defined. } $gottoday = false; foreach ($encs as $key => $value) { $enc = $value['encounter']; $dispdate = $value['date']; if (strcmp($dispdate, $today) == 0 && !$gottoday) { $dispdate = date("Y-m-d"); $gottoday = true; } //------------------------------------------------------------------------------------ $inscopay = getCopay($pid, $dispdate); $patcopay = getPatientCopay($pid, $enc); //Insurance Payment //----------------- $drow = sqlQuery("SELECT SUM(pay_amount) AS payments, " . "SUM(adj_amount) AS adjustments FROM ar_activity WHERE " . "pid = ? and encounter = ? and " . "payer_type != 0 and account_code!='PCP' ", array($pid, $enc)); $dpayment = $drow['payments']; $dadjustment = $drow['adjustments']; //Patient Payment //--------------- $drow = sqlQuery("SELECT SUM(pay_amount) AS payments, " . "SUM(adj_amount) AS adjustments FROM ar_activity WHERE " . "pid = ? and encounter = ? and " . "payer_type = 0 and account_code!='PCP' ", array($pid, $enc)); $dpayment_pat = $drow['payments']; //------------------------------------------------------------------------------------ //NumberOfInsurance $ResultNumberOfInsurance = sqlStatement("SELECT COUNT( DISTINCT TYPE ) NumberOfInsurance FROM insurance_data\n\t\t\twhere pid = ? and provider>0 ", array($pid)); $RowNumberOfInsurance = sqlFetchArray($ResultNumberOfInsurance); $NumberOfInsurance = $RowNumberOfInsurance['NumberOfInsurance'] * 1; //------------------------------------------------------------------------------------
// grab the date to reformat it in the output $bdate = strtotime($b['date']); echo "<tr>\n"; echo "<td class='text' style='font-size: 0.8em'>" . oeFormatShortDate(date("Y-m-d", $bdate)) . "<BR>" . date("h:i a", $bdate) . "</td>"; echo "<td class='text'>" . text($b['provider_name']) . "</td>"; echo "<td class='text'>"; echo text($b['code_type']) . ":\t" . text($b['code']) . " " . text($b['modifier']) . " " . text($b['code_text']) . " "; echo "</td>\n"; echo "<td class='text'>"; echo oeFormatMoney($b['fee']); echo "</td>\n"; echo "</tr>\n"; $total += $b['fee']; } // Calculate the copay for the encounter $copays = getPatientCopay($pids[$iCounter], $ta[1]); //} echo "<tr><td> </td></tr>"; echo "<tr><td class='bold' colspan=3 style='text-align:right'>" . xlt('Sub-Total') . "</td><td class='text'>" . oeFormatMoney($total + abs($copays)) . "</td></tr>"; echo "<tr><td class='bold' colspan=3 style='text-align:right'>" . xlt('Copay Paid') . "</td><td class='text'>" . oeFormatMoney(abs($copays)) . "</td></tr>"; echo "<tr><td class='bold' colspan=3 style='text-align:right'>" . xlt('Total') . "</td><td class='text'>" . oeFormatMoney($total) . "</td></tr>"; echo "</table>"; echo "<pre>"; //print_r($billings); echo "</pre>"; } echo "</div>"; ++$iCounter; print "<br/><br/>" . xlt('Physician Signature') . ": _______________________________________________"; print "<hr class='pagebreak' />"; }