3 * Trending script for graphing objects in track anything module.
6 * @link http://www.open-emr.org
7 * @author Brady Miller <brady.g.miller@gmail.com>
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @author Joe Slam <joe@produnis.de>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
11 * @copyright Copyright (c) 2010-2017 Brady Miller <brady.g.miller@gmail.com>
12 * @copyright Copyright (c) 2011 Rod Roark <rod@sunsetsystems.com>
13 * @copyright Copyright (c) 2014 Joe Slam <joe@produnis.de>
17 require_once(dirname(__FILE__
) . "/../../interface/globals.php");
20 $titleGraph = json_decode($_POST['track'], true);
21 $the_date_array = json_decode($_POST['dates'], true);
22 $the_value_array = json_decode($_POST['values'], true);
23 $the_item_names = json_decode($_POST['items'], true);
24 $the_checked_cols = json_decode($_POST['thecheckboxes'], true);
25 // ++++++/end get POSTed data
27 // check if something was sent
29 //-------------------------------
30 if ($the_checked_cols == null) {
32 echo "No item checked,\n";
33 echo "nothing to plot."; // DEBUG ONLY! COMMENT ME OUT!
37 // end check if NULL data
40 $data_final = array();
41 $data_final = xl('Date');
42 foreach ($the_checked_cols as $col) {
43 if (is_numeric($the_value_array[$col][0])) {
44 $data_final .= "\t" . $the_item_names[$col];
46 // is NOT numeric, so skip column
53 for ($i = 0; $i < count($the_date_array); $i++
) {
54 $data_final .= $the_date_array[$i];
55 foreach ($the_checked_cols as $col) {
56 if (is_numeric($the_value_array[$col][0])) {
58 $data_final .= "\t" . $the_value_array[$col][$i];
60 // is NOT numeric, do nothing
67 // Build and send back the json
68 $graph_build = array();
69 $graph_build['data_final'] = $data_final;
70 $graph_build['title'] = $titleGraph;
72 // Note need to also use " when building the $data_final rather
73 // than ' , or else JSON_UNESCAPED_SLASHES doesn't work and \n and
75 echo json_encode($graph_build, JSON_UNESCAPED_SLASHES
);