From 069d684a6e55cf8c7fe4a932a47b2f7aae134602 Mon Sep 17 00:00:00 2001 From: Kevin Yeh Date: Fri, 2 Nov 2012 11:15:59 -0400 Subject: [PATCH] Support for using pounds and ounces on the vitals form. Introduced global 'us_weight_format' to choose display type. (decimal pounds or pounds and ounces) Added short hand using '#' for vitals input to denote pounds and ounces --- interface/forms/vitals/FormVitals.class.php | 15 ++++++++++++ interface/forms/vitals/report.php | 27 ++++++++++++++++++---- .../forms/vitals/templates/vitals/general_new.html | 14 ++++++++--- library/globals.inc.php | 13 ++++++++++- 4 files changed, 61 insertions(+), 8 deletions(-) diff --git a/interface/forms/vitals/FormVitals.class.php b/interface/forms/vitals/FormVitals.class.php index 6beb930ac..733e90ef1 100644 --- a/interface/forms/vitals/FormVitals.class.php +++ b/interface/forms/vitals/FormVitals.class.php @@ -159,6 +159,21 @@ class FormVitals extends ORDataObject { $this->weight = $w; } } + function display_weight($pounds) + { + if($pounds!=0) + { + if($GLOBALS['us_weight_format']==2) + { + $pounds_int=floor($pounds); + return $pounds_int." ".xl('lb') ." " .round(($pounds-$pounds_int)*16)." ".xl('oz'); + } + else + { + return $pounds; + } + } + } function get_height() { return $this->height; } diff --git a/interface/forms/vitals/report.php b/interface/forms/vitals/report.php index a36541c67..873bf1331 100644 --- a/interface/forms/vitals/report.php +++ b/interface/forms/vitals/report.php @@ -3,6 +3,22 @@ include_once("../../globals.php"); include_once($GLOBALS["srcdir"]."/api.inc"); include_once ($GLOBALS['fileroot']."/library/patient.inc"); + +function US_weight($pounds,$mode=1) +{ + + if($mode==1) + { + return $pounds . " " . xl('lb') ; + } + else + { + $pounds_int=floor($pounds); + $ounces=round(($pounds-$pounds_int)*16); + return $pounds_int . " " . xl('lb') . " " . $ounces . " " . xl('oz'); + } +} + function vitals_report( $pid, $encounter, $cols, $id, $print = true) { $count = 0; $data = formFetch("form_vitals", $id); @@ -57,19 +73,22 @@ function vitals_report( $pid, $encounter, $cols, $id, $print = true) { } elseif ($key == "Weight") { $convValue = number_format($value*0.45359237,2); + $vitals.="" . xl($key) . ": "; // show appropriate units + $mode=$GLOBALS['us_weight_format']; if ($GLOBALS['units_of_measurement'] == 2) { - $vitals .= "" . xl($key) . ": " . $convValue . " " . xl('kg') . " (" . $value . " " . xl('lb') . ")"; + $vitals .= $convValue . " " . xl('kg') . " (" . US_weight($value,$mode) . ")"; } elseif ($GLOBALS['units_of_measurement'] == 3) { - $vitals .= "" . xl($key) . ": " . $value . " " . xl('lb') . ""; + $vitals .= US_weight($value,$mode) ; } elseif ($GLOBALS['units_of_measurement'] == 4) { - $vitals .= "" . xl($key) . ": " . $convValue . " " . xl('kg') . ""; + $vitals .= $convValue . " " . xl('kg') ; } else { // = 1 or not set - $vitals .= "" . xl($key) . ": " . $value . " " . xl('lb') . " (" . $convValue . " " . xl('kg') . ")"; + $vitals .= US_weight($value,$mode) . " (" . $convValue . " " . xl('kg') . ")"; } + $vitals.= ""; } elseif ($key == "Height" || $key == "Waist Circ" || $key == "Head Circ") { $convValue = number_format($value*2.54,2); diff --git a/interface/forms/vitals/templates/vitals/general_new.html b/interface/forms/vitals/templates/vitals/general_new.html index 25c661fd6..5ef75f3ba 100644 --- a/interface/forms/vitals/templates/vitals/general_new.html +++ b/interface/forms/vitals/templates/vitals/general_new.html @@ -82,10 +82,10 @@ td,th { {if $units_of_measurement == 2}{else}{/if}{xl t="Weight"} {if $units_of_measurement == 2}{else}{/if}{xl t="lbs"} {if $units_of_measurement == 2}{else}{/if} - + {foreach item=result from=$results} - {if $result.weight != 0}{$result.weight}{/if} + {$vitals->display_weight($result.weight)} {/foreach} {if $units_of_measurement == 3}{else}{/if} @@ -313,7 +313,15 @@ function ShowGrowthchart(doPDF) { function convLbtoKg(name) { var lb = $("#"+name).val(); - + var hash_loc=lb.indexOf("#"); + if(hash_loc>=0) + { + var pounds=lb.substr(0,hash_loc); + var ounces=lb.substr(hash_loc+1); + var num=parseInt(pounds)+parseInt(ounces)/16; + lb=num; + $("#"+name).val(lb); + } if (lb == "0") { $("#"+name+"_metric").val("0"); } diff --git a/library/globals.inc.php b/library/globals.inc.php index 0e198ac16..2d22b05f7 100644 --- a/library/globals.inc.php +++ b/library/globals.inc.php @@ -89,6 +89,7 @@ $USER_SPECIFIC_GLOBALS = array('default_top_pane', 'gbl_pt_list_page_size', 'gbl_pt_list_new_window', 'units_of_measurement', + 'us_weight_format', 'date_display_format', 'time_display_format', 'event_color', @@ -350,7 +351,17 @@ $GLOBALS_METADATA = array( '1', // default = Both/US xl('Applies to the Vitals form and Growth Chart') ), - + + 'us_weight_format' => array( + xl('Display Format for US Weights'), + array( + '1'=>xl('Show pounds as decimal value'), + '2'=>xl('Show pounds and ounces') + ), + '1', + xl('Applies to Vitals form') + ) + , 'disable_deprecated_metrics_form' => array( xl('Disable Old Metric Vitals Form'), 'bool', // data type -- 2.11.4.GIT