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 6f884ef6628..943b3e9ca32 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 @@ -942,10 +942,14 @@ private function sanitizeZip($zipLocation) $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; @@ -1005,7 +1009,7 @@ private function importZipUpload($request) $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 8d50f591989..67528885b1f 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 9c4177a7629..b3e7315ed54 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 @@ public function importCore($xml_content, $doc_id = null): void } 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 @@ public function importCore($xml_content, $doc_id = null): void $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 @@ public function insert_patient($audit_master_id, $document_id) $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 @@ public function insert_patient($audit_master_id, $document_id) // 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 @@ public function insert_patient($audit_master_id, $document_id) $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 34b01539953..9b2772c7d04 100644 --- a/library/classes/Document.class.php +++ b/library/classes/Document.class.php @@ -1006,7 +1006,7 @@ function createDocument( * 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 dea808eb52f..45e4dc42ca4 100644 --- a/src/Services/Cda/CdaTemplateImportDispose.php +++ b/src/Services/Cda/CdaTemplateImportDispose.php @@ -606,8 +606,8 @@ public function InsertEncounter($enc_array, $pid, CarecoordinationTable $carecoo 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 @@ -2142,7 +2142,7 @@ public function findClosestEncounter($item_date, $item_pid): int 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 c6ef443a0fb..663b1511910 100644 --- a/src/Services/Cda/CdaTemplateParse.php +++ b/src/Services/Cda/CdaTemplateParse.php @@ -373,12 +373,12 @@ public function fetchEncounterPerformed($entry): void $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 @@ public function fetchAllergyIntoleranceObservation($entry) } $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 @@ public function fetchImmunizationData($entry): void $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 @@ public function functionalCognitiveStatus($component) $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 {