added cache clearing support for dialog.js (#411)
[openemr.git] / interface / patient_file / summary / immunizations.php
blob37cef9056a5ee463854fbe69969d6fe93911d74c
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 completion_status = ?,
45 information_source = ?,
46 refusal_reason = ?,
47 ordering_provider = ?";
48 $sqlBindArray = array(
49 trim($_GET['id']),
50 trim($_GET['administered_date']), trim($_GET['administered_date']),
51 trim($_GET['form_immunization_id']),
52 trim($_GET['cvx_code']),
53 trim($_GET['manufacturer']),
54 trim($_GET['lot_number']),
55 trim($_GET['administered_by_id']), trim($_GET['administered_by_id']),
56 trim($_GET['administered_by']), trim($_GET['administered_by']),
57 trim($_GET['education_date']), trim($_GET['education_date']),
58 trim($_GET['vis_date']), trim($_GET['vis_date']),
59 trim($_GET['note']),
60 $pid,
61 $_SESSION['authId'],
62 $_SESSION['authId'],
63 trim($_GET['immuniz_amt_adminstrd']),
64 trim($_GET['form_drug_units']),
65 trim($_GET['immuniz_exp_date']), trim($_GET['immuniz_exp_date']),
66 trim($_GET['immuniz_route']),
67 trim($_GET['immuniz_admin_ste']),
68 trim($_GET['immuniz_completion_status']),
69 trim($_GET['immunization_informationsource']),
70 trim($_GET['immunization_refusal_reason']),
71 trim($_GET['ordered_by_id'])
73 $newid = sqlInsert($sql,$sqlBindArray);
74 $administered_date=date('Y-m-d H:i');
75 $education_date=date('Y-m-d');
76 $immunization_id=$cvx_code=$manufacturer=$lot_number=$administered_by_id=$note=$id=$ordered_by_id="";
77 $administered_by=$vis_date="";
78 $newid = $_GET['id'] ? $_GET['id'] : $newid;
79 if($GLOBALS['observation_results_immunization']) {
80 saveImmunizationObservationResults($newid,$_GET);
84 elseif ($_GET['mode'] == "delete" ) {
85 // log the event
86 newEvent("delete", $_SESSION['authUser'], $_SESSION['authProvider'], 1, "Immunization id ".$_GET['id']." deleted from pid ".$pid);
87 // delete the immunization
88 $sql="DELETE FROM immunizations WHERE id =? LIMIT 1";
89 sqlStatement($sql, array($_GET['id']));
92 elseif ($_GET['mode'] == "added_error" ) {
93 $sql = "UPDATE immunizations " .
94 "SET added_erroneously=? " .
95 "WHERE id=?";
96 $sql_arg_array = array(
97 ($_GET['isError'] === 'true'),
98 $_GET['id']
100 sqlStatement($sql, $sql_arg_array);
102 elseif ($_GET['mode'] == "edit" ) {
103 $sql = "select * from immunizations where id = ?";
104 $result = sqlQuery($sql, array($_GET['id']));
106 $administered_date = new DateTime($result['administered_date']);
107 $administered_date = $administered_date->format('Y-m-d H:i');
109 $immuniz_amt_adminstrd = $result['amount_administered'];
110 $drugunitselecteditem = $result['amount_administered_unit'];
111 $immunization_id = $result['immunization_id'];
112 $immuniz_exp_date = $result['expiration_date'];
114 $cvx_code = $result['cvx_code'];
115 $code_text = '';
116 if ( !(empty($cvx_code)) ) {
117 $query = "SELECT codes.code_text as `code_text`, codes.code as `code` " .
118 "FROM codes " .
119 "LEFT JOIN code_types on codes.code_type = code_types.ct_id " .
120 "WHERE code_types.ct_key = 'CVX' AND codes.code = ?";
121 $result_code_text = sqlQuery($query, array($cvx_code));
122 $code_text = $result_code_text['code_text'];
124 $manufacturer = $result['manufacturer'];
125 $lot_number = $result['lot_number'];
126 $administered_by_id = ($result['administered_by_id'] ? $result['administered_by_id'] : 0);
127 $ordered_by_id = ($result['ordering_provider'] ? $result['ordering_provider'] : 0);
128 $entered_by_id = ($result['created_by'] ? $result['created_by'] : 0);
130 $administered_by = "";
131 if (!$result['administered_by'] && !$row['administered_by_id']) {
132 $stmt = "select CONCAT(IFNULL(lname,''), ' ,',IFNULL(fname,'')) as full_name ".
133 "from users where ".
134 "id=?";
135 $user_result = sqlQuery($stmt, array($result['administered_by_id']));
136 $administered_by = $user_result['full_name'];
139 $education_date = $result['education_date'];
140 $vis_date = $result['vis_date'];
141 $immuniz_route = $result['route'];
142 $immuniz_admin_ste = $result['administration_site'];
143 $note = $result['note'];
144 $isAddedError = $result['added_erroneously'];
146 $immuniz_completion_status = $result['completion_status'];
147 $immuniz_information_source = $result['information_source'];
148 $immuniz_refusal_reason = $result['refusal_reason'];
149 //set id for page
150 $id = $_GET['id'];
152 $imm_obs_data = getImmunizationObservationResults();
156 $observation_criteria = getImmunizationObservationLists('1');
157 $observation_criteria_value = getImmunizationObservationLists('2');
158 // Decide whether using the CVX list or the custom list in list_options
159 if ($GLOBALS['use_custom_immun_list']) {
160 // user forces the use of the custom list
161 $useCVX = false;
163 else {
164 if ($_GET['mode'] == "edit") {
165 //depends on if a cvx code is enterer already
166 if (empty($cvx_code)) {
167 $useCVX = false;
169 else {
170 $useCVX = true;
173 else { // $_GET['mode'] == "add"
174 $useCVX = true;
178 // set the default sort method for the list of past immunizations
179 $sortby = $_GET['sortby'];
180 if (!$sortby) { $sortby = 'vacc'; }
182 // set the default value of 'administered_by'
183 if (!$administered_by && !$administered_by_id) {
184 $stmt = "select CONCAT(IFNULL(lname,''), ' ,',IFNULL(fname,'')) as full_name ".
185 " from users where ".
186 " id=?";
187 $row = sqlQuery($stmt, array($_SESSION['authId']));
188 $administered_by = $row['full_name'];
191 // get the entered username
192 if ($entered_by_id) {
193 $stmt = "select CONCAT(IFNULL(lname,''), ' ,',IFNULL(fname,'')) as full_name ".
194 " from users where ".
195 " id=?";
196 $row = sqlQuery($stmt, array($entered_by_id));
197 $entered_by = $row['full_name'];
200 if($_POST['type'] == 'duplicate_row'){
201 $observation_criteria = getImmunizationObservationLists('1');
202 echo json_encode($observation_criteria);
203 exit;
205 if($_POST['type'] == 'duplicate_row_2'){
206 $observation_criteria_value = getImmunizationObservationLists('2');
207 echo json_encode($observation_criteria_value);
208 exit;
211 function getImmunizationObservationLists($k)
213 if($k == 1) {
214 $observation_criteria_res = sqlStatement("SELECT * FROM list_options WHERE list_id = ? AND activity=1 ORDER BY seq, title", array('immunization_observation'));
215 for ($iter = 0; $row = sqlFetchArray($observation_criteria_res); $iter++) {
216 $observation_criteria[0]['option_id'] = '';
217 $observation_criteria[0]['title'] = 'Unassigned';
218 $observation_criteria[++$iter] = $row;
220 return $observation_criteria;
221 }else {
222 $observation_criteria_value_res = sqlStatement("SELECT * FROM list_options WHERE list_id = ? AND activity=1 ORDER BY seq, title", array('imm_vac_eligibility_results'));
223 for ($iter = 0; $row = sqlFetchArray($observation_criteria_value_res); $iter++) {
224 $observation_criteria_value[0]['option_id'] = '';
225 $observation_criteria_value[0]['title'] = 'Unassigned';
226 $observation_criteria_value[++$iter] = $row;
228 return $observation_criteria_value;
232 function getImmunizationObservationResults()
234 $obs_res_q = "SELECT
236 FROM
237 immunization_observation
238 WHERE imo_pid = ?
239 AND imo_im_id = ?";
240 $res = sqlStatement($obs_res_q, array($_SESSION["pid"],$_GET['id']));
241 for ($iter = 0; $row = sqlFetchArray($res); $iter++)
242 $imm_obs_data[$iter] = $row;
243 return $imm_obs_data;
246 function saveImmunizationObservationResults($id,$immunizationdata)
248 $imm_obs_data = getImmunizationObservationResults();
249 if(count($imm_obs_data) > 0) {
250 foreach($imm_obs_data as $key=>$val) {
251 if($val['imo_id'] && $val['imo_id'] != 0 ) {
252 $sql2 = " DELETE
253 FROM
254 immunization_observation
255 WHERE imo_im_id = ?
256 AND imo_pid = ?";
257 $result2 = sqlQuery($sql2,array($val['imo_im_id'],$val['imo_pid']));
261 for($i = 0; $i < $immunizationdata['tr_count']; $i++) {
262 if($immunizationdata['observation_criteria'][$i] == 'vaccine_type') {
263 $code = $immunizationdata['cvx_vac_type_code'][$i];
264 $code_text = $immunizationdata['code_text_hidden'][$i];
265 $code_type = $immunizationdata['code_type_hidden'][$i];
266 $vis_published_dateval = $immunizationdata['vis_published_date'][$i] ? $immunizationdata['vis_published_date'][$i] : '';
267 $vis_presented_dateval = $immunizationdata['vis_presented_date'][$i] ? $immunizationdata['vis_presented_date'][$i] : '';
268 $imo_criteria_value = '';
269 } else if($immunizationdata['observation_criteria'][$i] == 'disease_with_presumed_immunity') {
270 $code = $immunizationdata['sct_code'][$i];
271 $code_text = $immunizationdata['codetext'][$i];
272 $code_type = $immunizationdata['codetypehidden'][$i];
273 $imo_criteria_value = '';
274 $vis_published_dateval = '';
275 $vis_presented_dateval = '';
276 }else if($immunizationdata['observation_criteria'][$i] == 'funding_program_eligibility') {
277 $imo_criteria_value = $immunizationdata['observation_criteria_value'][$i];
278 $code = '';
279 $code_text = '';
280 $code_type = '';
281 $vis_published_dateval = '';
282 $vis_presented_dateval = '';
285 if($immunizationdata['observation_criteria'][$i] != '') {
286 $sql = " INSERT INTO immunization_observation (
287 imo_im_id,
288 imo_pid,
289 imo_criteria,
290 imo_criteria_value,
291 imo_user,
292 imo_code,
293 imo_codetext,
294 imo_codetype,
295 imo_vis_date_published,
296 imo_vis_date_presented
298 VALUES
299 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
300 $res = sqlQuery($sql, array($id,$_SESSION["pid"],$immunizationdata['observation_criteria'][$i],$imo_criteria_value,$_SESSION['authId'],$code, $code_text, $code_type,$vis_published_dateval,$vis_presented_dateval));
303 return;
306 <html>
307 <head>
308 <?php html_header_show();?>
310 <!-- supporting javascript code -->
311 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-1/index.js"></script>
312 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js"></script>
313 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
316 <!-- page styles -->
317 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
319 <style>
320 .highlight {
321 color: green;
323 tr.selected {
324 background-color: white;
326 </style>
328 <!-- pop up calendar -->
329 <style type="text/css">@import url(<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.css);</style>
330 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.js"></script>
331 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
332 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar_setup.js"></script>
334 <script language="JavaScript">
335 // required to validate date text boxes
336 var mypcc = '<?php echo htmlspecialchars( $GLOBALS['phone_country_code'], ENT_QUOTES); ?>';
337 </script>
339 </head>
341 <body class="body_top">
343 <span class="title"><?php echo htmlspecialchars( xl('Immunizations'), ENT_NOQUOTES); ?></span>
345 <form action="immunizations.php" name="add_immunization" id="add_immunization">
346 <input type="hidden" name="mode" id="mode" value="add">
347 <input type="hidden" name="id" id="id" value="<?php echo htmlspecialchars( $id, ENT_QUOTES); ?>">
348 <input type="hidden" name="pid" id="pid" value="<?php echo htmlspecialchars( $pid, ENT_QUOTES); ?>">
349 <br>
350 <table border=0 cellpadding=1 cellspacing=1>
351 <?php
352 if ($isAddedError) {
353 echo "<tr><font color='red'><b>" . xlt("Entered in Error") . "</b></font></tr>";
357 <?php if (!($useCVX)) { ?>
358 <tr>
359 <td align="right">
360 <span class=text>
361 <?php echo htmlspecialchars( xl('Immunization'), ENT_NOQUOTES); ?> </span> </td>
362 <td>
363 <?php
364 // Modified 7/2009 by BM to incorporate the immunization items into the list_options listings
365 generate_form_field(array('data_type'=>1,'field_id'=>'immunization_id','list_id'=>'immunizations','empty_title'=>'SKIP'), $immunization_id);
367 </td>
368 </tr>
369 <?php } else { ?>
370 <tr>
371 <td align="right" valign="top" style="padding-top:4px;">
372 <span class=text>
373 <?php echo htmlspecialchars( xl('Immunization'), ENT_NOQUOTES); ?> (<?php echo htmlspecialchars( xl('CVX Code'), ENT_NOQUOTES); ?>) </span> </td>
374 <td>
375 <input type='text' size='10' name='cvx_code' id='cvx_code'
376 value='<?php echo htmlspecialchars($cvx_code,ENT_QUOTES); ?>' onclick='sel_cvxcode(this)'
377 title='<?php echo htmlspecialchars( xl('Click to select or change CVX code'), ENT_QUOTES); ?>'
379 <div id='cvx_description' style='display:inline; float:right; padding:3px; margin-left:3px; width:400px'>
380 <?php echo htmlspecialchars( xl( $code_text ), ENT_QUOTES); ?> </div> </td>
381 </tr>
382 <?php } ?>
384 <tr>
385 <td align="right">
386 <span class=text>
387 <?php echo htmlspecialchars( xl('Date & Time Administered'), ENT_NOQUOTES); ?> </span> </td>
388 <td><table border="0">
389 <tr>
390 <td><input type='text' size='14' name="administered_date" id="administered_date"
391 value='<?php echo $administered_date ? htmlspecialchars( $administered_date, ENT_QUOTES) : date('Y-m-d H:i'); ?>'
392 title='<?php echo htmlspecialchars( xl('yyyy-mm-dd Hours(24):minutes'), ENT_QUOTES); ?>'
393 onKeyUp='datekeyup(this,mypcc)' onBlur='dateblur(this,mypcc);'
395 <img src='<?php echo $rootdir; ?>/pic/show_calendar.gif' align='absbottom' width='24' height='22'
396 id='img_administered_date' border='0' alt='[?]' style='cursor:pointer;cursor:hand'
397 title='<?php echo htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES); ?>'>
398 </td>
399 </tr>
400 </table></td>
401 </tr>
402 <tr>
403 <td align="right"><span class="text"><?php echo htmlspecialchars( xl('Amount Administered'), ENT_NOQUOTES); ?></span></td>
404 <td class='text'>
405 <input class='text' type='text' name="immuniz_amt_adminstrd" size="25" value="<?php echo htmlspecialchars( $immuniz_amt_adminstrd, ENT_QUOTES); ?>">
406 <?php echo generate_select_list("form_drug_units", "drug_units", $drugunitselecteditem,'Select Drug Unit',''); ?>
407 </td>
408 </tr>
409 <tr>
410 <td align="right"><span class="text"><?php echo htmlspecialchars( xl('Immunization Expiration Date'), ENT_NOQUOTES); ?></span></td>
411 <td class='text'><input type='text' size='10' name="immuniz_exp_date" id="immuniz_exp_date"
412 value='<?php echo $immuniz_exp_date ? htmlspecialchars( $immuniz_exp_date, ENT_QUOTES) : ''; ?>'
413 title='<?php echo htmlspecialchars( xl('yyyy-mm-dd'), ENT_QUOTES); ?>'
414 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc);'
416 <img src='<?php echo $rootdir; ?>/pic/show_calendar.gif' align='absbottom' width='24' height='22'
417 id='img_immuniz_exp_date' border='0' alt='[?]' style='cursor:pointer;cursor:hand'
418 title='<?php echo htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES); ?>'></td>
419 </tr>
420 <tr>
421 <td align="right">
422 <span class=text>
423 <?php echo htmlspecialchars( xl('Immunization Manufacturer'), ENT_NOQUOTES); ?> </span> </td>
424 <td>
425 <?php echo generate_select_list('manufacturer', 'Immunization_Manufacturer', $manufacturer, 'Select Manufacturer', '');?>
426 </tr>
427 <tr>
428 <td align="right">
429 <span class=text>
430 <?php echo htmlspecialchars( xl('Immunization Lot Number'), ENT_NOQUOTES); ?> </span> </td>
431 <td>
432 <input class='text' type='text' name="lot_number" size="25" value="<?php echo htmlspecialchars( $lot_number, ENT_QUOTES); ?>"> </td>
433 </tr>
434 <tr>
435 <td align="right">
436 <span class='text'>
437 <?php echo htmlspecialchars( xl('Name and Title of Immunization Administrator'), ENT_NOQUOTES); ?> </span> </td>
438 <td class='text'>
439 <input type="text" name="administered_by" id="administered_by" size="25" value="<?php echo htmlspecialchars( $administered_by, ENT_QUOTES); ?>">
440 <?php echo htmlspecialchars( xl('or choose'), ENT_NOQUOTES); ?>
441 <!-- NEEDS WORK -->
442 <select name="administered_by_id" id='administered_by_id'>
443 <option value=""></option>
444 <?php
445 $sql = "select id, CONCAT_WS(' ',lname,fname) as full_name " .
446 "from users where username != '' and password != 'NoLogin' " .
447 "order by full_name";
449 $result = sqlStatement($sql);
450 while($row = sqlFetchArray($result)){
451 echo '<OPTION VALUE=' . htmlspecialchars( $row{'id'}, ENT_QUOTES);
452 echo (isset($administered_by_id) && $administered_by_id != "" ? $administered_by_id : $_SESSION['authId']) == $row{'id'} ? ' selected>' : '>';
453 echo htmlspecialchars( $row{'full_name'}, ENT_NOQUOTES) . '</OPTION>';
456 </select> </td>
457 </tr>
458 <tr>
459 <td align="right" class="text">
460 <?php echo htmlspecialchars( xl('Date Immunization Information Statements Given'), ENT_NOQUOTES); ?> </td>
461 <td>
462 <input type='text' size='10' name="education_date" id="education_date"
463 value='<?php echo $education_date? htmlspecialchars( $education_date, ENT_QUOTES) : date('Y-m-d'); ?>'
464 title='<?php echo htmlspecialchars( xl('yyyy-mm-dd'), ENT_QUOTES); ?>'
465 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc);'
467 <img src='<?php echo $rootdir; ?>/pic/show_calendar.gif' align='absbottom' width='24' height='22'
468 id='img_education_date' border='0' alt='[?]' style='cursor:pointer;'
469 title='<?php echo htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES); ?>'
470 /> </td>
471 </tr>
472 <tr>
473 <td align="right" class="text">
474 <?php echo htmlspecialchars( xl('Date of VIS Statement'), ENT_NOQUOTES); ?>
475 (<a href="http://www.cdc.gov/vaccines/pubs/vis/default.htm" title="<?php echo htmlspecialchars( xl('Help'), ENT_QUOTES); ?>" target="_blank">?</a>) </td>
476 <td>
477 <input type='text' size='10' name="vis_date" id="vis_date"
478 value='<?php echo $vis_date ? htmlspecialchars( $vis_date, ENT_QUOTES) : date('Y-m-d'); ?>'
479 title='<?php echo htmlspecialchars( xl('yyyy-mm-dd'), ENT_QUOTES); ?>'
480 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc);'
482 <img src='<?php echo $rootdir; ?>/pic/show_calendar.gif' align='absbottom' width='24' height='22'
483 id='img_vis_date' border='0' alt='[?]' style='cursor:pointer;'
484 title='<?php echo htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES); ?>'
485 /> </td>
486 </tr>
487 <tr>
488 <td align="right" class='text'><?php echo htmlspecialchars( xl('Route'), ENT_NOQUOTES); ?></td>
489 <td>
490 <?php echo generate_select_list('immuniz_route', 'drug_route', $immuniz_route, 'Select Route', '');?>
491 </td>
492 </tr>
493 <tr>
494 <td align="right" class='text'><?php echo htmlspecialchars( xl('Administration Site'), ENT_NOQUOTES); ?></td>
495 <td>
496 <?php echo generate_select_list('immuniz_admin_ste', 'immunization_administered_site', $immuniz_admin_ste, 'Select Administration Site', ' ', '','','',null,false,'proc_body_site');?>
497 </td>
498 </tr>
499 <tr>
500 <td align="right" class='text'>
501 <?php echo htmlspecialchars( xl('Notes'), ENT_NOQUOTES); ?> </td>
502 <td>
503 <textarea class='text' name="note" id="note" rows=5 cols=25><?php echo htmlspecialchars( $note, ENT_NOQUOTES); ?></textarea> </td>
504 </tr>
505 <tr>
506 <td align="right" class='text'>
507 <?php echo htmlspecialchars( xl('Information Source'), ENT_NOQUOTES); ?>
508 </td>
509 <td>
510 <?php echo generate_select_list('immunization_informationsource', 'immunization_informationsource', $immuniz_information_source, 'Select Information Source', ' ');?>
511 </td>
512 </tr>
513 <tr>
514 <td align="right" class='text'>
515 <?php echo htmlspecialchars( xl('Completion Status'), ENT_NOQUOTES); ?> </td>
516 <td>
517 <?php echo generate_select_list('immuniz_completion_status', 'Immunization_Completion_Status', $immuniz_completion_status, 'Select Completion Status', ' ');?> </td>
518 </tr>
519 <tr>
520 <td align="right" class='text'>
521 <?php echo htmlspecialchars( xl('Substance Refusal Reason'), ENT_NOQUOTES); ?>
522 </td>
523 <td>
524 <?php echo generate_select_list('immunization_refusal_reason', 'immunization_refusal_reason', $immuniz_refusal_reason, 'Select Refusal Reason', ' ');?>
525 </td>
526 </tr>
527 <tr>
528 <td align="right" class='text'>
529 <?php echo htmlspecialchars( xl('Immunization Ordering Provider'), ENT_NOQUOTES); ?>
530 </td>
531 <td>
532 <select name="ordered_by_id" id='ordered_by_id'>
533 <option value=""></option>
534 <?php
535 $sql = "select id, CONCAT(IFNULL(lname,''), ' ,',IFNULL(fname,'')) as full_name " .
536 "from users where username != '' and password != 'NoLogin' " .
537 "order by full_name";
539 $result = sqlStatement($sql);
540 while($row = sqlFetchArray($result)){
541 echo '<OPTION VALUE=' . htmlspecialchars( $row{'id'}, ENT_QUOTES);
542 echo (isset($ordered_by_id) && $ordered_by_id != "" ? $ordered_by_id : $_SESSION['authId']) == $row{'id'} ? ' selected>' : '>';
543 echo htmlspecialchars( $row{'full_name'}, ENT_NOQUOTES) . '</OPTION>';
546 </select>
547 </td>
548 </tr>
549 <?php
550 if($entered_by){
552 <tr>
553 <td align="right" class='text'>
554 <?php echo htmlspecialchars( xl('Entered By'), ENT_NOQUOTES); ?>
555 </td>
556 <td>
557 <?php echo htmlspecialchars( $entered_by, ENT_NOQUOTES); ?>
558 </td>
559 </tr>
560 <?php
562 if($GLOBALS['observation_results_immunization']) {
564 <tr>
565 <td colspan="3" align="center">
566 <img src='../../pic/add.png' onclick="showObservationResultSection();" align='absbottom' width='27' height='24' border='0' style='cursor:pointer;cursor:hand' title='<?php echo xla('Click here to see observation results'); ?>'>
567 </td>
568 </tr><?php } ?>
569 <tr>
570 <td align="center" colspan="3">
571 <div class="observation_results" style="display:none;">
572 <fieldset class="obs_res_head">
573 <legend><?php echo htmlspecialchars( xl('Observation Results'), ENT_QUOTES); ?></legend>
574 <table class="obs_res_table">
575 <?php if(count($imm_obs_data) > 0) {
576 foreach($imm_obs_data as $key=>$value) {
577 $key_snomed = 0; $key_cvx = 0; $style= '';?>
578 <tr id="or_tr_<?php echo $key + 1 ;?>">
579 <?php
580 if($id == 0 ) {
581 if($key == 0)
582 $style = 'display: table-cell;width:765px !important';
583 else
584 $style = 'display: none;width:765px !important';
586 else
587 $style = 'display : table-cell;width:765px !important';
589 <td id="observation_criteria_td_<?php echo $key + 1 ;?>" style="<?php echo $style;?>">
590 <label><?php echo htmlspecialchars( xl('Observation Criteria'), ENT_QUOTES);?></label>
591 <select id="observation_criteria_<?php echo $key + 1 ;?>" name="observation_criteria[]" onchange="selectCriteria(this.id,this.value);" style="width: 220px;">
592 <?php foreach ($observation_criteria as $keyo=> $valo) { ?>
593 <option value="<?php echo attr($valo['option_id']);?>" <?php if($valo['option_id'] == $value['imo_criteria'] && $id !=0) echo 'selected = "selected"' ;?> ><?php echo text($valo['title']);?></option>
594 <?php }
596 </select>
597 </td>
598 <td <?php if($value['imo_criteria'] != 'funding_program_eligibility' || $id == 0) { ?> style="display: none;" <?php } ?> class="observation_criteria_value_td" id="observation_criteria_value_td_<?php echo $key + 1 ;?>">
599 <label><?php echo htmlspecialchars( xl('Observation Criteria Value'), ENT_QUOTES); ?></label>
600 <select name="observation_criteria_value[]" id="observation_criteria_value_<?php echo $key + 1 ;?>" style="width: 220px;">
601 <?php foreach ($observation_criteria_value as $keyoc=> $valoc) { ?>
602 <option value="<?php echo attr($valoc['option_id']);?>" <?php if($valoc['option_id'] == $value['imo_criteria_value'] && $id != 0) echo 'selected = "selected"' ;?>><?php echo text($valoc['title']);?></option>
603 <?php }
605 </select>
606 </td>
607 <td <?php if($value['imo_criteria'] != 'disease_with_presumed_immunity' || $id == 0) { ?> style="display: none;" <?php } ?> class="code_serach_td" id="code_search_td_<?php echo $key + 1 ;?>">
608 <?php $key_snomed = ($key > 0) ? (($key*2) + 2) : ($key + 2);?>
609 <label><?php echo htmlspecialchars( xl('SNOMED-CT Code'), ENT_QUOTES);?></label>
610 <input type="text" id="sct_code_<?php echo $key_snomed; ?>" style="width:140px" name="sct_code[]" class="code" value="<?php if($id != 0 && $value['imo_criteria'] == 'disease_with_presumed_immunity') echo attr($value['imo_code']);?>" onclick='sel_code(this.id);'><br>
611 <span id="displaytext_<?php echo $key_snomed; ?>" style="width:210px !important;display: block;font-size:13px;color: blue;" class="displaytext"><?php echo text($value['imo_codetext']);?></span>
612 <input type="hidden" id="codetext_<?php echo $key_snomed; ?>" name="codetext[]" class="codetext" value="<?php echo attr($value['imo_codetext']); ?>">
613 <input type="hidden" value="SNOMED-CT" name="codetypehidden[]" id="codetypehidden<?php echo $key_snomed; ?>" />
614 </td>
615 <td <?php if($value['imo_criteria'] != 'vaccine_type' || $id == 0) { ?> style="display: none;" <?php } ?> class="code_serach_vaccine_type_td" id="code_serach_vaccine_type_td_<?php echo $key + 1 ;?>">
616 <label><?php echo htmlspecialchars( xl('CVX Code'), ENT_QUOTES);?></label>
617 <?php $key_cvx = ($key > 0) ? (($key*2) + 3) : ($key + 3);?>
618 <input type="text" id="cvx_code<?php echo $key_cvx ;?>" name="cvx_vac_type_code[]" onclick="sel_cvxcode(this);"
619 value="<?php if($id != 0 && $value['imo_criteria'] == 'vaccine_type') echo attr($value['imo_code']);?>" style="width:140px;" />
620 <div class="imm-imm-add-12" id="imm-imm-add-12<?php echo $key_cvx ;?>"><?php if($id != 0 && $value['imo_criteria'] == 'vaccine_type') echo text($value['imo_codetext']);?></div>
621 <input type="hidden" value="CVX" name="code_type_hidden[]" id="code_type_hidden<?php echo $key_cvx ;?>" />
622 <input type="hidden" class="code_text_hidden" name="code_text_hidden[]" id="code_text_hidden<?php echo $key_cvx ;?>" value="<?php if($id != 0 && $value['imo_criteria'] == 'vaccine_type') echo attr($value['imo_codetext']);?>"/>
623 </td>
624 <td <?php if($value['imo_criteria'] != 'vaccine_type' || $id == 0) { ?> style="display: none;" <?php } ?> class="vis_published_date_td" id="vis_published_date_td_<?php echo $key + 1 ;?>">
625 <label><?php echo htmlspecialchars( xl('Date VIS Published'), ENT_QUOTES); ?></label>
626 <?php
627 $vis_published_dateval = $value['imo_vis_date_published'] ? htmlspecialchars( $value['imo_vis_date_published'], ENT_QUOTES) : '';
629 <input type="text" name="vis_published_date[]" value="<?php if($id != 0 && $vis_published_dateval != 0) echo attr($vis_published_dateval);?>" id="vis_published_date_<?php echo $key + 1 ;?>" autocomplete="off" onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc);' style="width:140px">
630 <img src='<?php echo $rootdir; ?>/pic/show_calendar.gif' align='absbottom' width='24' height='22' id='img_immuniz_vis_date_published_<?php echo $key + 1 ;?>' border='0' alt='[?]' style='cursor:pointer;cursor:hand' title='<?php echo htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES); ?>'>
631 </td>
632 <td <?php if($value['imo_criteria'] != 'vaccine_type' || $id == 0) { ?> style="display: none;" <?php } ?> class="vis_presented_date_td" id="vis_presented_date_td_<?php echo $key + 1 ;?>">
633 <label><?php echo htmlspecialchars( xl('Date VIS Presented'), ENT_QUOTES); ?></label>
634 <?php
635 $vis_presented_dateval = $value['imo_vis_date_presented'] ?htmlspecialchars( $value['imo_vis_date_presented'], ENT_QUOTES) : '';
637 <input type="text" name="vis_presented_date[]" value="<?php if($id != 0 && $vis_presented_dateval !=0) echo attr($vis_presented_dateval);?>" id="vis_presented_date_<?php echo $key + 1 ;?>" autocomplete="off" onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc);' style="width:140px">
638 <img src='<?php echo $rootdir; ?>/pic/show_calendar.gif' align='absbottom' width='24' height='22' id='img_immuniz_vis_date_presented_<?php echo $key + 1 ;?>' border='0' alt='[?]' style='cursor:pointer;cursor:hand' title='<?php echo htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES); ?>'>
639 </td>
640 <?php if($key != 0 && $id != 0) {?>
641 <td>
642 <img src='../../pic/remove.png' id ="<?php echo $key +1;?>" onclick="RemoveRow(this.id);" align='absbottom' width='24' height='22' border='0' style='cursor:pointer;cursor:hand' title='<?php echo xla('Click here to delete the row'); ?>'>
643 </td>
644 <?php } ?>
645 </tr>
646 <?php }
647 }else{?>
648 <tr id="or_tr_1">
649 <td id="observation_criteria_td_1">
650 <label><?php echo htmlspecialchars( xl('Observation Criteria'), ENT_QUOTES); ?></label>
651 <select id="observation_criteria_1" name="observation_criteria[]" onchange="selectCriteria(this.id,this.value);" style="width: 220px;">
652 <?php foreach ($observation_criteria as $keyo=> $valo) { ?>
653 <option value="<?php echo attr($valo['option_id']);?>" <?php if($valo['option_id'] == $value['imo_criteria'] && $id !=0) echo 'selected = "selected"' ;?> ><?php echo text($valo['title']);?></option>
654 <?php }
656 </select>
657 </td>
658 <td <?php if($value['imo_criteria'] != 'funding_program_eligibility') { ?> style="display: none;" <?php } ?> class="observation_criteria_value_td" id="observation_criteria_value_td_1">
659 <label><?php echo htmlspecialchars( xl('Observation Criteria Value'), ENT_QUOTES); ?></label>
660 <select id="observation_criteria_value_1" name="observation_criteria_value[]" style="width: 220px;">
661 <?php foreach ($observation_criteria_value as $keyoc=> $valoc) { ?>
662 <option value="<?php echo attr($valoc['option_id']);?>" <?php if($valoc['option_id'] == $value['imo_criteria_value'] && $id != 0) echo 'selected = "selected"' ;?>><?php echo text($valoc['title']);?></option>
663 <?php }
665 </select>
666 </td>
667 <td <?php if($value['imo_criteria'] != 'disease_with_presumed_immunity' || $id == 0) { ?> style="display: none;" <?php } ?> class="code_serach_td" id="code_search_td_1">
668 <label><?php echo htmlspecialchars( xl('SNOMED-CT Code'), ENT_QUOTES);?></label>
669 <input type="text" id="sct_code_2" style="width:140px" name="sct_code[]" class="code" value="<?php if($id != 0 && $value['imo_criteria'] == 'disease_with_presumed_immunity') echo attr($value['imo_code']);?>" onclick='sel_code(this.id);'><br>
670 <span id="displaytext_2" style="width:210px !important;display: block;font-size:13px;color: blue;" class="displaytext"><?php echo text($value['imo_codetext']);?></span>
671 <input type="hidden" id="codetext_2" name="codetext[]" class="codetext" value="<?php echo attr($value['imo_codetext']); ?>">
672 <input type="hidden" value="SNOMED-CT" name="codetypehidden[]" id="codetypehidden2" />
673 </td>
674 <td <?php if($value['imo_criteria'] != 'vaccine_type' || $id == 0) { ?> style="display: none;" <?php } ?> class="code_serach_vaccine_type_td" id="code_serach_vaccine_type_td_1">
675 <label><?php echo htmlspecialchars( xl('CVX Code'), ENT_QUOTES);?></label>
676 <input type="text" id="cvx_code3" name="cvx_vac_type_code[]" onclick="sel_cvxcode(this);"
677 value="<?php if($id != 0 && $value['imo_criteria'] == 'vaccine_type') echo attr($value['imo_code']);?>" style="width:140px;" />
678 <div class="imm-imm-add-12" id="imm-imm-add-123"><?php if($id != 0 && $value['imo_criteria'] == 'vaccine_type') echo text($value['imo_codetext']);?></div>
679 <input type="hidden" value="CVX" name="code_type_hidden[]" id="code_type_hidden3"/>
680 <input type="hidden" class="code_text_hidden" name="code_text_hidden[]" id="code_text_hidden3" value="<?php if($id != 0 && $value['imo_criteria'] == 'vaccine_type') echo attr($value['imo_codetext']);?>"/>
681 </td>
682 <td <?php if($value['imo_criteria'] != 'vaccine_type' || $id == 0) { ?> style="display: none;" <?php } ?> class="vis_published_date_td" id="vis_published_date_td_1">
683 <label><?php echo htmlspecialchars( xl('Date VIS Published'), ENT_QUOTES); ?></label>
684 <?php
685 $vis_published_dateval = $value['imo_vis_date_published'] ? htmlspecialchars( $value['imo_vis_date_published'], ENT_QUOTES) : '';
687 <input type="text" name="vis_published_date[]" value="<?php if($id != 0 && $vis_published_dateval != 0) echo attr($vis_published_dateval);?>" id="vis_published_date_1" autocomplete="off" onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc);' style="width:140px">
688 <img src='<?php echo $rootdir; ?>/pic/show_calendar.gif' align='absbottom' width='24' height='22' id='img_immuniz_vis_date_published_1' border='0' alt='[?]' style='cursor:pointer;cursor:hand' title='<?php echo htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES); ?>'>
689 </td>
690 <td <?php if($value['imo_criteria'] != 'vaccine_type' || $id == 0) { ?> style="display: none;" <?php } ?> class="vis_presented_date_td" id="vis_presented_date_td_1">
691 <label><?php echo htmlspecialchars( xl('Date VIS Presented'), ENT_QUOTES); ?></label>
692 <?php
693 $vis_presented_dateval = $value['imo_vis_date_presented'] ?htmlspecialchars( $value['imo_vis_date_presented'], ENT_QUOTES) : '';
695 <input type="text" name="vis_presented_date[]" value="<?php if($id != 0 && $vis_presented_dateval !=0) echo attr($vis_presented_dateval);?>" id="vis_presented_date_1" autocomplete="off" onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc);' style="width:140px">
696 <img src='<?php echo $rootdir; ?>/pic/show_calendar.gif' align='absbottom' width='24' height='22' id='img_immuniz_vis_date_presented_1' border='0' alt='[?]' style='cursor:pointer;cursor:hand' title='<?php echo htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES); ?>'>
697 </td>
698 </tr>
699 <?php }?>
700 </table>
701 <div>
702 <center style="cursor: pointer;">
703 <img src='../../pic/add.png' onclick="addNewRow();" align='absbottom' width='27' height='24' border='0' style='cursor:pointer;cursor:hand' title='<?php echo xla('Click here to add new row'); ?>'>
704 </center>
705 </div>
706 <input type ="hidden" name="tr_count" id="tr_count" value="<?php echo (count($imm_obs_data)>0) ? count($imm_obs_data) : 1 ;?>">
707 <input type="hidden" id="clickId" value="">
708 </fieldset>
709 </div>
710 </td>
711 </tr>
712 <tr>
713 <td colspan="3" align="center">
715 <input type="button" name="save" id="save" value="<?php echo htmlspecialchars( xl('Save Immunization'), ENT_QUOTES); ?>">
717 <input type="button" name="print" id="print" value="<?php echo htmlspecialchars( xl('Print Record') . xl('PDF','',' (',')'), ENT_QUOTES); ?>">
719 <input type="button" name="printHtml" id="printHtml" value="<?php echo htmlspecialchars( xl('Print Record') . xl('HTML','',' (',')'), ENT_QUOTES); ?>">
721 <input type="reset" name="clear" id="clear" value="<?php echo htmlspecialchars( xl('Clear'), ENT_QUOTES); ?>"> </td>
722 </tr>
723 </table>
724 </form>
726 <div id="immunization_list">
728 <table border=0 cellpadding=3 cellspacing=0>
730 <!-- some columns are sortable -->
731 <tr class='text bold'>
732 <th>
733 <a href="javascript:top.restoreSession();location.href='immunizations.php?sortby=vacc';" title='<?php echo htmlspecialchars( xl('Sort by vaccine'), ENT_QUOTES); ?>'>
734 <?php echo htmlspecialchars( xl('Vaccine'), ENT_NOQUOTES); ?></a>
735 <span class='small' style='font-family:arial'><?php if ($sortby == 'vacc') { echo 'v'; } ?></span>
736 </th>
737 <th>
738 <a href="javascript:top.restoreSession();location.href='immunizations.php?sortby=date';" title='<?php echo htmlspecialchars( xl('Sort by date'), ENT_QUOTES); ?>'>
739 <?php echo htmlspecialchars( xl('Date'), ENT_NOQUOTES); ?></a>
740 <span class='small' style='font-family:arial'><?php if ($sortby == 'date') { echo 'v'; } ?></span>
741 </th>
742 <th><?php echo htmlspecialchars( xl('Amount'), ENT_NOQUOTES); ?></th>
743 <th><?php echo xlt('Expiration'); ?></th>
744 <th><?php echo htmlspecialchars( xl('Manufacturer'), ENT_NOQUOTES); ?></th>
745 <th><?php echo htmlspecialchars( xl('Lot Number'), ENT_NOQUOTES); ?></th>
746 <th><?php echo htmlspecialchars( xl('Administered By'), ENT_NOQUOTES); ?></th>
747 <th><?php echo htmlspecialchars( xl('Education Date'), ENT_NOQUOTES); ?></th>
748 <th><?php echo htmlspecialchars( xl('Route'), ENT_NOQUOTES); ?></th>
749 <th><?php echo htmlspecialchars( xl('Administered Site'), ENT_NOQUOTES); ?></th>
750 <th><?php echo htmlspecialchars( xl('Notes'), ENT_NOQUOTES); ?></th>
751 <th><?php echo htmlspecialchars( xl('Completion Status'), ENT_NOQUOTES); ?></th>
752 <th><?php echo htmlspecialchars( xl('Error'), ENT_NOQUOTES); ?></th>
753 <th>&nbsp;</th>
754 </tr>
756 <?php
757 $result = getImmunizationList($pid, $_GET['sortby'], true);
759 while($row = sqlFetchArray($result)) {
760 $isError = $row['added_erroneously'];
762 if ($isError) {
763 $tr_title = 'title="' . xla("Entered in Error") . '"';
764 } else {
765 $tr_title = "";
768 if ($row["id"] == $id) {
769 echo "<tr " . $tr_title . " class='immrow text selected' id='".htmlspecialchars( $row["id"], ENT_QUOTES)."'>";
771 else {
772 echo "<tr " . $tr_title . " class='immrow text' id='".htmlspecialchars( $row["id"], ENT_QUOTES)."'>";
775 // Figure out which name to use (ie. from cvx list or from the custom list)
776 if ($GLOBALS['use_custom_immun_list']) {
777 $vaccine_display = generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']);
779 else {
780 if (!empty($row['code_text_short'])) {
781 $vaccine_display = htmlspecialchars( xl($row['code_text_short']), ENT_NOQUOTES);
783 else {
784 $vaccine_display = generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']);
788 if ($isError) {
789 $del_tag_open = "<del>";
790 $del_tag_close = "</del>";
791 } else {
792 $del_tag_open = "";
793 $del_tag_close = "";
796 echo "<td>" . $del_tag_open . $vaccine_display . $del_tag_close . "</td>";
798 if ($row["administered_date"]) {
799 $administered_date_summary = new DateTime($row['administered_date']);
800 $administered_date_summary = $administered_date_summary->format('Y-m-d H:i');
801 } else {
802 $administered_date_summary = "";
804 echo "<td>" . $del_tag_open . htmlspecialchars( $administered_date_summary, ENT_NOQUOTES) . $del_tag_close . "</td>";
805 if ($row["amount_administered"] > 0) {
806 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>";
808 else {
809 echo "<td>&nbsp</td>";
811 echo "<td>" . $del_tag_open . text($row["expiration_date"]) . $del_tag_close . "</td>";
812 echo "<td>" . $del_tag_open . htmlspecialchars( $row["manufacturer"], ENT_NOQUOTES) . $del_tag_close . "</td>";
813 echo "<td>" . $del_tag_open . htmlspecialchars( $row["lot_number"], ENT_NOQUOTES) . $del_tag_close . "</td>";
814 echo "<td>" . $del_tag_open . htmlspecialchars( $row["administered_by"], ENT_NOQUOTES) . $del_tag_close . "</td>";
815 echo "<td>" . $del_tag_open . htmlspecialchars( $row["education_date"], ENT_NOQUOTES) . $del_tag_close . "</td>";
816 echo "<td>" . $del_tag_open . generate_display_field(array('data_type'=>'1','list_id'=>'drug_route'), $row['route']) . $del_tag_close . "</td>";
817 echo "<td>" . $del_tag_open . generate_display_field(array('data_type'=>'1','list_id'=>'immunization_administered_site'), $row['administration_site']) . $del_tag_close . "</td>";
818 echo "<td>" . $del_tag_open . htmlspecialchars( $row["note"], ENT_NOQUOTES) . $del_tag_close . "</td>";
819 echo "<td>" . $del_tag_open . generate_display_field(array('data_type'=>'1','list_id'=>'Immunization_Completion_Status'), $row['completion_status']) . $del_tag_close . "</td>";
821 if ($isError) {
822 $checkbox = "checked";
823 } else {
824 $checkbox = "";
827 echo "<td><input type='checkbox' class='error' id='".htmlspecialchars( $row["id"], ENT_QUOTES)."' value='" . htmlspecialchars( xl('Error'), ENT_QUOTES) . "' " . $checkbox . "></td>";
829 echo "<td><input type='button' class='delete' id='".htmlspecialchars( $row["id"], ENT_QUOTES)."' value='" . htmlspecialchars( xl('Delete'), ENT_QUOTES) . "'></td>";
830 echo "</tr>";
835 </table>
836 </div> <!-- end immunizations -->
838 </body>
840 <script language="javascript">
841 var tr_count = $('#tr_count').val();
842 /* required for popup calendar */
843 Calendar.setup({inputField:"administered_date", ifFormat:"%Y-%m-%d %H:%M", button:"img_administered_date", showsTime:true});
844 Calendar.setup({inputField:"immuniz_exp_date", ifFormat:"%Y-%m-%d", button:"img_immuniz_exp_date"});
845 Calendar.setup({inputField:"education_date", ifFormat:"%Y-%m-%d", button:"img_education_date"});
846 Calendar.setup({inputField:"vis_date", ifFormat:"%Y-%m-%d", button:"img_vis_date"});
847 Calendar.setup({inputField:"vis_published_date_"+tr_count, ifFormat:"%Y-%m-%d", button:"img_immuniz_vis_date_published_"+tr_count});
848 Calendar.setup({inputField:"vis_presented_date_"+tr_count, ifFormat:"%Y-%m-%d", button:"img_immuniz_vis_date_presented_"+tr_count});
850 // jQuery stuff to make the page a little easier to use
852 $(document).ready(function(){
853 <?php if (!($useCVX)) { ?>
854 $("#save").click(function() { SaveForm(); });
855 <?php } else { ?>
856 $("#save").click(function() {
857 if (validate_cvx()) {
858 SaveForm();
860 else {
861 return;
864 <?php } ?>
865 $("#print").click(function() { PrintForm("pdf"); });
866 $("#printHtml").click(function() { PrintForm("html"); });
867 $(".immrow").click(function() { EditImm(this); });
868 $(".error").click(function(event) { ErrorImm(this); event.stopPropagation(); });
869 $(".delete").click(function(event) { DeleteImm(this); event.stopPropagation(); });
871 $(".immrow").mouseover(function() { $(this).toggleClass("highlight"); });
872 $(".immrow").mouseout(function() { $(this).toggleClass("highlight"); });
874 $("#administered_by_id").change(function() { $("#administered_by").val($("#administered_by_id :selected").text()); });
876 $("#form_immunization_id").change( function() {
877 if ( $(this).val() != "" ) {
878 $("#cvx_code").val( "" );
879 $("#cvx_description").text( "" );
880 $("#cvx_code").change();
885 var PrintForm = function(typ) {
886 top.restoreSession();
887 newURL='shot_record.php?output='+typ+'&sortby=<?php echo $sortby; ?>';
888 window.open(newURL, '_blank', "menubar=1,toolbar=1,scrollbars=1,resizable=1,width=600,height=450");
891 var SaveForm = function() {
892 top.restoreSession();
893 $("#add_immunization").submit();
896 var EditImm = function(imm) {
897 top.restoreSession();
898 location.href='immunizations.php?mode=edit&id='+imm.id;
901 var DeleteImm = function(imm) {
902 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); ?>")) {
903 top.restoreSession();
904 location.href='immunizations.php?mode=delete&id='+imm.id;
908 var ErrorImm = function(imm) {
909 top.restoreSession();
910 location.href='immunizations.php?mode=added_error&id='+imm.id+'&isError='+imm.checked;
913 //This is for callback by the find-code popup.
914 //Appends to or erases the current list of diagnoses.
915 function set_related(codetype, code, selector, codedesc) {
916 if(codetype == 'CVX') {
917 var f = document.forms[0][current_sel_name];
918 if(!f.length) {
919 var s = f.value;
921 if (code) {
922 s = code;
924 else {
925 s = '';
928 f.value = s;
929 if(f.name != 'cvx_vac_type_code[]'){
930 $("#cvx_description").text( codedesc );
931 $("#form_immunization_id").attr( "value", "" );
932 $("#form_immunization_id").change();
933 }else{
934 id_arr = f.id.split('cvx_code');
935 counter = id_arr[1];
936 $('#imm-imm-add-12'+counter).html(codedesc);
937 $('#code_text_hidden'+counter).val(codedesc);
939 }else {
940 var index = document.forms[0][current_sel_name].length -1;
941 var elem = document.forms[0][current_sel_name][index];
942 var ss = elem.value;
943 if (code) {
944 ss = code;
946 else {
947 ss = '';
950 elem.value = ss;
951 arr = elem.id.split('cvx_code');
952 count = arr[1];
953 $('#imm-imm-add-12'+count).html(codedesc);
954 $('#code_text_hidden'+count).val(codedesc);
956 }else {
957 var checkId = $('#clickId').val();
958 $("#sct_code_" + checkId).val(code);
959 $("#codetext_" + checkId).val(codedesc);
960 $("#displaytext_" + checkId).html(codedesc);
964 // This invokes the find-code popup.
965 function sel_cvxcode(e) {
966 current_sel_name = e.name;
967 dlgopen('../encounter/find_code_popup.php?codetype=CVX', '_blank', 500, 400);
970 // This ensures the cvx centric entry is filled.
971 function validate_cvx() {
972 if (document.add_immunization.cvx_code.value>0) {
973 return true;
975 else {
976 document.add_immunization.cvx_code.style.backgroundColor="red";
977 document.add_immunization.cvx_code.focus();
978 return false;
982 function showObservationResultSection()
984 $('.observation_results').slideToggle();
987 function selectCriteria(id,value)
989 var arr = id.split('observation_criteria_');
990 var key = arr[1];
991 if(value == 'funding_program_eligibility') {
992 $('.obs_res_table').css('width','50%');
993 if(key > 1) {
994 var target = $("#observation_criteria_value_"+key);
995 $.ajax({
996 type: "POST",
997 url: "immunizations.php",
998 dataType: "json",
999 data: {
1000 type : 'duplicate_row_2'
1002 success: function(thedata){
1003 $.each(thedata,function(i,item) {
1004 target.append($('<option />').val(item.option_id).text(item.title));
1006 $('#observation_criteria_value_'+key+' option[value=""]').attr('selected','selected');
1008 error:function(){
1009 alert("ajax error");
1013 $("#code_search_td_"+key).hide();
1014 $("#vis_published_date_td_"+key).hide();
1015 $("#vis_presented_date_td_"+key).hide();
1016 $("#code_serach_vaccine_type_td_"+key).hide();
1017 $("#observation_criteria_value_td_"+key).show();
1019 if(value == 'vaccine_type')
1021 $("#observation_criteria_value_td_"+key).hide();
1022 $("#code_search_td_"+key).hide();
1023 $("#code_serach_vaccine_type_td_"+key).show();
1024 $("#vis_published_date_td_"+key).show();
1025 $("#vis_presented_date_td_"+key).show();
1026 if(key == 1) {
1027 key = parseInt(key) + 2;
1029 else {
1030 key = (parseInt(key) * 2) + 1;
1032 $("#cvx_code"+key).css("background-color", "red");
1033 $("#cvx_code"+key).focus();
1034 return false;
1036 if(value == 'disease_with_presumed_immunity')
1038 $('.obs_res_table').css('width','50%');
1039 $("#observation_criteria_value_td_"+key).hide();
1040 $("#vis_published_date_td_"+key).hide();
1041 $("#vis_presented_date_td_"+key).hide();
1042 $("#code_serach_vaccine_type_td_"+key).hide();
1043 $("#code_search_td_"+key).show();
1044 if(key == 1) {
1045 key = parseInt(key) + 1;
1047 else {
1048 key = (parseInt(key) * 2);
1050 $("#sct_code_"+key).css("background-color", "red");
1051 $("#sct_code_"+key).focus();
1052 return false;
1054 if(value == '')
1056 $("#observation_criteria_value_td_"+key).hide();
1057 $("#vis_published_date_td_"+key).hide();
1058 $("#vis_presented_date_td_"+key).hide();
1059 $("#code_serach_vaccine_type_td_"+key).hide();
1060 $("#code_search_td_"+key).hide();
1064 function RemoveRow(id)
1066 tr_count = parseInt($("#tr_count").val());
1067 new_tr_count = tr_count-1;
1068 $("#tr_count").val(new_tr_count);
1069 $("#or_tr_"+id).remove();
1072 function addNewRow()
1074 tr_count = parseInt($("#tr_count").val());
1075 new_tr_count = tr_count+1;
1076 new_tr_count_2 = (new_tr_count * 2);
1077 new_tr_count_3 = (new_tr_count *2) + 1;
1078 $("#tr_count").val(new_tr_count);
1079 label1 = "<?php echo htmlspecialchars( xl('Observation Criteria'), ENT_QUOTES); ?>";
1080 label2 = "<?php echo htmlspecialchars( xl('Observation Criteria Value'), ENT_QUOTES); ?>";
1081 label3 = "<?php echo htmlspecialchars( xl('SNOMED-CT Code'), ENT_QUOTES); ?>";
1082 label4 = "<?php echo htmlspecialchars( xl('CVX Code'), ENT_QUOTES); ?>";
1083 label5 = "<?php echo htmlspecialchars( xl('Date VIS Published'), ENT_QUOTES); ?>";
1084 label6 = "<?php echo htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES); ?>";
1085 label7 = "<?php echo htmlspecialchars( xl('Date VIS Presented'), ENT_QUOTES); ?>";
1086 label8 = "<?php echo htmlspecialchars( xl('Click here to choose a date'), ENT_QUOTES); ?>";
1087 label9 = "<?php echo htmlspecialchars( xl('Click here to delete the row'), ENT_QUOTES); ?>";
1088 str = '<tr id ="or_tr_'+new_tr_count+'">'+
1089 '<td id ="observation_criteria_td_'+new_tr_count+'"><label>'+label1+'</label><select id="observation_criteria_'+new_tr_count+'" name="observation_criteria[]" onchange="selectCriteria(this.id,this.value);" style="width: 220px;"></select>'+
1090 '</td>'+
1091 '<td id="observation_criteria_value_td_'+new_tr_count+'" class="observation_criteria_value_td" style="display: none;"><label>'+label2+'</label><select name="observation_criteria_value[]" id="observation_criteria_value_'+new_tr_count+'" style="width: 220px;"></select>'+
1092 '</td>'+
1093 '<td class="code_serach_td" id="code_search_td_'+new_tr_count+'" style="display: none;"><label>'+label3+'</label>'+
1094 '<input type="text" id="sct_code_'+new_tr_count_2+'" style="width:140px" name="sct_code[]" class="code" onclick=sel_code(this.id) /><br>'+
1095 '<span id="displaytext_'+new_tr_count_2+'" style="width:210px !important;display: block;font-size:13px;color: blue;" class="displaytext"></span>'+
1096 '<input type="hidden" id="codetext_'+new_tr_count_2+'" name="codetext[]" class="codetext">'+
1097 '<input type="hidden" value="SNOMED-CT" name="codetypehidden[]" id="codetypehidden'+new_tr_count_2+'" /> '+
1098 '</td>'+
1099 '<td class="code_serach_vaccine_type_td" id="code_serach_vaccine_type_td_'+new_tr_count+'" style="display: none;"><label>'+label4+'</label>'+
1100 '<input type="text" id="cvx_code'+new_tr_count_3+'" name="cvx_vac_type_code[]" onclick=sel_cvxcode(this); style="width:140px;" />'+
1101 '<div class="imm-imm-add-12" id="imm-imm-add-12'+new_tr_count_3+'"></div> '+
1102 '<input type="hidden" value="CVX" name="code_type_hidden[]" id="code_type_hidden'+new_tr_count_3+'" /> '+
1103 '<input type="hidden" class="code_text_hidden" name="code_text_hidden[]" id="code_text_hidden'+new_tr_count_3+'" value="" />'+
1104 '</td>'+
1105 '<td id="vis_published_date_td_'+new_tr_count+'" class="vis_published_date_td" style="display: none;"><label>'+label5+'</label><input type="text" name= "vis_published_date[]" id ="vis_published_date_'+new_tr_count+'" autocomplete=off onkeyup="datekeyup(this,mypcc)" onblur="dateblur(this,mypcc);" style="width:140px">'+
1106 '<img src="../../pic/show_calendar.gif" align="absbottom" width="24" height="22" id="img_immuniz_vis_date_published_'+new_tr_count+'" border="0" alt="[?]" style="cursor:pointer;cursor:hand" title="'+label6+'"></td>'+
1107 '<td id="vis_presented_date_td_'+new_tr_count+'" class="vis_presented_date_td" style="display: none;"><label>'+label7+'</label><input type="text" name= "vis_presented_date[]" id ="vis_presented_date_'+new_tr_count+'" autocomplete=off onkeyup="datekeyup(this,mypcc)" onblur="dateblur(this,mypcc);" style="width:140px">'+
1108 '<img src="../../pic/show_calendar.gif" align="absbottom" width="24" height="22" id="img_immuniz_vis_date_presented_'+new_tr_count+'" border="0" alt="[?]" style="cursor:pointer;cursor:hand" title="'+label8+'"></td>'+
1109 '<td><img src="../../pic/remove.png" id ="'+new_tr_count+'" onclick="RemoveRow(this.id);" align="absbottom" width="24" height="22" border="0" style="cursor:pointer;cursor:hand" title="'+label9+'"></td></tr>';
1111 $(".obs_res_table").append(str);
1113 var ajax_url = 'immunizations.php';
1114 var target = $("#observation_criteria_"+new_tr_count);
1115 $.ajax({
1116 type: "POST",
1117 url: ajax_url,
1118 dataType: "json",
1119 data: {
1120 type : 'duplicate_row'
1122 success: function(thedata){
1123 $.each(thedata,function(i,item) {
1124 target.append($('<option></option>').val(item.option_id).text(item.title));
1126 $('#observation_criteria_'+new_tr_count+' option[value=""]').attr('selected','selected');
1128 error:function(){
1129 alert("ajax error");
1133 Calendar.setup({inputField:"vis_published_date_"+new_tr_count, ifFormat:"%Y-%m-%d", button:"img_immuniz_vis_date_published_"+new_tr_count});
1134 Calendar.setup({inputField:"vis_presented_date_"+new_tr_count, ifFormat:"%Y-%m-%d", button:"img_immuniz_vis_date_presented_"+new_tr_count});
1137 function sel_code(id)
1139 id = id.split('sct_code_');
1140 var checkId = id[1];
1141 $('#clickId').val(checkId);
1142 dlgopen('<?php echo $GLOBALS['webroot'] . "/interface/patient_file/encounter/" ?>find_code_popup.php', '_blank', 700, 400);
1144 </script>
1146 </html>