Highway to PSR2
[openemr.git] / interface / forms / vitals / report.php
blob32c140d32a78bb621d23cb863697680087d565ed
1 <?php
2 include_once("../../globals.php");
3 include_once($GLOBALS["srcdir"]."/api.inc");
4 include_once($GLOBALS['fileroot']."/library/patient.inc");
7 function US_weight($pounds, $mode = 1)
10 if ($mode==1) {
11 return $pounds . " " . xl('lb') ;
12 } else {
13 $pounds_int=floor($pounds);
14 $ounces=round(($pounds-$pounds_int)*16);
15 return $pounds_int . " " . xl('lb') . " " . $ounces . " " . xl('oz');
19 function vitals_report($pid, $encounter, $cols, $id, $print = true)
21 $count = 0;
22 $data = formFetch("form_vitals", $id);
23 $patient_data = getPatientData($GLOBALS['pid']);
24 $patient_age = getPatientAge($patient_data['DOB']);
26 $vitals="";
27 if ($data) {
28 $vitals .= "<table><tr>";
30 foreach ($data as $key => $value) {
31 if ($key == "id" || $key == "pid" ||
32 $key == "user" || $key == "groupname" ||
33 $key == "authorized" || $key == "activity" ||
34 $key == "date" || $value == "" ||
35 $value == "0000-00-00 00:00:00" || $value == "0.0" ) {
36 // skip certain data
37 continue;
40 if ($value == "on") {
41 $value = "yes";
44 $key = ucwords(str_replace("_", " ", $key));
46 //modified by BM 06-2009 for required translation
47 if ($key == "Temp Method" || $key == "BMI Status") {
48 if ($key == "BMI Status") {
49 if ($patient_age <= 20 || (preg_match('/month/', $patient_age))) {
50 $value = "See Growth-Chart";
54 $vitals .= '<td><div class="bold" style="display:inline-block">' . xl($key) . ': </div><div class="text" style="display:inline-block">' . xl($value) . "</div></td>";
55 } elseif ($key == "Bps") {
56 $bps = $value;
57 if ($bpd) {
58 $vitals .= "<td><div class='bold' style='display:inline-block'>" . xl('Blood Pressure') . ": </div><div class='text' style='display:inline-block'>" . $bps . "/". $bpd . "</div></td>";
59 } else {
60 continue;
62 } elseif ($key == "Bpd") {
63 $bpd = $value;
64 if ($bps) {
65 $vitals .= "<td><div class='bold' style='display:inline-block'>" . xl('Blood Pressure') . ": </div><div class='text' style='display:inline-block'>" . $bps . "/". $bpd . "</div></td>";
66 } else {
67 continue;
69 } elseif ($key == "Weight") {
70 $convValue = number_format($value*0.45359237, 2);
71 $vitals.="<td><div class='bold'>" . xl($key) . ": </div><div class='text'>";
72 // show appropriate units
73 $mode=$GLOBALS['us_weight_format'];
74 if ($GLOBALS['units_of_measurement'] == 2) {
75 $vitals .= $convValue . " " . xl('kg') . " (" . US_weight($value, $mode) . ")";
76 } elseif ($GLOBALS['units_of_measurement'] == 3) {
77 $vitals .= US_weight($value, $mode) ;
78 } elseif ($GLOBALS['units_of_measurement'] == 4) {
79 $vitals .= $convValue . " " . xl('kg') ;
80 } else { // = 1 or not set
81 $vitals .= US_weight($value, $mode) . " (" . $convValue . " " . xl('kg') . ")";
84 $vitals.= "</div></td>";
85 } elseif ($key == "Height" || $key == "Waist Circ" || $key == "Head Circ") {
86 $convValue = round(number_format($value*2.54, 2), 1);
87 // show appropriate units
88 if ($GLOBALS['units_of_measurement'] == 2) {
89 $vitals .= "<td><div class='bold' style='display:inline-block'>" . xl($key) . ": </div><div class='text' style='display:inline-block'>" . $convValue . " " . xl('cm') . " (" . $value . " " . xl('in') . ")</div></td>";
90 } elseif ($GLOBALS['units_of_measurement'] == 3) {
91 $vitals .= "<td><div class='bold' style='display:inline-block'>" . xl($key) . ": </div><div class='text' style='display:inline-block'>" . $value . " " . xl('in') . "</div></td>";
92 } elseif ($GLOBALS['units_of_measurement'] == 4) {
93 $vitals .= "<td><div class='bold' style='display:inline-block'>" . xl($key) . ": </div><div class='text' style='display:inline-block'>" . $convValue . " " . xl('cm') . "</div></td>";
94 } else { // = 1 or not set
95 $vitals .= "<td><div class='bold' style='display:inline-block'>" . xl($key) . ": </div><div class='text' style='display:inline-block'>" . $value . " " . xl('in') . " (" . $convValue . " " . xl('cm') . ")</div></td>";
97 } elseif ($key == "Temperature") {
98 $convValue = number_format((($value-32)*0.5556), 2);
99 // show appropriate units
100 if ($GLOBALS['units_of_measurement'] == 2) {
101 $vitals .= "<td><div class='bold' style='display:inline-block'>" . xl($key) . ": </div><div class='text' style='display:inline-block'>" . $convValue . " " . xl('C') . " (" . $value . " " . xl('F') . ")</div></td>";
102 } elseif ($GLOBALS['units_of_measurement'] == 3) {
103 $vitals .= "<td><div class='bold' style='display:inline-block'>" . xl($key) . ": </div><div class='text' style='display:inline-block'>" . $value . " " . xl('F') . "</div></td>";
104 } elseif ($GLOBALS['units_of_measurement'] == 4) {
105 $vitals .= "<td><div class='bold' style='display:inline-block'>" . xl($key) . ": </div><div class='text' style='display:inline-block'>" . $convValue . " " . xl('C') . "</div></td>";
106 } else { // = 1 or not set
107 $vitals .= "<td><div class='bold' style='display:inline-block'>" . xl($key) . ": </div><div class='text' style='display:inline-block'>" . $value . " " . xl('F') . " (" . $convValue . " " . xl('C') . ")</div></td>";
109 } elseif ($key == "Pulse" || $key == "Respiration" || $key == "Oxygen Saturation" || $key == "BMI") {
110 $value = number_format($value, 0);
111 if ($key == "Oxygen Saturation") {
112 $vitals .= "<td><div class='bold' style='display:inline-block'>" . xl($key) . ": </div><div class='text' style='display:inline-block'>" . $value . " " . xl('%') . "</div></td>";
113 } elseif ($key == "BMI") {
114 $vitals .= "<td><div class='bold' style='display:inline-block'>" . xl($key) . ": </div><div class='text' style='display:inline-block'>" . $value . " " . xl('kg/m^2') . "</div></td>";
115 } else { //pulse and respirations
116 $vitals .= "<td><div class='bold' style='display:inline-block'>" . xl($key) . ": </div><div class='text' style='display:inline-block'>" . $value . " " . xl('per min') . "</div></td>";
118 } else {
119 $vitals .= "<td><div class='bold' style='display:inline-block'>" . xl($key) . ": </div><div class='text' style='display:inline-block'>" . text($value) . "</div></td>";
122 $count++;
124 if ($count == $cols) {
125 $count = 0;
126 $vitals .= "</tr><tr>\n";
130 $vitals .= "</tr></table>";
133 if ($print) {
134 echo $vitals ;
135 } else {
136 return $vitals;