3 * Common script for the encounter form (new and view) scripts.
5 * Copyright (C) 2016 Shachar Zilbershlag <shaharzi@matrix.co.il>
6 * Copyright (C) 2016 Amiel Elboim <amielel@matrix.co.il>
7 * Copyright (C) 2017 Brady Miller <brady.g.miller@gmail.com>
9 * LICENSE: This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
21 * @author Amiel Elboim <amielel@matrix.co.il>
22 * @author Brady Miller <brady.g.miller@gmail.com>
23 * @link http://www.open-emr.org
26 require_once("$srcdir/options.inc.php");
27 require_once("$srcdir/group.inc");
28 require_once("$srcdir/classes/POSRef.class.php");
30 $facilityService = new \services\
FacilityService();
32 $months = array("01","02","03","04","05","06","07","08","09","10","11","12");
33 $days = array("01","02","03","04","05","06","07","08","09","10","11","12","13","14",
34 "15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31");
35 $thisyear = date("Y");
36 $years = array($thisyear-1, $thisyear, $thisyear+
1, $thisyear+
2);
39 $id = (isset($_REQUEST['id'])) ?
$_REQUEST['id'] : '';
40 $result = sqlQuery("SELECT * FROM form_groups_encounter WHERE id = ?", array($id));
41 $encounter = $result['encounter'];
42 if ($result['sensitivity'] && !acl_check('sensitivities', $result['sensitivity'])) {
43 echo "<body>\n<html>\n";
44 echo "<p>" . xlt('You are not authorized to see this encounter.') . "</p>\n";
45 echo "</body>\n</html>\n";
50 // Sort comparison for sensitivities by their order attribute.
51 function sensitivity_compare($a, $b)
53 return ($a[2] < $b[2]) ?
-1 : 1;
57 $ires = sqlStatement("SELECT id, type, title, begdate FROM lists WHERE " .
58 "pid = ? AND enddate IS NULL " .
59 "ORDER BY type, begdate", array($pid));
61 <!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
64 <?php
html_header_show();?
>
65 <title
><?php
echo xlt('Therapy Group Encounter'); ?
></title
>
67 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
68 <link rel
="stylesheet" type
="text/css" href
="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox-1.3.4/jquery.fancybox-1.3.4.css" media
="screen" />
69 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
71 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-7-2/index.js"></script
>
72 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script
>
73 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/common.js?v=<?php echo $v_js_includes; ?>"></script
>
74 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox-1.3.4/jquery.fancybox-1.3.4.pack.js"></script
>
75 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
76 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js?v=<?php echo $v_js_includes; ?>"></script
>
78 <!-- validation library
-->
80 //Not lbf forms use the new validation, please make sure you have the corresponding values in the list Page validation
82 require_once($GLOBALS['srcdir'] . "/validation/validation_script.js.php"); ?
>
84 <?php
include_once("{$GLOBALS['srcdir']}/ajax/facility_ajax_jav.inc.php"); ?
>
85 <script language
="JavaScript">
87 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
90 // Process click on issue title.
92 dlgopen('../../patient_file/summary/add_edit_issue.php', '_blank', 800, 600);
96 // callback from add_edit_issue.php:
97 function refreshIssue(issue, title) {
98 var s = document.forms[0]['issues[]'];
99 s.options[s.options.length] = new Option(title, issue, true, true);
104 //Gets validation rules from Page Validation list.
105 //Note that for technical reasons, we are bypassing the standard validateUsingPageRules() call.
106 $collectthis = collectValidationPageRules("/interface/forms/newGroupEncounter/common.php");
107 if (empty($collectthis)) {
108 $collectthis = "undefined";
110 $collectthis = $collectthis["new-encounter-form"]["rules"];
113 var collectvalidation
= <?php
echo($collectthis); ?
>;
114 $
(document
).ready(function(){
115 window
.saveClicked
= function(event
) {
116 var submit
= submitme(1, event
, 'new-encounter-form', collectvalidation
);
118 top
.restoreSession();
119 $
('#new-encounter-form').submit();
123 $
('.datepicker').datetimepicker({
124 <?php
$datetimepicker_timepicker = false; ?
>
125 <?php
$datetimepicker_showseconds = false; ?
>
126 <?php
$datetimepicker_formatInput = false; ?
>
127 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
128 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
135 var pid
=<?php
echo attr($pid);?
>;
136 var dte
=document
.getElementById('form_date').value
;
137 var facility
=document
.forms
[0].facility_id
.value
;
138 ajax_bill_loc(pid
,dte
,facility
);
141 // Handler for Cancel clicked when creating a new encounter.
142 // Show demographics or encounters list depending on what frame we're in.
143 function cancelClicked() {
144 if (window
.name
== 'RBot') {
145 parent
.left_nav
.loadFrame('ens1', window
.name
, 'patient_file/history/encounters.php');
148 parent
.left_nav
.loadFrame('dem1', window
.name
, 'patient_file/summary/demographics.php');
156 <?php
if ($viewmode) { ?
>
157 <body
class="body_top">
159 <body
class="body_top" onload
="javascript:document.new_encounter.reason.focus();">
162 <!-- Required
for the popup date selectors
-->
163 <div id
="overDiv" style
="position:absolute; visibility:hidden; z-index:1000;"></div
>
165 <form id
="new-encounter-form" method
='post' action
="<?php echo $rootdir ?>/forms/newGroupEncounter/save.php" name
='new_encounter'>
167 <div style
='float:left'>
168 <?php
if ($viewmode) { ?
>
169 <input type
=hidden name
='mode' value
='update'>
170 <input type
=hidden name
='id' value
='<?php echo (isset($_GET["id"])) ? attr($_GET["id"]) : '' ?>'>
171 <span
class=title
><?php
echo xlt('Group Encounter Form'); ?
></span
>
173 <input type
='hidden' name
='mode' value
='new'>
174 <span
class='title'><?php
echo xlt('New Group Encounter Form'); ?
></span
>
179 <div style
= 'float:left; margin-left:8px;margin-top:-3px'>
180 <a href
="javascript:saveClicked(undefined);" class="css_button link_submit"><span
><?php
echo xlt('Save'); ?
></span
></a
>
181 <?php
if ($viewmode ||
!isset($_GET["autoloaded"]) ||
$_GET["autoloaded"] != "1") { ?
>
183 <div style
= 'float:left; margin-top:-3px'>
184 <a href
="<?php echo "$rootdir/patient_file
/encounter
/encounter_top
.php
"; ?>"
185 class="css_button link_submit" onClick
="top.restoreSession()"><span
><?php
echo xlt('Cancel'); ?
></span
></a
>
186 <?php
} else { // not $viewmode ?>
187 <a href
="" class="css_button link_submit" onClick
="return cancelClicked()">
188 <span
><?php
echo xlt('Cancel'); ?
></span
></a
>
189 <?php
} // end not $viewmode ?>
198 <td width
='33%' nowrap
class='bold'><?php
echo xlt('Consultation Brief Description'); ?
>:</td
>
199 <td width
='34%' rowspan
='2' align
='center' valign
='center' class='text'>
203 <td
class='bold' nowrap
><?php
echo xlt('Visit Category'); ?
>:</td
>
205 <select name
='pc_catid' id
='pc_catid'>
206 <option value
='_blank'>-- <?php
echo xlt('Select One'); ?
> --</option
>
208 $cres = sqlStatement("SELECT pc_catid, pc_catname, pc_cattype " .
209 "FROM openemr_postcalendar_categories where pc_active = 1 ORDER BY pc_seq ");
210 while ($crow = sqlFetchArray($cres)) {
211 $catid = $crow['pc_catid'];
212 if ($crow['pc_cattype'] != 3) {
216 echo " <option value='" . attr($catid) . "'";
217 // mark therapy group's category as selected
218 if (!$viewmode && $crow['pc_cattype'] == 3) {
222 if ($viewmode && $crow['pc_catid'] == $result['pc_catid']) {
226 echo ">" . text(xl_appt_category($crow['pc_catname'])) . "</option>\n";
234 <td
class='bold' nowrap
><?php
echo xlt('Facility'); ?
>:</td
>
236 <select name
='facility_id' onChange
="bill_loc()">
240 $def_facility = $result['facility_id'];
242 $dres = sqlStatement("select facility_id from users where username = ?", array($_SESSION['authUser']));
243 $drow = sqlFetchArray($dres);
244 $def_facility = $drow['facility_id'];
247 $facilities = $facilityService->getAllServiceLocations();
249 foreach ($facilities as $iter) {
251 <option value
="<?php echo attr($iter['id']); ?>" <?php
if ($def_facility == $iter['id']) {
253 }?
>><?php
echo text($iter['name']); ?
></option
>
262 <td
class='bold' nowrap
><?php
echo xlt('Billing Facility'); ?
>:</td
>
266 billing_facility('billing_facility', $result['billing_facility']);
271 <?php
if ($GLOBALS['set_pos_code_encounter']) { ?
>
273 <td
><span
class='bold' nowrap
><?php
echo xlt('POS Code'); ?
>: </span
></td
>
275 <select name
="pos_code">
280 foreach ($pc->get_pos_ref() as $pos) {
281 echo "<option value=\"" . attr($pos["code"]) . "\" ";
282 if ($pos["code"] == $result['pos_code']) {
286 echo ">" . text($pos['code']) . ": ". xlt($pos['title']);
297 $sensitivities = acl_get_sensitivities();
298 if ($sensitivities && count($sensitivities)) {
299 usort($sensitivities, "sensitivity_compare");
301 <td
class='bold' nowrap
><?php
echo xlt('Sensitivity:'); ?
></td
>
303 <select name
='form_sensitivity'>
305 foreach ($sensitivities as $value) {
306 // Omit sensitivities to which this user does not have access.
307 if (acl_check('sensitivities', $value[1])) {
308 echo " <option value='" . attr($value[1]) . "'";
309 if ($viewmode && $result['sensitivity'] == $value[1]) {
313 echo ">" . xlt($value[3]) . "</option>\n";
317 echo " <option value=''";
318 if ($viewmode && !$result['sensitivity']) {
322 echo ">" . xlt('None'). "</option>\n";
329 <td colspan
='2'><!-- sensitivities not used
--></td
>
335 <tr
<?php
if (!$GLOBALS['gbl_visit_referral_source']) {
336 echo " style='visibility:hidden;'";
338 <td
class='bold' nowrap
><?php
echo xlt('Referral Source'); ?
>:</td
>
341 echo generate_select_list('form_referral_source', 'refsource', $viewmode ?
$result['referral_source'] : '', '');
347 <td
class='bold' nowrap
><?php
echo xlt('Date of Service'); ?
>:</td
>
348 <td
class='text' nowrap
>
349 <input type
='text' size
='10' class='datepicker' name
='form_date' id
='form_date' <?php
echo $disabled ?
>
350 value
='<?php echo $viewmode ? substr($result['date
'], 0, 10) : date('Y
-m
-d
'); ?>'
351 title
='<?php echo xla('yyyy
-mm
-dd Date of service
'); ?>' />
355 <tr
<?php
if ($GLOBALS['ippf_specific']) {
356 echo " style='visibility:hidden;'";
358 <td
class='bold' nowrap
><?php
echo xlt('Additional Date:'); ?
></td
>
359 <td
class='text' nowrap
><!-- default is blank so that
while generating claim the date is blank
. -->
360 <input type
='text' size
='10' class='datepicker' name
='form_onset_date' id
='form_onset_date'
361 value
='<?php echo $viewmode && $result['onset_date
']!='0000-00-00 00:00:00' ? substr($result['onset_date
'], 0, 10) : ''; ?>'
362 title
='<?php echo xla('yyyy
-mm
-dd Date of onset
or hospitalization
'); ?>' />
366 <td
class='text' colspan
='2' style
='padding-top:1em'>
375 <td
class='text' valign
='top'>
376 <textarea name
='reason' cols
='40' rows
='12' wrap
='virtual' style
='width:96%'
377 ><?php
echo $viewmode ?
text($result['reason']) : text($GLOBALS['default_chief_complaint']); ?
></textarea
>
387 <script language
="javascript">
390 function duplicateVisit(enc
, datestr
) {
391 if (!confirm('<?php echo xls("A visit already exists for this group today. Click Cancel to open it, or OK to proceed with creating a new one.") ?>')) {
392 // User pressed the cancel button, so re-direct to today's encounter
393 top
.restoreSession();
394 parent
.left_nav
.setEncounter(datestr
, enc
, window
.name
);
395 parent
.left_nav
.loadFrame('enc2', window
.name
, 'patient_file/encounter/encounter_top.php?set_encounter=' + enc
);
398 // otherwise just continue normally
402 // Search for an encounter from today
403 $erow = sqlQuery("SELECT fe.encounter, fe.date " .
404 "FROM form_groups_encounter AS fe, forms AS f WHERE " .
406 " AND fe.date >= ? " .
407 " AND fe.date <= ? " .
409 "f.formdir = 'newGroupEncounter' AND f.form_id = fe.id AND f.deleted = 0 " .
410 "ORDER BY fe.encounter DESC LIMIT 1", array($therapy_group,date('Y-m-d 00:00:00'),date('Y-m-d 23:59:59')));
412 if (!empty($erow['encounter'])) {
413 // If there is an encounter from today then present the duplicate visit dialog
414 echo "duplicateVisit('" . $erow['encounter'] . "', '" .
415 oeFormatShortDate(substr($erow['date'], 0, 10)) . "');\n";