Highway to PSR2
[openemr.git] / interface / patient_file / encounter / trend_form.php
blob197d39ecb6d0faa1619b396bdd43bd243fc234e3
1 <?php
2 /**
3 * Trending script for graphing objects.
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 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
10 * @copyright Copyright (c) 2010-2017 Brady Miller <brady.g.miller@gmail.com>
11 * @copyright Copyright (c) 2011 Rod Roark <rod@sunsetsystems.com>
14 $special_timeout = 3600;
15 include_once("../../globals.php");
17 $formname = $_GET["formname"];
18 $is_lbf = substr($formname, 0, 3) === 'LBF';
20 if ($is_lbf) {
21 // Determine the default field ID and its title for graphing.
22 // This is from the last graphable field in the form.
23 $default = sqlQuery(
24 "SELECT field_id, title FROM layout_options WHERE " .
25 "form_id = ? AND uor > 0 AND edit_options LIKE '%G%' " .
26 "ORDER BY group_name DESC, seq DESC, title DESC LIMIT 1",
27 array($formname)
31 //Bring in the style sheet
34 <?php require $GLOBALS['srcdir'] . '/js/xl/dygraphs.js.php'; ?>
36 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
37 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/modified/dygraphs-2-0-0/dygraph.css" type="text/css"></script>
38 <?php
39 // Hide the current value css entries. This is currently specific
40 // for the vitals form but could use this mechanism for other
41 // forms.
42 // Hiding classes:
43 // currentvalues - input boxes
44 // valuesunfocus - input boxes that are auto-calculated
45 // editonly - the edit and cancel buttons
46 // Showing class:
47 // readonly - the link back to summary screen
48 // Also customize the 'graph' class to look like links.
50 <style>
51 .currentvalues { display: none;}
52 .valuesunfocus { display: none;}
53 .editonly { display: none;}
55 .graph {color:#0000cc;}
57 #chart {
58 margin:0em 1em 2em 2em;
60 </style>
62 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-7-2/index.js"></script>
63 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/modified/dygraphs-2-0-0/dygraph.js?v=<?php echo $v_js_includes; ?>"></script>
65 <script type="text/javascript">
68 // Show the selected chart in the 'chart' div element
69 function show_graph(table_graph, name_graph, title_graph)
71 top.restoreSession();
72 $.ajax({ url: '../../../library/ajax/graphs.php',
73 type: 'POST',
74 data: ({
75 table: table_graph,
76 name: name_graph,
77 title: title_graph
78 }),
79 dataType: "json",
80 success: function(returnData){
82 g2 = new Dygraph(
83 document.getElementById("chart"),
84 returnData.data_final,
86 title: returnData.title,
87 delimiter: '\t',
88 xRangePad: 20,
89 yRangePad: 20,
90 xlabel: xlabel_translate
94 // ensure show the chart div
95 $('#chart').show();
97 error: function() {
98 // hide the chart div
99 $('#chart').hide();
104 $(document).ready(function(){
106 // Use jquery to show the 'readonly' class entries
107 $('.readonly').show();
109 // Place click callback for graphing
110 <?php if ($is_lbf) { ?>
111 // For LBF the <td> has an id of label_id_$fieldid
112 $(".graph").click(function(e){ show_graph('<?php echo $formname; ?>', this.id.substring(9), $(this).text()) });
113 <?php } else { ?>
114 $(".graph").click(function(e){ show_graph('form_vitals', this.id, $(this).text()) });
115 <?php } ?>
117 // Show hovering effects for the .graph links
118 $(".graph").hover(
119 function(){
120 $(this).css({color:'#ff5555'}); //mouseover
122 function(){
123 $(this).css({color:'#0000cc'}); // mouseout
127 // show blood pressure graph by default
128 <?php if ($is_lbf) { ?>
129 show_graph('<?php echo $formname; ?>','<?php echo $default['field_id']; ?>','<?php echo $default['title']; ?>');
130 <?php } else { ?>
131 show_graph('form_vitals','bps','');
132 <?php } ?>
134 </script>
136 <?php
137 if ($is_lbf) {
138 // Use the List Based Forms engine for all LBFxxxxx forms.
139 include_once("$incdir/forms/LBF/new.php");
140 } else {
141 // ensure the path variable has no illegal characters
142 check_file_dir_name($formname);
144 include_once("$incdir/forms/$formname/new.php");