From da0adda5a405f94388e992ae7313ba78c4ad6369 Mon Sep 17 00:00:00 2001
From: macomeza <77448377+macomeza@users.noreply.github.com>
Date: Sat, 14 Oct 2023 14:35:11 -0600
Subject: [PATCH] fix: Clinical report not working when searching for patients
with a specific medical problem (#6880)
* Improve look and feel for highlighting items
* Let line breaks to show correctly in document
* Revertir el line break
* Line breaks of text are not exporting as is when generating a document (#6868)
* deshacer cambios
* deshacer cambios
* fix: clinical reports not working with problems diagnosis (https://github.com/openemr/openemr/issues/6879)
* fix: clinical reports not filtering diagnosis or allergies
---
interface/reports/clinical_reports.php | 28 +++++++++++---------------
1 file changed, 12 insertions(+), 16 deletions(-)
diff --git a/interface/reports/clinical_reports.php b/interface/reports/clinical_reports.php
index d073e86aa0f..7882a5f46e1 100644
--- a/interface/reports/clinical_reports.php
+++ b/interface/reports/clinical_reports.php
@@ -261,7 +261,7 @@ function submitForm() {
:
-
' readonly />
+
' readonly />
@@ -449,7 +449,7 @@ function submitForm() {
pd.race AS patient_race,pd.ethnicity AS patient_ethinic,
concat(u.fname, ' ', u.lname) AS users_provider,
REPLACE(REPLACE(concat_ws(',',IF(pd.hipaa_allowemail = 'YES', 'Allow Email','NO'),IF(pd.hipaa_allowsms = 'YES', 'Allow SMS','NO') , IF(pd.hipaa_mail = 'YES', 'Allow Mail Message','NO') , IF(pd.hipaa_voice = 'YES', 'Allow Voice Message','NO') ), ',NO',''), 'NO,','') as communications";
- if (strlen($form_diagnosis) > 0 || !empty($_POST['form_diagnosis_allergy']) || !empty($_POST['form_diagnosis_medprb'])) {
+ if (!empty($form_diagnosis)) {
$sqlstmt = $sqlstmt . ",li.date AS lists_date,
li.diagnosis AS lists_diagnosis,
li.title AS lists_title";
@@ -506,12 +506,8 @@ function submitForm() {
$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 || (!empty($_POST['form_diagnosis_allergy']) && !empty($_POST['form_diagnosis_medprb']))) {
+ if (!empty($form_diagnosis)) {
$sqlstmt = $sqlstmt . " left outer join lists as li on (li.pid = pd.pid AND (li.type='medical_problem' OR li.type='allergy')) ";
- } elseif (!empty($_POST['form_diagnosis_allergy'])) {
- $sqlstmt = $sqlstmt . " left outer join lists as li on (li.pid = pd.pid AND (li.type='allergy')) ";
- } elseif (!empty($_POST['form_diagnosis_medprb'])) {
- $sqlstmt = $sqlstmt . " left outer join lists as li on (li.pid = pd.pid AND (li.type='medical_problem')) ";
}
if ($type == 'Procedure' || ( strlen($form_lab_results) != 0) || !empty($_POST['lab_results'])) {
@@ -551,14 +547,14 @@ function submitForm() {
//where
$whr_stmt = "where 1=1";
- if (strlen($form_diagnosis) > 0 || !empty($_POST['form_diagnosis_allergy']) || !empty($_POST['form_diagnosis_medprb'])) {
+ if (!empty($form_diagnosis)) {
$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 || !empty($_POST['lab_results'])) {
- $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"));
+ $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 || !empty($_POST['form_drug'])) {
@@ -645,9 +641,9 @@ function submitForm() {
array_push($sqlBindArray, $facility);
}
- if (strlen($form_diagnosis) > 0) {
- $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);
+ if (!empty($form_diagnosis)) {
+ $whr_stmt = $whr_stmt . " AND (li.diagnosis LIKE ?) ";
+ array_push($sqlBindArray, '%' . $form_diagnosis . '%');
}
//communication preferences added in clinical report
@@ -683,7 +679,7 @@ function submitForm() {
$odrstmt = $odrstmt . ",patient_age";
}
- if ((strlen($form_diagnosis) > 0)) {
+ if (!empty($form_diagnosis)) {
$odrstmt = $odrstmt . ",lists_diagnosis";
} elseif ((!empty($_POST['form_diagnosis_allergy'])) || (!empty($_POST['form_diagnosis_medprb']))) {
$odrstmt = $odrstmt . ",lists_title";
@@ -778,7 +774,7 @@ function submitForm() {
0 || !empty($_POST['form_diagnosis_allergy']) || !empty($_POST['form_diagnosis_medprb'])) {
+ if (!empty($form_diagnosis)) {
?>