public function getVitals($pid, $encounter) { $wherCon = ''; if ($encounter) { $wherCon = "AND fe.encounter = {$encounter}"; } $vitals = ''; $query = "SELECT DATE(fe.date) AS date, fv.id, temperature, bpd, bps, head_circ, pulse, height, oxygen_saturation, weight, BMI FROM forms AS f\n JOIN form_encounter AS fe ON fe.encounter = f.encounter AND fe.pid = f.pid\n JOIN form_vitals AS fv ON fv.id = f.form_id\n WHERE f.pid = ? AND f.formdir = 'vitals' AND f.deleted=0 {$wherCon}\n ORDER BY fe.date DESC"; $appTable = new ApplicationTable(); $res = $appTable->zQuery($query, array($pid)); $vitals .= "<vitals_list>"; foreach ($res as $row) { $convWeightValue = number_format($row['weight'] * 0.45359237, 2); $convHeightValue = round(number_format($row['height'] * 2.54, 2), 1); if ($GLOBALS['units_of_measurement'] == 2 || $GLOBALS['units_of_measurement'] == 4) { $weight_value = $convWeightValue; $weight_unit = 'kg'; $height_value = $convHeightValue; $height_unit = 'cm'; } else { $temp = US_weight($row['weight'], 1); $tempArr = explode(" ", $temp); $weight_value = $tempArr[0]; $weight_unit = 'lb'; $height_value = $row['height']; $height_unit = 'in'; } $vitals .= "<vitals>\n\t\t <extension>" . htmlspecialchars(base64_encode($_SESSION['site_id'] . $row['id']), ENT_QUOTES) . "</extension>\n\t\t <sha_extension>" . htmlspecialchars("c6f88321-67ad-11db-bd13-0800200c9a66", ENT_QUOTES) . "</sha_extension>\n <date>" . htmlspecialchars($this->date_format($row['date']), ENT_QUOTES) . "</date>\n <effectivetime>" . htmlspecialchars(preg_replace('/-/', '', $row['date']), ENT_QUOTES) . "000000</effectivetime>\n <temperature>" . htmlspecialchars($row['temperature'], ENT_QUOTES) . "</temperature>\n\t\t <extension_temperature>" . htmlspecialchars(base64_encode($_SESSION['site_id'] . $row['id'] . 'temperature'), ENT_QUOTES) . "</extension_temperature>\n <bpd>" . htmlspecialchars($row['bpd'] ? $row['bpd'] : 0, ENT_QUOTES) . "</bpd>\n\t\t <extension_bpd>" . htmlspecialchars(base64_encode($_SESSION['site_id'] . $row['id'] . 'bpd'), ENT_QUOTES) . "</extension_bpd>\n <bps>" . htmlspecialchars($row['bps'] ? $row['bps'] : 0, ENT_QUOTES) . "</bps>\n\t\t <extension_bps>" . htmlspecialchars(base64_encode($_SESSION['site_id'] . $row['id'] . 'bps'), ENT_QUOTES) . "</extension_bps>\n <head_circ>" . htmlspecialchars($row['head_circ'] ? $row['head_circ'] : 0, ENT_QUOTES) . "</head_circ>\n\t\t <extension_head_circ>" . htmlspecialchars(base64_encode($_SESSION['site_id'] . $row['id'] . 'head_circ'), ENT_QUOTES) . "</extension_head_circ>\n <pulse>" . htmlspecialchars($row['pulse'] ? $row['pulse'] : 0, ENT_QUOTES) . "</pulse>\n\t\t <extension_pulse>" . htmlspecialchars(base64_encode($_SESSION['site_id'] . $row['id'] . 'pulse'), ENT_QUOTES) . "</extension_pulse>\n <height>" . htmlspecialchars($height_value, ENT_QUOTES) . "</height>\n\t\t <extension_height>" . htmlspecialchars(base64_encode($_SESSION['site_id'] . $row['id'] . 'height'), ENT_QUOTES) . "</extension_height>\n <unit_height>" . htmlspecialchars($height_unit, ENT_QUOTES) . "</unit_height>\n <oxygen_saturation>" . htmlspecialchars($row['oxygen_saturation'] ? $row['oxygen_saturation'] : 0, ENT_QUOTES) . "</oxygen_saturation>\n\t\t <extension_oxygen_saturation>" . htmlspecialchars(base64_encode($_SESSION['site_id'] . $row['id'] . 'oxygen_saturation'), ENT_QUOTES) . "</extension_oxygen_saturation>\n <breath>" . htmlspecialchars($row['respiration'] ? $row['respiration'] : 0, ENT_QUOTES) . "</breath>\n\t\t <extension_breath>" . htmlspecialchars(base64_encode($_SESSION['site_id'] . $row['id'] . 'breath'), ENT_QUOTES) . "</extension_breath>\n <weight>" . htmlspecialchars($weight_value, ENT_QUOTES) . "</weight>\n\t\t <extension_weight>" . htmlspecialchars(base64_encode($_SESSION['site_id'] . $row['id'] . 'weight'), ENT_QUOTES) . "</extension_weight>\n <unit_weight>" . htmlspecialchars($weight_unit, ENT_QUOTES) . "</unit_weight>\n <BMI>" . htmlspecialchars($row['BMI'] ? $row['BMI'] : 0, ENT_QUOTES) . "</BMI>\n\t\t <extension_BMI>" . htmlspecialchars(base64_encode($_SESSION['site_id'] . $row['id'] . 'BMI'), ENT_QUOTES) . "</extension_BMI>\n </vitals>"; } $vitals .= "</vitals_list>"; return $vitals; }
function vitals_report($pid, $encounter, $cols, $id, $print = true) { $count = 0; $data = formFetch("form_vitals", $id); $patient_data = getPatientData($GLOBALS['pid']); $patient_age = getPatientAge($patient_data['DOB']); $vitals = ""; if ($data) { $vitals .= "<table><tr>"; foreach ($data as $key => $value) { if ($key == "id" || $key == "pid" || $key == "user" || $key == "groupname" || $key == "authorized" || $key == "activity" || $key == "date" || $value == "" || $value == "0000-00-00 00:00:00" || $value == "0.0") { // skip certain data continue; } if ($value == "on") { $value = "yes"; } $key = ucwords(str_replace("_", " ", $key)); //modified by BM 06-2009 for required translation if ($key == "Temp Method" || $key == "BMI Status") { if ($key == "BMI Status") { if ($patient_age <= 20 || preg_match('/month/', $patient_age)) { $value = "See Growth-Chart"; } } $vitals .= "<td><span class=bold>" . xl($key) . ": </span><span class=text>" . xl($value) . "</span></td>"; } elseif ($key == "Bps") { $bps = $value; if ($bpd) { $vitals .= "<td><span class=bold>" . xl('Blood Pressure') . ": </span><span class=text>" . $bps . "/" . $bpd . "</span></td>"; } else { continue; } } elseif ($key == "Bpd") { $bpd = $value; if ($bps) { $vitals .= "<td><span class=bold>" . xl('Blood Pressure') . ": </span><span class=text>" . $bps . "/" . $bpd . "</span></td>"; } else { continue; } } elseif ($key == "Weight") { $convValue = number_format($value * 0.45359237, 2); $vitals .= "<td><span class=bold>" . xl($key) . ": </span><span class=text>"; // show appropriate units $mode = $GLOBALS['us_weight_format']; if ($GLOBALS['units_of_measurement'] == 2) { $vitals .= $convValue . " " . xl('kg') . " (" . US_weight($value, $mode) . ")"; } elseif ($GLOBALS['units_of_measurement'] == 3) { $vitals .= US_weight($value, $mode); } elseif ($GLOBALS['units_of_measurement'] == 4) { $vitals .= $convValue . " " . xl('kg'); } else { // = 1 or not set $vitals .= US_weight($value, $mode) . " (" . $convValue . " " . xl('kg') . ")"; } $vitals .= "</span></td>"; } elseif ($key == "Height" || $key == "Waist Circ" || $key == "Head Circ") { $convValue = round(number_format($value * 2.54, 2), 1); // show appropriate units if ($GLOBALS['units_of_measurement'] == 2) { $vitals .= "<td><span class=bold>" . xl($key) . ": </span><span class=text>" . $convValue . " " . xl('cm') . " (" . $value . " " . xl('in') . ")</span></td>"; } elseif ($GLOBALS['units_of_measurement'] == 3) { $vitals .= "<td><span class=bold>" . xl($key) . ": </span><span class=text>" . $value . " " . xl('in') . "</span></td>"; } elseif ($GLOBALS['units_of_measurement'] == 4) { $vitals .= "<td><span class=bold>" . xl($key) . ": </span><span class=text>" . $convValue . " " . xl('cm') . "</span></td>"; } else { // = 1 or not set $vitals .= "<td><span class=bold>" . xl($key) . ": </span><span class=text>" . $value . " " . xl('in') . " (" . $convValue . " " . xl('cm') . ")</span></td>"; } } elseif ($key == "Temperature") { $convValue = number_format(($value - 32) * 0.5556, 2); // show appropriate units if ($GLOBALS['units_of_measurement'] == 2) { $vitals .= "<td><span class=bold>" . xl($key) . ": </span><span class=text>" . $convValue . " " . xl('C') . " (" . $value . " " . xl('F') . ")</span></td>"; } elseif ($GLOBALS['units_of_measurement'] == 3) { $vitals .= "<td><span class=bold>" . xl($key) . ": </span><span class=text>" . $value . " " . xl('F') . "</span></td>"; } elseif ($GLOBALS['units_of_measurement'] == 4) { $vitals .= "<td><span class=bold>" . xl($key) . ": </span><span class=text>" . $convValue . " " . xl('C') . "</span></td>"; } else { // = 1 or not set $vitals .= "<td><span class=bold>" . xl($key) . ": </span><span class=text>" . $value . " " . xl('F') . " (" . $convValue . " " . xl('C') . ")</span></td>"; } } elseif ($key == "Pulse" || $key == "Respiration" || $key == "Oxygen Saturation" || $key == "BMI") { $value = number_format($value, 0); if ($key == "Oxygen Saturation") { $vitals .= "<td><span class=bold>" . xl($key) . ": </span><span class=text>" . $value . " " . xl('%') . "</span></td>"; } elseif ($key == "BMI") { $vitals .= "<td><span class=bold>" . xl($key) . ": </span><span class=text>" . $value . " " . xl('kg/m^2') . "</span></td>"; } else { //pulse and respirations $vitals .= "<td><span class=bold>" . xl($key) . ": </span><span class=text>" . $value . " " . xl('per min') . "</span></td>"; } } else { $vitals .= "<td><span class=bold>" . xl($key) . ": </span><span class=text>" . text($value) . "</span></td>"; } $count++; if ($count == $cols) { $count = 0; $vitals .= "</tr><tr>\n"; } } $vitals .= "</tr></table>"; } if ($print) { echo $vitals; } else { return $vitals; } }