Highway to PSR2
[openemr.git] / interface / patient_file / summary / immunizations.php
blobfe9b7fef675639ef120fcdd15ed15dcb422515f0
1 <?php
2 /**
3 * Immunizations
6 * LICENSE: This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
17 * @package OpenEMR
18 * @author Brady Miller <brady.g.miller@gmail.com>
19 * @link http://www.open-emr.org
25 include_once("../../globals.php");
26 include_once("$srcdir/options.inc.php");
27 include_once("$srcdir/immunization_helper.php");
29 if (isset($_GET['mode'])) {
31 * THIS IS A BUG. IF NEW IMMUN IS ADDED AND USER PRINTS PDF,
32 * WHEN BACK IS CLICKED, ANOTHER ITEM GETS ADDED
35 if ($_GET['mode'] == "add") {
36 $sql = "REPLACE INTO immunizations set
37 id = ?,
38 administered_date = if(?,?,NULL),
39 immunization_id = ?,
40 cvx_code = ?,
41 manufacturer = ?,
42 lot_number = ?,
43 administered_by_id = if(?,?,NULL),
44 administered_by = if(?,?,NULL),
45 education_date = if(?,?,NULL),
46 vis_date = if(?,?,NULL),
47 note = ?,
48 patient_id = ?,
49 created_by = ?,
50 updated_by = ?,
51 create_date = now(),
52 amount_administered = ?,
53 amount_administered_unit = ?,
54 expiration_date = if(?,?,NULL),
55 route = ?,
56 administration_site = ? ,
57 completion_status = ?,
58 information_source = ?,
59 refusal_reason = ?,
60 ordering_provider = ?";
61 $sqlBindArray = array(
62 trim($_GET['id']),
63 trim($_GET['administered_date']), trim($_GET['administered_date']),
64 trim($_GET['form_immunization_id']),
65 trim($_GET['cvx_code']),
66 trim($_GET['manufacturer']),
67 trim($_GET['lot_number']),
68 trim($_GET['administered_by_id']), trim($_GET['administered_by_id']),
69 trim($_GET['administered_by']), trim($_GET['administered_by']),
70 trim($_GET['education_date']), trim($_GET['education_date']),
71 trim($_GET['vis_date']), trim($_GET['vis_date']),
72 trim($_GET['note']),
73 $pid,
74 $_SESSION['authId'],
75 $_SESSION['authId'],
76 trim($_GET['immuniz_amt_adminstrd']),
77 trim($_GET['form_drug_units']),
78 trim($_GET['immuniz_exp_date']), trim($_GET['immuniz_exp_date']),
79 trim($_GET['immuniz_route']),
80 trim($_GET['immuniz_admin_ste']),
81 trim($_GET['immuniz_completion_status']),
82 trim($_GET['immunization_informationsource']),
83 trim($_GET['immunization_refusal_reason']),
84 trim($_GET['ordered_by_id'])
86 $newid = sqlInsert($sql, $sqlBindArray);
87 $administered_date=date('Y-m-d H:i');
88 $education_date=date('Y-m-d');
89 $immunization_id=$cvx_code=$manufacturer=$lot_number=$administered_by_id=$note=$id=$ordered_by_id="";
90 $administered_by=$vis_date="";
91 $newid = $_GET['id'] ? $_GET['id'] : $newid;
92 if ($GLOBALS['observation_results_immunization']) {
93 saveImmunizationObservationResults($newid, $_GET);
95 } elseif ($_GET['mode'] == "delete") {
96 // log the event
97 newEvent("delete", $_SESSION['authUser'], $_SESSION['authProvider'], 1, "Immunization id ".$_GET['id']." deleted from pid ".$pid);
98 // delete the immunization
99 $sql="DELETE FROM immunizations WHERE id =? LIMIT 1";
100 sqlStatement($sql, array($_GET['id']));
101 } elseif ($_GET['mode'] == "added_error") {
102 $sql = "UPDATE immunizations " .
103 "SET added_erroneously=? " .
104 "WHERE id=?";
105 $sql_arg_array = array(
106 ($_GET['isError'] === 'true'),
107 $_GET['id']
109 sqlStatement($sql, $sql_arg_array);
110 } elseif ($_GET['mode'] == "edit") {
111 $sql = "select * from immunizations where id = ?";
112 $result = sqlQuery($sql, array($_GET['id']));
114 $administered_date = new DateTime($result['administered_date']);
115 $administered_date = $administered_date->format('Y-m-d H:i');
117 $immuniz_amt_adminstrd = $result['amount_administered'];
118 $drugunitselecteditem = $result['amount_administered_unit'];
119 $immunization_id = $result['immunization_id'];
120 $immuniz_exp_date = $result['expiration_date'];
122 $cvx_code = $result['cvx_code'];
123 $code_text = '';
124 if (!(empty($cvx_code))) {
125 $query = "SELECT codes.code_text as `code_text`, codes.code as `code` " .
126 "FROM codes " .
127 "LEFT JOIN code_types on codes.code_type = code_types.ct_id " .
128 "WHERE code_types.ct_key = 'CVX' AND codes.code = ?";
129 $result_code_text = sqlQuery($query, array($cvx_code));
130 $code_text = $result_code_text['code_text'];
133 $manufacturer = $result['manufacturer'];
134 $lot_number = $result['lot_number'];
135 $administered_by_id = ($result['administered_by_id'] ? $result['administered_by_id'] : 0);
136 $ordered_by_id = ($result['ordering_provider'] ? $result['ordering_provider'] : 0);
137 $entered_by_id = ($result['created_by'] ? $result['created_by'] : 0);
139 $administered_by = "";
140 if (!$result['administered_by'] && !$row['administered_by_id']) {
141 $stmt = "select CONCAT(IFNULL(lname,''), ' ,',IFNULL(fname,'')) as full_name ".
142 "from users where ".
143 "id=?";
144 $user_result = sqlQuery($stmt, array($result['administered_by_id']));
145 $administered_by = $user_result['full_name'];
148 $education_date = $result['education_date'];
149 $vis_date = $result['vis_date'];
150 $immuniz_route = $result['route'];
151 $immuniz_admin_ste = $result['administration_site'];
152 $note = $result['note'];
153 $isAddedError = $result['added_erroneously'];
155 $immuniz_completion_status = $result['completion_status'];
156 $immuniz_information_source = $result['information_source'];
157 $immuniz_refusal_reason = $result['refusal_reason'];
158 //set id for page
159 $id = $_GET['id'];
161 $imm_obs_data = getImmunizationObservationResults();
165 $observation_criteria = getImmunizationObservationLists('1');
166 $observation_criteria_value = getImmunizationObservationLists('2');
167 // Decide whether using the CVX list or the custom list in list_options
168 if ($GLOBALS['use_custom_immun_list']) {
169 // user forces the use of the custom list
170 $useCVX = false;
171 } else {
172 if ($_GET['mode'] == "edit") {
173 //depends on if a cvx code is enterer already
174 if (empty($cvx_code)) {
175 $useCVX = false;
176 } else {
177 $useCVX = true;
179 } else { // $_GET['mode'] == "add"
180 $useCVX = true;
184 // set the default sort method for the list of past immunizations
185 $sortby = $_GET['sortby'];
186 if (!$sortby) {
187 $sortby = 'vacc';
190 // set the default value of 'administered_by'
191 if (!$administered_by && !$administered_by_id) {
192 $stmt = "select CONCAT(IFNULL(lname,''), ' ,',IFNULL(fname,'')) as full_name ".
193 " from users where ".
194 " id=?";
195 $row = sqlQuery($stmt, array($_SESSION['authId']));
196 $administered_by = $row['full_name'];
199 // get the entered username
200 if ($entered_by_id) {
201 $stmt = "select CONCAT(IFNULL(lname,''), ' ,',IFNULL(fname,'')) as full_name ".
202 " from users where ".
203 " id=?";
204 $row = sqlQuery($stmt, array($entered_by_id));
205 $entered_by = $row['full_name'];
208 if ($_POST['type'] == 'duplicate_row') {
209 $observation_criteria = getImmunizationObservationLists('1');
210 echo json_encode($observation_criteria);
211 exit;
214 if ($_POST['type'] == 'duplicate_row_2') {
215 $observation_criteria_value = getImmunizationObservationLists('2');
216 echo json_encode($observation_criteria_value);
217 exit;
220 function getImmunizationObservationLists($k)
222 if ($k == 1) {
223 $observation_criteria_res = sqlStatement("SELECT * FROM list_options WHERE list_id = ? AND activity=1 ORDER BY seq, title", array('immunization_observation'));
224 for ($iter = 0; $row = sqlFetchArray($observation_criteria_res); $iter++) {
225 $observation_criteria[0]['option_id'] = '';
226 $observation_criteria[0]['title'] = 'Unassigned';
227 $observation_criteria[++$iter] = $row;
230 return $observation_criteria;
231 } else {
232 $observation_criteria_value_res = sqlStatement("SELECT * FROM list_options WHERE list_id = ? AND activity=1 ORDER BY seq, title", array('imm_vac_eligibility_results'));
233 for ($iter = 0; $row = sqlFetchArray($observation_criteria_value_res); $iter++) {
234 $observation_criteria_value[0]['option_id'] = '';
235 $observation_criteria_value[0]['title'] = 'Unassigned';
236 $observation_criteria_value[++$iter] = $row;
239 return $observation_criteria_value;
243 function getImmunizationObservationResults()
245 $obs_res_q = "SELECT
247 FROM
248 immunization_observation
249 WHERE imo_pid = ?
250 AND imo_im_id = ?";
251 $res = sqlStatement($obs_res_q, array($_SESSION["pid"],$_GET['id']));
252 for ($iter = 0; $row = sqlFetchArray($res); $iter++) {
253 $imm_obs_data[$iter] = $row;
256 return $imm_obs_data;
259 function saveImmunizationObservationResults($id, $immunizationdata)
261 $imm_obs_data = getImmunizationObservationResults();
262 if (count($imm_obs_data) > 0) {
263 foreach ($imm_obs_data as $key => $val) {
264 if ($val['imo_id'] && $val['imo_id'] != 0) {
265 $sql2 = " DELETE
266 FROM
267 immunization_observation
268 WHERE imo_im_id = ?
269 AND imo_pid = ?";
270 $result2 = sqlQuery($sql2, array($val['imo_im_id'],$val['imo_pid']));
275 for ($i = 0; $i < $immunizationdata['tr_count']; $i++) {
276 if ($immunizationdata['observation_criteria'][$i] == 'vaccine_type') {
277 $code = $immunizationdata['cvx_vac_type_code'][$i];
278 $code_text = $immunizationdata['code_text_hidden'][$i];
279 $code_type = $immunizationdata['code_type_hidden'][$i];
280 $vis_published_dateval = $immunizationdata['vis_published_date'][$i] ? $immunizationdata['vis_published_date'][$i] : '';
281 $vis_presented_dateval = $immunizationdata['vis_presented_date'][$i] ? $immunizationdata['vis_presented_date'][$i] : '';
282 $imo_criteria_value = '';
283 } else if ($immunizationdata['observation_criteria'][$i] == 'disease_with_presumed_immunity') {
284 $code = $immunizationdata['sct_code'][$i];
285 $code_text = $immunizationdata['codetext'][$i];
286 $code_type = $immunizationdata['codetypehidden'][$i];
287 $imo_criteria_value = '';
288 $vis_published_dateval = '';
289 $vis_presented_dateval = '';
290 } else if ($immunizationdata['observation_criteria'][$i] == 'funding_program_eligibility') {
291 $imo_criteria_value = $immunizationdata['observation_criteria_value'][$i];
292 $code = '';
293 $code_text = '';
294 $code_type = '';
295 $vis_published_dateval = '';
296 $vis_presented_dateval = '';
299 if ($immunizationdata['observation_criteria'][$i] != '') {
300 $sql = " INSERT INTO immunization_observation (
301 imo_im_id,
302 imo_pid,
303 imo_criteria,
304 imo_criteria_value,
305 imo_user,
306 imo_code,
307 imo_codetext,
308 imo_codetype,
309 imo_vis_date_published,
310 imo_vis_date_presented
312 VALUES
313 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
314 $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));
318 return;
321 <html>
322 <head>
323 <?php html_header_show();?>
325 <!-- supporting javascript code -->
326 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js?v=<?php echo $v_js_includes; ?>"></script>
327 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
328 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-9-1/index.js"></script>
329 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-ui-1-10-4/ui/jquery-ui.js"></script>
330 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script>
332 <!-- page styles -->
333 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
334 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-ui-1-10-4/themes/base/jquery-ui.css" type="text/css" />
335 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
336 <style>
337 .highlight {
338 color: green;
340 tr.selected {
341 background-color: white;
343 </style>
345 <script language="JavaScript">
346 // required to validate date text boxes
347 var mypcc = '<?php echo htmlspecialchars($GLOBALS['phone_country_code'], ENT_QUOTES); ?>';
348 </script>
350 </head>
352 <body class="body_top">
354 <span class="title"><?php echo htmlspecialchars(xl('Immunizations'), ENT_NOQUOTES); ?></span>
356 <form action="immunizations.php" name="add_immunization" id="add_immunization">
357 <input type="hidden" name="mode" id="mode" value="add">
358 <input type="hidden" name="id" id="id" value="<?php echo htmlspecialchars($id, ENT_QUOTES); ?>">
359 <input type="hidden" name="pid" id="pid" value="<?php echo htmlspecialchars($pid, ENT_QUOTES); ?>">
360 <br>
361 <table border=0 cellpadding=1 cellspacing=1>
362 <?php
363 if ($isAddedError) {
364 echo "<tr><font color='red'><b>" . xlt("Entered in Error") . "</b></font></tr>";
368 <?php if (!($useCVX)) { ?>
369 <tr>
370 <td align="right">
371 <span class=text>
372 <?php echo htmlspecialchars(xl('Immunization'), ENT_NOQUOTES); ?> </span> </td>
373 <td>
374 <?php
375 // Modified 7/2009 by BM to incorporate the immunization items into the list_options listings
376 generate_form_field(array('data_type'=>1,'field_id'=>'immunization_id','list_id'=>'immunizations','empty_title'=>'SKIP'), $immunization_id);
378 </td>
379 </tr>
380 <?php } else { ?>
381 <tr>
382 <td align="right" valign="top" style="padding-top:4px;">
383 <span class=text>
384 <?php echo htmlspecialchars(xl('Immunization'), ENT_NOQUOTES); ?> (<?php echo htmlspecialchars(xl('CVX Code'), ENT_NOQUOTES); ?>) </span> </td>
385 <td>
386 <input type='text' size='10' name='cvx_code' id='cvx_code'
387 value='<?php echo htmlspecialchars($cvx_code, ENT_QUOTES); ?>' onclick='sel_cvxcode(this)'
388 title='<?php echo htmlspecialchars(xl('Click to select or change CVX code'), ENT_QUOTES); ?>'
390 <div id='cvx_description' style='display:inline; float:right; padding:3px; margin-left:3px; width:400px'>
391 <?php echo htmlspecialchars(xl($code_text), ENT_QUOTES); ?> </div> </td>
392 </tr>
393 <?php } ?>
395 <tr>
396 <td align="right">
397 <span class=text>
398 <?php echo htmlspecialchars(xl('Date & Time Administered'), ENT_NOQUOTES); ?> </span> </td>
399 <td><table border="0">
400 <tr>
401 <td><input type='text' size='14' class='datetimepicker' name="administered_date" id="administered_date"
402 value='<?php echo $administered_date ? htmlspecialchars($administered_date, ENT_QUOTES) : date('Y-m-d H:i'); ?>'
403 title='<?php echo htmlspecialchars(xl('yyyy-mm-dd Hours(24):minutes'), ENT_QUOTES); ?>'
405 </td>
406 </tr>
407 </table></td>
408 </tr>
409 <tr>
410 <td align="right"><span class="text"><?php echo htmlspecialchars(xl('Amount Administered'), ENT_NOQUOTES); ?></span></td>
411 <td class='text'>
412 <input class='text' type='text' name="immuniz_amt_adminstrd" size="25" value="<?php echo htmlspecialchars($immuniz_amt_adminstrd, ENT_QUOTES); ?>">
413 <?php echo generate_select_list("form_drug_units", "drug_units", $drugunitselecteditem, 'Select Drug Unit', ''); ?>
414 </td>
415 </tr>
416 <tr>
417 <td align="right"><span class="text"><?php echo htmlspecialchars(xl('Immunization Expiration Date'), ENT_NOQUOTES); ?></span></td>
418 <td class='text'><input type='text' size='10' class='datepicker' name="immuniz_exp_date" id="immuniz_exp_date"
419 value='<?php echo $immuniz_exp_date ? htmlspecialchars($immuniz_exp_date, ENT_QUOTES) : ''; ?>'
420 title='<?php echo htmlspecialchars(xl('yyyy-mm-dd'), ENT_QUOTES); ?>'
422 </td>
423 </tr>
424 <tr>
425 <td align="right">
426 <span class=text>
427 <?php echo htmlspecialchars(xl('Immunization Manufacturer'), ENT_NOQUOTES); ?> </span> </td>
428 <td>
429 <?php echo generate_select_list('manufacturer', 'Immunization_Manufacturer', $manufacturer, 'Select Manufacturer', '');?>
430 </tr>
431 <tr>
432 <td align="right">
433 <span class=text>
434 <?php echo htmlspecialchars(xl('Immunization Lot Number'), ENT_NOQUOTES); ?> </span> </td>
435 <td>
436 <input class='text auto' type='text' name="lot_number" size="25" value="<?php echo htmlspecialchars($lot_number, ENT_QUOTES); ?>"> </td>
437 </tr>
438 <tr>
439 <td align="right">
440 <span class='text'>
441 <?php echo htmlspecialchars(xl('Name and Title of Immunization Administrator'), ENT_NOQUOTES); ?> </span> </td>
442 <td class='text'>
443 <input type="text" name="administered_by" id="administered_by" size="25" value="<?php echo htmlspecialchars($administered_by, ENT_QUOTES); ?>">
444 <?php echo htmlspecialchars(xl('or choose'), ENT_NOQUOTES); ?>
445 <!-- NEEDS WORK -->
446 <select name="administered_by_id" id='administered_by_id'>
447 <option value=""></option>
448 <?php
449 $sql = "select id, CONCAT_WS(' ',lname,fname) as full_name " .
450 "from users where username != '' and password != 'NoLogin' " .
451 "order by full_name";
453 $result = sqlStatement($sql);
454 while ($row = sqlFetchArray($result)) {
455 echo '<OPTION VALUE=' . htmlspecialchars($row{'id'}, ENT_QUOTES);
456 echo (isset($administered_by_id) && $administered_by_id != "" ? $administered_by_id : $_SESSION['authId']) == $row{'id'} ? ' selected>' : '>';
457 echo htmlspecialchars($row{'full_name'}, ENT_NOQUOTES) . '</OPTION>';
460 </select> </td>
461 </tr>
462 <tr>
463 <td align="right" class="text">
464 <?php echo htmlspecialchars(xl('Date Immunization Information Statements Given'), ENT_NOQUOTES); ?> </td>
465 <td>
466 <input type='text' size='10' class='datepicker' name="education_date" id="education_date"
467 value='<?php echo $education_date? htmlspecialchars($education_date, ENT_QUOTES) : date('Y-m-d'); ?>'
468 title='<?php echo htmlspecialchars(xl('yyyy-mm-dd'), 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' class='datepicker' 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); ?>'
481 </td>
482 </tr>
483 <tr>
484 <td align="right" class='text'><?php echo htmlspecialchars(xl('Route'), ENT_NOQUOTES); ?></td>
485 <td>
486 <?php echo generate_select_list('immuniz_route', 'drug_route', $immuniz_route, 'Select Route', '');?>
487 </td>
488 </tr>
489 <tr>
490 <td align="right" class='text'><?php echo htmlspecialchars(xl('Administration Site'), ENT_NOQUOTES); ?></td>
491 <td>
492 <?php echo generate_select_list('immuniz_admin_ste', 'immunization_administered_site', $immuniz_admin_ste, 'Select Administration Site', ' ', '', '', '', null, false, 'proc_body_site');?>
493 </td>
494 </tr>
495 <tr>
496 <td align="right" class='text'>
497 <?php echo htmlspecialchars(xl('Notes'), ENT_NOQUOTES); ?> </td>
498 <td>
499 <textarea class='text' name="note" id="note" rows=5 cols=25><?php echo htmlspecialchars($note, ENT_NOQUOTES); ?></textarea> </td>
500 </tr>
501 <tr>
502 <td align="right" class='text'>
503 <?php echo htmlspecialchars(xl('Information Source'), ENT_NOQUOTES); ?>
504 </td>
505 <td>
506 <?php echo generate_select_list('immunization_informationsource', 'immunization_informationsource', $immuniz_information_source, 'Select Information Source', ' ');?>
507 </td>
508 </tr>
509 <tr>
510 <td align="right" class='text'>
511 <?php echo htmlspecialchars(xl('Completion Status'), ENT_NOQUOTES); ?> </td>
512 <td>
513 <?php echo generate_select_list('immuniz_completion_status', 'Immunization_Completion_Status', $immuniz_completion_status, 'Select Completion Status', ' ');?> </td>
514 </tr>
515 <tr>
516 <td align="right" class='text'>
517 <?php echo htmlspecialchars(xl('Substance Refusal Reason'), ENT_NOQUOTES); ?>
518 </td>
519 <td>
520 <?php echo generate_select_list('immunization_refusal_reason', 'immunization_refusal_reason', $immuniz_refusal_reason, 'Select Refusal Reason', ' ');?>
521 </td>
522 </tr>
523 <tr>
524 <td align="right" class='text'>
525 <?php echo htmlspecialchars(xl('Immunization Ordering Provider'), ENT_NOQUOTES); ?>
526 </td>
527 <td>
528 <select name="ordered_by_id" id='ordered_by_id'>
529 <option value=""></option>
530 <?php
531 $sql = "select id, CONCAT(IFNULL(lname,''), ' ,',IFNULL(fname,'')) as full_name " .
532 "from users where username != '' and password != 'NoLogin' " .
533 "order by full_name";
535 $result = sqlStatement($sql);
536 while ($row = sqlFetchArray($result)) {
537 echo '<OPTION VALUE=' . htmlspecialchars($row{'id'}, ENT_QUOTES);
538 echo (isset($ordered_by_id) && $ordered_by_id != "" ? $ordered_by_id : $_SESSION['authId']) == $row{'id'} ? ' selected>' : '>';
539 echo htmlspecialchars($row{'full_name'}, ENT_NOQUOTES) . '</OPTION>';
542 </select>
543 </td>
544 </tr>
545 <?php
546 if ($entered_by) {
548 <tr>
549 <td align="right" class='text'>
550 <?php echo htmlspecialchars(xl('Entered By'), ENT_NOQUOTES); ?>
551 </td>
552 <td>
553 <?php echo htmlspecialchars($entered_by, ENT_NOQUOTES); ?>
554 </td>
555 </tr>
556 <?php
559 if ($GLOBALS['observation_results_immunization']) {
561 <tr>
562 <td colspan="3" align="center">
563 <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'); ?>'>
564 </td>
565 </tr>
566 <?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
576 if (count($imm_obs_data) > 0) {
577 foreach ($imm_obs_data as $key => $value) {
578 $key_snomed = 0;
579 $key_cvx = 0;
580 $style= '';?>
581 <tr id="or_tr_<?php echo $key + 1 ;?>">
582 <?php
583 if ($id == 0) {
584 if ($key == 0) {
585 $style = 'display: table-cell;width:765px !important';
586 } else {
587 $style = 'display: none;width:765px !important';
589 } else {
590 $style = 'display : table-cell;width:765px !important';
593 <td id="observation_criteria_td_<?php echo $key + 1 ;?>" style="<?php echo $style;?>">
594 <label><?php echo htmlspecialchars(xl('Observation Criteria'), ENT_QUOTES);?></label>
595 <select id="observation_criteria_<?php echo $key + 1 ;?>" name="observation_criteria[]" onchange="selectCriteria(this.id,this.value);" style="width: 220px;">
596 <?php foreach ($observation_criteria as $keyo => $valo) { ?>
597 <option value="<?php echo attr($valo['option_id']);?>" <?php if ($valo['option_id'] == $value['imo_criteria'] && $id !=0) {
598 echo 'selected = "selected"' ;
599 }?> ><?php echo text($valo['title']);?></option>
600 <?php }
602 </select>
603 </td>
604 <td <?php if ($value['imo_criteria'] != 'funding_program_eligibility' || $id == 0) {
605 ?> style="display: none;" <?php
606 } ?> class="observation_criteria_value_td" id="observation_criteria_value_td_<?php echo $key + 1 ;?>">
607 <label><?php echo htmlspecialchars(xl('Observation Criteria Value'), ENT_QUOTES); ?></label>
608 <select name="observation_criteria_value[]" id="observation_criteria_value_<?php echo $key + 1 ;?>" style="width: 220px;">
609 <?php foreach ($observation_criteria_value as $keyoc => $valoc) { ?>
610 <option value="<?php echo attr($valoc['option_id']);?>" <?php if ($valoc['option_id'] == $value['imo_criteria_value'] && $id != 0) {
611 echo 'selected = "selected"' ;
612 }?>><?php echo text($valoc['title']);?></option>
613 <?php }
615 </select>
616 </td>
617 <td <?php if ($value['imo_criteria'] != 'disease_with_presumed_immunity' || $id == 0) {
618 ?> style="display: none;" <?php
619 } ?> class="code_serach_td" id="code_search_td_<?php echo $key + 1 ;?>">
620 <?php $key_snomed = ($key > 0) ? (($key*2) + 2) : ($key + 2);?>
621 <label><?php echo htmlspecialchars(xl('SNOMED-CT Code'), ENT_QUOTES);?></label>
622 <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') {
623 echo attr($value['imo_code']);
624 }?>" onclick='sel_code(this.id);'><br>
625 <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>
626 <input type="hidden" id="codetext_<?php echo $key_snomed; ?>" name="codetext[]" class="codetext" value="<?php echo attr($value['imo_codetext']); ?>">
627 <input type="hidden" value="SNOMED-CT" name="codetypehidden[]" id="codetypehidden<?php echo $key_snomed; ?>" />
628 </td>
629 <td <?php if ($value['imo_criteria'] != 'vaccine_type' || $id == 0) {
630 ?> style="display: none;" <?php
631 } ?> class="code_serach_vaccine_type_td" id="code_serach_vaccine_type_td_<?php echo $key + 1 ;?>">
632 <label><?php echo htmlspecialchars(xl('CVX Code'), ENT_QUOTES);?></label>
633 <?php $key_cvx = ($key > 0) ? (($key*2) + 3) : ($key + 3);?>
634 <input type="text" id="cvx_code<?php echo $key_cvx ;?>" name="cvx_vac_type_code[]" onclick="sel_cvxcode(this);"
635 value="<?php if ($id != 0 && $value['imo_criteria'] == 'vaccine_type') {
636 echo attr($value['imo_code']);
637 }?>" style="width:140px;" />
638 <div class="imm-imm-add-12" id="imm-imm-add-12<?php echo $key_cvx ;?>"><?php if ($id != 0 && $value['imo_criteria'] == 'vaccine_type') {
639 echo text($value['imo_codetext']);
640 }?></div>
641 <input type="hidden" value="CVX" name="code_type_hidden[]" id="code_type_hidden<?php echo $key_cvx ;?>" />
642 <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') {
643 echo attr($value['imo_codetext']);
644 }?>"/>
645 </td>
646 <td <?php if ($value['imo_criteria'] != 'vaccine_type' || $id == 0) {
647 ?> style="display: none;" <?php
648 } ?> class="vis_published_date_td" id="vis_published_date_td_<?php echo $key + 1 ;?>">
649 <label><?php echo htmlspecialchars(xl('Date VIS Published'), ENT_QUOTES); ?></label>
650 <?php
651 $vis_published_dateval = $value['imo_vis_date_published'] ? htmlspecialchars($value['imo_vis_date_published'], ENT_QUOTES) : '';
653 <input type="text" class='datepicker' name="vis_published_date[]" value="<?php if ($id != 0 && $vis_published_dateval != 0) {
654 echo attr($vis_published_dateval);
655 }?>" id="vis_published_date_<?php echo $key + 1 ;?>" style="width:140px">
656 </td>
657 <td <?php if ($value['imo_criteria'] != 'vaccine_type' || $id == 0) {
658 ?> style="display: none;" <?php
659 } ?> class="vis_presented_date_td" id="vis_presented_date_td_<?php echo $key + 1 ;?>">
660 <label><?php echo htmlspecialchars(xl('Date VIS Presented'), ENT_QUOTES); ?></label>
661 <?php
662 $vis_presented_dateval = $value['imo_vis_date_presented'] ?htmlspecialchars($value['imo_vis_date_presented'], ENT_QUOTES) : '';
664 <input type="text" class='datepicker' name="vis_presented_date[]" value="<?php if ($id != 0 && $vis_presented_dateval !=0) {
665 echo attr($vis_presented_dateval);
666 }?>" id="vis_presented_date_<?php echo $key + 1 ;?>" style="width:140px">
667 </td>
668 <?php if ($key != 0 && $id != 0) {?>
669 <td>
670 <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'); ?>'>
671 </td>
672 <?php } ?>
673 </tr>
674 <?php
676 } else {?>
677 <tr id="or_tr_1">
678 <td id="observation_criteria_td_1">
679 <label><?php echo htmlspecialchars(xl('Observation Criteria'), ENT_QUOTES); ?></label>
680 <select id="observation_criteria_1" name="observation_criteria[]" onchange="selectCriteria(this.id,this.value);" style="width: 220px;">
681 <?php foreach ($observation_criteria as $keyo => $valo) { ?>
682 <option value="<?php echo attr($valo['option_id']);?>" <?php if ($valo['option_id'] == $value['imo_criteria'] && $id !=0) {
683 echo 'selected = "selected"' ;
684 }?> ><?php echo text($valo['title']);?></option>
685 <?php }
687 </select>
688 </td>
689 <td <?php if ($value['imo_criteria'] != 'funding_program_eligibility') {
690 ?> style="display: none;" <?php
691 } ?> class="observation_criteria_value_td" id="observation_criteria_value_td_1">
692 <label><?php echo htmlspecialchars(xl('Observation Criteria Value'), ENT_QUOTES); ?></label>
693 <select id="observation_criteria_value_1" name="observation_criteria_value[]" style="width: 220px;">
694 <?php foreach ($observation_criteria_value as $keyoc => $valoc) { ?>
695 <option value="<?php echo attr($valoc['option_id']);?>" <?php if ($valoc['option_id'] == $value['imo_criteria_value'] && $id != 0) {
696 echo 'selected = "selected"' ;
697 }?>><?php echo text($valoc['title']);?></option>
698 <?php }
700 </select>
701 </td>
702 <td <?php if ($value['imo_criteria'] != 'disease_with_presumed_immunity' || $id == 0) {
703 ?> style="display: none;" <?php
704 } ?> class="code_serach_td" id="code_search_td_1">
705 <label><?php echo htmlspecialchars(xl('SNOMED-CT Code'), ENT_QUOTES);?></label>
706 <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') {
707 echo attr($value['imo_code']);
708 }?>" onclick='sel_code(this.id);'><br>
709 <span id="displaytext_2" style="width:210px !important;display: block;font-size:13px;color: blue;" class="displaytext"><?php echo text($value['imo_codetext']);?></span>
710 <input type="hidden" id="codetext_2" name="codetext[]" class="codetext" value="<?php echo attr($value['imo_codetext']); ?>">
711 <input type="hidden" value="SNOMED-CT" name="codetypehidden[]" id="codetypehidden2" />
712 </td>
713 <td <?php if ($value['imo_criteria'] != 'vaccine_type' || $id == 0) {
714 ?> style="display: none;" <?php
715 } ?> class="code_serach_vaccine_type_td" id="code_serach_vaccine_type_td_1">
716 <label><?php echo htmlspecialchars(xl('CVX Code'), ENT_QUOTES);?></label>
717 <input type="text" id="cvx_code3" name="cvx_vac_type_code[]" onclick="sel_cvxcode(this);"
718 value="<?php if ($id != 0 && $value['imo_criteria'] == 'vaccine_type') {
719 echo attr($value['imo_code']);
720 }?>" style="width:140px;" />
721 <div class="imm-imm-add-12" id="imm-imm-add-123"><?php if ($id != 0 && $value['imo_criteria'] == 'vaccine_type') {
722 echo text($value['imo_codetext']);
723 }?></div>
724 <input type="hidden" value="CVX" name="code_type_hidden[]" id="code_type_hidden3"/>
725 <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') {
726 echo attr($value['imo_codetext']);
727 }?>"/>
728 </td>
729 <td <?php if ($value['imo_criteria'] != 'vaccine_type' || $id == 0) {
730 ?> style="display: none;" <?php
731 } ?> class="vis_published_date_td" id="vis_published_date_td_1">
732 <label><?php echo htmlspecialchars(xl('Date VIS Published'), ENT_QUOTES); ?></label>
733 <?php
734 $vis_published_dateval = $value['imo_vis_date_published'] ? htmlspecialchars($value['imo_vis_date_published'], ENT_QUOTES) : '';
736 <input type="text" class='datepicker' name="vis_published_date[]" value="<?php if ($id != 0 && $vis_published_dateval != 0) {
737 echo attr($vis_published_dateval);
738 }?>" id="vis_published_date_1" style="width:140px">
739 </td>
740 <td <?php if ($value['imo_criteria'] != 'vaccine_type' || $id == 0) {
741 ?> style="display: none;" <?php
742 } ?> class="vis_presented_date_td" id="vis_presented_date_td_1">
743 <label><?php echo htmlspecialchars(xl('Date VIS Presented'), ENT_QUOTES); ?></label>
744 <?php
745 $vis_presented_dateval = $value['imo_vis_date_presented'] ?htmlspecialchars($value['imo_vis_date_presented'], ENT_QUOTES) : '';
747 <input type="text" class='datepicker' name="vis_presented_date[]" value="<?php if ($id != 0 && $vis_presented_dateval !=0) {
748 echo attr($vis_presented_dateval);
749 }?>" id="vis_presented_date_1" style="width:140px">
750 </td>
751 </tr>
752 <?php
755 </table>
756 <div>
757 <center style="cursor: pointer;">
758 <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'); ?>'>
759 </center>
760 </div>
761 <input type ="hidden" name="tr_count" id="tr_count" value="<?php echo (count($imm_obs_data)>0) ? count($imm_obs_data) : 1 ;?>">
762 <input type="hidden" id="clickId" value="">
763 </fieldset>
764 </div>
765 </td>
766 </tr>
767 <tr>
768 <td colspan="3" align="center">
770 <input type="button" name="save" id="save" value="<?php echo htmlspecialchars(xl('Save Immunization'), ENT_QUOTES); ?>">
772 <input type="button" name="print" id="print" value="<?php echo htmlspecialchars(xl('Print Record') . xl('PDF', '', ' (', ')'), ENT_QUOTES); ?>">
774 <input type="button" name="printHtml" id="printHtml" value="<?php echo htmlspecialchars(xl('Print Record') . xl('HTML', '', ' (', ')'), ENT_QUOTES); ?>">
776 <input type="reset" name="clear" id="clear" value="<?php echo htmlspecialchars(xl('Clear'), ENT_QUOTES); ?>"> </td>
777 </tr>
778 </table>
779 </form>
781 <div id="immunization_list">
783 <table border=0 cellpadding=3 cellspacing=0>
785 <!-- some columns are sortable -->
786 <tr class='text bold'>
787 <th>
788 <a href="javascript:top.restoreSession();location.href='immunizations.php?sortby=vacc';" title='<?php echo htmlspecialchars(xl('Sort by vaccine'), ENT_QUOTES); ?>'>
789 <?php echo htmlspecialchars(xl('Vaccine'), ENT_NOQUOTES); ?></a>
790 <span class='small' style='font-family:arial'><?php if ($sortby == 'vacc') {
791 echo 'v';
792 } ?></span>
793 </th>
794 <th>
795 <a href="javascript:top.restoreSession();location.href='immunizations.php?sortby=date';" title='<?php echo htmlspecialchars(xl('Sort by date'), ENT_QUOTES); ?>'>
796 <?php echo htmlspecialchars(xl('Date'), ENT_NOQUOTES); ?></a>
797 <span class='small' style='font-family:arial'><?php if ($sortby == 'date') {
798 echo 'v';
799 } ?></span>
800 </th>
801 <th><?php echo htmlspecialchars(xl('Amount'), ENT_NOQUOTES); ?></th>
802 <th><?php echo xlt('Expiration'); ?></th>
803 <th><?php echo htmlspecialchars(xl('Manufacturer'), ENT_NOQUOTES); ?></th>
804 <th><?php echo htmlspecialchars(xl('Lot Number'), ENT_NOQUOTES); ?></th>
805 <th><?php echo htmlspecialchars(xl('Administered By'), ENT_NOQUOTES); ?></th>
806 <th><?php echo htmlspecialchars(xl('Education Date'), ENT_NOQUOTES); ?></th>
807 <th><?php echo htmlspecialchars(xl('Route'), ENT_NOQUOTES); ?></th>
808 <th><?php echo htmlspecialchars(xl('Administered Site'), ENT_NOQUOTES); ?></th>
809 <th><?php echo htmlspecialchars(xl('Notes'), ENT_NOQUOTES); ?></th>
810 <th><?php echo htmlspecialchars(xl('Completion Status'), ENT_NOQUOTES); ?></th>
811 <th><?php echo htmlspecialchars(xl('Error'), ENT_NOQUOTES); ?></th>
812 <th>&nbsp;</th>
813 </tr>
815 <?php
816 $result = getImmunizationList($pid, $_GET['sortby'], true);
818 while ($row = sqlFetchArray($result)) {
819 $isError = $row['added_erroneously'];
821 if ($isError) {
822 $tr_title = 'title="' . xla("Entered in Error") . '"';
823 } else {
824 $tr_title = "";
827 if ($row["id"] == $id) {
828 echo "<tr " . $tr_title . " class='immrow text selected' id='".htmlspecialchars($row["id"], ENT_QUOTES)."'>";
829 } else {
830 echo "<tr " . $tr_title . " class='immrow text' id='".htmlspecialchars($row["id"], ENT_QUOTES)."'>";
833 // Figure out which name to use (ie. from cvx list or from the custom list)
834 if ($GLOBALS['use_custom_immun_list']) {
835 $vaccine_display = generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']);
836 } else {
837 if (!empty($row['code_text_short'])) {
838 $vaccine_display = htmlspecialchars(xl($row['code_text_short']), ENT_NOQUOTES);
839 } else {
840 $vaccine_display = generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']);
844 if ($isError) {
845 $del_tag_open = "<del>";
846 $del_tag_close = "</del>";
847 } else {
848 $del_tag_open = "";
849 $del_tag_close = "";
852 echo "<td>" . $del_tag_open . $vaccine_display . $del_tag_close . "</td>";
854 if ($row["administered_date"]) {
855 $administered_date_summary = new DateTime($row['administered_date']);
856 $administered_date_summary = $administered_date_summary->format('Y-m-d H:i');
857 } else {
858 $administered_date_summary = "";
861 echo "<td>" . $del_tag_open . htmlspecialchars($administered_date_summary, ENT_NOQUOTES) . $del_tag_close . "</td>";
862 if ($row["amount_administered"] > 0) {
863 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>";
864 } else {
865 echo "<td>&nbsp</td>";
868 echo "<td>" . $del_tag_open . text($row["expiration_date"]) . $del_tag_close . "</td>";
869 echo "<td>" . $del_tag_open . htmlspecialchars($row["manufacturer"], ENT_NOQUOTES) . $del_tag_close . "</td>";
870 echo "<td>" . $del_tag_open . htmlspecialchars($row["lot_number"], ENT_NOQUOTES) . $del_tag_close . "</td>";
871 echo "<td>" . $del_tag_open . htmlspecialchars($row["administered_by"], ENT_NOQUOTES) . $del_tag_close . "</td>";
872 echo "<td>" . $del_tag_open . htmlspecialchars($row["education_date"], ENT_NOQUOTES) . $del_tag_close . "</td>";
873 echo "<td>" . $del_tag_open . generate_display_field(array('data_type'=>'1','list_id'=>'drug_route'), $row['route']) . $del_tag_close . "</td>";
874 echo "<td>" . $del_tag_open . generate_display_field(array('data_type'=>'1','list_id'=>'immunization_administered_site'), $row['administration_site']) . $del_tag_close . "</td>";
875 echo "<td>" . $del_tag_open . htmlspecialchars($row["note"], ENT_NOQUOTES) . $del_tag_close . "</td>";
876 echo "<td>" . $del_tag_open . generate_display_field(array('data_type'=>'1','list_id'=>'Immunization_Completion_Status'), $row['completion_status']) . $del_tag_close . "</td>";
878 if ($isError) {
879 $checkbox = "checked";
880 } else {
881 $checkbox = "";
884 echo "<td><input type='checkbox' class='error' id='".htmlspecialchars($row["id"], ENT_QUOTES)."' value='" . htmlspecialchars(xl('Error'), ENT_QUOTES) . "' " . $checkbox . "></td>";
886 echo "<td><input type='button' class='delete' id='".htmlspecialchars($row["id"], ENT_QUOTES)."' value='" . htmlspecialchars(xl('Delete'), ENT_QUOTES) . "'></td>";
887 echo "</tr>";
892 </table>
893 </div> <!-- end immunizations -->
895 </body>
897 <script language="javascript">
898 var tr_count = $('#tr_count').val();
900 // jQuery stuff to make the page a little easier to use
902 $(document).ready(function(){
903 <?php if (!($useCVX)) { ?>
904 $("#save").click(function() { SaveForm(); });
905 <?php } else { ?>
906 $("#save").click(function() {
907 if (validate_cvx()) {
908 SaveForm();
910 else {
911 return;
914 <?php } ?>
915 $("#print").click(function() { PrintForm("pdf"); });
916 $("#printHtml").click(function() { PrintForm("html"); });
917 $(".immrow").click(function() { EditImm(this); });
918 $(".error").click(function(event) { ErrorImm(this); event.stopPropagation(); });
919 $(".delete").click(function(event) { DeleteImm(this); event.stopPropagation(); });
921 $(".immrow").mouseover(function() { $(this).toggleClass("highlight"); });
922 $(".immrow").mouseout(function() { $(this).toggleClass("highlight"); });
924 $("#administered_by_id").change(function() { $("#administered_by").val($("#administered_by_id :selected").text()); });
926 $("#form_immunization_id").change( function() {
927 if ( $(this).val() != "" ) {
928 $("#cvx_code").val( "" );
929 $("#cvx_description").text( "" );
930 $("#cvx_code").change();
934 $('.datepicker').datetimepicker({
935 <?php $datetimepicker_timepicker = false; ?>
936 <?php $datetimepicker_showseconds = false; ?>
937 <?php $datetimepicker_formatInput = false; ?>
938 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
939 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
941 $('.datetimepicker').datetimepicker({
942 <?php $datetimepicker_timepicker = true; ?>
943 <?php $datetimepicker_showseconds = false; ?>
944 <?php $datetimepicker_formatInput = false; ?>
945 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
946 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
948 // special cases to deal with datepicker items that are added dynamically
949 $(document).on('mouseover','.datepicker_dynamic', function(){
950 $(this).datetimepicker({
951 <?php $datetimepicker_timepicker = false; ?>
952 <?php $datetimepicker_showseconds = false; ?>
953 <?php $datetimepicker_formatInput = false; ?>
954 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
955 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
960 var PrintForm = function(typ) {
961 top.restoreSession();
962 newURL='shot_record.php?output='+typ+'&sortby=<?php echo $sortby; ?>';
963 window.open(newURL, '_blank', "menubar=1,toolbar=1,scrollbars=1,resizable=1,width=600,height=450");
966 var SaveForm = function() {
967 top.restoreSession();
968 $("#add_immunization").submit();
971 var EditImm = function(imm) {
972 top.restoreSession();
973 location.href='immunizations.php?mode=edit&id='+imm.id;
976 var DeleteImm = function(imm) {
977 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); ?>")) {
978 top.restoreSession();
979 location.href='immunizations.php?mode=delete&id='+imm.id;
983 var ErrorImm = function(imm) {
984 top.restoreSession();
985 location.href='immunizations.php?mode=added_error&id='+imm.id+'&isError='+imm.checked;
988 //This is for callback by the find-code popup.
989 //Appends to or erases the current list of diagnoses.
990 function set_related(codetype, code, selector, codedesc) {
991 if(codetype == 'CVX') {
992 var f = document.forms[0][current_sel_name];
993 if(!f.length) {
994 var s = f.value;
996 if (code) {
997 s = code;
999 else {
1000 s = '';
1003 f.value = s;
1004 if(f.name != 'cvx_vac_type_code[]'){
1005 $("#cvx_description").text( codedesc );
1006 $("#form_immunization_id").attr( "value", "" );
1007 $("#form_immunization_id").change();
1008 }else{
1009 id_arr = f.id.split('cvx_code');
1010 counter = id_arr[1];
1011 $('#imm-imm-add-12'+counter).html(codedesc);
1012 $('#code_text_hidden'+counter).val(codedesc);
1014 }else {
1015 var index = document.forms[0][current_sel_name].length -1;
1016 var elem = document.forms[0][current_sel_name][index];
1017 var ss = elem.value;
1018 if (code) {
1019 ss = code;
1021 else {
1022 ss = '';
1025 elem.value = ss;
1026 arr = elem.id.split('cvx_code');
1027 count = arr[1];
1028 $('#imm-imm-add-12'+count).html(codedesc);
1029 $('#code_text_hidden'+count).val(codedesc);
1031 }else {
1032 var checkId = $('#clickId').val();
1033 $("#sct_code_" + checkId).val(code);
1034 $("#codetext_" + checkId).val(codedesc);
1035 $("#displaytext_" + checkId).html(codedesc);
1039 // This invokes the find-code popup.
1040 function sel_cvxcode(e) {
1041 current_sel_name = e.name;
1042 dlgopen('../encounter/find_code_popup.php?codetype=CVX', '_blank', 500, 400);
1045 // This ensures the cvx centric entry is filled.
1046 function validate_cvx() {
1047 if (document.add_immunization.cvx_code.value>0) {
1048 return true;
1050 else {
1051 document.add_immunization.cvx_code.style.backgroundColor="red";
1052 document.add_immunization.cvx_code.focus();
1053 return false;
1057 function showObservationResultSection()
1059 $('.observation_results').slideToggle();
1062 function selectCriteria(id,value)
1064 var arr = id.split('observation_criteria_');
1065 var key = arr[1];
1066 if(value == 'funding_program_eligibility') {
1067 $('.obs_res_table').css('width','50%');
1068 if(key > 1) {
1069 var target = $("#observation_criteria_value_"+key);
1070 $.ajax({
1071 type: "POST",
1072 url: "immunizations.php",
1073 dataType: "json",
1074 data: {
1075 type : 'duplicate_row_2'
1077 success: function(thedata){
1078 $.each(thedata,function(i,item) {
1079 target.append($('<option />').val(item.option_id).text(item.title));
1081 $('#observation_criteria_value_'+key+' option[value=""]').attr('selected','selected');
1083 error:function(){
1084 alert("ajax error");
1088 $("#code_search_td_"+key).hide();
1089 $("#vis_published_date_td_"+key).hide();
1090 $("#vis_presented_date_td_"+key).hide();
1091 $("#code_serach_vaccine_type_td_"+key).hide();
1092 $("#observation_criteria_value_td_"+key).show();
1094 if(value == 'vaccine_type')
1096 $("#observation_criteria_value_td_"+key).hide();
1097 $("#code_search_td_"+key).hide();
1098 $("#code_serach_vaccine_type_td_"+key).show();
1099 $("#vis_published_date_td_"+key).show();
1100 $("#vis_presented_date_td_"+key).show();
1101 if(key == 1) {
1102 key = parseInt(key) + 2;
1104 else {
1105 key = (parseInt(key) * 2) + 1;
1107 $("#cvx_code"+key).css("background-color", "red");
1108 $("#cvx_code"+key).focus();
1109 return false;
1111 if(value == 'disease_with_presumed_immunity')
1113 $('.obs_res_table').css('width','50%');
1114 $("#observation_criteria_value_td_"+key).hide();
1115 $("#vis_published_date_td_"+key).hide();
1116 $("#vis_presented_date_td_"+key).hide();
1117 $("#code_serach_vaccine_type_td_"+key).hide();
1118 $("#code_search_td_"+key).show();
1119 if(key == 1) {
1120 key = parseInt(key) + 1;
1122 else {
1123 key = (parseInt(key) * 2);
1125 $("#sct_code_"+key).css("background-color", "red");
1126 $("#sct_code_"+key).focus();
1127 return false;
1129 if(value == '')
1131 $("#observation_criteria_value_td_"+key).hide();
1132 $("#vis_published_date_td_"+key).hide();
1133 $("#vis_presented_date_td_"+key).hide();
1134 $("#code_serach_vaccine_type_td_"+key).hide();
1135 $("#code_search_td_"+key).hide();
1139 function RemoveRow(id)
1141 tr_count = parseInt($("#tr_count").val());
1142 new_tr_count = tr_count-1;
1143 $("#tr_count").val(new_tr_count);
1144 $("#or_tr_"+id).remove();
1147 function addNewRow()
1149 tr_count = parseInt($("#tr_count").val());
1150 new_tr_count = tr_count+1;
1151 new_tr_count_2 = (new_tr_count * 2);
1152 new_tr_count_3 = (new_tr_count *2) + 1;
1153 $("#tr_count").val(new_tr_count);
1154 label1 = "<?php echo htmlspecialchars(xl('Observation Criteria'), ENT_QUOTES); ?>";
1155 label2 = "<?php echo htmlspecialchars(xl('Observation Criteria Value'), ENT_QUOTES); ?>";
1156 label3 = "<?php echo htmlspecialchars(xl('SNOMED-CT Code'), ENT_QUOTES); ?>";
1157 label4 = "<?php echo htmlspecialchars(xl('CVX Code'), ENT_QUOTES); ?>";
1158 label5 = "<?php echo htmlspecialchars(xl('Date VIS Published'), ENT_QUOTES); ?>";
1159 label6 = "<?php echo htmlspecialchars(xl('Click here to choose a date'), ENT_QUOTES); ?>";
1160 label7 = "<?php echo htmlspecialchars(xl('Date VIS Presented'), ENT_QUOTES); ?>";
1161 label8 = "<?php echo htmlspecialchars(xl('Click here to choose a date'), ENT_QUOTES); ?>";
1162 label9 = "<?php echo htmlspecialchars(xl('Click here to delete the row'), ENT_QUOTES); ?>";
1163 str = '<tr id ="or_tr_'+new_tr_count+'">'+
1164 '<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>'+
1165 '</td>'+
1166 '<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>'+
1167 '</td>'+
1168 '<td class="code_serach_td" id="code_search_td_'+new_tr_count+'" style="display: none;"><label>'+label3+'</label>'+
1169 '<input type="text" id="sct_code_'+new_tr_count_2+'" style="width:140px" name="sct_code[]" class="code" onclick=sel_code(this.id) /><br>'+
1170 '<span id="displaytext_'+new_tr_count_2+'" style="width:210px !important;display: block;font-size:13px;color: blue;" class="displaytext"></span>'+
1171 '<input type="hidden" id="codetext_'+new_tr_count_2+'" name="codetext[]" class="codetext">'+
1172 '<input type="hidden" value="SNOMED-CT" name="codetypehidden[]" id="codetypehidden'+new_tr_count_2+'" /> '+
1173 '</td>'+
1174 '<td class="code_serach_vaccine_type_td" id="code_serach_vaccine_type_td_'+new_tr_count+'" style="display: none;"><label>'+label4+'</label>'+
1175 '<input type="text" id="cvx_code'+new_tr_count_3+'" name="cvx_vac_type_code[]" onclick=sel_cvxcode(this); style="width:140px;" />'+
1176 '<div class="imm-imm-add-12" id="imm-imm-add-12'+new_tr_count_3+'"></div> '+
1177 '<input type="hidden" value="CVX" name="code_type_hidden[]" id="code_type_hidden'+new_tr_count_3+'" /> '+
1178 '<input type="hidden" class="code_text_hidden" name="code_text_hidden[]" id="code_text_hidden'+new_tr_count_3+'" value="" />'+
1179 '</td>'+
1180 '<td id="vis_published_date_td_'+new_tr_count+'" class="vis_published_date_td" style="display: none;"><label>'+label5+'</label><input type="text" class="datepicker_dynamic" name= "vis_published_date[]" id ="vis_published_date_'+new_tr_count+'" style="width:140px">'+
1181 '</td>'+
1182 '<td id="vis_presented_date_td_'+new_tr_count+'" class="vis_presented_date_td" style="display: none;"><label>'+label7+'</label><input type="text" class="datepicker_dynamic" name= "vis_presented_date[]" id ="vis_presented_date_'+new_tr_count+'" style="width:140px">'+
1183 '</td>'+
1184 '<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>';
1186 $(".obs_res_table").append(str);
1188 var ajax_url = 'immunizations.php';
1189 var target = $("#observation_criteria_"+new_tr_count);
1190 $.ajax({
1191 type: "POST",
1192 url: ajax_url,
1193 dataType: "json",
1194 data: {
1195 type : 'duplicate_row'
1197 success: function(thedata){
1198 $.each(thedata,function(i,item) {
1199 target.append($('<option></option>').val(item.option_id).text(item.title));
1201 $('#observation_criteria_'+new_tr_count+' option[value=""]').attr('selected','selected');
1203 error:function(){
1204 alert("ajax error");
1209 function sel_code(id)
1211 id = id.split('sct_code_');
1212 var checkId = id[1];
1213 $('#clickId').val(checkId);
1214 dlgopen('<?php echo $GLOBALS['webroot'] . "/interface/patient_file/encounter/" ?>find_code_popup.php', '_blank', 700, 400);
1217 $(function() {
1219 //autocomplete
1220 $(".auto").autocomplete({
1221 source: "../../../library/ajax/imm_autocomplete/search.php",
1222 minLength: 1
1226 </script>
1228 </html>