PageRenderTime 54ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/interface/forms/newpatient/common.php

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