fixes for prior commit
[openemr.git] / interface / patient_file / summary / immunizations.php
blob5f21a806b315d7a35acd170f6bd0f101e02eedc2
1 <?php
3 //SANITIZE ALL ESCAPES
4 $sanitize_all_escapes=true;
5 //
7 //STOP FAKE REGISTER GLOBALS
8 $fake_register_globals=false;
9 //
11 include_once("../../globals.php");
12 include_once("$srcdir/sql.inc");
13 include_once("$srcdir/options.inc.php");
14 include_once("$srcdir/immunization_helper.php");
16 if (isset($_GET['mode'])) {
18 * THIS IS A BUG. IF NEW IMMUN IS ADDED AND USER PRINTS PDF,
19 * WHEN BACK IS CLICKED, ANOTHER ITEM GETS ADDED
22 if ($_GET['mode'] == "add") {
23 $sql = "REPLACE INTO immunizations set
24 id = ?,
25 administered_date = if(?,?,NULL),
26 immunization_id = ?,
27 cvx_code = ?,
28 manufacturer = ?,
29 lot_number = ?,
30 administered_by_id = if(?,?,NULL),
31 administered_by = if(?,?,NULL),
32 education_date = if(?,?,NULL),
33 vis_date = if(?,?,NULL),
34 note = ?,
35 patient_id = ?,
36 created_by = ?,
37 updated_by = ?,
38 create_date = now(),
39 amount_administered = ?,
40 amount_administered_unit = ?,
41 expiration_date = if(?,?,NULL),
42 route = ?,
43 administration_site = ? ";
44 $sqlBindArray = array(
45 trim($_GET['id']),
46 trim($_GET['administered_date']), trim($_GET['administered_date']),
47 trim($_GET['form_immunization_id']),
48 trim($_GET['cvx_code']),
49 trim($_GET['manufacturer']),
50 trim($_GET['lot_number']),
51 trim($_GET['administered_by_id']), trim($_GET['administered_by_id']),
52 trim($_GET['administered_by']), trim($_GET['administered_by']),
53 trim($_GET['education_date']), trim($_GET['education_date']),
54 trim($_GET['vis_date']), trim($_GET['vis_date']),
55 trim($_GET['note']),
56 $pid,
57 $_SESSION['authId'],
58 $_SESSION['authId'],
59 trim($_GET['immuniz_amt_adminstrd']),
60 trim($_GET['form_drug_units']),
61 trim($_GET['immuniz_exp_date']), trim($_GET['immuniz_exp_date']),
62 trim($_GET['immuniz_route']),
63 trim($_GET['immuniz_admin_ste'])
65 sqlStatement($sql,$sqlBindArray);
66 $administered_date=date('Y-m-d H:i');
67 $education_date=date('Y-m-d');
68 $immunization_id=$cvx_code=$manufacturer=$lot_number=$administered_by_id=$note=$id="";
69 $administered_by=$vis_date="";
72 elseif ($_GET['mode'] == "delete" ) {
73 // log the event
74 newEvent("delete", $_SESSION['authUser'], $_SESSION['authProvider'], 1, "Immunization id ".$_GET['id']." deleted from pid ".$pid);
75 // delete the immunization
76 $sql="DELETE FROM immunizations WHERE id =? LIMIT 1";
77 sqlStatement($sql, array($_GET['id']));
80 elseif ($_GET['mode'] == "added_error" ) {
81 $sql = "UPDATE immunizations " .
82 "SET added_erroneously=? " .
83 "WHERE id=?";
84 $sql_arg_array = array(
85 ($_GET['isError'] === 'true'),
86 $_GET['id']
88 sqlStatement($sql, $sql_arg_array);
90 elseif ($_GET['mode'] == "edit" ) {
91 $sql = "select * from immunizations where id = ?";
92 $result = sqlQuery($sql, array($_GET['id']));
94 $administered_date = new DateTime($result['administered_date']);
95 $administered_date = $administered_date->format('Y-m-d H:i');
97 $immuniz_amt_adminstrd = $result['amount_administered'];
98 $drugunitselecteditem = $result['amount_administered_unit'];
99 $immunization_id = $result['immunization_id'];
100 $immuniz_exp_date = $result['expiration_date'];
102 $cvx_code = $result['cvx_code'];
103 $code_text = '';
104 if ( !(empty($cvx_code)) ) {
105 $query = "SELECT codes.code_text as `code_text`, codes.code as `code` " .
106 "FROM codes " .
107 "LEFT JOIN code_types on codes.code_type = code_types.ct_id " .
108 "WHERE code_types.ct_key = 'CVX' AND codes.code = ?";
109 $result_code_text = sqlQuery($query, array($cvx_code));
110 $code_text = $result_code_text['code_text'];
112 $manufacturer = $result['manufacturer'];
113 $lot_number = $result['lot_number'];
114 $administered_by_id = ($result['administered_by_id'] ? $result['administered_by_id'] : 0);
116 $administered_by = "";
117 if (!$result['administered_by'] && !$row['administered_by_id']) {
118 $stmt = "select concat(lname,', ',fname) as full_name ".
119 "from users where ".
120 "id=?";
121 $user_result = sqlQuery($stmt, array($result['administered_by_id']));
122 $administered_by = $user_result['full_name'];
125 $education_date = $result['education_date'];
126 $vis_date = $result['vis_date'];
127 $immuniz_route = $result['route'];
128 $immuniz_admin_ste = $result['administration_site'];
129 $note = $result['note'];
130 $isAddedError = $result['added_erroneously'];
132 //set id for page
133 $id = $_GET['id'];
138 // Decide whether using the CVX list or the custom list in list_options
139 if ($GLOBALS['use_custom_immun_list']) {
140 // user forces the use of the custom list
141 $useCVX = false;
143 else {
144 if ($_GET['mode'] == "edit") {
145 //depends on if a cvx code is enterer already
146 if (empty($cvx_code)) {
147 $useCVX = false;
149 else {
150 $useCVX = true;
153 else { // $_GET['mode'] == "add"
154 $useCVX = true;
158 // set the default sort method for the list of past immunizations
159 $sortby = $_GET['sortby'];
160 if (!$sortby) { $sortby = 'vacc'; }
162 // set the default value of 'administered_by'
163 if (!$administered_by && !$administered_by_id) {
164 $stmt = "select concat(lname,', ',fname) as full_name ".
165 " from users where ".
166 " id=?";
167 $row = sqlQuery($stmt, array($_SESSION['authId']));
168 $administered_by = $row['full_name'];
172 <html>
173 <head>
174 <?php html_header_show();?>
176 <!-- supporting javascript code -->
177 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script>
178 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js"></script>
179 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script>
182 <!-- page styles -->
183 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
185 <style>
186 .highlight {
187 color: green;
189 tr.selected {
190 background-color: white;
192 </style>
194 <!-- pop up calendar -->
195 <style type="text/css">@import url(<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.css);</style>
196 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.js"></script>
197 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
198 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar_setup.js"></script>
200 <script language="JavaScript">
201 // required to validate date text boxes
202 var mypcc = '<?php echo htmlspecialchars( $GLOBALS['phone_country_code'], ENT_QUOTES); ?>';
203 </script>
205 </head>
207 <body class="body_top">
209 <?php if ($GLOBALS['concurrent_layout']) { ?>
210 <span class="title"><?php echo htmlspecialchars( xl('Immunizations'), ENT_NOQUOTES); ?></span>
211 <?php } else { ?>
212 <a href="patient_summary.php" target="Main" onClick="top.restoreSession()">
213 <span class="title"><?php echo htmlspecialchars( xl('Immunizations'), ENT_NOQUOTES); ?></span>
214 <span class=back><?php echo htmlspecialchars( $tback, ENT_NOQUOTES); ?></span></a>
215 <?php } ?>
217 <form action="immunizations.php" name="add_immunization" id="add_immunization">
218 <input type="hidden" name="mode" id="mode" value="add">
219 <input type="hidden" name="id" id="id" value="<?php echo htmlspecialchars( $id, ENT_QUOTES); ?>">
220 <input type="hidden" name="pid" id="pid" value="<?php echo htmlspecialchars( $pid, ENT_QUOTES); ?>">
221 <br>
222 <table border=0 cellpadding=1 cellspacing=1>
223 <?php
224 if ($isAddedError) {
225 echo "<tr><font color='red'><b>" . xlt("Entered in Error") . "</b></font></tr>";
229 <?php if (!($useCVX)) { ?>
230 <tr>
231 <td align="right">
232 <span class=text>
233 <?php echo htmlspecialchars( xl('Immunization'), ENT_NOQUOTES); ?> </span> </td>
234 <td>
235 <?php
236 // Modified 7/2009 by BM to incorporate the immunization items into the list_options listings
237 generate_form_field(array('data_type'=>1,'field_id'=>'immunization_id','list_id'=>'immunizations','empty_title'=>'SKIP'), $immunization_id);
239 </td>
240 </tr>
241 <?php } else { ?>
242 <tr>
243 <td align="right" valign="top" style="padding-top:4px;">
244 <span class=text>
245 <?php echo htmlspecialchars( xl('Immunization'), ENT_NOQUOTES); ?> (<?php echo htmlspecialchars( xl('CVX Code'), ENT_NOQUOTES); ?>) </span> </td>
246 <td>
247 <input type='text' size='10' name='cvx_code' id='cvx_code'
248 value='<?php echo htmlspecialchars($cvx_code,ENT_QUOTES); ?>' onclick='sel_cvxcode(this)'
249 title='<?php echo htmlspecialchars( xl('Click to select or change CVX code'), ENT_QUOTES); ?>'
251 <div id='cvx_description' style='display:inline; float:right; padding:3px; margin-left:3px; width:400px'>
252 <?php echo htmlspecialchars( xl( $code_text ), ENT_QUOTES); ?> </div> </td>
253 </tr>
254 <?php } ?>
256 <tr>
257 <td align="right">
258 <span class=text>
259 <?php echo htmlspecialchars( xl('Date & Time Administered'), ENT_NOQUOTES); ?> </span> </td>
260 <td><table border="0">
261 <tr>
262 <td><input type='text' size='14' name="administered_date" id="administered_date"
263 value='<?php echo $administered_date ? htmlspecialchars( $administered_date, ENT_QUOTES) : date('Y-m-d H:i'); ?>'
264 title='<?php echo htmlspecialchars( xl('yyyy-mm-dd Hours(24):minutes'), ENT_QUOTES); ?>'
265 onKeyUp='datekeyup(this,mypcc)' onBlur='dateblur(this,mypcc);'
267 <img src='<?php echo $rootdir; ?>/pic/show_calendar.gif' align='absbottom' width='24' height='22'
268 id='img_administered_date' border='0' alt='[?]' style='cursor:pointer;cursor:hand'
269 title='<?php echo htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES); ?>'>
270 </td>
271 </tr>
272 </table></td>
273 </tr>
274 <tr>
275 <td align="right"><span class="text"><?php echo htmlspecialchars( xl('Amount Administered'), ENT_NOQUOTES); ?></span></td>
276 <td class='text'>
277 <input class='text' type='text' name="immuniz_amt_adminstrd" size="25" value="<?php echo htmlspecialchars( $immuniz_amt_adminstrd, ENT_QUOTES); ?>">
278 <?php echo generate_select_list("form_drug_units", "drug_units", $drugunitselecteditem,'Select Drug Unit',''); ?>
279 </td>
280 </tr>
281 <tr>
282 <td align="right"><span class="text"><?php echo htmlspecialchars( xl('Immunization Expiration Date'), ENT_NOQUOTES); ?></span></td>
283 <td class='text'><input type='text' size='10' name="immuniz_exp_date" id="immuniz_exp_date"
284 value='<?php echo $immuniz_exp_date ? htmlspecialchars( $immuniz_exp_date, ENT_QUOTES) : ''; ?>'
285 title='<?php echo htmlspecialchars( xl('yyyy-mm-dd'), ENT_QUOTES); ?>'
286 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc);'
288 <img src='<?php echo $rootdir; ?>/pic/show_calendar.gif' align='absbottom' width='24' height='22'
289 id='img_immuniz_exp_date' border='0' alt='[?]' style='cursor:pointer;cursor:hand'
290 title='<?php echo htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES); ?>'></td>
291 </tr>
292 <tr>
293 <td align="right">
294 <span class=text>
295 <?php echo htmlspecialchars( xl('Immunization Manufacturer'), ENT_NOQUOTES); ?> </span> </td>
296 <td>
297 <input class='text' type='text' name="manufacturer" size="25" value="<?php echo htmlspecialchars( $manufacturer, ENT_QUOTES); ?>"> </td>
298 </tr>
299 <tr>
300 <td align="right">
301 <span class=text>
302 <?php echo htmlspecialchars( xl('Immunization Lot Number'), ENT_NOQUOTES); ?> </span> </td>
303 <td>
304 <input class='text' type='text' name="lot_number" size="25" value="<?php echo htmlspecialchars( $lot_number, ENT_QUOTES); ?>"> </td>
305 </tr>
306 <tr>
307 <td align="right">
308 <span class='text'>
309 <?php echo htmlspecialchars( xl('Name and Title of Immunization Administrator'), ENT_NOQUOTES); ?> </span> </td>
310 <td class='text'>
311 <input type="text" name="administered_by" id="administered_by" size="25" value="<?php echo htmlspecialchars( $administered_by, ENT_QUOTES); ?>">
312 <?php echo htmlspecialchars( xl('or choose'), ENT_NOQUOTES); ?>
313 <!-- NEEDS WORK -->
314 <select name="administered_by_id" id='administered_by_id'>
315 <option value=""></option>
316 <?php
317 $sql = "select id, concat(lname,', ',fname) as full_name " .
318 "from users where username != '' " .
319 "order by concat(lname,', ',fname)";
321 $result = sqlStatement($sql);
322 while($row = sqlFetchArray($result)){
323 echo '<OPTION VALUE=' . htmlspecialchars( $row{'id'}, ENT_QUOTES);
324 echo (isset($administered_by_id) && $administered_by_id != "" ? $administered_by_id : $_SESSION['authId']) == $row{'id'} ? ' selected>' : '>';
325 echo htmlspecialchars( $row{'full_name'}, ENT_NOQUOTES) . '</OPTION>';
328 </select> </td>
329 </tr>
330 <tr>
331 <td align="right" class="text">
332 <?php echo htmlspecialchars( xl('Date Immunization Information Statements Given'), ENT_NOQUOTES); ?> </td>
333 <td>
334 <input type='text' size='10' name="education_date" id="education_date"
335 value='<?php echo $education_date? htmlspecialchars( $education_date, ENT_QUOTES) : date('Y-m-d'); ?>'
336 title='<?php echo htmlspecialchars( xl('yyyy-mm-dd'), ENT_QUOTES); ?>'
337 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc);'
339 <img src='<?php echo $rootdir; ?>/pic/show_calendar.gif' align='absbottom' width='24' height='22'
340 id='img_education_date' border='0' alt='[?]' style='cursor:pointer;'
341 title='<?php echo htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES); ?>'
342 /> </td>
343 </tr>
344 <tr>
345 <td align="right" class="text">
346 <?php echo htmlspecialchars( xl('Date of VIS Statement'), ENT_NOQUOTES); ?>
347 (<a href="http://www.cdc.gov/vaccines/pubs/vis/default.htm" title="<?php echo htmlspecialchars( xl('Help'), ENT_QUOTES); ?>" target="_blank">?</a>) </td>
348 <td>
349 <input type='text' size='10' name="vis_date" id="vis_date"
350 value='<?php echo $vis_date ? htmlspecialchars( $vis_date, ENT_QUOTES) : date('Y-m-d'); ?>'
351 title='<?php echo htmlspecialchars( xl('yyyy-mm-dd'), ENT_QUOTES); ?>'
352 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc);'
354 <img src='<?php echo $rootdir; ?>/pic/show_calendar.gif' align='absbottom' width='24' height='22'
355 id='img_vis_date' border='0' alt='[?]' style='cursor:pointer;'
356 title='<?php echo htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES); ?>'
357 /> </td>
358 </tr>
359 <tr>
360 <td align="right" class='text'><?php echo htmlspecialchars( xl('Route'), ENT_NOQUOTES); ?></td>
361 <td>
362 <?php echo generate_select_list('immuniz_route', 'drug_route', $immuniz_route, 'Select Route', '');?>
363 </td>
364 </tr>
365 <tr>
366 <td align="right" class='text'><?php echo htmlspecialchars( xl('Administration Site'), ENT_NOQUOTES); ?></td>
367 <td>
368 <?php echo generate_select_list('immuniz_admin_ste', 'proc_body_site', $immuniz_admin_ste, 'Select Administration Site', ' ');?>
369 </td>
370 </tr>
371 <tr>
372 <td align="right" class='text'>
373 <?php echo htmlspecialchars( xl('Notes'), ENT_NOQUOTES); ?> </td>
374 <td>
375 <textarea class='text' name="note" id="note" rows=5 cols=25><?php echo htmlspecialchars( $note, ENT_NOQUOTES); ?></textarea> </td>
376 </tr>
377 <tr>
378 <td colspan="3" align="center">
380 <input type="button" name="save" id="save" value="<?php echo htmlspecialchars( xl('Save Immunization'), ENT_QUOTES); ?>">
382 <input type="button" name="print" id="print" value="<?php echo htmlspecialchars( xl('Print Record') . xl('PDF','',' (',')'), ENT_QUOTES); ?>">
384 <input type="button" name="printHtml" id="printHtml" value="<?php echo htmlspecialchars( xl('Print Record') . xl('HTML','',' (',')'), ENT_QUOTES); ?>">
386 <input type="reset" name="clear" id="clear" value="<?php echo htmlspecialchars( xl('Clear'), ENT_QUOTES); ?>"> </td>
387 </tr>
388 </table>
389 </form>
391 <div id="immunization_list">
393 <table border=0 cellpadding=3 cellspacing=0>
395 <!-- some columns are sortable -->
396 <tr class='text bold'>
397 <th>
398 <a href="javascript:top.restoreSession();location.href='immunizations.php?sortby=vacc';" title='<?php echo htmlspecialchars( xl('Sort by vaccine'), ENT_QUOTES); ?>'>
399 <?php echo htmlspecialchars( xl('Vaccine'), ENT_NOQUOTES); ?></a>
400 <span class='small' style='font-family:arial'><?php if ($sortby == 'vacc') { echo 'v'; } ?></span>
401 </th>
402 <th>
403 <a href="javascript:top.restoreSession();location.href='immunizations.php?sortby=date';" title='<?php echo htmlspecialchars( xl('Sort by date'), ENT_QUOTES); ?>'>
404 <?php echo htmlspecialchars( xl('Date'), ENT_NOQUOTES); ?></a>
405 <span class='small' style='font-family:arial'><?php if ($sortby == 'date') { echo 'v'; } ?></span>
406 </th>
407 <th><?php echo htmlspecialchars( xl('Amount'), ENT_NOQUOTES); ?></th>
408 <th><?php echo xlt('Expiration'); ?></th>
409 <th><?php echo htmlspecialchars( xl('Manufacturer'), ENT_NOQUOTES); ?></th>
410 <th><?php echo htmlspecialchars( xl('Lot Number'), ENT_NOQUOTES); ?></th>
411 <th><?php echo htmlspecialchars( xl('Administered By'), ENT_NOQUOTES); ?></th>
412 <th><?php echo htmlspecialchars( xl('Education Date'), ENT_NOQUOTES); ?></th>
413 <th><?php echo htmlspecialchars( xl('Route'), ENT_NOQUOTES); ?></th>
414 <th><?php echo htmlspecialchars( xl('Administered Site'), ENT_NOQUOTES); ?></th>
415 <th><?php echo htmlspecialchars( xl('Notes'), ENT_NOQUOTES); ?></th>
416 <th><?php echo htmlspecialchars( xl('Error'), ENT_NOQUOTES); ?></th>
417 <th>&nbsp;</th>
418 </tr>
420 <?php
421 $result = getImmunizationList($pid, $_GET['sortby'], true);
423 while($row = sqlFetchArray($result)) {
424 $isError = $row['added_erroneously'];
426 if ($isError) {
427 $tr_title = 'title="' . xla("Entered in Error") . '"';
428 } else {
429 $tr_title = "";
432 if ($row["id"] == $id) {
433 echo "<tr " . $tr_title . " class='immrow text selected' id='".htmlspecialchars( $row["id"], ENT_QUOTES)."'>";
435 else {
436 echo "<tr " . $tr_title . " class='immrow text' id='".htmlspecialchars( $row["id"], ENT_QUOTES)."'>";
439 // Figure out which name to use (ie. from cvx list or from the custom list)
440 if ($GLOBALS['use_custom_immun_list']) {
441 $vaccine_display = generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']);
443 else {
444 if (!empty($row['code_text_short'])) {
445 $vaccine_display = htmlspecialchars( xl($row['code_text_short']), ENT_NOQUOTES);
447 else {
448 $vaccine_display = generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']);
452 if ($isError) {
453 $del_tag_open = "<del>";
454 $del_tag_close = "</del>";
455 } else {
456 $del_tag_open = "";
457 $del_tag_close = "";
460 echo "<td>" . $del_tag_open . $vaccine_display . $del_tag_close . "</td>";
462 if ($row["administered_date"]) {
463 $administered_date_summary = new DateTime($row['administered_date']);
464 $administered_date_summary = $administered_date_summary->format('Y-m-d H:i');
465 } else {
466 $administered_date_summary = "";
468 echo "<td>" . $del_tag_open . htmlspecialchars( $administered_date_summary, ENT_NOQUOTES) . $del_tag_close . "</td>";
469 if ($row["amount_administered"] > 0) {
470 echo "<td>" . $del_tag_open . htmlspecialchars( $row["amount_administered"] . " " . generate_display_field(array('data_type'=>'1','list_id'=>'drug_units'), $row['amount_administered_unit']) , ENT_NOQUOTES) . $del_tag_close . "</td>";
472 else {
473 echo "<td>&nbsp</td>";
475 echo "<td>" . $del_tag_open . text($row["expiration_date"]) . $del_tag_close . "</td>";
476 echo "<td>" . $del_tag_open . htmlspecialchars( $row["manufacturer"], ENT_NOQUOTES) . $del_tag_close . "</td>";
477 echo "<td>" . $del_tag_open . htmlspecialchars( $row["lot_number"], ENT_NOQUOTES) . $del_tag_close . "</td>";
478 echo "<td>" . $del_tag_open . htmlspecialchars( $row["administered_by"], ENT_NOQUOTES) . $del_tag_close . "</td>";
479 echo "<td>" . $del_tag_open . htmlspecialchars( $row["education_date"], ENT_NOQUOTES) . $del_tag_close . "</td>";
480 echo "<td>" . $del_tag_open . generate_display_field(array('data_type'=>'1','list_id'=>'drug_route'), $row['route']) . $del_tag_close . "</td>";
481 echo "<td>" . $del_tag_open . generate_display_field(array('data_type'=>'1','list_id'=>'proc_body_site'), $row['administration_site']) . $del_tag_close . "</td>";
482 echo "<td>" . $del_tag_open . htmlspecialchars( $row["note"], ENT_NOQUOTES) . $del_tag_close . "</td>";
484 if ($isError) {
485 $checkbox = "checked";
486 } else {
487 $checkbox = "";
490 echo "<td><input type='checkbox' class='error' id='".htmlspecialchars( $row["id"], ENT_QUOTES)."' value='" . htmlspecialchars( xl('Error'), ENT_QUOTES) . "' " . $checkbox . "></td>";
492 echo "<td><input type='button' class='delete' id='".htmlspecialchars( $row["id"], ENT_QUOTES)."' value='" . htmlspecialchars( xl('Delete'), ENT_QUOTES) . "'></td>";
493 echo "</tr>";
498 </table>
499 </div> <!-- end immunizations -->
501 </body>
503 <script language="javascript">
504 /* required for popup calendar */
505 Calendar.setup({inputField:"administered_date", ifFormat:"%Y-%m-%d %H:%M", button:"img_administered_date", showsTime:true});
506 Calendar.setup({inputField:"immuniz_exp_date", ifFormat:"%Y-%m-%d", button:"img_immuniz_exp_date"});
507 Calendar.setup({inputField:"education_date", ifFormat:"%Y-%m-%d", button:"img_education_date"});
508 Calendar.setup({inputField:"vis_date", ifFormat:"%Y-%m-%d", button:"img_vis_date"});
510 // jQuery stuff to make the page a little easier to use
512 $(document).ready(function(){
513 <?php if (!($useCVX)) { ?>
514 $("#save").click(function() { SaveForm(); });
515 <?php } else { ?>
516 $("#save").click(function() {
517 if (validate_cvx()) {
518 SaveForm();
520 else {
521 return;
524 <?php } ?>
525 $("#print").click(function() { PrintForm("pdf"); });
526 $("#printHtml").click(function() { PrintForm("html"); });
527 $(".immrow").click(function() { EditImm(this); });
528 $(".error").click(function(event) { ErrorImm(this); event.stopPropagation(); });
529 $(".delete").click(function(event) { DeleteImm(this); event.stopPropagation(); });
531 $(".immrow").mouseover(function() { $(this).toggleClass("highlight"); });
532 $(".immrow").mouseout(function() { $(this).toggleClass("highlight"); });
534 $("#administered_by_id").change(function() { $("#administered_by").val($("#administered_by_id :selected").text()); });
536 $("#form_immunization_id").change( function() {
537 if ( $(this).val() != "" ) {
538 $("#cvx_code").val( "" );
539 $("#cvx_description").text( "" );
540 $("#cvx_code").change();
545 var PrintForm = function(typ) {
546 top.restoreSession();
547 newURL='shot_record.php?output='+typ+'&sortby=<?php echo $sortby; ?>';
548 window.open(newURL, '_blank', "menubar=1,toolbar=1,scrollbars=1,resizable=1,width=600,height=450");
551 var SaveForm = function() {
552 top.restoreSession();
553 $("#add_immunization").submit();
556 var EditImm = function(imm) {
557 top.restoreSession();
558 location.href='immunizations.php?mode=edit&id='+imm.id;
561 var DeleteImm = function(imm) {
562 if (confirm("<?php echo htmlspecialchars( xl('This action cannot be undone.'), ENT_QUOTES); ?>" + "\n" +"<?php echo htmlspecialchars( xl('Do you wish to PERMANENTLY delete this immunization record?'), ENT_QUOTES); ?>")) {
563 top.restoreSession();
564 location.href='immunizations.php?mode=delete&id='+imm.id;
568 var ErrorImm = function(imm) {
569 top.restoreSession();
570 location.href='immunizations.php?mode=added_error&id='+imm.id+'&isError='+imm.checked;
573 //This is for callback by the find-code popup.
574 //Appends to or erases the current list of diagnoses.
575 function set_related(codetype, code, selector, codedesc) {
576 var f = document.forms[0][current_sel_name];
577 var s = f.value;
579 if (code) {
580 s = code;
582 else {
583 s = '';
586 f.value = s;
587 $("#cvx_description").text( codedesc );
588 $("#form_immunization_id").attr( "value", "" );
589 $("#form_immunization_id").change();
593 // This invokes the find-code popup.
594 function sel_cvxcode(e) {
595 current_sel_name = e.name;
596 dlgopen('../encounter/find_code_popup.php?codetype=CVX', '_blank', 500, 400);
599 // This ensures the cvx centric entry is filled.
600 function validate_cvx() {
601 if (document.add_immunization.cvx_code.value>0) {
602 return true;
604 else {
605 document.add_immunization.cvx_code.style.backgroundColor="red";
606 document.add_immunization.cvx_code.focus();
607 return false;
611 </script>
613 </html>