if ($tempid >= 0) { $tempid = -1; } sqlInsert("INSERT INTO form_{$spreadsheet_form_name} ( " . "id, rownbr, colnbr, datatype, value " . ") VALUES ( " . "{$tempid}, -1, -1, 0, " . "'" . real2db($template_name) . "' " . ")"); sqlStatement("UNLOCK TABLES"); } $saveid = $tempid; } } if (!$alertmsg) { // Finally, save the table cells. for ($i = 0; $i < $num_used_rows; ++$i) { for ($j = 0; $j < $num_used_cols; ++$j) { $tmp = $cells[$i][$j]; $celltype = substr($tmp, 0, 1) + 0; $cellvalue = form2db(substr($tmp, 1)); if ($celltype) { sqlInsert("INSERT INTO form_{$spreadsheet_form_name} ( " . "id, rownbr, colnbr, datatype, value " . ") VALUES ( " . "{$saveid}, {$i}, {$j}, {$celltype}, '{$cellvalue}' )"); } } } } } else { if ($_POST['bn_delete_template'] && $tempid) { sqlStatement("DELETE FROM form_{$spreadsheet_form_name} WHERE " . "id = '{$tempid}'"); $tempid = 0; $template_name = ''; } } if ($_POST['bn_save_form'] && !$alertmsg && !$popup) { formHeader("Redirecting....");
function add_vitals($patient_pid, $dos, $encounter_id, $medics, &$errors) { $bmi; $bmi_status; // Create Vitals form. if (!empty($medics->medical->physicalexamsvitals->bps)) { /* DISABLED // Calculate BMI_status if ($medics->medical->physicalexamsvitals->weight > 0 && $medics->medical->physicalexamsvitals->height > 0) { $bmi = ($weight/$height/$height)*703; if ( $bmi > 42 ) $bmi_status = 'Obesity III'; elseif ( $bmi > 34 ) $bmi_status = 'Obesity II'; elseif ( $bmi > 30 ) $bmi_status = 'Obesity I'; elseif ( $bmi > 27 ) $bmi_status = 'Overweight'; elseif ( $bmi > 25 ) $bmi_status = 'Normal BL'; elseif ( $bmi > 18.5 ) $bmi_status = 'Normal'; elseif ( $bmi > 10 ) $bmi_status = 'Underweight'; } */ addForm($encounter_id, "Vitals", sqlInsert("INSERT INTO form_vitals SET " . "date = '{$dos}', " . "pid = '{$patient_pid}', " . "user = '******', " . "groupname = '', " . "authorized = 1, " . "activity = 1, " . "mentalstate = '" . form2db($medics->medical->physicalexamsvitals->mentalstatus) . "', " . "bps = '" . form2db($medics->medical->physicalexamsvitals->bps) . "', " . "bpd = '" . form2db($medics->medical->physicalexamsvitals->bpd) . "', " . "weight = '" . form2db($medics->medical->physicalexamsvitals->weight) . "', " . "height = '" . form2db($medics->medical->physicalexamsvitals->height) . "', " . "temperature = '" . form2db($medics->medical->physicalexamsvitals->temperature) . "', " . "temp_method = '" . form2db($medics->medical->physicalexamsvitals->tempmethods) . "', " . "pulse = '" . form2db($medics->medical->physicalexamsvitals->pulse) . "', " . "respiration = '" . form2db($medics->medical->physicalexamsvitals->respiration) . "', " . "BMI = '" . form2db($medics->medical->physicalexamsvitals->bmi) . "', " . "BMI_status = '{$bmi_status}', " . "waist_circ = '" . form2db($medics->medical->physicalexamsvitals->waistcirc) . "', " . "head_circ = '" . form2db($medics->medical->physicalexamsvitals->headcirc) . "', " . "oxygen_saturation = '" . form2db($medics->medical->physicalexamsvitals->o2) . "'"), "vitals", $patient_pid, 1, $dos); return "Created vitals form for Patient ID " . $patient_pid . ".\n"; } return "No vitals form created for Patient ID " . $patient_pid . ".\n"; }
$ret .= " checked"; } $ret .= " />{$desc}"; return $ret; } $formid = $_GET['id']; // If Save was clicked, save the info. // if ($_POST['bn_save']) { // If updating an existing form... // if ($formid) { $query = "UPDATE form_body_composition SET " . "body_type = " . rbvalue('form_body_type') . ", " . "height = '" . form2db($_POST['form_height']) . "', " . "weight = '" . form2db($_POST['form_weight']) . "', " . "bmi = '" . form2db($_POST['form_bmi']) . "', " . "bmr = '" . form2db($_POST['form_bmr']) . "', " . "impedance = '" . form2db($_POST['form_impedance']) . "', " . "fat_pct = '" . form2db($_POST['form_fat_pct']) . "', " . "fat_mass = '" . form2db($_POST['form_fat_mass']) . "', " . "ffm = '" . form2db($_POST['form_ffm']) . "', " . "tbw = '" . form2db($_POST['form_tbw']) . "', " . "other = '" . form2db($_POST['form_other']) . "' " . "WHERE id = '{$formid}'"; sqlStatement($query); } else { $query = "INSERT INTO form_body_composition ( " . "body_type, height, weight, bmi, bmr, impedance, fat_pct, " . "fat_mass, ffm, tbw, other " . ") VALUES ( " . rbvalue('form_body_type') . ", " . "'" . form2db($_POST['form_height']) . "', " . "'" . form2db($_POST['form_weight']) . "', " . "'" . form2db($_POST['form_bmi']) . "', " . "'" . form2db($_POST['form_bmr']) . "', " . "'" . form2db($_POST['form_impedance']) . "', " . "'" . form2db($_POST['form_fat_pct']) . "', " . "'" . form2db($_POST['form_fat_mass']) . "', " . "'" . form2db($_POST['form_ffm']) . "', " . "'" . form2db($_POST['form_tbw']) . "', " . "'" . form2db($_POST['form_other']) . "' " . ")"; $newid = sqlInsert($query); addForm($encounter, "Body Composition", $newid, "body_composition", $pid, $userauthorized); } formHeader("Redirecting...."); formJump(); formFooter(); exit; } if ($formid) { $row = sqlQuery("SELECT * FROM form_body_composition WHERE " . "id = '{$formid}' AND activity = '1'"); } else { // Get the most recent scale reading. $items = explode(',', trim(file_get_contents($scale_file_name))); if ($items && count($items) > 11) { $scale_file_age = round((time() - filemtime($scale_file_name)) / 60);