Skip to content

Commit

Permalink
fix: php8 errors in eye form (openemr#7924)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenwaite authored Jan 16, 2025
1 parent 3f57f1f commit b188c4f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
17 changes: 11 additions & 6 deletions interface/forms/eye_mag/php/eye_mag_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1701,7 +1701,9 @@ function build_PMSFH($pid)
$diags = explode(";", $row['diagnosis']);
foreach ($diags as $diag) {
$codedesc = lookup_code_descriptions($diag);
list($codetype, $code) = explode(':', $diag);
if (strpos($diag, ':') !== false) {
list($codetype, $code) = explode(':', $diag);
}
$order = array("\r\n", "\n","\r");
$codedesc = str_replace($order, '', $codedesc);
$codetext .= text($diag) . " (" . text($codedesc) . ")";
Expand Down Expand Up @@ -2164,6 +2166,7 @@ function display_PMSFH($rows, $view = "pending", $min_height = "min-height:344px
</tr>
</table>
';
$subtype_Meds[$item['row_subtype']]['table'] = $subtype_Meds[$item['row_subtype']]['table'] ?? '';
$subtype_Meds[$item['row_subtype']]['table'] .= "<span name='QP_PMH_" . attr($item['rowid']) . "' href='#PMH_anchor' id='QP_PMH_" . attr($item['rowid']) . "'
onclick=\"alter_issue2(" . attr_js($item['rowid']) . ",\"Eye Meds\"," . attr_js($index) . ");\">" . text($item['title']) . "</span><br />";
$index++;
Expand Down Expand Up @@ -4432,7 +4435,7 @@ function start_your_engines($FIELDS)
//This option is run for 3 conditions at present:
//CSME/NVD/NVE per eye. It is the same every time so only do it once, per eye.
//Did we already code this? If so move on.
if ($hit_DM[$side1] == '1') {
if (!empty($hit_DM) && ($hit_DM[$side1] ?? '') == '1') {
continue;
}

Expand Down Expand Up @@ -4550,7 +4553,7 @@ function start_your_engines($FIELDS)
//or is there a code for both eyes?
if ($side1 == "OS") {
$count = '0';
for ($i = 0; $i < count($codes_found[$sub_term]); $i++) {
for ($i = 0; $i < count($codes_found[$sub_term] ?? []); $i++) {
$swap = "OD";
$codes_found[$sub_term][$i]['title'] = str_replace($swap, "OU", $codes_found[$sub_term][$i]['title']);
break 2;
Expand Down Expand Up @@ -4645,7 +4648,7 @@ function start_your_engines($FIELDS)

if ($side1 == "OS") {
$count = '0';
for ($i = 0; $i < count($codes_found[$sub_term]); $i++) {
for ($i = 0; $i < count($codes_found[$sub_term] ?? []); $i++) {
$swap = "OD";
$codes_found[$sub_term][$i]['title'] = str_replace($swap, "OU", $codes_found[$sub_term][$i]['title']);
break 2;
Expand Down Expand Up @@ -4718,7 +4721,7 @@ function coding_carburetor($term, $field)
'code' => $row['code'],
'code_text' => $row['code_text'],
'code_type' => $row['code_type_name'],
'code_desc' => $row['code_desc']
'code_desc' => $row['code_desc'] ?? ''
);
$codes[] = $newdata;
}
Expand Down Expand Up @@ -5092,7 +5095,8 @@ function display_GlaucomaFlowSheet($pid, $bywhat = 'byday')
$count_Meds = count($PMSFH[0]['Medication']);
if ($count_Meds > '0') {
foreach ($PMSFH[0]['Medication'] as $drug) {
if (($drug['row_subtype'] == "eye") && (strtotime($drug['enddate']) < strtotime($visit_date) ) && ($drug['status'] != "Inactive")) {
if (($drug['row_subtype'] == "eye") && (strtotime($drug['enddate'] ?? '') < strtotime($visit_date ?? '') ) && ($drug['status'] != "Inactive")) {
$current_drugs = $current_drugs ?? '';
$current_drugs .= "<tr><td colspan='2' class='GFS_td_1'><span name='QP_PMH_" . attr($drug['rowid']) . "' href='#PMH_anchor' id='QP_PMH_" . attr($drug['rowid']) . "'
onclick=\"alter_issue2(" . attr_js($drug['rowid']) . ",'Medication','" . $i . "');\">" . text($drug['title']) . "</span></td>
<td class='GFS_td'>" . text(oeFormatShortDate($drug['begdate'])) . "</td></tr>";
Expand Down Expand Up @@ -5267,6 +5271,7 @@ function display_GlaucomaFlowSheet($pid, $bywhat = 'byday')
$cups = "<tr><td class='GFS_td_1 " . $hideme . " '>" . text($visit['exam_date']) . "</td><td class='GFS_td " . $hideme . "' style='border:1pt dotted gray;'>" . text($visit['ODCUP']) . "</td><td class='GFS_td " . $hideme . "' style='border:1pt dotted gray;''>" . text($visit['OSCUP']) . "</td></tr>";
}

$DISCS_chart = $DISCS_chart ?? '';
$DISCS_chart .= '"1",';
$count++;
} else {
Expand Down
2 changes: 2 additions & 0 deletions interface/forms/eye_mag/save.php
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,8 @@
if ($_POST['PLAN'][$i] == '') {
continue;
}
$fields = $fields ?? [];
$fields['PLAN'] = $fields['PLAN'] ?? '';
$fields['PLAN'] .= $_POST['PLAN'][$i] . "|"; //this makes an entry for form_eyemag: PLAN
$ORDERS_sql = "INSERT INTO form_eye_mag_orders (form_id,pid,ORDER_DETAILS,ORDER_PRIORITY,ORDER_STATUS,ORDER_DATE_PLACED,ORDER_PLACED_BYWHOM) VALUES (?,?,?,?,?,?,?)";
$okthen = sqlQuery($ORDERS_sql, array($form_id, $pid, $_POST['PLAN'][$i], $i, 'pending', $visit_date, $providerID));
Expand Down
3 changes: 2 additions & 1 deletion interface/forms/eye_mag/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -3942,6 +3942,7 @@ class="PRIORS_class PRIORS"><i class="fa fa-spinner fa-spin"></i>
while ($plan_row = sqlFetchArray($PLAN_results)) {
$PLAN_arr[] = $plan_row;
}
$found = 0;
while ($row = sqlFetchArray($TODO_data)) {
$arrPLAN[$counter]['option_id'] = $row['option_id'];
$arrPLAN[$counter]['title'] = $row['title'];
Expand Down Expand Up @@ -4360,7 +4361,7 @@ function sel_diagnosis(target,term) {
//also add in any obj.Clinical data if the form was already opened
$codes_found = start_your_engines($encounter_data);
if ($codes_found) { ?>
obj.Clinical = [<?php echo json_encode($codes_found[0]); ?>];
obj.Clinical = [<?php echo json_encode($codes_found[0] ?? ''); ?>];
<?php
} ?>

Expand Down

0 comments on commit b188c4f

Please sign in to comment.