3 * Patient history posting for the WordPress Patient Portal.
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']) {
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";
50 // Get the portal request data.
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, "*");
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">
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
; }
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();
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(' ');
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);
105 function validate() {
106 var f
= document
.forms
[0];
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 ?>
131 <body
class="body_top">
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'>
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
>
147 $lores = sqlStatement(
148 "SELECT * FROM layout_options " .
149 "WHERE form_id = ? AND uor > 0 ORDER BY group_id, seq",
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.
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) {
171 // Generate form fields for items that are either from the WordPress form
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 . ')';
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";
191 generate_form_field($lorow, $newvalue);
201 <input type
='submit' name
='bn_save' value
='<?php echo xla('Save
and Delete Request
'); ?>' />
203 <input type
='button' value
='<?php echo xla('Back
'); ?>'
204 onclick
="myRestoreSession();location='list_requests.php'" />
209 <script language
="JavaScript">
213 // This is a by-product of generate_form_field().
214 <?php
echo $date_init; ?
>
218 <!-- include support
for the
list-add selectbox feature
-->
219 <?php
include $GLOBALS['fileroot'] . "/library/options_listadd.inc"; ?
>