Skip to content

Commit

Permalink
fix: Clinical report not working when searching for patients with a s…
Browse files Browse the repository at this point in the history
…pecific medical problem (openemr#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 (openemr#6868)

* deshacer cambios

* deshacer cambios

* fix: clinical reports not working with problems diagnosis (openemr#6879)

* fix: clinical reports not filtering diagnosis or allergies
  • Loading branch information
macomeza authored Oct 14, 2023
1 parent 2860b5d commit da0adda
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions interface/reports/clinical_reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ function submitForm() {
</tr>
</table></td>
<td class='col-form-label'><?php echo xlt('Problem DX'); ?>:</td>
<td><input type='text' name='form_diagnosis form-control' class= 'form-control' size='10' maxlength='250' value='<?php echo attr($form_diagnosis); ?>' onclick='sel_diagnosis(this)' title='<?php echo xla('Click to select or change diagnoses'); ?>' readonly /></td>
<td><input type='text' name='form_diagnosis' class= 'form-control' size='10' maxlength='250' value='<?php echo attr($form_diagnosis); ?>' onclick='sel_diagnosis(this)' title='<?php echo xla('Click to select or change diagnoses'); ?>' readonly /></td>
<td>&nbsp;</td>
<!-- Visolve -->
</tr>
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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'])) {
Expand Down Expand Up @@ -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'])) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -778,7 +774,7 @@ function submitForm() {
</tr>
<!-- Diagnosis Report Start-->
<?php
if (strlen($form_diagnosis) > 0 || !empty($_POST['form_diagnosis_allergy']) || !empty($_POST['form_diagnosis_medprb'])) {
if (!empty($form_diagnosis)) {
?>
<tr bgcolor="#C3FDB8" align="left">
<td colspan='12'><strong><?php echo "#";
Expand Down Expand Up @@ -1059,4 +1055,4 @@ function submitForm() {
</form>
</body>

</html>
</html>

0 comments on commit da0adda

Please sign in to comment.