Ejemplo n.º 1
0
function echoLine($lino, $codetype, $code, $modifier, $ndc_info = '', $auth = TRUE, $del = FALSE, $units = NULL, $fee = NULL, $id = NULL, $billed = FALSE, $code_text = NULL, $justify = NULL, $provider_id = 0, $notecodes = '')
{
    global $code_types, $ndc_applies, $ndc_uom_choices, $justinit, $pid;
    global $contraception, $usbillstyle, $hasCharges;
    // If using line item billing and user wishes to default to a selected provider, then do so.
    if ($GLOBALS['default_fee_sheet_line_item_provider'] == 1 && $GLOBALS['support_fee_sheet_line_item_provider'] == 1) {
        if ($provider_id == 0) {
            $provider_id = 0 + findProvider();
        }
    }
    if ($codetype == 'COPAY') {
        if (!$code_text) {
            $code_text = 'Cash';
        }
        if ($fee > 0) {
            $fee = 0 - $fee;
        }
    }
    if (!$code_text) {
        $sqlArray = array();
        $query = "select id, units, code_text from codes where code_type = ? " . " and " . "code = ? and ";
        array_push($sqlArray, $code_types[$codetype]['id'], $code);
        if ($modifier) {
            $query .= "modifier = ?";
            array_push($sqlArray, $modifier);
        } else {
            $query .= "(modifier is null or modifier = '')";
        }
        $result = sqlQuery($query, $sqlArray);
        $code_text = $result['code_text'];
        if (empty($units)) {
            $units = max(1, intval($result['units']));
        }
        if (!isset($fee)) {
            // Fees come from the prices table now.
            $query = "SELECT prices.pr_price " . "FROM patient_data, prices WHERE " . "patient_data.pid = ? AND " . "prices.pr_id = ? AND " . "prices.pr_selector = '' AND " . "prices.pr_level = patient_data.pricelevel " . "LIMIT 1";
            echo "\n<!-- {$query} -->\n";
            // debugging
            $prrow = sqlQuery($query, array($pid, $result['id']));
            $fee = empty($prrow) ? 0 : $prrow['pr_price'];
        }
    }
    $fee = sprintf('%01.2f', $fee);
    if (empty($units)) {
        $units = 1;
    }
    $units = max(1, intval($units));
    // We put unit price on the screen, not the total line item fee.
    $price = $fee / $units;
    $strike1 = $id && $del ? "<strike>" : "";
    $strike2 = $id && $del ? "</strike>" : "";
    echo " <tr>\n";
    echo "  <td class='billcell'>{$strike1}" . ($codetype == 'COPAY' ? xl($codetype) : $codetype) . $strike2;
    //if the line to ouput is copay, show the date here passed as $ndc_info,
    //since this variable is not applicable in the case of copay.
    if ($codetype == 'COPAY') {
        echo "(" . htmlspecialchars($ndc_info) . ")";
        $ndc_info = '';
    }
    if ($id) {
        echo "<input type='hidden' name='bill[" . attr($lino) . "][id]' value='{$id}'>";
    }
    echo "<input type='hidden' name='bill[" . attr($lino) . "][code_type]' value='" . attr($codetype) . "'>";
    echo "<input type='hidden' name='bill[" . attr($lino) . "][code]' value='" . attr($code) . "'>";
    echo "<input type='hidden' name='bill[" . attr($lino) . "][billed]' value='" . attr($billed) . "'>";
    echo "</td>\n";
    if ($codetype != 'COPAY') {
        echo "  <td class='billcell'>{$strike1}" . text($code) . "{$strike2}</td>\n";
    } else {
        echo "  <td class='billcell'>&nbsp;</td>\n";
    }
    if ($billed) {
        if (modifiers_are_used(true)) {
            echo "  <td class='billcell'>{$strike1}" . text($modifier) . "{$strike2}" . "<input type='hidden' name='bill[" . attr($lino) . "][mod]' value='" . attr($modifier) . "'></td>\n";
        }
        if (fees_are_used()) {
            echo "  <td class='billcell' align='right'>" . text(oeFormatMoney($price)) . "</td>\n";
            if ($codetype != 'COPAY') {
                echo "  <td class='billcell' align='center'>" . text($units) . "</td>\n";
            } else {
                echo "  <td class='billcell'>&nbsp;</td>\n";
            }
        }
        if (justifiers_are_used()) {
            echo "  <td class='billcell' align='center'{$usbillstyle}>" . text($justify) . "</td>\n";
        }
        // Show provider for this line (if using line item billing).
        if ($GLOBALS['support_fee_sheet_line_item_provider'] == 1) {
            echo "  <td class='billcell' align='center'>";
        } else {
            echo "  <td class='billcell' align='center' style='display: none'>";
        }
        genProviderSelect('', '-- ' . xl("Default") . ' --', $provider_id, true);
        echo "</td>\n";
        if ($code_types[$codetype]['claim'] && !$code_types[$codetype]['diag']) {
            echo "  <td class='billcell' align='center'{$usbillstyle}>" . htmlspecialchars($notecodes, ENT_NOQUOTES) . "</td>\n";
        } else {
            echo "  <td class='billcell' align='center'{$usbillstyle}></td>\n";
        }
        echo "  <td class='billcell' align='center'{$usbillstyle}><input type='checkbox'" . ($auth ? " checked" : "") . " disabled /></td>\n";
        echo "  <td class='billcell' align='center'><input type='checkbox'" . " disabled /></td>\n";
    } else {
        // not billed
        if (modifiers_are_used(true)) {
            if ($codetype != 'COPAY' && ($code_types[$codetype]['mod'] || $modifier)) {
                echo "  <td class='billcell'><input type='text' name='bill[" . attr($lino) . "][mod]' " . "value='" . attr($modifier) . "' " . "title='" . xla("Multiple modifiers can be separated by colons or spaces, maximum of 4 (M1:M2:M3:M4)") . "' " . "value='" . attr($modifier) . "' size='" . attr($code_types[$codetype]['mod']) . "'></td>\n";
            } else {
                echo "  <td class='billcell'>&nbsp;</td>\n";
            }
        }
        if (fees_are_used()) {
            if ($codetype == 'COPAY' || $code_types[$codetype]['fee'] || $fee != 0) {
                echo "  <td class='billcell' align='right'>" . "<input type='text' name='bill[" . attr($lino) . "][price]' " . "value='" . attr($price) . "' size='6'";
                if (acl_check('acct', 'disc')) {
                    echo " style='text-align:right'";
                } else {
                    echo " style='text-align:right;background-color:transparent' readonly";
                }
                echo "></td>\n";
                echo "  <td class='billcell' align='center'>";
                if ($codetype != 'COPAY') {
                    echo "<input type='text' name='bill[" . attr($lino) . "][units]' " . "value='" . attr($units) . "' size='2' style='text-align:right'>";
                } else {
                    echo "<input type='hidden' name='bill[" . attr($lino) . "][units]' value='" . attr($units) . "'>";
                }
                echo "</td>\n";
            } else {
                echo "  <td class='billcell'>&nbsp;</td>\n";
                echo "  <td class='billcell'>&nbsp;</td>\n";
            }
        }
        if (justifiers_are_used()) {
            if ($code_types[$codetype]['just'] || $justify) {
                echo "  <td class='billcell' align='center'{$usbillstyle} ";
                echo "title='" . xla("Select one or more diagnosis codes to justify the service") . "' >";
                echo "<select name='bill[" . attr($lino) . "][justify]' onchange='setJustify(this)'>";
                echo "<option value='" . attr($justify) . "'>" . text($justify) . "</option></select>";
                echo "</td>\n";
                $justinit .= "setJustify(f['bill[" . attr($lino) . "][justify]']);\n";
            } else {
                echo "  <td class='billcell'{$usbillstyle}>&nbsp;</td>\n";
            }
        }
        // Show provider for this line (if using line item billing)
        if ($GLOBALS['support_fee_sheet_line_item_provider'] == 1) {
            echo "  <td class='billcell' align='center'>";
        } else {
            echo "  <td class='billcell' align='center' style='display: none'>";
        }
        genProviderSelect("bill[{$lino}][provid]", '-- ' . xl("Default") . ' --', $provider_id);
        echo "</td>\n";
        if ($code_types[$codetype]['claim'] && !$code_types[$codetype]['diag']) {
            echo "  <td class='billcell' align='center'{$usbillstyle}><input type='text' name='bill[" . attr($lino) . "][notecodes]' " . "value='" . htmlspecialchars($notecodes, ENT_QUOTES) . "' maxlength='10' size='8' /></td>\n";
        } else {
            echo "  <td class='billcell' align='center'{$usbillstyle}></td>\n";
        }
        echo "  <td class='billcell' align='center'{$usbillstyle}><input type='checkbox' name='bill[" . attr($lino) . "][auth]' " . "value='1'" . ($auth ? " checked" : "") . " /></td>\n";
        echo "  <td class='billcell' align='center'><input type='checkbox' name='bill[" . attr($lino) . "][del]' " . "value='1'" . ($del ? " checked" : "") . " /></td>\n";
    }
    echo "  <td class='billcell'>{$strike1}" . text($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[" . attr($lino) . "][ndcnum]' value='" . attr($ndcnum) . "' " . "size='11' style='background-color:transparent'>";
        echo " &nbsp;Qty:&nbsp;";
        echo "<input type='text' name='bill[" . attr($lino) . "][ndcqty]' value='" . attr($ndcqty) . "' " . "size='3' style='background-color:transparent;text-align:right'>";
        echo " ";
        echo "<select name='bill[" . attr($lino) . "][ndcuom]' style='background-color:transparent'>";
        foreach ($ndc_uom_choices as $key => $value) {
            echo "<option value='" . attr($key) . "'";
            if ($key == $ndcuom) {
                echo " selected";
            }
            echo ">" . text($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;" . xlt("NDC Data") . ": " . text($ndc_info) . "</td>\n";
            echo " </tr>\n";
        }
    }
    // For IPPF.  Track contraceptive services.
    if (!$del) {
        $contraception |= contraceptionClass($codetype, $code);
    }
    if ($fee != 0) {
        $hasCharges = true;
    }
}
Ejemplo n.º 2
0
function echoLine($lino, $codetype, $code, $modifier, $ndc_info = '', $auth = TRUE, $del = FALSE, $units = NULL, $fee = NULL, $id = NULL, $billed = FALSE, $code_text = NULL, $justify = NULL, $provider_id = 0, $notecodes = '')
{
    global $code_types, $ndc_applies, $ndc_uom_choices, $justinit, $pid;
    global $contraception, $usbillstyle, $hasCharges;
    if ($codetype == 'COPAY') {
        if (!$code_text) {
            $code_text = 'Cash';
        }
        if ($fee > 0) {
            $fee = 0 - $fee;
        }
    }
    if (!$code_text) {
        $query = "select id, units, code_text from codes where code_type = '" . $code_types[$codetype]['id'] . "' and " . "code = '{$code}' and ";
        if ($modifier) {
            $query .= "modifier = '{$modifier}'";
        } else {
            $query .= "(modifier is null or modifier = '')";
        }
        $result = sqlQuery($query);
        $code_text = $result['code_text'];
        if (empty($units)) {
            $units = max(1, intval($result['units']));
        }
        if (!isset($fee)) {
            // Fees come from the prices table now.
            $query = "SELECT prices.pr_price " . "FROM patient_data, prices WHERE " . "patient_data.pid = '{$pid}' AND " . "prices.pr_id = '" . $result['id'] . "' AND " . "prices.pr_selector = '' AND " . "prices.pr_level = patient_data.pricelevel " . "LIMIT 1";
            echo "\n<!-- {$query} -->\n";
            // debugging
            $prrow = sqlQuery($query);
            $fee = empty($prrow) ? 0 : $prrow['pr_price'];
        }
    }
    $fee = sprintf('%01.2f', $fee);
    if (empty($units)) {
        $units = 1;
    }
    $units = max(1, intval($units));
    // We put unit price on the screen, not the total line item fee.
    $price = $fee / $units;
    $strike1 = $id && $del ? "<strike>" : "";
    $strike2 = $id && $del ? "</strike>" : "";
    echo " <tr>\n";
    echo "  <td class='billcell'>{$strike1}" . ($codetype == 'COPAY' ? xl($codetype) : $codetype) . $strike2;
    if ($id) {
        echo "<input type='hidden' name='bill[{$lino}][id]' value='{$id}'>";
    }
    echo "<input type='hidden' name='bill[{$lino}][code_type]' value='{$codetype}'>";
    echo "<input type='hidden' name='bill[{$lino}][code]' value='{$code}'>";
    echo "<input type='hidden' name='bill[{$lino}][billed]' value='{$billed}'>";
    echo "</td>\n";
    if ($codetype != 'COPAY') {
        echo "  <td class='billcell'>{$strike1}{$code}{$strike2}</td>\n";
    } else {
        echo "  <td class='billcell'>&nbsp;</td>\n";
    }
    if ($billed) {
        if (modifiers_are_used(true)) {
            echo "  <td class='billcell'>{$strike1}{$modifier}{$strike2}" . "<input type='hidden' name='bill[{$lino}][mod]' value='{$modifier}'></td>\n";
        }
        if (fees_are_used()) {
            echo "  <td class='billcell' align='right'>" . oeFormatMoney($price) . "</td>\n";
            if ($codetype != 'COPAY') {
                echo "  <td class='billcell' align='center'>{$units}</td>\n";
            } else {
                echo "  <td class='billcell'>&nbsp;</td>\n";
            }
            echo "  <td class='billcell' align='center'{$usbillstyle}>{$justify}</td>\n";
        }
        // Show provider for this line.
        echo "  <td class='billcell' align='center'>";
        genProviderSelect('', '-- Default --', $provider_id, true);
        echo "</td>\n";
        if ($codetype == 'HCPCS' || $codetype == 'CPT4') {
            echo "  <td class='billcell' align='center'{$usbillstyle}>" . htmlspecialchars($notecodes, ENT_NOQUOTES) . "</td>\n";
        } else {
            echo "  <td class='billcell' align='center'{$usbillstyle}></td>\n";
        }
        echo "  <td class='billcell' align='center'{$usbillstyle}><input type='checkbox'" . ($auth ? " checked" : "") . " disabled /></td>\n";
        echo "  <td class='billcell' align='center'><input type='checkbox'" . " disabled /></td>\n";
    } else {
        // not billed
        if (modifiers_are_used(true)) {
            if ($codetype != 'COPAY' && ($code_types[$codetype]['mod'] || $modifier)) {
                echo "  <td class='billcell'><input type='text' name='bill[{$lino}][mod]' " . "value='{$modifier}' " . "title='" . xl("Multiple modifiers can be separated by colons or spaces, maximum of 4 (M1:M2:M3:M4)") . "' " . "value='{$modifier}' size='" . $code_types[$codetype]['mod'] . "'></td>\n";
            } else {
                echo "  <td class='billcell'>&nbsp;</td>\n";
            }
        }
        if (fees_are_used()) {
            if ($codetype == 'COPAY' || $code_types[$codetype]['fee'] || $fee != 0) {
                echo "  <td class='billcell' align='right'>" . "<input type='text' name='bill[{$lino}][price]' " . "value='{$price}' size='6'";
                if (acl_check('acct', 'disc')) {
                    echo " style='text-align:right'";
                } else {
                    echo " style='text-align:right;background-color:transparent' readonly";
                }
                echo "></td>\n";
                echo "  <td class='billcell' align='center'>";
                if ($codetype != 'COPAY') {
                    echo "<input type='text' name='bill[{$lino}][units]' " . "value='{$units}' size='2' style='text-align:right'>";
                } else {
                    echo "<input type='hidden' name='bill[{$lino}][units]' value='{$units}'>";
                }
                echo "</td>\n";
                if ($code_types[$codetype]['just'] || $justify) {
                    echo "  <td class='billcell' align='center'{$usbillstyle} ";
                    echo "title='" . xl("Select one or more diagnosis codes to justify the service") . "' >";
                    echo "<select name='bill[{$lino}][justify]' onchange='setJustify(this)'>";
                    echo "<option value='{$justify}'>{$justify}</option></select>";
                    echo "</td>\n";
                    $justinit .= "setJustify(f['bill[{$lino}][justify]']);\n";
                } else {
                    echo "  <td class='billcell'{$usbillstyle}>&nbsp;</td>\n";
                }
            } else {
                echo "  <td class='billcell'>&nbsp;</td>\n";
                echo "  <td class='billcell'>&nbsp;</td>\n";
                echo "  <td class='billcell'{$usbillstyle}>&nbsp;</td>\n";
                // justify
            }
        }
        // Provider drop-list for this line.
        echo "  <td class='billcell' align='center'>";
        genProviderSelect("bill[{$lino}][provid]", '-- Default --', $provider_id);
        echo "</td>\n";
        if ($codetype == 'HCPCS' || $codetype == 'CPT4') {
            echo "  <td class='billcell' align='center'{$usbillstyle}><input type='text' name='bill[{$lino}][notecodes]' " . "value='" . htmlspecialchars($notecodes, ENT_QUOTES) . "' maxlength='10' size='8' /></td>\n";
        } else {
            echo "  <td class='billcell' align='center'{$usbillstyle}></td>\n";
        }
        echo "  <td class='billcell' align='center'{$usbillstyle}><input type='checkbox' name='bill[{$lino}][auth]' " . "value='1'" . ($auth ? " checked" : "") . " /></td>\n";
        echo "  <td class='billcell' align='center'><input type='checkbox' name='bill[{$lino}][del]' " . "value='1'" . ($del ? " checked" : "") . " /></td>\n";
    }
    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";
        }
    }
    // For IPPF.  Track contraceptive services.
    if (!$del) {
        $contraception |= contraceptionClass($codetype, $code);
    }
    if ($fee != 0) {
        $hasCharges = true;
    }
}