4 $sanitize_all_escapes=true;
7 //STOP FAKE REGISTER GLOBALS
8 $fake_register_globals=false;
11 include_once("../../globals.php");
12 include_once("$srcdir/sql.inc");
13 include_once("$srcdir/options.inc.php");
15 if (isset($_GET['mode'])) {
17 if ($_GET['mode'] == "add" ) {
19 $sql = "REPLACE INTO immunizations set
21 administered_date = if(?,?,NULL),
26 administered_by_id = if(?,?,NULL),
27 administered_by = if(?,?,NULL),
28 education_date = if(?,?,NULL),
29 vis_date = if(?,?,NULL),
34 create_date = now() ";
35 $sqlBindArray = array(
37 trim($_GET['administered_date']), trim($_GET['administered_date']),
38 trim($_GET['form_immunization_id']),
39 trim($_GET['cvx_code']),
40 trim($_GET['manufacturer']),
41 trim($_GET['lot_number']),
42 trim($_GET['administered_by_id']), trim($_GET['administered_by_id']),
43 trim($_GET['administered_by']), trim($_GET['administered_by']),
44 trim($_GET['education_date']), trim($_GET['education_date']),
45 trim($_GET['vis_date']), trim($_GET['vis_date']),
51 sqlStatement($sql,$sqlBindArray);
52 $administered_date=$education_date=date('Y-m-d');
53 $immunization_id=$cvx_code=$manufacturer=$lot_number=$administered_by_id=$note=$id="";
54 $administered_by=$vis_date="";
56 elseif ($_GET['mode'] == "delete" ) {
58 newEvent("delete", $_SESSION['authUser'], $_SESSION['authProvider'], 1, "Immunization id ".$_GET['id']." deleted from pid ".$pid);
59 // delete the immunization
60 $sql="DELETE FROM immunizations WHERE id =? LIMIT 1";
61 sqlStatement($sql, array($_GET['id']));
63 elseif ($_GET['mode'] == "edit" ) {
64 $sql = "select * from immunizations where id = ?";
65 $result = sqlQuery($sql, array($_GET['id']));
66 $administered_date = $result['administered_date'];
67 $immunization_id = $result['immunization_id'];
68 $cvx_code = $result['cvx_code'];
70 if ( !(empty($cvx_code)) ) {
71 $query = "SELECT codes.code_text as `code_text`, codes.code as `code` " .
73 "LEFT JOIN code_types on codes.code_type = code_types.ct_id " .
74 "WHERE code_types.ct_key = 'CVX' AND codes.code = ?";
75 $result_code_text = sqlQuery($query, array($cvx_code));
76 $code_text = $result_code_text['code_text'];
78 $manufacturer = $result['manufacturer'];
79 $lot_number = $result['lot_number'];
80 $administered_by_id = ($result['administered_by_id'] ?
$result['administered_by_id'] : 0);
81 $administered_by = $result['administered_by'];
82 $education_date = $result['education_date'];
83 $vis_date = $result['vis_date'];
84 $note = $result['note'];
92 // Decide whether using the CVX list or the custom list in list_options
93 if ($GLOBALS['use_custom_immun_list']) {
94 // user forces the use of the custom list
98 if ($_GET['mode'] == "edit") {
99 //depends on if a cvx code is enterer already
100 if (empty($cvx_code)) {
107 else { // $_GET['mode'] == "add"
112 // set the default sort method for the list of past immunizations
113 $sortby = $_GET['sortby'];
114 if (!$sortby) { $sortby = 'vacc'; }
116 // set the default value of 'administered_by'
117 if (!$administered_by && !$administered_by_id) {
118 $stmt = "select concat(lname,', ',fname) as full_name ".
119 " from users where ".
121 $row = sqlQuery($stmt, array($_SESSION['authId']));
122 $administered_by = $row['full_name'];
128 <?php
html_header_show();?
>
130 <!-- supporting javascript code
-->
131 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script
>
132 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js"></script
>
133 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script
>
137 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
144 background
-color
: white
;
148 <!-- pop up calendar
-->
149 <style type
="text/css">@import
url(<?php
echo $GLOBALS['webroot'] ?
>/library
/dynarch_calendar
.css
);</style
>
150 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.js"></script
>
151 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
152 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar_setup.js"></script
>
154 <script language
="JavaScript">
155 // required to validate date text boxes
156 var mypcc
= '<?php echo htmlspecialchars( $GLOBALS['phone_country_code
'], ENT_QUOTES); ?>';
161 <body
class="body_top">
163 <?php
if ($GLOBALS['concurrent_layout']) { ?
>
164 <span
class="title"><?php
echo htmlspecialchars( xl('Immunizations'), ENT_NOQUOTES
); ?
></span
>
166 <a href
="patient_summary.php" target
="Main" onclick
="top.restoreSession()">
167 <span
class="title"><?php
echo htmlspecialchars( xl('Immunizations'), ENT_NOQUOTES
); ?
></span
>
168 <span
class=back
><?php
echo htmlspecialchars( $tback, ENT_NOQUOTES
); ?
></span
></a
>
171 <form action
="immunizations.php" name
="add_immunization" id
="add_immunization">
172 <input type
="hidden" name
="mode" id
="mode" value
="add">
173 <input type
="hidden" name
="id" id
="id" value
="<?php echo htmlspecialchars( $id, ENT_QUOTES); ?>">
174 <input type
="hidden" name
="pid" id
="pid" value
="<?php echo htmlspecialchars( $pid, ENT_QUOTES); ?>">
176 <table border
=0 cellpadding
=1 cellspacing
=1>
178 <?php
if (!($useCVX)) { ?
>
182 <?php
echo htmlspecialchars( xl('Immunization'), ENT_NOQUOTES
); ?
>
187 // Modified 7/2009 by BM to incorporate the immunization items into the list_options listings
188 generate_form_field(array('data_type'=>1,'field_id'=>'immunization_id','list_id'=>'immunizations','empty_title'=>'SKIP'), $immunization_id);
194 <td align
="right" valign
="top" style
="padding-top:4px;">
196 <?php
echo htmlspecialchars( xl('Immunization'), ENT_NOQUOTES
); ?
> (<?php
echo htmlspecialchars( xl('CVX Code'), ENT_NOQUOTES
); ?
>)
200 <input type
='text' size
='10' name
='cvx_code' id
='cvx_code'
201 value
='<?php echo htmlspecialchars($cvx_code,ENT_QUOTES); ?>' onclick
='sel_cvxcode(this)'
202 title
='<?php echo htmlspecialchars( xl('Click to select
or change CVX code
'), ENT_QUOTES); ?>'
204 <div id
='cvx_description' style
='display:inline; float:right; padding:3px; margin-left:3px; width:400px'>
205 <?php
echo htmlspecialchars( xl( $code_text ), ENT_QUOTES
); ?
>
214 <?php
echo htmlspecialchars( xl('Date Administered'), ENT_NOQUOTES
); ?
>
219 <input type
='text' size
='10' name
="administered_date" id
="administered_date"
220 value
='<?php echo $administered_date ? htmlspecialchars( $administered_date, ENT_QUOTES) : date('Y
-m
-d
'); ?>'
221 title
='<?php echo htmlspecialchars( xl('yyyy
-mm
-dd
'), ENT_QUOTES); ?>'
222 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc);'
224 <img src
='<?php echo $rootdir; ?>/pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
225 id
='img_administered_date' border
='0' alt
='[?]' style
='cursor:pointer;cursor:hand'
226 title
='<?php echo htmlspecialchars( xl('Click here to choose a date
'), ENT_QUOTES); ?>'>
233 <?php
echo htmlspecialchars( xl('Immunization Manufacturer'), ENT_NOQUOTES
); ?
>
237 <input
class='text' type
='text' name
="manufacturer" size
="25" value
="<?php echo htmlspecialchars( $manufacturer, ENT_QUOTES); ?>">
243 <?php
echo htmlspecialchars( xl('Immunization Lot Number'), ENT_NOQUOTES
); ?
>
247 <input
class='text' type
='text' name
="lot_number" size
="25" value
="<?php echo htmlspecialchars( $lot_number, ENT_QUOTES); ?>">
253 <?php
echo htmlspecialchars( xl('Name and Title of Immunization Administrator'), ENT_NOQUOTES
); ?
>
257 <input type
="text" name
="administered_by" id
="administered_by" size
="25" value
="<?php echo htmlspecialchars( $administered_by, ENT_QUOTES); ?>">
258 <?php
echo htmlspecialchars( xl('or choose'), ENT_NOQUOTES
); ?
>
260 <select name
="administered_by_id" id
='administered_by_id'>
261 <option value
=""></option
>
263 $sql = "select id, concat(lname,', ',fname) as full_name " .
264 "from users where username != '' " .
265 "order by concat(lname,', ',fname)";
267 $result = sqlStatement($sql);
268 while($row = sqlFetchArray($result)){
269 echo '<OPTION VALUE=' . htmlspecialchars( $row{'id'}, ENT_QUOTES
);
270 echo (isset($administered_by_id) && $administered_by_id != "" ?
$administered_by_id : $_SESSION['authId']) == $row{'id'} ?
' selected>' : '>';
271 echo htmlspecialchars( $row{'full_name'}, ENT_NOQUOTES
) . '</OPTION>';
278 <td align
="right" class="text">
279 <?php
echo htmlspecialchars( xl('Date Immunization Information Statements Given'), ENT_NOQUOTES
); ?
>
282 <input type
='text' size
='10' name
="education_date" id
="education_date"
283 value
='<?php echo $education_date? htmlspecialchars( $education_date, ENT_QUOTES) : date('Y
-m
-d
'); ?>'
284 title
='<?php echo htmlspecialchars( xl('yyyy
-mm
-dd
'), ENT_QUOTES); ?>'
285 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc);'
287 <img src
='<?php echo $rootdir; ?>/pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
288 id
='img_education_date' border
='0' alt
='[?]' style
='cursor:pointer;'
289 title
='<?php echo htmlspecialchars( xl('Click here to choose a date
'), ENT_QUOTES); ?>'
294 <td align
="right" class="text">
295 <?php
echo htmlspecialchars( xl('Date of VIS Statement'), ENT_NOQUOTES
); ?
>
296 (<a href
="http://www.cdc.gov/vaccines/pubs/vis/default.htm" title
="<?php echo htmlspecialchars( xl('Help'), ENT_QUOTES); ?>" target
="_blank">?
</a
>)
299 <input type
='text' size
='10' name
="vis_date" id
="vis_date"
300 value
='<?php echo $vis_date ? htmlspecialchars( $vis_date, ENT_QUOTES) : date('Y
-m
-d
'); ?>'
301 title
='<?php echo htmlspecialchars( xl('yyyy
-mm
-dd
'), ENT_QUOTES); ?>'
302 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc);'
304 <img src
='<?php echo $rootdir; ?>/pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
305 id
='img_vis_date' border
='0' alt
='[?]' style
='cursor:pointer;'
306 title
='<?php echo htmlspecialchars( xl('Click here to choose a date
'), ENT_QUOTES); ?>'
311 <td align
="right" class='text'>
312 <?php
echo htmlspecialchars( xl('Notes'), ENT_NOQUOTES
); ?
>
315 <textarea
class='text' name
="note" id
="note" rows
=5 cols
=25><?php
echo htmlspecialchars( $note, ENT_NOQUOTES
); ?
></textarea
>
319 <td colspan
="3" align
="center">
321 <input type
="button" name
="save" id
="save" value
="<?php echo htmlspecialchars( xl('Save Immunization'), ENT_QUOTES); ?>">
323 <input type
="button" name
="print" id
="print" value
="<?php echo htmlspecialchars( xl('Print Record') . xl('PDF','',' (',')'), ENT_QUOTES); ?>">
325 <input type
="button" name
="printHtml" id
="printHtml" value
="<?php echo htmlspecialchars( xl('Print Record') . xl('HTML','',' (',')'), ENT_QUOTES); ?>">
327 <input type
="reset" name
="clear" id
="clear" value
="<?php echo htmlspecialchars( xl('Clear'), ENT_QUOTES); ?>">
333 <div id
="immunization_list">
335 <table border
=0 cellpadding
=3 cellspacing
=0>
337 <!-- some columns are sortable
-->
338 <tr
class='text bold'>
340 <a href
="javascript:top.restoreSession();location.href='immunizations.php?sortby=vacc';" title
='<?php echo htmlspecialchars( xl('Sort by vaccine
'), ENT_QUOTES); ?>'>
341 <?php
echo htmlspecialchars( xl('Vaccine'), ENT_NOQUOTES
); ?
></a
>
342 <span
class='small' style
='font-family:arial'><?php
if ($sortby == 'vacc') { echo 'v'; } ?
></span
>
345 <a href
="javascript:top.restoreSession();location.href='immunizations.php?sortby=date';" title
='<?php echo htmlspecialchars( xl('Sort by date
'), ENT_QUOTES); ?>'>
346 <?php
echo htmlspecialchars( xl('Date'), ENT_NOQUOTES
); ?
></a
>
347 <span
class='small' style
='font-family:arial'><?php
if ($sortby == 'date') { echo 'v'; } ?
></span
>
349 <th
><?php
echo htmlspecialchars( xl('Manufacturer'), ENT_NOQUOTES
); ?
></th
>
350 <th
><?php
echo htmlspecialchars( xl('Lot Number'), ENT_NOQUOTES
); ?
></th
>
351 <th
><?php
echo htmlspecialchars( xl('Administered By'), ENT_NOQUOTES
); ?
></th
>
352 <th
><?php
echo htmlspecialchars( xl('Education Date'), ENT_NOQUOTES
); ?
></th
>
353 <th
><?php
echo htmlspecialchars( xl('Note'), ENT_NOQUOTES
); ?
></th
>
358 $sql = "select i1.id ,i1.immunization_id, i1.cvx_code, i1.administered_date, c.code_text_short, c.code".
359 ",i1.manufacturer ,i1.lot_number ".
360 ",ifnull(concat(u.lname,', ',u.fname),'Other') as administered_by ".
361 ",i1.education_date ,i1.note ".
362 " from immunizations i1 ".
363 " left join users u on i1.administered_by_id = u.id ".
364 " left join code_types ct on ct.ct_key = 'CVX' ".
365 " left join codes c on c.code_type = ct.ct_id AND i1.cvx_code = c.code ".
366 " where i1.patient_id = ? ".
368 if ($sortby == "vacc") {
369 $sql .= " c.code_text_short, i1.immunization_id, i1.administered_date DESC";
371 else { $sql .= " administered_date desc"; }
373 $result = sqlStatement($sql, array($pid) );
374 while($row = sqlFetchArray($result)) {
375 if ($row["id"] == $id) {
376 echo "<tr class='immrow text selected' id='".htmlspecialchars( $row["id"], ENT_QUOTES
)."'>";
379 echo "<tr class='immrow text' id='".htmlspecialchars( $row["id"], ENT_QUOTES
)."'>";
382 // Figure out which name to use (ie. from cvx list or from the custom list)
383 if ($GLOBALS['use_custom_immun_list']) {
384 $vaccine_display = generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']);
387 if (!empty($row['code_text_short'])) {
388 $vaccine_display = htmlspecialchars( xl($row['code_text_short']), ENT_NOQUOTES
);
391 $vaccine_display = generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']);
395 echo "<td>" . $vaccine_display . "</td>";
397 echo "<td>" . htmlspecialchars( $row["administered_date"], ENT_NOQUOTES
) . "</td>";
398 echo "<td>" . htmlspecialchars( $row["manufacturer"], ENT_NOQUOTES
) . "</td>";
399 echo "<td>" . htmlspecialchars( $row["lot_number"], ENT_NOQUOTES
) . "</td>";
400 echo "<td>" . htmlspecialchars( $row["administered_by"], ENT_NOQUOTES
) . "</td>";
401 echo "<td>" . htmlspecialchars( $row["education_date"], ENT_NOQUOTES
) . "</td>";
402 echo "<td>" . htmlspecialchars( $row["note"], ENT_NOQUOTES
) . "</td>";
403 echo "<td><input type='button' class='delete' id='".htmlspecialchars( $row["id"], ENT_QUOTES
)."' value='" . htmlspecialchars( xl('Delete'), ENT_QUOTES
) . "'></td>";
410 </div
> <!-- end immunizations
-->
414 <script language
="javascript">
415 /* required for popup calendar */
416 Calendar
.setup({inputField
:"administered_date", ifFormat
:"%Y-%m-%d", button
:"img_administered_date"});
417 Calendar
.setup({inputField
:"education_date", ifFormat
:"%Y-%m-%d", button
:"img_education_date"});
418 Calendar
.setup({inputField
:"vis_date", ifFormat
:"%Y-%m-%d", button
:"img_vis_date"});
420 // jQuery stuff to make the page a little easier to use
422 $
(document
).ready(function(){
423 <?php
if (!($useCVX)) { ?
>
424 $
("#save").click(function() { SaveForm(); });
426 $
("#save").click(function() {
427 if (validate_cvx()) {
435 $
("#print").click(function() { PrintForm("pdf"); });
436 $
("#printHtml").click(function() { PrintForm("html"); });
437 $
(".immrow").click(function() { EditImm(this
); });
438 $
(".delete").click(function(event
) { DeleteImm(this
); event
.stopPropagation(); });
440 $
(".immrow").mouseover(function() { $
(this
).toggleClass("highlight"); });
441 $
(".immrow").mouseout(function() { $
(this
).toggleClass("highlight"); });
443 $
("#administered_by_id").change(function() { $
("#administered_by").val($
("#administered_by_id :selected").text()); });
445 $
("#form_immunization_id").change( function() {
446 if ( $
(this
).val() != "" ) {
447 $
("#cvx_code").val( "" );
448 $
("#cvx_description").text( "" );
449 $
("#cvx_code").change();
454 var PrintForm
= function(typ
) {
455 top
.restoreSession();
456 newURL
='shot_record.php?output='+typ+
'&sortby=<?php echo $sortby; ?>';
458 location
.href
=newURL
;
461 window
.open(newURL
, '_blank', "menubar=1,toolbar=1,scrollbars=1,resizable=1,width=600,height=450");
465 var SaveForm
= function() {
466 top
.restoreSession();
467 $
("#add_immunization").submit();
470 var EditImm
= function(imm
) {
471 top
.restoreSession();
472 location
.href
='immunizations.php?mode=edit&id='+imm
.id
;
475 var DeleteImm
= function(imm
) {
476 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); ?>")) {
477 top
.restoreSession();
478 location
.href
='immunizations.php?mode=delete&id='+imm
.id
;
482 //This is for callback by the find-code popup.
483 //Appends to or erases the current list of diagnoses.
484 function set_related(codetype
, code
, selector
, codedesc
) {
485 var f
= document
.forms
[0][current_sel_name
];
496 $
("#cvx_description").text( codedesc
);
497 $
("#form_immunization_id").attr( "value", "" );
498 $
("#form_immunization_id").change();
502 // This invokes the find-code popup.
503 function sel_cvxcode(e
) {
504 current_sel_name
= e
.name
;
505 dlgopen('../encounter/find_code_popup.php?codetype=CVX', '_blank', 500, 400);
508 // This ensures the cvx centric entry is filled.
509 function validate_cvx() {
510 if (document
.add_immunization
.cvx_code
.value
>0) {
514 document
.add_immunization
.cvx_code
.style
.backgroundColor
="red";
515 document
.add_immunization
.cvx_code
.focus();