PHP Warnings in Fee Sheet

I get the following 2 errors in the apache2 logs several hundred times a day.

PHP Warning:  Undefined array key "" in /var/www/html/openemr/interface/forms/fee_sheet/new.php on line 1046, referer: http://10.0.1.84/openemr/interface/forms/fee_sheet/new.php?rde=0&addmore=0
PHP Warning:  Trying to access array offset on value of type null in /var/www/html/openemr/interface/forms/fee_sheet/new.php on line 1046, referer: http://10.0.1.84/openemr/interface/forms/fee_sheet/new.php?rde=0&addmore=0

The section of code in that file is as follows

// Create drop-lists based on categories defined within the codes.
                                $pres = sqlStatement("SELECT option_id, title FROM list_options " .
                                "WHERE list_id = 'superbill' AND activity = 1 ORDER BY seq");
                            while ($prow = sqlFetchArray($pres)) {
                                global $code_types;
                                ++$i;
                                echo ($i <= 1) ? " <tr>\n" : "";
                                echo "  <td class='text-center text-nowrap' width='50%'>\n";
                                echo "   <select class='form-control' onchange='codeselect(this)'>\n";
                                echo "    <option value=''> " . text(xl_list_label($prow['title'])) . "\n";
                                $res = sqlStatement("SELECT code_type, code, code_text,modifier FROM codes " .
                                "WHERE superbill = ? AND active = 1 " .
                                "ORDER BY code_text", array($prow['option_id']));
                                while ($row = sqlFetchArray($res)) {
                                    $ctkey = $fs->alphaCodeType($row['code_type']);
                                    if ($code_types[$ctkey]['nofs']) {
                                        continue;
                                    }
                                    echo "    <option value='" . attr($ctkey) . "|" .
                                    attr($row['code']) . ':' . attr($row['modifier']) . "|'>" . text($row['code_text']) . "</option>\n";
                                }
                                echo "   </select>\n";
                                echo "  </td>\n";
                                if ($i >= $FEE_SHEET_COLUMNS) {
                                    echo " </tr>\n";
                                    $i = 0;
                                }
                            }

With line 1046 being the following line

if ($code_types[$ctkey]['nofs']) {

This is probably a warning that php 8 generates that php 7 didn’t. But I’m trying to get the warnings that show up in the error log hundreds of times a day fixed so that if any real problems show up they aren’t obscured by 1000’s of needless warnings.

I’m running oemr v7(2) on ubuntu 22.04 with php 8.1.

If anyone can suggest a way to modify the code so this warning doesn’t happen I’d appreciate it.
Thanks

hi @bearzillasquatch , have you tried to play with the easy-dev docker environment. There’s some neat ways to get in and see the code in action.

@stephenwaite I will give that a shot. It looks very interesting. Thanks.

1 Like