Skip to content
Permalink
Browse files Browse the repository at this point in the history
bring back #5676, #5689, and #5674 to rel-700 (#5694)
* php8.1 fixes (#5676)

* php8 fixes for batch payments (#5689)

* change int cast to ceil for little payments

* simplify with floatval()

* better comment

* fix other php8 maths

* bug fix (#5674)

* bug fix

* check for empty eid

* consistently null with opener vars
  • Loading branch information
stephenwaite committed Aug 20, 2022
1 parent ba39341 commit 235b191
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 35 deletions.
4 changes: 2 additions & 2 deletions interface/billing/edit_payment.php
Expand Up @@ -188,7 +188,7 @@
//==============================================================================================================================

$where = "$where1 AND adj_amount != 0";
if (isset($_POST["AdjAmount$CountRow"]) && $_POST["AdjAmount$CountRow"] * 1 !== 0) {
if (isset($_POST["AdjAmount$CountRow"]) && floatval($_POST["AdjAmount$CountRow"]) !== 0) {
if (trim($_POST['type_name']) == 'insurance') {
$AdjustString = "Ins adjust Ins" . trim($_POST["HiddenIns$CountRow"]);
$AccountCode = "IA";
Expand Down Expand Up @@ -939,7 +939,7 @@ function DeletePaymentDistribution(DeleteId) {//Confirms deletion of payment dis
$ReasonCodeDB = $rowPayment['reason_code'];

if ($Ins == 1) {
$AllowedDB = number_format($Fee - $AdjAmountDB, 2);
$AllowedDB = number_format($Fee - floatval($AdjAmountDB), 2);
} else {
$AllowedDB = 0;
}
Expand Down
44 changes: 24 additions & 20 deletions interface/patient_tracker/patient_tracker.php
Expand Up @@ -64,7 +64,7 @@
//set default start date of flow board to value based on globals
if (!$GLOBALS['ptkr_date_range']) {
$from_date = date('Y-m-d');
} elseif (!is_null($_REQUEST['form_from_date'])) {
} elseif (!is_null($_REQUEST['form_from_date'] ?? null)) {
$from_date = DateToYYYYMMDD($_REQUEST['form_from_date']);
} elseif (($GLOBALS['ptkr_start_date']) == 'D0') {
$from_date = date('Y-m-d');
Expand Down Expand Up @@ -101,13 +101,13 @@
}

$to_date = date('Y-m-d', $ptkr_future_time);
$to_date = !is_null($_REQUEST['form_to_date']) ? DateToYYYYMMDD($_REQUEST['form_to_date']) : $to_date;
$to_date = !is_null($_REQUEST['form_to_date'] ?? null) ? DateToYYYYMMDD($_REQUEST['form_to_date']) : $to_date;
} else {
$to_date = date('Y-m-d');
}

$form_patient_name = !is_null($_POST['form_patient_name']) ? $_POST['form_patient_name'] : null;
$form_patient_id = !is_null($_POST['form_patient_id']) ? $_POST['form_patient_id'] : null;
$form_patient_name = !is_null($_POST['form_patient_name'] ?? null) ? $_POST['form_patient_name'] : null;
$form_patient_id = !is_null($_POST['form_patient_id'] ?? null) ? $_POST['form_patient_id'] : null;


$lres = sqlStatement("SELECT option_id, title FROM list_options WHERE list_id = ? AND activity=1", array('apptstat'));
Expand Down Expand Up @@ -143,7 +143,7 @@
}
}

if (!$_REQUEST['flb_table']) {
if (!($_REQUEST['flb_table'] ?? null)) {
?>
<html>
<head>
Expand Down Expand Up @@ -188,7 +188,7 @@
echo "<option value=''>" . xlt("Visit Categories") . "</option>";
while ($cat = sqlFetchArray($categories)) {
echo "<option value='" . attr($cat['id']) . "'";
if ($cat['id'] == $_POST['form_apptcat']) {
if ($cat['id'] == ($_POST['form_apptcat'] ?? null)) {
echo " selected='true' ";
}
echo ">" . xlt($cat['category']) . "</option>";
Expand All @@ -204,7 +204,7 @@
$apptstats = sqlStatement("SELECT * FROM list_options WHERE list_id = 'apptstat' AND activity = 1 ORDER BY seq");
while ($apptstat = sqlFetchArray($apptstats)) {
echo "<option value='" . attr($apptstat['option_id']) . "'";
if ($apptstat['option_id'] == $_POST['form_apptstatus']) {
if ($apptstat['option_id'] == ($_POST['form_apptstatus'] ?? null)) {
echo " selected='true' ";
}
echo ">" . xlt($apptstat['title']) . "</option>";
Expand All @@ -218,8 +218,10 @@
<?php
$fac_sql = sqlStatement("SELECT * FROM facility ORDER BY id");
while ($fac = sqlFetchArray($fac_sql)) {
$true = ($fac['id'] == $_POST['form_facility']) ? "selected=true" : '';
$true = ($fac['id'] == ($_POST['form_facility'] ?? null)) ? "selected=true" : '';
($select_facs ?? null) ? $select_facs : $select_facs = '';
$select_facs .= "<option value=" . attr($fac['id']) . " " . $true . ">" . text($fac['name']) . "</option>\n";
($count ?? null) ? $count_facs : $count_facs = 0;
$count_facs++;
}
if ($count_facs < '1') {
Expand All @@ -238,13 +240,15 @@
$ures = sqlStatement($query);
while ($urow = sqlFetchArray($ures)) {
$provid = $urow['id'];
($select_provs ?? null) ? $select_provs : $select_provs = '';
$select_provs .= " <option value='" . attr($provid) . "'";
if (isset($_POST['form_provider']) && $provid == $_POST['form_provider']) {
$select_provs .= " selected";
} elseif (!isset($_POST['form_provider']) && $_SESSION['userauthorized'] && $provid == $_SESSION['authUserID']) {
$select_provs .= " selected";
}
$select_provs .= ">" . text($urow['lname']) . ", " . text($urow['fname']) . "\n";
($count_provs ?? null) ? $count_provs : $count_provs = 0;
$count_provs++;
}
?>
Expand Down Expand Up @@ -284,7 +288,7 @@

<div class="col-sm-12 mt-3 mx-auto">
<button id="filter_submit" class="btn btn-primary btn-sm btn-filter"><?php echo xlt('Filter'); ?></button>
<input type="hidden" id="kiosk" name="kiosk" value="<?php echo attr($_REQUEST['kiosk']); ?>" />
<input type="hidden" id="kiosk" name="kiosk" value="<?php echo attr($_REQUEST['kiosk'] ?? ''); ?>" />
</div>
</div>
<div class="col-4 mt-3 row">
Expand Down Expand Up @@ -464,7 +468,7 @@
// Collect appt date and set up squashed date for use below
$date_appt = $appointment['pc_eventDate'];
$date_squash = str_replace("-", "", $date_appt);
if (empty($appointment['room']) && ($logged_in) && ($setting_bootstrap_submenu != 'hide')) {
if (empty($appointment['room']) && ($logged_in ?? null) && ($setting_bootstrap_submenu != 'hide')) {
//Patient has not arrived yet, display MedEx Reminder info
//one icon per type of response.
//If there was a SMS dialog, display it as a mouseover/title
Expand Down Expand Up @@ -697,21 +701,21 @@ class="text-small"
$to_time = strtotime($newend);
$yestime = '0';
} else {
$from_time = strtotime($appointment['start_datetime']);
$from_time = (($appointment['start_datetime'] ?? null) ? strtotime($appointment['start_datetime']) : null);
$yestime = '1';
}

$timecheck = round(abs($to_time - $from_time) / 60, 0);
$timecheck = round(abs($to_time - ($from_time ?? null)) / 60, 0);
if ($timecheck >= $statalert && ($statalert > '0')) { // Determine if the time in status limit has been reached.
echo "<td class='text-center js-blink-infinite small' nowrap> "; // and if so blink
} else {
echo "<td class='detail text-center' nowrap> "; // and if not do not blink
}
if (($yestime == '1') && ($timecheck >= 1) && (strtotime($newarrive) != '')) {
echo text($timecheck . ' ' . ($timecheck >= 2 ? xl('minutes') : xl('minute')));
} elseif ($icon_here || $icon2_here || $icon_CALL) {
} elseif (($icon_here ?? null) || ($icon2_here ?? null) || ($icon_CALL ?? null)) {
echo "<span style='font-size:0.7rem;' onclick='return calendarpopup(" . attr_js($appt_eid) . "," . attr_js($date_squash) . ")'>" . implode($icon_here) . $icon2_here . "</span> " . $icon_CALL;
} elseif ($logged_in) {
} elseif ($logged_in ?? null) {
$pat = $MedEx->display->possibleModalities($appointment);
echo "<span style='font-size:0.7rem;' onclick='return calendarpopup(" . attr_js($appt_eid) . "," . attr_js($date_squash) . ")'>" . $pat['SMS'] . $pat['AVM'] . $pat['EMAIL'] . "</span>";
}
Expand Down Expand Up @@ -743,7 +747,7 @@ class="text-small"
echo text($timecheck2 . ' ' . ($timecheck2 >= 2 ? xl('minutes') : xl('minute')));
}
// end total time in practice
echo text($appointment['pc_time']); ?>
echo text($appointment['pc_time'] ?? ''); ?>
</td>
<td class="detail text-center">
<?php
Expand Down Expand Up @@ -803,7 +807,7 @@ class="text-small"

<?php
}
if (!$_REQUEST['flb_table']) { ?>
if (!($_REQUEST['flb_table'] ?? null)) { ?>
</div>
</div>
</div>
Expand Down Expand Up @@ -1014,10 +1018,10 @@ function openNewTopWindow(newpid, newencounterid) {
*/
function SMS_bot(pid) {
top.restoreSession();
var from = <?php echo js_escape($from_date); ?>;
var to = <?php echo js_escape($to_date); ?>;
var oefrom = <?php echo js_escape(oeFormatShortDate($from_date)); ?>;
var oeto = <?php echo js_escape(oeFormatShortDate($to_date)); ?>;
var from = <?php echo js_escape($from_date ?? ''); ?>;
var to = <?php echo js_escape($to_date ?? ''); ?>;
var oefrom = <?php echo js_escape(oeFormatShortDate($from_date ?? null)); ?>;
var oeto = <?php echo js_escape(oeFormatShortDate($to_date ?? null)); ?>;
window.open('../main/messages/messages.php?nomenu=1&go=SMS_bot&pid=' + encodeURIComponent(pid) + '&to=' + encodeURIComponent(to) + '&from=' + encodeURIComponent(from) + '&oeto=' + encodeURIComponent(oeto) + '&oefrom=' + encodeURIComponent(oefrom), 'SMS_bot', 'width=370,height=600,resizable=0');
return false;
}
Expand Down
11 changes: 6 additions & 5 deletions library/payment.inc.php
Expand Up @@ -61,7 +61,8 @@ function DistributionInsert($CountRow, $created_time, $user_id)
//It automatically pushes to next insurance for billing.
//In the screen a drop down of Ins1,Ins2,Ins3,Pat are given.The posting can be done for any level.
$Affected = 'no';
if (isset($_POST["Payment$CountRow"]) && (int)$_POST["Payment$CountRow"] > 0) {
// watch for payments less than $1, thanks @snailwell
if (isset($_POST["Payment$CountRow"]) && (floatval($_POST["Payment$CountRow"]) > 0)) {
if (trim(formData('type_name')) == 'insurance') {
if (trim(formData("HiddenIns$CountRow")) == 1) {
$AccountCode = "IPP";
Expand Down Expand Up @@ -100,7 +101,7 @@ function DistributionInsert($CountRow, $created_time, $user_id)
$Affected = 'yes';
}

if (!empty($_POST["AdjAmount$CountRow"]) && (($_POST["AdjAmount$CountRow"] ?? null) * 1 != 0)) {
if (!empty($_POST["AdjAmount$CountRow"]) && (floatval($_POST["AdjAmount$CountRow"] ?? null)) != 0) {
if (trim(formData('type_name')) == 'insurance') {
$AdjustString = "Ins adjust Ins" . trim(formData("HiddenIns$CountRow"));
$AccountCode = "IA";
Expand Down Expand Up @@ -132,7 +133,7 @@ function DistributionInsert($CountRow, $created_time, $user_id)
$Affected = 'yes';
}

if (!empty($_POST["Deductible$CountRow"]) && (($_POST["Deductible$CountRow"] ?? null) * 1 > 0)) {
if (!empty($_POST["Deductible$CountRow"]) && (floatval($_POST["Deductible$CountRow"] ?? null)) > 0) {
sqlBeginTrans();
$sequence_no = sqlQuery("SELECT IFNULL(MAX(sequence_no),0) + 1 AS increment FROM ar_activity WHERE pid = ? AND encounter = ?", array(trim(formData('hidden_patient_code')), trim(formData("HiddenEncounter$CountRow"))));
sqlStatement("insert into ar_activity set " .
Expand All @@ -156,7 +157,7 @@ function DistributionInsert($CountRow, $created_time, $user_id)
$Affected = 'yes';
}

if (!empty($_POST["Takeback$CountRow"]) && (($_POST["Takeback$CountRow"] ?? null) * 1 > 0)) {
if (!empty($_POST["Takeback$CountRow"]) && (floatval($_POST["Takeback$CountRow"] ?? null)) > 0) {
sqlBeginTrans();
$sequence_no = sqlQuery("SELECT IFNULL(MAX(sequence_no),0) + 1 AS increment FROM ar_activity WHERE pid = ? AND encounter = ?", array(trim(formData('hidden_patient_code')), trim(formData("HiddenEncounter$CountRow"))));
sqlStatement("insert into ar_activity set " .
Expand Down Expand Up @@ -212,7 +213,7 @@ function DistributionInsert($CountRow, $created_time, $user_id)
//last_level_closed gets increased. unless a follow up is required.
// in which case we'll allow secondary to be re setup to current setup.
// just not advancing last closed.
$tmp = (((!empty($_POST["Payment$CountRow"]) ? $_POST["Payment$CountRow"] : null) * 1) + ((!empty($_POST["AdjAmount$CountRow"]) ? $_POST["AdjAmount$CountRow"] : null) * 1));
$tmp = ((!empty($_POST["Payment$CountRow"]) ? floatval($_POST["Payment$CountRow"]) : null) + (!empty($_POST["AdjAmount$CountRow"]) ? floatval($_POST["AdjAmount$CountRow"]) : null));
if ((empty($_POST["FollowUp$CountRow"]) || ($_POST["FollowUp$CountRow"] != 'y')) && $tmp !== 0) {
sqlStatement("update form_encounter set last_level_closed='" .
trim(formData("HiddenIns$CountRow")) .
Expand Down
27 changes: 19 additions & 8 deletions portal/add_edit_event_user.php
Expand Up @@ -41,18 +41,29 @@
require_once("../interface/globals.php");
require_once("$srcdir/patient.inc");
require_once("$srcdir/forms.inc");
require_once("$srcdir/appointments.inc.php");

use OpenEMR\Core\Header;

// Things that might be passed by our opener.
//
$eid = $_GET['eid']; // only for existing events
$date = $_GET['date']; // this and below only for new events
$userid = $_GET['userid'];
$default_catid = $_GET['catid'] ? $_GET['catid'] : '5';
$patientid = $_GET['patid'];
$eid = $_GET['eid'] ?? null; // only for existing events
$date = $_GET['date'] ?? null; // this and below only for new events
$userid = $_GET['userid'] ?? null;
$default_catid = ($_GET['catid'] ?? null) ? $_GET['catid'] : '5';
$patientid = $_GET['patid'] ?? null;
//

// did someone tamper with eid?
$checkEidInAppt = false;
$patient_appointments = fetchAppointments('1970-01-01', '2382-12-31', $_SESSION['pid']);
$checkEidInAppt = array_search($eid, array_column($patient_appointments, 'pc_eid'));

if (!empty($eid) && !$checkEidInAppt) {
echo js_escape("error");
exit();
}

if ($date) {
$date = substr($date, 0, 4) . '-' . substr($date, 4, 2) . '-' . substr($date, 6);
} else {
Expand Down Expand Up @@ -118,7 +129,7 @@

// If we are saving, then save and close the window.
//
if ($_POST['form_action'] == "save") {
if (($_POST['form_action'] ?? null) == "save") {
//print_r($_POST);
//exit();
$event_date = fixDate($_POST['form_date']);
Expand Down Expand Up @@ -455,7 +466,7 @@
"1, " . (int)$_POST['facility'] . ")"); // FF stuff
} // INSERT single
} // else - insert
} elseif ($_POST['form_action'] == "delete") {
} elseif (($_POST['form_action'] ?? null) == "delete") {
// =======================================
// multi providers case
// =======================================
Expand Down Expand Up @@ -696,7 +707,7 @@
// default to the currently logged-in user
while ($urow = sqlFetchArray($ures)) {
echo "<option value='" . attr($urow['id']) . "'";
if (($urow['id'] == $_GET['userid']) || ($urow['id'] == $userid)) {
if (($urow['id'] == ($_GET['userid'] ?? null)) || ($urow['id'] == $userid)) {
echo " selected";
}
echo ">" . text($urow['lname']);
Expand Down
1 change: 1 addition & 0 deletions src/Services/PatientTrackerService.php
Expand Up @@ -365,6 +365,7 @@ public function getApptStatus($appointments)
$astat['count_all'] = count($appointments);
//group the appointment by status
foreach ($appointments as $appointment) {
($astat[$appointment['pc_apptstatus']] ?? null) ? $astat[$appointment['pc_apptstatus']] : $astat[$appointment['pc_apptstatus']] = 0;
$astat[$appointment['pc_apptstatus']] += 1;
}

Expand Down

0 comments on commit 235b191

Please sign in to comment.