Added historical data and graphing support for LBF encounter forms.
[openemr.git] / interface / patient_file / encounter / trend_form.php
blob1e96ef92860c930c04a22cba881062020712cf7d
1 <?php
2 // Copyright (C) 2010 Brady Miller <brady@sparmy.com>
3 // Modified 2011 Rod Roark <rod@sunsetsystems.com>
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 $special_timeout = 3600;
11 include_once("../../globals.php");
13 $formname = $_GET["formname"];
14 $is_lbf = substr($formname, 0, 3) === 'LBF';
16 //Bring in the style sheet
18 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
19 <?php
20 // Hide the current value css entries. This is currently specific
21 // for the vitals form but could use this mechanism for other
22 // forms.
23 // Hiding classes:
24 // currentvalues - input boxes
25 // valuesunfocus - input boxes that are auto-calculated
26 // editonly - the edit and cancel buttons
27 // Showing class:
28 // readonly - the link back to summary screen
29 // Also customize the 'graph' class to look like links.
31 <style>
32 .currentvalues { display: none;}
33 .valuesunfocus { display: none;}
34 .editonly { display: none;}
36 .graph {color:#0000cc;}
38 #chart {
39 border-style:solid;
40 border-width:2px;
41 margin:0em 1em 2em 2em;
43 </style>
45 <script type="text/javascript" src="../../../library/js/jquery.1.3.2.js"></script>
46 <script type="text/javascript" src="../../../library/openflashchart/js/json/json2.js"></script>
47 <script type="text/javascript" src="../../../library/openflashchart/js/swfobject.js"></script>
48 <script type="text/javascript">
50 // variable that holds graph information for the open_flash_chart_data() function
51 var data;
53 // Function that is built into swfobject.js script that will collect the
54 // data used for the graph.
55 function open_flash_chart_data()
57 return JSON.stringify(data);
60 // Show the selected chart in the 'chart' div element
61 function show_graph(table_graph, name_graph, title_graph)
63 top.restoreSession();
64 $.ajax({ url: '../../../library/openflashchart/graphs.php',
65 type: 'POST',
66 data: ({ table: table_graph,
67 name: name_graph,
68 title: title_graph
69 }),
70 dataType: "json",
71 success: function(returnData){
72 // place the raw graph data in the data variable
73 data=returnData;
74 // this function will automatically call open_flash_chart_data() in order to collect the raw data
75 swfobject.embedSWF('../../../library/openflashchart/open-flash-chart.swf', "chart", "650", "200", "9.0.0");
76 // ensure show the chart div
77 $('#chart').show();
79 error: function() {
80 // hide the chart div
81 $('#chart').hide();
83 });
86 $(document).ready(function(){
88 // Use jquery to show the 'readonly' class entries
89 $('.readonly').show();
91 // Place click callback for graphing
92 $(".graph").click(function(e){ show_graph('<?php echo $is_lbf ? $formname : 'form_vitals'; ?>', this.id, $(this).text()) });
94 // Show hovering effects for the .graph links
95 $(".graph").hover(
96 function(){
97 $(this).css({color:'#ff5555'}); //mouseover
99 function(){
100 $(this).css({color:'#0000cc'}); // mouseout
104 // show blood pressure graph by default
105 <?php if ($formname == 'LBFfms') { ?>
106 show_graph('<?php echo $formname; ?>','total','Sum of Scores');
107 <?php } else if ($is_lbf) { ?>
108 show_graph('<?php echo $formname; ?>','bp_systolic','');
109 <?php } else { ?>
110 show_graph('form_vitals','bps','');
111 <?php } ?>
113 </script>
115 <?php
116 if ($is_lbf) {
117 // Use the List Based Forms engine for all LBFxxxxx forms.
118 include_once("$incdir/forms/LBF/new.php");
120 else {
121 include_once("$incdir/forms/$formname/new.php");