4 * Trending script for graphing objects.
7 * @link http://www.open-emr.org
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
11 * @copyright Copyright (c) 2011 Rod Roark <rod@sunsetsystems.com>
12 * @copyright Copyright (c) 2010-2018 Brady Miller <brady.g.miller@gmail.com>
15 require_once("../../globals.php");
17 use OpenEMR\Common\Csrf\CsrfUtils
;
18 use OpenEMR\Core\Header
;
20 $formname = $_GET["formname"];
21 $is_lbf = substr($formname, 0, 3) === 'LBF';
24 // Determine the default field ID and its title for graphing.
25 // This is from the last graphable field in the form.
27 "SELECT field_id, title FROM layout_options WHERE " .
28 "form_id = ? AND uor > 0 AND edit_options LIKE '%G%' " .
29 "ORDER BY group_id DESC, seq DESC, title DESC LIMIT 1",
34 //Bring in the style sheet
36 <?php
require $GLOBALS['srcdir'] . '/js/xl/dygraphs.js.php'; ?
>
39 // Special case where not setting up the header for a script, so using setupAssets function,
40 // which does not autoload anything. The actual header is set up in the script called at
41 // the bottom of this script.
42 Header
::setupAssets(['dygraphs', 'jquery']);
46 // Hide the current value css entries. This is currently specific
47 // for the vitals form but could use this mechanism for other
50 // currentvalues - input boxes
51 // valuesunfocus - input boxes that are auto-calculated
52 // editonly - the edit and cancel buttons
54 // readonly - the link back to summary screen
55 // Also customize the 'graph' class to look like links.
65 display
: none
!important
;
73 margin
:0em
1em
2em
2em
;
80 // Show the selected chart in the 'chart' div element
81 function show_graph(table_graph
, name_graph
, title_graph
)
84 $
.ajax({ url
: '../../../library/ajax/graphs.php',
90 csrf_token_form
: <?php
echo js_escape(CsrfUtils
::collectCsrfToken()); ?
>
93 success
: function(returnData
){
96 document
.getElementById("chart"),
97 returnData
.data_final
,
99 title
: returnData
.title
,
105 xlabel
: xlabel_translate
109 // ensure show the chart div
113 // hide the chart div
115 <?php
if ($GLOBALS['graph_data_warning']) { ?
>
117 alert(<?php
echo xlj('This item does not have enough data to graph');?
> +
".\n" +
<?php
echo xlj('Please select an item that has more data');?
> +
".");
120 alert(title_graph +
" " +
<?php
echo xlj('does not have enough data to graph');?
> +
".\n" +
<?php
echo xlj('Please select an item that has more data');?
> +
".");
130 // Use jquery to show the 'readonly' class entries
131 $
('.readonly').show();
133 // Place click callback for graphing
134 <?php
if ($is_lbf) { ?
>
135 // For LBF the <td> has an id of label_id_$fieldid
136 $
(".graph").on("click", function(e
){ show_graph(<?php
echo js_escape($formname); ?
>, this
.id
.substring(9), $
(this
).text()) });
138 $
(".graph").on("click", function(e
){ show_graph('form_vitals', this
.id
, '$(this).text()') });
141 // Show hovering effects for the .graph links
142 $
(".graph").on("mouseenter",
144 $
(this
).css({color
:'#ff5555'});
147 $
(this
).css({color
:'#0000cc'});
151 // show blood pressure graph by default
152 <?php
if ($is_lbf) { ?
>
153 <?php
if (!empty($default)) { ?
>
154 show_graph(<?php
echo js_escape($formname); ?
>,<?php
echo js_escape($default['field_id']); ?
>,<?php
echo js_escape($default['title']); ?
>);
157 show_graph('form_vitals','bps','');
164 // Use the List Based Forms engine for all LBFxxxxx forms.
165 include_once("$incdir/forms/LBF/new.php");
167 // ensure the path variable has no illegal characters
168 check_file_dir_name($formname);
170 include_once("$incdir/forms/$formname/new.php");