3 * Patient history posting for the WordPress Patient Portal.
5 * Copyright (C) 2014 Rod Roark <rod@sunsetsystems.com>
7 * LICENSE: This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
19 * @author Rod Roark <rod@sunsetsystems.com>
22 $sanitize_all_escapes = true;
23 $fake_register_globals = false;
25 require_once("../globals.php");
26 require_once("$srcdir/patient.inc");
27 require_once("$srcdir/options.inc.php");
28 require_once("portal.inc.php");
30 $postid = intval($_REQUEST['postid']);
31 $ptid = intval($_REQUEST['ptid' ]);
33 if ($_POST['bn_save']) {
35 $fres = sqlStatement("SELECT * FROM layout_options WHERE " .
36 "form_id = 'HIS' AND field_id != '' AND uor > 0 " .
37 "ORDER BY group_name, seq");
38 while ($frow = sqlFetchArray($fres)) {
39 $data_type = $frow['data_type'];
40 $field_id = $frow['field_id'];
41 if (isset($_POST["form_$field_id"])) {
42 $newdata[$field_id] = get_layout_form_value($frow);
45 updateHistoryData($ptid, $newdata);
46 // Finally, delete the request from the portal.
47 $result = cms_portal_call(array('action' => 'delpost', 'postid' => $postid));
48 if ($result['errmsg']) {
49 die(text($result['errmsg']));
51 echo "<html><body><script language='JavaScript'>\n";
52 echo "if (top.restoreSession) top.restoreSession(); else opener.top.restoreSession();\n";
53 echo "document.location.href = 'list_requests.php';\n";
54 echo "</script></body></html>\n";
58 // Get the portal request data.
59 if (!$postid) die(xlt('Request ID is missing!'));
60 $result = cms_portal_call(array('action' => 'getpost', 'postid' => $postid));
61 if ($result['errmsg']) {
62 die(text($result['errmsg']));
65 // Look up the patient in OpenEMR.
66 $ptid = lookup_openemr_patient($result['post']['user']);
68 // Get patient's current history data in OpenEMR.
69 $hyrow = getHistoryData($ptid, "*");
73 <?php
html_header_show(); ?
>
74 <link rel
=stylesheet href
="<?php echo $css_header; ?>" type
="text/css">
76 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
79 tr
.head
{ font
-size
:10pt
; background
-color
:#cccccc; text-align:center; }
80 tr
.detail
{ font
-size
:10pt
; background
-color
:#ddddff; }
81 td input
{ background
-color
:transparent
; }
85 <script type
="text/javascript" src
="../../library/textformat.js"></script
>
86 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
87 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
88 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
89 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-2/index.js"></script
>
91 <script language
="JavaScript">
93 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
95 function myRestoreSession() {
96 if (top
.restoreSession
) top
.restoreSession(); else opener
.top
.restoreSession();
100 // This capitalizes the first letter of each word in the passed input
101 // element. It also strips out extraneous spaces.
102 // Copied from demographics_full.php.
103 function capitalizeMe(elem
) {
104 var a
= elem
.value
.split(' ');
106 for(var i
= 0; i
< a
.length
; ++i
) {
107 if (a
[i
].length
> 0) {
108 if (s
.length
> 0) s +
= ' ';
109 s +
= a
[i
].charAt(0).toUpperCase() + a
[i
].substring(1);
115 function validate() {
116 var f
= document
.forms
[0];
124 <body
class="body_top">
127 <form method
='post' action
='history_form.php' onsubmit
='return validate()'>
129 <input type
='hidden' name
='ptid' value
='<?php echo attr($ptid); ?>' />
130 <input type
='hidden' name
='postid' value
='<?php echo attr($postid); ?>' />
132 <table width
='100%' cellpadding
='1' cellspacing
='2'>
134 <th align
='left'><?php
echo xlt('Field' ); ?
></th
>
135 <th align
='left'><?php
echo xlt('Current Value'); ?
></th
>
136 <th align
='left'><?php
echo xlt('New Value' ); ?
></th
>
140 $lores = sqlStatement("SELECT * FROM layout_options " .
141 "WHERE form_id = ? AND uor > 0 ORDER BY group_name, seq",
144 while ($lorow = sqlFetchArray($lores)) {
145 $data_type = $lorow['data_type'];
146 $field_id = $lorow['field_id'];
147 // Check for field name match in portal results, case insensitive.
150 foreach ($result['fields'] as $key => $dummy) {
151 // For Exam Results the field ID has a colon and list item ID appended.
152 if (($i = strpos($key, ':')) !== false) {
153 $key = substr($key, 0, $i);
155 if (strcasecmp($key, $field_id) == 0) {
160 // Generate form fields for items that are either from the WordPress form
162 if ($gotfield ||
$lorow['uor'] > 1) {
163 $list_id = $lorow['list_id'];
164 $field_title = $lorow['title'];
165 if ($field_title === '') $field_title = '(' . $field_id . ')';
168 if (isset($hyrow[$field_id])) $currvalue = $hyrow[$field_id];
170 $newvalue = cms_field_to_lbf($data_type, $reskey, $result['fields']);
172 echo " <tr class='detail'>\n";
173 echo " <td class='bold'>" . text($field_title) . "</td>\n";
174 echo " <td>" . generate_display_field($lorow, $currvalue) . "</td>\n";
175 echo " <td>"; generate_form_field($lorow, $newvalue); echo "</td>\n";
184 <input type
='submit' name
='bn_save' value
='<?php echo xla('Save
and Delete Request
'); ?>' />
186 <input type
='button' value
='<?php echo xla('Back
'); ?>'
187 onclick
="myRestoreSession();location='list_requests.php'" />
192 <script language
="JavaScript">
196 // This is a by-product of generate_form_field().
197 <?php
echo $date_init; ?
>
201 <!-- include support
for the
list-add selectbox feature
-->
202 <?php
include $GLOBALS['fileroot'] . "/library/options_listadd.inc"; ?
>