4 * Common script for the encounter form (new and view) scripts.
7 * @link http://www.open-emr.org
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @author Ranganath Pathak <pathak@scrs1.org>
10 * @author Jerry Padgett <sjpadgett@gmail.com>
11 * @copyright Copyright (c) 2019 Brady Miller <brady.g.miller@gmail.com>
12 * @copyright Copyright (c) 2019 Ranganath Pathak <pathak@scrs1.org>
13 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
16 require_once("$srcdir/options.inc.php");
17 require_once("$srcdir/lists.inc");
19 use OpenEMR\Common\Acl\AclExtended
;
20 use OpenEMR\Common\Acl\AclMain
;
21 use OpenEMR\Common\Csrf\CsrfUtils
;
22 use OpenEMR\Core\Header
;
23 use OpenEMR\Services\FacilityService
;
24 use OpenEMR\Services\ListService
;
25 use OpenEMR\Services\UserService
;
26 use OpenEMR\OeUI\OemrUI
;
28 $facilityService = new FacilityService();
30 if ($GLOBALS['enable_group_therapy']) {
31 require_once("$srcdir/group.inc");
34 $months = array("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12");
35 $days = array("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14",
36 "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31");
37 $thisyear = date("Y");
38 $years = array($thisyear - 1, $thisyear, $thisyear +
1, $thisyear +
2);
40 $mode = (!empty($_GET['mode'])) ?
$_GET['mode'] : null;
42 // "followup" mode is relevant when enable follow up encounters global is enabled
43 // it allows the user to duplicate past encounter and connect between the two
44 // under this mode the facility and the visit category will be same as the origin and in readonly
45 if ($mode === "followup") {
46 $encounter = (!empty($_GET['enc'])) ?
(int)$_GET['enc'] : null;
47 if (!is_null($encounter)) {
49 $_REQUEST['id'] = $encounter;
54 $id = (isset($_REQUEST['id'])) ?
$_REQUEST['id'] : '';
55 $result = sqlQuery("SELECT * FROM form_encounter WHERE id = ?", array($id));
56 $encounter = $result['encounter'];
57 $encounter_followup_id = $result['parent_encounter_id'] ??
null;
58 if ($encounter_followup_id) {
59 $q = "SELECT fe.date as date, fe.encounter as encounter FROM form_encounter AS fe " .
60 "JOIN forms AS f ON f.form_id = fe.id AND f.encounter = fe.encounter " .
61 "WHERE fe.id = ? AND f.deleted = 0 ";
62 $followup_enc = sqlQuery($q, array($encounter_followup_id));
63 $followup_date = date("m/d/Y", strtotime($followup_enc['date']));
64 $encounter_followup = $followup_enc['encounter'];
66 // @todo why is this here?
67 if ($mode === "followup") {
68 $followup_date = date("m/d/Y", strtotime($result['date']));
69 $encounter_followup = $result['encounter'];
70 $result['reason'] = '';
71 $result['date'] = date('Y-m-d H:i:s');
72 $encounterId = $result['id'];
75 if ($result['sensitivity'] && !AclMain
::aclCheckCore('sensitivities', $result['sensitivity'])) {
76 echo "<body>\n<html>\n";
77 echo "<p>" . xlt('You are not authorized to see this encounter.') . "</p>\n";
78 echo "</body>\n</html>\n";
83 // Sort comparison for sensitivities by their order attribute.
84 function sensitivity_compare($a, $b)
86 return ($a[2] < $b[2]) ?
-1 : 1;
90 $ires = sqlStatement("SELECT id, type, title, begdate FROM lists WHERE " .
91 "pid = ? AND enddate IS NULL " .
92 "ORDER BY type, begdate", array($pid));
96 <?php Header
::setupHeader(['datetime-picker', 'common']); ?
>
97 <title
><?php
echo xlt('Patient Encounter'); ?
></title
>
100 <!-- validation library
-->
102 //Not lbf forms use the new validation, please make sure you have the corresponding values in the list Page validation
103 $use_validate_js = 1;
104 require_once($GLOBALS['srcdir'] . "/validation/validation_script.js.php"); ?
>
106 <?php
include_once("{$GLOBALS['srcdir']}/ajax/facility_ajax_jav.inc.php"); ?
>
108 const mypcc
= '' +
<?php
echo js_escape($GLOBALS['phone_country_code']); ?
>;
110 // Process click on issue title.
111 function newissue() {
112 dlgopen('../../patient_file/summary/add_edit_issue.php', '_blank', 700, 535, '', '', {
114 {text
: <?php
echo xlj('Close'); ?
>, close
: true, style
: 'default btn-sm'}
120 // callback from add_edit_issue.php:
121 function refreshIssue(issue
, title
) {
122 var s
= document
.forms
[0]['issues[]'];
123 s
.options
[s
.options
.length
] = new Option(title
, issue
, true, true);
127 //Gets validation rules from Page Validation list.
128 //Note that for technical reasons, we are bypassing the standard validateUsingPageRules() call.
129 $collectthis = collectValidationPageRules("/interface/forms/newpatient/common.php");
130 if (empty($collectthis)) {
131 $collectthis = "undefined";
133 $collectthis = json_sanitize($collectthis["new_encounter"]["rules"]);
136 let collectvalidation
= <?php
echo $collectthis; ?
>;
138 window
.saveClicked
= function (event
) {
139 const submit
= submitme(1, event
, 'new-encounter-form', collectvalidation
);
141 top
.restoreSession();
142 $
('#new-encounter-form').submit();
146 $
(".enc_issue").on('click', function (e
) {
149 dlgopen('', '', 700, 650, '', '', {
154 url
: $
(this
).attr('href')
158 $
('.datepicker').datetimepicker({
159 <?php
$datetimepicker_timepicker = false; ?
>
160 <?php
$datetimepicker_showseconds = false; ?
>
161 <?php
$datetimepicker_formatInput = true; ?
>
162 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
163 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
167 const isPosEnabled
= "" +
<?php
echo js_escape($GLOBALS['set_pos_code_encounter']); ?
>;
173 let facility
= document
.forms
[0].facility_id
.value
;
175 url
: "./../../../library/ajax/facility_ajax_code.php",
179 facility_id
: facility
,
180 csrf_token_form
: <?php
echo js_escape(CsrfUtils
::collectCsrfToken()); ?
>
182 }).done(function (fid
) {
183 document
.forms
[0].pos_code
.value
= JSON
.parse(fid
);
184 }).fail(function (xhr
) {
185 console
.log('error', xhr
);
189 function newUserSelected() {
190 let provider
= document
.getElementById('provider_id').value
;
192 url
: "./../../../library/ajax/facility_ajax_code.php",
195 mode
: "get_user_data",
196 provider_id
: provider
,
197 csrf_token_form
: <?php
echo js_escape(CsrfUtils
::collectCsrfToken()); ?
>
199 }).done(function (data
) {
200 let rtn
= JSON
.parse(data
);
201 document
.forms
[0].facility_id
.value
= rtn
[0];
203 document
.forms
[0].pos_code
.value
= rtn
[1];
205 if (Number(rtn
[2]) === 1) {
206 document
.forms
[0]['billing_facility'].value
= rtn
[0];
208 }).fail(function (xhr
) {
209 console
.log('error', xhr
);
213 // Handler for Cancel clicked when creating a new encounter.
214 // Show demographics or encounters list depending on what frame we're in.
215 function cancelClickedNew() {
216 window
.parent
.left_nav
.loadFrame('ens1', window
.name
, 'patient_file/history/encounters.php');
220 // Handler for cancel clicked when not creating a new encounter.
221 // Just reload the view mode.
222 function cancelClickedOld() {
223 location
.href
= '<?php echo "$rootdir/patient_file/encounter/forms.php"; ?>';
229 @media only screen
and (max
-width
: 1024px
) {
230 #visit-details [class*="col-"],
231 #visit-issues [class*="col-"] {
233 text
-align
: <?php
echo ($_SESSION['language_direction'] == 'rtl') ?
'right ' : 'left '?
> !important
;
239 $body_javascript = '';
240 $heading_caption = xl('Patient Encounter Form');
242 $body_javascript = 'onload="javascript:document.new_encounter.reason.focus();"';
243 $heading_caption = xl('New Encounter Form');
247 if ($GLOBALS['enable_help'] == 1) {
248 $help_icon = '<a class="float-right oe-help-redirect" data-target="#myModal" data-toggle="modal" href="#" id="help-href" name="help-href" style="color:#676666" title="' . xla("Click to view Help") . '"><i class="fa fa-question-circle" aria-hidden="true"></i></a>';
249 } elseif ($GLOBALS['enable_help'] == 2) {
250 $help_icon = '<a class="float-right oe-help-redirect" data-target="#myModal" data-toggle="modal" href="#" id="help-href" name="help-href" style="color:#DCD6D0 !Important" title="' . xla("To enable help - Go to Administration > Globals > Features > Enable Help Modal") . '"><i class="fa fa-question-circle" aria-hidden="true"></i></a>';
251 } elseif ($GLOBALS['enable_help'] == 0) {
256 $arrOeUiSettings = array(
257 'heading_title' => $heading_caption,
258 'include_patient_name' => true,// use only in appropriate pages
259 'expandable' => false,
260 'expandable_files' => array(""),//all file names need suffix _xpd
261 'action' => "",//conceal, reveal, search, reset, link or back
262 'action_title' => "",
263 'action_href' => "",//only for actions - reset, link or back
264 'show_help_icon' => true,
265 'help_file_name' => "common_help.php"
267 $oemr_ui = new OemrUI($arrOeUiSettings);
269 $provider_id = $userauthorized ?
$_SESSION['authUserID'] : 0;
271 $now = date('Y-m-d');
272 $encnow = date('Y-m-d 00:00:00');
273 $time = date("H:i:00");
274 $q = "SELECT pc_aid, pc_facility, pc_billing_location, pc_catid, pc_startTime" .
275 " FROM openemr_postcalendar_events WHERE pc_pid=? AND pc_eventDate=?" .
276 " ORDER BY pc_startTime ASC";
277 $q_events = sqlStatement($q, array($pid, $now));
278 while ($override = sqlFetchArray($q_events)) {
279 $q = "SELECT fe.encounter as encounter FROM form_encounter AS fe " .
280 "JOIN forms AS f ON f.form_id = fe.id AND f.encounter = fe.encounter " .
281 "WHERE fe.pid=? AND fe.date=? AND fe.provider_id=? AND f.deleted=0";
282 $q_enc = sqlQuery($q, array($pid, $encnow, $override['pc_aid']));
283 if (!empty($override) && is_array($override) && empty($q_enc['encounter'])) {
284 $provider_id = $override['pc_aid'];
285 $default_bill_fac_override = $override['pc_billing_location'];
286 $default_fac_override = $override['pc_facility'];
287 $default_catid_override = $override['pc_catid'];
293 <body
<?php
echo $body_javascript; ?
>>
294 <div id
="container_div" class="<?php echo attr($oemr_ui->oeContainer()); ?> mt-3">
296 <div
class="col-sm-12">
297 <!-- Required
for the popup date selectors
-->
298 <div id
="overDiv" style
="position: absolute; visibility: hidden; z-index: 1000;"></div
>
299 <?php
echo $oemr_ui->pageHeading() . "\r\n"; ?
>
302 <form
class="mt-3" id
="new-encounter-form" method
='post' action
="<?php echo $rootdir ?>/forms/newpatient/save.php" name
='new_encounter'>
303 <?php
if ($viewmode && $mode !== "followup") { ?
>
304 <input type
='hidden' name
='mode' value
='update' />
305 <input type
='hidden' name
='id' value
='<?php echo (isset($_GET["id"])) ? attr($_GET["id"]) : '' ?>' />
307 <input type
='hidden' name
='mode' value
='new' />
309 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
311 <?php
if ($mode === "followup") { ?
>
312 <input type
='hidden' name
='parent_enc_id' value
='<?php echo attr($encounterId); ?>' />
316 <legend
><?php
echo xlt('Visit Details') ?
>
318 <?php
echo (!empty($encounter_followup)) ?
(xlt("Follow up for") . ": " . text($encounter_followup) . " " . xlt("Dated") . ": " . text($followup_date)) : ''; ?
>
321 <div id
="visit-details" class="px-5">
322 <div
class="form-row align-items-center">
323 <div
class="col-sm-2">
324 <label
for="pc_catid" class="text-right"><?php
echo xlt('Visit Category:'); ?
></label
>
327 <select name
='pc_catid' id
='pc_catid' class='form-control' <?php
echo ($mode === "followup") ?
'disabled' : ''; ?
>>
328 <option value
='_blank'>-- <?php
echo xlt('Select One'); ?
> --</option
>
330 //Bring only patient and group categories
331 $visitSQL = "SELECT pc_catid, pc_catname, pc_cattype
332 FROM openemr_postcalendar_categories
333 WHERE pc_active = 1 and pc_cattype IN (0,3) and pc_constant_id != 'no_show' ORDER BY pc_seq";
335 $visitResult = sqlStatement($visitSQL);
336 $therapyGroupCategories = [];
338 while ($row = sqlFetchArray($visitResult)) {
339 $catId = $row['pc_catid'];
340 $name = $row['pc_catname'];
342 if ($row['pc_cattype'] == 3) {
343 $therapyGroupCategories[] = $catId;
346 if ($catId === "_blank") {
350 if ($row['pc_cattype'] == 3 && !$GLOBALS['enable_group_therapy']) {
354 // Fetch acl for category of given encounter. Only if has write auth for a category, then can create an encounter of that category.
355 $postCalendarCategoryACO = AclMain
::fetchPostCalendarCategoryACO($catId);
356 if ($postCalendarCategoryACO) {
357 $postCalendarCategoryACO = explode('|', $postCalendarCategoryACO);
358 $authPostCalendarCategoryWrite = AclMain
::aclCheckCore($postCalendarCategoryACO[0], $postCalendarCategoryACO[1], '', 'write');
359 } else { // if no aco is set for category
360 $authPostCalendarCategoryWrite = true;
363 //if no permission for category write, don't show in drop-down
364 if (!$authPostCalendarCategoryWrite) {
368 $optionStr = '<option value="%pc_catid%" %selected%>%pc_catname%</option>';
369 $optionStr = str_replace("%pc_catid%", attr($catId), $optionStr);
370 $optionStr = str_replace("%pc_catname%", text(xl_appt_category($name)), $optionStr);
372 $selected = ($result['pc_catid'] == $catId) ?
" selected" : "";
374 $selected = ($GLOBALS['default_visit_category'] == $catId) ?
" selected" : "";
377 $optionStr = str_replace("%selected%", $selected, $optionStr);
382 <?php
if ($mode === "followup") { ?
>
383 <input name
="pc_catid" value
="<?php echo attr($result['pc_catid']); ?>" hidden
/>
387 $sensitivities = AclExtended
::aclGetSensitivities();
388 if ($sensitivities && count($sensitivities)) {
389 usort($sensitivities, "sensitivity_compare");
391 <div
class="col-sm-2">
392 <label
for="pc_catid" class="text-right"><?php
echo xlt('Sensitivity:'); ?
> <i id
='sensitivity-tooltip' class="fa fa-info-circle text-primary" aria
-hidden
="true"></i
></label
>
395 <select name
='form_sensitivity' id
='form_sensitivity' class='form-control'>
397 foreach ($sensitivities as $value) {
398 // Omit sensitivities to which this user does not have access.
399 if (AclMain
::aclCheckCore('sensitivities', $value[1])) {
400 echo " <option value='" . attr($value[1]) . "'";
401 if ($viewmode && $result['sensitivity'] == $value[1]) {
405 echo ">" . xlt($value[3]) . "</option>\n";
408 echo " <option value=''";
409 if ($viewmode && !$result['sensitivity']) {
412 echo ">" . xlt('None{{Sensitivity}}') . "</option>\n";
418 <div
class="form-row align-items-center mt-2">
419 <div
class="col-sm-2">
420 <label
for='form_date' class="text-right"><?php
echo xlt('Date of Service:'); ?
></label
>
423 <input type
='text' class='form-control datepicker' name
='form_date' id
='form_date' <?php
echo ($disabled ??
'') ?
> value
='<?php echo $viewmode ? attr(oeFormatShortDate(substr($result['date
'], 0, 10))) : attr(oeFormatShortDate(date('Y
-m
-d
'))); ?>' title
='<?php echo xla('Date of service
'); ?>' />
425 <div
class="col-sm-2" <?php
echo empty($GLOBALS['gbl_visit_onset_date']) ?
"style='visibility:hidden;'" : ""; ?
>>
426 <label
for='form_onset_date' class="text-right"><?php
echo xlt('Onset/hosp. date:'); ?
>  
;<i id
='onset-tooltip' class="fa fa-info-circle text-primary" aria
-hidden
="true"></i
></label
>
428 <div
class="col-sm" <?php
echo empty($GLOBALS['gbl_visit_onset_date']) ?
"style='visibility:hidden;'" : ""; ?
>>
429 <input type
='text' class='form-control datepicker' name
='form_onset_date' id
='form_onset_date' value
='<?php echo $viewmode && $result['onset_date
'] !== '0000-00-00 00:00:00' ? attr(oeFormatShortDate(substr($result['onset_date
'], 0, 10))) : ''; ?>' title
='<?php echo xla('Date of onset
or hospitalization
'); ?>' />
432 <div
class="form-row align-items-center mt-2"
434 if (!$GLOBALS['gbl_visit_referral_source']) {
435 echo "style='display:none' ";
437 <div
class="col-sm-2">
438 <label
for="form_referral_source" class="text-right"><?php
echo xlt('Referral Source'); ?
>:</label
>
441 <?php
echo generate_select_list('form_referral_source', 'refsource', $viewmode ?
$result['referral_source'] : '', ''); ?
>
444 <?php
if ($GLOBALS['enable_group_therapy']) { ?
>
445 <div
class="form-group mx-auto mt-2" id
="therapy_group_name" style
="display: none">
446 <div
class="col-sm-2">
447 <label
for="form_group" class="text-right"><?php
echo xlt('Group name'); ?
>:</label
>
450 <input type
='text' name
='form_group' class='form-control' id
="form_group" placeholder
='<?php echo xla('Click to select
'); ?>' value
='<?php echo $viewmode && in_array($result['pc_catid
'], $therapyGroupCategories) ? attr(getGroup($result['external_id
'])['group_name
']) : ''; ?>' onclick
='sel_group()' title
='<?php echo xla('Click to select group
'); ?>' readonly
/>
451 <input type
='hidden' name
='form_gid' value
='<?php echo $viewmode && in_array($result['pc_catid
'], $therapyGroupCategories) ? attr($result['external_id
']) : '' ?>' />
455 <div
class="form-row align-items-center mt-2">
456 <div
class="col-sm-2">
457 <label
for='provider_id' class="text-right"><?php
echo xlt('Encounter Provider'); ?
>:</label
>
460 <select name
='provider_id' id
='provider_id' class='form-control' onChange
="newUserSelected()">
463 $provider_id = $result['provider_id'];
465 $userService = new UserService();
466 $users = $userService->getActiveUsers();
467 foreach ($users as $activeUser) {
468 $p_id = (int)$activeUser['id'];
469 // Check for the case where an encounter is created by non-auth user
470 // but has permissions to create/edit encounter.
472 if ($activeUser['authorized'] != 1) {
473 if ($p_id === (int)($result['provider_id'] ??
null)) {
474 $flag_it = " (" . xlt("Non Provider") . ")";
479 echo "<option value='" . attr($p_id) . "'";
480 if ((int)$provider_id === $p_id) {
483 echo ">" . text($activeUser['lname']) . ' ' .
484 text($activeUser['fname']) . ' ' . text($activeUser['mname']) . $flag_it . "</option>\n";
489 <div
class="col-sm-2">
490 <label
for='class' class="text-right"><?php
echo xlt('Class'); ?
>:</label
>
493 <?php
echo generate_select_list('class_code', '_ActEncounterCode', $viewmode ?
$result['class_code'] : '', '', ''); ?
>
496 <div
class="form-row align-items-center mt-2">
497 <div
class="col-sm-2">
498 <label
for='facility_id' class="text-right"><?php
echo xlt('Facility'); ?
>:</label
>
501 <select name
='facility_id' id
='facility_id' class='form-control' onChange
="getPOS()" <?php
echo ($mode === "followup") ?
'disabled' : ''; ?
> >
504 $def_facility = $result['facility_id'];
505 } elseif (!empty($default_fac_override)) {
506 $def_facility = $default_fac_override;
508 $def_facility = ($facilityService->getFacilityForUser($_SESSION['authUserID'])['id'] ??
null);
511 $facilities = $facilityService->getAllServiceLocations();
512 foreach ($facilities as $iter) {
514 if ($def_facility === $iter['id']) {
515 $selected_fac = " selected";
517 $posCode = $iter['pos_code'];
520 <option value
="<?php echo attr($iter['id']); ?>"<?php
echo $selected_fac; ?
>><?php
echo text($iter['name']); ?
></option
>
524 <?php
if ($mode === "followup") { ?
>
525 <input type
="hidden" name
="facility_id" value
="<?php echo attr($result['facility_id']); ?>" />
527 <div
class="col-sm-2">
528 <label
for='billing_facility' class="text-right"><?php
echo xlt('Billing Facility'); ?
>:</label
>
530 <div id
="ajaxdiv" class="col-sm">
532 if (!empty($default_bill_fac_override)) {
533 $default_bill_fac = $default_bill_fac_override;
534 } elseif (!$viewmode && $mode !== "followup") {
535 $tmp_be = $facilityService->getPrimaryBusinessEntity();
536 $tmp_bl = $facilityService->getPrimaryBillingLocation();
537 $tmp = !empty($tmp_be['id']) ?
$tmp_be['id'] : (!empty($tmp_bl['id']) ?
$tmp_bl['id'] : null);
538 $default_bill_fac = !empty($tmp) ?
$tmp : $def_facility;
540 $default_bill_fac = isset($result['billing_facility']) ?
$result['billing_facility'] : $def_facility;
542 billing_facility('billing_facility', $default_bill_fac);
546 <!-- Discharge Disposition
-->
547 <div
class="form-row align-items-center mt-2">
548 <div
class="col-sm-2">
549 <label
for='facility_id' class="text-right"><?php
echo xlt('Discharge Disposition'); ?
>:</label
>
552 <select name
='discharge_disposition' id
='discharge_disposition' class='form-control'>
553 <option value
='_blank'>-- <?php
echo xlt('Select One'); ?
> --</option
>
555 $dischargeListDisposition = new ListService();
556 $dischargeDisposiitons = $dischargeListDisposition->getOptionsByListName('discharge-disposition') ??
[];
557 foreach ($dischargeDisposiitons as $dispositon) {
558 $selected = $result['discharge_disposition'] == $dispositon['option_id'] ?
"selected='selected'" : "";
560 <option value
="<?php echo attr($dispositon['option_id']); ?>" <?php
echo $selected; ?
> ><?php
echo text($dispositon['title']); ?
></option
>
564 <div
class="col-sm-2"></div
>
565 <div
class="col-sm"></div
>
567 <?php
if ($GLOBALS['set_pos_code_encounter']) { ?
>
568 <div
class="form-row mt-2">
569 <div
class="col-sm-2">
570 <label
for='pos_code' class="text-right"><?php
echo xlt('POS Code'); ?
>:</label
>
572 <div
class="col-sm-8">
573 <select name
="pos_code" id
="pos_code" class='form-control'>
576 foreach ($pc->get_pos_ref() as $pos) {
577 echo "<option value=\"" . attr($pos["code"]) . "\"";
578 if (($pos["code"] == $result['pos_code'] && $viewmode) ||
($pos["code"] == $posCode && !$viewmode)) {
581 echo ">" . text($pos['code']) . ": " . xlt($pos['title']);
592 <legend
><?php
echo xlt('Reason for Visit') ?
></legend
>
593 <div
class="form-row mx-5">
594 <textarea name
="reason" id
="reason" class="form-control" cols
="80" rows
="4"><?php
echo $viewmode ?
text($result['reason']) : text($GLOBALS['default_chief_complaint']); ?
></textarea
>
598 // To see issues stuff user needs write access to all issue types.
600 foreach ($ISSUE_TYPES as $type => $dummy) {
601 if (!AclMain
::aclCheckIssue($type, '', 'write')) {
609 <legend
><?php
echo xlt('Link/Add Issues (Injuries/Medical/Allergy) to Current Visit') ?
></legend
>
610 <div id
="visit-issues">
611 <div
class="form-row px-5">
613 <div
class="btn-group" role
="group">
614 <?php
if (AclMain
::aclCheckCore('patients', 'med', '', 'write')) { ?
>
615 <a href
="../../patient_file/summary/add_edit_issue.php" class="btn btn-primary btn-add btn-sm enc_issue" onclick
="top.restoreSession()"><?php
echo xlt('Add Issue'); ?
></a
>
619 <select multiple name
='issues[]' class='form-control' title
='<?php echo xla('Hold down
[Ctrl
] for multiple selections
or to unselect
'); ?>' size
='6'>
621 while ($irow = sqlFetchArray($ires)) {
622 $list_id = $irow['id'];
623 $tcode = $irow['type'];
624 if ($ISSUE_TYPES[$tcode]) {
625 $tcode = $ISSUE_TYPES[$tcode][2];
627 echo " <option value='" . attr($list_id) . "'";
629 $perow = sqlQuery("SELECT count(*) AS count FROM issue_encounter WHERE " .
630 "pid = ? AND encounter = ? AND list_id = ?", array($pid, $encounter, $list_id));
631 if ($perow['count']) {
635 // For new encounters the invoker may pass an issue ID.
636 if (!empty($_REQUEST['issue']) && $_REQUEST['issue'] == $list_id) {
640 echo ">" . text($tcode) . ": " . text($irow['begdate']) . " " .
641 text(substr($irow['title'], 0, 40)) . "</option>\n";
645 <p
><i
><?php
echo xlt('To link this encounter/consult to an existing issue, click the '
646 . 'desired issue above to highlight it and then click [Save]. '
647 . 'Hold down [Ctrl] button to select multiple issues.'); ?
></i
></p
>
654 <?php
//can change position of buttons by creating a class 'position-override' and adding rule text-align:center or right as the case may be in individual stylesheets ?>
655 <div
class="form-row">
656 <div
class="col-sm-12 text-left position-override">
657 <div
class="btn-group" role
="group">
658 <button type
="button" class="btn btn-primary btn-save" onclick
="top.restoreSession(); saveClicked(undefined);"><?php
echo xlt('Save'); ?
></button
>
659 <?php
if ($viewmode ||
empty($_GET["autoloaded"])) { // not creating new encounter ?>
660 <button type
="button" class="btn btn-secondary btn-cancel" onClick
="return cancelClickedOld()"><?php
echo xlt('Cancel'); ?
></button
>
661 <?php
} else { // not $viewmode ?>
662 <button
class="btn btn-secondary btn-cancel link_submit" onClick
="return cancelClickedNew()"><?php
echo xlt('Cancel'); ?
></button
>
663 <?php
} // end not $viewmode ?>
668 </div
><!--End of container div
-->
669 <?php
$oemr_ui->oeBelowContainerDiv(); ?
>
673 function duplicateVisit(enc
, datestr
) {
674 if (!confirm(<?php
echo xlj("A visit already exists for this patient today. Click Cancel to open it, or OK to proceed with creating a new one.") ?
>)) {
675 // User pressed the cancel button, so re-direct to today's encounter
676 top
.restoreSession();
677 parent
.left_nav
.setEncounter(datestr
, enc
, window
.name
);
678 parent
.left_nav
.loadFrame('enc2', window
.name
, 'patient_file/encounter/encounter_top.php?set_encounter=' +
encodeURIComponent(enc
));
681 // otherwise just continue normally
684 // Search for an encounter from today
685 $erow = sqlQuery("SELECT fe.encounter, fe.date " .
686 "FROM form_encounter AS fe, forms AS f WHERE " .
688 " AND fe.date >= ? " .
689 " AND fe.date <= ? " .
691 "f.formdir = 'newpatient' AND f.form_id = fe.id AND f.deleted = 0 " .
692 "ORDER BY fe.encounter DESC LIMIT 1", array($pid, date('Y-m-d 00:00:00'), date('Y-m-d 23:59:59')));
694 if (!empty($erow['encounter'])) {
695 // If there is an encounter from today then present the duplicate visit dialog
696 echo "duplicateVisit(" . js_escape($erow['encounter']) . ", " .
697 js_escape(oeFormatShortDate(substr($erow['date'], 0, 10))) . ");\n";
702 if ($GLOBALS['enable_group_therapy']) { ?
>
703 /* hide / show group name input */
704 let groupCategories
= <?php
echo json_encode($therapyGroupCategories); ?
>;
705 $
('#pc_catid').on('change', function () {
706 if (groupCategories
.indexOf($
(this
).val()) > -1) {
707 $
('#therapy_group_name').show();
709 $
('#therapy_group_name').hide();
713 function sel_group() {
714 top
.restoreSession();
715 const url
= '<?php echo $GLOBALS['webroot
']?>/interface/main/calendar/find_group_popup.php';
716 dlgopen(url
, '_blank', 500, 400, '', '', {
718 {text
: <?php
echo xlj('Close'); ?
>, close
: true, style
: 'default btn-sm'}
723 // This is for callback by the find-group popup.
724 function setgroup(gid
, name
) {
725 var f
= document
.forms
[0];
726 f
.form_group
.value
= name
;
727 f
.form_gid
.value
= gid
;
731 if ($viewmode && in_array($result['pc_catid'], $therapyGroupCategories)) {?
>
732 $
('#therapy_group_name').show();
739 $
('#sensitivity-tooltip').attr({"title": <?php
echo xlj('If set as high will restrict visibility of encounter to users belonging to certain groups (AROs). By default - Physicians and Administrators'); ?
>, "data-toggle": "tooltip", "data-placement": "bottom"}).tooltip();
740 $
('#onset-tooltip').attr({"title": <?php
echo xlj('Hospital date needed for successful billing of hospital encounters'); ?
>, "data-toggle": "tooltip", "data-placement": "bottom"}).tooltip();
745 <?php
if (!empty($GLOBALS['text_templates_enabled'])) { ?
>
746 <script src
="<?php echo $GLOBALS['web_root'] ?>/library/js/CustomTemplateLoader.js"></script
>