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;
15 //landing page definition -- where to go if something goes wrong
16 $landingpage = "index.php";
19 // kick out if patient not authenticated
21 if ( isset($_SESSION['pid']) && isset($_SESSION['patient_portal_onsite']) ) {
22 $pid = $_SESSION['pid'];
26 header('Location: '.$landingpage.'?w');
32 include_once('../interface/globals.php');
34 $selects = "po.procedure_order_id, po.date_ordered, " .
35 "po.procedure_type_id AS order_type_id, pt1.name AS procedure_name, " .
36 "ptrc.name AS result_category_name, " .
37 "pt2.procedure_type AS result_type, " .
38 "pt2.procedure_type_id AS result_type_id, pt2.name AS result_name, " .
39 "pt2.units AS result_def_units, pt2.range AS result_def_range, " .
40 "pt2.description AS result_description, lo.title AS units_name, " .
41 "pr.procedure_report_id, pr.date_report, pr.date_collected, pr.specimen_num, pr.report_status, pr.review_status, " .
42 "ps.procedure_result_id, ps.abnormal, ps.result, ps.range, ps.result_status, " .
43 "ps.facility, ps.comments";
45 $joins = "LEFT JOIN procedure_type AS pt1 ON pt1.procedure_type_id = po.procedure_type_id ";
46 $joins .= "LEFT JOIN procedure_type AS ptrc ON ptrc.procedure_type_id = pt1.parent ";
47 $joins .= "AND ptrc.procedure_type LIKE 'grp%' " .
48 "LEFT JOIN procedure_type AS pt2 ON " .
49 "( ( ptrc.procedure_type_id IS NULL AND ( pt2.parent = po.procedure_type_id " .
50 "OR pt2.procedure_type_id = po.procedure_type_id ) ) OR ";
51 $joins .= "( pt2.procedure_type_id IS NOT NULL AND pt2.parent = pt1.procedure_type_id ) " .
52 ") AND ( pt2.procedure_type LIKE 'res%' OR pt2.procedure_type LIKE 'rec%' ) " .
53 "LEFT JOIN list_options AS lo ON list_id = 'proc_unit' AND option_id = pt2.units " .
54 "LEFT JOIN procedure_report AS pr ON pr.procedure_order_id = po.procedure_order_id " .
55 "LEFT JOIN procedure_result AS ps ON ps.procedure_report_id = pr.procedure_report_id " .
56 "AND ps.procedure_type_id = pt2.procedure_type_id";
58 $orderby ="po.date_ordered, po.procedure_order_id, pr.procedure_report_id, " .
59 "ptrc.seq, ptrc.name, ptrc.procedure_type_id, " .
60 "pt2.seq, pt2.name, pt2.procedure_type_id";
64 $res = sqlStatement("SELECT $selects " .
65 "FROM procedure_order AS po $joins " .
66 "WHERE po.patient_id = ? AND $where " .
67 "ORDER BY $orderby", array($pid));
69 if(sqlNumRows($res)>0)
72 <table
class="class1">
74 <th
><?php
echo htmlspecialchars( xl('Order Date'),ENT_NOQUOTES
); ?
></th
>
75 <th
><?php
echo htmlspecialchars( xl('Order Name'),ENT_NOQUOTES
); ?
></th
>
76 <th
><?php
echo htmlspecialchars( xl('Report Status'),ENT_NOQUOTES
); ?
></th
>
77 <th
><?php
echo htmlspecialchars( xl('Results Group'),ENT_NOQUOTES
); ?
></th
>
78 <th
><?php
echo htmlspecialchars( xl('Abnormal'),ENT_NOQUOTES
); ?
></th
>
79 <th
><?php
echo htmlspecialchars( xl('Value'),ENT_NOQUOTES
); ?
></th
>
83 while ($row = sqlFetchArray($res)) {
91 $date=explode('-',$row['date_ordered']);
92 echo "<tr class='".$class."'>";
93 echo "<td>".htmlspecialchars($date[1]."/".$date[2]."/".$date[0],ENT_NOQUOTES
)."</td>";
94 echo "<td>".htmlspecialchars($row['procedure_name'],ENT_NOQUOTES
)."</td>";
95 echo "<td>".htmlspecialchars($row['report_status'],ENT_NOQUOTES
)."</td>";
96 echo "<td>".htmlspecialchars($row['result_status'],ENT_NOQUOTES
)."</td>";
97 echo "<td>".htmlspecialchars($row['abnormal'],ENT_NOQUOTES
)."</td>";
98 echo "<td>".htmlspecialchars($row['result'],ENT_NOQUOTES
)."</td>";
105 echo htmlspecialchars( xl("No Results"),ENT_NOQUOTES
);