From d06123aa395d4d272abf5fbf2f8a4b93242b159c Mon Sep 17 00:00:00 2001 From: Rod Roark Date: Tue, 12 Mar 2013 16:40:06 -0700 Subject: [PATCH] Modified patient report to include complete lab results. --- interface/forms/procedure_order/report.php | 75 +---- interface/orders/single_order_results.inc.php | 358 ++++++++++++++++++++ interface/orders/single_order_results.php | 458 ++++---------------------- version.php | 2 +- 4 files changed, 444 insertions(+), 449 deletions(-) rewrite interface/forms/procedure_order/report.php (83%) create mode 100644 interface/orders/single_order_results.inc.php rewrite interface/orders/single_order_results.php (84%) diff --git a/interface/forms/procedure_order/report.php b/interface/forms/procedure_order/report.php dissimilarity index 83% index b8a5901ea..b8d79c044 100644 --- a/interface/forms/procedure_order/report.php +++ b/interface/forms/procedure_order/report.php @@ -1,58 +1,17 @@ - -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. - -include_once("../../globals.php"); -include_once($GLOBALS["srcdir"] . "/api.inc"); -include_once($GLOBALS["srcdir"] . "/options.inc.php"); - -function procedure_order_report($pid, $encounter, $cols, $id) { - $data = sqlQuery("SELECT " . - "po.procedure_order_id, po.date_ordered, " . - "po.order_status, po.specimen_type, " . - "pp.name AS labname, pr.procedure_report_id, " . - "u.lname AS ulname, u.fname AS ufname, u.mname AS umname " . - "FROM procedure_order AS po " . - "LEFT JOIN procedure_providers AS pp ON pp.ppid = po.lab_id " . - "LEFT JOIN users AS u ON u.id = po.provider_id " . - "LEFT JOIN procedure_report AS pr ON pr.procedure_order_id = po.procedure_order_id " . - "WHERE po.procedure_order_id = ? " . - "ORDER BY pr.procedure_report_id LIMIT 1", - array($id)); - - if ($data) { - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - if (!empty($data['procedure_report_id'])) { - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - } - echo "
" . xlt('Order ID') . ": " . text($data['procedure_order_id']) . "
" . xlt('Order Date') . ": " . text(oeFormatShortDate($data['date_ordered'])) . "
" . xlt('Ordered By') . ": " . text($data['ulname'] . ', ' . $data['ufname'] . ' ' . $data['umname']) . "
" . xlt('Lab') . ": " . text($data['labname']) . "
 [" . xlt('View Results') . "]
\n"; - } -} -?> + +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. + +require_once("../../globals.php"); +require_once($GLOBALS["srcdir"] . "/api.inc"); +require_once($GLOBALS["srcdir"] . "/options.inc.php"); +require_once($GLOBALS["include_root"] . "/orders/single_order_results.inc.php"); + +function procedure_order_report($pid, $encounter, $cols, $id) { + generate_order_report($id); +} +?> diff --git a/interface/orders/single_order_results.inc.php b/interface/orders/single_order_results.inc.php new file mode 100644 index 000000000..0f00bc284 --- /dev/null +++ b/interface/orders/single_order_results.inc.php @@ -0,0 +1,358 @@ + +* +* LICENSE: This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* @package OpenEMR +* @author Rod Roark +*/ + +require_once("$srcdir/acl.inc"); +require_once("$srcdir/formdata.inc.php"); +require_once("$srcdir/options.inc.php"); +require_once("$srcdir/formatting.inc.php"); + +function getListItem($listid, $value) { + $lrow = sqlQuery("SELECT title FROM list_options " . + "WHERE list_id = ? AND option_id = ?", + array($listid, $value)); + $tmp = xl_list_label($lrow['title']); + if (empty($tmp)) $tmp = "($report_status)"; + return $tmp; +} + +function myCellText($s) { + if ($s === '') return ' '; + return text($s); +} + +// Check if the given string already exists in the $aNotes array. +// If not, stores it as a new entry. +// Either way, returns the corresponding key which is a small integer. +function storeNote($s) { + global $aNotes; + $key = array_search($s, $aNotes); + if ($key !== FALSE) return $key; + $key = count($aNotes); + $aNotes[$key] = $s; + return $key; +} + +function generate_order_report($orderid, $input_form=false) { + // Check authorization. + $thisauth = acl_check('patients', 'med'); + if (!$thisauth) return xl('Not authorized'); + + $orow = sqlQuery("SELECT " . + "po.procedure_order_id, po.date_ordered, " . + "po.order_status, po.specimen_type, " . + "pd.pubpid, pd.lname, pd.fname, pd.mname, " . + "fe.date, " . + "pp.name AS labname, " . + "u.lname AS ulname, u.fname AS ufname, u.mname AS umname " . + "FROM procedure_order AS po " . + "LEFT JOIN patient_data AS pd ON pd.pid = po.patient_id " . + "LEFT JOIN procedure_providers AS pp ON pp.ppid = po.lab_id " . + "LEFT JOIN users AS u ON u.id = po.provider_id " . + "LEFT JOIN form_encounter AS fe ON fe.pid = po.patient_id AND fe.encounter = po.encounter_id " . + "WHERE po.procedure_order_id = ?", + array($orderid)); +?> + + + + + + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + 
+ + + + + + + + + + + + + + + + + + + + + + + + ''); + } + + foreach ($rrows as $rrow) { + $result_code = empty($rrow['result_code' ]) ? '' : $rrow['result_code']; + $result_text = empty($rrow['result_text' ]) ? '' : $rrow['result_text']; + $result_abnormal = empty($rrow['abnormal' ]) ? '' : $rrow['abnormal']; + $result_result = empty($rrow['result' ]) ? '' : $rrow['result']; + $result_units = empty($rrow['units' ]) ? '' : $rrow['units']; + $result_facility = empty($rrow['facility' ]) ? '' : $rrow['facility']; + $result_comments = empty($rrow['comments' ]) ? '' : $rrow['comments']; + $result_range = empty($rrow['range' ]) ? '' : $rrow['range']; + $result_status = empty($rrow['result_status' ]) ? '' : $rrow['result_status']; + + $result_comments = trim($result_comments); + $result_noteid = ''; + if (!empty($result_comments)) { + $result_noteid = 1 + storeNote($result_comments); + } + + if ($lastpoid != $order_id || $lastpcid != $order_seq) { + ++$encount; + } + $bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd"); + + echo " \n"; + + if ($lastpcid != $order_seq) { + $lastprid = -1; // force report fields on first line of each procedure + echo " \n"; + } + else { + echo " "; + } + + // If this starts a new report or a new order, generate the report fields. + if ($report_id != $lastprid) { + echo " \n"; + + echo " \n"; + + echo " \n"; + + echo " \n"; + } + else { + echo " \n"; + } + + if ($result_code !== '') { + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + } + else { + echo " \n"; + } + + echo " \n"; + + $lastpoid = $order_id; + $lastpcid = $order_seq; + $lastprid = $report_id; + ++$lino; + } + } +?> + +
" . text("$procedure_code: $procedure_name") . " "; + echo myCellText(oeFormatShortDate($date_report)); + echo ""; + echo myCellText($specimen_num); + echo ""; + echo myCellText(getListItem('proc_rep_status', $report_status)); + if ($row['review_status'] == 'reviewed') { + echo " ✓"; // unicode check mark character + } + echo ""; + echo myCellText($report_noteid); + echo " "; + echo myCellText($result_code); + echo ""; + echo myCellText($result_text); + echo ""; + echo myCellText(getListItem('proc_res_abnormal', $result_abnormal)); + echo ""; + echo myCellText($result_result); + echo ""; + echo myCellText($result_range); + echo ""; + echo myCellText($result_units); + echo ""; + echo myCellText($result_noteid); + echo " 
+ + 
+ + + \n"; + echo " \n"; + echo " \n"; + foreach ($aNotes as $key => $value) { + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + } + echo "
+\n"; + echo "
" . xlt('Notes') . "
" . ($key + 1) . "" . nl2br(text($value)) . "
\n"; + } +?> + + + + + ' + title='' /> + + + + + +
+ + +
+ + + diff --git a/interface/orders/single_order_results.php b/interface/orders/single_order_results.php dissimilarity index 84% index a75c2aa07..ca74b2f64 100644 --- a/interface/orders/single_order_results.php +++ b/interface/orders/single_order_results.php @@ -1,390 +1,68 @@ - -* -* LICENSE: This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* -* @package OpenEMR -* @author Rod Roark -*/ - -$sanitize_all_escapes = true; -$fake_register_globals = false; - -require_once("../globals.php"); -require_once("$srcdir/acl.inc"); -require_once("$srcdir/formdata.inc.php"); -require_once("$srcdir/options.inc.php"); -require_once("$srcdir/formatting.inc.php"); -require_once("../orders/lab_exchange_tools.php"); - -// Check authorization. -$thisauth = acl_check('patients', 'med'); -if (!$thisauth) die(xl('Not authorized')); - -$orderid = intval($_GET['orderid']); - -function getListItem($listid, $value) { - $lrow = sqlQuery("SELECT title FROM list_options " . - "WHERE list_id = ? AND option_id = ?", - array($listid, $value)); - $tmp = xl_list_label($lrow['title']); - if (empty($tmp)) $tmp = "($report_status)"; - return $tmp; -} - -function myCellText($s) { - if ($s === '') return ' '; - return text($s); -} - -// Check if the given string already exists in the $aNotes array. -// If not, stores it as a new entry. -// Either way, returns the corresponding key which is a small integer. -function storeNote($s) { - global $aNotes; - $key = array_search($s, $aNotes); - if ($key !== FALSE) return $key; - $key = count($aNotes); - $aNotes[$key] = $s; - return $key; -} - -if (!empty($_POST['form_sign_list'])) { - if (!acl_check('patients', 'sign')) { - die(xl('Not authorized to sign results')); - } - // When signing results we are careful to sign only those reports that were - // in the sending form. While this will usually be all the reports linked to - // the order it's possible for a new report to come in while viewing these, - // and it would be very bad to sign results that nobody has seen! - $arrSign = explode(',', $_POST['form_sign_list']); - foreach ($arrSign as $id) { - sqlStatement("UPDATE procedure_report SET " . - "review_status = 'reviewed' WHERE " . - "procedure_report_id = ?", array($id)); - } -} - -$orow = sqlQuery("SELECT " . - "po.procedure_order_id, po.date_ordered, " . - "po.order_status, po.specimen_type, " . - "pd.pubpid, pd.lname, pd.fname, pd.mname, " . - "fe.date, " . - "pp.name AS labname, " . - "u.lname AS ulname, u.fname AS ufname, u.mname AS umname " . - "FROM procedure_order AS po " . - "LEFT JOIN patient_data AS pd ON pd.pid = po.patient_id " . - "LEFT JOIN procedure_providers AS pp ON pp.ppid = po.lab_id " . - "LEFT JOIN users AS u ON u.id = po.provider_id " . - "LEFT JOIN form_encounter AS fe ON fe.pid = po.patient_id AND fe.encounter = po.encounter_id " . - "WHERE po.procedure_order_id = ?", - array($orderid)); -?> - - - - - - -<?php echo xlt('Order Results'); ?> - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - 
- - - - - - - - - - - - - - - - - - - - - - - - ''); - } - - foreach ($rrows as $rrow) { - $result_code = empty($rrow['result_code' ]) ? '' : $rrow['result_code']; - $result_text = empty($rrow['result_text' ]) ? '' : $rrow['result_text']; - $result_abnormal = empty($rrow['abnormal' ]) ? '' : $rrow['abnormal']; - $result_result = empty($rrow['result' ]) ? '' : $rrow['result']; - $result_units = empty($rrow['units' ]) ? '' : $rrow['units']; - $result_facility = empty($rrow['facility' ]) ? '' : $rrow['facility']; - $result_comments = empty($rrow['comments' ]) ? '' : $rrow['comments']; - $result_range = empty($rrow['range' ]) ? '' : $rrow['range']; - $result_status = empty($rrow['result_status' ]) ? '' : $rrow['result_status']; - - $result_comments = trim($result_comments); - $result_noteid = ''; - if (!empty($result_comments)) { - $result_noteid = 1 + storeNote($result_comments); - } - - if ($lastpoid != $order_id || $lastpcid != $order_seq) { - ++$encount; - } - $bgcolor = "#" . (($encount & 1) ? "ddddff" : "ffdddd"); - - echo " \n"; - - if ($lastpcid != $order_seq) { - $lastprid = -1; // force report fields on first line of each procedure - echo " \n"; - } - else { - echo " "; - } - - // If this starts a new report or a new order, generate the report fields. - if ($report_id != $lastprid) { - echo " \n"; - - echo " \n"; - - echo " \n"; - - echo " \n"; - } - else { - echo " \n"; - } - - if ($result_code !== '') { - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - } - else { - echo " \n"; - } - - echo " \n"; - - $lastpoid = $order_id; - $lastpcid = $order_seq; - $lastprid = $report_id; - ++$lino; - } -} -?> - -
" . text("$procedure_code: $procedure_name") . " "; - echo myCellText(oeFormatShortDate($date_report)); - echo ""; - echo myCellText($specimen_num); - echo ""; - echo myCellText(getListItem('proc_rep_status', $report_status)); - if ($row['review_status'] == 'reviewed') { - echo " ✓"; // unicode check mark character - } - echo ""; - echo myCellText($report_noteid); - echo " "; - echo myCellText($result_code); - echo ""; - echo myCellText($result_text); - echo ""; - echo myCellText(getListItem('proc_res_abnormal', $result_abnormal)); - echo ""; - echo myCellText($result_result); - echo ""; - echo myCellText($result_range); - echo ""; - echo myCellText($result_units); - echo ""; - echo myCellText($result_noteid); - echo " 
- - 
- - - \n"; - echo " \n"; - echo " \n"; - foreach ($aNotes as $key => $value) { - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - } - echo "
-\n"; - echo "
" . xlt('Notes') . "
" . ($key + 1) . "" . nl2br(text($value)) . "
\n"; -} -?> - - - - - ' - title='' /> - - - - - -
- - + +* +* LICENSE: This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* +* @package OpenEMR +* @author Rod Roark +*/ + +$sanitize_all_escapes = true; +$fake_register_globals = false; + +require_once("../globals.php"); +require_once($GLOBALS["include_root"] . "/orders/single_order_results.inc.php"); + +// Check authorization. +$thisauth = acl_check('patients', 'med'); +if (!$thisauth) die(xl('Not authorized')); + +$orderid = intval($_GET['orderid']); + +if (!empty($_POST['form_sign_list'])) { + if (!acl_check('patients', 'sign')) { + die(xl('Not authorized to sign results')); + } + // When signing results we are careful to sign only those reports that were + // in the sending form. While this will usually be all the reports linked to + // the order it's possible for a new report to come in while viewing these, + // and it would be very bad to sign results that nobody has seen! + $arrSign = explode(',', $_POST['form_sign_list']); + foreach ($arrSign as $id) { + sqlStatement("UPDATE procedure_report SET " . + "review_status = 'reviewed' WHERE " . + "procedure_report_id = ?", array($id)); + } +} +?> + + + + +<?php echo xlt('Order Results'); ?> + + + + + + diff --git a/version.php b/version.php index bc1ff9da7..6d1af9cb3 100644 --- a/version.php +++ b/version.php @@ -17,7 +17,7 @@ $v_realpatch = '0'; // is a database change in the course of development. It is used // internally to determine when a database upgrade is needed. // -$v_database = 88; +$v_database = 89; // Access control version identifier, this is to be incremented whenever there // is a access control change in the course of development. It is used -- 2.11.4.GIT