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'> </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'> </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'> </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'> </td>\n"; echo " <td class='billcell'> </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}> </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'> </td>\n"; echo " <td class='billcell' colspan='6'> NDC: "; echo "<input type='text' name='bill[" . attr($lino) . "][ndcnum]' value='" . attr($ndcnum) . "' " . "size='11' style='background-color:transparent'>"; echo " Qty: "; 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'> </td>\n"; echo " <td class='billcell' colspan='6'> " . 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; } }
* ADD ANY NEW PREFERENCES above, and as a hidden field in the body. */ /** <!-- End Preferences --> **/ /** * Create, update or retrieve a form and its values */ if (!$pid) { $pid = $_SESSION['pid']; } $userauthorized = $_SESSION['userauthorized']; if ($encounter == "") { $encounter = date("Ymd"); } $form_id = $_REQUEST['form_id']; $zone = $_REQUEST['zone']; $providerID = findProvider($pid, $encounter); if ($providerID == '0') { $providerID = $userauthorized; } //who is the default provider? $providerNAME = getProviderName($providerID); // The form is submitted to be updated or saved in some way. // Give each instance of a form a uniqueID. If the form has no owner, update DB with this uniqueID. // If the DB shows a uniqueID ie. an owner, and the save request uniqueID does not = the uniqueID in the DB, // ask if the new user wishes to take ownership? // If yes, any other's attempt to save fields/form are denied and the return code says you are not the owner... if ($_REQUEST['unlock'] == '1') { // we are releasing the form, by closing the page or clicking on ACTIVE FORM, so unlock it. // if it's locked and they own it ($REQUEST[LOCKEDBY] == LOCKEDBY), they can unlock it $query = "SELECT LOCKED,LOCKEDBY,LOCKEDDATE from " . $table_name . " WHERE ID=?"; $lock = sqlQuery($query, array($form_id));
function __construct($pid = 0, $encounter = 0) { if (empty($pid)) { $pid = $GLOBALS['pid']; } if (empty($encounter)) { $encounter = $GLOBALS['encounter']; } $this->pid = $pid; $this->encounter = $encounter; // IPPF doesn't want any payments to be made or displayed in the Fee Sheet. $this->ALLOW_COPAYS = !$GLOBALS['ippf_specific']; // Get the user's default warehouse and an indicator if there's a choice of warehouses. $wrow = sqlQuery("SELECT count(*) AS count FROM list_options WHERE list_id = 'warehouse' AND activity = 1"); $this->got_warehouses = $wrow['count'] > 1; $wrow = sqlQuery("SELECT default_warehouse FROM users WHERE username = ?", array($_SESSION['authUser'])); $this->default_warehouse = empty($wrow['default_warehouse']) ? '' : $wrow['default_warehouse']; // Get some info about this visit. $visit_row = sqlQuery("SELECT fe.date, fe.provider_id, fe.supervisor_id, " . "opc.pc_catname, fac.extra_validation " . "FROM form_encounter AS fe " . "LEFT JOIN openemr_postcalendar_categories AS opc ON opc.pc_catid = fe.pc_catid " . "LEFT JOIN facility AS fac ON fac.id = fe.facility_id " . "WHERE fe.pid = ? AND fe.encounter = ? LIMIT 1", array($this->pid, $this->encounter)); $this->visit_date = substr($visit_row['date'], 0, 10); $this->provider_id = $visit_row['provider_id']; if (empty($this->provider_id)) { $this->provider_id = findProvider(); } $this->supervisor_id = $visit_row['supervisor_id']; // This flag is specific to IPPF validation at form submit time. It indicates // that most contraceptive services and products should match up on the fee sheet. $this->match_services_to_products = $GLOBALS['ippf_specific'] && !empty($visit_row['extra_validation']); // Get some information about the patient. $patientrow = getPatientData($this->pid, "DOB, sex, pricelevel"); $this->patient_age = $this->getAge($patientrow['DOB'], $this->visit_date); $this->patient_male = strtoupper(substr($patientrow['sex'], 0, 1)) == 'M' ? 1 : 0; $this->patient_pricelevel = $patientrow['pricelevel']; }
} if (!$_SESSION['encounter']) { $encounter = date("Ymd"); } else { $encounter = $_SESSION['encounter']; } $query = "select * from form_encounter where pid =? and encounter= ?"; $encounter_data = sqlQuery($query, array($pid, $encounter)); $encounter_date = $encounter_data['date']; $query = "SELECT * " . "FROM form_encounter AS fe, forms AS f WHERE " . "fe.pid = ? AND fe.date = ? AND " . "f.formdir = ? AND f.encounter = fe.encounter AND f.deleted = 0"; $erow = sqlQuery($query, array($pid, $encounter_date, $form_folder)); if ($erow['form_id'] > '0') { formHeader("Redirecting...."); formJump('./view_form.php?formname=' . $form_folder . '&id=' . attr($erow['form_id']) . '&pid=' . attr($pid)); formFooter(); exit; } else { $id = $erow2['count']++; $providerid = findProvider(attr($pid), $encounter); $newid = formSubmit($table_name, $_POST, $id, $providerid); $sql = "insert into forms (date, encounter, form_name, form_id, pid, " . "user, groupname, authorized, formdir) values (NOW(),?,?,?,?,?,?,?,?)"; //activity=1, date = NOW() $answer = sqlInsert($sql, array($encounter, $form_name, $newid, $pid, $user, $group, $providerid, $form_folder)); } formHeader("Redirecting...."); formJump('./view_form.php?formname=' . $form_folder . '&id=' . attr($newid) . '&pid=' . attr($pid)); formFooter(); exit; ?>