-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#3 | add function to calculate the growth status for adolescent
- Loading branch information
Showing
5 changed files
with
2,245 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import _ from "lodash"; | ||
import growthChartBoys from "/src/health_modules/adolescent/metadata/adolesecent_growth_chart_boys.json"; | ||
import growthChartGirls from "/src/health_modules/adolescent/metadata/adolesecent_growth_chart_girls.json"; | ||
|
||
const getStatusData = (data) => [ | ||
{value: data.severe_mn, status: -3}, | ||
{value: data.moderate_mn, status: -2}, | ||
{value: data.mild_mn, status: -1}, | ||
{value: data.normal, status: 0}, | ||
{value: data.mild_ob, status: 1}, | ||
{value: data.moderate_ob, status: 2}, | ||
{value: data.severe_ob, status: 3} | ||
]; | ||
|
||
|
||
const getStatus = (arrayDataObj,weight) => { | ||
for (const item of arrayDataObj) { | ||
if (weight <= item.value) { | ||
return item.status; | ||
} | ||
} | ||
return 3; // Default status if weight exceeds all thresholds (severe_ob) | ||
} | ||
|
||
const calculateGrowthStatus = (individual, weight, asOnDate) => { | ||
let ageInMonths = individual.getAgeInMonths(asOnDate); | ||
let gender = _.get(individual, "gender.name"); | ||
let growthStatusValuesJson = gender === 'Female' ? growthChartGirls : growthChartBoys; | ||
let values = _.find(growthStatusValuesJson, (item) => item.month == ageInMonths); | ||
|
||
return {wfaStatus:getStatus(getStatusData(values),weight)}; | ||
} | ||
|
||
export default calculateGrowthStatus; | ||
|
||
|
Oops, something went wrong.