Skip to content

Commit

Permalink
initial support for electronic secondary claims, NDC info in claims, …
Browse files Browse the repository at this point in the history
…and improved electronic claims without freeb
  • Loading branch information
sunsetsystems committed Jun 18, 2007
1 parent b89cd34 commit 48e8e63
Show file tree
Hide file tree
Showing 8 changed files with 1,759 additions and 252 deletions.
463 changes: 243 additions & 220 deletions interface/billing/billing_process.php

Large diffs are not rendered by default.

101 changes: 89 additions & 12 deletions interface/forms/fee_sheet/new.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// This nonsense will go away if we ever move to subversion.
//////////////////////////////////////////////////////////////////////

// Copyright (C) 2005 Rod Roark <[email protected]>
// Copyright (C) 2005-2007 Rod Roark <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
Expand All @@ -23,6 +23,15 @@
include_once("codes.php");
include_once("../../../custom/code_types.inc.php");

// Possible units of measure for NDC drug quantities.
//
$ndc_uom_choices = array(
'ML' => 'ML',
'GR' => 'Grams',
'F2' => 'I.U.',
'UN' => 'Units'
);

// $FEE_SHEET_COLUMNS should be defined in codes.php.
if (empty($FEE_SHEET_COLUMNS)) $FEE_SHEET_COLUMNS = 2;

Expand Down Expand Up @@ -50,6 +59,12 @@
$auth = $iter['auth'] ? "1" : "0";
$del = $iter['del'];

$ndc_info = '';
if ($iter['ndcnum']) {
$ndc_info = 'N4' . trim($iter['ndcnum']) . ' ' . $iter['ndcuom'] .
trim($iter['ndcqty']);
}

// If the item is already in the database...
if ($id) {
if ($del) {
Expand All @@ -59,7 +74,8 @@
// authorizeBilling($id, $auth);
sqlQuery("UPDATE billing SET " .
"units = '$units', fee = '$fee', modifier = '$modifier', " .
"authorized = $auth, provider_id = '$provid' WHERE " .
"authorized = $auth, provider_id = '$provid', " .
"ndc_info = '$ndc_info' WHERE " .
"id = '$id' AND billed = 0 AND activity = 1");
}
}
Expand All @@ -77,7 +93,7 @@
$result = sqlQuery($query);
$code_text = addslashes($result['code_text']);
addBilling($encounter, $code_type, $code, $code_text, $pid, $auth,
$provid, $modifier, $units, $fee);
$provid, $modifier, $units, $fee, $ndc_info);
}
}

Expand Down Expand Up @@ -143,6 +159,16 @@ function codeselect(selobj, newtype) {
$search_type = $default_search_type;
if ($_POST['search_type']) $search_type = $_POST['search_type'];

// Find out if the patient has any insurance that requires NDC numbers.
// Currently this is just Medicaid, type 3.
//
$tmp = sqlQuery("SELECT c.id FROM " .
"insurance_data AS i, insurance_companies AS c WHERE " .
"i.pid = '$pid' AND i.provider != '' AND " .
"c.id = i.provider AND c.freeb_type = 3 " .
"LIMIT 1");
$ndc_applies = !empty($tmp);

echo $i ? " <td></td>\n </tr>\n" : "";
echo " <tr>\n";
echo " <td colspan='$FEE_SHEET_COLUMNS' align='center' nowrap>\n";
Expand Down Expand Up @@ -226,10 +252,12 @@ function codeselect(selobj, newtype) {

// This writes a billing line item to the output page.
//
function echoLine($lino, $codetype, $code, $modifier, $auth = TRUE, $del = FALSE,
$units = NULL, $fee = NULL, $id = NULL, $billed = FALSE, $code_text = NULL)
function echoLine($lino, $codetype, $code, $modifier, $ndc_info='',
$auth = TRUE, $del = FALSE, $units = NULL, $fee = NULL, $id = NULL,
$billed = FALSE, $code_text = NULL)
{
global $code_types;
global $code_types, $ndc_applies, $ndc_uom_choices;

if (! $code_text) {
$query = "select units, fee, code_text from codes where code_type = '" .
$code_types[$codetype]['id'] . "' and " .
Expand Down Expand Up @@ -296,6 +324,38 @@ function echoLine($lino, $codetype, $code, $modifier, $auth = TRUE, $del = FALSE
}
echo " <td class='billcell'>$strike1" . ucfirst(strtolower($code_text)) . "$strike2</td>\n";
echo " </tr>\n";

// If NDC info exists or may be required, add a line for it.
if ($codetype == 'HCPCS' && $ndc_applies && !$billed) {
$ndcnum = ''; $ndcuom = ''; $ndcqty = '';
if (preg_match('/^N4(\S+)\s+(\S\S)(.*)/', $ndc_info, $tmp)) {
$ndcnum = $tmp[1]; $ndcuom = $tmp[2]; $ndcqty = $tmp[3];
}
echo " <tr>\n";
echo " <td class='billcell' colspan='2'>&nbsp;</td>\n";
echo " <td class='billcell' colspan='6'>&nbsp;NDC:&nbsp;";
echo "<input type='text' name='bill[$lino][ndcnum]' value='$ndcnum' " .
"size='11' style='background-color:transparent'>";
echo " &nbsp;Qty:&nbsp;";
echo "<input type='text' name='bill[$lino][ndcqty]' value='$ndcqty' " .
"size='3' style='background-color:transparent;text-align:right'>";
echo " ";
echo "<select name='bill[$lino][ndcuom]' style='background-color:transparent'>";
foreach ($ndc_uom_choices as $key => $value) {
echo "<option value='$key'";
if ($key == $ndcuom) echo " selected";
echo ">$value</option>";
}
echo "</select>";
echo "</td>\n";
echo " </tr>\n";
}
else if ($ndc_info) {
echo " <tr>\n";
echo " <td class='billcell' colspan='2'>&nbsp;</td>\n";
echo " <td class='billcell' colspan='6'>&nbsp;NDC Data: $ndc_info</td>\n";
echo " </tr>\n";
}
}

// Try setting the default provider to that of the new encounter form.
Expand All @@ -315,9 +375,10 @@ function echoLine($lino, $codetype, $code, $modifier, $auth = TRUE, $del = FALSE
++$lino;
$del = $_POST['bill']["$lino"]['del']; // preserve Delete if checked
// list($code, $modifier) = explode("-", $iter["code"]);
echoLine($lino, $iter["code_type"], trim($iter["code"]), trim($iter["modifier"]),
$iter["authorized"], $del, $iter["units"], $iter["fee"], $iter["id"],
$iter["billed"], $iter["code_text"]);
echoLine($lino, $iter["code_type"], trim($iter["code"]),
trim($iter["modifier"]), $iter["ndc_info"], $iter["authorized"],
$del, $iter["units"], $iter["fee"], $iter["id"], $iter["billed"],
$iter["code_text"]);
// If no default provider yet then try this one.
if ($encounter_provid < 0 && ! $del) $encounter_provid = $iter["provider_id"];
}
Expand All @@ -334,8 +395,14 @@ function echoLine($lino, $codetype, $code, $modifier, $auth = TRUE, $del = FALSE
foreach ($_POST['bill'] as $key => $iter) {
if ($iter["id"]) continue; // skip if it came from the database
if ($iter["del"]) continue; // skip if Delete was checked
echoLine(++$lino, $iter["code_type"], $iter["code"], trim($iter["mod"]),
$iter["auth"], $iter["del"], $iter["units"], $iter["fee"]);
$ndc_info = '';
if ($iter['ndcnum']) {
$ndc_info = 'N4' . trim($iter['ndcnum']) . ' ' . $iter['ndcuom'] .
trim($iter['ndcqty']);
}
echoLine(++$lino, $iter["code_type"], $iter["code"], trim($iter["mod"]),
$ndc_info, $iter["auth"], $iter["del"], $iter["units"],
$iter["fee"]);
}
}

Expand All @@ -350,7 +417,17 @@ function echoLine($lino, $codetype, $code, $modifier, $auth = TRUE, $del = FALSE
$newtype = "HCPCS";
else if ($newtype == "OPCS" && preg_match("/^[0-9]/", $code))
$newtype = "CPT4";
echoLine(++$lino, $newtype, $code, trim($modifier));

$ndc_info = '';
// If HCPCS and Medicaid, find last NDC string used for this code.
if ($newtype == 'HCPCS' && $ndc_applies) {
$tmp = sqlQuery("SELECT ndc_info FROM billing WHERE " .
"code_type = '$newtype' AND code = '$code' AND ndc_info LIKE 'N4%' " .
"ORDER BY date DESC LIMIT 1");
if (!empty($tmp)) $ndc_info = $tmp['ndc_info'];
}

echoLine(++$lino, $newtype, $code, trim($modifier), $ndc_info);
}

?>
Expand Down
101 changes: 89 additions & 12 deletions interface/forms/fee_sheet/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// This nonsense will go away if we ever move to subversion.
//////////////////////////////////////////////////////////////////////

// Copyright (C) 2005 Rod Roark <[email protected]>
// Copyright (C) 2005-2007 Rod Roark <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
Expand All @@ -23,6 +23,15 @@
include_once("codes.php");
include_once("../../../custom/code_types.inc.php");

// Possible units of measure for NDC drug quantities.
//
$ndc_uom_choices = array(
'ML' => 'ML',
'GR' => 'Grams',
'F2' => 'I.U.',
'UN' => 'Units'
);

// $FEE_SHEET_COLUMNS should be defined in codes.php.
if (empty($FEE_SHEET_COLUMNS)) $FEE_SHEET_COLUMNS = 2;

Expand Down Expand Up @@ -50,6 +59,12 @@
$auth = $iter['auth'] ? "1" : "0";
$del = $iter['del'];

$ndc_info = '';
if ($iter['ndcnum']) {
$ndc_info = 'N4' . trim($iter['ndcnum']) . ' ' . $iter['ndcuom'] .
trim($iter['ndcqty']);
}

// If the item is already in the database...
if ($id) {
if ($del) {
Expand All @@ -59,7 +74,8 @@
// authorizeBilling($id, $auth);
sqlQuery("UPDATE billing SET " .
"units = '$units', fee = '$fee', modifier = '$modifier', " .
"authorized = $auth, provider_id = '$provid' WHERE " .
"authorized = $auth, provider_id = '$provid', " .
"ndc_info = '$ndc_info' WHERE " .
"id = '$id' AND billed = 0 AND activity = 1");
}
}
Expand All @@ -77,7 +93,7 @@
$result = sqlQuery($query);
$code_text = addslashes($result['code_text']);
addBilling($encounter, $code_type, $code, $code_text, $pid, $auth,
$provid, $modifier, $units, $fee);
$provid, $modifier, $units, $fee, $ndc_info);
}
}

Expand Down Expand Up @@ -143,6 +159,16 @@ function codeselect(selobj, newtype) {
$search_type = $default_search_type;
if ($_POST['search_type']) $search_type = $_POST['search_type'];

// Find out if the patient has any insurance that requires NDC numbers.
// Currently this is just Medicaid, type 3.
//
$tmp = sqlQuery("SELECT c.id FROM " .
"insurance_data AS i, insurance_companies AS c WHERE " .
"i.pid = '$pid' AND i.provider != '' AND " .
"c.id = i.provider AND c.freeb_type = 3 " .
"LIMIT 1");
$ndc_applies = !empty($tmp);

echo $i ? " <td></td>\n </tr>\n" : "";
echo " <tr>\n";
echo " <td colspan='$FEE_SHEET_COLUMNS' align='center' nowrap>\n";
Expand Down Expand Up @@ -226,10 +252,12 @@ function codeselect(selobj, newtype) {

// This writes a billing line item to the output page.
//
function echoLine($lino, $codetype, $code, $modifier, $auth = TRUE, $del = FALSE,
$units = NULL, $fee = NULL, $id = NULL, $billed = FALSE, $code_text = NULL)
function echoLine($lino, $codetype, $code, $modifier, $ndc_info='',
$auth = TRUE, $del = FALSE, $units = NULL, $fee = NULL, $id = NULL,
$billed = FALSE, $code_text = NULL)
{
global $code_types;
global $code_types, $ndc_applies, $ndc_uom_choices;

if (! $code_text) {
$query = "select units, fee, code_text from codes where code_type = '" .
$code_types[$codetype]['id'] . "' and " .
Expand Down Expand Up @@ -296,6 +324,38 @@ function echoLine($lino, $codetype, $code, $modifier, $auth = TRUE, $del = FALSE
}
echo " <td class='billcell'>$strike1" . ucfirst(strtolower($code_text)) . "$strike2</td>\n";
echo " </tr>\n";

// If NDC info exists or may be required, add a line for it.
if ($codetype == 'HCPCS' && $ndc_applies && !$billed) {
$ndcnum = ''; $ndcuom = ''; $ndcqty = '';
if (preg_match('/^N4(\S+)\s+(\S\S)(.*)/', $ndc_info, $tmp)) {
$ndcnum = $tmp[1]; $ndcuom = $tmp[2]; $ndcqty = $tmp[3];
}
echo " <tr>\n";
echo " <td class='billcell' colspan='2'>&nbsp;</td>\n";
echo " <td class='billcell' colspan='6'>&nbsp;NDC:&nbsp;";
echo "<input type='text' name='bill[$lino][ndcnum]' value='$ndcnum' " .
"size='11' style='background-color:transparent'>";
echo " &nbsp;Qty:&nbsp;";
echo "<input type='text' name='bill[$lino][ndcqty]' value='$ndcqty' " .
"size='3' style='background-color:transparent;text-align:right'>";
echo " ";
echo "<select name='bill[$lino][ndcuom]' style='background-color:transparent'>";
foreach ($ndc_uom_choices as $key => $value) {
echo "<option value='$key'";
if ($key == $ndcuom) echo " selected";
echo ">$value</option>";
}
echo "</select>";
echo "</td>\n";
echo " </tr>\n";
}
else if ($ndc_info) {
echo " <tr>\n";
echo " <td class='billcell' colspan='2'>&nbsp;</td>\n";
echo " <td class='billcell' colspan='6'>&nbsp;NDC Data: $ndc_info</td>\n";
echo " </tr>\n";
}
}

// Try setting the default provider to that of the new encounter form.
Expand All @@ -315,9 +375,10 @@ function echoLine($lino, $codetype, $code, $modifier, $auth = TRUE, $del = FALSE
++$lino;
$del = $_POST['bill']["$lino"]['del']; // preserve Delete if checked
// list($code, $modifier) = explode("-", $iter["code"]);
echoLine($lino, $iter["code_type"], trim($iter["code"]), trim($iter["modifier"]),
$iter["authorized"], $del, $iter["units"], $iter["fee"], $iter["id"],
$iter["billed"], $iter["code_text"]);
echoLine($lino, $iter["code_type"], trim($iter["code"]),
trim($iter["modifier"]), $iter["ndc_info"], $iter["authorized"],
$del, $iter["units"], $iter["fee"], $iter["id"], $iter["billed"],
$iter["code_text"]);
// If no default provider yet then try this one.
if ($encounter_provid < 0 && ! $del) $encounter_provid = $iter["provider_id"];
}
Expand All @@ -334,8 +395,14 @@ function echoLine($lino, $codetype, $code, $modifier, $auth = TRUE, $del = FALSE
foreach ($_POST['bill'] as $key => $iter) {
if ($iter["id"]) continue; // skip if it came from the database
if ($iter["del"]) continue; // skip if Delete was checked
echoLine(++$lino, $iter["code_type"], $iter["code"], trim($iter["mod"]),
$iter["auth"], $iter["del"], $iter["units"], $iter["fee"]);
$ndc_info = '';
if ($iter['ndcnum']) {
$ndc_info = 'N4' . trim($iter['ndcnum']) . ' ' . $iter['ndcuom'] .
trim($iter['ndcqty']);
}
echoLine(++$lino, $iter["code_type"], $iter["code"], trim($iter["mod"]),
$ndc_info, $iter["auth"], $iter["del"], $iter["units"],
$iter["fee"]);
}
}

Expand All @@ -350,7 +417,17 @@ function echoLine($lino, $codetype, $code, $modifier, $auth = TRUE, $del = FALSE
$newtype = "HCPCS";
else if ($newtype == "OPCS" && preg_match("/^[0-9]/", $code))
$newtype = "CPT4";
echoLine(++$lino, $newtype, $code, trim($modifier));

$ndc_info = '';
// If HCPCS and Medicaid, find last NDC string used for this code.
if ($newtype == 'HCPCS' && $ndc_applies) {
$tmp = sqlQuery("SELECT ndc_info FROM billing WHERE " .
"code_type = '$newtype' AND code = '$code' AND ndc_info LIKE 'N4%' " .
"ORDER BY date DESC LIMIT 1");
if (!empty($tmp)) $ndc_info = $tmp['ndc_info'];
}

echoLine(++$lino, $newtype, $code, trim($modifier), $ndc_info);
}

?>
Expand Down
Loading

0 comments on commit 48e8e63

Please sign in to comment.