From 50118df8fc4d4de8ec158cf83843916beb9c97eb Mon Sep 17 00:00:00 2001 From: sunsetsystems Date: Mon, 6 Jun 2005 18:04:01 +0000 Subject: [PATCH] implemented customization of billing code types --- custom/code_types.inc.php | 40 ++++ interface/billing/billing_report.php | 4 +- interface/billing/sl_eob_invoice.php | 70 +++++- interface/forms/fee_sheet/codes.php | 23 +- interface/forms/fee_sheet/new.php | 112 +++++----- interface/forms/fee_sheet/view.php | 112 +++++----- interface/patient_file/encounter/coding.php | 18 +- interface/patient_file/encounter/search_code.php | 97 +++++++++ .../patient_file/encounter/superbill_codes.php | 236 +++++++++------------ .../encounter/superbill_custom_full.php | 77 ++++--- interface/reports/appt_encounter_report.php | 7 +- 11 files changed, 482 insertions(+), 314 deletions(-) create mode 100644 custom/code_types.inc.php create mode 100644 interface/patient_file/encounter/search_code.php rewrite interface/patient_file/encounter/superbill_codes.php (64%) diff --git a/custom/code_types.inc.php b/custom/code_types.inc.php new file mode 100644 index 000000000..2a5aed715 --- /dev/null +++ b/custom/code_types.inc.php @@ -0,0 +1,40 @@ + array('id' => 2, 'fee' => 0, 'mod' => 2, 'just' => '' ), + 'CPT4' => array('id' => 1, 'fee' => 1, 'mod' => 2, 'just' => 'ICD9'), + 'HCPCS' => array('id' => 3, 'fee' => 1, 'mod' => 2, 'just' => 'ICD9') + + /* UK Sports Medicine: + 'ICD10' => array('id' => 4, 'fee' => 0, 'mod' => 0, 'just' => '' ), + 'OSICS' => array('id' => 5, 'fee' => 0, 'mod' => 4, 'just' => '' ), + 'OPCS' => array('id' => 6, 'fee' => 0, 'mod' => 0, 'just' => '' ) */ +); + +$default_search_type = 'ICD9'; // US +// $default_search_type = 'OSICS'; // UK + +function fees_are_used() { + global $code_types; + foreach ($code_types as $value) { if ($value['fee']) return true; } + return false; +} + +function modifiers_are_used() { + global $code_types; + foreach ($code_types as $value) { if ($value['mod']) return true; } + return false; +} + +?> diff --git a/interface/billing/billing_report.php b/interface/billing/billing_report.php index ebfb68c5f..5f8e4526f 100644 --- a/interface/billing/billing_report.php +++ b/interface/billing/billing_report.php @@ -1,6 +1,7 @@ \n"; $justify = ""; - if ($iter['code_type'] == "CPT4" || $iter['code_type'] == "HCPCS") { +// if ($iter['code_type'] == "CPT4" || $iter['code_type'] == "HCPCS") { + if ($code_types[$iter['code_type']]['just']) { $js = split(":",$iter['justify']); $counter = 0; foreach ($js as $j) { diff --git a/interface/billing/sl_eob_invoice.php b/interface/billing/sl_eob_invoice.php index d35d13f8a..e6b3a8852 100644 --- a/interface/billing/sl_eob_invoice.php +++ b/interface/billing/sl_eob_invoice.php @@ -14,9 +14,26 @@ include_once("../../library/forms.inc"); include_once("../../library/sql-ledger.inc"); include_once("../../library/invoice_summary.inc.php"); + include_once("../../custom/code_types.inc.php"); $debug = 0; // set to 1 for debugging mode + $reasons = array( + "Ins adjust", + "Coll w/o", + "Pt released", + "Sm debt w/o", + "To ded'ble", + "To copay", + "Bad debt", + "Discount", + "Hardship w/o", + "Ins refund", + "Pt refund", + "Ins overpaid", + "Pt overpaid" + ); + $info_msg = ""; // Format money for display. @@ -58,10 +75,10 @@ // Insert a row into the invoice table. // - function addLineItem($invid, $serialnumber, $amount, $adjdate, $insplan) { + function addLineItem($invid, $serialnumber, $amount, $adjdate, $insplan, $reason) { global $sl_err, $services_id, $debug; $adjdate = fixDate($adjdate); - $description = "Adjustment $adjdate"; + $description = "Adjustment $adjdate $reason"; $query = "INSERT INTO invoice ( " . "trans_id, " . "parts_id, " . @@ -233,6 +250,8 @@ // Set the billing code type and description. $code_type = ""; $code_text = ""; + + /**** if (preg_match("/CPT/", $row['serialnumber'])) { $code_type = "CPT4"; $code_text = "Procedure $code"; @@ -254,6 +273,28 @@ $proc_ins_id = 0; } } + ****/ + + foreach ($code_types as $key => $value) { + if (preg_match("/$key/", $row['serialnumber'])) { + $code_type = $key; + if ($value['fee']) { + $code_text = "Procedure $code"; + } else { + $code_text = "Diagnosis $code"; + if ($proc_ins_id) { + $query = "UPDATE billing SET justify = '$code' WHERE id = $proc_ins_id"; + if ($debug) { + echo $query . "
\n"; + } else { + sqlQuery($query); + } + $proc_ins_id = 0; + } + } + break; + } + } // Skip adjustments. if (! $code_type) continue; @@ -392,6 +433,9 @@ function validate(f) { $thispay = trim($cdata['pay']); $thisadj = trim($cdata['adj']); $thisins = trim($cdata['ins']); + $reason = trim($cdata['reason']); + if (strpos(strtolower($reason), 'ins') !== false) + $reason .= ' ' . $_POST['form_insurance']; if (! $thisins) $thisins = 0; if ($thispay) { // Post a payment: add to ar, subtract from cash. @@ -402,7 +446,7 @@ function validate(f) { } if ($thisadj) { // Post an adjustment: add negative invoice item, add to ar, subtract from income - addLineItem($trans_id, $code, 0 - $thisadj, $thisdate, $thisins); + addLineItem($trans_id, $code, 0 - $thisadj, $thisdate, $thisins, $reason); addTransaction($trans_id, $chart_id_ar, $thisadj, $thisdate, "InvAdj $thissrc", $code, $thisins); addTransaction($trans_id, $chart_id_income, 0 - $thisadj, $thisdate, "InvAdj $thissrc", $code, $thisins); updateAR($trans_id, 0 - $thisadj); @@ -458,7 +502,7 @@ function validate(f) { - + @@ -485,6 +529,12 @@ function validate(f) { + + Now posting for:  + Ins1  + Ins2  + Ins3 + @@ -532,6 +582,9 @@ function validate(f) { Adjust + + Reason + $cdata) { @@ -561,6 +614,15 @@ function validate(f) {   W + + + 'Brief', '99212' => 'Limited', '99213' => 'Detailed', @@ -18,7 +20,7 @@ $cpt['Established Patient'] = array( '99396' => 'Well Exam 40-64 Yrs (V72.31/V70.0)', '99397' => 'Well Exam 65+ Yrs (V72.31/V70.0)', ); -$cpt['New Patient'] = array( +$bcodes['CPT4']['New Patient'] = array( '99201' => 'Brief', '99202' => 'Limited', '99203' => 'Detailed', @@ -32,7 +34,7 @@ $cpt['New Patient'] = array( '99386' => 'Well Exam 40-64 Yrs (V72.31/V70.0)', '99387' => 'Well Exam 65+ Yrs (V72.31/V70.0)', ); -$cpt['Procedures'] = array( +$bcodes['CPT4']['Procedures'] = array( '10040' => 'Cyst Removal', '10060' => 'I & D simple/single', '10061' => 'I & D abscess multiple/complex', @@ -70,7 +72,7 @@ $cpt['Procedures'] = array( '93233' => 'Holter Monitor Review', '93272' => 'Event monitor interpretation', ); -$cpt['Lab'] = array( +$bcodes['CPT4']['Lab'] = array( '82962' => 'Accucheck', '90788' => 'Admin of Antibiotic', '90782' => 'Admin of Injection', @@ -97,10 +99,9 @@ $cpt['Lab'] = array( '81002' => 'Urinalysis w/o micro', '81025' => 'Urine pregnancy losl/BHCG', '36415' => 'Venipuncture', -# 'G0001' => 'Venipuncture - Medicare', 'G0107' => 'Screening Hemoccult - Medicare', ); -$cpt['Immunizations'] = array( +$bcodes['CPT4']['Immunizations'] = array( '90471' => 'Single Immunization Admin', '90472' => 'Additional Immunization Admin', 'G0008' => 'Flu shot / medicare (V06.6)', @@ -110,7 +111,7 @@ $cpt['Immunizations'] = array( '90718' => 'Td (V06.5)', '90703' => 'Tot Tox (V03.7)', ); -$cpt['Consultation and Review'] = array( +$bcodes['CPT4']['Consultation and Review'] = array( '99361' => 'Medical Conference 30 min', '99371' => 'Telephone Consultation 1-10 min', '99372' => 'Telephone Consultation 10-20 min', @@ -120,9 +121,9 @@ $cpt['Consultation and Review'] = array( 'G0181' => 'Care Plan Oversight', ); -$hcpcs = array(); +$bcodes['HCPCS'] = array(); -$hcpcs['Therapeutic Injections'] = array( +$bcodes['HCPCS']['Therapeutic Injections'] = array( 'J7619' => 'Albuterol unit dose 0.083%', 'J1200' => 'Benadryl up to 50 mg', 'J3420' => 'B-12 1000 mg', @@ -141,4 +142,4 @@ $hcpcs['Therapeutic Injections'] = array( 'J2680' => 'Prolixin 25 mg', 'J3410' => 'Vistaril up to 25 mg', ); -?> \ No newline at end of file +?> diff --git a/interface/forms/fee_sheet/new.php b/interface/forms/fee_sheet/new.php index 30388dde1..70835b7e4 100644 --- a/interface/forms/fee_sheet/new.php +++ b/interface/forms/fee_sheet/new.php @@ -8,7 +8,7 @@ // And if you check in a change to either module, be sure to check // in the other (identical) module also. // -// This nonsense will go away when we are moved to subversion. +// This nonsense will go away if we ever move to subversion. ////////////////////////////////////////////////////////////////////// // Copyright (C) 2005 Rod Roark @@ -21,14 +21,7 @@ include_once("../../globals.php"); include_once("$srcdir/api.inc"); include_once("codes.php"); - -// Numeric code types used internally by OpenEMR. -// -$type_map = array( - 'CPT4' => '1', - 'ICD9' => '2', - 'HCPCS' => '3' -); +include_once("../../../custom/code_types.inc.php"); // If Save was clicked, save the new and modified billing lines; // then if no error, redirect to patient_encounter.php. @@ -41,7 +34,7 @@ if ($_POST['bn_save']) { $iter = $bill["$lino"]; // Skip disabled (billed) line items. - if (!isset($iter['fee'])) continue; + if ($iter['billed']) continue; $id = $iter['id']; $code_type = $iter['code_type']; @@ -67,7 +60,7 @@ if ($_POST['bn_save']) { // Otherwise it's a new item... else if (! $del) { $query = "select code_text from codes where code_type = '" . - $type_map[$code_type] . "' and " . + $code_types[$code_type]['id'] . "' and " . "code = '$code' and "; if ($modifier) { $query .= "modifier = '$modifier'"; @@ -119,35 +112,25 @@ function codeselect(selobj, newtype) { $value1) { - ++$i; - echo ($i & 1) ? " \n" : ""; - echo " \n"; - echo " \n"; - echo " \n"; - echo ($i & 1) ? "" : " \n"; -} - -foreach ($hcpcs as $key1 => $value1) { - ++$i; - echo ($i & 1) ? " \n" : ""; - echo " \n"; - echo " \n"; + echo "