Percentile calculation for BMI and BP

sprdad wrote on Friday, October 14, 2011:

I would like to add a function to calculate a child’s Body Mass Index and Blood Pressure PERCENTILEs (based on age, gender). How do integrate this ability/code into OpenEMR?

yehster wrote on Friday, October 14, 2011:

This would be a complicated feature to add since we would need to some how incorporate the epidemiology data from the CDC so that we can make the appropriate computation given the patient’s age.  The computation for BMI is done by javascript code in form_vitals.php. A potentially simple approach, but kind of kludgy would be to add an iFrame on the vitals page which linked to the cdc’s web based calculator and populated the form for BMI percentile.  I presume the cdc has a similar calculator for bp.

sprdad wrote on Monday, October 17, 2011:

The coding has already been written. For example:

http://www.uptodate.com/contents/calculator-body-mass-index-for-boys-patient-information

It appears the javascript could be incorporated in form_vitals.php (or elsewhere). Can you tell me how to proceed?

yehster wrote on Monday, October 17, 2011:

The next step on how to proceed depends on how much you understand javascript.

Both OpenEMR and that calculator on up-to-date rely on jQuery
http://jquery.com/
which is a very powerful tool for building web pages.

However, the legality of “lifting” the javascript from up-to-date and incorporating it into OpenEMR seems questionable at best.

sprdad wrote on Monday, October 17, 2011:

I am not suggesting violating copyright, etc. The statistical data is freely available from the CDC. The javascript in question is also available open source on git hub: https://github.com/jmwohl/NutPercentile. The HTML code is easy to make (tables). Let me know if you see any issues here.

yehster wrote on Monday, October 17, 2011:

That github link changes a lot :) 

This is where the current javascript for calculating BMI is located:

interface\forms\vitals\templates\vitals\general_new.html

sprdad wrote on Wednesday, October 19, 2011:

Below are the additions to include BMI Percentile. I did not include the code to calculate percentile but I assume it would go into “general_new.html”. What else would need to be changed to store the percentile in the patient record and display it in reports, etc.


FILE: /interface/forms/vitals/templates/vitals/general_new.html.array
INSERT: after line 121

<tr><td>BMI Percentile</td><td>%</td>
{foreach item=vital from=$vitals}
<td><input type=“text”
name=“BMI” value="{$vital->get_BMI_percentile()}"/></td>
{/foreach}


FILE: /interface/forms/vitals/templates/vitals/general_new.html
INSERT: after line 222

<td>{xl t=“BMI Percentile”}</td><td>{xl t=“Type”}</td>
<td class=‘currentvalues’><input type=“text” size=‘3’ name=“BMI_percentile” id=“BMI_percentile value=”{$vitals->get_BMI_percentile()}"/></td>
  {foreach item=result from=$results}
<td  class=‘historicalvalues’>{if $result.BMI_percentile}{xl t=$result.BMI_percentile}{/if}</td>
{/foreach}


FILE: /interface/forms/vitals/C_FormVitals.class
INSERT: after line 68

$results = $result->fields;

INSERT: after line 99

$BMI_percentile = $_POST;


FILE: /interface/forms/vitals/FormVitals.class.php
INSERT: after line 44

var $BMI_percentile;

INSERT: after line 220

function get_BMI_percentile() {
return $this->BMI_percentile;
}
function set_BMI_percentile($percentile) {
$this->BMI_percentile= $percentile;
}


yehster wrote on Wednesday, October 19, 2011:

Poke around in the “controller” files in the directory above, in particular C_FormVitals.class.php, FormVitals.class.php and table.sql.
That’s where the code which persists the data resides.

bradymiller wrote on Thursday, October 20, 2011:

Hi sprdad,

We can provide much more guidance and help if you can get this into a git repository or put this into a patch. Here is a tutorial on setting up and using a github repository with OpenEMR:
http://open-emr.org/wiki/index.php/Git_for_dummies

If learn git, note this will streamline the process of getting code ideas such as your refined and into the official codebase.

thanks,
-brady

sprdad wrote on Monday, October 24, 2011:

Whew! That was a little tricky but I made a fork and posted my changes. I haven’t posted the code to do the BMI percentile calculation yet, please let me know where to put that. Also, I need the names of the variables for: age, sex, height, date of measurement. Anything else I need to do? Thanks!

bradymiller wrote on Wednesday, October 26, 2011:

Hi,

Check out the javascript functions at bottom of:
openemr/interface/forms/vitals/templates/vitals/general_new.html
(basically gonna mimick these to do your calculation)

After get it working, we’ll then package all your commits into one commit and do a review of it on github.

thanks,
-brady

sprdad wrote on Friday, October 28, 2011:

Before I post the code, I have a question about copyright. Some of the code is open source, some is modification of open source, and some is unknown. How do I address this?

bradymiller wrote on Saturday, October 29, 2011:

Hi,
Do you have web links to where you got the code from? Is the open source code using a GPL license? If don’t know, send the files to my email at brady@sparmy.com
-brady
www.open-emr.org