74a29bf1bba5c86fb36386f6a0ff3d7c51e1409a
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 //collect facility data
16 $res = sqlQuery("select concat(f.name,'\n',f.street,'\n',f.city,', ',f.state,' ',f.postal_code) as facility_address ".
17 " from facility f, users u ".
18 " where u.facility = f.name ".
19 " and u.id = ?", array($_SESSION['authId'])
22 //collect patient data
23 $res2 = sqlQuery("select concat(p.lname,', ',p.fname,' ',p.mname) patient_name ".
24 ",date_format(p.DOB,'%c/%e/%Y') as patient_DOB ".
25 ",concat(p.street,'\n',p.city,', ',p.state,' ',p.postal_code) as patient_address".
26 " from patient_data p where p.pid = ?", array($pid)
29 //collect immunizations
30 $sqlstmt = "select date_format(i1.administered_date,'%Y-%m-%d') as '" . xl('Date') . "\n" . xl('Administered') . "' ".
31 ",i1.immunization_id as '" . xl('Vaccine') . "' ".
32 ",c.code_text_short as cvx_text ".
33 ",i1.manufacturer as '" . xl('Manufacturer') . "' ".
34 ",i1.lot_number as '" . xl('Lot') . "\n" . xl('Number') . "' ".
35 ",concat(u.lname,', ',u.fname) as '" . xl('Administered By') . "' ".
36 ",date_format(i1.education_date,'%Y-%m-%d') as '" . xl('Patient') . "\n" . xl('Education') . "\n" . xl('Date') . "' ".
37 ",i1.note as '" . xl('Comments') . "'".
38 " from immunizations i1 ".
39 " left join users u on i1.administered_by_id = u.id ".
40 " left join patient_data p on i1.patient_id = p.pid ".
41 " left join code_types ct on ct.ct_key = 'CVX' ".
42 " left join codes c on c.code_type = ct.ct_id AND i1.cvx_code = c.code ".
45 // sort the results, as they are on the user's screen
46 $sqlstmt .= " order by ";
47 if ($_GET['sortby'] == "vacc") { $sqlstmt .= " i1.immunization_id, i1.administered_date DESC"; }
48 else { $sqlstmt .= " i1.administered_date desc"; }
50 $res3 = sqlStatement($sqlstmt, array($pid) );
52 while ($data[] = sqlFetchArray($res3)) {}
54 for ($i=0;$i<count($data);$i++
) {
55 // Figure out which name to use (ie. from cvx list or from the custom list)
56 if ($GLOBALS['use_custom_immun_list']) {
57 $data[$i][xl('Vaccine')] = generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $data[$i][xl('Vaccine')]);
60 if (!(empty($data[$i]['cvx_text']))) {
61 $data[$i][xl('Vaccine')] = htmlspecialchars( xl($data[$i]['cvx_text']), ENT_NOQUOTES
);
64 $data[$i][xl('Vaccine')] = generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $data[$i][xl('Vaccine')]);
67 unset( $data[$i]['cvx_text'] );
71 $title = xl('Shot Record as of:','','',' ') . date('m/d/Y h:i:s a');
74 if ($_GET['output'] == "html") { //print html css
76 //convert end of line characters to html (escape for html output first)
77 $patterns = array ('/\n/');
78 $replace = array ('<br>');
79 $res['facility_address'] = htmlspecialchars( $res['facility_address'], ENT_NOQUOTES
);
80 $res['facility_address'] = preg_replace($patterns, $replace, $res['facility_address']);
81 $res2['patient_address'] = htmlspecialchars( $res2['patient_address'], ENT_NOQUOTES
);
82 $res2['patient_address'] = preg_replace($patterns, $replace, $res2['patient_address']);
84 //deal with bug (last array index is empty)
93 font
-family
: sans
-serif
;
106 page
-break-after
: always
;
109 margin
: 20pt
0 10pt
0;
118 margin
: 30pt
0 0 20pt
;
126 margin
: 0 20pt
0 20pt
;
127 border
-collapse
: collapse
;
128 border
: 1pt solid black
;
132 padding
: 2pt
3pt
2pt
3pt
;
133 border
-right
: 1pt solid black
;
134 border
-left
: 1pt solid black
;
137 background
-color
: #D8D8D8;
141 border
: 1pt solid black
;
142 padding
: 2pt
3pt
2pt
3pt
;
151 <title
><?php
xl ('Shot Record','e'); ?
></title
>
156 //plan 15 lines per page
158 $countTotalPages = (ceil((count($data))/$linesPerPage));
159 for ($i=0;$i<$countTotalPages;$i++
) {
160 echo "<div class='paddingdiv'>\n";
162 //display facility information (Note it is already escaped)
163 echo "<div class='clinicAddress'>" . $res['facility_address'] . "</div>\n";
165 //display patient information (Note patient address is already escaped)
166 echo "<div class='patientAddress'>" . htmlspecialchars( $res2['patient_name'], ENT_NOQUOTES
) . "<br>" .
167 htmlspecialchars( xl('Date of Birth') . ": " . $res2['patient_DOB'], ENT_NOQUOTES
) . "<br>" .
168 $res2['patient_address'] . "</div>\n";
170 //display table title
171 echo "<div class='tabletitle'>" . htmlspecialchars( $title, ENT_NOQUOTES
) . "</div>\n";
173 echo "<table cellspacing='0' cellpadding='0'>\n";
177 foreach ($data[0] as $key => $value) {
178 //convert end of line characters to space
179 $patterns = array ('/\n/');
180 $replace = array (' ');
181 $key = preg_replace($patterns, $replace, $key);
182 echo "<th>".htmlspecialchars( $key, ENT_NOQUOTES
)."</th>\n";
187 for ($j=0;$j<$linesPerPage;$j++
) {
188 if ($rowData = array_shift($data)) {
190 foreach ($rowData as $key => $value) {
197 echo "<td class ='odd'>";
203 // output data of cell
204 echo ($value == "") ?
" " : htmlspecialchars($value, ENT_NOQUOTES
);
210 //done displaying shot data, so leave loop
217 //display signature line
218 echo "<div class='sign'>" . htmlspecialchars( xl('Signature'), ENT_NOQUOTES
) .
219 ":________________________________" . "</div>\n";
221 if ($countTotalPages > 1) {
222 //display page number if greater than one page
223 echo "<div class='pageNumber'>" .
224 htmlspecialchars( xl('Page') . " " . ($i+
1) . "/" . $countTotalPages, ENT_NOQUOTES
) .
233 <script language
='JavaScript'>
243 require_once ($GLOBALS['fileroot'] . "/library/classes/class.ezpdf.php");
245 $pdf =& new Cezpdf("LETTER");
246 $pdf->ezSetMargins(72,30,50,30);
247 $pdf->selectFont($GLOBALS['fileroot'] . "/library/fonts/Helvetica.afm");
249 $opts = array('justification' => "center");
250 $pdf->ezText($res['facility_address'] ,"",$opts);
252 $pdf->ezText("\n" . $res2['patient_name'] . "\n" . xl('Date of Birth') . ": " . $res2['patient_DOB'] . "\n" . $res2['patient_address']);
255 $opts = array('maxWidth' => 504, 'fontSize' => 8);
257 $pdf->ezTable($data, "", $title, $opts);
259 $pdf->ezText("\n\n\n\n" . xl('Signature') . ":________________________________","",array('justification' => 'right'));