4 * add_transaction is a misnomer, as this script will now also edit
5 * existing transactions.
8 * LICENSE: This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>.
20 * @author Rod Roark <rod@sunsetsystems.com>
21 * @author Brady Miller <brady.g.miller@gmail.com>
22 * @link http://www.open-emr.org
28 require_once("../../globals.php");
29 require_once("$srcdir/transactions.inc");
30 require_once("$srcdir/options.inc.php");
31 require_once("$srcdir/amc.php");
33 // This can come from the URL if it's an Add.
34 $title = empty($_REQUEST['title']) ?
'LBTref' : $_REQUEST['title'];
38 $fname = $GLOBALS['OE_SITE_DIR'] . "/LBF/$form_id.plugin.php";
39 if (file_exists($fname)) {
43 $transid = empty($_REQUEST['transid']) ?
0 : $_REQUEST['transid'] +
0;
44 $mode = empty($_POST['mode' ]) ?
'' : $_POST['mode' ];
45 // $inmode = $_GET['inmode'];
46 $body_onload_code = "";
49 $sets = "title = ?, user = ?, groupname = ?, authorized = ?, date = NOW()";
50 $sqlBindArray = array($form_id, $_SESSION['authUser'], $_SESSION['authProvider'], $userauthorized);
53 array_push($sqlBindArray, $transid);
54 sqlStatement("UPDATE transactions SET $sets WHERE id = ?", $sqlBindArray);
56 array_push($sqlBindArray, $pid);
58 $newid = sqlInsert("INSERT INTO transactions SET $sets", $sqlBindArray);
61 $fres = sqlStatement("SELECT * FROM layout_options " .
62 "WHERE form_id = ? AND uor > 0 AND field_id != '' " .
63 "ORDER BY group_name, seq", array($form_id));
65 while ($frow = sqlFetchArray($fres)) {
66 $data_type = $frow['data_type'];
67 $field_id = $frow['field_id'];
68 $value = get_layout_form_value($frow);
70 if ($transid) { // existing form
72 $query = "DELETE FROM lbt_data WHERE " .
73 "form_id = ? AND field_id = ?";
74 sqlStatement($query, array($transid, $field_id));
76 $query = "REPLACE INTO lbt_data SET field_value = ?, " .
77 "form_id = ?, field_id = ?";
78 sqlStatement($query, array($value, $transid, $field_id));
83 "INSERT INTO lbt_data " .
84 "( form_id, field_id, field_value ) VALUES ( ?, ?, ? )",
85 array($newid, $field_id, $value)
95 // Set the AMC sent records flag
96 if (!(empty($_POST['send_sum_flag']))) {
97 // add the sent records flag
98 processAmcCall('send_sum_amc', true, 'add', $pid, 'transactions', $transid);
99 if (!(empty($_POST['send_sum_elec_flag']))) {
100 processAmcCall('send_sum_elec_amc', true, 'add', $pid, 'transactions', $transid);
103 // remove the sent records flags
104 processAmcCall('send_sum_amc', true, 'remove', $pid, 'transactions', $transid);
105 processAmcCall('send_sum_elec_amc', true, 'remove', $pid, 'transactions', $transid);
108 $body_onload_code = "javascript:location.href='transactions.php';";
111 $CPR = 4; // cells per row
115 global $item_count, $cell_count;
116 if ($item_count > 0) {
124 global $cell_count, $CPR;
126 if ($cell_count > 0) {
127 for (; $cell_count < $CPR;
140 if (strlen($last_group) > 0) {
147 // If we are editing a transaction, get its ID and data.
148 $trow = $transid ?
getTransById($transid) : array();
153 <title
><?php
echo xlt('Add/Edit Patient Transaction'); ?
></title
>
155 <link rel
='stylesheet' href
="<?php echo $css_header;?>" type
="text/css">
156 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative'] ?>/bootstrap-3-3-4/dist/css/bootstrap.min.css">
157 <?php
if ($_SESSION['language_direction'] == 'rtl') { ?
>
158 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative'] ?>/bootstrap-rtl-3-3-4/dist/css/bootstrap-rtl.min.css">
160 <link rel
="stylesheet" type
="text/css" href
="../../../library/js/fancybox/jquery.fancybox-1.2.6.css" media
="screen" />
161 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
163 <script type
="text/javascript" src
="../../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script
>
164 <script type
="text/javascript" src
="../../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
165 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-7-2/index.js"></script
>
166 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/common.js?v=<?php echo $v_js_includes; ?>"></script
>
167 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox/jquery.fancybox-1.2.6.js"></script
>
168 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script
>
170 <?php
include_once("{$GLOBALS['srcdir']}/options.js.php"); ?
>
172 <script type
="text/javascript">
173 $
(document
).ready(function() {
174 if (window
.enable_modals
) {
180 if (window
.checkSkipConditions
) {
181 checkSkipConditions();
185 var mypcc
= '<?php echo htmlspecialchars($GLOBALS['phone_country_code
'], ENT_QUOTES); ?>';
187 $
(document
).ready(function(){
188 $
("#send_sum_flag").click(function() {
189 if ( $
('#send_sum_flag').attr('checked') ) {
190 // Enable the send_sum_elec_flag checkbox
191 $
("#send_sum_elec_flag").removeAttr("disabled");
194 //Disable the send_sum_elec_flag checkbox (also uncheck it if applicable)
195 $
("#send_sum_elec_flag").attr("disabled", true);
196 $
("#send_sum_elec_flag").removeAttr("checked");
200 $
('.datepicker').datetimepicker({
201 <?php
$datetimepicker_timepicker = false; ?
>
202 <?php
$datetimepicker_showseconds = false; ?
>
203 <?php
$datetimepicker_formatInput = false; ?
>
204 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
205 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
207 $
('.datetimepicker').datetimepicker({
208 <?php
$datetimepicker_timepicker = true; ?
>
209 <?php
$datetimepicker_showseconds = false; ?
>
210 <?php
$datetimepicker_formatInput = false; ?
>
211 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
212 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
216 function titleChanged() {
217 var sel
= document
.forms
[0].title
;
218 // Layouts must not interfere with each other. Reload the document in Add mode.
219 top
.restoreSession();
220 location
.href
= 'add_transaction.php?title=' + sel
.value
;
224 function divclick(cb
, divid
) {
225 var divstyle
= document
.getElementById(divid
).style
;
227 divstyle
.display
= 'block';
229 divstyle
.display
= 'none';
234 // The ID of the input element to receive a found code.
235 var current_sel_name
= '';
237 // This is for callback by the find-code popup.
238 // Appends to or erases the current list of related codes.
239 function set_related(codetype
, code
, selector
, codedesc
) {
240 var frc
= document
.forms
[0][current_sel_name
];
243 if (s
.length
> 0) s +
= ';';
244 s +
= codetype +
':' + code
;
251 // This invokes the find-code popup.
252 function sel_related(e
) {
253 current_sel_name
= e
.name
;
254 dlgopen('../encounter/find_code_popup.php<?php if ($GLOBALS['ippf_specific
']) {
255 echo '?codetype
=REF
';
256 } ?>', '_blank', 500, 400);
259 // Process click on Delete link.
260 function deleteme() {
261 // onclick='return deleteme()'
262 dlgopen('../deleter.php?transaction=<?php echo htmlspecialchars($transid, ENT_QUOTES); ?>', '_blank', 500, 450);
266 // Called by the deleteme.php window on a successful delete.
267 function imdeleted() {
268 top
.restoreSession();
269 location
.href
= 'transaction/transactions.php';
272 // Compute the length of a string without leading and trailing spaces.
273 function trimlen(s
) {
275 var j
= s
.length
- 1;
276 for (; i
<= j
&& s
.charAt(i
) == ' '; ++i
);
277 for (; i
<= j
&& s
.charAt(j
) == ' '; --j
);
282 // Validation logic for form submission.
283 function validate(f
) {
285 var errMsgs
= new Array();
287 <?php
generate_layout_validation($form_id); ?
>
290 msg +
= "<?php echo xla('The following fields are required'); ?>:\n\n";
291 for ( var i
= 0; i
< errMsgs
.length
; i++
) {
292 msg +
= errMsgs
[i
] +
"\n";
294 msg +
= "\n<?php echo xla('Please fill them in before continuing.'); ?>";
296 if ( errMsgs
.length
> 0 ) {
300 return errMsgs
.length
< 1;
303 function submitme() {
304 var f
= document
.forms
['new_transaction'];
306 top
.restoreSession();
311 <?php
if (function_exists($form_id . '_javascript')) {
312 call_user_func($form_id . '_javascript');
317 <style type
="text/css">
330 <body
class="body_top" onload
="<?php echo $body_onload_code; ?>" >
331 <form name
='new_transaction' method
='post' action
='add_transaction.php?transid=<?php echo attr($transid); ?>' onsubmit
='return validate(this)'>
332 <input type
='hidden' name
='mode' value
='add'>
334 <div
class="container-fluid">
336 <div
class="col-xs-12">
337 <div
class="page-header">
338 <h1
><?php
echo xlt('Add/Edit Patient Transaction');?
></h1
>
341 <div
class="col-xs-12">
342 <div
class="btn-group">
343 <a href
="#" class="btn btn-default btn-save" onclick
="submitme();">
344 <?php
echo xlt('Save'); ?
>
346 <a href
="transactions.php" class="btn btn-link btn-cancel" onclick
="top.restoreSession()">
347 <?php
echo xlt('Cancel'); ?
>
357 <?php
echo xlt('Transaction Type'); ?
>: 
;</td
><td
>
358 <?php
echo generate_select_list('title', 'transactions', $form_id, '', '', '', 'titleChanged()'); ?
>
364 <?php
if ($GLOBALS['enable_amc_prompting'] && 'LBTref' == $form_id) { ?
>
365 <div style
='float:right;margin-right:25px;border-style:solid;border-width:1px;'>
366 <div style
='float:left;margin:5px 5px 5px 5px;'>
368 <?php
// Display the send records checkboxes (AMC prompting)
369 $itemAMC = amcCollect("send_sum_amc", $pid, 'transactions', $transid);
370 $itemAMC_elec = amcCollect("send_sum_elec_amc", $pid, 'transactions', $transid);
373 <?php
if (!(empty($itemAMC))) { ?
>
374 <input type
="checkbox" id
="send_sum_flag" name
="send_sum_flag" checked
>
376 <input type
="checkbox" id
="send_sum_flag" name
="send_sum_flag">
379 <span
class="text"><?php
echo xlt('Sent Summary of Care?') ?
></span
><br
>
381 <?php
if (!(empty($itemAMC)) && !(empty($itemAMC_elec))) { ?
>
382  
; 
;<input type
="checkbox" id
="send_sum_elec_flag" name
="send_sum_elec_flag" checked
>
383 <?php
} else if (!(empty($itemAMC))) { ?
>
384  
; 
;<input type
="checkbox" id
="send_sum_elec_flag" name
="send_sum_elec_flag">
386  
; 
;<input type
="checkbox" id
="send_sum_elec_flag" name
="send_sum_elec_flag" disabled
>
389 <span
class="text"><?php
echo xlt('Sent Summary of Care Electronically?') ?
></span
><br
>
398 $fres = sqlStatement("SELECT * FROM layout_options " .
399 "WHERE form_id = ? AND uor > 0 " .
400 "ORDER BY group_name, seq", array($form_id));
403 while ($frow = sqlFetchArray($fres)) {
404 $this_group = $frow['group_name'];
405 // Handle a data category (group) change.
406 if (strcmp($this_group, $last_group) != 0) {
407 $group_seq = substr($this_group, 0, 1);
408 $group_name = substr($this_group, 1);
409 $last_group = $this_group;
410 if ($group_seq == 1) {
411 echo "<li class='current'>";
413 echo "<li class=''>";
416 $group_seq_esc = attr($group_seq);
417 $group_name_show = text(xl_layout_label($group_name));
418 echo "<a href='#' id='div_$group_seq_esc'>" .
419 "$group_name_show</a></li>";
424 <div
class="tabContainer">
427 $fres = sqlStatement("SELECT * FROM layout_options " .
428 "WHERE form_id = ? AND uor > 0 " .
429 "ORDER BY group_name, seq", array($form_id));
434 $display_style = 'block';
437 while ($frow = sqlFetchArray($fres)) {
438 $this_group = $frow['group_name'];
439 $titlecols = $frow['titlecols'];
440 $datacols = $frow['datacols'];
441 $data_type = $frow['data_type'];
442 $field_id = $frow['field_id'];
443 $list_id = $frow['list_id'];
445 // Accumulate skip conditions into a JSON expression for the browser side.
446 // Cloned from interface/forms/LBF/new.php.
447 $conditions = empty($frow['conditions']) ?
array() : unserialize($frow['conditions']);
448 foreach ($conditions as $condition) {
449 if (empty($condition['id'])) {
453 $andor = empty($condition['andor']) ?
'' : $condition['andor'];
454 if ($condition_str) {
455 $condition_str .= ",\n";
458 $condition_str .= "{" .
459 "target:'" . addslashes($field_id) . "', " .
460 "id:'" . addslashes($condition['id']) . "', " .
461 "itemid:'" . addslashes($condition['itemid']) . "', " .
462 "operator:'" . addslashes($condition['operator']) . "', " .
463 "value:'" . addslashes($condition['value']) . "', " .
464 "andor:'" . addslashes($andor) . "'}";
468 if (isset($trow[$field_id])) {
469 $currvalue = $trow[$field_id];
472 // Handle special-case default values.
473 if (!$currvalue && !$transid && $form_id == 'LBTref') {
474 if ($field_id == 'refer_date') {
475 $currvalue = date('Y-m-d');
476 } else if ($field_id == 'body' && $transid > 0) {
477 $tmp = sqlQuery("SELECT reason FROM form_encounter WHERE " .
478 "pid = ? ORDER BY date DESC LIMIT 1", array($pid));
480 $currvalue = $tmp['reason'];
485 // Handle a data category (group) change.
486 if (strcmp($this_group, $last_group) != 0) {
488 $group_seq = substr($this_group, 0, 1);
489 $group_name = substr($this_group, 1);
490 $last_group = $this_group;
491 $group_seq_esc = attr($group_seq);
492 if ($group_seq == 1) {
493 echo "<div class='tab current' id='div_$group_seq_esc'>";
495 echo "<div class='tab' id='div_$group_seq_esc'>";
498 echo " <table border='0' cellpadding='0'>\n";
499 $display_style = 'none';
502 // Handle starting of a new row.
503 if (($titlecols > 0 && $cell_count >= $CPR) ||
$cell_count == 0) {
508 if ($item_count == 0 && $titlecols == 0) {
512 // Handle starting of a new label cell.
513 if ($titlecols > 0) {
515 $titlecols_esc = attr($titlecols);
516 echo "<td width='70' valign='top' colspan='$titlecols_esc'";
517 echo ($frow['uor'] == 2) ?
" class='required'" : " class='bold'";
518 if ($cell_count == 2) {
519 echo " style='padding-left:10pt'";
522 // This ID is used by skip conditions.
523 echo " id='label_id_" . attr($field_id) . "'";
525 $cell_count +
= $titlecols;
532 // Modified 6-09 by BM - Translate if applicable
533 if ($frow['title']) {
534 echo (text(xl_layout_label($frow['title'])) . ":");
541 // Handle starting of a new data cell.
544 $datacols_esc = attr($datacols);
545 echo "<td valign='top' colspan='$datacols_esc' class='text'";
546 // This ID is used by skip conditions.
547 echo " id='value_id_" . attr($field_id) . "'";
548 if ($cell_count > 0) {
549 echo " style='padding-left:5pt'";
553 $cell_count +
= $datacols;
557 generate_form_field($frow, $currvalue);
569 <!-- include support
for the
list-add selectbox feature
-->
570 <?php
include $GLOBALS['fileroot']."/library/options_listadd.inc"; ?
>
574 <script language
="JavaScript">
576 // Array of skip conditions for the checkSkipConditions() function.
578 <?php
echo $condition_str; ?
>
581 <?php
echo $date_init; ?
>
584 if (function_exists($form_id . '_javascript_onload')) {
585 call_user_func($form_id . '_javascript_onload');