From 7bf4b48174a4947178b2be35067b3e77fe41ad63 Mon Sep 17 00:00:00 2001 From: Jerry Padgett Date: Fri, 29 Apr 2022 12:39:17 -0400 Subject: [PATCH] CQM and others (#5241) * CQM and others - fix deleter to remove sync alert * remove duplicate dependency from core package * add duplicate functionality for imports * add additional counts to view --- .../Controller/CarecoordinationController.php | 72 ++++++++++++++++++++++ .../Model/CarecoordinationTable.php | 20 ++++-- .../carecoordination/carecoordination/upload.phtml | 44 +++++++++++-- interface/patient_file/deleter.php | 12 +++- package-lock.json | 2 - package.json | 2 - 6 files changed, 136 insertions(+), 16 deletions(-) diff --git a/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Controller/CarecoordinationController.php b/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Controller/CarecoordinationController.php index c9b317624..b4bb38314 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 @@ -61,6 +61,31 @@ class CarecoordinationController extends AbstractActionController $this->redirect()->toRoute('encountermanager', array('action' => 'index')); } + /** + * delete an audit record + * + * @return ViewModel + */ + public function deleteAuditAction() + { + $request = $this->getRequest(); + $amid = $request->getPost('am_id') ?? null; + if ($amid) { + $this->getCarecoordinationTable()->deleteImportAuditData(array('audit_master_id' => $amid)); + } + $category_details = $this->getCarecoordinationTable()->fetch_cat_id('CCDA'); + $records = $this->getCarecoordinationTable()->document_fetch(array('cat_title' => 'CCDA', 'type' => '12')); + $view = new ViewModel(array( + 'records' => $records, + 'category_id' => $category_details[0]['id'], + 'file_location' => basename($_FILES['file']['name'] ?? ''), + 'patient_id' => '00', + 'listenerObject' => $this->listenerObject + )); + + return $view; + } + /* * Upload CCDA file */ @@ -121,6 +146,53 @@ class CarecoordinationController extends AbstractActionController } $records = $this->getCarecoordinationTable()->document_fetch(array('cat_title' => 'CCDA', 'type' => '12')); + foreach ($records as $key => $r) { + if (!empty($records[$key]['dupl_patient'])) { + continue; + } + $name = $r['pat_name']; + $dob = $r['dob_raw']; + //$records[$key]['dupl'] = ''; + foreach ($records as $k => $r1) { + $f = false; + $why = ''; + if (!empty($r1['dupl_patient']) || $key == $k) { + continue; + } + $n = $r1['pat_name']; + $fn = $r1['ad_fname'] == $r['ad_fname']; + $ln = $r1['ad_lname'] == $r['ad_lname']; + $dob = $r1['dob_raw'] == $r['dob_raw']; + if ($dob) { + $f = true; + $why = xlt('Match DOB'); + } + if ($name == $n && ($f || $r1['race'] == $r['race'] || $r1['ethnicity'] == $r['ethnicity'])) { + $why = xlt('Matched Demo'); + if ($r1['enc_count'] != $r['enc_count'] || $r1['cp_count'] != $r['cp_count'] || $r1['ob_count'] != $r['ob_count']) { + $why .= ' ' . xlt('with Mismatched Components'); + } + $f = true; + } + if ( + (($ln && !$fn || $fn && !$ln) && $dob) + && ($r1['race'] == $r['race'] || $r1['ethnicity'] == $r['ethnicity']) + ) { + $why = xlt('Name Misspelled'); + if ( + $r1['enc_count'] != $r['enc_count'] + || $r1['cp_count'] != $r['cp_count'] + || $r1['ob_count'] != $r['ob_count'] + ) { + $why .= ' ' . xlt('with Mismatched Components'); + } + $f = true; + } + if ($f) { + $records[$key]['dupl_patient'] = $records[$k]['dupl_patient'] = $why; + } + } + } $view = new ViewModel(array( 'records' => $records, 'category_id' => $category_details[0]['id'], diff --git a/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Model/CarecoordinationTable.php b/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Model/CarecoordinationTable.php index d2af3589a..abcb1123a 100644 --- a/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Model/CarecoordinationTable.php +++ b/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Model/CarecoordinationTable.php @@ -110,9 +110,17 @@ class CarecoordinationTable extends AbstractTableGateway d.url AS file_url, d.id AS document_id, am.is_qrda_document, - ad.field_value, - ad1.field_value, - ad2.field_value, + ad.field_value as ad_lname, + ad1.field_value as ad_fname, + ad2.field_value as dob_raw, + (Select COUNT(field_name) From `audit_details` Where audit_master_id = am.id AND table_name = 'encounter' AND field_name = 'date') as enc_count, + (Select COUNT(field_name) From `audit_details` Where audit_master_id = am.id AND table_name = 'lists1' AND field_name = 'type' AND field_value = 'medical_problem') as prb_count, + (Select COUNT(field_name) From `audit_details` Where audit_master_id = am.id AND table_name = 'form_care_plan' AND field_name = 'date') as cp_count, + (Select COUNT(field_name) From `audit_details` Where audit_master_id = am.id AND table_name = 'observation_preformed' AND field_name = 'date') as ob_count, + (Select COUNT(field_name) From `audit_details` Where audit_master_id = am.id AND table_name = 'procedure' AND field_name = 'date') as proc_count, + (Select COUNT(field_name) From `audit_details` Where audit_master_id = am.id AND table_name = 'lists3' AND field_name = 'type' AND field_value = 'medication') as med_count, + ad5.field_value as race, + ad6.field_value as ethnicity, pd.pid, CONCAT(ad.field_value,' ',ad1.field_value) as pat_name, DATE(ad2.field_value) as dob, @@ -124,10 +132,12 @@ class CarecoordinationTable extends AbstractTableGateway LEFT JOIN audit_details ad ON ad.audit_master_id = am.id AND ad.table_name = 'patient_data' AND ad.field_name = 'lname' LEFT JOIN audit_details ad1 ON ad1.audit_master_id = am.id AND ad1.table_name = 'patient_data' AND ad1.field_name = 'fname' LEFT JOIN audit_details ad2 ON ad2.audit_master_id = am.id AND ad2.table_name = 'patient_data' AND ad2.field_name = 'DOB' + LEFT JOIN audit_details ad5 ON ad5.audit_master_id = am.id AND ad5.table_name = 'patient_data' AND ad5.field_name = 'race' + LEFT JOIN audit_details ad6 ON ad6.audit_master_id = am.id AND ad6.table_name = 'patient_data' AND ad6.field_name = 'ethnicity' LEFT JOIN patient_data pd ON pd.lname = ad.field_value AND pd.fname = ad1.field_value AND pd.DOB = DATE(ad2.field_value) LEFT JOIN users AS u ON u.id = d.owner WHERE d.audit_master_approval_status = 1 AND am.id > 0 - ORDER BY date DESC"; + ORDER BY date ASC"; $appTable = new ApplicationTable(); $result = $appTable->zQuery($query, array($data['cat_title'], $data['type'])); $records = array(); @@ -182,7 +192,7 @@ class CarecoordinationTable extends AbstractTableGateway $this->is_qrda_import = true; if (count($components[2]["section"]["entry"] ?? []) < 2) { $name = $xml["recordTarget"]["patientRole"]["patient"]["name"]["given"] . ' ' . - $xml["recordTarget"]["patientRole"]["patient"]["name"]["family"]; + $xml["recordTarget"]["patientRole"]["patient"]["name"]["family"]; error_log("No QDMs for patient: " . $name); return true; } diff --git a/interface/modules/zend_modules/module/Carecoordination/view/carecoordination/carecoordination/upload.phtml b/interface/modules/zend_modules/module/Carecoordination/view/carecoordination/carecoordination/upload.phtml index 0831043cb..18ff5912e 100644 --- a/interface/modules/zend_modules/module/Carecoordination/view/carecoordination/carecoordination/upload.phtml +++ b/interface/modules/zend_modules/module/Carecoordination/view/carecoordination/carecoordination/upload.phtml @@ -131,6 +131,22 @@ echo $this->headScript()->prependFile($this->basePath() . '/js/autosuggest/autos var uploadURL = "basePath();?>/carecoordination/upload"; }); + function deleteAuditRecord(amid, name) { + let status = confirm('listenerObject->z_xlt("Do You Really Want to Remove Duplicate");?>' + ' ' + name + '?'); + if (status !== true) { + return; + } + let url = "basePath();?>/carecoordination/deleteAudit"; + let fd = new FormData(); + fd.append('am_id', amid); + fetch(url, { + method: "POST", + body: fd + }).then((response) => { + $('#form_ccda_import').submit(); + }); + } + function sendFileToServer(formData, status) { var uploadURL = "basePath();?>/carecoordination/upload"; //Upload URL var extraData = {}; //Extra Data. @@ -338,7 +354,7 @@ echo $this->headScript()->prependFile($this->basePath() . '/js/autosuggest/autos
 
- + @@ -364,8 +380,17 @@ echo $this->headScript()->prependFile($this->basePath() . '/js/autosuggest/autos listenerObject->z_xlt('Owner'); ?> listenerObject->z_xlt('Patient Name'); ?> listenerObject->z_xlt('DOB'); ?> + listenerObject->z_xlt('Race'); ?> + listenerObject->z_xlt('Ethnic'); ?> + listenerObject->z_xlt('Enc'); ?> + listenerObject->z_xlt('Prob'); ?> + listenerObject->z_xlt('CP'); ?> + listenerObject->z_xlt('OB'); ?> + listenerObject->z_xlt('Proc'); ?> + listenerObject->z_xlt('Med'); ?> listenerObject->z_xlt('Match Found'); ?> listenerObject->z_xlt('Matched Patient'); ?> + listenerObject->z_xlt('Duplicate'); ?> listenerObject->z_xlt('Type'); ?>