change eligibility batch from ssn to policy number, minor fix to filename with extra...
[openemr.git] / library / ajax / graph_track_anything.php
blobc62a3bc04bbac874affd25771d796ae9830a2315
1 <?php
2 /**
3 * Trending script for graphing objects in track anything module.
5 * @package OpenEMR
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");
19 // get $_POSTed data
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
28 // and quit if not
29 //-------------------------------
30 if ($the_checked_cols == null) {
31 // nothing to plot
32 echo "No item checked,\n";
33 echo "nothing to plot."; // DEBUG ONLY! COMMENT ME OUT!
34 exit;
37 // end check if NULL data
39 // build labels
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];
45 } else {
46 // is NOT numeric, so skip column
50 $data_final .= "\n";
52 // build data
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])) {
57 // is numeric
58 $data_final .= "\t" . $the_value_array[$col][$i];
59 } else {
60 // is NOT numeric, do nothing
64 $data_final .= "\n";
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
74 // \t get escaped.
75 echo json_encode($graph_build, JSON_UNESCAPED_SLASHES);