Skip to content

Commit

Permalink
first steps to support v5.0 misc billing form (#869)
Browse files Browse the repository at this point in the history
* first steps to support v5.0 misc billing

* corrections from brady

* 837 fix added

* minor fix
  • Loading branch information
stephenwaite authored and bradymiller committed Jun 20, 2017
1 parent 7de2ad9 commit 5f30cbe
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 102 deletions.
31 changes: 31 additions & 0 deletions interface/forms/misc_billing_options/date_qualifier_options.php
Expand Up @@ -23,6 +23,37 @@
* @author Kevin Yeh <kevin.y@integralemr.com>
* @link http://www.open-emr.org
*/
function generateDateQualifierSelect($name,$options,$obj)
{
echo "<select name='".attr($name)."'>";
for($idx=0;$idx<count($options);$idx++)
{
echo "<option value='".attr($options[$idx][1])."'";
if($obj[$name]==$options[$idx][1]) echo " selected";
echo ">".text($options[$idx][0])."</option>";
}
echo "</select>";

}
function genProviderSelect($selname, $toptext, $default=0, $disabled=false) {
$query = "SELECT id, lname, fname FROM users WHERE " .
"( authorized = 1 OR info LIKE '%provider%' ) AND username != '' " .
"AND active = 1 AND ( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
"ORDER BY lname, fname";
$res = sqlStatement($query);
echo " <select name='" . attr($selname) . "'";
if ($disabled) echo " disabled";
echo ">\n";
echo " <option value=''>" . text($toptext) . "\n";
while ($row = sqlFetchArray($res)) {
$provid = $row['id'];
echo " <option value='" . attr($provid) . "'";
if ($provid == $default) echo " selected";
echo ">" . text($row['lname'] . ", " . $row['fname']) . "\n";
}
echo text($provid);
echo " </select>\n";
}

$box_14_qualifier_options=array(array(xl("Onset of Current Symptoms or Illness"),"431"),
array(xl("Last Menstrual Period"),"484"));
Expand Down
96 changes: 29 additions & 67 deletions interface/forms/misc_billing_options/new.php
@@ -1,39 +1,23 @@
<?php
/*
* new.php for the creation of the misc_billing_form
*
* This program creates the misc_billing_form
*
* Copyright (C) 2007 Bo Huynh
* Copyright (C) 2016 Terry Hill <terry@lillysystems.com>
* Copyright (C) 2017 Brady Miller <brady.g.miller@gmail.com>
*
* LICENSE: This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://opensource.org/licenses/gpl-license.php.
*
* @package OpenEMR
* @author Terry Hill <terry@lilysystems.com>
* @author Brady Miller <brady.g.miller@gmail.com>
* @link http://www.open-emr.org
*
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/



require_once("../../globals.php");
require_once("$srcdir/options.inc.php");
require_once("$srcdir/api.inc");
require_once("date_qualifier_options.php");


if (! $encounter) { // comes from globals.php
die(xlt("Internal error: we do not seem to be in an encounter!"));
}
Expand All @@ -42,68 +26,46 @@
$obj = $formid ? formFetch("form_misc_billing_options", $formid) : array();

formHeader("Form: misc_billing_options");
function generateDateQualifierSelect($name,$options,$obj)
{
echo "<select name='".attr($name)."'>";
for($idx=0;$idx<count($options);$idx++)
{
echo "<option value='".attr($options[$idx][1])."'";
if($obj[$name]==$options[$idx][1]) echo " selected";
echo ">".text($options[$idx][0])."</option>";
}
echo "</select>";

}
function genProviderSelect($selname, $toptext, $default=0, $disabled=false) {
$query = "SELECT id, lname, fname FROM users WHERE " .
"( authorized = 1 OR info LIKE '%provider%' ) AND username != '' " .
"AND active = 1 AND ( info IS NULL OR info NOT LIKE '%Inactive%' ) " .
"ORDER BY lname, fname";
$res = sqlStatement($query);
echo " <select name='" . attr($selname) . "'";
if ($disabled) echo " disabled";
echo ">\n";
echo " <option value=''>" . text($toptext) . "\n";
while ($row = sqlFetchArray($res)) {
$provid = $row['id'];
echo " <option value='" . attr($provid) . "'";
if ($provid == $default) echo " selected";
echo ">" . text($row['lname'] . ", " . $row['fname']) . "\n";
}
echo text($provid);
echo " </select>\n";
}
?>
<html>
<head>
<?php html_header_show(); ?>

<link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
<link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">

<script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script>
<script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js?v=<?php echo $v_js_includes; ?>"></script>
<script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script>

</head>
<body class="body_top">
<form method=post <?php echo "name='my_form' " . "action='$rootdir/forms/misc_billing_options/save.php?id=" . attr($formid) . "'>\n";?>

<span class="title"><?php echo xlt('Misc Billing Options for HCFA-1500'); ?></span><br><br>
<span class=text><?php echo xlt('Checked box = yes , empty = no');?><br><br>
<label><span class=text><?php echo xlt('BOX 10 A. Employment related '); ?>: </span><input type=checkbox name="employment_related" value="1" <?php if ($obj['employment_related'] == "1") echo "checked";?>></label><br><br>
<label><span class=text><?php echo xlt('BOX 10 B. Auto Accident '); ?>: </span><input type=checkbox name="auto_accident" value="1" <?php if ($obj['auto_accident'] == "1") echo "checked";?>></label>
<label><span class=text><?php echo xlt('Box 10 A. Employment related '); ?>: </span><input type=checkbox name="employment_related" value="1" <?php if ($obj['employment_related'] == "1") echo "checked";?>></label><br><br>
<label><span class=text><?php echo xlt('Box 10 B. Auto Accident '); ?>: </span><input type=checkbox name="auto_accident" value="1" <?php if ($obj['auto_accident'] == "1") echo "checked";?>></label>
<span class=text><?php echo xlt('State'); ?>: </span><input type=entry name="accident_state" size=1 value="<?php echo attr($obj{"accident_state"});?>" ><br><br>
<label><span class=text><?php echo xlt('BOX 10 C. Other Accident '); ?>: </span><input type=checkbox name="other_accident" value="1" <?php if ($obj['other_accident'] == "1") echo "checked";?>></label><br><br>
<span class=text><?php echo xlt('BOX 10 D. EPSDT Referral Code');?> </span><input type=entry style="width: 25px;" size=2 name="medicaid_referral_code" value="<?php echo attr($obj{"medicaid_referral_code"});?>" >&nbsp;&nbsp;&nbsp;&nbsp;
<label><span class=text><?php echo xlt('Box 10 C. Other Accident '); ?>: </span><input type=checkbox name="other_accident" value="1" <?php if ($obj['other_accident'] == "1") echo "checked";?>></label><br><br>
<span class=text><?php echo xlt('Box 10 D. EPSDT Referral Code');?> </span><input type=entry style="width: 25px;" size=2 name="medicaid_referral_code" value="<?php echo attr($obj{"medicaid_referral_code"});?>" >&nbsp;&nbsp;&nbsp;&nbsp;
<label><span class=text><?php echo xlt('EPSDT'); ?> : </span><input type=checkbox name="epsdt_flag" value="1" <?php if ($obj['epsdt_flag'] == "1") echo "checked";?>></label><br><br>
<span class="text" title="<?php echo xla("For HCFA 02/12 Onset date specified on the Encounter Form needs a qualifier");?>"></span>
<span class=text title="<?php echo xla('For HCFA 02/12 Box 15 is Other Date with a qualifier to specify what the date indicates');?>"></span>
<tr>
<td><span class=text><?php echo xlt('BOX 14. Is Populated from the Encounter Screen as the Onset Date');?>.</span></td>
<td><span class=text><?php echo xlt('Box 14. Populated from the Encounter Screen as the Onset Date needs a qualifier.');?>
<?php generateDateQualifierSelect("box_14_date_qual",$box_14_qualifier_options,$obj); ?>
</span></td>
</tr><br><br>
<tr>
<td><span class=text><?php echo xlt('Box 15. Other Date with a qualifier to specify what the date indicates.');?>
<?php $date_initial_treatment = $obj{"date_initial_treatment"}; ?>
<input type=text style="width: 70px;" size=10 class='datepicker' name='date_initial_treatment' id='date_initial_treatment'
value='<?php echo attr($date_initial_treatment); ?>'
title='<?php echo xla('yyyy-mm-dd'); ?>' />
</span></td>
<td>
<?php generateDateQualifierSelect("box_15_date_qual",$box_15_qualifier_options,$obj); ?>
</td>

</tr><br><br>
<tr>
<td><span class=text><?php echo xlt('BOX 16. Date unable to work from');?>:</span></td>
<td><span class=text><?php echo xlt('Box 16. Date unable to work from');?>:</span></td>
<td><?php $off_work_from = $obj{"off_work_from"}; ?>
<input type=text style="width: 70px;" size=10 class='datepicker' name='off_work_from' id='off_work_from'
value='<?php echo attr($off_work_from); ?>'
Expand All @@ -112,7 +74,7 @@ function genProviderSelect($selname, $toptext, $default=0, $disabled=false) {
</tr>
&nbsp;&nbsp;
<tr>
<td><span class=text><?php echo xlt('BOX 16. Date unable to work to');?>:</span></td>
<td><span class=text><?php echo xlt('Box 16. Date unable to work to');?>:</span></td>
<td><?php $off_work_to = $obj{"off_work_to"}; ?>
<input type=text style="width: 70px;" size=10 class='datepicker' name='off_work_to' id='off_work_to'
value='<?php echo attr($off_work_to); ?>'
Expand All @@ -121,18 +83,18 @@ function genProviderSelect($selname, $toptext, $default=0, $disabled=false) {
</tr>
<br><br>

<td class='label_custom'><?php echo xlt('BOX 17. Provider') ?>:</td>
<td class='label_custom'><?php echo xlt('Box 17. Provider') ?>:</td>
<td><?php # Build a drop-down list of providers. # Added (TLH)
genProviderSelect('provider_id', '-- '.xl("Please Select").' --',$obj{"provider_id"});
?></td>&nbsp;&nbsp;
<td><span class=text><?php echo xlt('BOX 17. Provider Qualifier'); ?>: </span>
<td><span class=text><?php echo xlt('Box 17. Provider Qualifier'); ?>: </span>
<tr><td><?php
echo generate_select_list('provider_qualifier_code', 'provider_qualifier_code',$obj{"provider_qualifier_code"}, 'Provider Qualifier Code');
?></td>
</tr></td>
<br><br>
<tr>
<td><span class=text><?php echo xlt('BOX 18. Hospitalization date from');?>:</span></td>
<td><span class=text><?php echo xlt('Box 18. Hospitalization date from');?>:</span></td>
<td><?php $hospitalization_date_from = $obj{"hospitalization_date_from"}; ?>
<input type=text style="width: 70px;" size=10 class='datepicker' name='hospitalization_date_from' id='hospitalization_date_from'
value='<?php echo attr($hospitalization_date_from); ?>'
Expand All @@ -141,19 +103,19 @@ function genProviderSelect($selname, $toptext, $default=0, $disabled=false) {
</tr>
&nbsp;&nbsp;
<tr>
<td><span class=text><?php echo xlt('BOX 18. Hospitalization date to');?>:</span></td>
<td><span class=text><?php echo xlt('Box 18. Hospitalization date to');?>:</span></td>
<td><?php $hospitalization_date_to = $obj{"hospitalization_date_to"}; ?>
<input type=text style="width: 70px;" size=10 class='datepicker' name='hospitalization_date_to' id='hospitalization_date_to'
value='<?php echo attr($hospitalization_date_to); ?>'
title='<?php echo xla('yyyy-mm-dd'); ?>' />
</td>
</tr>
<br><br>
<span class=text><?php echo xlt('BOX 20. Is Outside Lab used?'); ?>: </span><input type=checkbox name="outside_lab" value="1" <?php if ($obj['outside_lab'] == "1") echo "checked";?>>
<span class=text><?php echo xlt('Box 20. Is Outside Lab used?'); ?>: </span><input type=checkbox name="outside_lab" value="1" <?php if ($obj['outside_lab'] == "1") echo "checked";?>>
<span class=text><?php echo xlt('Amount Charges'); ?>: </span><input type=entry size=7 align='right' name="lab_amount" value="<?php echo attr($obj{"lab_amount"});?>" ><br><br>
<span class=text><?php echo xlt('BOX 22. Medicaid Resubmission Code (ICD-9) ');?></span><input type=entry size=9 name="medicaid_resubmission_code" value="<?php echo attr($obj{"medicaid_resubmission_code"});?>" >
<span class=text><?php echo xlt('Box 22. Medicaid Resubmission Code (ICD-9) ');?></span><input type=entry size=9 name="medicaid_resubmission_code" value="<?php echo attr($obj{"medicaid_resubmission_code"});?>" >
<span class=text><?php echo xlt(' Medicaid Original Reference No. ');?></span><input type=entry size=15 name="medicaid_original_reference" value="<?php echo attr($obj{"medicaid_original_reference"});?>" ><br><br>
<span class=text><?php echo xlt('BOX 23. Prior Authorization No. ');?></span><input type=entry size=15 name="prior_auth_number" value="<?php echo attr($obj{"prior_auth_number"});?>" ><br><br>
<span class=text><?php echo xlt('Box 23. Prior Authorization No. ');?></span><input type=entry size=15 name="prior_auth_number" value="<?php echo attr($obj{"prior_auth_number"});?>" ><br><br>
<label><span class=text><?php echo xlt('X12 only: Replacement Claim '); ?>: </span><input type=checkbox name="replacement_claim" value="1" <?php if ($obj['replacement_claim'] == "1") echo "checked";?>></label><br><br>
<span class=text><?php echo xlt('X12 only ICN resubmission No.');?> </span><input type=entry size=35 name="icn_resubmission_number" value="<?php echo attr($obj{"icn_resubmission_number"});?>" ><br><br>

Expand Down
18 changes: 9 additions & 9 deletions library/Claim.class.php
@@ -1,11 +1,11 @@
<?php
// Copyright (C) 2007-2009 Rod Roark <rod@sunsetsystems.com>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.

/** @package OpenEMR
* @link http://www.open-emr.org
* @author Rod Roark <rod@sunsetsystems.com>
* @copyright Copyright (c) 2009 Rod Roark <rod@sunsetsystems.com>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/
require_once(dirname(__FILE__) . "/invoice_summary.inc.php");

// This enforces the X12 Basic Character Set. Page A2.
Expand Down Expand Up @@ -1089,14 +1089,14 @@ function dateInitialTreatment() {
return cleanDate($this->billing_options['date_initial_treatment']);
}

function box14qualifier()
function box14Qualifier()
{
// If no box qualifier specified use "431" indicating Onset
return empty($this->billing_options['box_14_date_qual']) ? '431' :
$this->billing_options['box_14_date_qual'];
}

function box15qualifier()
function box15Qualifier()
{
// If no box qualifier specified use "454" indicating Initial Treatment
return empty($this->billing_options['box_15_date_qual']) ? '454' :
Expand Down
16 changes: 8 additions & 8 deletions library/gen_hcfa_1500.inc.php
@@ -1,10 +1,10 @@
<?php
// Copyright (C) 2008-2011 Rod Roark <rod@sunsetsystems.com>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
/** @package OpenEMR
* @link http://www.open-emr.org
* @author Rod Roark <rod@sunsetsystems.com>
* @copyright Copyright (c) 2011 Rod Roark <rod@sunsetsystems.com>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/

require_once("Claim.class.php");
require_once("gen_hcfa_1500_02_12.inc.php");
Expand Down Expand Up @@ -346,15 +346,15 @@ function gen_hcfa_1500_page($pid, $encounter, &$log, &$claim) {
if(hcfa_1500_version_02_12() && !empty($tmp))
{
// Only include the Box 14 qualifier if there we are using version 02/12 and there is a Box 14 date.
put_hcfa(32, 16, 3, $claim->box14qualifier());
put_hcfa(32, 16, 3, $claim->box14Qualifier());

}
// Box 15. First Date of Same or Similar Illness, if applicable
$tmp = $claim->dateInitialTreatment();
if(hcfa_1500_version_02_12() && !empty($tmp))
{
// Only include the Box 15 qualifier if there we are using version 02/12 and there is a Box 15 date.
put_hcfa(32, 31, 3, $claim->box15qualifier());
put_hcfa(32, 31, 3, $claim->box15Qualifier());
}


Expand Down
38 changes: 20 additions & 18 deletions library/gen_x12_837.inc.php
@@ -1,10 +1,10 @@
<?php
// Copyright (C) 2007-2011 Rod Roark <rod@sunsetsystems.com>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
/** @package OpenEMR
* @link http://www.open-emr.org
* @author Rod Roark <rod@sunsetsystems.com>
* @copyright Copyright (c) 2009 Rod Roark <rod@sunsetsystems.com>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/

require_once("Claim.class.php");
function stripZipCode($zip)
Expand Down Expand Up @@ -559,24 +559,26 @@ function gen_x12_837($pid, $encounter, &$log, $encounter_claim=false) {
"~\n";
}

if ($claim->dateInitialTreatment() && ($claim->onsetDateValid())) {
// Segment DTP*454 (Initial Treatment Date)
// Segment DTP*304 (Last Seen Date)
// Segment DTP*453 (Acute Manifestation Date)
// Segment DTP*439 (Accident Date)
// Segment DTP*484 (Last Menstrual Period Date)
// Segment DTP*455 (Last X-Ray Date)
// Segment DTP*471 (Hearing and Vision Prescription Date)
// Segment DTP (Disability Dates)
// Segment DTP*297 (Last Worked Date)
// Segment DTP*296 (Authorized Return to Work Date)

if ($claim->dateInitialTreatment() && ($claim->box15Qualifier())) {
++$edicount;
$out .= "DTP" . // Date of Initial Treatment
"*454" .
$out .= "DTP" . // Date Last Seen
"*" . $claim->box15Qualifier() .
"*D8" .
"*" . $claim->dateInitialTreatment() .
"~\n";
}

// Segment DTP*304 (Last Seen Date) omitted.
// Segment DTP*453 (Acute Manifestation Date) omitted.
// Segment DTP*439 (Accident Date) omitted.
// Segment DTP*484 (Last Menstrual Period Date) omitted.
// Segment DTP*455 (Last X-Ray Date) omitted.
// Segment DTP*471 (Hearing and Vision Prescription Date) omitted.
// Segments DTP (Disability Dates) omitted.
// Segment DTP*297 (Last Worked Date) omitted.
// Segment DTP*296 (Authorized Return to Work Date) omitted.

if (strcmp($claim->facilityPOS(),'21') == 0 && $claim->onsetDateValid() ) {
++$edicount;
Expand Down

0 comments on commit 5f30cbe

Please sign in to comment.