From 6c78b1545764f347c2a4ffb55269ecdfbb566216 Mon Sep 17 00:00:00 2001 From: Jerry Padgett Date: Thu, 13 Aug 2020 02:32:08 -0400 Subject: [PATCH] CCM (#3847) * CCM and various other fixes - deprecated create_function replace w/anonymous function - focus ccm import and review. - some work on immunizations. * fix reverted code and Travis --- .../src/Application/Plugin/CommonPlugin.php | 117 ++-- .../Controller/CarecoordinationController.php | 436 ++++++------- .../Model/EncounterccdadispatchTable.php | 689 +++++++++++---------- .../Model/EncountermanagerTable.php | 10 +- .../view/carecoordination/setup/index.phtml | 3 + .../view/layout/{setup.phtml => mapper.phtml} | 35 +- .../Carecoordination/view/layout/setup.phtml | 8 +- .../Controller/ImmunizationController.php | 496 +++++++-------- .../src/Immunization/Form/ImmunizationForm.php | 199 +++--- .../src/Immunization/Model/ImmunizationTable.php | 464 +++++++------- .../libs/Controller/PortalPatientController.php | 6 +- 11 files changed, 1242 insertions(+), 1221 deletions(-) copy interface/modules/zend_modules/module/Carecoordination/view/layout/{setup.phtml => mapper.phtml} (61%) rewrite interface/modules/zend_modules/module/Immunization/src/Immunization/Form/ImmunizationForm.php (81%) rewrite interface/modules/zend_modules/module/Immunization/src/Immunization/Model/ImmunizationTable.php (60%) diff --git a/interface/modules/zend_modules/module/Application/src/Application/Plugin/CommonPlugin.php b/interface/modules/zend_modules/module/Application/src/Application/Plugin/CommonPlugin.php index 36d5add10..8139cc5a3 100644 --- a/interface/modules/zend_modules/module/Application/src/Application/Plugin/CommonPlugin.php +++ b/interface/modules/zend_modules/module/Application/src/Application/Plugin/CommonPlugin.php @@ -22,51 +22,52 @@ class CommonPlugin extends AbstractPlugin { protected $application; - /** - * Application Table Object - * Listener Object - * @param type $container ContainerInterface - */ + /** + * Application Table Object + * Listener Object + * + * @param type $container ContainerInterface + */ public function __construct(ContainerInterface $container) { // TODO: this is crazy... why do we grab the service locator so we can load the db adapter? // is there some db related state that is being loaded here in a global type of way that we aren't aware of?? Or can we just remove this line? $container->get('Laminas\Db\Adapter\Adapter'); - $this->application = new ApplicationTable(); + $this->application = new ApplicationTable(); $this->listenerObject = new Listener(); } - /** - * Function checkACL - * Plugin functions are easily access from any where in the project - * Call the ACL Check function zAclCheck from ApplicationTable - * - * @param int $useID - * @param string $sectionID - * @return type - */ + /** + * Function checkACL + * Plugin functions are easily access from any where in the project + * Call the ACL Check function zAclCheck from ApplicationTable + * + * @param int $useID + * @param string $sectionID + * @return type + */ public function checkACL($useID, $sectionID) { return $this->application->zAclCheck($useID, $sectionID); } - /** - * Keyword color hightlight (primary keyword and secondary) - * ? - The question mark used for omit the error. - * Error occur in second word of the search keyword, - * if maches any of the letter in the html element - */ + /** + * Keyword color hightlight (primary keyword and secondary) + * ? - The question mark used for omit the error. + * Error occur in second word of the search keyword, + * if maches any of the letter in the html element + */ public function hightlight($str, $keywords = '') { - $keywords = preg_replace('/\s\s+/', ' ', strip_tags(trim($keywords))); - $style = '???'; - $style_i = 'highlight_i'; - $var = ''; + $keywords = preg_replace('/\s\s+/', ' ', strip_tags(trim($keywords))); + $style = '???'; + $style_i = 'highlight_i'; + $var = ''; foreach (explode(' ', $keywords) as $keyword) { - $replacement = "" . trim($keyword) . ""; - $var .= $replacement . " "; - $str = str_ireplace($keyword, $replacement, $str); + $replacement = "" . trim($keyword) . ""; + $var .= $replacement . " "; + $str = str_ireplace($keyword, $replacement, $str); } $str = str_ireplace(rtrim($var), "" . trim($keywords) . "", $str); @@ -78,7 +79,7 @@ class CommonPlugin extends AbstractPlugin public function date_format($date, $output_format, $input_format) { - $this->application = new ApplicationTable(); + $this->application = new ApplicationTable(); $date_formatted = $this->application->fixDate($date, $output_format, $input_format); return $date_formatted; } @@ -96,31 +97,31 @@ class CommonPlugin extends AbstractPlugin */ public function insert_ccr_into_audit_data($var) { - $appTable = new ApplicationTable(); - $audit_master_id_to_delete = $var['audit_master_id_to_delete']; + $appTable = new ApplicationTable(); + $audit_master_id_to_delete = $var['audit_master_id_to_delete']; $approval_status = $var['approval_status']; - $type = $var['type']; + $type = $var['type']; $ip_address = $var['ip_address']; - $field_name_value_array = $var['field_name_value_array']; + $field_name_value_array = $var['field_name_value_array']; $entry_identification_array = $var['entry_identification_array']; if ($audit_master_id_to_delete) { - $qry = "DELETE from audit_details WHERE audit_master_id=?"; + $qry = "DELETE from audit_details WHERE audit_master_id=?"; $appTable->zQuery($qry, array($audit_master_id_to_delete)); - $qry = "DELETE from audit_master WHERE id=?"; + $qry = "DELETE from audit_master WHERE id=?"; $appTable->zQuery($qry, array($audit_master_id_to_delete)); } $master_query = "INSERT INTO audit_master SET pid = ?,approval_status = ?,ip_address = ?,type = ?"; - $result = $appTable->zQuery($master_query, array(0,$approval_status,$ip_address,$type)); - $audit_master_id = $result->getGeneratedValue(); + $result = $appTable->zQuery($master_query, array(0, $approval_status, $ip_address, $type)); + $audit_master_id = $result->getGeneratedValue(); $detail_query = "INSERT INTO `audit_details` (`table_name`, `field_name`, `field_value`, `audit_master_id`, `entry_identification`) VALUES "; $detail_query_array = array(); foreach ($field_name_value_array as $key => $val) { foreach ($field_name_value_array[$key] as $cnt => $field_details) { foreach ($field_details as $field_name => $field_value) { - $detail_query .= "(? ,? ,? ,? ,?),"; + $detail_query .= "(? ,? ,? ,? ,?),"; $detail_query_array[] = $key; $detail_query_array[] = trim($field_name); if (is_array($field_value)) { @@ -152,27 +153,27 @@ class CommonPlugin extends AbstractPlugin $res = $appTable->zQuery("SELECT * FROM list_options WHERE list_id=? ORDER BY seq, title", array($list_id)); $i = 0; if ($opt == 'search') { - $rows[$i] = array ( - 'value' => 'all', - 'label' => $this->listenerObject->z_xlt('All'), - 'selected' => true, - ); - $i++; + $rows[$i] = array( + 'value' => 'all', + 'label' => $this->listenerObject->z_xlt('All'), + 'selected' => true, + ); + $i++; } elseif ($opt == '') { - $rows[$i] = array ( - 'value' => '', - 'label' => $this->listenerObject->z_xlt('Unassigned'), - 'disabled' => false + $rows[$i] = array( + 'value' => '', + 'label' => $this->listenerObject->z_xlt('Unassigned'), + 'disabled' => false ); $i++; } foreach ($res as $row) { $sel = ($row['option_id'] == $selected) ? true : false; - $rows[$i] = array ( - 'value' => htmlspecialchars($row['option_id'], ENT_QUOTES), - 'label' => $this->listenerObject->z_xlt($row['title']), - 'selected' => $sel, + $rows[$i] = array( + 'value' => htmlspecialchars($row['option_id'], ENT_QUOTES), + 'label' => $this->listenerObject->z_xlt($row['title']), + 'selected' => $sel, ); $i++; } @@ -180,11 +181,11 @@ class CommonPlugin extends AbstractPlugin return $rows; } - /* - * $this->escapeHtml() cannot be used in any files other than view. - * This function will enable a user to use escapeHtml in any files like controller model etc. - */ - public function escape($string) + /* + * $this->escapeHtml() cannot be used in any files other than view. + * This function will enable a user to use escapeHtml in any files like controller model etc. + */ + public static function escape($string) { return htmlspecialchars($string, ENT_QUOTES); } @@ -193,7 +194,7 @@ class CommonPlugin extends AbstractPlugin { $appTable = new ApplicationTable(); $sql = "SELECT title FROM list_options WHERE list_id = ? AND option_id = ? "; - $result = $appTable->zQuery($sql, array($listId,$listOptionId)); + $result = $appTable->zQuery($sql, array($listId, $listOptionId)); $row = $result->current(); $return = xl_list_label($row['title']); return $return; 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 7bef3e104..d1a02ddac 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 @@ -14,6 +14,8 @@ namespace Carecoordination\Controller; +use Application\Model\ApplicationTable; +use Application\Plugin\CommonPlugin; use Laminas\Mvc\Controller\AbstractActionController; use Laminas\View\Model\ViewModel; use Laminas\View\Model\JsonModel; @@ -41,15 +43,16 @@ class CarecoordinationController extends AbstractActionController { $this->carecoordinationTable = $table; $this->listenerObject = new Listener(); - $this->date_format = \Application\Model\ApplicationTable::dateFormat($GLOBALS['date_display_format']); + $this->date_format = ApplicationTable::dateFormat($GLOBALS['date_display_format']); $this->documentsController = $documentsController; } /** * Index Page - * @param int $id menu id - * $param array $data menu details - * @param string $slug controller name + * + * @param int $id menu id + * $param array $data menu details + * @param string $slug controller name * @return \Laminas\View\Model\ViewModel */ public function indexAction() @@ -58,8 +61,8 @@ class CarecoordinationController extends AbstractActionController } /* - * Upload CCDA file - */ + * Upload CCDA file + */ public function uploadAction() { $request = $this->getRequest(); @@ -76,7 +79,7 @@ class CarecoordinationController extends AbstractActionController if ($upload == 1) { $time_start = date('Y-m-d H:i:s'); - $obj_doc = $this->documentsController; + $obj_doc = $this->documentsController; $cdoc = $obj_doc->uploadAction($request); $uploaded_documents = array(); $uploaded_documents = $this->getCarecoordinationTable()->fetch_uploaded_documents(array('user' => $_SESSION['authUserID'], 'time_start' => $time_start, 'time_end' => date('Y-m-d H:i:s'))); @@ -108,11 +111,11 @@ class CarecoordinationController extends AbstractActionController } /* - * Function to import the data CCDA file to audit tables. - * - * @param document_id integer value - * @return \Laminas\View\Model\JsonModel - */ + * Function to import the data CCDA file to audit tables. + * + * @param document_id integer value + * @return \Laminas\View\Model\JsonModel + */ public function importAction() { $request = $this->getRequest(); @@ -127,11 +130,11 @@ class CarecoordinationController extends AbstractActionController $xml_content_new = preg_replace('#
#', '', $xml_content); $xml_content_new = preg_replace('#
#', '', $xml_content_new); - // Note the behavior of this relies on PHP's XMLReader - // @see https://docs.zendframework.com/zend-config/reader/ - // @see https://php.net/xmlreader +// Note the behavior of this relies on PHP's XMLReader +// @see https://docs.zendframework.com/zend-config/reader/ +// @see https://php.net/xmlreader $xmltoarray = new \Laminas\Config\Reader\Xml(); - $array = $xmltoarray->fromString((string) $xml_content_new); + $array = $xmltoarray->fromString((string)$xml_content_new); $patient_role = $array['recordTarget']['patientRole']; $patient_pub_pid = $patient_role['id'][0]['extension']; @@ -243,9 +246,9 @@ class CarecoordinationController extends AbstractActionController $view = new \Laminas\View\Model\JsonModel(); $view->setTerminal(true); return $view; - // $view = new ViewModel(array()); - // $view->setTerminal(true); - // return $view; +// $view = new ViewModel(array()); +// $view->setTerminal(true); +// return $view; } public function revandapproveAction() @@ -258,16 +261,16 @@ class CarecoordinationController extends AbstractActionController if ($request->getPost('setval') == 'approve') { $this->getCarecoordinationTable()->insertApprovedData($request->getPost()); return $this->redirect()->toRoute('carecoordination', array( - 'controller' => 'Carecoordination', - 'action' => 'upload')); + 'controller' => 'Carecoordination', + 'action' => 'upload')); } elseif ($request->getPost('setval') == 'discard') { $this->getCarecoordinationTable()->discardCCDAData(array('audit_master_id' => $audit_master_id)); return $this->redirect()->toRoute('carecoordination', array( - 'controller' => 'Carecoordination', - 'action' => 'upload')); + 'controller' => 'Carecoordination', + 'action' => 'upload')); } - $documentationOf = $this->getCarecoordinationTable()->getdocumentationOf($audit_master_id); + $documentationOf = $this->getCarecoordinationTable()->getdocumentationOf($audit_master_id); $demographics = $this->getCarecoordinationTable()->getDemographics(array('audit_master_id' => $audit_master_id)); $demographics_old = $this->getCarecoordinationTable()->getDemographicsOld(array('pid' => $pid)); @@ -382,10 +385,10 @@ class CarecoordinationController extends AbstractActionController public function getCCDAComponentsAction() { $request = $this->getRequest(); - $id = $request->getQuery('id'); - $arr = explode("-", $id); - $amid = $arr[0]; - $pid = $arr[1]; + $id = $request->getQuery('id'); + $arr = explode("-", $id); + $amid = $arr[0]; + $pid = $arr[1]; $components = $this->getCarecoordinationTable()->getCCDAComponents(1); $discharge_medication_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'discharge_medication'); $discharge_summary_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'discharge_summary'); @@ -402,12 +405,12 @@ class CarecoordinationController extends AbstractActionController $temp = ''; foreach ($components as $key => $value) { $temp .= ' - - - - - - '; + + + + + +'; } $temp .= '
'; @@ -417,59 +420,59 @@ class CarecoordinationController extends AbstractActionController public function getEachCCDAComponentDetailsAction() { - $request = $this->getRequest(); - $id = $request->getQuery('id'); + $request = $this->getRequest(); + $id = $request->getQuery('id'); $component = $request->getQuery('component'); - $amid = $request->getQuery('amid'); - $temp = ''; + $amid = $request->getQuery('amid'); + $temp = ''; switch ($component) { case 'allergies': $allergies_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'lists2'); if (count($allergies_audit) > 0) { $temp .= '
- - - - - - - '; + + + + + + + '; foreach ($allergies_audit['lists2'] as $key => $val) { $severity_option_id = $this->getCarecoordinationTable()->getOptionId('severity_ccda', '', 'SNOMED-CT:' . $val['severity_al']); $severity_text = $this->getCarecoordinationTable()->getListTitle($severity_option_id, 'severity_ccda', 'SNOMED-CT:' . $val['severity_al']); if ($val['enddate'] != 0 && $val['enddate'] != '') { - $status = 'completed'; + $status = 'completed'; } else { - $status = 'active'; + $status = 'active'; } $temp .= ' - - - - - '; + + + + + '; } $temp .= '
' . \Application\Listener\Listener::z_xlt('Substance') . '' . \Application\Listener\Listener::z_xlt('Reaction') . '' . \Application\Listener\Listener::z_xlt('Severity') . '' . \Application\Listener\Listener::z_xlt('Status') . '
' . Listener::z_xlt('Substance') . '' . Listener::z_xlt('Reaction') . '' . Listener::z_xlt('Severity') . '' . Listener::z_xlt('Status') . '
' . \Application\Plugin\CommonPlugin::escape($val['list_code_text']) . '' . \Application\Listener\Listener::z_xlt($val['reaction_text']) . '' . \Application\Listener\Listener::z_xlt($severity_text) . '' . \Application\Listener\Listener::z_xlt($status) . '
' . CommonPlugin::escape($val['list_code_text']) . '' . Listener::z_xlt($val['reaction_text']) . '' . Listener::z_xlt($severity_text) . '' . Listener::z_xlt($status) . '
'; } else { - $temp .= \Application\Listener\Listener::z_xlt('No Known Allergies'); + $temp .= Listener::z_xlt('No Known Allergies'); } break; case 'medications': $medications_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'lists3'); if (count($medications_audit) > 0) { $temp .= '
- - - - - - - - - '; + + + + + + + + + '; foreach ($medications_audit['lists3'] as $key => $val) { if ($val['enddate'] && $val['enddate'] != 0) { $active = 'completed'; @@ -478,18 +481,18 @@ class CarecoordinationController extends AbstractActionController } $temp .= ' - - - - - - - '; + + + + + + + '; } $temp .= '
' . \Application\Listener\Listener::z_xlt('Medication') . '' . \Application\Listener\Listener::z_xlt('Directions') . '' . \Application\Listener\Listener::z_xlt('Start Date') . '' . \Application\Listener\Listener::z_xlt('Status') . '' . \Application\Listener\Listener::z_xlt('Indications') . '' . \Application\Listener\Listener::z_xlt('Fill Instructions') . '
' . Listener::z_xlt('Medication') . '' . Listener::z_xlt('Directions') . '' . Listener::z_xlt('Start Date') . '' . Listener::z_xlt('Status') . '' . Listener::z_xlt('Indications') . '' . Listener::z_xlt('Fill Instructions') . '
' . \Application\Plugin\CommonPlugin::escape($val['drug_text']) . '' . \Application\Plugin\CommonPlugin::escape($val['rate'] . " " . $val['rate_unit'] . " " . $val['route_display'] . " " . $val['dose'] . " " . $val['dose_unit']) . '' . \Application\Model\ApplicationTable::fixDate(substr($val['begdate'], 0, 4) . "-" . substr($val['begdate'], 4, 2) . "-" . substr($val['begdate'], 6, 2), $this->date_format, 'yyyy-mm-dd') . '' . \Application\Listener\Listener::z_xlt($active) . '' . \Application\Plugin\CommonPlugin::escape($val['indication']) . '' . \Application\Plugin\CommonPlugin::escape($val['note']) . '
' . CommonPlugin::escape($val['drug_text']) . '' . CommonPlugin::escape($val['rate'] . " " . $val['rate_unit'] . " " . $val['route_display'] . " " . $val['dose'] . " " . $val['dose_unit']) . '' . ApplicationTable::fixDate(substr($val['begdate'], 0, 4) . "-" . substr($val['begdate'], 4, 2) . "-" . substr($val['begdate'], 6, 2), $this->date_format, 'yyyy-mm-dd') . '' . Listener::z_xlt($active) . '' . CommonPlugin::escape($val['indication']) . '' . CommonPlugin::escape($val['note']) . '
'; } else { - $temp .= \Application\Listener\Listener::z_xlt('No Known Medications'); + $temp .= Listener::z_xlt('No Known Medications'); } break; case 'problems': @@ -499,206 +502,206 @@ class CarecoordinationController extends AbstractActionController $i = 1; foreach ($problems_audit['lists1'] as $key => $val) { if ($val['enddate'] != 0 && $val['enddate'] != '') { - $status = 'Resolved'; + $status = 'Resolved'; } else { - $status = 'Active'; + $status = 'Active'; } - $temp .= '
  • ' . $i . '. ' . \Application\Plugin\CommonPlugin::escape($val['list_code_text']) . ',' . substr($val['begdate'], 0, 4) . "-" . substr($val['begdate'], 4, 2) . "-" . substr($val['begdate'], 6, 2) . ', ' . \Application\Listener\Listener::z_xlt('Status') . ' :' . \Application\Listener\Listener::z_xlt($status) . '
  • '; + $temp .= '
  • ' . $i . '. ' . CommonPlugin::escape($val['list_code_text']) . ',' . substr($val['begdate'], 0, 4) . "-" . substr($val['begdate'], 4, 2) . "-" . substr($val['begdate'], 6, 2) . ', ' . Listener::z_xlt('Status') . ' :' . Listener::z_xlt($status) . '
  • '; $i++; } $temp .= ''; } else { - $temp .= \Application\Listener\Listener::z_xlt('No Known Problems'); + $temp .= Listener::z_xlt('No Known Problems'); } break; case 'immunizations': $immunizations_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'immunization'); if (count($immunizations_audit) > 0) { $temp .= '
    - - - - - - '; + + + + + + '; foreach ($immunizations_audit['immunization'] as $key => $val) { $temp .= ' - - - - '; + + + + '; } $temp .= '
    ' . \Application\Listener\Listener::z_xlt('Vaccine') . '' . \Application\Listener\Listener::z_xlt('Date') . '' . \Application\Listener\Listener::z_xlt('Status') . '
    ' . Listener::z_xlt('Vaccine') . '' . Listener::z_xlt('Date') . '' . Listener::z_xlt('Status') . '
    ' . \Application\Plugin\CommonPlugin::escape($val['cvx_code_text']) . '' . $this->getCarecoordinationTable()->getMonthString(substr($val['administered_date'], 4, 2)) . ' ' . substr($val['administered_date'], 0, 4) . '' . \Application\Listener\Listener::z_xlt('Completed') . '
    ' . CommonPlugin::escape($val['cvx_code_text']) . '' . $this->getCarecoordinationTable()->getMonthString(substr($val['administered_date'], 4, 2)) . ' ' . substr($val['administered_date'], 0, 4) . '' . Listener::z_xlt('Completed') . '
    '; } else { - $temp .= \Application\Listener\Listener::z_xlt('No Known Immunizations'); + $temp .= Listener::z_xlt('No Known Immunizations'); } break; case 'procedures': $procedure_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'procedure'); if (count($procedure_audit) > 0) { $temp .= '
    - - - - - '; + + + + + '; foreach ($procedure_audit['procedure'] as $key => $val) { $temp .= ' - - - '; + + + '; } $temp .= '
    ' . \Application\Listener\Listener::z_xlt('Procedure') . '' . \Application\Listener\Listener::z_xlt('Date') . '
    ' . Listener::z_xlt('Procedure') . '' . Listener::z_xlt('Date') . '
    ' . \Application\Plugin\CommonPlugin::escape($val['code_text']) . '' . \Application\Model\ApplicationTable::fixDate(substr($val['date'], 0, 4) . "-" . substr($val['date'], 4, 2) . "-" . substr($val['date'], 6, 2), $this->date_format, 'yyyy-mm-dd') . '
    ' . CommonPlugin::escape($val['code_text']) . '' . ApplicationTable::fixDate(substr($val['date'], 0, 4) . "-" . substr($val['date'], 4, 2) . "-" . substr($val['date'], 6, 2), $this->date_format, 'yyyy-mm-dd') . '
    '; } else { - $temp .= \Application\Listener\Listener::z_xlt('No Known Procedures'); + $temp .= Listener::z_xlt('No Known Procedures'); } break; case 'results': $lab_results_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'procedure_result'); if (count($lab_results_audit) > 0) { $temp .= '
    - - - - - - - '; +
    ' . \Application\Listener\Listener::z_xlt('Laboratory Information') . '' . \Application\Listener\Listener::z_xlt('Result') . '' . \Application\Listener\Listener::z_xlt('Date') . '
    + + + + + + '; foreach ($lab_results_audit['procedure_result'] as $key => $val) { if ($val['results_text']) { $temp .= ' - - - - '; + + + + '; } } $temp .= '
    ' . Listener::z_xlt('Laboratory Information') . '' . Listener::z_xlt('Result') . '' . Listener::z_xlt('Date') . '
    ' . \Application\Plugin\CommonPlugin::escape($val['results_text']) . ($val['results_range'] != "-" ? "(" . \Application\Plugin\CommonPlugin::escape($val['results_range']) . ")" : "") . '' . \Application\Plugin\CommonPlugin::escape($val['results_value']) . " " . \Application\Plugin\CommonPlugin::escape($val['results_unit']) . '' . \Application\Model\ApplicationTable::fixDate(substr($val['date'], 0, 4) . "-" . substr($val['date'], 4, 2) . "-" . substr($val['date'], 6, 2), $this->date_format, 'yyyy-mm-dd') . '
    ' . CommonPlugin::escape($val['results_text']) . ($val['results_range'] != "-" ? "(" . CommonPlugin::escape($val['results_range']) . ")" : "") . '' . CommonPlugin::escape($val['results_value']) . " " . CommonPlugin::escape($val['results_unit']) . '' . ApplicationTable::fixDate(substr($val['date'], 0, 4) . "-" . substr($val['date'], 4, 2) . "-" . substr($val['date'], 6, 2), $this->date_format, 'yyyy-mm-dd') . '
    '; } else { - $temp .= \Application\Listener\Listener::z_xlt('No Known Lab Results'); + $temp .= Listener::z_xlt('No Known Lab Results'); } break; case 'plan_of_care': $care_plan_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'care_plan'); if (count($care_plan_audit) > 0) { $temp .= '
    - - - - - '; + + + + + '; foreach ($care_plan_audit['care_plan'] as $key => $val) { $temp .= ' - - - '; + + + '; } $temp .= '
    ' . \Application\Listener\Listener::z_xlt('Planned Activity') . '' . \Application\Listener\Listener::z_xlt('Planned Date') . '
    ' . Listener::z_xlt('Planned Activity') . '' . Listener::z_xlt('Planned Date') . '
    ' . \Application\Plugin\CommonPlugin::escape($val['code_text']) . '' . \Application\Model\ApplicationTable::fixDate(substr($val['date'], 0, 4) . "-" . substr($val['date'], 4, 2) . "-" . substr($val['date'], 6, 2), $this->date_format, 'yyyy-mm-dd') . '
    ' . CommonPlugin::escape($val['code_text']) . '' . ApplicationTable::fixDate(substr($val['date'], 0, 4) . "-" . substr($val['date'], 4, 2) . "-" . substr($val['date'], 6, 2), $this->date_format, 'yyyy-mm-dd') . '
    '; } else { - $temp .= \Application\Listener\Listener::z_xlt('No Known Plan of Care'); + $temp .= Listener::z_xlt('No Known Plan of Care'); } break; case 'vitals': $vitals_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'vital_sign'); if (count($vitals_audit) > 0) { $temp .= '
    - - '; + + '; foreach ($vitals_audit['vital_sign'] as $key => $val) { - $temp .= ''; + $temp .= ''; } $temp .= ' - - '; + + '; foreach ($vitals_audit['vital_sign'] as $key => $val) { - $temp .= ''; + $temp .= ''; } $temp .= ' - - '; + + '; foreach ($vitals_audit['vital_sign'] as $key => $val) { - $temp .= ''; + $temp .= ''; } $temp .= ' - - '; + + '; foreach ($vitals_audit['vital_sign'] as $key => $val) { - $temp .= ''; + $temp .= ''; } $temp .= ' - - '; + + '; foreach ($vitals_audit['vital_sign'] as $key => $val) { - $temp .= ''; + $temp .= ''; } $temp .= ' - - '; + + '; foreach ($vitals_audit['vital_sign'] as $key => $val) { - $temp .= ''; + $temp .= ''; } $temp .= ' - - '; + + '; foreach ($vitals_audit['vital_sign'] as $key => $val) { - $temp .= ''; + $temp .= ''; } $temp .= ' - - '; + + '; foreach ($vitals_audit['vital_sign'] as $key => $val) { - $temp .= ''; + $temp .= ''; } $temp .= ' - - '; + + '; foreach ($vitals_audit['vital_sign'] as $key => $val) { - $temp .= ''; + $temp .= ''; } $temp .= ' - - '; + + '; foreach ($vitals_audit['vital_sign'] as $key => $val) { - $temp .= ''; + $temp .= ''; } $temp .= ' - - '; + + '; foreach ($vitals_audit['vital_sign'] as $key => $val) { - $temp .= ''; + $temp .= ''; } $temp .= '
    ' . \Application\Listener\Listener::z_xlt('Date / Time') . ':
    ' . Listener::z_xlt('Date / Time') . ': ' . \Application\Model\ApplicationTable::fixDate(substr($val['date'], 0, 4) . "-" . substr($val['date'], 4, 2) . "-" . substr($val['date'], 6, 2), $this->date_format, 'yyyy-mm-dd') . '' . ApplicationTable::fixDate(substr($val['date'], 0, 4) . "-" . substr($val['date'], 4, 2) . "-" . substr($val['date'], 6, 2), $this->date_format, 'yyyy-mm-dd') . '
    ' . \Application\Listener\Listener::z_xlt('Temperature') . '
    ' . Listener::z_xlt('Temperature') . '' . \Application\Plugin\CommonPlugin::escape($val['temperature']) . '' . CommonPlugin::escape($val['temperature']) . '
    ' . \Application\Listener\Listener::z_xlt('Diastolic') . '
    ' . Listener::z_xlt('Diastolic') . '' . \Application\Plugin\CommonPlugin::escape($val['bpd']) . '' . CommonPlugin::escape($val['bpd']) . '
    ' . \Application\Listener\Listener::z_xlt('Systolic') . '
    ' . Listener::z_xlt('Systolic') . '' . \Application\Plugin\CommonPlugin::escape($val['bps']) . '' . CommonPlugin::escape($val['bps']) . '
    ' . \Application\Listener\Listener::z_xlt('Head Circumference') . '
    ' . Listener::z_xlt('Head Circumference') . '' . \Application\Plugin\CommonPlugin::escape($val['head_circ']) . '' . CommonPlugin::escape($val['head_circ']) . '
    ' . \Application\Listener\Listener::z_xlt('Pulse') . '
    ' . Listener::z_xlt('Pulse') . '' . \Application\Plugin\CommonPlugin::escape($val['pulse']) . '' . CommonPlugin::escape($val['pulse']) . '
    ' . \Application\Listener\Listener::z_xlt('Height') . '
    ' . Listener::z_xlt('Height') . '' . \Application\Plugin\CommonPlugin::escape($val['height']) . '' . CommonPlugin::escape($val['height']) . '
    ' . \Application\Listener\Listener::z_xlt('Oxygen Saturation') . '
    ' . Listener::z_xlt('Oxygen Saturation') . '' . \Application\Plugin\CommonPlugin::escape($val['oxygen_saturation']) . '' . CommonPlugin::escape($val['oxygen_saturation']) . '
    ' . \Application\Listener\Listener::z_xlt('Breath') . '
    ' . Listener::z_xlt('Breath') . '' . \Application\Plugin\CommonPlugin::escape($val['breath']) . '' . CommonPlugin::escape($val['breath']) . '
    ' . \Application\Listener\Listener::z_xlt('Weight') . '
    ' . Listener::z_xlt('Weight') . '' . \Application\Plugin\CommonPlugin::escape($val['weight']) . '' . CommonPlugin::escape($val['weight']) . '
    ' . \Application\Listener\Listener::z_xlt('BMI') . '
    ' . Listener::z_xlt('BMI') . '' . \Application\Plugin\CommonPlugin::escape($val['BMI']) . '' . CommonPlugin::escape($val['BMI']) . '
    '; } else { - $temp .= \Application\Listener\Listener::z_xlt('No Known Vitals'); + $temp .= Listener::z_xlt('No Known Vitals'); } break; case 'social_history': $social_history_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'social_history'); if (count($social_history_audit) > 0) { $temp .= '
    - - - - - - '; + + + + + + '; foreach ($social_history_audit['social_history'] as $key => $val) { $array_his_tobacco = explode("|", $val['smoking']); if ($array_his_tobacco[2] != 0 && $array_his_tobacco[2] != '') { @@ -706,31 +709,31 @@ class CarecoordinationController extends AbstractActionController } $temp .= ' - - - - '; + + + + '; } $temp .= '
    ' . \Application\Listener\Listener::z_xlt('Social History Element') . '' . \Application\Listener\Listener::z_xlt('Description') . '' . \Application\Listener\Listener::z_xlt('Effective Dates') . '
    ' . Listener::z_xlt('Social History Element') . '' . Listener::z_xlt('Description') . '' . Listener::z_xlt('Effective Dates') . '
    ' . \Application\Listener\Listener::z_xlt('Smoking') . '' . \Application\Plugin\CommonPlugin::escape($array_his_tobacco[0]) . '' . \Application\Model\ApplicationTable::fixDate($his_tob_date, $this->date_format, 'yyyy-mm-dd') . '
    ' . Listener::z_xlt('Smoking') . '' . CommonPlugin::escape($array_his_tobacco[0]) . '' . ApplicationTable::fixDate($his_tob_date, $this->date_format, 'yyyy-mm-dd') . '
    '; } else { - $temp .= \Application\Listener\Listener::z_xlt('No Known Social History'); + $temp .= Listener::z_xlt('No Known Social History'); } break; case 'encounters': $encounter_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'encounter'); if (count($encounter_audit) > 0) { $temp .= '
    - - - - - - - - - - '; + + + + + + + + + + '; foreach ($encounter_audit['encounter'] as $key => $val) { if ($val['code_text'] != 'NULL') { $encounter_activity = 'Active'; @@ -739,43 +742,43 @@ class CarecoordinationController extends AbstractActionController } $enc_date = substr($val['date'], 0, 4) . "-" . substr($val['date'], 4, 2) . "-" . substr($val['date'], 6, 2); - $temp .= ' - - - - - - - - '; + $temp .= ' + + + + + + + + '; } $temp .= '
    ' . \Application\Listener\Listener::z_xlt('Encounter') . '' . \Application\Listener\Listener::z_xlt('Performer') . '' . \Application\Listener\Listener::z_xlt('Location') . '' . \Application\Listener\Listener::z_xlt('Date') . '' . \Application\Listener\Listener::z_xlt('Encounter Diagnosis') . '' . \Application\Listener\Listener::z_xlt('Status') . '' . \Application\Listener\Listener::z_xlt('Reason for Visit') . '
    ' . Listener::z_xlt('Encounter') . '' . Listener::z_xlt('Performer') . '' . Listener::z_xlt('Location') . '' . Listener::z_xlt('Date') . '' . Listener::z_xlt('Encounter Diagnosis') . '' . Listener::z_xlt('Status') . '' . Listener::z_xlt('Reason for Visit') . '
    ' . \Application\Plugin\CommonPlugin::escape($val['pc_catname']) . '' . \Application\Plugin\CommonPlugin::escape($val['provider_name']) . '' . \Application\Plugin\CommonPlugin::escape($val['represented_organization_name']) . '' . \Application\Model\ApplicationTable::fixDate($enc_date, $this->date_format, 'yyyy-mm-dd') . '' . ($val['code_text'] != 'NULL' ? \Application\Plugin\CommonPlugin::escape($val['code_text']) : '') . '' . \Application\Listener\Listener::z_xlt($encounter_activity) . '
    ' . CommonPlugin::escape($val['pc_catname']) . '' . CommonPlugin::escape($val['provider_name']) . '' . CommonPlugin::escape($val['represented_organization_name']) . '' . ApplicationTable::fixDate($enc_date, $this->date_format, 'yyyy-mm-dd') . '' . ($val['code_text'] != 'NULL' ? CommonPlugin::escape($val['code_text']) : '') . '' . Listener::z_xlt($encounter_activity) . '
    '; } else { - $temp .= \Application\Listener\Listener::z_xlt('No Known Encounters'); + $temp .= Listener::z_xlt('No Known Encounters'); } break; case 'functional_status': $functional_cognitive_status_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'functional_cognitive_status'); if (count($functional_cognitive_status_audit) > 0) { $temp .= '
    - - - - - - '; + + + + + + '; foreach ($functional_cognitive_status_audit['functional_cognitive_status'] as $key => $val) { $temp .= ' - - - - '; + + + + '; } $temp .= '
    ' . \Application\Listener\Listener::z_xlt('Functional Condition') . '' . \Application\Listener\Listener::z_xlt('Effective Dates') . '' . \Application\Listener\Listener::z_xlt('Condition Status') . '
    ' . Listener::z_xlt('Functional Condition') . '' . Listener::z_xlt('Effective Dates') . '' . Listener::z_xlt('Condition Status') . '
    ' . \Application\Plugin\CommonPlugin::escape($val['description']) . '' . \Application\Model\ApplicationTable::fixDate(substr($val['date'], 0, 4) . "-" . substr($val['date'], 4, 2) . "-" . substr($val['date'], 6, 2), $this->date_format, 'yyyy-mm-dd') . '' . \Application\Listener\Listener::z_xlt('Active') . '
    ' . CommonPlugin::escape($val['description']) . '' . ApplicationTable::fixDate(substr($val['date'], 0, 4) . "-" . substr($val['date'], 4, 2) . "-" . substr($val['date'], 6, 2), $this->date_format, 'yyyy-mm-dd') . '' . Listener::z_xlt('Active') . '
    '; } else { - $temp .= \Application\Listener\Listener::z_xlt('No Known Social Functional Status'); + $temp .= Listener::z_xlt('No Known Social Functional Status'); } break; case 'referral': @@ -785,30 +788,30 @@ class CarecoordinationController extends AbstractActionController foreach ($referral_audit['referral'] as $key => $val) { $referal_data = explode("#$%^&*", $val['body']); foreach ($referal_data as $k => $v) { - $temp .= '

    ' . \Application\Plugin\CommonPlugin::escape($v) . '

    '; + $temp .= '

    ' . CommonPlugin::escape($v) . '

    '; } } $temp .= ''; } else { - $temp .= \Application\Listener\Listener::z_xlt('No Known Referrals'); + $temp .= Listener::z_xlt('No Known Referrals'); } break; case 'instructions': - $temp .= \Application\Listener\Listener::z_xlt('No Known Clinical Instructions'); + $temp .= Listener::z_xlt('No Known Clinical Instructions'); break; case 'discharge_medication': $discharge_medication_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'discharge_medication'); - $temp .= '
    - - - - - - - - - '; + $temp .= '
    ' . \Application\Listener\Listener::z_xlt('Medication') . '' . \Application\Listener\Listener::z_xlt('Directions') . '' . \Application\Listener\Listener::z_xlt('Start Date') . '' . \Application\Listener\Listener::z_xlt('Status') . '' . \Application\Listener\Listener::z_xlt('Indications') . '' . \Application\Listener\Listener::z_xlt('Fill Instructions') . '
    + + + + + + + + + '; foreach ($discharge_medication_audit['discharge_medication'] as $key => $val) { if ($val['enddate'] && $val['enddate'] != 0) { $active = 'completed'; @@ -817,34 +820,36 @@ class CarecoordinationController extends AbstractActionController } $temp .= ' - - - - - - - '; + + + + + + + '; } - $temp .= '
    ' . Listener::z_xlt('Medication') . '' . Listener::z_xlt('Directions') . '' . Listener::z_xlt('Start Date') . '' . Listener::z_xlt('Status') . '' . Listener::z_xlt('Indications') . '' . Listener::z_xlt('Fill Instructions') . '
    ' . \Application\Plugin\CommonPlugin::escape($val['drug_text']) . '' . \Application\Plugin\CommonPlugin::escape($val['rate'] . " " . $val['rate_unit'] . " " . $val['route_display'] . " " . $val['dose'] . " " . $val['dose_unit']) . '' . \Application\Model\ApplicationTable::fixDate(substr($val['begdate'], 0, 4) . "-" . substr($val['begdate'], 4, 2) . "-" . substr($val['begdate'], 6, 2), $this->date_format, 'yyyy-mm-dd') . '' . \Application\Listener\Listener::z_xlt($active) . '' . \Application\Plugin\CommonPlugin::escape($val['indication']) . '' . \Application\Plugin\CommonPlugin::escape($val['note']) . '
    ' . CommonPlugin::escape($val['drug_text']) . '' . CommonPlugin::escape($val['rate'] . " " . $val['rate_unit'] . " " . $val['route_display'] . " " . $val['dose'] . " " . $val['dose_unit']) . '' . ApplicationTable::fixDate(substr($val['begdate'], 0, 4) . "-" . substr($val['begdate'], 4, 2) . "-" . substr($val['begdate'], 6, 2), $this->date_format, 'yyyy-mm-dd') . '' . Listener::z_xlt($active) . '' . CommonPlugin::escape($val['indication']) . '' . CommonPlugin::escape($val['note']) . '
    '; + $temp .= ''; break; case 'discharge_summary': $discharge_summary_audit = $this->getCarecoordinationTable()->createAuditArray($amid, 'discharge_summary'); - $temp .= '
    '; + $temp .= '
    '; foreach ($discharge_summary_audit['discharge_summary'] as $key => $val) { - $text = str_replace("#$%", "
    ", \Application\Plugin\CommonPlugin::escape($val['text'])); + $text = str_replace("#$%", "
    ", CommonPlugin::escape($val['text'])); $temp .= $text; } - $temp .= '
    '; + $temp .= '
    '; break; } echo $temp; exit; } + /** * Table gateway + * * @return \Carecoordination\Model\CarecoordinationTable */ public function getCarecoordinationTable() @@ -863,6 +868,7 @@ class CarecoordinationController extends AbstractActionController /** * PHP 7 requires foreach iterables to not be null / undefined. There's a ton of code in the revandapprove.phtml file that assumes * the arrays are not empty... so to skip over the foreach's we are giving them empty values. + * * @param $audit_master_id * @param $table_name * @return array diff --git a/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Model/EncounterccdadispatchTable.php b/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Model/EncounterccdadispatchTable.php index fa184a032..e23145aff 100644 --- a/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Model/EncounterccdadispatchTable.php +++ b/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Model/EncounterccdadispatchTable.php @@ -37,15 +37,15 @@ class EncounterccdadispatchTable extends AbstractTableGateway */ public function getPatientdata($pid, $encounter) { - $query = "select patient_data.*, l1.notes AS race_code, l1.title as race_title, l2.notes AS ethnicity_code, l2.title as ethnicity_title, l3.title as religion, l3.notes as religion_code, l4.notes as language_code, l4.title as language_title + $query = "select patient_data.*, l1.notes AS race_code, l1.title as race_title, l2.notes AS ethnicity_code, l2.title as ethnicity_title, l3.title as religion, l3.notes as religion_code, l4.notes as language_code, l4.title as language_title from patient_data left join list_options as l1 on l1.list_id=? AND l1.option_id=race left join list_options as l2 on l2.list_id=? AND l2.option_id=ethnicity left join list_options AS l3 ON l3.list_id=? AND l3.option_id=religion left join list_options AS l4 ON l4.list_id=? AND l4.option_id=language where pid=?"; - $appTable = new ApplicationTable(); - $row = $appTable->zQuery($query, array('race','ethnicity','religious_affiliation','language',$pid)); + $appTable = new ApplicationTable(); + $row = $appTable->zQuery($query, array('race', 'ethnicity', 'religious_affiliation', 'language', $pid)); foreach ($row as $result) { $patient_data = " @@ -99,19 +99,19 @@ class EncounterccdadispatchTable extends AbstractTableGateway $provider_details = ''; if (!$encounter) { $query_enc = "SELECT encounter FROM form_encounter WHERE pid=? ORDER BY date DESC LIMIT 1"; - $appTable = new ApplicationTable(); - $res_enc = $appTable->zQuery($query_enc, array($pid)); + $appTable = new ApplicationTable(); + $res_enc = $appTable->zQuery($query_enc, array($pid)); foreach ($res_enc as $row_enc) { $encounter = $row_enc['encounter']; } } - $query = "SELECT * FROM form_encounter as fe + $query = "SELECT * FROM form_encounter as fe JOIN users AS u ON u.id = fe.provider_id JOIN facility AS f ON f.id = u.facility_id WHERE fe.pid = ? AND fe.encounter = ?"; - $appTable = new ApplicationTable(); - $row = $appTable->zQuery($query, array($pid,$encounter)); + $appTable = new ApplicationTable(); + $row = $appTable->zQuery($query, array($pid, $encounter)); foreach ($row as $result) { $provider_details = " @@ -216,42 +216,42 @@ class EncounterccdadispatchTable extends AbstractTableGateway public function getInformationRecipient($pid, $encounter, $recipients, $params) { - $information_recipient = ''; - $field_name = array(); - $details = $this->getDetails('hie_recipient_id'); + $information_recipient = ''; + $field_name = array(); + $details = $this->getDetails('hie_recipient_id'); - $appTable = new ApplicationTable(); + $appTable = new ApplicationTable(); if ($recipients == 'hie') { - $details['fname'] = 'MyHealth'; - $details['lname'] = ''; + $details['fname'] = 'MyHealth'; + $details['lname'] = ''; $details['organization'] = ''; } elseif ($recipients == 'emr_direct') { - $query = "select fname, lname, organization, street, city, state, zip, phonew1 from users where email = ?"; - $field_name[] = $params; + $query = "select fname, lname, organization, street, city, state, zip, phonew1 from users where email = ?"; + $field_name[] = $params; } elseif ($recipients == 'patient') { - $query = "select fname, lname from patient_data WHERE pid = ?"; - $field_name[] = $params; + $query = "select fname, lname from patient_data WHERE pid = ?"; + $field_name[] = $params; } else { if (!$params) { $params = $_SESSION['authUserID']; } - $query = "select fname, lname, organization, street, city, state, zip, phonew1 from users where id = ?"; - $field_name[] = $params; + $query = "select fname, lname, organization, street, city, state, zip, phonew1 from users where id = ?"; + $field_name[] = $params; } if ($recipients != 'hie') { - $res = $appTable->zQuery($query, $field_name); - $result = $res->current(); - $details['fname'] = $result['fname']; - $details['lname'] = $result['lname']; - $details['organization'] = $result['organization']; - $details['street'] = $result['street']; - $details['city'] = $result['city']; - $details['state'] = $result['state']; - $details['zip'] = $result['zip']; - $details['phonew1'] = $result['phonew1']; + $res = $appTable->zQuery($query, $field_name); + $result = $res->current(); + $details['fname'] = $result['fname']; + $details['lname'] = $result['lname']; + $details['organization'] = $result['organization']; + $details['street'] = $result['street']; + $details['city'] = $result['city']; + $details['state'] = $result['state']; + $details['zip'] = $result['zip']; + $details['phonew1'] = $result['phonew1']; } $information_recipient = " @@ -362,52 +362,52 @@ class EncounterccdadispatchTable extends AbstractTableGateway */ public function getAllergies($pid, $encounter) { - $allergies = ''; - $query = "SELECT l.id, l.title, l.begdate, l.enddate, lo.title AS observation, + $allergies = ''; + $query = "SELECT l.id, l.title, l.begdate, l.enddate, lo.title AS observation, SUBSTRING(lo.codes, LOCATE(':',lo.codes)+1, LENGTH(lo.codes)) AS observation_code, SUBSTRING(l.`diagnosis`,1,LOCATE(':',l.diagnosis)-1) AS code_type_real, l.reaction, l.diagnosis, l.diagnosis AS code FROM lists AS l LEFT JOIN list_options AS lo ON lo.list_id = ? AND lo.option_id = l.severity_al WHERE l.type = ? AND l.pid = ?"; - $appTable = new ApplicationTable(); - $res = $appTable->zQuery($query, array('severity_ccda','allergy',$pid)); + $appTable = new ApplicationTable(); + $res = $appTable->zQuery($query, array('severity_ccda', 'allergy', $pid)); $allergies = ""; foreach ($res as $row) { - $split_codes = explode(';', $row['code']); + $split_codes = explode(';', $row['code']); foreach ($split_codes as $key => $single_code) { $code = $code_text = $code_rx = $code_text_rx = $code_snomed = $code_text_snomed = $reaction_text = $reaction_code = ''; $get_code_details = explode(':', $single_code); if ($get_code_details[0] == 'RXNORM') { - $code_rx = $get_code_details[1]; + $code_rx = $get_code_details[1]; $code_text_rx = lookup_code_descriptions($single_code); } elseif ($get_code_details[0] == 'SNOMED') { - $code_snomed = $get_code_details[1]; + $code_snomed = $get_code_details[1]; $code_text_snomed = lookup_code_descriptions($row['code']); } else { - $code = $get_code_details[1]; - $code_text = lookup_code_descriptions($single_code); + $code = $get_code_details[1]; + $code_text = lookup_code_descriptions($single_code); } $active = $status_table = ''; if ($row['enddate']) { - $active = 'completed'; + $active = 'completed'; $allergy_status = 'completed'; $status_table = 'Resolved'; - $status_code = '73425007'; + $status_code = '73425007'; } else { - $active = 'completed'; + $active = 'completed'; $allergy_status = 'active'; - $status_table = 'Active'; - $status_code = '55561003'; + $status_table = 'Active'; + $status_code = '55561003'; } if ($row['reaction']) { - $reaction_text = CarecoordinationTable::getListTitle($row['reaction'], 'reaction', ''); - $reaction_code = CarecoordinationTable::getCodes($row['reaction'], 'reaction'); + $reaction_text = (new CarecoordinationTable())->getListTitle($row['reaction'], 'reaction', ''); + $reaction_code = (new CarecoordinationTable())->getCodes($row['reaction'], 'reaction'); } $allergies .= " @@ -442,8 +442,8 @@ class EncounterccdadispatchTable extends AbstractTableGateway public function getMedications($pid, $encounter) { - $medications = ''; - $query = "select l.id, l.date_added, l.drug, l.dosage, l.quantity, l.size, l.substitute, l.drug_info_erx, l.active, SUBSTRING(l3.codes, LOCATE(':',l3.codes)+1, LENGTH(l3.codes)) AS route_code, + $medications = ''; + $query = "select l.id, l.date_added, l.drug, l.dosage, l.quantity, l.size, l.substitute, l.drug_info_erx, l.active, SUBSTRING(l3.codes, LOCATE(':',l3.codes)+1, LENGTH(l3.codes)) AS route_code, l.rxnorm_drugcode, l1.title as unit, l1.codes as unit_code,l2.title as form,SUBSTRING(l2.codes, LOCATE(':',l2.codes)+1, LENGTH(l2.codes)) AS form_code, l3.title as route, l4.title as `interval`, u.title, u.fname, u.lname, u.mname, u.npi, u.street, u.streetb, u.city, u.state, u.zip, u.phonew1, l.note from prescriptions as l @@ -453,8 +453,8 @@ class EncounterccdadispatchTable extends AbstractTableGateway left join list_options as l4 on l4.option_id=`interval` AND l4.list_id = ? left join users as u on u.id = l.provider_id where l.patient_id = ? and l.active = 1"; - $appTable = new ApplicationTable(); - $res = $appTable->zQuery($query, array('drug_units','drug_form','drug_route','drug_interval',$pid)); + $appTable = new ApplicationTable(); + $res = $appTable->zQuery($query, array('drug_units', 'drug_form', 'drug_route', 'drug_interval', $pid)); $medications = ""; foreach ($res as $row) { @@ -465,10 +465,10 @@ class EncounterccdadispatchTable extends AbstractTableGateway $unit = $str = $active = ''; if ($row['size'] > 0) { - $unit = $row['size'] . " " . \Application\Listener\Listener::z_xlt($row['unit']) . " "; + $unit = $row['size'] . " " . \Application\Listener\Listener::z_xlt($row['unit']) . " "; } - $str = $unit . " " . \Application\Listener\Listener::z_xlt($row['route']) . " " . $row['dosage'] . " " . \Application\Listener\Listener::z_xlt($row['form'] . " " . $row['interval']); + $str = $unit . " " . \Application\Listener\Listener::z_xlt($row['route']) . " " . $row['dosage'] . " " . \Application\Listener\Listener::z_xlt($row['form'] . " " . $row['interval']); if ($row['active'] > 0) { $active = 'active'; @@ -477,7 +477,7 @@ class EncounterccdadispatchTable extends AbstractTableGateway } if ($row['date_added']) { - $start_date = str_replace('-', '', $row['date_added']); + $start_date = str_replace('-', '', $row['date_added']); $start_date_formatted = \Application\Model\ApplicationTable::fixDate($row['date_added'], $GLOBALS['date_display_format'], 'yyyy-mm-dd'); ; } @@ -527,43 +527,43 @@ class EncounterccdadispatchTable extends AbstractTableGateway public function getProblemList($pid, $encounter) { - $problem_lists = ''; - $query = "select l.*, lo.title as observation, lo.codes as observation_code, l.diagnosis AS code + $problem_lists = ''; + $query = "select l.*, lo.title as observation, lo.codes as observation_code, l.diagnosis AS code from lists AS l left join list_options as lo on lo.option_id = l.outcome AND lo.list_id = ? where l.type = ? and l.pid = ? AND l.outcome <> ? AND l.id NOT IN(SELECT list_id FROM issue_encounter WHERE pid = ?)"; - $appTable = new ApplicationTable(); - $res = $appTable->zQuery($query, array('outcome','medical_problem',$pid,1,$pid)); + $appTable = new ApplicationTable(); + $res = $appTable->zQuery($query, array('outcome', 'medical_problem', $pid, 1, $pid)); - $problem_lists .= ''; + $problem_lists .= ''; foreach ($res as $row) { - $split_codes = explode(';', $row['code']); + $split_codes = explode(';', $row['code']); foreach ($split_codes as $key => $single_code) { $get_code_details = explode(':', $single_code); - $code = $get_code_details[1]; - $code_text = lookup_code_descriptions($single_code); + $code = $get_code_details[1]; + $code_text = lookup_code_descriptions($single_code); - $age = $this->getAge($pid, $row['begdate']); - $start_date = str_replace('-', '', $row['begdate']); - $end_date = str_replace('-', '', $row['enddate']); + $age = $this->getAge($pid, $row['begdate']); + $start_date = str_replace('-', '', $row['begdate']); + $end_date = str_replace('-', '', $row['enddate']); $status = $status_table = ''; - $start_date = $start_date ? $start_date : '0'; - $end_date = $end_date ? $end_date : '0'; + $start_date = $start_date ? $start_date : '0'; + $end_date = $end_date ? $end_date : '0'; //Active - 55561003 Completed - 73425007 if ($end_date) { - $status = 'completed'; - $status_table = 'Resolved'; - $status_code = '73425007'; + $status = 'completed'; + $status_table = 'Resolved'; + $status_code = '73425007'; } else { - $status = 'active'; - $status_table = 'Active'; - $status_code = '55561003'; + $status = 'active'; + $status_table = 'Active'; + $status_code = '55561003'; } - $observation = $row['observation']; + $observation = $row['observation']; $observation_code = explode(':', $row['observation_code']); $observation_code = $observation_code[1]; @@ -587,14 +587,14 @@ class EncounterccdadispatchTable extends AbstractTableGateway } } - $problem_lists .= ''; - return $problem_lists; + $problem_lists .= ''; + return $problem_lists; } public function getImmunization($pid, $encounter) { $immunizations = ''; - $query = "SELECT im.*, cd.code_text, DATE(administered_date) AS administered_date, + $query = "SELECT im.*, cd.code_text, DATE(administered_date) AS administered_date, DATE_FORMAT(administered_date,'%Y%m%d') AS administered_formatted, lo.title as route_of_administration, u.title, u.fname, u.mname, u.lname, u.npi, u.street, u.streetb, u.city, u.state, u.zip, u.phonew1, f.name, f.phone, SUBSTRING(lo.codes, LOCATE(':',lo.codes)+1, LENGTH(lo.codes)) AS route_code @@ -605,8 +605,8 @@ class EncounterccdadispatchTable extends AbstractTableGateway LEFT JOIN users AS u ON u.id = im.administered_by_id LEFT JOIN facility AS f ON f.id = u.facility_id WHERE im.patient_id=?"; - $appTable = new ApplicationTable(); - $res = $appTable->zQuery($query, array($pid)); + $appTable = new ApplicationTable(); + $res = $appTable->zQuery($query, array($pid)); $immunizations .= ''; foreach ($res as $row) { @@ -652,8 +652,8 @@ class EncounterccdadispatchTable extends AbstractTableGateway $wherCon = "AND b.encounter = $encounter"; } - $procedure = ''; - $query = "select b.id, b.date as proc_date, b.code_text, b.code, fe.date, + $procedure = ''; + $query = "select b.id, b.date as proc_date, b.code_text, b.code, fe.date, u.fname, u.lname, u.mname, u.npi, u.street, u.city, u.state, u.zip, f.id as fid, f.name, f.phone, f.street as fstreet, f.city as fcity, f.state as fstate, f.postal_code as fzip, f.country_code, f.phone as fphone from billing as b @@ -663,8 +663,8 @@ class EncounterccdadispatchTable extends AbstractTableGateway LEFT JOIN users AS u ON u.id = b.provider_id LEFT JOIN facility AS f ON f.id = fe.facility_id where b.pid = ? and b.activity = ? $wherCon"; - $appTable = new ApplicationTable(); - $res = $appTable->zQuery($query, array($pid,1)); + $appTable = new ApplicationTable(); + $res = $appTable->zQuery($query, array($pid, 1)); $procedure = ''; foreach ($res as $row) { @@ -715,8 +715,8 @@ class EncounterccdadispatchTable extends AbstractTableGateway JOIN procedure_report AS pr ON pr.procedure_order_id = po.procedure_order_id JOIN procedure_result AS prs ON prs.procedure_report_id = pr.procedure_report_id WHERE po.patient_id = ? AND prs.result NOT IN ('DNR','TNP') $wherCon"; - $appTable = new ApplicationTable(); - $res = $appTable->zQuery($query, array($pid)); + $appTable = new ApplicationTable(); + $res = $appTable->zQuery($query, array($pid)); $results_list = array(); foreach ($res as $row) { @@ -797,7 +797,7 @@ class EncounterccdadispatchTable extends AbstractTableGateway } $results = ""; - $query = "SELECT fe.date, fe.encounter,fe.reason, + $query = "SELECT fe.date, fe.encounter,fe.reason, f.id as fid, f.name, f.phone, f.street as fstreet, f.city as fcity, f.state as fstate, f.postal_code as fzip, f.country_code, f.phone as fphone, f.facility_npi as fnpi, f.facility_code as foid, u.fname, u.mname, u.lname, u.npi, u.street, u.city, u.state, u.zip, u.phonew1, cat.pc_catname, lo.title, lo.codes AS physician_type_code, SUBSTRING(ll.diagnosis, LENGTH('SNOMED-CT:')+1, LENGTH(ll.diagnosis)) AS encounter_diagnosis, ll.title, ll.begdate, ll.enddate @@ -809,8 +809,8 @@ class EncounterccdadispatchTable extends AbstractTableGateway LEFT JOIN issue_encounter AS ie ON ie.encounter=fe.encounter AND ie.pid=fe.pid LEFT JOIN lists AS ll ON ll.id=ie.list_id AND ll.pid=fe.pid WHERE fe.pid = ? $wherCon ORDER BY fe.date"; - $appTable = new ApplicationTable(); - $res = $appTable->zQuery($query, array('physician_type', $pid)); + $appTable = new ApplicationTable(); + $res = $appTable->zQuery($query, array('physician_type', $pid)); $results = ""; foreach ($res as $row) { @@ -820,12 +820,12 @@ class EncounterccdadispatchTable extends AbstractTableGateway } $codes = ""; - $query_procedures = "SELECT c.code, c.code_text FROM billing AS b + $query_procedures = "SELECT c.code, c.code_text FROM billing AS b JOIN code_types AS ct ON ct.ct_key = ? JOIN codes AS c ON c.code = b.code AND c.code_type = ct.ct_id WHERE b.pid = ? AND b.code_type = ? AND activity = 1 AND b.encounter = ?"; $appTable_procedures = new ApplicationTable(); - $res_procedures = $appTable_procedures->zQuery($query_procedures, array('CPT4', $pid, 'CPT4', $row['encounter'])); + $res_procedures = $appTable_procedures->zQuery($query_procedures, array('CPT4', $pid, 'CPT4', $row['encounter'])); foreach ($res_procedures as $row_procedures) { $codes .= " @@ -957,8 +957,8 @@ class EncounterccdadispatchTable extends AbstractTableGateway public function getDischargeMedications($pid, $encounter) { - $discharge_medications = ''; - $formTables_details = $this->fetchFields('discharge_summary', 'hospital_discharge_medications', 1); + $discharge_medications = ''; + $formTables_details = $this->fetchFields('discharge_summary', 'hospital_discharge_medications', 1); $result = $this->fetchFormValues($pid, $encounter, $formTables_details); $discharge_medications .= ""; @@ -983,12 +983,12 @@ class EncounterccdadispatchTable extends AbstractTableGateway */ public function getComplications($pid, $encounter) { - $complications = ''; + $complications = ''; $formTables_details = $this->fetchFields('procedure_note', 'complications', 1); - $result = $this->fetchFormValues($pid, $encounter, $formTables_details); + $result = $this->fetchFormValues($pid, $encounter, $formTables_details); - $complications .= ""; - $complications .= "" . $this->getAge($pid) . ""; + $complications .= ""; + $complications .= "" . $this->getAge($pid) . ""; foreach ($result as $row) { $complications .= htmlspecialchars(implode(' ', $row), ENT_QUOTES); } @@ -1007,17 +1007,17 @@ class EncounterccdadispatchTable extends AbstractTableGateway */ public function getPostProcedureDiag($pid, $encounter) { - $procedure_diag = ''; + $procedure_diag = ''; $formTables_details = $this->fetchFields('procedure_note', 'postprocedure_diagnosis', 1); - $result = $this->fetchFormValues($pid, $encounter, $formTables_details); + $result = $this->fetchFormValues($pid, $encounter, $formTables_details); - $procedure_diag .= ''; - $procedure_diag .= "" . $this->getAge($pid) . ""; + $procedure_diag .= ''; + $procedure_diag .= "" . $this->getAge($pid) . ""; foreach ($result as $row) { $procedure_diag .= htmlspecialchars(implode(' ', $row), ENT_QUOTES); } - $procedure_diag .= ''; + $procedure_diag .= ''; return $procedure_diag; } @@ -1031,9 +1031,9 @@ class EncounterccdadispatchTable extends AbstractTableGateway */ public function getProcedureDescription($pid, $encounter) { - $procedure_description = ''; - $formTables_details = $this->fetchFields('procedure_note', 'procedure_description', 1); - $result = $this->fetchFormValues($pid, $encounter, $formTables_details); + $procedure_description = ''; + $formTables_details = $this->fetchFields('procedure_note', 'procedure_description', 1); + $result = $this->fetchFormValues($pid, $encounter, $formTables_details); $procedure_description .= ""; foreach ($result as $row) { @@ -1054,11 +1054,11 @@ class EncounterccdadispatchTable extends AbstractTableGateway */ public function getProcedureIndications($pid, $encounter) { - $procedure_indications = ''; - $formTables_details = $this->fetchFields('procedure_note', 'procedure_indications', 1); - $result = $this->fetchFormValues($pid, $encounter, $formTables_details); + $procedure_indications = ''; + $formTables_details = $this->fetchFields('procedure_note', 'procedure_indications', 1); + $result = $this->fetchFormValues($pid, $encounter, $formTables_details); - $procedure_indications .= ""; + $procedure_indications .= ""; foreach ($result as $row) { $procedure_indications .= htmlspecialchars(implode(' ', $row), ENT_QUOTES); } @@ -1081,15 +1081,15 @@ class EncounterccdadispatchTable extends AbstractTableGateway public function getAnesthesia($pid, $encounter) { $anesthesia = ''; - $formTables_details = $this->fetchFields('operative_note', 'anesthesia', 1); - $result = $this->fetchFormValues($pid, $encounter, $formTables_details); + $formTables_details = $this->fetchFields('operative_note', 'anesthesia', 1); + $result = $this->fetchFormValues($pid, $encounter, $formTables_details); - $anesthesia .= ""; + $anesthesia .= ""; foreach ($result as $row) { - $anesthesia .= htmlspecialchars(implode(' ', $row), ENT_QUOTES); + $anesthesia .= htmlspecialchars(implode(' ', $row), ENT_QUOTES); } - $anesthesia .= ""; + $anesthesia .= ""; return $anesthesia; } @@ -1103,15 +1103,15 @@ class EncounterccdadispatchTable extends AbstractTableGateway public function getPostoperativeDiag($pid, $encounter) { $post_operative_diag = ''; - $formTables_details = $this->fetchFields('operative_note', 'post_operative_diagnosis', 1); - $result = $this->fetchFormValues($pid, $encounter, $formTables_details); + $formTables_details = $this->fetchFields('operative_note', 'post_operative_diagnosis', 1); + $result = $this->fetchFormValues($pid, $encounter, $formTables_details); - $post_operative_diag .= ""; + $post_operative_diag .= ""; foreach ($result as $row) { - $post_operative_diag .= htmlspecialchars(implode(' ', $row), ENT_QUOTES); + $post_operative_diag .= htmlspecialchars(implode(' ', $row), ENT_QUOTES); } - $post_operative_diag .= ""; + $post_operative_diag .= ""; return $post_operative_diag; } @@ -1125,15 +1125,15 @@ class EncounterccdadispatchTable extends AbstractTableGateway public function getPreOperativeDiag($pid, $encounter) { $pre_operative_diag = ''; - $formTables_details = $this->fetchFields('operative_note', 'pre_operative_diagnosis', 1); - $result = $this->fetchFormValues($pid, $encounter, $formTables_details); + $formTables_details = $this->fetchFields('operative_note', 'pre_operative_diagnosis', 1); + $result = $this->fetchFormValues($pid, $encounter, $formTables_details); - $pre_operative_diag .= ""; + $pre_operative_diag .= ""; foreach ($result as $row) { - $pre_operative_diag .= htmlspecialchars(implode(' ', $row), ENT_QUOTES); + $pre_operative_diag .= htmlspecialchars(implode(' ', $row), ENT_QUOTES); } - $pre_operative_diag .= ""; + $pre_operative_diag .= ""; return $pre_operative_diag; } @@ -1147,15 +1147,15 @@ class EncounterccdadispatchTable extends AbstractTableGateway public function getEstimatedBloodLoss($pid, $encounter) { $estimated_blood_loss = ''; - $formTables_details = $this->fetchFields('operative_note', 'procedure_estimated_blood_loss', 1); - $result = $this->fetchFormValues($pid, $encounter, $formTables_details); + $formTables_details = $this->fetchFields('operative_note', 'procedure_estimated_blood_loss', 1); + $result = $this->fetchFormValues($pid, $encounter, $formTables_details); - $estimated_blood_loss .= ""; + $estimated_blood_loss .= ""; foreach ($result as $row) { - $estimated_blood_loss .= htmlspecialchars(implode(' ', $row), ENT_QUOTES); + $estimated_blood_loss .= htmlspecialchars(implode(' ', $row), ENT_QUOTES); } - $estimated_blood_loss .= ""; + $estimated_blood_loss .= ""; return $estimated_blood_loss; } @@ -1169,15 +1169,15 @@ class EncounterccdadispatchTable extends AbstractTableGateway public function getProcedureFindings($pid, $encounter) { $procedure_findings = ''; - $formTables_details = $this->fetchFields('operative_note', 'procedure_findings', 1); - $result = $this->fetchFormValues($pid, $encounter, $formTables_details); + $formTables_details = $this->fetchFields('operative_note', 'procedure_findings', 1); + $result = $this->fetchFormValues($pid, $encounter, $formTables_details); - $procedure_findings .= ""; + $procedure_findings .= ""; foreach ($result as $row) { - $procedure_findings .= htmlspecialchars(implode(' ', $row), ENT_QUOTES); + $procedure_findings .= htmlspecialchars(implode(' ', $row), ENT_QUOTES); } - $procedure_findings .= "" . $this->getAge($pid) . ""; + $procedure_findings .= "" . $this->getAge($pid) . ""; return $procedure_findings; } @@ -1191,15 +1191,15 @@ class EncounterccdadispatchTable extends AbstractTableGateway public function getProcedureSpecimensTaken($pid, $encounter) { $procedure_specimens = ''; - $formTables_details = $this->fetchFields('operative_note', 'procedure_specimens_taken', 1); - $result = $this->fetchFormValues($pid, $encounter, $formTables_details); + $formTables_details = $this->fetchFields('operative_note', 'procedure_specimens_taken', 1); + $result = $this->fetchFormValues($pid, $encounter, $formTables_details); - $procedure_specimens .= ""; + $procedure_specimens .= ""; foreach ($result as $row) { - $procedure_specimens .= htmlspecialchars(implode(' ', $row), ENT_QUOTES); + $procedure_specimens .= htmlspecialchars(implode(' ', $row), ENT_QUOTES); } - $procedure_specimens .= ""; + $procedure_specimens .= ""; return $procedure_specimens; } @@ -1217,11 +1217,11 @@ class EncounterccdadispatchTable extends AbstractTableGateway { $hp = ''; $formTables_details = $this->fetchFields('consultation_note', 'history_of_present_illness', 1); - $result = $this->fetchFormValues($pid, $encounter, $formTables_details); + $result = $this->fetchFormValues($pid, $encounter, $formTables_details); $hp .= ""; foreach ($result as $row) { - $hp .= htmlspecialchars(implode(' ', $row), ENT_QUOTES); + $hp .= htmlspecialchars(implode(' ', $row), ENT_QUOTES); } $hp .= ""; @@ -1238,15 +1238,15 @@ class EncounterccdadispatchTable extends AbstractTableGateway public function getPhysicalExam($pid, $encounter) { $physical_exam = ''; - $formTables_details = $this->fetchFields('consultation_note', 'physical_exam', 1); - $result = $this->fetchFormValues($pid, $encounter, $formTables_details); + $formTables_details = $this->fetchFields('consultation_note', 'physical_exam', 1); + $result = $this->fetchFormValues($pid, $encounter, $formTables_details); - $physical_exam .= ""; + $physical_exam .= ""; foreach ($result as $row) { - $physical_exam .= htmlspecialchars(implode(' ', $row), ENT_QUOTES); + $physical_exam .= htmlspecialchars(implode(' ', $row), ENT_QUOTES); } - $physical_exam .= ""; + $physical_exam .= ""; return $physical_exam; } @@ -1263,15 +1263,15 @@ class EncounterccdadispatchTable extends AbstractTableGateway public function getChiefComplaint($pid, $encounter) { $chief_complaint = ''; - $formTables_details = $this->fetchFields('history_physical_note', 'chief_complaint', 1); - $result = $this->fetchFormValues($pid, $encounter, $formTables_details); + $formTables_details = $this->fetchFields('history_physical_note', 'chief_complaint', 1); + $result = $this->fetchFormValues($pid, $encounter, $formTables_details); - $chief_complaint .= ""; + $chief_complaint .= ""; foreach ($result as $row) { - $chief_complaint .= htmlspecialchars(implode(' ', $row), ENT_QUOTES); + $chief_complaint .= htmlspecialchars(implode(' ', $row), ENT_QUOTES); } - $chief_complaint .= ""; + $chief_complaint .= ""; return $chief_complaint; } @@ -1285,15 +1285,15 @@ class EncounterccdadispatchTable extends AbstractTableGateway public function getGeneralStatus($pid, $encounter) { $general_status = ''; - $formTables_details = $this->fetchFields('history_physical_note', 'general_status', 1); - $result = $this->fetchFormValues($pid, $encounter, $formTables_details); + $formTables_details = $this->fetchFields('history_physical_note', 'general_status', 1); + $result = $this->fetchFormValues($pid, $encounter, $formTables_details); - $general_status .= ""; + $general_status .= ""; foreach ($result as $row) { - $general_status .= htmlspecialchars(implode(' ', $row), ENT_QUOTES); + $general_status .= htmlspecialchars(implode(' ', $row), ENT_QUOTES); } - $general_status .= ""; + $general_status .= ""; return $general_status; } @@ -1307,15 +1307,15 @@ class EncounterccdadispatchTable extends AbstractTableGateway public function getHistoryOfPastIllness($pid, $encounter) { $history_past_illness = ''; - $formTables_details = $this->fetchFields('history_physical_note', 'hpi_past_med', 1); - $result = $this->fetchFormValues($pid, $encounter, $formTables_details); + $formTables_details = $this->fetchFields('history_physical_note', 'hpi_past_med', 1); + $result = $this->fetchFormValues($pid, $encounter, $formTables_details); - $history_past_illness .= ""; + $history_past_illness .= ""; foreach ($result as $row) { - $history_past_illness .= htmlspecialchars(implode(' ', $row), ENT_QUOTES); + $history_past_illness .= htmlspecialchars(implode(' ', $row), ENT_QUOTES); } - $history_past_illness .= ""; + $history_past_illness .= ""; return $history_past_illness; } @@ -1329,15 +1329,15 @@ class EncounterccdadispatchTable extends AbstractTableGateway public function getReviewOfSystems($pid, $encounter) { $review_of_systems = ''; - $formTables_details = $this->fetchFields('history_physical_note', 'review_of_systems', 1); - $result = $this->fetchFormValues($pid, $encounter, $formTables_details); + $formTables_details = $this->fetchFields('history_physical_note', 'review_of_systems', 1); + $result = $this->fetchFormValues($pid, $encounter, $formTables_details); - $review_of_systems .= ""; + $review_of_systems .= ""; foreach ($result as $row) { - $review_of_systems .= htmlspecialchars(implode(' ', $row), ENT_QUOTES); + $review_of_systems .= htmlspecialchars(implode(' ', $row), ENT_QUOTES); } - $review_of_systems .= ""; + $review_of_systems .= ""; return $review_of_systems; } @@ -1356,31 +1356,31 @@ class EncounterccdadispatchTable extends AbstractTableGateway } $vitals = ''; - $query = "SELECT DATE(fe.date) AS date, fv.id, temperature, bpd, bps, head_circ, pulse, height, oxygen_saturation, weight, BMI FROM forms AS f + $query = "SELECT DATE(fe.date) AS date, fv.id, temperature, bpd, bps, head_circ, pulse, height, oxygen_saturation, weight, BMI FROM forms AS f JOIN form_encounter AS fe ON fe.encounter = f.encounter AND fe.pid = f.pid JOIN form_vitals AS fv ON fv.id = f.form_id WHERE f.pid = ? AND f.formdir = 'vitals' AND f.deleted=0 $wherCon ORDER BY fe.date DESC"; - $appTable = new ApplicationTable(); - $res = $appTable->zQuery($query, array($pid)); + $appTable = new ApplicationTable(); + $res = $appTable->zQuery($query, array($pid)); - $vitals .= ""; + $vitals .= ""; foreach ($res as $row) { $convWeightValue = number_format($row['weight'] * 0.45359237, 2); $convHeightValue = round(number_format($row['height'] * 2.54, 2), 1); if ($GLOBALS['units_of_measurement'] == 2 || $GLOBALS['units_of_measurement'] == 4) { $weight_value = $convWeightValue; - $weight_unit = 'kg'; + $weight_unit = 'kg'; $height_value = $convHeightValue; - $height_unit = 'cm'; + $height_unit = 'cm'; } else { $temp = US_weight($row['weight'], 1); $tempArr = explode(" ", $temp); $weight_value = $tempArr[0]; $weight_unit = 'lb'; $height_value = $row['height']; - $height_unit = 'in'; + $height_unit = 'in'; } $vitals .= " @@ -1413,7 +1413,7 @@ class EncounterccdadispatchTable extends AbstractTableGateway "; } - $vitals .= ""; + $vitals .= ""; return $vitals; } @@ -1428,28 +1428,28 @@ class EncounterccdadispatchTable extends AbstractTableGateway { $social_history = ''; $arr = array( - 'alcohol' => '160573003', - 'drug' => '363908000', - 'employment' => '364703007', - 'exercise' => '256235009', - 'other_social_history' => '228272008', - 'diet' => '364393001', - 'smoking' => '229819007', - 'toxic_exposure' => '425400000' + 'alcohol' => '160573003', + 'drug' => '363908000', + 'employment' => '364703007', + 'exercise' => '256235009', + 'other_social_history' => '228272008', + 'diet' => '364393001', + 'smoking' => '229819007', + 'toxic_exposure' => '425400000' ); $arr_status = array( - 'currenttobacco' => 'Current', - 'quittobacco' => 'Quit', - 'nevertobacco' => 'Never', - 'currentalcohol' => 'Current', - 'quitalcohol' => 'Quit', - 'neveralcohol' => 'Never' + 'currenttobacco' => 'Current', + 'quittobacco' => 'Quit', + 'nevertobacco' => 'Never', + 'currentalcohol' => 'Current', + 'quitalcohol' => 'Quit', + 'neveralcohol' => 'Never' ); $snomeds_status = array( - 'currenttobacco' => 'completed', - 'quittobacco' => 'completed', - 'nevertobacco' => 'completed', + 'currenttobacco' => 'completed', + 'quittobacco' => 'completed', + 'nevertobacco' => 'completed', 'not_applicabletobacco' => 'completed' ); @@ -1462,38 +1462,38 @@ class EncounterccdadispatchTable extends AbstractTableGateway ); $alcohol_status = array( - 'currentalcohol' => 'completed', - 'quitalcohol' => 'completed', - 'neveralcohol' => 'completed' + 'currentalcohol' => 'completed', + 'quitalcohol' => 'completed', + 'neveralcohol' => 'completed' ); $alcohol_status_codes = array( - 'currentalcohol' => '11', - 'quitalcohol' => '22', - 'neveralcohol' => '33' + 'currentalcohol' => '11', + 'quitalcohol' => '22', + 'neveralcohol' => '33' ); $query = "SELECT id, tobacco, alcohol, exercise_patterns, recreational_drugs FROM history_data WHERE pid=? ORDER BY id DESC LIMIT 1"; - $appTable = new ApplicationTable(); - $res = $appTable->zQuery($query, array($pid)); + $appTable = new ApplicationTable(); + $res = $appTable->zQuery($query, array($pid)); $social_history .= ""; foreach ($res as $row) { - $tobacco = explode('|', $row['tobacco']); - $status_code = CarecoordinationTable::getListCodes($tobacco[3], 'smoking_status'); - $status_code = str_replace("SNOMED-CT:", "", $status_code); + $tobacco = explode('|', $row['tobacco']); + $status_code = (new CarecoordinationTable())->getListCodes($tobacco[3], 'smoking_status'); + $status_code = str_replace("SNOMED-CT:", "", $status_code); $social_history .= " " . htmlspecialchars(base64_encode('smoking' . $_SESSION['site_id'] . $row['id']), ENT_QUOTES) . " " . htmlspecialchars("9b56c25d-9104-45ee-9fa4-e0f3afaa01c1", ENT_QUOTES) . " " . htmlspecialchars('Smoking', ENT_QUOTES) . " - " . htmlspecialchars(CarecoordinationTable::getListTitle($tobacco[3], 'smoking_status'), ENT_QUOTES) . " + " . htmlspecialchars((new CarecoordinationTable())->getListTitle($tobacco[3], 'smoking_status'), ENT_QUOTES) . " " . htmlspecialchars(($status_code ? $status_code : 0), ENT_QUOTES) . " " . htmlspecialchars(($snomeds_status[$tobacco[1]] ? $snomeds_status[$tobacco[1]] : 'NULL'), ENT_QUOTES) . " " . ($tobacco[2] ? htmlspecialchars($this->date_format($tobacco[2]), ENT_QUOTES) : 0) . " " . ($tobacco[2] ? htmlspecialchars(preg_replace('/-/', '', $tobacco[2]), ENT_QUOTES) : 0) . " " . htmlspecialchars(($arr['smoking'] ? $arr['smoking'] : 0), ENT_QUOTES) . " "; - $alcohol = explode('|', $row['alcohol']); + $alcohol = explode('|', $row['alcohol']); $social_history .= " " . htmlspecialchars(base64_encode('alcohol' . $_SESSION['site_id'] . $row['id']), ENT_QUOTES) . " " . htmlspecialchars("37f76c51-6411-4e1d-8a37-957fd49d2cef", ENT_QUOTES) . " @@ -1519,33 +1519,33 @@ class EncounterccdadispatchTable extends AbstractTableGateway public function getUnstructuredDocuments($pid, $encounter) { $image = ''; - $formTables_details = $this->fetchFields('unstructured_document', 'unstructured_doc', 1); - $result = $this->fetchFormValues($pid, $encounter, $formTables_details); + $formTables_details = $this->fetchFields('unstructured_document', 'unstructured_doc', 1); + $result = $this->fetchFormValues($pid, $encounter, $formTables_details); - $image .= ""; + $image .= ""; foreach ($result as $row) { foreach ($row as $key => $value) { - $image .= ""; - $image .= "" . $row[$key][1] . ""; - $image .= "" . $row[$key][0] . ""; - $image .= ""; + $image .= ""; + $image .= "" . $row[$key][1] . ""; + $image .= "" . $row[$key][0] . ""; + $image .= ""; } } - $image .= ""; + $image .= ""; return $image; } public function getDetails($field_name) { if ($field_name == 'hie_custodian_id') { - $query = "SELECT f.name AS organization, f.street, f.city, f.state, f.postal_code AS zip, f.phone AS phonew1 + $query = "SELECT f.name AS organization, f.street, f.city, f.state, f.postal_code AS zip, f.phone AS phonew1 FROM facility AS f JOIN modules AS mo ON mo.mod_directory='Carecoordination' JOIN module_configuration AS conf ON conf.field_value=f.id AND mo.mod_id=conf.module_id WHERE conf.field_name=?"; } else { - $query = "SELECT u.title, u.fname, u.mname, u.lname, u.npi, u.street, u.city, u.state, u.zip, CONCAT_WS(' ','',u.phonew1) AS phonew1, u.organization, u.specialty, conf.field_name, mo.mod_name, lo.title as physician_type, SUBSTRING(lo.codes, LENGTH('SNOMED-CT:')+1, LENGTH(lo.codes)) as physician_type_code + $query = "SELECT u.title, u.fname, u.mname, u.lname, u.npi, u.street, u.city, u.state, u.zip, CONCAT_WS(' ','',u.phonew1) AS phonew1, u.organization, u.specialty, conf.field_name, mo.mod_name, lo.title as physician_type, SUBSTRING(lo.codes, LENGTH('SNOMED-CT:')+1, LENGTH(lo.codes)) as physician_type_code FROM users AS u LEFT JOIN list_options AS lo ON lo.list_id = 'physician_type' AND lo.option_id = u.physician_type JOIN modules AS mo ON mo.mod_directory='Carecoordination' @@ -1553,8 +1553,8 @@ class EncounterccdadispatchTable extends AbstractTableGateway WHERE conf.field_name=?"; } - $appTable = new ApplicationTable(); - $res = $appTable->zQuery($query, array($field_name)); + $appTable = new ApplicationTable(); + $res = $appTable->zQuery($query, array($field_name)); foreach ($res as $result) { return $result; } @@ -1575,12 +1575,12 @@ class EncounterccdadispatchTable extends AbstractTableGateway } $age = 0; - $query = "select ROUND(DATEDIFF('$date',DOB)/365.25) AS age from patient_data where pid= ? "; - $appTable = new ApplicationTable(); - $res = $appTable->zQuery($query, array($pid)); + $query = "select ROUND(DATEDIFF('$date',DOB)/365.25) AS age from patient_data where pid= ? "; + $appTable = new ApplicationTable(); + $res = $appTable->zQuery($query, array($pid)); foreach ($res as $row) { - $age = $row['age']; + $age = $row['age']; } return $age; @@ -1588,9 +1588,9 @@ class EncounterccdadispatchTable extends AbstractTableGateway public function getRepresentedOrganization() { - $query = "select * from facility where primary_business_entity = 1"; - $appTable = new ApplicationTable(); - $res = $appTable->zQuery($query, array($pid)); + $query = "select * from facility where primary_business_entity = 1"; + $appTable = new ApplicationTable(); + $res = $appTable->zQuery($query, array($pid)); $records = array(); foreach ($res as $row) { @@ -1613,8 +1613,8 @@ class EncounterccdadispatchTable extends AbstractTableGateway $query = "select * from ccda_table_mapping left join ccda_field_mapping as ccf on ccf.table_id = ccda_table_mapping.id where ccda_component = ? and ccda_component_section = ? and user_id = ? and deleted = 0"; - $appTable = new ApplicationTable(); - $res = $appTable->zQuery($query, array($ccda_component, $ccda_section, $user_id)); + $appTable = new ApplicationTable(); + $res = $appTable->zQuery($query, array($ccda_component, $ccda_section, $user_id)); $ret = array(); $field_names_type1 = ''; @@ -1663,9 +1663,9 @@ class EncounterccdadispatchTable extends AbstractTableGateway $count_folder = 0; foreach ($formTables as $formTables_details) { /***************Fetching the form id for the patient***************/ - $query = "select form_id,encounter from forms where pid = ? and formdir = ? AND deleted=0"; - $appTable = new ApplicationTable(); - $form_ids = $appTable->zQuery($query, array($pid, $formTables_details[2])); + $query = "select form_id,encounter from forms where pid = ? and formdir = ? AND deleted=0"; + $appTable = new ApplicationTable(); + $form_ids = $appTable->zQuery($query, array($pid, $formTables_details[2])); /***************Fetching the form id for the patient***************/ if ($formTables_details[0] == 1) {//Fetching the values from an HTML form @@ -1683,8 +1683,8 @@ class EncounterccdadispatchTable extends AbstractTableGateway } } else {//Fetching a single field from the table $primary_key = ''; - $query = "SHOW INDEX FROM ? WHERE Key_name='PRIMARY'"; - $appTable = new ApplicationTable(); + $query = "SHOW INDEX FROM ? WHERE Key_name='PRIMARY'"; + $appTable = new ApplicationTable(); $res_primary = $appTable->zQuery($query, array($formTables_details[1])); foreach ($res_primary as $row_primary) { $primary_key = $row_primary['Column_name']; @@ -1692,11 +1692,11 @@ class EncounterccdadispatchTable extends AbstractTableGateway unset($res_primary); - $query = "select " . $formTables_details[3] . " from " . $formTables_details[1] . " + $query = "select " . $formTables_details[3] . " from " . $formTables_details[1] . " join forms as f on f.pid=? AND f.encounter=? AND f.form_id=" . $formTables_details[1] . "." . $primary_key . " AND f.formdir=? where 1 = 1 "; - $appTable = new ApplicationTable(); - $result = $appTable->zQuery($query, array($pid, $encounter, $formTables_details[2])); + $appTable = new ApplicationTable(); + $result = $appTable->zQuery($query, array($pid, $encounter, $formTables_details[2])); foreach ($result as $row) { foreach ($row as $key => $value) { @@ -1717,9 +1717,9 @@ class EncounterccdadispatchTable extends AbstractTableGateway ob_start(); ?> - +
    $value) { if ($fields_str != '') { $fields_str .= ","; @@ -1754,11 +1754,11 @@ class EncounterccdadispatchTable extends AbstractTableGateway $fields_str .= "'$value'"; } - $query = "select * from " . $lbf . " + $query = "select * from " . $lbf . " join forms as f on f.pid = ? AND f.form_id = " . $lbf . ".form_id AND f.formdir = ? AND " . $lbf . ".field_id IN (" . $fields_str . ") where deleted = 0"; - $appTable = new ApplicationTable(); - $result = $appTable->zQuery($query, array($pid, $formTables_details[2])); + $appTable = new ApplicationTable(); + $result = $appTable->zQuery($query, array($pid, $formTables_details[2])); foreach ($result as $row) { preg_match('/\.$/', trim($row['field_value']), $matches); @@ -1770,12 +1770,12 @@ class EncounterccdadispatchTable extends AbstractTableGateway } } } elseif ($formTables_details[0] == 3) {//Fetching documents from mapped folders - $query = "SELECT c.id, c.name, d.id AS document_id, d.type, d.mimetype, d.url, d.docdate + $query = "SELECT c.id, c.name, d.id AS document_id, d.type, d.mimetype, d.url, d.docdate FROM categories AS c, documents AS d, categories_to_documents AS c2d WHERE c.id = ? AND c.id = c2d.category_id AND c2d.document_id = d.id AND d.foreign_id = ?"; - $appTable = new ApplicationTable(); - $result = $appTable->zQuery($query, array($formTables_details[2], $pid)); + $appTable = new ApplicationTable(); + $result = $appTable->zQuery($query, array($formTables_details[2], $pid)); foreach ($result as $row_folders) { $r = \Documents\Plugin\Documents::getDocument($row_folders['document_id']); @@ -1801,8 +1801,8 @@ class EncounterccdadispatchTable extends AbstractTableGateway $query = "SELECT mo_conf.field_value FROM modules AS mo LEFT JOIN module_configuration AS mo_conf ON mo_conf.module_id = mo.mod_id WHERE mo.mod_directory = ? AND mo_conf.field_name = ?"; - $appTable = new ApplicationTable(); - $result = $appTable->zQuery($query, array($module_directory, $field_name)); + $appTable = new ApplicationTable(); + $result = $appTable->zQuery($query, array($module_directory, $field_name)); foreach ($result as $row) { return $row['field_value']; } @@ -1816,14 +1816,14 @@ class EncounterccdadispatchTable extends AbstractTableGateway */ public function getEncounterDate($date) { - $date_list = array(); - $query = "select pid, encounter from form_encounter where date between ? and ?"; - $appTable = new ApplicationTable(); - $result = $appTable->zQuery($query, array($date, $date)); + $date_list = array(); + $query = "select pid, encounter from form_encounter where date between ? and ?"; + $appTable = new ApplicationTable(); + $result = $appTable->zQuery($query, array($date, $date)); - $count = 0; + $count = 0; foreach ($result as $row) { - $date_list[$count]['pid'] = $row['pid']; + $date_list[$count]['pid'] = $row['pid']; $date_list[$count]['encounter'] = $row['encounter']; $count++; } @@ -1841,56 +1841,56 @@ class EncounterccdadispatchTable extends AbstractTableGateway public function signOff($pid, $encounter) { /*Saving Demographics to locked data*/ - $query_patient_data = "SELECT * FROM patient_data WHERE pid = ?"; - $appTable = new ApplicationTable(); - $result_patient_data = $appTable->zQuery($query_patient_data, array($pid)); + $query_patient_data = "SELECT * FROM patient_data WHERE pid = ?"; + $appTable = new ApplicationTable(); + $result_patient_data = $appTable->zQuery($query_patient_data, array($pid)); foreach ($result_patient_data as $row_patient_data) { } $query_dem = "SELECT field_id FROM layout_options WHERE form_id = ?"; - $appTable = new ApplicationTable(); - $result_dem = $appTable->zQuery($query_dem, array('DEM')); + $appTable = new ApplicationTable(); + $result_dem = $appTable->zQuery($query_dem, array('DEM')); foreach ($result_dem as $row_dem) { - $query_insert_patient_data = "INSERT INTO combination_form_locked_data SET pid = ?, encounter = ?, form_dir = ?, field_name = ?, field_value = ?"; - $appTable = new ApplicationTable(); - $result_dem = $appTable->zQuery($query_insert_patient_data, array($pid, $encounter, 'DEM', $row_dem['field_id'], $row_patient_data[$row_dem['field_id']])); + $query_insert_patient_data = "INSERT INTO combination_form_locked_data SET pid = ?, encounter = ?, form_dir = ?, field_name = ?, field_value = ?"; + $appTable = new ApplicationTable(); + $result_dem = $appTable->zQuery($query_insert_patient_data, array($pid, $encounter, 'DEM', $row_dem['field_id'], $row_patient_data[$row_dem['field_id']])); } /*************************************/ - $query_saved_forms = "SELECT formid FROM combined_encountersaved_forms WHERE pid = ? AND encounter = ?"; - $appTable = new ApplicationTable(); - $result_saved_forms = $appTable->zQuery($query_saved_forms, array($pid, $encounter)); + $query_saved_forms = "SELECT formid FROM combined_encountersaved_forms WHERE pid = ? AND encounter = ?"; + $appTable = new ApplicationTable(); + $result_saved_forms = $appTable->zQuery($query_saved_forms, array($pid, $encounter)); $count = 0; foreach ($result_saved_forms as $row_saved_forms) { - $form_dir = ''; - $form_type = 0; - $form_id = 0; - $temp = explode('***', $row_saved_forms['formid']); + $form_dir = ''; + $form_type = 0; + $form_id = 0; + $temp = explode('***', $row_saved_forms['formid']); if ($temp[1] == 1) { //Fetch HTML form id from the Combination form template - $form_type = 0; - $form_dir = $temp[0]; + $form_type = 0; + $form_dir = $temp[0]; } else { //Fetch LBF form from the Combination form template $temp_1 = explode('*', $temp[1]); if ($temp_1[1] == 1) { //Complete LBF in Combination form - $form_type = 1; - $form_dir = $temp[0]; + $form_type = 1; + $form_dir = $temp[0]; } elseif ($temp_1[1] == 2) { //Particular section from LBF in Combination form - $temp_2 = explode('|', $temp[0]); - $form_type = 1; - $form_dir = $temp_2[0]; + $temp_2 = explode('|', $temp[0]); + $form_type = 1; + $form_dir = $temp_2[0]; } } /*Fetch form id from the concerned tables*/ if ($form_dir == 'HIS') { //Fetching History form id $query_form_id = "SELECT MAX(id) AS form_id FROM history_data WHERE pid = ?"; - $appTable = new ApplicationTable(); + $appTable = new ApplicationTable(); $result_form_id = $appTable->zQuery($query_form_id, array($pid)); } else { //Fetching normal form id $query_form_id = "select form_id from forms where pid = ? and encounter = ? and formdir = ?"; - $appTable = new ApplicationTable(); + $appTable = new ApplicationTable(); $result_form_id = $appTable->zQuery($query_form_id, array($pid, $encounter, $form_dir)); } @@ -1899,9 +1899,9 @@ class EncounterccdadispatchTable extends AbstractTableGateway } /****************************************/ - $forms[$count]['formdir'] = $form_dir; + $forms[$count]['formdir'] = $form_dir; $forms[$count]['formtype'] = $form_type; - $forms[$count]['formid'] = $form_id; + $forms[$count]['formid'] = $form_id; $this->lockedthisform($pid, $encounter, $form_dir, $form_type, $form_id); $count++; } @@ -1922,16 +1922,16 @@ class EncounterccdadispatchTable extends AbstractTableGateway */ public function lockedthisform($pid, $encounter, $formdir, $formtype, $formid) { - $query = "select count(*) as count from combination_form where pid = ? and encounter = ? and form_dir = ? and form_type = ? and form_id = ?"; - $appTable = new ApplicationTable(); - $result = $appTable->zQuery($query, array($pid, $encounter, $formdir, $formtype, $formid)); + $query = "select count(*) as count from combination_form where pid = ? and encounter = ? and form_dir = ? and form_type = ? and form_id = ?"; + $appTable = new ApplicationTable(); + $result = $appTable->zQuery($query, array($pid, $encounter, $formdir, $formtype, $formid)); foreach ($result as $count) { } if ($count['count'] == 0) { $query_insert = "INSERT INTO combination_form SET pid = ?, encounter = ?, form_dir = ?, form_type = ?, form_id = ?"; - $appTable = new ApplicationTable(); - $result = $appTable->zQuery($query_insert, array($pid, $encounter, $formdir, $formtype, $formid)); + $appTable = new ApplicationTable(); + $result = $appTable->zQuery($query_insert, array($pid, $encounter, $formdir, $formtype, $formid)); } } @@ -1944,9 +1944,9 @@ class EncounterccdadispatchTable extends AbstractTableGateway public function getCCDAComponents($type) { $components = array(); - $query = "select * from ccda_components where ccda_type = ?"; - $appTable = new ApplicationTable(); - $result = $appTable->zQuery($query, array($type)); + $query = "select * from ccda_components where ccda_type = ?"; + $appTable = new ApplicationTable(); + $result = $appTable->zQuery($query, array($type)); foreach ($result as $row) { $components[$row['ccda_components_field']] = $row['ccda_components_name']; @@ -1967,8 +1967,8 @@ class EncounterccdadispatchTable extends AbstractTableGateway */ public function logCCDA($pid, $encounter, $content, $time, $status, $user_id, $view = 0, $transfer = 0, $emr_transfer = 0) { - $content = base64_decode($content); - $file_path = ''; + $content = base64_decode($content); + $file_path = ''; $docid = ''; $revid = ''; if ($GLOBALS['document_storage_method'] == 1) { @@ -1985,8 +1985,8 @@ class EncounterccdadispatchTable extends AbstractTableGateway $docid = $resp->id; $revid = $resp->rev; } else { - $file_path = $GLOBALS['OE_SITE_DIR'] . '/documents/' . $pid . '/CCDA'; - $file_name = $pid . "_" . $encounter . "_" . $time . ".xml"; + $file_path = $GLOBALS['OE_SITE_DIR'] . '/documents/' . $pid . '/CCDA'; + $file_name = $pid . "_" . $encounter . "_" . $time . ".xml"; if (!is_dir($file_path)) { mkdir($file_path, 0777, true); } @@ -2004,17 +2004,17 @@ class EncounterccdadispatchTable extends AbstractTableGateway $file_path = $file_path . "/" . $file_name; } - $query = "insert into ccda (pid, encounter, ccda_data, time, status, user_id, couch_docid, couch_revid, view, transfer,emr_transfer, encrypted) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ? ,?, ?)"; - $appTable = new ApplicationTable(); - $result = $appTable->zQuery($query, array($pid, $encounter, $file_path, $time, $status, $user_id, $docid, $revid, $view, $transfer,$emr_transfer, $encrypted)); + $query = "insert into ccda (pid, encounter, ccda_data, time, status, user_id, couch_docid, couch_revid, view, transfer,emr_transfer, encrypted) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ? ,?, ?)"; + $appTable = new ApplicationTable(); + $result = $appTable->zQuery($query, array($pid, $encounter, $file_path, $time, $status, $user_id, $docid, $revid, $view, $transfer, $emr_transfer, $encrypted)); return $moduleInsertId = $result->getGeneratedValue(); } public function getCcdaLogDetails($logID = 0) { - $query_ccda_log = "SELECT pid, encounter, ccda_data, time, status, user_id, couch_docid, couch_revid, view, transfer,emr_transfer FROM ccda WHERE id = ?"; - $appTable = new ApplicationTable(); - $res_ccda_log = $appTable->zQuery($query_ccda_log, array($logID)); + $query_ccda_log = "SELECT pid, encounter, ccda_data, time, status, user_id, couch_docid, couch_revid, view, transfer,emr_transfer FROM ccda WHERE id = ?"; + $appTable = new ApplicationTable(); + $res_ccda_log = $appTable->zQuery($query_ccda_log, array($logID)); return $res_ccda_log->current(); } @@ -2060,41 +2060,41 @@ class EncounterccdadispatchTable extends AbstractTableGateway */ public function generate_code($code_text) { - $encrypted = sha1($code_text); - $code = ''; + $encrypted = sha1($code_text); + $code = ''; for ($i = 0; $i <= strlen($encrypted);) { - $code .= $encrypted[$i]; - $i = $i + 2; + $code .= $encrypted[$i]; + $i = $i + 2; } - $encrypted = $code; - $code = ''; + $encrypted = $code; + $code = ''; for ($i = 0; $i <= strlen($encrypted);) { - $code .= $encrypted[$i]; - $i = $i + 2; + $code .= $encrypted[$i]; + $i = $i + 2; } - $code = strtoupper(substr($code, 0, 6)); + $code = strtoupper(substr($code, 0, 6)); return $code; } public function getProviderId($pid) { - $appTable = new ApplicationTable(); - $query = "SELECT providerID FROM patient_data WHERE `pid` = ?"; - $result = $appTable->zQuery($query, array($pid)); - $row = $result->current(); + $appTable = new ApplicationTable(); + $query = "SELECT providerID FROM patient_data WHERE `pid` = ?"; + $result = $appTable->zQuery($query, array($pid)); + $row = $result->current(); return $row['providerID']; } public function getUserDetails($uid) { - $query = "SELECT u.title,npi,fname,mname,lname,street,city,state,zip,CONCAT_WS(' ','',phonew1) AS phonew1, lo.title as physician_type, + $query = "SELECT u.title,npi,fname,mname,lname,street,city,state,zip,CONCAT_WS(' ','',phonew1) AS phonew1, lo.title as physician_type, organization, specialty, SUBSTRING(lo.codes, LENGTH('SNOMED-CT:')+1, LENGTH(lo.codes)) as physician_type_code FROM users as u LEFT JOIN list_options AS lo ON lo.list_id = 'physician_type' AND lo.option_id = u.physician_type WHERE `id` = ?"; - $appTable = new ApplicationTable(); - $res = $appTable->zQuery($query, array($uid)); + $appTable = new ApplicationTable(); + $res = $appTable->zQuery($query, array($uid)); foreach ($res as $result) { return $result; } @@ -2117,6 +2117,7 @@ class EncounterccdadispatchTable extends AbstractTableGateway return $codes_installed; } + /* * get details from care plan form * @param int $pid Patient Internal Identifier. @@ -2127,10 +2128,10 @@ class EncounterccdadispatchTable extends AbstractTableGateway public function getPlanOfCare($pid, $encounter) { $wherCon = ''; - $appTable = new ApplicationTable(); + $appTable = new ApplicationTable(); if ($encounter) { - $query = "SELECT form_id FROM forms WHERE pid = ? AND formdir = ? AND deleted = 0 ORDER BY date DESC LIMIT 1"; - $result = $appTable->zQuery($query, array($pid,'care_plan')); + $query = "SELECT form_id FROM forms WHERE pid = ? AND formdir = ? AND deleted = 0 ORDER BY date DESC LIMIT 1"; + $result = $appTable->zQuery($query, array($pid, 'care_plan')); foreach ($result as $row) { $form_id = $row['form_id']; } @@ -2145,16 +2146,16 @@ class EncounterccdadispatchTable extends AbstractTableGateway // TODO: is there a better way to find out if the SNOMED tables have been installed through a global setting instead of describing the tables? $fcp_code_type = 'ct.`ct_key` AS fcp_code_type'; $sct_descriptions_join = ''; - $care_plan_query_data = ['Plan_of_Care_Type',$pid,'care_plan',0,$pid]; + $care_plan_query_data = ['Plan_of_Care_Type', $pid, 'care_plan', 0, $pid]; if ($this->is_snomed_codes_installed($appTable)) { $fcp_code_type = "IF(sct_descriptions.ConceptId,'SNOMED-CT',ct.`ct_key`) AS fcp_code_type"; $sct_descriptions_join = ' LEFT JOIN sct_descriptions ON sct_descriptions.ConceptId = fcp.`code` AND sct_descriptions.DescriptionStatus = ? AND sct_descriptions.DescriptionType = ? LEFT JOIN sct_concepts ON sct_descriptions.ConceptId = sct_concepts.ConceptId '; - $care_plan_query_data = array_merge([0,1], $care_plan_query_data); + $care_plan_query_data = array_merge([0, 1], $care_plan_query_data); } - $query = "SELECT 'care_plan' AS source,fcp.code,fcp.codetext,fcp.description,fcp.date," . $fcp_code_type . " , l.`notes` AS moodCode + $query = "SELECT 'care_plan' AS source,fcp.code,fcp.codetext,fcp.description,fcp.date," . $fcp_code_type . " , l.`notes` AS moodCode FROM forms AS f LEFT JOIN form_care_plan AS fcp ON fcp.id = f.form_id LEFT JOIN codes AS c ON c.code = fcp.code @@ -2170,7 +2171,7 @@ class EncounterccdadispatchTable extends AbstractTableGateway LEFT JOIN lbt_data AS l3 ON l3.form_id=t.id AND l3.field_id = 'refer_to' LEFT JOIN users AS u ON u.id = l3.field_value WHERE t.pid = ?"; - $res = $appTable->zQuery($query, $care_plan_query_data); + $res = $appTable->zQuery($query, $care_plan_query_data); $status = 'Pending'; $status_entry = 'active'; $planofcare .= ''; @@ -2201,13 +2202,14 @@ class EncounterccdadispatchTable extends AbstractTableGateway $planofcare .= ''; return $planofcare; } - /* - * get details from functional and cognitive status form - * @param int $pid Patient Internal Identifier. - * @param int $encounter Current selected encounter. - * return string $functional_cognitive XML which contains the details collected from the patient. - */ + /* + * get details from functional and cognitive status form + * @param int $pid Patient Internal Identifier. + * @param int $encounter Current selected encounter. + + * return string $functional_cognitive XML which contains the details collected from the patient. + */ public function getFunctionalCognitiveStatus($pid, $encounter) { $wherCon = ''; @@ -2216,21 +2218,21 @@ class EncounterccdadispatchTable extends AbstractTableGateway } $functional_cognitive = ''; - $query = "SELECT ffcs.* FROM forms AS f + $query = "SELECT ffcs.* FROM forms AS f LEFT JOIN form_functional_cognitive_status AS ffcs ON ffcs.id = f.form_id WHERE f.pid = ? AND f.formdir = ? AND f.deleted = ? $wherCon"; - $appTable = new ApplicationTable(); - $res = $appTable->zQuery($query, array($pid,'functional_cognitive_status',0)); + $appTable = new ApplicationTable(); + $res = $appTable->zQuery($query, array($pid, 'functional_cognitive_status', 0)); $functional_cognitive .= ''; foreach ($res as $row) { $status = $status_entry = ''; if ($row['activity'] == 1) { - $status = 'Active'; + $status = 'Active'; $status_code = '55561003'; $status_entry = 'completed'; } else { - $status = 'Inactive'; + $status = 'Inactive'; $status_code = '73425007'; $status_entry = 'completed'; } @@ -2254,10 +2256,10 @@ class EncounterccdadispatchTable extends AbstractTableGateway public function getCareTeamProviderId($pid) { - $appTable = new ApplicationTable(); - $query = "SELECT care_team FROM patient_data WHERE `pid` = ?"; - $result = $appTable->zQuery($query, array($pid)); - $row = $result->current(); + $appTable = new ApplicationTable(); + $query = "SELECT care_team FROM patient_data WHERE `pid` = ?"; + $result = $appTable->zQuery($query, array($pid)); + $row = $result->current(); return $row['care_team']; } @@ -2268,11 +2270,11 @@ class EncounterccdadispatchTable extends AbstractTableGateway $wherCon = "AND f.encounter = $encounter"; } - $query = "SELECT fci.* FROM forms AS f + $query = "SELECT fci.* FROM forms AS f LEFT JOIN form_clinical_instructions AS fci ON fci.id = f.form_id WHERE f.pid = ? AND f.formdir = ? AND f.deleted = ? $wherCon"; - $appTable = new ApplicationTable(); - $res = $appTable->zQuery($query, array($pid,'clinical_instructions',0)); + $appTable = new ApplicationTable(); + $res = $appTable->zQuery($query, array($pid, 'clinical_instructions', 0)); $clinical_instructions = ''; foreach ($res as $row) { $clinical_instructions .= '' . htmlspecialchars($row['instruction']) . ''; @@ -2289,10 +2291,10 @@ class EncounterccdadispatchTable extends AbstractTableGateway $wherCon = "ORDER BY date DESC LIMIT 1"; } - $appTable = new ApplicationTable(); + $appTable = new ApplicationTable(); $referrals = ''; - $query = "SELECT field_value FROM transactions JOIN lbt_data ON form_id=id AND field_id = 'body' WHERE pid = ? $wherCon"; - $result = $appTable->zQuery($query, array($pid)); + $query = "SELECT field_value FROM transactions JOIN lbt_data ON form_id=id AND field_id = 'body' WHERE pid = ? $wherCon"; + $result = $appTable->zQuery($query, array($pid)); $referrals = ''; foreach ($result as $row) { $referrals .= '' . htmlspecialchars($row['field_value']) . ''; @@ -2305,9 +2307,9 @@ class EncounterccdadispatchTable extends AbstractTableGateway public function getLatestEncounter($pid) { $encounter = ''; - $appTable = new ApplicationTable(); - $query = "SELECT encounter FROM form_encounter WHERE pid = ? ORDER BY id DESC LIMIT 1"; - $result = $appTable->zQuery($query, array($pid)); + $appTable = new ApplicationTable(); + $query = "SELECT encounter FROM form_encounter WHERE pid = ? ORDER BY id DESC LIMIT 1"; + $result = $appTable->zQuery($query, array($pid)); foreach ($result as $row) { $encounter = $row['encounter']; } @@ -2315,4 +2317,5 @@ class EncounterccdadispatchTable extends AbstractTableGateway return $encounter; } } + ?> diff --git a/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Model/EncountermanagerTable.php b/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Model/EncountermanagerTable.php index fcbf01e28..5f4cf6923 100644 --- a/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Model/EncountermanagerTable.php +++ b/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Model/EncountermanagerTable.php @@ -199,7 +199,7 @@ class EncountermanagerTable extends AbstractTableGateway return("$config_err 1"); } - $fp = \Application\Plugin\Phimail::phimail_connect($err); + $fp = (new \Application\Plugin\Phimail())->phimail_connect($err); if ($fp === false) { return("$config_err $err"); } @@ -207,7 +207,7 @@ class EncountermanagerTable extends AbstractTableGateway $phimail_username = $GLOBALS['phimail_username']; $cryptoGen = new CryptoGen(); $phimail_password = $cryptoGen->decryptStandard($GLOBALS['phimail_password']); - $ret = \Application\Plugin\Phimail::phimail_write_expect_OK($fp, "AUTH $phimail_username $phimail_password\n"); + $ret = (new \Application\Plugin\Phimail())->phimail_write_expect_OK($fp, "AUTH $phimail_username $phimail_password\n"); if ($ret !== true) { return("$config_err 4"); } @@ -230,16 +230,16 @@ class EncountermanagerTable extends AbstractTableGateway } $text_len = strlen($text_out); - \Application\Plugin\Phimail::phimail_write($fp, "TEXT $text_len\n"); + (new \Application\Plugin\Phimail())->phimail_write($fp, "TEXT $text_len\n"); $ret = @fgets($fp, 256); if ($ret != "BEGIN\n") { - \Application\Plugin\Phimail::phimail_close($fp); + (new \Application\Plugin\Phimail())->phimail_close($fp); //return("$config_err 5"); $d_Address .= ' ' . $recipient; continue; } - $ret = \Application\Plugin\Phimail::phimail_write_expect_OK($fp, $text_out); + $ret = (new \Application\Plugin\Phimail())->phimail_write_expect_OK($fp, $text_out); if ($ret !== true) { //return("$config_err 6"); $d_Address .= $recipient; diff --git a/interface/modules/zend_modules/module/Carecoordination/view/carecoordination/setup/index.phtml b/interface/modules/zend_modules/module/Carecoordination/view/carecoordination/setup/index.phtml index b01513ab1..e86ac6786 100644 --- a/interface/modules/zend_modules/module/Carecoordination/view/carecoordination/setup/index.phtml +++ b/interface/modules/zend_modules/module/Carecoordination/view/carecoordination/setup/index.phtml @@ -9,6 +9,9 @@ * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3 */ ?> +headScript()->prependFile($this->basePath() . '/js/application/sendTo.js') + ->prependFile($this->basePath() . '/js/lib/jquery-ui.js') +?>