/
history_form.php
267 lines (227 loc) · 8.6 KB
/
history_form.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<?php
/**
* Patient history posting for the WordPress Patient Portal.
*
* @package OpenEMR
* @link http://www.open-emr.org
* @author Rod Roark <rod@sunsetsystems.com>
* @author Brady Miller <brady.g.miller@gmail.com>
* @copyright Copyright (c) 2014 Rod Roark <rod@sunsetsystems.com>
* @copyright Copyright (c) 2017-2019 Brady Miller <brady.g.miller@gmail.com>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/
require_once("../globals.php");
require_once("$srcdir/patient.inc");
require_once("$srcdir/options.inc.php");
require_once("portal.inc.php");
use OpenEMR\Core\Header;
$postid = intval($_REQUEST['postid']);
$ptid = intval($_REQUEST['ptid' ]);
if ($_POST['bn_save']) {
$newdata = array();
$fres = sqlStatement("SELECT * FROM layout_options WHERE " .
"form_id = 'HIS' AND field_id != '' AND uor > 0 " .
"ORDER BY group_id, seq");
while ($frow = sqlFetchArray($fres)) {
$data_type = $frow['data_type'];
$field_id = $frow['field_id'];
if (isset($_POST["form_$field_id"])) {
$newdata[$field_id] = get_layout_form_value($frow);
}
}
updateHistoryData($ptid, $newdata);
// Finally, delete the request from the portal.
$result = cms_portal_call(array('action' => 'delpost', 'postid' => $postid));
if ($result['errmsg']) {
die(text($result['errmsg']));
}
echo "<html><body><script language='JavaScript'>\n";
echo "if (top.restoreSession) top.restoreSession(); else opener.top.restoreSession();\n";
echo "document.location.href = 'list_requests.php';\n";
echo "</script></body></html>\n";
exit();
}
// Get the portal request data.
if (!$postid) {
die(xlt('Request ID is missing!'));
}
$result = cms_portal_call(array('action' => 'getpost', 'postid' => $postid));
if ($result['errmsg']) {
die(text($result['errmsg']));
}
// Look up the patient in OpenEMR.
$ptid = lookup_openemr_patient($result['post']['user']);
// Get patient's current history data in OpenEMR.
$hyrow = getHistoryData($ptid, "*");
?>
<html>
<head>
<?php Header::setupHeader('datetime-picker'); ?>
<style>
tr.head {
font-size: 0.8125rem;
background-color: var(--gray400);
text-align: center;
}
tr.detail {
font-size: 0.8125rem;
background-color: var(--gray300);
}
td input {
background-color: transparent;
}
</style>
<script>
function myRestoreSession() {
if (top.restoreSession) top.restoreSession(); else opener.top.restoreSession();
return true;
}
// This capitalizes the first letter of each word in the passed input
// element. It also strips out extraneous spaces.
// Copied from demographics_full.php.
function capitalizeMe(elem) {
var a = elem.value.split(' ');
var s = '';
for(var i = 0; i < a.length; ++i) {
if (a[i].length > 0) {
if (s.length > 0) s += ' ';
s += a[i].charAt(0).toUpperCase() + a[i].substring(1);
}
}
elem.value = s;
}
function validate() {
var f = document.forms[0];
// TBD
return true;
}
$(function () {
$('.datepicker').datetimepicker({
<?php $datetimepicker_timepicker = false; ?>
<?php $datetimepicker_showseconds = false; ?>
<?php $datetimepicker_formatInput = true; ?>
<?php $datetimepicker_minDate = false; ?>
<?php $datetimepicker_maxDate = false; ?>
<?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
<?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
});
$('.datetimepicker').datetimepicker({
<?php $datetimepicker_timepicker = true; ?>
<?php $datetimepicker_showseconds = false; ?>
<?php $datetimepicker_formatInput = true; ?>
<?php $datetimepicker_minDate = false; ?>
<?php $datetimepicker_maxDate = false; ?>
<?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
<?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
});
$('.datepicker-past').datetimepicker({
<?php $datetimepicker_timepicker = false; ?>
<?php $datetimepicker_showseconds = false; ?>
<?php $datetimepicker_formatInput = true; ?>
<?php $datetimepicker_minDate = false; ?>
<?php $datetimepicker_maxDate = '+1970/01/01'; ?>
<?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
<?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
});
$('.datetimepicker-past').datetimepicker({
<?php $datetimepicker_timepicker = true; ?>
<?php $datetimepicker_showseconds = false; ?>
<?php $datetimepicker_formatInput = true; ?>
<?php $datetimepicker_minDate = false; ?>
<?php $datetimepicker_maxDate = '+1970/01/01'; ?>
<?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
<?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
});
$('.datepicker-future').datetimepicker({
<?php $datetimepicker_timepicker = false; ?>
<?php $datetimepicker_showseconds = false; ?>
<?php $datetimepicker_formatInput = true; ?>
<?php $datetimepicker_minDate = '-1970/01/01'; ?>
<?php $datetimepicker_maxDate = false; ?>
<?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
<?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
});
$('.datetimepicker-future').datetimepicker({
<?php $datetimepicker_timepicker = true; ?>
<?php $datetimepicker_showseconds = false; ?>
<?php $datetimepicker_formatInput = true; ?>
<?php $datetimepicker_minDate = '-1970/01/01'; ?>
<?php $datetimepicker_maxDate = false; ?>
<?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
<?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
});
});
</script>
</head>
<body class="body_top">
<center>
<form method='post' action='history_form.php' onsubmit='return validate()'>
<input type='hidden' name='ptid' value='<?php echo attr($ptid); ?>' />
<input type='hidden' name='postid' value='<?php echo attr($postid); ?>' />
<table class='w-100' cellpadding='1' cellspacing='2'>
<tr class='head'>
<th align='left'><?php echo xlt('Field'); ?></th>
<th align='left'><?php echo xlt('Current Value'); ?></th>
<th align='left'><?php echo xlt('New Value'); ?></th>
</tr>
<?php
$lores = sqlStatement(
"SELECT * FROM layout_options " .
"WHERE form_id = ? AND uor > 0 ORDER BY group_id, seq",
array('HIS')
);
while ($lorow = sqlFetchArray($lores)) {
$data_type = $lorow['data_type'];
$field_id = $lorow['field_id'];
// Check for field name match in portal results, case insensitive.
$reskey = $field_id;
$gotfield = false;
foreach ($result['fields'] as $key => $dummy) {
// For Exam Results the field ID has a colon and list item ID appended.
if (($i = strpos($key, ':')) !== false) {
$key = substr($key, 0, $i);
}
if (strcasecmp($key, $field_id) == 0) {
$reskey = $key;
$gotfield = true;
}
}
// Generate form fields for items that are either from the WordPress form
// or are mandatory.
if ($gotfield || $lorow['uor'] > 1) {
$list_id = $lorow['list_id'];
$field_title = $lorow['title'];
if ($field_title === '') {
$field_title = '(' . $field_id . ')';
}
$currvalue = '';
if (isset($hyrow[$field_id])) {
$currvalue = $hyrow[$field_id];
}
$newvalue = cms_field_to_lbf($data_type, $reskey, $result['fields']);
echo " <tr class='detail'>\n";
echo " <td class='font-weight-bold'>" . text($field_title) . "</td>\n";
echo " <td>" . generate_display_field($lorow, $currvalue) . "</td>\n";
echo " <td>";
generate_form_field($lorow, $newvalue);
echo "</td>\n";
echo " </tr>\n";
}
}
echo "</table>\n";
?>
<div class="btn-group">
<input type='submit' class='btn btn-primary' name='bn_save' value='<?php echo xla('Save and Delete Request'); ?>' />
<input type='button' class='btn btn-secondary' value='<?php echo xla('Back'); ?>' onclick="myRestoreSession();location='list_requests.php'" />
</div>
</form>
<script>
randompass();
// This is a by-product of generate_form_field().
<?php echo $date_init; ?>
</script>
<!-- include support for the list-add selectbox feature -->
<?php include $GLOBALS['fileroot'] . "/library/options_listadd.inc"; ?>
</center>
</body>
</html>