Annoying CKEditor4 security warning (#7543)
[openemr.git] / interface / forms / track_anything / report.php
blobd3d4f10b1d2ef29b44dc6d2a4c9cea417e645835
1 <?php
3 /**
4 * Encounter form to track any clinical parameter.
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Joe Slam <trackanything@produnis.de>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2014 Joe Slam <trackanything@produnis.de>
11 * @copyright Copyright (c) 2019 Brady Miller <brady.g.miller@gmail.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once(dirname(__FILE__) . '/../../globals.php');
16 require_once($GLOBALS["srcdir"] . "/api.inc.php");
18 function track_anything_report($pid, $encounter, $cols, $id)
20 #$patient_report_flag = 'no';
21 echo "<div id='track_anything'>";
22 global $web_root;
23 $ofc_name = array();
24 $ofc_date = array();
25 $ofc_value = array();
26 $row = 0; // how many rows
27 $col = 0; // how many Items per row
28 $dummy = array(); // counter to decide if graph-button is shown
29 $formid = $id;
30 $shownameflag = 0;
31 echo "<div id='graph" . attr($formid) . "' class='chart-dygraphs'> </div><br />";
32 echo "<table border='1'>";
34 // get name of selected track, used for GraphTitle
35 $spell = "SELECT form_track_anything_type.name AS track_name ";
36 $spell .= "FROM form_track_anything ";
37 $spell .= "INNER JOIN form_track_anything_type ON form_track_anything.procedure_type_id = form_track_anything_type.track_anything_type_id ";
38 $spell .= "WHERE id = ? AND form_track_anything_type.active = 1";
39 $myrow = sqlQuery($spell, array($formid));
40 $the_track_name = $myrow["track_name"];
41 //------------
43 // get correct track
44 $spell0 = "SELECT DISTINCT track_timestamp ";
45 $spell0 .= "FROM form_track_anything_results ";
46 $spell0 .= "WHERE track_anything_id = ? ";
47 $spell0 .= "ORDER BY track_timestamp DESC ";
48 $query = sqlStatement($spell0, array($formid));
50 // get all data of this specific track
51 while ($myrow = sqlFetchArray($query)) {
52 $thistime = $myrow['track_timestamp'];
53 $shownameflag++;
54 $spell = "SELECT form_track_anything_results.itemid, form_track_anything_results.result, form_track_anything_type.name AS the_name ";
55 $spell .= "FROM form_track_anything_results ";
56 $spell .= "INNER JOIN form_track_anything_type ON form_track_anything_results.itemid = form_track_anything_type.track_anything_type_id ";
57 $spell .= "WHERE track_anything_id = ? AND track_timestamp = ? AND form_track_anything_type.active = 1 ";
58 $spell .= "ORDER BY form_track_anything_type.position ASC, the_name ASC ";
59 $query2 = sqlStatement($spell, array($formid, $thistime));
61 // is this the <tbale>-head?
62 if ($shownameflag == 1) {
63 echo "<tr><th class='time'>" . xlt('Time') . "</th>";
64 while ($myrow2 = sqlFetchArray($query2)) {
65 echo "<th class='item'>&nbsp;" . text($myrow2['the_name']) . "&nbsp;</th>";
66 $ofc_name[$col] = $myrow2['the_name']; // save for chart-form
67 $col++;
70 echo "</tr>";
73 // post data entries per row
74 echo "<tr><td class='time'>" . text($thistime) . "</td>";
75 $ofc_date[$row] = $thistime; // save for chart-form
76 $col_i = 0; // how many columns
77 $query2 = sqlStatement($spell, array($formid, $thistime));
78 while ($myrow2 = sqlFetchArray($query2)) {
79 echo "<td class='item'>&nbsp;" . text($myrow2['result']) . "&nbsp;</td>";
80 if (is_numeric($myrow2['result'])) {
81 $ofc_value[$col_i][$row] = $myrow2['result'];// save for chart-form
84 $col_i++;
87 echo "</tr>";
88 $row++;
93 // hide all interactive link stuff if inside a patient report
94 // (to keep Patient Report clean...)
95 // Thus we use "<div class='navigateLink'>"; see custom_report.php
96 //--------------------------------------------------------------
97 // Graph-Button row
98 //-------------------------------
99 echo "<tr>";
100 echo "<td class='check'><div class='navigateLink'>" . xlt('Check items to graph') . "</div></td>";
101 for ($col_i = 0; $col_i < $col; $col_i++) {
102 echo "<td class='check'><div class='navigateLink'>";
103 for ($row_b = 0; $row_b < $row; $row_b++) {
104 // count more than 1 to show graph-button
105 if (is_numeric($ofc_value[$col_i][$row_b])) {
106 $dummy[$col_i]++;
110 // show graph-button only if we have more than 1 valid data
111 if ($dummy[$col_i] > 1) {
112 echo "<input type='checkbox' name='check_col" . attr($formid) . "' value='" . attr($col_i) . "'>";
113 $showbutton++;
116 echo "</div></td>";
119 echo "</tr>";
121 // end Graph-Button-Row---------
123 if ($showbutton > 0) {
124 echo "<tr><td></td>";
125 echo "<td colspan='" . attr($col) . "'><div class='navigateLink'>";
126 echo "<input type='button' class='graph_button' ";
127 echo " onclick='ta_report_plot_graph(" . attr_js($formid) . "," . attr_js($ofc_name) . "," . attr_js($the_track_name) . "," . attr_js($ofc_date) . "," . attr_js($ofc_value) . ")'";
128 echo " name='' value='" . xla('Plot selected Items') . "'>";
129 echo "</div></td></tr>";
132 //---/end graph button------------------
133 echo "</table>";
134 echo "<br />";
135 echo "<div class='navigateLink'>"; // see custom_report.php
136 echo "<form method='post' action='../../forms/track_anything/history.php' onsubmit='return top.restoreSession()'>";
137 echo "<input type='hidden' name='formid' value='" . attr($formid) . "'>";
138 echo "<input type='submit' name='history' value='" . xla('Show track history') . "' />";
139 echo "</form>";
140 echo "</div>"; // end hide for report
141 echo "</div>";
142 }// end function track_anything_report