5 include_once("../../globals.php");
6 include_once("$srcdir/options.inc.php");
7 include_once("$srcdir/immunization_helper.php");
9 $facilityService = new \services\
FacilityService();
11 //collect facility data
12 $res = $facilityService->getFacilityForUserFormatted($_SESSION['authId']);
14 //collect patient data
15 $res2 = sqlQuery("select concat(p.lname,', ',p.fname,' ',p.mname) patient_name ".
16 ",date_format(p.DOB,'%c/%e/%Y') as patient_DOB ".
17 ",concat(p.street,'\n',p.city,', ',p.state,' ',p.postal_code) as patient_address".
18 " from patient_data p where p.pid = ?", array($pid));
20 //collect immunizations
21 $res3 = getImmunizationList($pid, $_GET['sortby'], false);
22 $data_array = convertToDataArray($res3);
24 $title = xl('Shot Record as of:', '', '', ' ') . date('m/d/Y h:i:s a');
26 if ($_GET['output'] == "html") {
27 printHTML($res, $res2, $data_array);
29 printPDF($res, $res2, $data_array);
33 function convertToDataArray($data_array)
36 while ($row = sqlFetchArray($data_array)) {
38 $temp_date = new DateTime($row['administered_date']);
39 $data[$current][xl('Date') . "\n" . xl('Admin')] = $temp_date->format('Y-m-d H:i'); //->format('%Y-%m-%d %H:%i');
42 // Figure out which name to use (ie. from cvx list or from the custom list)
43 if ($GLOBALS['use_custom_immun_list']) {
44 $vaccine_display = generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']);
46 if (!empty($row['code_text_short'])) {
47 $vaccine_display = htmlspecialchars(xl($row['code_text_short']), ENT_NOQUOTES
);
49 $vaccine_display = generate_display_field(array('data_type'=>'1','list_id'=>'immunizations'), $row['immunization_id']);
53 $data[$current][xl('Vaccine')] = $vaccine_display;
56 if ($row['amount_administered'] > 0) {
57 $data[$current][xl('Amount') . "\n" . xl('Admin')] = $row['amount_administered'] . " " .
58 generate_display_field(array('data_type'=>'1','list_id'=>'drug_units'), $row['amount_administered_unit']);
60 $data[$current][xl('Amount') . "\n" . xl('Admin')] = "";
63 //expiration date fixed by checking for empty value, smw 040214
64 if (isset($row['expiration_date'])) {
65 $temp_date = new DateTime($row['expiration_date']);
66 $data[$current][xl('Expiration') . "\n" . xl('Date')] = $temp_date->format('Y-m-d');
68 $data[$current][xl('Expiration') . "\n" . xl('Date')] = '';//$temp_date->format('Y-m-d');
72 $data[$current][xl('Manufacturer')] = $row['manufacturer'];
75 $data[$current][xl('Lot') . "\n" . xl('Number')] = $row['lot_number'];
78 $data[$current][xl('Admin') . "\n" . xl('By')] = $row['administered_by'];
81 $temp_date = new DateTime($row['education_date']);
82 $data[$current][xl('Patient') . "\n" . xl('Education') . "\n" . xl('Date')] = $temp_date->format('Y-m-d');
85 $data[$current][xl('Route')] = generate_display_field(array('data_type'=>'1','list_id'=>'drug_route'), $row['route']);
88 $data[$current][xl('Admin') . "\n" . xl('Site')] = generate_display_field(array('data_type'=>'1','list_id'=>'proc_body_site'), $row['administration_site']);
91 $data[$current][xl('Comments')] = $row['note'];
98 function printPDF($res, $res2, $data)
101 $pdf = new Cezpdf("LETTER");
102 $pdf->ezSetMargins(72, 30, 50, 30);
103 $pdf->selectFont('Helvetica');
105 $opts = array('justification' => "center");
106 $pdf->ezText($res['facility_address'], "", $opts);
108 $pdf->ezText("\n" . $res2['patient_name'] . "\n" . xl('Date of Birth') . ": " . $res2['patient_DOB'] . "\n" . $res2['patient_address']);
111 $opts = array('maxWidth' => 550, 'fontSize' => 8);
113 $pdf->ezTable($data, "", $title, $opts);
114 $pdf->ezText("\n\n\n\n" . xl('Signature') . ":________________________________", "", array('justification' => 'right'));
118 function printHTML($res, $res2, $data)
122 //convert end of line characters to html (escape for html output first)
123 $patterns = array ('/\n/');
124 $replace = array ('<br>');
125 $res['facility_address'] = htmlspecialchars($res['facility_address'], ENT_NOQUOTES
);
126 $res['facility_address'] = preg_replace($patterns, $replace, $res['facility_address']);
127 $res2['patient_address'] = htmlspecialchars($res2['patient_address'], ENT_NOQUOTES
);
128 $res2['patient_address'] = preg_replace($patterns, $replace, $res2['patient_address']);
130 //deal with bug (last array index is empty)
139 font
-family
: sans
-serif
;
152 page
-break-after
: always
;
155 margin
: 20pt
0 10pt
0;
164 margin
: 30pt
0 0 20pt
;
172 margin
: 0 20pt
0 20pt
;
173 border
-collapse
: collapse
;
174 border
: 1pt solid black
;
178 padding
: 2pt
3pt
2pt
3pt
;
179 border
-right
: 1pt solid black
;
180 border
-left
: 1pt solid black
;
183 background
-color
: #D8D8D8;
187 border
: 1pt solid black
;
188 padding
: 2pt
3pt
2pt
3pt
;
197 <title
><?php
xl('Shot Record', 'e'); ?
></title
>
202 //plan 15 lines per page
204 $countTotalPages = (ceil((count($data))/$linesPerPage));
205 for ($i=0; $i<$countTotalPages; $i++
) {
206 echo "<div class='paddingdiv'>\n";
208 //display facility information (Note it is already escaped)
209 echo "<div class='clinicAddress'>" . $res['facility_address'] . "</div>\n";
211 //display patient information (Note patient address is already escaped)
212 echo "<div class='patientAddress'>" . htmlspecialchars($res2['patient_name'], ENT_NOQUOTES
) . "<br>" .
213 htmlspecialchars(xl('Date of Birth') . ": " . $res2['patient_DOB'], ENT_NOQUOTES
) . "<br>" .
214 $res2['patient_address'] . "</div>\n";
216 //display table title
217 echo "<div class='tabletitle'>" . htmlspecialchars($title, ENT_NOQUOTES
) . "</div>\n";
219 echo "<table cellspacing='0' cellpadding='0'>\n";
223 foreach ($data[0] as $key => $value) {
224 //convert end of line characters to space
225 $patterns = array ('/\n/');
226 $replace = array (' ');
227 $key = preg_replace($patterns, $replace, $key);
228 echo "<th>".htmlspecialchars($key, ENT_NOQUOTES
)."</th>\n";
234 for ($j=0; $j<$linesPerPage; $j++
) {
235 if ($rowData = array_shift($data)) {
237 foreach ($rowData as $key => $value) {
242 echo "<td class ='odd'>";
247 // output data of cell
248 echo ($value == "") ?
" " : htmlspecialchars($value, ENT_NOQUOTES
);
252 //done displaying shot data, so leave loop
259 //display signature line
260 echo "<div class='sign'>" . htmlspecialchars(xl('Signature'), ENT_NOQUOTES
) .
261 ":________________________________" . "</div>\n";
263 if ($countTotalPages > 1) {
264 //display page number if greater than one page
265 echo "<div class='pageNumber'>" .
266 htmlspecialchars(xl('Page') . " " . ($i+
1) . "/" . $countTotalPages, ENT_NOQUOTES
) .
275 <script language
='JavaScript'>
276 opener
.top
.printLogPrint(window
);