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 $results = sqlQ($sql, array($_GET['id']));
66 while ($row = sqlFetchArray($results)) {
67 $administered_date = $row['administered_date'];
68 $immunization_id = $row['immunization_id'];
69 $cvx_code = $row['cvx_code'];
71 if ( !(empty($cvx_code)) ) {
72 $query = "SELECT codes.code_text as `code_text`, codes.code as `code` " .
74 "LEFT JOIN code_types on codes.code_type = code_types.ct_id " .
75 "WHERE code_types.ct_key = 'CVX' AND codes.code = ?";
76 $row = sqlQuery($query, array($cvx_code));
77 $code_text = $row['code_text'];
79 $manufacturer = $row['manufacturer'];
80 $lot_number = $row['lot_number'];
81 $administered_by_id = ($row['administered_by_id'] ?
$row['administered_by_id'] : 0);
82 $administered_by = $row['administered_by'];
83 $education_date = $row['education_date'];
84 $vis_date = $row['vis_date'];
94 // Decide whether using the CVX list or the custom list in list_options
95 if ($GLOBALS['use_custom_immun_list']) {
96 // user forces the use of the custom list
100 if ($_GET['mode'] == "edit") {
101 //depends on if a cvx code is enterer already
102 if (empty($cvx_code)) {
109 else { // $_GET['mode'] == "add"
114 // set the default sort method for the list of past immunizations
115 $sortby = $_GET['sortby'];
116 if (!$sortby) { $sortby = 'vacc'; }
118 // set the default value of 'administered_by'
119 if (!$administered_by && !$administered_by_id) {
120 $stmt = "select concat(lname,', ',fname) as full_name ".
121 " from users where ".
123 $row = sqlQuery($stmt, array($_SESSION['authId']));
124 $administered_by = $row['full_name'];
130 <?php
html_header_show();?
>
132 <!-- supporting javascript code
-->
133 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script
>
134 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js"></script
>
135 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script
>
139 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
146 background
-color
: white
;
150 <!-- pop up calendar
-->
151 <style type
="text/css">@import
url(<?php
echo $GLOBALS['webroot'] ?
>/library
/dynarch_calendar
.css
);</style
>
152 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.js"></script
>
153 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
154 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar_setup.js"></script
>
156 <script language
="JavaScript">
157 // required to validate date text boxes
158 var mypcc
= '<?php echo htmlspecialchars( $GLOBALS['phone_country_code
'], ENT_QUOTES); ?>';
163 <body
class="body_top">
165 <?php
if ($GLOBALS['concurrent_layout']) { ?
>
166 <span
class="title"><?php
echo htmlspecialchars( xl('Immunizations'), ENT_NOQUOTES
); ?
></span
>
168 <a href
="patient_summary.php" target
="Main" onclick
="top.restoreSession()">
169 <span
class="title"><?php
echo htmlspecialchars( xl('Immunizations'), ENT_NOQUOTES
); ?
></span
>
170 <span
class=back
><?php
echo htmlspecialchars( $tback, ENT_NOQUOTES
); ?
></span
></a
>
173 <form action
="immunizations.php" name
="add_immunization" id
="add_immunization">
174 <input type
="hidden" name
="mode" id
="mode" value
="add">
175 <input type
="hidden" name
="id" id
="id" value
="<?php echo htmlspecialchars( $id, ENT_QUOTES); ?>">
176 <input type
="hidden" name
="pid" id
="pid" value
="<?php echo htmlspecialchars( $pid, ENT_QUOTES); ?>">
178 <table border
=0 cellpadding
=1 cellspacing
=1>
180 <?php
if (!($useCVX)) { ?
>
184 <?php
echo htmlspecialchars( xl('Immunization'), ENT_NOQUOTES
); ?
>
189 // Modified 7/2009 by BM to incorporate the immunization items into the list_options listings
190 generate_form_field(array('data_type'=>1,'field_id'=>'immunization_id','list_id'=>'immunizations','empty_title'=>'SKIP'), $immunization_id);
196 <td align
="right" valign
="top" style
="padding-top:4px;">
198 <?php
echo htmlspecialchars( xl('Immunization'), ENT_NOQUOTES
); ?
> (<?php
echo htmlspecialchars( xl('CVX Code'), ENT_NOQUOTES
); ?
>)
202 <input type
='text' size
='10' name
='cvx_code' id
='cvx_code'
203 value
='<?php echo htmlspecialchars($cvx_code,ENT_QUOTES); ?>' onclick
='sel_cvxcode(this)'
204 title
='<?php echo htmlspecialchars( xl('Click to select
or change CVX code
'), ENT_QUOTES); ?>'
206 <div id
='cvx_description' style
='display:inline; float:right; padding:3px; margin-left:3px; width:400px'>
207 <?php
echo htmlspecialchars( xl( $code_text ), ENT_QUOTES
); ?
>
216 <?php
echo htmlspecialchars( xl('Date Administered'), ENT_NOQUOTES
); ?
>
221 <input type
='text' size
='10' name
="administered_date" id
="administered_date"
222 value
='<?php echo $administered_date ? htmlspecialchars( $administered_date, ENT_QUOTES) : date('Y
-m
-d
'); ?>'
223 title
='<?php echo htmlspecialchars( xl('yyyy
-mm
-dd
'), ENT_QUOTES); ?>'
224 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc);'
226 <img src
='<?php echo $rootdir; ?>/pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
227 id
='img_administered_date' border
='0' alt
='[?]' style
='cursor:pointer;cursor:hand'
228 title
='<?php echo htmlspecialchars( xl('Click here to choose a date
'), ENT_QUOTES); ?>'>
235 <?php
echo htmlspecialchars( xl('Immunization Manufacturer'), ENT_NOQUOTES
); ?
>
239 <input
class='text' type
='text' name
="manufacturer" size
="25" value
="<?php echo htmlspecialchars( $manufacturer, ENT_QUOTES); ?>">
245 <?php
echo htmlspecialchars( xl('Immunization Lot Number'), ENT_NOQUOTES
); ?
>
249 <input
class='text' type
='text' name
="lot_number" size
="25" value
="<?php echo htmlspecialchars( $lot_number, ENT_QUOTES); ?>">
255 <?php
echo htmlspecialchars( xl('Name and Title of Immunization Administrator'), ENT_NOQUOTES
); ?
>
259 <input type
="text" name
="administered_by" id
="administered_by" size
="25" value
="<?php echo htmlspecialchars( $administered_by, ENT_QUOTES); ?>">
260 <?php
echo htmlspecialchars( xl('or choose'), ENT_NOQUOTES
); ?
>
262 <select name
="administered_by_id" id
='administered_by_id'>
263 <option value
=""></option
>
265 $sql = "select id, concat(lname,', ',fname) as full_name " .
266 "from users where username != '' " .
267 "order by concat(lname,', ',fname)";
269 $result = sqlStatement($sql);
270 while($row = sqlFetchArray($result)){
271 echo '<OPTION VALUE=' . htmlspecialchars( $row{'id'}, ENT_QUOTES
);
272 echo (isset($administered_by_id) && $administered_by_id != "" ?
$administered_by_id : $_SESSION['authId']) == $row{'id'} ?
' selected>' : '>';
273 echo htmlspecialchars( $row{'full_name'}, ENT_NOQUOTES
) . '</OPTION>';
280 <td align
="right" class="text">
281 <?php
echo htmlspecialchars( xl('Date Immunization Information Statements Given'), ENT_NOQUOTES
); ?
>
284 <input type
='text' size
='10' name
="education_date" id
="education_date"
285 value
='<?php echo $education_date? htmlspecialchars( $education_date, ENT_QUOTES) : date('Y
-m
-d
'); ?>'
286 title
='<?php echo htmlspecialchars( xl('yyyy
-mm
-dd
'), ENT_QUOTES); ?>'
287 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc);'
289 <img src
='<?php echo $rootdir; ?>/pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
290 id
='img_education_date' border
='0' alt
='[?]' style
='cursor:pointer;'
291 title
='<?php echo htmlspecialchars( xl('Click here to choose a date
'), ENT_QUOTES); ?>'
296 <td align
="right" class="text">
297 <?php
echo htmlspecialchars( xl('Date of VIS Statement'), ENT_NOQUOTES
); ?
>
298 (<a href
="http://www.cdc.gov/vaccines/pubs/vis/default.htm" title
="<?php echo htmlspecialchars( xl('Help'), ENT_QUOTES); ?>" target
="_blank">?
</a
>)
301 <input type
='text' size
='10' name
="vis_date" id
="vis_date"
302 value
='<?php echo $vis_date ? htmlspecialchars( $vis_date, ENT_QUOTES) : date('Y
-m
-d
'); ?>'
303 title
='<?php echo htmlspecialchars( xl('yyyy
-mm
-dd
'), ENT_QUOTES); ?>'
304 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc);'
306 <img src
='<?php echo $rootdir; ?>/pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
307 id
='img_vis_date' border
='0' alt
='[?]' style
='cursor:pointer;'
308 title
='<?php echo htmlspecialchars( xl('Click here to choose a date
'), ENT_QUOTES); ?>'
313 <td align
="right" class='text'>
314 <?php
echo htmlspecialchars( xl('Notes'), ENT_NOQUOTES
); ?
>
317 <textarea
class='text' name
="note" id
="note" rows
=5 cols
=25><?php
echo htmlspecialchars( $note, ENT_NOQUOTES
); ?
></textarea
>
321 <td colspan
="3" align
="center">
323 <input type
="button" name
="save" id
="save" value
="<?php echo htmlspecialchars( xl('Save Immunization'), ENT_QUOTES); ?>">
325 <input type
="button" name
="print" id
="print" value
="<?php echo htmlspecialchars( xl('Print Record') . xl('PDF','',' (',')'), ENT_QUOTES); ?>">
327 <input type
="button" name
="printHtml" id
="printHtml" value
="<?php echo htmlspecialchars( xl('Print Record') . xl('HTML','',' (',')'), ENT_QUOTES); ?>">
329 <input type
="reset" name
="clear" id
="clear" value
="<?php echo htmlspecialchars( xl('Clear'), ENT_QUOTES); ?>">
335 <div id
="immunization_list">
337 <table border
=0 cellpadding
=3 cellspacing
=0>
339 <!-- some columns are sortable
-->
340 <tr
class='text bold'>
342 <a href
="javascript:top.restoreSession();location.href='immunizations.php?sortby=vacc';" title
='<?php echo htmlspecialchars( xl('Sort by vaccine
'), ENT_QUOTES); ?>'>
343 <?php
echo htmlspecialchars( xl('Vaccine'), ENT_NOQUOTES
); ?
></a
>
344 <span
class='small' style
='font-family:arial'><?php
if ($sortby == 'vacc') { echo 'v'; } ?
></span
>
347 <a href
="javascript:top.restoreSession();location.href='immunizations.php?sortby=date';" title
='<?php echo htmlspecialchars( xl('Sort by date
'), ENT_QUOTES); ?>'>
348 <?php
echo htmlspecialchars( xl('Date'), ENT_NOQUOTES
); ?
></a
>
349 <span
class='small' style
='font-family:arial'><?php
if ($sortby == 'date') { echo 'v'; } ?
></span
>
351 <th
><?php
echo htmlspecialchars( xl('Manufacturer'), ENT_NOQUOTES
); ?
></th
>
352 <th
><?php
echo htmlspecialchars( xl('Lot Number'), ENT_NOQUOTES
); ?
></th
>
353 <th
><?php
echo htmlspecialchars( xl('Administered By'), ENT_NOQUOTES
); ?
></th
>
354 <th
><?php
echo htmlspecialchars( xl('Education Date'), ENT_NOQUOTES
); ?
></th
>
355 <th
><?php
echo htmlspecialchars( xl('Note'), ENT_NOQUOTES
); ?
></th
>
360 $sql = "select i1.id ,i1.immunization_id, i1.cvx_code, i1.administered_date, c.code_text_short, c.code".
361 ",i1.manufacturer ,i1.lot_number ".
362 ",ifnull(concat(u.lname,', ',u.fname),'Other') as administered_by ".
363 ",i1.education_date ,i1.note ".
364 " from immunizations i1 ".
365 " left join users u on i1.administered_by_id = u.id ".
366 " left join codes c on CAST(IFNULL(i1.cvx_code,0) AS CHAR) = c.code ".
367 " left join code_types ct on c.code_type = ct.ct_id ".
368 " where patient_id = ? ".
369 " AND (( i1.cvx_code = '0' OR i1.cvx_code IS NULL ) OR ".
370 " ( (i1.cvx_code != '0' AND i1.cvx_code IS NOT NULL ) AND ct.ct_key = 'CVX') ) ".
372 if ($sortby == "vacc") {
373 $sql .= " c.code_text_short, i1.immunization_id, i1.administered_date DESC";
375 else { $sql .= " administered_date desc"; }
377 $result = sqlStatement($sql, array($pid) );
378 while($row = sqlFetchArray($result)) {
379 if ($row["id"] == $id) {
380 echo "<tr class='immrow text selected' id='".htmlspecialchars( $row["id"], ENT_QUOTES
)."'>";
383 echo "<tr class='immrow text' id='".htmlspecialchars( $row["id"], ENT_QUOTES
)."'>";
386 // Figure out which name to use (ie. from cvx list or from the custom list)
387 if ($GLOBALS['use_custom_immun_list']) {
388 $vaccine_display = generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']);
391 if (!empty($row['code_text_short'])) {
392 $vaccine_display = htmlspecialchars( xl($row['code_text_short']), ENT_NOQUOTES
);
395 $vaccine_display = generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']);
399 echo "<td>" . $vaccine_display . "</td>";
401 echo "<td>" . htmlspecialchars( $row["administered_date"], ENT_NOQUOTES
) . "</td>";
402 echo "<td>" . htmlspecialchars( $row["manufacturer"], ENT_NOQUOTES
) . "</td>";
403 echo "<td>" . htmlspecialchars( $row["lot_number"], ENT_NOQUOTES
) . "</td>";
404 echo "<td>" . htmlspecialchars( $row["administered_by"], ENT_NOQUOTES
) . "</td>";
405 echo "<td>" . htmlspecialchars( $row["education_date"], ENT_NOQUOTES
) . "</td>";
406 echo "<td>" . htmlspecialchars( $row["note"], ENT_NOQUOTES
) . "</td>";
407 echo "<td><input type='button' class='delete' id='".htmlspecialchars( $row["id"], ENT_QUOTES
)."' value='" . htmlspecialchars( xl('Delete'), ENT_QUOTES
) . "'></td>";
414 </div
> <!-- end immunizations
-->
418 <script language
="javascript">
419 /* required for popup calendar */
420 Calendar
.setup({inputField
:"administered_date", ifFormat
:"%Y-%m-%d", button
:"img_administered_date"});
421 Calendar
.setup({inputField
:"education_date", ifFormat
:"%Y-%m-%d", button
:"img_education_date"});
422 Calendar
.setup({inputField
:"vis_date", ifFormat
:"%Y-%m-%d", button
:"img_vis_date"});
424 // jQuery stuff to make the page a little easier to use
426 $
(document
).ready(function(){
427 <?php
if (!($useCVX)) { ?
>
428 $
("#save").click(function() { SaveForm(); });
430 $
("#save").click(function() {
431 if (validate_cvx()) {
439 $
("#print").click(function() { PrintForm("pdf"); });
440 $
("#printHtml").click(function() { PrintForm("html"); });
441 $
(".immrow").click(function() { EditImm(this
); });
442 $
(".delete").click(function(event
) { DeleteImm(this
); event
.stopPropagation(); });
444 $
(".immrow").mouseover(function() { $
(this
).toggleClass("highlight"); });
445 $
(".immrow").mouseout(function() { $
(this
).toggleClass("highlight"); });
447 $
("#administered_by_id").change(function() { $
("#administered_by").val($
("#administered_by_id :selected").text()); });
449 $
("#form_immunization_id").change( function() {
450 if ( $
(this
).val() != "" ) {
451 $
("#cvx_code").val( "" );
452 $
("#cvx_description").text( "" );
453 $
("#cvx_code").change();
458 var PrintForm
= function(typ
) {
459 top
.restoreSession();
460 newURL
='shot_record.php?output='+typ+
'&sortby=<?php echo $sortby; ?>';
462 location
.href
=newURL
;
465 window
.open(newURL
, '_blank', "menubar=1,toolbar=1,scrollbars=1,resizable=1,width=600,height=450");
469 var SaveForm
= function() {
470 top
.restoreSession();
471 $
("#add_immunization").submit();
474 var EditImm
= function(imm
) {
475 top
.restoreSession();
476 location
.href
='immunizations.php?mode=edit&id='+imm
.id
;
479 var DeleteImm
= function(imm
) {
480 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); ?>")) {
481 top
.restoreSession();
482 location
.href
='immunizations.php?mode=delete&id='+imm
.id
;
486 //This is for callback by the find-code popup.
487 //Appends to or erases the current list of diagnoses.
488 function set_related(codetype
, code
, selector
, codedesc
) {
489 var f
= document
.forms
[0][current_sel_name
];
500 $
("#cvx_description").text( codedesc
);
501 $
("#form_immunization_id").attr( "value", "" );
502 $
("#form_immunization_id").change();
506 // This invokes the find-code popup.
507 function sel_cvxcode(e
) {
508 current_sel_name
= e
.name
;
509 dlgopen('../encounter/find_code_popup.php?codetype=CVX', '_blank', 500, 400);
512 // This ensures the cvx centric entry is filled.
513 function validate_cvx() {
514 if (document
.add_immunization
.cvx_code
.value
>0) {
518 document
.add_immunization
.cvx_code
.style
.backgroundColor
="red";
519 document
.add_immunization
.cvx_code
.focus();