Fully responsive globals.php with vertical menu (#2460)
[openemr.git] / interface / cmsportal / history_form.php
blob39357acd92d70f92ef47bf0b9b19066dc755a0b6
1 <?php
2 /**
3 * Patient history posting for the WordPress Patient Portal.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Rod Roark <rod@sunsetsystems.com>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2014 Rod Roark <rod@sunsetsystems.com>
10 * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once("../globals.php");
16 require_once("$srcdir/patient.inc");
17 require_once("$srcdir/options.inc.php");
18 require_once("portal.inc.php");
20 $postid = intval($_REQUEST['postid']);
21 $ptid = intval($_REQUEST['ptid' ]);
23 if ($_POST['bn_save']) {
24 $newdata = array();
25 $fres = sqlStatement("SELECT * FROM layout_options WHERE " .
26 "form_id = 'HIS' AND field_id != '' AND uor > 0 " .
27 "ORDER BY group_id, seq");
28 while ($frow = sqlFetchArray($fres)) {
29 $data_type = $frow['data_type'];
30 $field_id = $frow['field_id'];
31 if (isset($_POST["form_$field_id"])) {
32 $newdata[$field_id] = get_layout_form_value($frow);
36 updateHistoryData($ptid, $newdata);
37 // Finally, delete the request from the portal.
38 $result = cms_portal_call(array('action' => 'delpost', 'postid' => $postid));
39 if ($result['errmsg']) {
40 die(text($result['errmsg']));
43 echo "<html><body><script language='JavaScript'>\n";
44 echo "if (top.restoreSession) top.restoreSession(); else opener.top.restoreSession();\n";
45 echo "document.location.href = 'list_requests.php';\n";
46 echo "</script></body></html>\n";
47 exit();
50 // Get the portal request data.
51 if (!$postid) {
52 die(xlt('Request ID is missing!'));
55 $result = cms_portal_call(array('action' => 'getpost', 'postid' => $postid));
56 if ($result['errmsg']) {
57 die(text($result['errmsg']));
60 // Look up the patient in OpenEMR.
61 $ptid = lookup_openemr_patient($result['post']['user']);
63 // Get patient's current history data in OpenEMR.
64 $hyrow = getHistoryData($ptid, "*");
66 <html>
67 <head>
68 <link rel=stylesheet href="<?php echo $css_header; ?>" type="text/css">
69 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker/build/jquery.datetimepicker.min.css">
71 <style>
73 tr.head { font-size:10pt; background-color:#cccccc; text-align:center; }
74 tr.detail { font-size:10pt; background-color:#ddddff; }
75 td input { background-color:transparent; }
77 </style>
79 <script type="text/javascript" src="../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script>
80 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-1-7-2/jquery.min.js"></script>
81 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker/build/jquery.datetimepicker.full.min.js"></script>
83 <script language="JavaScript">
85 function myRestoreSession() {
86 if (top.restoreSession) top.restoreSession(); else opener.top.restoreSession();
87 return true;
90 // This capitalizes the first letter of each word in the passed input
91 // element. It also strips out extraneous spaces.
92 // Copied from demographics_full.php.
93 function capitalizeMe(elem) {
94 var a = elem.value.split(' ');
95 var s = '';
96 for(var i = 0; i < a.length; ++i) {
97 if (a[i].length > 0) {
98 if (s.length > 0) s += ' ';
99 s += a[i].charAt(0).toUpperCase() + a[i].substring(1);
102 elem.value = s;
105 function validate() {
106 var f = document.forms[0];
107 // TBD
108 return true;
111 $(function() {
112 $('.datepicker').datetimepicker({
113 <?php $datetimepicker_timepicker = false; ?>
114 <?php $datetimepicker_showseconds = false; ?>
115 <?php $datetimepicker_formatInput = true; ?>
116 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
117 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
119 $('.datetimepicker').datetimepicker({
120 <?php $datetimepicker_timepicker = true; ?>
121 <?php $datetimepicker_showseconds = false; ?>
122 <?php $datetimepicker_formatInput = true; ?>
123 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
124 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
128 </script>
129 </head>
131 <body class="body_top">
132 <center>
134 <form method='post' action='history_form.php' onsubmit='return validate()'>
136 <input type='hidden' name='ptid' value='<?php echo attr($ptid); ?>' />
137 <input type='hidden' name='postid' value='<?php echo attr($postid); ?>' />
139 <table width='100%' cellpadding='1' cellspacing='2'>
140 <tr class='head'>
141 <th align='left'><?php echo xlt('Field'); ?></th>
142 <th align='left'><?php echo xlt('Current Value'); ?></th>
143 <th align='left'><?php echo xlt('New Value'); ?></th>
144 </tr>
146 <?php
147 $lores = sqlStatement(
148 "SELECT * FROM layout_options " .
149 "WHERE form_id = ? AND uor > 0 ORDER BY group_id, seq",
150 array('HIS')
153 while ($lorow = sqlFetchArray($lores)) {
154 $data_type = $lorow['data_type'];
155 $field_id = $lorow['field_id'];
156 // Check for field name match in portal results, case insensitive.
157 $reskey = $field_id;
158 $gotfield = false;
159 foreach ($result['fields'] as $key => $dummy) {
160 // For Exam Results the field ID has a colon and list item ID appended.
161 if (($i = strpos($key, ':')) !== false) {
162 $key = substr($key, 0, $i);
165 if (strcasecmp($key, $field_id) == 0) {
166 $reskey = $key;
167 $gotfield = true;
171 // Generate form fields for items that are either from the WordPress form
172 // or are mandatory.
173 if ($gotfield || $lorow['uor'] > 1) {
174 $list_id = $lorow['list_id'];
175 $field_title = $lorow['title'];
176 if ($field_title === '') {
177 $field_title = '(' . $field_id . ')';
180 $currvalue = '';
181 if (isset($hyrow[$field_id])) {
182 $currvalue = $hyrow[$field_id];
185 $newvalue = cms_field_to_lbf($data_type, $reskey, $result['fields']);
187 echo " <tr class='detail'>\n";
188 echo " <td class='bold'>" . text($field_title) . "</td>\n";
189 echo " <td>" . generate_display_field($lorow, $currvalue) . "</td>\n";
190 echo " <td>";
191 generate_form_field($lorow, $newvalue);
192 echo "</td>\n";
193 echo " </tr>\n";
197 echo "</table>\n";
201 <input type='submit' name='bn_save' value='<?php echo xla('Save and Delete Request'); ?>' />
202 &nbsp;
203 <input type='button' value='<?php echo xla('Back'); ?>'
204 onclick="myRestoreSession();location='list_requests.php'" />
205 </p>
207 </form>
209 <script language="JavaScript">
211 randompass();
213 // This is a by-product of generate_form_field().
214 <?php echo $date_init; ?>
216 </script>
218 <!-- include support for the list-add selectbox feature -->
219 <?php include $GLOBALS['fileroot'] . "/library/options_listadd.inc"; ?>
221 </center>
222 </body>
223 </html>