From 3ef82dbbb59ade081d7ea525b1b80cf2079b6619 Mon Sep 17 00:00:00 2001 From: Ram Date: Fri, 5 Sep 2014 06:38:08 -0700 Subject: [PATCH] Implemented the following changes at Clinical report as per the Vamsi's request - show data based on the below check boxes. --- interface/reports/clinical_reports.php | 76 ++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 31 deletions(-) diff --git a/interface/reports/clinical_reports.php b/interface/reports/clinical_reports.php index f35810bd6..cf920e72e 100644 --- a/interface/reports/clinical_reports.php +++ b/interface/reports/clinical_reports.php @@ -325,6 +325,8 @@ Search options include diagnosis, procedure, prescription, medical history, and   >   + > + @@ -362,19 +364,20 @@ $sqlstmt = "select DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(),pd.dob)), '%Y')+0 AS patient_age, pd.sex AS patient_sex, pd.race AS patient_race,pd.ethnicity AS patient_ethinic, - concat(u.fname, ' ', u.lname) AS users_provider"; - if(strlen($form_diagnosis) > 0) { + concat(u.fname, ' ', u.lname) AS users_provider, + concat_ws(', ',IF(pd.hipaa_allowsms = 'YES', 'Allow SMS','NO') , IF(pd.hipaa_voice = 'YES', 'Allow Voice Message','NO'), IF(pd.hipaa_mail = 'YES', 'Allow Mail Message','NO'), IF(pd.hipaa_allowemail = 'YES', 'Allow Email','NO')) as communications"; + if(strlen($form_diagnosis) > 0 || $_POST['form_diagnosis_code'] == true || $_POST['form_diagnosis_tit'] == true) { $sqlstmt=$sqlstmt.",li.date AS lists_date, li.diagnosis AS lists_diagnosis, li.title AS lists_title"; } - if(strlen($form_drug_name) > 0) { + if(strlen($form_drug_name) > 0 || $_POST['form_drug'] == true) { $sqlstmt=$sqlstmt.",r.id as id, r.date_modified AS prescriptions_date_modified, r.dosage as dosage, r.route as route, r.interval as hinterval, r.refills as refills, r.drug as drug, r.form as hform, r.size as size, r.unit as hunit, d.name as name, d.ndc_number as ndc_number,r.quantity as quantity"; } - if(strlen($form_lab_results) > 0) { + if(strlen($form_lab_results) > 0 || $_POST['lab_results'] == true) { $sqlstmt = $sqlstmt.",pr.date AS procedure_result_date, pr.facility AS procedure_result_facility, pr.units AS procedure_result_units, @@ -417,18 +420,18 @@ $sqlstmt = "select $sqlstmt=$sqlstmt." from patient_data as pd left outer join users as u on u.id = pd.providerid left outer join facility as f on f.id = u.facility_id"; - if(strlen($form_diagnosis) > 0 ){ + if(strlen($form_diagnosis) > 0 || $_POST['form_diagnosis_code'] == true || $_POST['form_diagnosis_tit'] == true){ $sqlstmt = $sqlstmt." left outer join lists as li on li.pid = pd.pid "; } - if ( $type == 'Procedure' ||( strlen($form_lab_results)!=0) ) { + if ( $type == 'Procedure' ||( strlen($form_lab_results)!=0) || $_POST['lab_results'] == true) { $sqlstmt = $sqlstmt." left outer join procedure_order as po on po.patient_id = pd.pid left outer join procedure_order_code as pc on pc.procedure_order_id = po.procedure_order_id left outer join procedure_report as pp on pp.procedure_order_id = po.procedure_order_id left outer join procedure_type as pt on pt.procedure_code = pc.procedure_code and pt.lab_id = po.lab_id "; } - if (strlen($form_lab_results)!=0 ) { + if (strlen($form_lab_results)!=0 || $_POST['lab_results'] == true) { $sqlstmt = $sqlstmt." left outer join procedure_result as pr on pr.procedure_report_id = pp.procedure_report_id "; } //Immunization added in clinical report @@ -436,7 +439,7 @@ $sqlstmt = "select $sqlstmt = $sqlstmt." LEFT OUTER JOIN immunizations as imm ON imm.patient_id = pd.pid LEFT OUTER JOIN codes as immc ON imm.cvx_code = immc.id "; } - if(strlen($form_drug_name)!=0) { + if(strlen($form_drug_name)!=0 || $_POST['form_drug'] == true) { $sqlstmt=$sqlstmt." left outer join prescriptions AS r on r.patient_id=pd.pid LEFT OUTER JOIN drugs AS d ON d.drug_id = r.drug_id"; } @@ -453,15 +456,15 @@ $sqlstmt = "select } //where $whr_stmt="where 1=1"; - if(strlen($form_diagnosis) > 0 ) { + if(strlen($form_diagnosis) > 0 || $_POST['form_diagnosis_code'] == true || $_POST['form_diagnosis_tit'] == true) { $whr_stmt=$whr_stmt." AND li.date >= ? AND li.date < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(li.date) <= ?"; array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d")); } - if(strlen($form_lab_results)!=0 ) { + if(strlen($form_lab_results)!=0 || $_POST['lab_results'] == true) { $whr_stmt=$whr_stmt." AND pr.date >= ? AND pr.date < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(pr.date) <= ?"; array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d")); } - if(strlen($form_drug_name)!=0) { + if(strlen($form_drug_name)!=0 || $_POST['form_drug'] == true) { $whr_stmt=$whr_stmt." AND r.date_modified >= ? AND r.date_modified < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(r.date_modified) <= ?"; array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d")); } @@ -477,15 +480,17 @@ $sqlstmt = "select $whr_stmt=$whr_stmt." AND b.date >= ? AND b.date < DATE_ADD(?, INTERVAL 1 DAY) AND DATE(b.date) <= ?"; array_push($sqlBindArray, $sql_date_from, $sql_date_to, date("Y-m-d")); } - if(strlen($form_lab_results) != 0) { + if(strlen($form_lab_results) != 0 || $_POST['lab_results'] == true) { $whr_stmt= $whr_stmt." AND (pr.result LIKE ?) "; + if(empty($form_lab_results)) $form_lab_results ="%"; array_push($sqlBindArray, $form_lab_results); } - if(strlen($form_drug_name) > 0) { + if(strlen($form_drug_name) > 0 || $_POST['form_drug'] == true) { $whr_stmt .= " AND ( d.name LIKE ? OR r.drug LIKE ? ) "; + if(empty($form_drug_name)) $form_drug_name ="%"; array_push($sqlBindArray, $form_drug_name, $form_drug_name); } if($type == 'Service Codes') { @@ -524,16 +529,20 @@ $sqlstmt = "select $whr_stmt = $whr_stmt." and f.id = ? "; array_push($sqlBindArray, $facility); } - if(strlen($form_diagnosis) > 0) { + if(strlen($form_diagnosis) > 0 || $_POST['form_diagnosis_code'] == true || $_POST['form_diagnosis_tit'] == true) { $whr_stmt = $whr_stmt." AND (li.diagnosis LIKE ? or li.diagnosis LIKE ? or li.diagnosis LIKE ? or li.diagnosis = ?) "; array_push($sqlBindArray, $form_diagnosis.";%", '%;'.$form_diagnosis.';%', '%;'.$form_diagnosis, $form_diagnosis); } //communication preferences added in clinical report - if(strlen($communication) > 0){ + if(strlen($communication) > 0 || $_POST['communication_check'] == true){ + if($communication == "allow_sms") $whr_stmt .= " AND pd.hipaa_allowsms = 'YES' "; else if($communication == "allow_voice") $whr_stmt .= " AND pd.hipaa_voice = 'YES' "; else if($communication == "allow_mail") $whr_stmt .= " AND pd.hipaa_mail = 'YES' "; else if($communication == "allow_email") $whr_stmt .= " AND pd.hipaa_allowemail = 'YES' "; + else if($communication == "" && $_POST['communication_check'] == true){ + $whr_stmt .= " AND (pd.hipaa_allowsms = 'YES' OR pd.hipaa_voice = 'YES' OR pd.hipaa_mail = 'YES' OR pd.hipaa_allowemail = 'YES') "; + } } //Immunization where condition for full text or short text @@ -594,7 +603,9 @@ if(sqlNumRows($result) > 0) ?>
- + + @@ -611,8 +622,8 @@ if(sqlNumRows($result) > 0) - - 0){ ?> + + 0 || ($_POST['communication_check'] == true)){ ?> @@ -623,14 +634,17 @@ if(sqlNumRows($result) > 0) - - 0){ ?> - - + + + 0 || $_POST['communication_check'] == true){ ?> + + 0) + if(strlen($form_diagnosis) > 0 || $_POST['form_diagnosis_code'] == true || $_POST['form_diagnosis_tit'] == true) { ?> @@ -639,19 +653,19 @@ if(sqlNumRows($result) > 0) - + - + 0) + if(strlen($form_drug_name) > 0 || $_POST['form_drug'] == true) { ?> @@ -667,7 +681,7 @@ if(sqlNumRows($result) > 0) - + 0) - + 0) + if(strlen($form_lab_results) > 0 || $_POST['lab_results'] == true) { ?> @@ -706,7 +720,7 @@ if(sqlNumRows($result) > 0) - + @@ -716,7 +730,7 @@ if(sqlNumRows($result) > 0) - + -- 2.11.4.GIT
colspan=5 > colspan=5 >
'1','list_id'=>'sex'), $row['patient_sex']),ENT_NOQUOTES); ?>  '1','list_id'=>'race'), $row['patient_race']),ENT_NOQUOTES); ?>  '1','list_id'=>'ethnicity'), $row['patient_ethinic']),ENT_NOQUOTES); ?>  colspan=5 >   colspan=5 >