Beispiel #1
0
                    }
                    //--------------------------------------------------------------------------------------------------------------------
                }
                //invoice_balance
            }
            //if ($amount = 0 + $payment)
        }
        //foreach
    }
    //if ($_POST['form_upay'])
}
//if ($_POST['form_save'])
if ($_POST['form_save'] || $_REQUEST['receipt']) {
    if ($_REQUEST['receipt']) {
        $form_pid = $_GET['patient'];
        $timestamp = decorateString('....-..-.. ..:..:..', $_GET['time']);
    }
    // Get details for what we guess is the primary facility.
    $frow = sqlQuery("SELECT * FROM facility " . "ORDER BY billing_location DESC, accepts_assignment DESC, id LIMIT 1");
    // Get the patient's name and chart number.
    $patdata = getPatientData($form_pid, 'fname,mname,lname,pubpid');
    // Re-fetch payment info.
    $payrow = sqlQuery("SELECT " . "SUM(amount1) AS amount1, " . "SUM(amount2) AS amount2, " . "MAX(method) AS method, " . "MAX(source) AS source, " . "MAX(dtime) AS dtime, " . "MAX(user) AS user, " . "MAX(encounter) as encounter " . "FROM payments WHERE " . "pid = ? AND dtime = ?", array($form_pid, $timestamp));
    // Create key for deleting, just in case.
    $ref_id = $_REQUEST['radio_type_of_payment'] == 'copay' ? $session_id : $payment_id;
    $payment_key = $form_pid . '.' . preg_replace('/[^0-9]/', '', $timestamp) . '.' . $ref_id;
    // get facility from encounter
    $tmprow = sqlQuery("\n    SELECT facility_id\n    FROM form_encounter\n    WHERE encounter = ?", array($payrow['encounter']));
    $frow = sqlQuery("SELECT * FROM facility " . " WHERE id = ?", array($tmprow['facility_id']));
    // Now proceed with printing the receipt.
    ?>
Beispiel #2
0
     }
     $trow = sqlQuery("SELECT url FROM documents WHERE id = '{$document}'");
     $url = $trow['url'];
     row_delete("categories_to_documents", "document_id = '{$document}'");
     row_delete("documents", "id = '{$document}'");
     row_delete("gprelations", "type1 = 1 AND id1 = '{$document}'");
     if (substr($url, 0, 7) == 'file://') {
         @unlink(substr($url, 7));
     }
 } else {
     if ($payment) {
         if (!acl_check('admin', 'super')) {
             die("Not authorized!");
         }
         list($patient_id, $timestamp) = explode(".", $payment);
         $timestamp = decorateString('....-..-.. ..:..:..', $timestamp);
         $payres = sqlStatement("SELECT * FROM payments WHERE " . "pid = '{$patient_id}' AND dtime = '{$timestamp}'");
         while ($payrow = sqlFetchArray($payres)) {
             if ($payrow['amount1'] != 0) {
                 // Mark the payment as inactive.
                 row_modify("billing", "activity = 0", "pid = '{$patient_id}' AND " . "encounter = '" . $payrow['encounter'] . "' AND " . "code_type = 'COPAY' AND " . "fee = '" . (0 - $payrow['amount1']) . "' AND " . "LEFT(date, 10) = '" . substr($timestamp, 0, 10) . "' AND " . "activity = 1 LIMIT 1");
             }
             if ($payrow['amount2'] != 0) {
                 if ($GLOBALS['oer_config']['ws_accounting']['enabled'] === 2) {
                     $thissrc = '';
                     if ($payrow['method']) {
                         $thissrc .= $payrow['method'];
                         if ($payrow['source']) {
                             $thissrc .= ' ' . $payrow['source'];
                         }
                     }