internationalizatio bug fix
[openemr.git] / interface / patient_file / summary / immunizations.php
blob99e5910b5179ff885ef88e464d95fb2c27e2738a
1 <?php
2 include_once("../../globals.php");
3 include_once("$srcdir/sql.inc");
4 include_once("$srcdir/options.inc.php");
6 if (isset($mode)) {
7 if ($mode == "add" ) {
8 $sql = "REPLACE INTO immunizations set
9 id = '" . mysql_real_escape_string($id) . "',
10 administered_date = if('" . mysql_real_escape_string($administered_date) . "','" . mysql_real_escape_string($administered_date) . "',NULL),
11 immunization_id = '" . mysql_real_escape_string($form_immunization_id) . "',
12 manufacturer = '" . mysql_real_escape_string($manufacturer) . "',
13 lot_number = '" . mysql_real_escape_string($lot_number) . "',
14 administered_by_id = if(" . mysql_real_escape_string($administered_by_id) . "," . mysql_real_escape_string($administered_by_id) . ",NULL),
15 administered_by = if('" . mysql_real_escape_string($administered_by) . "','" . mysql_real_escape_string($administered_by) . "',NULL),
16 education_date = if('" . mysql_real_escape_string($education_date) . "','" . mysql_real_escape_string($education_date) . "',NULL),
17 vis_date = if('" . mysql_real_escape_string($vis_date) . "','" . mysql_real_escape_string($vis_date) . "',NULL),
18 note = '" . mysql_real_escape_string($note) . "',
19 patient_id = '" . mysql_real_escape_string($pid) . "',
20 created_by = '" . mysql_real_escape_string($_SESSION['authId']) . "',
21 updated_by = '" . mysql_real_escape_string($_SESSION['authId']) . "',
22 create_date = now() ";
23 sqlStatement($sql);
24 $administered_date=$education_date=date('Y-m-d');
25 $immunization_id=$manufacturer=$lot_number=$administered_by_id=$note=$id="";
26 $administered_by=$vis_date="";
28 elseif ($mode == "delete" ) {
29 // log the event
30 newEvent("delete", $_SESSION['authUser'], $_SESSION['authProvider'], "Immunization id ".$_POST['id']." deleted from pid ".$_POST['pid']);
31 // delete the immunization
32 $sql="DELETE FROM immunizations WHERE id =". mysql_real_escape_string($id)." LIMIT 1";
33 sqlStatement($sql);
35 elseif ($mode == "edit" ) {
36 $sql = "select * from immunizations where id = " . mysql_real_escape_string($id);
37 $results = sqlQ($sql);
38 while ($row = mysql_fetch_assoc($results)) {
39 $administered_date = $row['administered_date'];
40 $immunization_id = $row['immunization_id'];
41 $manufacturer = $row['manufacturer'];
42 $lot_number = $row['lot_number'];
43 $administered_by_id = ($row['administered_by_id'] ? $row['administered_by_id'] : 0);
44 $administered_by = $row['administered_by'];
45 $education_date = $row['education_date'];
46 $vis_date = $row['vis_date'];
47 $note = stripslashes($row['note']);
52 // set the default sort method for the list of past immunizations
53 if (!$sortby) { $sortby = 'vacc'; }
55 // set the default value of 'administered_by'
56 if (!$administered_by && !$administered_by_id) {
57 $stmt = "select concat(lname,', ',fname) as full_name ".
58 " from users where ".
59 " id='".$_SESSION['authId']."'";
60 $row = sqlQuery($stmt);
61 $administered_by = $row['full_name'];
64 <html>
65 <head>
66 <?php html_header_show();?>
68 <!-- supporting javascript code -->
69 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script>
70 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js"></script>
72 <!-- page styles -->
73 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
75 <!-- pop up calendar -->
76 <style type="text/css">@import url(<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.css);</style>
77 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.js"></script>
78 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar_en.js"></script>
79 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar_setup.js"></script>
81 <script language="JavaScript">
82 // required to validate date text boxes
83 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
84 </script>
86 </head>
88 <body class="body_top">
90 <?php if ($GLOBALS['concurrent_layout']) { ?>
91 <span class="title"><?php xl('Immunizations','e'); ?></span>
92 <?php } else { ?>
93 <a href="patient_summary.php" target="Main" onclick="top.restoreSession()">
94 <span class="title"><?php xl('Immunizations','e'); ?></span>
95 <span class=back><?php echo $tback;?></span></a>
96 <?php } ?>
98 <form action="immunizations.php" name="add_immunization" id="add_immunization">
99 <input type="hidden" name="mode" id="mode" value="add">
100 <input type="hidden" name="id" id="id" value="<?php echo $id?>">
101 <input type="hidden" name="pid" id="pid" value="<?php echo $pid?>">
102 <br>
103 <table border=0 cellpadding=1 cellspacing=1>
105 <tr>
106 <td align="right">
107 <span class=text>
108 <?php xl('Immunization','e'); ?>
109 </span>
110 </td>
111 <td>
112 <?php
113 // Modified 7/2009 by BM to incorporate the immunization items into the list_options listings
114 generate_form_field(array('data_type'=>1,'field_id'=>'immunization_id','list_id'=>'immunizations','empty_title'=>'SKIP'), $immunization_id);
116 </td>
117 </tr>
118 <tr>
119 <td align="right">
120 <span class=text>
121 <?php xl('Date Administered','e'); ?>
122 </span>
123 </td>
124 <td>
126 <input type='text' size='10' name="administered_date" id="administered_date"
127 value='<?php echo $administered_date ? $administered_date : date('Y-m-d'); ?>'
128 title='<?php xl('yyyy-mm-dd','e'); ?>'
129 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc);'
131 <img src='<?php echo $rootdir; ?>/pic/show_calendar.gif' align='absbottom' width='24' height='22'
132 id='img_administered_date' border='0' alt='[?]' style='cursor:pointer;cursor:hand'
133 title='<?php xl('Click here to choose a date','e'); ?>'>
135 </td>
136 </tr>
137 <tr>
138 <td align="right">
139 <span class=text>
140 <?php xl('Immunization Manufacturer','e'); ?>
141 </span>
142 </td>
143 <td>
144 <input class='text' type='text' name="manufacturer" size="25" value="<?php echo mysql_real_escape_string($manufacturer) ?>">
145 </td>
146 </tr>
147 <tr>
148 <td align="right">
149 <span class=text>
150 <?php xl('Immunization Lot Number','e'); ?>
151 </span>
152 </td>
153 <td>
154 <input class='text' type='text' name="lot_number" size="25" value="<?php echo mysql_real_escape_string($lot_number) ?>">
155 </td>
156 </tr>
157 <tr>
158 <td align="right">
159 <span class='text'>
160 <?php xl('Name and Title of Immunization Administrator','e'); ?>
161 </span>
162 </td>
163 <td class='text'>
164 <input type="text" name="administered_by" id="administered_by" size="25" value="<?php echo $administered_by; ?>">
165 <?php xl('or choose','e'); ?>
166 <!-- NEEDS WORK -->
167 <select name="administered_by_id" id='administered_by_id'>
168 <option value=""></option>
169 <?php
170 $sql = "select id, concat(lname,', ',fname) as full_name " .
171 "from users where username != '' " .
172 "order by concat(lname,', ',fname)";
174 $result = sqlStatement($sql);
175 while($row = sqlFetchArray($result)){
176 echo '<OPTION VALUE=' . $row{'id'};
177 echo (isset($administered_by_id) && $administered_by_id != "" ? $administered_by_id : $_SESSION['authId']) == $row{'id'} ? ' selected>' : '>';
178 echo $row{'full_name'} . '</OPTION>';
181 </select>
182 </td>
183 </tr>
184 <tr>
185 <td align="right" class="text">
186 <?php xl('Date Immunization Information Statements Given','e'); ?>
187 </td>
188 <td>
189 <input type='text' size='10' name="education_date" id="education_date"
190 value='<?php echo $education_date? $education_date : date('Y-m-d'); ?>'
191 title='<?php xl('yyyy-mm-dd','e'); ?>'
192 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc);'
194 <img src='<?php echo $rootdir; ?>/pic/show_calendar.gif' align='absbottom' width='24' height='22'
195 id='img_education_date' border='0' alt='[?]' style='cursor:pointer;'
196 title='<?php xl('Click here to choose a date','e'); ?>'
198 </td>
199 </tr>
200 <tr>
201 <td align="right" class="text">
202 <?php xl('Date of VIS Statement','e'); ?>
203 (<a href="http://www.cdc.gov/vaccines/pubs/vis/default.htm" title="<?php xl('Help','e'); ?>" target="_blank">?</a>)
204 </td>
205 <td>
206 <input type='text' size='10' name="vis_date" id="vis_date"
207 value='<?php echo $vis_date ? $vis_date : date('Y-m-d'); ?>'
208 title='<?php xl('yyyy-mm-dd','e'); ?>'
209 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc);'
211 <img src='<?php echo $rootdir; ?>/pic/show_calendar.gif' align='absbottom' width='24' height='22'
212 id='img_vis_date' border='0' alt='[?]' style='cursor:pointer;'
213 title='<?php xl('Click here to choose a date','e'); ?>'
215 </td>
216 </tr>
217 <tr>
218 <td align="right" class='text'>
219 <?php xl('Notes','e'); ?>
220 </td>
221 <td>
222 <textarea class='text' name="note" id="note" rows=5 cols=25><?php echo $note ?></textarea>
223 </td>
224 </tr>
225 <tr>
226 <td colspan="3" align="center">
228 <input type="button" name="save" id="save" value="<?php xl('Save Immunization','e'); ?>">
230 <input type="button" name="print" id="print" value="<?php echo xl('Print Record') . xl('PDF','',' (',')'); ?>">
232 <input type="button" name="printHtml" id="printHtml" value="<?php echo xl('Print Record') . xl('HTML','',' (',')'); ?>">
234 <input type="reset" name="clear" id="clear" value="<?php xl('Clear','e'); ?>">
235 </td>
236 </tr>
237 </table>
238 </form>
240 <div id="immunization_list">
242 <table border=0 cellpadding=3 cellspacing=0>
244 <!-- some columns are sortable -->
245 <tr class='text bold'>
246 <th>
247 <a href="javascript:top.restoreSession();location.href='immunizations.php?sortby=vacc';" title=<?php xl('Sort by vaccine','e','\'','\''); ?>><?php xl('Vaccine','e'); ?></a>
248 <span class='small' style='font-family:arial'><?php if ($sortby == 'vacc') { echo 'v'; } ?></span>
249 </th>
250 <th>
251 <a href="javascript:top.restoreSession();location.href='immunizations.php?sortby=date';" title=<?php xl('Sort by date','e','\'','\''); ?>><?php xl('Date','e'); ?></a>
252 <span class='small' style='font-family:arial'><?php if ($sortby == 'date') { echo 'v'; } ?></span>
253 </th>
254 <th><?php xl('Manufacturer','e'); ?></th>
255 <th><?php xl('Lot Number','e'); ?></th>
256 <th><?php xl('Administered By','e'); ?></th>
257 <th><?php xl('Education Date','e'); ?></th>
258 <th><?php xl('Note','e'); ?></th>
259 <th>&nbsp;</th>
260 </tr>
262 <?php
263 $sql = "select i1.id ,i1.immunization_id ,i1.administered_date ".
264 ",i1.manufacturer ,i1.lot_number ".
265 ",ifnull(concat(u.lname,', ',u.fname),'Other') as administered_by ".
266 ",i1.education_date ,i1.note ".
267 " from immunizations i1 ".
268 " left join users u on i1.administered_by_id = u.id ".
269 " where patient_id = $pid ".
270 " order by ";
271 if ($sortby == "vacc") { $sql .= " i1.immunization_id, i1.administered_date DESC"; }
272 else { $sql .= " administered_date desc"; }
274 $result = sqlStatement($sql);
275 while($row = sqlFetchArray($result)) {
276 if ($row["id"] == $id) {
277 echo "<tr class='immrow text selected' id='".$row["id"]."'>";
279 else {
280 echo "<tr class='immrow text' id='".$row["id"]."'>";
282 // Modified 7/2009 by BM to utilize immunization items from the pertinent list in list_options
283 echo "<td>" . generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']) . "</td>";
284 echo "<td>" . $row["administered_date"] . "</td>";
285 echo "<td>" . $row["manufacturer"] . "</td>";
286 echo "<td>" . $row["lot_number"] . "</td>";
287 echo "<td>" . $row["administered_by"] . "</td>";
288 echo "<td>" . $row["education_date"] . "</td>";
289 echo "<td>" . $row["note"] . "</td>";
290 echo "<td><input type='button' class='delete' id='".$row["id"]."' value='" . xl('Delete') . "'></td>";
291 echo "</tr>";
296 </table>
297 </div> <!-- end immunizations -->
299 </body>
301 <script language="javascript">
302 /* required for popup calendar */
303 Calendar.setup({inputField:"administered_date", ifFormat:"%Y-%m-%d", button:"img_administered_date"});
304 Calendar.setup({inputField:"education_date", ifFormat:"%Y-%m-%d", button:"img_education_date"});
305 Calendar.setup({inputField:"vis_date", ifFormat:"%Y-%m-%d", button:"img_vis_date"});
307 // jQuery stuff to make the page a little easier to use
309 $(document).ready(function(){
310 $("#save").click(function() { SaveForm(); });
311 $("#print").click(function() { PrintForm("pdf"); });
312 $("#printHtml").click(function() { PrintForm("html"); });
313 $(".immrow").click(function() { EditImm(this); });
314 $(".delete").click(function(event) { DeleteImm(this); event.stopPropagation(); });
316 $(".immrow").mouseover(function() { $(this).toggleClass("highlight"); });
317 $(".immrow").mouseout(function() { $(this).toggleClass("highlight"); });
319 $("#administered_by_id").change(function() { $("#administered_by").val($("#administered_by_id :selected").text()); });
322 var PrintForm = function(typ) {
323 top.restoreSession();
324 newURL='shot_record.php?output='+typ+'&sortby=<?php echo $sortby; ?>';
325 if (typ=="pdf") {
326 location.href=newURL;
328 else { // typ=html
329 window.open(newURL, '_blank', "menubar=1,toolbar=1,scrollbars=1,resizable=1,width=600,height=450");
333 var SaveForm = function() {
334 top.restoreSession();
335 $("#add_immunization").submit();
338 var EditImm = function(imm) {
339 top.restoreSession();
340 location.href='immunizations.php?mode=edit&id='+imm.id;
343 var DeleteImm = function(imm) {
344 if (confirm("<?php xl('This action cannot be undone.','e'); ?>" + "\n" +"<?php xl('Do you wish to PERMANENTLY delete this immunization record?','e'); ?>")) {
345 top.restoreSession();
346 location.href='immunizations.php?mode=delete&id='+imm.id;
350 </script>
352 </html>