Fixed quote escaping problem in view.php.
[openemr.git] / interface / forms / newpatient / common.php
blobe6be4b7ff482889aafcc0b8e6e741bb24ed40602
1 <?php
2 $months = array("01","02","03","04","05","06","07","08","09","10","11","12");
3 $days = array("01","02","03","04","05","06","07","08","09","10","11","12","13","14",
4 "15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31");
5 $thisyear = date("Y");
6 $years = array($thisyear-1, $thisyear, $thisyear+1, $thisyear+2);
8 if ($viewmode) {
9 $id = $_REQUEST['id'];
10 $result = sqlQuery("SELECT * FROM form_encounter WHERE id = '$id'");
11 $encounter = $result['encounter'];
12 if ($result['sensitivity'] && !acl_check('sensitivities', $result['sensitivity'])) {
13 echo "<body>\n<html>\n";
14 echo "<p>You are not authorized to see this encounter.</p>\n";
15 echo "</body>\n</html>\n";
16 exit();
20 // Sort comparison for sensitivities by their order attribute.
21 function sensitivity_compare($a, $b) {
22 return ($a[2] < $b[2]) ? -1 : 1;
25 // get issues
26 $ires = sqlStatement("SELECT id, type, title, begdate FROM lists WHERE " .
27 "pid = $pid AND enddate IS NULL " .
28 "ORDER BY type, begdate");
30 <html>
31 <head>
32 <?php html_header_show();?>
33 <title><?php xl('Patient Encounter','e'); ?></title>
35 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
37 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script>
38 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/overlib_mini.js"></script>
39 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js"></script>
41 <!-- pop up calendar -->
42 <style type="text/css">@import url(<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.css);</style>
43 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.js"></script>
44 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar_en.js"></script>
45 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar_setup.js"></script>
47 <script language="JavaScript">
49 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
51 // Process click on issue title.
52 function newissue() {
53 dlgopen('../../patient_file/summary/add_edit_issue.php', '_blank', 600, 475);
54 return false;
57 // callback from add_edit_issue.php:
58 function refreshIssue(issue, title) {
59 var s = document.forms[0]['issues[]'];
60 s.options[s.options.length] = new Option(title, issue, true, true);
63 function saveClicked() {
64 var f = document.forms[0];
65 <?php if ($GLOBALS['ippf_specific']) { ?>
66 if (f['issues[]'].selectedIndex < 0) {
67 if (!confirm('There is no issue selected. If this visit relates to ' +
68 'contraception or abortion, click Cancel now and then select or ' +
69 'create the appropriate issue. Otherwise you can click OK.'))
71 return;
74 <?php } ?>
75 top.restoreSession();
76 f.submit();
79 </script>
80 </head>
82 <?php if ($viewmode) { ?>
83 <body class="body_top">
84 <?php } else { ?>
85 <body class="body_top" onload="javascript:document.new_encounter.reason.focus();">
86 <?php } ?>
88 <!-- Required for the popup date selectors -->
89 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
91 <form method='post' action="<?php echo $rootdir ?>/forms/newpatient/save.php" name='new_encounter'
92 <?php if (!$GLOBALS['concurrent_layout']) echo "target='Main'"; ?>>
94 <?php if ($viewmode) { ?>
95 <input type=hidden name='mode' value='update'>
96 <input type=hidden name='id' value='<?php echo $_GET["id"] ?>'>
97 <span class=title><?php xl('Patient Encounter Form','e'); ?></span>
98 <?php } else { ?>
99 <input type='hidden' name='mode' value='new'>
100 <span class='title'><?php xl('New Encounter Form','e'); ?></span>
101 <?php } ?>
103 <br>
104 <center>
106 <table width='96%'>
108 <tr>
109 <td width='33%' nowrap class='bold'><?php xl('Consultation Brief Description','e'); ?>:</td>
110 <td width='34%' rowspan='2' align='center' valign='top' class='text'>
111 <table>
113 <tr>
114 <td class='bold' nowrap><?php xl('Visit Category:','e'); ?></td>
115 <td class='text'>
116 <select name='pc_catid'>
117 <?php
118 $cres = sqlStatement("SELECT pc_catid, pc_catname " .
119 "FROM openemr_postcalendar_categories ORDER BY pc_catname");
120 while ($crow = sqlFetchArray($cres)) {
121 $catid = $crow['pc_catid'];
122 if ($catid < 9 && $catid != 5) continue;
123 echo " <option value='$catid'";
124 if ($viewmode && $crow['pc_catid'] == $result['pc_catid']) echo " selected";
125 echo ">" . $crow['pc_catname'] . "</option>\n";
128 </select>
129 </td>
130 </tr>
132 <tr>
133 <td class='bold' nowrap><?php xl('Facility:','e'); ?></td>
134 <td class='text'>
135 <select name='facility_id'>
136 <?php
138 if ($viewmode) {
139 $def_facility = $result['facility_id'];
140 } else {
141 $dres = sqlStatement("select facility_id from users where username = '" . $_SESSION['authUser'] . "'");
142 $drow = sqlFetchArray($dres);
143 $def_facility = $drow['facility_id'];
145 $fres = sqlStatement("select * from facility where service_location != 0 order by name");
146 if ($fres) {
147 $fresult = array();
148 for ($iter = 0; $frow = sqlFetchArray($fres); $iter++)
149 $fresult[$iter] = $frow;
150 foreach($fresult as $iter) {
152 <option value="<?php echo $iter['id']; ?>" <?php if ($def_facility == $iter['id']) echo "selected";?>><?php echo $iter['name']; ?></option>
153 <?php
157 </select>
158 </td>
159 </tr>
161 <tr>
162 <?php
163 $sensitivities = acl_get_sensitivities();
164 if ($sensitivities && count($sensitivities)) {
165 usort($sensitivities, "sensitivity_compare");
167 <td class='bold' nowrap><?php xl('Sensitivity:','e'); ?></td>
168 <td class='text'>
169 <select name='form_sensitivity'>
170 <?php
171 foreach ($sensitivities as $value) {
172 // Omit sensitivities to which this user does not have access.
173 if (acl_check('sensitivities', $value[1])) {
174 echo " <option value='" . $value[1] . "'";
175 if ($viewmode && $result['sensitivity'] == $value[1]) echo " selected";
176 echo ">" . $value[3] . "</option>\n";
179 echo " <option value=''";
180 if ($viewmode && !$result['sensitivity']) echo " selected";
181 echo ">" . xl('None'). "</option>\n";
183 </select>
184 </td>
185 <?php
186 } else {
188 <td colspan='2'><!-- sensitivities not used --></td>
189 <?php
192 </tr>
194 <tr>
195 <td class='bold' nowrap><?php xl('Date of Service:','e'); ?></td>
196 <td class='text' nowrap>
197 <input type='text' size='10' name='form_date' id='form_date' <?php echo $disabled ?>
198 value='<?php echo $viewmode ? substr($result['date'], 0, 10) : date('Y-m-d'); ?>'
199 title='<?php xl('yyyy-mm-dd Date of service','e'); ?>'
200 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />
201 <img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22'
202 id='img_form_date' border='0' alt='[?]' style='cursor:pointer;cursor:hand'
203 title='<?php xl('Click here to choose a date','e'); ?>'>
204 </td>
205 </tr>
207 <tr>
208 <td class='bold' nowrap><?php xl('Onset/hosp. date:','e'); ?></td>
209 <td class='text' nowrap>
210 <input type='text' size='10' name='form_onset_date' id='form_onset_date'
211 value='<?php echo $viewmode ? substr($result['onset_date'], 0, 10) : date('Y-m-d'); ?>'
212 title='<?php xl('yyyy-mm-dd Date of onset or hospitalization','e'); ?>'
213 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />
215 <img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22'
216 id='img_form_onset_date' border='0' alt='[?]' style='cursor:pointer;cursor:hand'
217 title='<?php xl('Click here to choose a date','e'); ?>'>
219 </td>
220 </tr>
222 <tr>
223 <td class='text' colspan='2' style='padding-top:1em'>
225 <?php if ($GLOBALS['athletic_team']) { ?>
226 <p><i>Click [Add Issue] to add a new issue if:<br />
227 New injury likely to miss &gt; 1 day<br />
228 New significant illness/medical<br />
229 New allergy - only if nil exist</i></p>
230 <?php } ?>
232 <p class='bold'>
233 <a href="javascript:saveClicked();" class="link_submit">[<?php xl('Save','e'); ?>]</a>
234 <?php if ($viewmode || !isset($_GET["autoloaded"]) || $_GET["autoloaded"] != "1") { ?>
235 &nbsp; &nbsp;
236 <?php if ($GLOBALS['concurrent_layout']) { ?>
237 <a href="<?php echo "$rootdir/patient_file/encounter/encounter_top.php"; ?>"
238 class="link_submit" onclick="top.restoreSession()">[<?php xl('Cancel','e'); ?>]</a>
239 <?php } else { ?>
240 <a href="<?php echo "$rootdir/patient_file/encounter/patient_encounter.php"; ?>"
241 class="link_submit" target='Main' onclick="top.restoreSession()">
242 [<?php xl('Cancel','e'); ?>]</a>
243 <?php } // end not concurrent layout ?>
244 <?php } // end not autoloading ?>
245 &nbsp; &nbsp;
246 <a href="" onclick="return newissue()" class="link_submit">[<?php xl('Add Issue','e'); ?>]</a>
247 </p>
249 </td>
250 </tr>
252 </table>
254 </td>
256 <td class='bold' width='33%' nowrap>
257 <?php xl('Issues (Injuries/Medical/Allergy):','e'); ?>
258 </td>
259 </tr>
261 <tr>
262 <td class='text' valign='top'>
263 <textarea name='reason' cols='40' rows='12' wrap='virtual' style='width:96%'
264 ><?php echo $viewmode ? htmlspecialchars($result['reason']) : $GLOBALS['default_chief_complaint']; ?></textarea>
265 </td>
266 <td class='text' valign='top'>
267 <select multiple name='issues[]' size='8' style='width:100%'
268 title='<?php xl('Hold down [Ctrl] for multiple selections or to unselect','e'); ?>'>
269 <?php
270 while ($irow = sqlFetchArray($ires)) {
271 $list_id = $irow['id'];
272 $tcode = $irow['type'];
273 if ($ISSUE_TYPES[$tcode]) $tcode = $ISSUE_TYPES[$tcode][2];
275 if ($viewmode) {
276 echo " <option value='$list_id'";
277 $perow = sqlQuery("SELECT count(*) AS count FROM issue_encounter WHERE " .
278 "pid = '$pid' AND encounter = '$encounter' AND list_id = '$list_id'");
279 if ($perow['count']) echo " selected";
280 echo ">$tcode: " . $irow['begdate'] . " " .
281 htmlspecialchars(substr($irow['title'], 0, 40)) . "</option>\n";
283 else {
284 echo " <option value='$list_id'>$tcode: ";
285 echo $irow['begdate'] . " " . htmlspecialchars(substr($irow['title'], 0, 40)) . "</option>\n";
289 </select>
291 <p><i>To link this encounter/consult to an existing issue, click the desired issue
292 above to highlight it and then click [Save]. Hold down &lt;Ctrl&gt; to select
293 multiple issues.</i></p>
295 </td>
296 </tr>
298 </table>
300 </center>
302 </form>
304 </body>
306 <script language="javascript">
307 /* required for popup calendar */
308 Calendar.setup({inputField:"form_date", ifFormat:"%Y-%m-%d", button:"img_form_date"});
309 Calendar.setup({inputField:"form_onset_date", ifFormat:"%Y-%m-%d", button:"img_form_onset_date"});
310 </script>
312 </html>