PHP Classes

Health Measures: Record body measures and render graphs of changes

Recommend this page to a friend!
  Info   View files Example   View files View files (23)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-02-12 (3 years ago) RSS 2.0 feedNot enough user ratingsTotal: 159 All time: 8,721 This week: 304Up
Version License PHP version Categories
healthmeasures 1.0.0The PHP License5PHP 5, Databases, Graphics, Biology, H...
Description Author

This package can record body measures and render graphs of changes.

It has a class for creating new measure unite with a given a name like for instance the weight in pounds or kilos. The units can be saved them to a database.

The class can record measurement values in a given unit in a database.

The package can also generate graphs with measurement statistics information.

Innovation Award
PHP Programming Innovation award nominee
February 2017
Number 11
Nutritionists and other health experts often need to keep track of the patients body measures such as weight, waist length, etc.

This package provides means to keep track of as many health measures as necessary in a database.

It stores the measure values and dates, so it can render evolution charts to see how the patient evolved.

Manuel Lemos
Name: Lucia Figueroa <contact>
Classes: 1 package by
Country: Uruguay Uruguay
Innovation award
Innovation award
Nominee: 1x

Details

Health Measures

towerhousestudio

  • This library gives you the ability to generate health measures given a name and a unit, for instance: weight / pound or kilo.
  • You can configure where to store them and them gather to collect their values by date given a username or other identifier.
  • The library gives you the ability to generate graphs or other stats information. It's totally configurable, methods are well documented and comes with unit testing.

Tech

Health Measures uses a number of open source projects to work properly:

  • [PHP] - <= 5.3
  • [illuminate/config] - 5 . This is the config handler that environments like laravel 4.2 used to have.
  • [amenadiel/jpgraph"] - ^3.6 . This guy ported all the jpgraph library to packagist, thank you.

Installation

  • composer require towerhouse/healthmeasures
  • Include the autoloader.
  • A file on the test's folder test-creation.php will give you a quick review of what the library does.
  • Merge the values from .env.example you want to use in your env or just rename the example to .env.
  • This package should work standalone.

Example of use

Select your storage method on the .env file

Enter your measures one by one or using the bulk method

//One by one
$mm = new Measure("waist", "cm", "en");
$mm->save();
$mm2 = new Measure("imc", "kg/m2", "es");
$mm2->save();
$mm3 = new Measure("systole", "", "en");
$mm3->save();

//Using the bulk method with a CSV file that has a header
//Don't worry about duplicates

Measure::setDefaultLanguage('es'); //All my csv measures are in spanish
$mm->bulkConstructor(__DIR__ . '/CSV/Measure.csv');

Example of content in Measure.csv

name,unit
sistole,	
diastole,
pulso,
peso,kilo
altura,cm
azucar en sangre,mg/dl
Saturación de oxígeno en sangre,SaO2
temperatura,ºC

Now enter your values, it's the same as measures so, for simplicity we will use the bulk method

$v = new Value();
$v->bulkConstructor(__DIR__ . '/CSV/Value.csv');
//Again, don't worry about duplicates

Example of content in Value.csv

measure_id,value,owner_id,created_at
2577a46ca60e3ff293ccb0113e6a59c0,97,1,2016-12-29 07:00:00
2577a46ca60e3ff293ccb0113e6a59c0,98,1,2016-12-30 08:00:00
2577a46ca60e3ff293ccb0113e6a59c0,98,1,2016-12-31 06:30:00
2577a46ca60e3ff293ccb0113e6a59c0,98,1,2017-01-01 07:00:00
2577a46ca60e3ff293ccb0113e6a59c0,98,1,2017-01-02 07:00:00
2577a46ca60e3ff293ccb0113e6a59c0,95,1,2017-01-10 11:00:00
2577a46ca60e3ff293ccb0113e6a59c0,95,1,2017-01-15 07:00:00
2577a46ca60e3ff293ccb0113e6a59c0,97,1,2017-01-25 11:00:00

Notice that the owner_id comes from an external system, while measure_id belongs to Healthmeasures. In this case measure_id "2577a46ca60e3ff293ccb0113e6a59c0" it's the id for the measure "waist".

Finally we retrieve all the values that the person with identifier 1 had for his waist starting from "2016-01-01" and ending in the most recent date (that would be today, otherwise you specify it on another last parameter)

$vals = $v->getValuesByDate(1, '2577a46ca60e3ff293ccb0113e6a59c0', "2016-01-01");

Let's create a Stats object and pass the values to generate a linear graph. You can specify a path and the picture will be saved there, otherwise it will be rendered to the client through the browser.

$stats = new Stats($vals);
$stats->image_path = "linear_sample.jpg";
$stats->generateDateMeasureGraph(Stats::GRAPH_LINEAR);

Finally, you can render a nice and simple html report to your browser with all the details

$stats = new Stats($vals);
$stats->image_path = "linear_bar.jpg";
if (!file_exists("linear_bar.jpg")) {
    $stats->generateDateMeasureGraph(Stats::GRAPH_LINEAR);
}
echo $stats->getHtmlReport();

This is a pdf I took from the html page. https://github.com/towerhouse/Healthmeasures/tree/master/test/report.pdf

...and this is the image of the graph Alt text

Unit testing

There is an article about unit testing I wrote for this library documented here: https://www.linkedin.com/pulse/unit-testing-activity-annoys-programmers-lucia-figueroa-tasca

  Files folder image Files  
File Role Description
Files folder imageconfig (2 files)
Files folder imagesrc (1 directory)
Files folder imagetest (6 files, 2 directories)
Accessible without login Plain text file .env.example Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  config  
File Role Description
  Accessible without login Plain text file database.php Conf. Configuration script
  Accessible without login Plain text file htmlReport.php Conf. Configuration script

  Files folder image Files  /  src  
File Role Description
Files folder imageHealthmeasures (2 directories)

  Files folder image Files  /  src  /  Healthmeasures  
File Role Description
Files folder imageConfiguration (2 files)
Files folder imageMeasurement (4 files)

  Files folder image Files  /  src  /  Healthmeasures  /  Configuration  
File Role Description
  Plain text file Application.php Class Class source
  Plain text file Config.php Class Class source

  Files folder image Files  /  src  /  Healthmeasures  /  Measurement  
File Role Description
  Plain text file Measure.php Class Class source
  Plain text file Persistance.php Class Class source
  Plain text file Stats.php Class Class source
  Plain text file Value.php Class Class source

  Files folder image Files  /  test  
File Role Description
Files folder imageCSV (3 files)
Files folder imageMeasurement (3 files)
  Accessible without login Plain text file quick.php Example Example script
  Accessible without login Plain text file report.pdf Data Auxiliary data
  Accessible without login Plain text file sample-bar-graph.php Example Example script
  Accessible without login Plain text file sample-graph.php Example Example script
  Accessible without login Image file sample-linear-graph.jpg Data Auxiliary data
  Accessible without login Plain text file sample-pie-graph.php Example Example script

  Files folder image Files  /  test  /  CSV  
File Role Description
  Accessible without login Plain text file Measure.csv Data Auxiliary data
  Accessible without login Plain text file StatsValues.csv Data Auxiliary data
  Accessible without login Plain text file Value.csv Data Auxiliary data

  Files folder image Files  /  test  /  Measurement  
File Role Description
  Plain text file MeasureTest.php Class Class source
  Plain text file StatsTest.php Class Class source
  Plain text file ValueTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:159
This week:0
All time:8,721
This week:304Up

For more information send a message to info at phpclasses dot org.