require_once "../../interface/globals.php"; require_once "{$srcdir}/forms.inc"; require_once "{$srcdir}/patient.inc"; require_once "{$srcdir}/formatting.inc.php"; require_once "{$srcdir}/encounter_events.inc.php"; $issue = $_GET['issue']; $createvisit = !empty($_GET['createvisit']); $today = date('Y-m-d'); $irow = sqlQuery("SELECT title, pid FROM lists WHERE id = ?", array($issue)); $thispid = $irow['pid']; if (empty($thispid)) { die("Error fetching issue {$issue}"); } if ($createvisit) { // Create a new encounter and give it a title of the issue title. $thisenc = todaysEncounter($thispid, $irow['title']); // If the encounter is not already linked to the specified issue, link it. $tmp = sqlQuery("SELECT count(*) AS count FROM issue_encounter WHERE " . "pid = ? AND list_id = ? AND encounter = ?", array($thispid, $issue, $thisenc)); if (empty($tmp['count'])) { sqlStatement("INSERT INTO issue_encounter " . "( pid, list_id, encounter ) VALUES ( ?, ?, ? )", array($thispid, $issue, $thisenc)); } ?> // alert('pid = <?php echo $pid; ?> thispid = <?php echo $thispid; ?> '); // debugging
} // $patdata = getPatientData($pid, 'fname,lname,pubpid'); $patdata = sqlQuery("SELECT " . "p.fname, p.mname, p.lname, p.pubpid, i.copay " . "FROM patient_data AS p " . "LEFT OUTER JOIN insurance_data AS i ON " . "i.pid = p.pid AND i.type = 'primary' " . "WHERE p.pid = '{$pid}' ORDER BY i.date DESC LIMIT 1"); $alertmsg = ''; // anything here pops up in an alert box // If the Save button was clicked... if ($_POST['form_save']) { $form_pid = $_POST['form_pid']; $form_method = trim($_POST['form_method']); $form_source = trim($_POST['form_source']); // Post payments for unbilled encounters. These go into the billing table. if ($_POST['form_upay']) { foreach ($_POST['form_upay'] as $enc => $payment) { if ($amount = 0 + $payment) { if (!$enc) { $enc = todaysEncounter($form_pid); } addBilling($enc, 'COPAY', sprintf('%.2f', $amount), $form_method, $form_pid, 1, $_SESSION["authUserID"], '', 1, 0 - $amount, '', ''); frontPayment($form_pid, $enc, $form_method, $form_source, $amount, 0); } } } // Post payments for previously billed encounters. These go to A/R. if ($_POST['form_bpay']) { foreach ($_POST['form_bpay'] as $enc => $payment) { if ($amount = 0 + $payment) { if ($INTEGRATED_AR) { $thissrc = ''; if ($form_method) { $thissrc .= $form_method; if ($form_source) {