acknowledgments update
[openemr.git] / interface / forms / newpatient / common.php
blobb475bae41486b9264bbdb300baa128e33a3a39d2
1 <?php
2 /**
3 * Common script for the encounter form (new and view) scripts.
5 * LICENSE: This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
16 * @package OpenEMR
17 * @author Brady Miller <brady@sparmy.com>
18 * @link http://www.open-emr.org
21 require_once("$srcdir/options.inc.php");
23 $months = array("01","02","03","04","05","06","07","08","09","10","11","12");
24 $days = array("01","02","03","04","05","06","07","08","09","10","11","12","13","14",
25 "15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31");
26 $thisyear = date("Y");
27 $years = array($thisyear-1, $thisyear, $thisyear+1, $thisyear+2);
29 if ($viewmode) {
30 $id = (isset($_REQUEST['id'])) ? $_REQUEST['id'] : '';
31 $result = sqlQuery("SELECT * FROM form_encounter WHERE id = ?", array($id));
32 $encounter = $result['encounter'];
33 if ($result['sensitivity'] && !acl_check('sensitivities', $result['sensitivity'])) {
34 echo "<body>\n<html>\n";
35 echo "<p>" . xlt('You are not authorized to see this encounter.') . "</p>\n";
36 echo "</body>\n</html>\n";
37 exit();
41 // Sort comparison for sensitivities by their order attribute.
42 function sensitivity_compare($a, $b) {
43 return ($a[2] < $b[2]) ? -1 : 1;
46 // get issues
47 $ires = sqlStatement("SELECT id, type, title, begdate FROM lists WHERE " .
48 "pid = ? AND enddate IS NULL " .
49 "ORDER BY type, begdate", array($pid));
51 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
52 <html>
53 <head>
54 <?php html_header_show();?>
55 <title><?php echo xlt('Patient Encounter'); ?></title>
57 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
59 <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" />
60 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-1.4.3.min.js"></script>
61 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/common.js"></script>
62 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox-1.3.4/jquery.fancybox-1.3.4.pack.js"></script>
63 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script>
64 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/overlib_mini.js"></script>
65 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js"></script>
67 <!-- pop up calendar -->
68 <style type="text/css">@import url(<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.css);</style>
69 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.js"></script>
70 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
71 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar_setup.js"></script>
72 <?php include_once("{$GLOBALS['srcdir']}/ajax/facility_ajax_jav.inc.php"); ?>
73 <script language="JavaScript">
75 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
77 // Process click on issue title.
78 function newissue() {
79 dlgopen('../../patient_file/summary/add_edit_issue.php', '_blank', 800, 600);
80 return false;
83 // callback from add_edit_issue.php:
84 function refreshIssue(issue, title) {
85 var s = document.forms[0]['issues[]'];
86 s.options[s.options.length] = new Option(title, issue, true, true);
89 function saveClicked() {
90 var f = document.forms[0];
92 <?php if (!$GLOBALS['athletic_team']) { ?>
93 var category = document.forms[0].pc_catid.value;
94 if ( category == '_blank' ) {
95 alert("<?php echo xls('You must select a visit category'); ?>");
96 return;
98 <?php } ?>
100 <?php if (false /* $GLOBALS['ippf_specific'] */) { // ippf decided not to do this ?>
101 if (f['issues[]'].selectedIndex < 0) {
102 if (!confirm('There is no issue selected. If this visit relates to ' +
103 'contraception or abortion, click Cancel now and then select or ' +
104 'create the appropriate issue. Otherwise you can click OK.'))
106 return;
109 <?php } ?>
110 top.restoreSession();
111 f.submit();
114 $(document).ready(function(){
115 enable_big_modals();
117 function bill_loc(){
118 var pid=<?php echo attr($pid);?>;
119 var dte=document.getElementById('form_date').value;
120 var facility=document.forms[0].facility_id.value;
121 ajax_bill_loc(pid,dte,facility);
124 // Handler for Cancel clicked when creating a new encounter.
125 // Show demographics or encounters list depending on what frame we're in.
126 function cancelClicked() {
127 if (window.name == 'RBot') {
128 parent.left_nav.setRadio(window.name, 'ens');
129 parent.left_nav.loadFrame('ens1', window.name, 'patient_file/history/encounters.php');
131 else {
132 parent.left_nav.setRadio(window.name, 'dem');
133 parent.left_nav.loadFrame('dem1', window.name, 'patient_file/summary/demographics.php');
135 return false;
138 </script>
139 </head>
141 <?php if ($viewmode) { ?>
142 <body class="body_top">
143 <?php } else { ?>
144 <body class="body_top" onload="javascript:document.new_encounter.reason.focus();">
145 <?php } ?>
147 <!-- Required for the popup date selectors -->
148 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
150 <form method='post' action="<?php echo $rootdir ?>/forms/newpatient/save.php" name='new_encounter'
151 <?php if (!$GLOBALS['concurrent_layout']) echo "target='Main'"; ?>>
153 <div style = 'float:left'>
154 <?php if ($viewmode) { ?>
155 <input type=hidden name='mode' value='update'>
156 <input type=hidden name='id' value='<?php echo (isset($_GET["id"])) ? attr($_GET["id"]) : '' ?>'>
157 <span class=title><?php echo xlt('Patient Encounter Form'); ?></span>
158 <?php } else { ?>
159 <input type='hidden' name='mode' value='new'>
160 <span class='title'><?php echo xlt('New Encounter Form'); ?></span>
161 <?php } ?>
162 </div>
164 <div>
165 <div style = 'float:left; margin-left:8px;margin-top:-3px'>
166 <a href="javascript:saveClicked();" class="css_button link_submit"><span><?php echo xlt('Save'); ?></span></a>
167 <?php if ($viewmode || !isset($_GET["autoloaded"]) || $_GET["autoloaded"] != "1") { ?>
168 </div>
170 <div style = 'float:left; margin-top:-3px'>
171 <?php if ($GLOBALS['concurrent_layout']) { ?>
172 <a href="<?php echo "$rootdir/patient_file/encounter/encounter_top.php"; ?>"
173 class="css_button link_submit" onClick="top.restoreSession()"><span><?php echo xlt('Cancel'); ?></span></a>
174 <?php } else { ?>
175 <a href="<?php echo "$rootdir/patient_file/encounter/patient_encounter.php"; ?>"
176 class="css_button link_submit" target='Main' onClick="top.restoreSession()">
177 <span><?php echo xlt('Cancel'); ?>]</span></a>
178 <?php } // end not concurrent layout ?>
179 <?php } else if ($GLOBALS['concurrent_layout']) { // not $viewmode ?>
180 <a href="" class="css_button link_submit" onClick="return cancelClicked()">
181 <span><?php echo xlt('Cancel'); ?></span></a>
182 <?php } // end not $viewmode ?>
183 </div>
184 </div>
186 <br> <br>
188 <table width='96%'>
190 <tr>
191 <td width='33%' nowrap class='bold'><?php echo xlt('Consultation Brief Description'); ?>:</td>
192 <td width='34%' rowspan='2' align='center' valign='center' class='text'>
193 <table>
195 <tr<?php if ($GLOBALS['athletic_team']) echo " style='visibility:hidden;'"; ?>>
196 <td class='bold' nowrap><?php echo xlt('Visit Category:'); ?></td>
197 <td class='text'>
198 <select name='pc_catid' id='pc_catid'>
199 <option value='_blank'>-- <?php echo xlt('Select One'); ?> --</option>
200 <?php
201 $cres = sqlStatement("SELECT pc_catid, pc_catname " .
202 "FROM openemr_postcalendar_categories ORDER BY pc_catname");
203 while ($crow = sqlFetchArray($cres)) {
204 $catid = $crow['pc_catid'];
205 if ($catid < 9 && $catid != 5) continue;
206 echo " <option value='" . attr($catid) . "'";
207 if ($viewmode && $crow['pc_catid'] == $result['pc_catid']) echo " selected";
208 echo ">" . text(xl_appt_category($crow['pc_catname'])) . "</option>\n";
211 </select>
212 </td>
213 </tr>
215 <tr>
216 <td class='bold' nowrap><?php echo xlt('Facility:'); ?></td>
217 <td class='text'>
218 <select name='facility_id' onChange="bill_loc()">
219 <?php
221 if ($viewmode) {
222 $def_facility = $result['facility_id'];
223 } else {
224 $dres = sqlStatement("select facility_id from users where username = ?", array($_SESSION['authUser']));
225 $drow = sqlFetchArray($dres);
226 $def_facility = $drow['facility_id'];
228 $fres = sqlStatement("select * from facility where service_location != 0 order by name");
229 if ($fres) {
230 $fresult = array();
231 for ($iter = 0; $frow = sqlFetchArray($fres); $iter++)
232 $fresult[$iter] = $frow;
233 foreach($fresult as $iter) {
235 <option value="<?php echo attr($iter['id']); ?>" <?php if ($def_facility == $iter['id']) echo "selected";?>><?php echo text($iter['name']); ?></option>
236 <?php
240 </select>
241 </td>
242 </tr>
243 <tr>
244 <td class='bold' nowrap><?php echo xlt('Billing Facility'); ?>:</td>
245 <td class='text'>
246 <div id="ajaxdiv">
247 <?php
248 billing_facility('billing_facility',$result['billing_facility']);
250 </div>
251 </td>
252 </tr>
253 <tr>
254 <?php
255 $sensitivities = acl_get_sensitivities();
256 if ($sensitivities && count($sensitivities)) {
257 usort($sensitivities, "sensitivity_compare");
259 <td class='bold' nowrap><?php echo xlt('Sensitivity:'); ?></td>
260 <td class='text'>
261 <select name='form_sensitivity'>
262 <?php
263 foreach ($sensitivities as $value) {
264 // Omit sensitivities to which this user does not have access.
265 if (acl_check('sensitivities', $value[1])) {
266 echo " <option value='" . attr($value[1]) . "'";
267 if ($viewmode && $result['sensitivity'] == $value[1]) echo " selected";
268 echo ">" . xlt($value[3]) . "</option>\n";
271 echo " <option value=''";
272 if ($viewmode && !$result['sensitivity']) echo " selected";
273 echo ">" . xlt('None'). "</option>\n";
275 </select>
276 </td>
277 <?php
278 } else {
280 <td colspan='2'><!-- sensitivities not used --></td>
281 <?php
284 </tr>
286 <tr<?php if (!$GLOBALS['gbl_visit_referral_source']) echo " style='visibility:hidden;'"; ?>>
287 <td class='bold' nowrap><?php echo xlt('Referral Source'); ?>:</td>
288 <td class='text'>
289 <?php
290 echo generate_select_list('form_referral_source', 'refsource', $viewmode ? $result['referral_source'] : '', '');
292 </td>
293 </tr>
295 <tr>
296 <td class='bold' nowrap><?php echo xlt('Date of Service:'); ?></td>
297 <td class='text' nowrap>
298 <input type='text' size='10' name='form_date' id='form_date' <?php echo $disabled ?>
299 value='<?php echo $viewmode ? substr($result['date'], 0, 10) : date('Y-m-d'); ?>'
300 title='<?php echo xla('yyyy-mm-dd Date of service'); ?>'
301 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />
302 <img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22'
303 id='img_form_date' border='0' alt='[?]' style='cursor:pointer;cursor:hand'
304 title='<?php echo xla('Click here to choose a date'); ?>'>
305 </td>
306 </tr>
308 <tr<?php if ($GLOBALS['ippf_specific'] || $GLOBALS['athletic_team']) echo " style='visibility:hidden;'"; ?>>
309 <td class='bold' nowrap><?php echo xlt('Onset/hosp. date:'); ?></td>
310 <td class='text' nowrap><!-- default is blank so that while generating claim the date is blank. -->
311 <input type='text' size='10' name='form_onset_date' id='form_onset_date'
312 value='<?php echo $viewmode && $result['onset_date']!='0000-00-00 00:00:00' ? substr($result['onset_date'], 0, 10) : ''; ?>'
313 title='<?php echo xla('yyyy-mm-dd Date of onset or hospitalization'); ?>'
314 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />
315 <img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22'
316 id='img_form_onset_date' border='0' alt='[?]' style='cursor:pointer;cursor:hand'
317 title='<?php echo xla('Click here to choose a date'); ?>'>
318 </td>
319 </tr>
321 <tr>
322 <td class='text' colspan='2' style='padding-top:1em'>
323 <?php if ($GLOBALS['athletic_team']) { ?>
324 <p><i>Click [Add Issue] to add a new issue if:<br />
325 New injury likely to miss &gt; 1 day<br />
326 New significant illness/medical<br />
327 New allergy - only if nil exist</i></p>
328 <?php } ?>
329 </td>
330 </tr>
332 </table>
334 </td>
336 <td class='bold' width='33%' nowrap>
337 <div style='float:left'>
338 <?php echo xlt('Issues (Injuries/Medical/Allergy)'); ?>
339 </div>
340 <div style='float:left;margin-left:8px;margin-top:-3px'>
341 <?php if ($GLOBALS['athletic_team']) { // they want the old-style popup window ?>
342 <a href="#" class="css_button_small link_submit"
343 onclick="return newissue()"><span><?php echo xlt('Add'); ?></span></a>
344 <?php } else { ?>
345 <a href="../../patient_file/summary/add_edit_issue.php" class="css_button_small link_submit iframe"
346 onclick="top.restoreSession()"><span><?php echo xlt('Add'); ?></span></a>
347 <?php } ?>
348 </div>
349 </td>
350 </tr>
352 <tr>
353 <td class='text' valign='top'>
354 <textarea name='reason' cols='40' rows='12' wrap='virtual' style='width:96%'
355 ><?php echo $viewmode ? text($result['reason']) : text($GLOBALS['default_chief_complaint']); ?></textarea>
356 </td>
357 <td class='text' valign='top'>
358 <select multiple name='issues[]' size='8' style='width:100%'
359 title='<?php echo xla('Hold down [Ctrl] for multiple selections or to unselect'); ?>'>
360 <?php
361 while ($irow = sqlFetchArray($ires)) {
362 $list_id = $irow['id'];
363 $tcode = $irow['type'];
364 if ($ISSUE_TYPES[$tcode]) $tcode = $ISSUE_TYPES[$tcode][2];
365 echo " <option value='" . attr($list_id) . "'";
366 if ($viewmode) {
367 $perow = sqlQuery("SELECT count(*) AS count FROM issue_encounter WHERE " .
368 "pid = ? AND encounter = ? AND list_id = ?", array($pid,$encounter,$list_id));
369 if ($perow['count']) echo " selected";
371 else {
372 // For new encounters the invoker may pass an issue ID.
373 if (!empty($_REQUEST['issue']) && $_REQUEST['issue'] == $list_id) echo " selected";
375 echo ">" . text($tcode) . ": " . text($irow['begdate']) . " " .
376 text(substr($irow['title'], 0, 40)) . "</option>\n";
379 </select>
381 <p><i><?php echo xlt('To link this encounter/consult to an existing issue, click the '
382 . 'desired issue above to highlight it and then click [Save]. '
383 . 'Hold down [Ctrl] button to select multiple issues.'); ?></i></p>
385 </td>
386 </tr>
388 </table>
390 </form>
392 </body>
394 <script language="javascript">
395 /* required for popup calendar */
396 Calendar.setup({inputField:"form_date", ifFormat:"%Y-%m-%d", button:"img_form_date"});
397 Calendar.setup({inputField:"form_onset_date", ifFormat:"%Y-%m-%d", button:"img_form_onset_date"});
398 <?php
399 if (!$viewmode) {
400 $erow = sqlQuery("SELECT count(*) AS count " .
401 "FROM form_encounter AS fe, forms AS f WHERE " .
402 "fe.pid = ? AND fe.date = ? AND " .
403 "f.formdir = 'newpatient' AND f.form_id = fe.id AND f.deleted = 0", array($pid,date('Y-m-d 00:00:00')));
404 if ($erow['count'] > 0) {
405 echo "alert('" . xls('Warning: A visit was already created for this patient today!') . "');\n";
409 </script>
411 </html>