From 842ffbe4d83dd19bde870e344967a132dccc984a Mon Sep 17 00:00:00 2001 From: stephen waite Date: Thu, 2 May 2024 19:54:09 -0400 Subject: [PATCH] fix: ccda zip import and php warnings and deprecations (#7416) * fix: php warns, deprecates * fix: php warns, deprecates openemr-cmd irp * check for non zero component count to start ccda zip import * fix couple other php warnings * remove conditional per Jerry's review --- .../Controller/CarecoordinationController.php | 10 +++++++--- .../Carecoordination/Controller/CcdController.php | 1 + .../Model/CarecoordinationTable.php | 22 +++++++++++----------- library/classes/Document.class.php | 2 +- src/Services/Cda/CdaTemplateImportDispose.php | 6 +++--- src/Services/Cda/CdaTemplateParse.php | 20 +++++++++++--------- 6 files changed, 34 insertions(+), 27 deletions(-) diff --git a/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Controller/CarecoordinationController.php b/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Controller/CarecoordinationController.php index f368717ff..833854465 100644 --- a/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Controller/CarecoordinationController.php +++ b/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Controller/CarecoordinationController.php @@ -952,10 +952,14 @@ class CarecoordinationController extends AbstractActionController $patientCountHash[$patientNameIndex]; } } elseif ($componentCount == ($patientDocumentsIndex + 1)) { - if ($patientCountHash[$patientNameIndex] > $maxDocuments) { + if ($patientCountHash[$patientNameIndex] ?? '' > $maxDocuments) { $shouldDeleteIndex = true; } else { - $patientCountHash[$patientNameIndex] += 1; + if (!empty($patientCountHash[$patientNameIndex])) { + $patientCountHash[$patientNameIndex] += 1; + } else { + $patientCountHash[$patientNameIndex] = 0; + } } } else { $shouldDeleteIndex = true; @@ -1015,7 +1019,7 @@ class CarecoordinationController extends AbstractActionController $componentCount = count($fileComponents); // now we need to do our document import for our ccda for this patient - if ($componentCount == 2) { + if ($componentCount > 0) { // let's process the ccda $file_name = basename($stat['name']); diff --git a/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Controller/CcdController.php b/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Controller/CcdController.php index 8d50f5919..67528885b 100644 --- a/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Controller/CcdController.php +++ b/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Controller/CcdController.php @@ -36,6 +36,7 @@ class CcdController extends AbstractActionController protected $documentsTable; + protected $listenerObject; /** * @var Documents\Controller\DocumentsController */ diff --git a/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Model/CarecoordinationTable.php b/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Model/CarecoordinationTable.php index 9c4177a76..b3e7315ed 100644 --- a/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Model/CarecoordinationTable.php +++ b/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Model/CarecoordinationTable.php @@ -321,15 +321,15 @@ class CarecoordinationTable extends AbstractTableGateway } else { $tel = $xml['recordTarget']['patientRole']['telecom'] ?? ''; if (!empty($tel)) { - if ($tel['use'] == 'MC') { + if ($tel['use'] ?? '' == 'MC') { $this->documentData['field_name_value_array']['patient_data'][1]['phone_cell'] = preg_replace('/[^0-9]+/i', '', ($tel['value'] ?? null)); - } elseif ($tel['use'] == 'HP') { + } elseif ($tel['use'] ?? '' == 'HP') { $this->documentData['field_name_value_array']['patient_data'][1]['phone_home'] = preg_replace('/[^0-9]+/i', '', ($tel['value'] ?? null)); - } elseif ($tel['use'] == 'WP') { + } elseif ($tel['use'] ?? '' == 'WP') { $this->documentData['field_name_value_array']['patient_data'][1]['phone_biz'] = preg_replace('/[^0-9]+/i', '', ($tel['value'] ?? null)); - } elseif ($tel['use'] == 'EC') { + } elseif ($tel['use'] ?? '' == 'EC') { $this->documentData['field_name_value_array']['patient_data'][1]['phone_contact'] = preg_replace('/[^0-9]+/i', '', ($tel['value'] ?? null)); - } elseif (stripos($tel['value'], 'mailto:') !== false) { + } elseif (stripos($tel['value'] ?? '', 'mailto:') !== false) { $regex = "/([a-z0-9_\-\.]+)" . "@" . "([a-z0-9-]{1,64})" . "\." . "([a-z]{2,10})/i"; $mail = explode('mailto:', ($tel['value'] ?? null)); $this->documentData['field_name_value_array']['patient_data'][1]['email'] = null; @@ -338,7 +338,7 @@ class CarecoordinationTable extends AbstractTableGateway $this->documentData['field_name_value_array']['patient_data'][1]['email'] = $mailto; } } else { - $this->documentData['field_name_value_array']['patient_data'][1]['phone_contact'] = preg_replace('/[^0-9]+/i', '', ($tel['value'] ?? null)); + $this->documentData['field_name_value_array']['patient_data'][1]['phone_contact'] = preg_replace('/[^0-9]+/i', '', ($tel['value'] ?? '')); } } } @@ -519,7 +519,7 @@ class CarecoordinationTable extends AbstractTableGateway $item = trim($item['value'] ?? ''); } } else { - $item = trim($item); + $item = trim($item ?? ''); } $resfield[] = ['table_name' => trim($row['table_name']), 'field_name' => trim($itemKey), 'field_value' => $item, 'entry_identification' => trim($row['entry_identification'])]; } @@ -582,7 +582,7 @@ class CarecoordinationTable extends AbstractTableGateway // patient UUID from exported $uuid = trim($newdata['patient_data']['referrerID']); // have we already imported for this UUID? - $pid_exist = sqlQuery("SELECT pid FROM `patient_data` WHERE `referrerID` = ? ORDER BY `pid` DESC Limit 1", array($uuid))['pid']; + $pid_exist = sqlQuery("SELECT pid FROM `patient_data` WHERE `referrerID` = ? ORDER BY `pid` DESC Limit 1", array($uuid))['pid'] ?? ''; if (!empty($pid_exist) && is_numeric($pid_exist ?? null)) { // We did so let check the type. If encounters then a CDA $enc_exist = sqlQuery("SELECT COUNT(`encounter`) as `cnt` FROM `form_encounter` WHERE `pid` = ? AND `encounter` > 0", array((int)$pid_exist))['cnt'] ?? 0; @@ -677,9 +677,9 @@ class CarecoordinationTable extends AbstractTableGateway $arr_allergies['lists2'][$c]['outcome'] = $newdata['lists2']['outcome']; $c++; } elseif ($table == 'encounter') { - $arr_encounter['encounter'][$k]['extension'] = $newdata['encounter']['extension']; - $arr_encounter['encounter'][$k]['root'] = $newdata['encounter']['root']; - $arr_encounter['encounter'][$k]['date'] = $newdata['encounter']['date']; + $arr_encounter['encounter'][$k]['extension'] = $newdata['encounter']['extension'] ?? ''; + $arr_encounter['encounter'][$k]['root'] = $newdata['encounter']['root'] ?? ''; + $arr_encounter['encounter'][$k]['date'] = $newdata['encounter']['date'] ?? null; $arr_encounter['encounter'][$k]['date_end'] = $newdata['encounter']['date_end'] ?? null; $arr_encounter['encounter'][$k]['provider_npi'] = $newdata['encounter']['provider_npi']; diff --git a/library/classes/Document.class.php b/library/classes/Document.class.php index 34b015399..9b2772c7d 100644 --- a/library/classes/Document.class.php +++ b/library/classes/Document.class.php @@ -1006,7 +1006,7 @@ class Document extends ORDataObject * Else resume the local file storage */ - if ($GLOBALS['documentStoredRemotely']) { + if ($GLOBALS['documentStoredRemotely'] ?? '') { return xlt("Document was uploaded to remote storage"); // terminate processing } diff --git a/src/Services/Cda/CdaTemplateImportDispose.php b/src/Services/Cda/CdaTemplateImportDispose.php index 67d9b9cda..dc4bb6b9c 100644 --- a/src/Services/Cda/CdaTemplateImportDispose.php +++ b/src/Services/Cda/CdaTemplateImportDispose.php @@ -607,8 +607,8 @@ class CdaTemplateImportDispose if (!empty($value['code_text'] ?? null)) { $cat = explode('|', $value['code_text'] ?? null); $catname = trim($cat[0]); - $reason = trim($cat[1]); - $pc_catid = sqlQuery("SELECT pc_catid FROM `openemr_postcalendar_categories` Where `pc_catname` = ?", array($catname))['pc_catid']; + $reason = trim($cat[1] ?? ''); + $pc_catid = sqlQuery("SELECT pc_catid FROM `openemr_postcalendar_categories` Where `pc_catname` = ?", array($catname))['pc_catid'] ?? ''; } if (empty($pc_catid) && !empty($catname)) { // create a new category to match the import @@ -2143,7 +2143,7 @@ class CdaTemplateImportDispose ORDER BY fe.encounter DESC, fe.date DESC Limit 1"; $rtn = sqlQuery($sql, array($item_date, $item_pid)); - return (int)$rtn['encounter'] ?: 0; + return (int)($rtn['encounter'] ?? '') ?: 0; } /** diff --git a/src/Services/Cda/CdaTemplateParse.php b/src/Services/Cda/CdaTemplateParse.php index c6ef443a0..663b15119 100644 --- a/src/Services/Cda/CdaTemplateParse.php +++ b/src/Services/Cda/CdaTemplateParse.php @@ -373,12 +373,12 @@ class CdaTemplateParse $i += count($this->templateData['field_name_value_array']['encounter']); } - $this->templateData['field_name_value_array']['encounter'][$i]['extension'] = $entry['encounter']['id']['extension']; - $this->templateData['field_name_value_array']['encounter'][$i]['root'] = $entry['encounter']['id']['root']; + $this->templateData['field_name_value_array']['encounter'][$i]['extension'] = $entry['encounter']['id']['extension'] ?? ''; + $this->templateData['field_name_value_array']['encounter'][$i]['root'] = $entry['encounter']['id']['root'] ?? ''; $this->templateData['field_name_value_array']['encounter'][$i]['date'] = ($entry['encounter']['effectiveTime']['value'] ?? null) ?: $entry['encounter']['effectiveTime']['low']['value'] ?? null; $this->templateData['field_name_value_array']['encounter'][$i]['date_end'] = $entry['encounter']['effectiveTime']['high']['value'] ?? null; - $code_type = $entry['encounter']['code']['codeSystemName'] ?: $entry['encounter']['code']['codeSystem'] ?? ''; + $code_type = $entry['encounter']['code']['codeSystemName'] ?? '' ?: $entry['encounter']['code']['codeSystem'] ?? ''; $code_text = $entry['encounter']['code']['displayName'] ?? ''; $code = $this->codeService->resolveCode($entry['encounter']['code']['code'], $code_type, $code_text); $this->templateData['field_name_value_array']['encounter'][$i]['code'] = $code['formatted_code']; @@ -495,18 +495,18 @@ class CdaTemplateParse } $this->templateData['field_name_value_array']['lists2'][$i]['type'] = 'allergy'; - $this->templateData['field_name_value_array']['lists2'][$i]['extension'] = $entry['act']['id']['extension']; + $this->templateData['field_name_value_array']['lists2'][$i]['extension'] = $entry['act']['id']['extension'] ?? ''; $this->templateData['field_name_value_array']['lists2'][$i]['begdate'] = $entry['act']['effectiveTime']['low']['value'] ?? null; $this->templateData['field_name_value_array']['lists2'][$i]['enddate'] = $entry['act']['effectiveTime']['high']['value'] ?? null; $this->templateData['field_name_value_array']['lists2'][$i]['list_code'] = $entry['act']['entryRelationship']['observation']['participant']['participantRole']['playingEntity']['code']['code'] ?? ''; $this->templateData['field_name_value_array']['lists2'][$i]['list_code_text'] = $entry['act']['entryRelationship']['observation']['participant']['participantRole']['playingEntity']['code']['displayName']; - $this->templateData['field_name_value_array']['lists2'][$i]['codeSystemName'] = $entry['act']['entryRelationship']['observation']['participant']['participantRole']['playingEntity']['code']['codeSystemName']; + $this->templateData['field_name_value_array']['lists2'][$i]['codeSystemName'] = $entry['act']['entryRelationship']['observation']['participant']['participantRole']['playingEntity']['code']['codeSystemName'] ?? ''; $this->templateData['field_name_value_array']['lists2'][$i]['outcome'] = $entry['act']['entryRelationship']['observation']['entryRelationship'][1]['observation']['value']['code'] ?? ''; $this->templateData['field_name_value_array']['lists2'][$i]['severity_al_code'] = $entry['act']['entryRelationship']['observation']['entryRelationship'][2]['observation']['value']['code'] ?? ''; $this->templateData['field_name_value_array']['lists2'][$i]['severity_al'] = $entry['act']['entryRelationship']['observation']['entryRelationship'][2]['observation']['value']['code'] ?? ''; - $this->templateData['field_name_value_array']['lists2'][$i]['status'] = $entry['act']['entryRelationship']['observation']['entryRelationship'][0]['observation']['value']['displayName']; + $this->templateData['field_name_value_array']['lists2'][$i]['status'] = $entry['act']['entryRelationship']['observation']['entryRelationship'][0]['observation']['value']['displayName'] ?? ''; $this->templateData['field_name_value_array']['lists2'][$i]['reaction'] = $entry['act']['entryRelationship']['observation']['entryRelationship'][1]['observation']['value']['code'] ?? ''; - $this->templateData['field_name_value_array']['lists2'][$i]['reaction_text'] = $entry['act']['entryRelationship']['observation']['entryRelationship'][1]['observation']['value']['displayName']; + $this->templateData['field_name_value_array']['lists2'][$i]['reaction_text'] = $entry['act']['entryRelationship']['observation']['entryRelationship'][1]['observation']['value']['displayName'] ?? ''; $this->templateData['field_name_value_array']['lists2'][$i]['modified_time'] = $entry['act']['entryRelationship']['observation']['performer']['assignedEntity']['time']['value'] ?? null; $this->templateData['entry_identification_array']['lists2'][$i] = $i; } elseif (!empty($entry['observation']['participant']['participantRole']['playingEntity']['code']['code'])) { @@ -667,7 +667,7 @@ class CdaTemplateParse $this->templateData['field_name_value_array']['immunization'][$i]['represented_organization'] = $entry['substanceAdministration']['performer']['assignedEntity']['representedOrganization']['name'] ?? null; $this->templateData['field_name_value_array']['immunization'][$i]['represented_organization_tele'] = $entry['substanceAdministration']['performer']['assignedEntity']['representedOrganization']['telecom'] ?? null; - if ($entry['substanceAdministration']['entryRelationship']['observation']['value']['code']) { + if (($entry['substanceAdministration']['entryRelationship'] ?? '') && $entry['substanceAdministration']['entryRelationship']['observation']['value']['code']) { $code = $this->codeService->resolveCode( $entry['substanceAdministration']['entryRelationship']['observation']['value']['code'], $entry['substanceAdministration']['entryRelationship']['observation']['value']['codeSystemName'] ?: $entry['substanceAdministration']['entryRelationship']['observation']['value']['codeSystem'] ?? '', @@ -1527,7 +1527,9 @@ class CdaTemplateParse $ccnt = 0; if ($component['section']['entry'][0] ?? '') { foreach ($component['section']['entry'] as $key => $value) { - $this->fetchFunctionalCognitiveStatusData($value, $component['section']['text'][$ccnt]); + if (!empty($component['section']['text'][$ccnt])) { + $this->fetchFunctionalCognitiveStatusData($value, $component['section']['text'][$ccnt]); + } $ccnt++; } } else { -- 2.11.4.GIT