2 // Copyright (C) 2011 Cassian LUP <cassi.lup@gmail.com>
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
10 $sanitize_all_escapes=true;
12 //STOP FAKE REGISTER GLOBALS
13 $fake_register_globals=false;
19 //landing page definition -- where to go if something goes wrong
20 $landingpage = "index.php?site=".$_SESSION['site_id'];
23 // kick out if patient not authenticated
24 if ( isset($_SESSION['pid']) && isset($_SESSION['patient_portal_onsite']) ) {
25 $pid = $_SESSION['pid'];
29 header('Location: '.$landingpage.'&w');
35 include_once('../interface/globals.php');
37 $selects = "po.procedure_order_id, po.date_ordered, " .
38 "po.procedure_type_id AS order_type_id, pt1.name AS procedure_name, " .
39 "ptrc.name AS result_category_name, " .
40 "pt2.procedure_type AS result_type, " .
41 "pt2.procedure_type_id AS result_type_id, pt2.name AS result_name, " .
42 "pt2.units AS result_def_units, pt2.range AS result_def_range, " .
43 "pt2.description AS result_description, lo.title AS units_name, " .
44 "pr.procedure_report_id, pr.date_report, pr.date_collected, pr.specimen_num, pr.report_status, pr.review_status, " .
45 "ps.procedure_result_id, ps.abnormal, ps.result, ps.range, ps.result_status, " .
46 "ps.facility, ps.comments";
48 $joins = "LEFT JOIN procedure_type AS pt1 ON pt1.procedure_type_id = po.procedure_type_id ";
49 $joins .= "LEFT JOIN procedure_type AS ptrc ON ptrc.procedure_type_id = pt1.parent ";
50 $joins .= "AND ptrc.procedure_type LIKE 'grp%' " .
51 "LEFT JOIN procedure_type AS pt2 ON " .
52 "( ( ptrc.procedure_type_id IS NULL AND ( pt2.parent = po.procedure_type_id " .
53 "OR pt2.procedure_type_id = po.procedure_type_id ) ) OR ";
54 $joins .= "( pt2.procedure_type_id IS NOT NULL AND pt2.parent = pt1.procedure_type_id ) " .
55 ") AND ( pt2.procedure_type LIKE 'res%' OR pt2.procedure_type LIKE 'rec%' ) " .
56 "LEFT JOIN list_options AS lo ON list_id = 'proc_unit' AND option_id = pt2.units " .
57 "LEFT JOIN procedure_report AS pr ON pr.procedure_order_id = po.procedure_order_id " .
58 "LEFT JOIN procedure_result AS ps ON ps.procedure_report_id = pr.procedure_report_id " .
59 "AND ps.procedure_type_id = pt2.procedure_type_id";
61 $orderby ="po.date_ordered, po.procedure_order_id, pr.procedure_report_id, " .
62 "ptrc.seq, ptrc.name, ptrc.procedure_type_id, " .
63 "pt2.seq, pt2.name, pt2.procedure_type_id";
67 $res = sqlStatement("SELECT $selects " .
68 "FROM procedure_order AS po $joins " .
69 "WHERE po.patient_id = ? AND $where " .
70 "ORDER BY $orderby", array($pid));
72 if(sqlNumRows($res)>0)
75 <table
class="class1">
77 <th
><?php
echo htmlspecialchars( xl('Order Date'),ENT_NOQUOTES
); ?
></th
>
78 <th
><?php
echo htmlspecialchars( xl('Order Name'),ENT_NOQUOTES
); ?
></th
>
79 <th
><?php
echo htmlspecialchars( xl('Report Status'),ENT_NOQUOTES
); ?
></th
>
80 <th
><?php
echo htmlspecialchars( xl('Results Group'),ENT_NOQUOTES
); ?
></th
>
81 <th
><?php
echo htmlspecialchars( xl('Abnormal'),ENT_NOQUOTES
); ?
></th
>
82 <th
><?php
echo htmlspecialchars( xl('Value'),ENT_NOQUOTES
); ?
></th
>
86 while ($row = sqlFetchArray($res)) {
94 $date=explode('-',$row['date_ordered']);
95 echo "<tr class='".$class."'>";
96 echo "<td>".htmlspecialchars($date[1]."/".$date[2]."/".$date[0],ENT_NOQUOTES
)."</td>";
97 echo "<td>".htmlspecialchars($row['procedure_name'],ENT_NOQUOTES
)."</td>";
98 echo "<td>".htmlspecialchars($row['report_status'],ENT_NOQUOTES
)."</td>";
99 echo "<td>".htmlspecialchars($row['result_status'],ENT_NOQUOTES
)."</td>";
100 echo "<td>".htmlspecialchars($row['abnormal'],ENT_NOQUOTES
)."</td>";
101 echo "<td>".htmlspecialchars($row['result'],ENT_NOQUOTES
)."</td>";
108 echo htmlspecialchars( xl("No Results"),ENT_NOQUOTES
);