Link to home
Start Free TrialLog in
Avatar of Bruce Gust
Bruce GustFlag for United States of America

asked on

Could you check my logic on this, please?

The dealbreaker, at this point, is the presence of an array. At least, that's what I've been able to deduce thus far.

Here's the first part of the process:

protected function processStatementSql ($sql) {

        $statements = StatementImage::runQuery($sql);
        $ret = array();

        //Second and Third DB Calls
        //TXN TABLE STUFF
        // NOTE - I don't know there is a reason to process these as separate queries
        // and I think they can be reasonably combined with the query held in getSQL()
        // and processed through to get the same dataset more quickly.
        if ($statements) {
            foreach($statements as $st) {
                $accountid = $st['AccountID'];

                if (!$st['StatementRollUp'] || $st['templateid'] == '9') {
                    $st['newtxns'] = StatementImage::getNewTransactions($st, $st['showphysician'] == '1');
                } else {
                    $st['newtxns'] = array();
                }

Open in new window


Look at line 15. $statements is a SELECT statement that's just been fired. We're going to parse it out as an array and when we get to $st['StatementRollUp'] we pause and ask a question...

if (!$st['StatementRollUp'] || $st['templateid'] == '9') {

Which, in plain language is asking, if the StatementRollUp value is not defined OR the template id is 9, then proceed with the getNewTransactions method. At which point, you've defining an index within an array ($st['newtxns'])  as the values represented by the getNewTransactions method.

Otherwise...

You've got the $st['newtxns'] array, but there's nothing in it.

The very next line of the code is this:

foreach($st['newtxns'] as $txn){
                    $st['lastclaimdate'] = $txn['firstdos'] < $st['lastclaimdate'] || $st['lastclaimdate'] === null ? $txn['firstdos'] : $st['lastclaimdate'];
                }

Open in new window


So, now that $st['newtxns'] is $txn.

I know. It's a mess. But be that as it may, I've been hired to fix what's there and not write new code. There's six years worth of original programming and the layers of nonsense are eternal.

So, here comes that $txn array and it's being looked at in the context of another IF statement:

  if (isset($encounter['txns'])) {

From here, the PDF that's being generated is formatted according to the result of this IF statement. My thought is that if your $encounter['txns'] array is devoid of content, then the result of the above IF clause is FALSE.

Agreed?
SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bruce Gust

ASKER

So...

It doesn't have anything to do with content. If both the array and the index have been defined, then this:

 if (isset($encounter['txns'])) {

...is TRUE. Both the array and the index have been defined and what's IN the array is not what's being looked at as much as it's THAT it's an array.

Yes?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial