Skip to content

Commit

Permalink
Merge pull request #18 from openhealthalgorithms/fixes-cholesterol-bmi
Browse files Browse the repository at this point in the history
Fixes Cholesterol and BMI issues
  • Loading branch information
samhq authored Sep 21, 2021
2 parents 6d90205 + c818dfd commit 3df329e
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 11 deletions.
27 changes: 26 additions & 1 deletion algorithms/hearts.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package algorithms

import (
"errors"
"fmt"
"strconv"
"strings"

Expand Down Expand Up @@ -500,7 +501,7 @@ func (h *Hearts) Process(o m.OHARequest, colorChartPath, countriesPath string) (
}

// Cholesterol
if len(cvdScore) > 0 {
if len(cvdScore) > 0 && cholValue > 0 {
cvdForChol := 1.0
if cvdScore == "10-20%" {
cvdForChol = 20.0
Expand Down Expand Up @@ -536,6 +537,30 @@ func (h *Hearts) Process(o m.OHARequest, colorChartPath, countriesPath string) (
referralReasons = append(referralReasons, ref)
}
}
} else {
errs = append(errs, "cholesterol assessment was not performed due to missing cvd assessment")
chol, err := a.GetResponse("total cholesterol", "CHOL-CALCULATION-FALSE", fmt.Sprintf("%.1f%s", cholValue, cholUnit), "Below 195mg/dL (5 mmol/L)")
if err != nil {
errs = append(errs, err.Error())
} else {
res := GetResults(chol, *h.GuidelineContent.Body.Contents)
assessments.Cholesterol.Components.TChol = &res
if res.Refer != nil && *res.Refer != "no" {
referral = referral || true
ref := m.ORRReferralReason{}
if *res.Refer == "urgent" {
referralUrgent = referralUrgent || true
val := true
ref.Urgent = &val
} else {
val := false
ref.Urgent = &val
}
patype := "total_cholesterol"
ref.Type = &patype
referralReasons = append(referralReasons, ref)
}
}
}

referrals.Refer = &referral
Expand Down
22 changes: 16 additions & 6 deletions contents/guideline_hearts.json
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
"definition": "South Asian BMI > 27.5 kg/m2",
"conditions": [
{
"from": 27.6,
"from": 27.5,
"unit": "kg/m2",
"target": "18.5–23"
}
Expand All @@ -279,7 +279,7 @@
"definition": "South Asian BMI > 23–27.5 kg/m2",
"conditions": [
{
"from": 23.1,
"from": 23,
"to": 27.5,
"unit": "kg/m2",
"target": "18.5-23"
Expand Down Expand Up @@ -339,12 +339,14 @@
"conditions": [
{
"gender": "male",
"from": 20,
"to": 91,
"unit": "cm",
"target": "90cm"
},
{
"gender": "female",
"from": 20,
"to": 81,
"unit": "cm",
"target": "80cm"
Expand Down Expand Up @@ -377,11 +379,13 @@
"conditions": [
{
"gender": "male",
"from": 0.5,
"to": 0.90,
"target": "0.90"
},
{
"gender": "female",
"from": 0.5,
"to": 0.85,
"target": "0.85"
}
Expand Down Expand Up @@ -643,6 +647,7 @@
"from": 60
},
"range": {
"from": 3,
"to": 13,
"unit": "%"
},
Expand All @@ -655,6 +660,7 @@
"to": 59
},
"range": {
"from": 3,
"to": 11,
"unit": "%"
},
Expand All @@ -667,6 +673,7 @@
"to": 39
},
"range": {
"from": 3,
"to": 8,
"unit": "%"
},
Expand All @@ -678,6 +685,7 @@
"from": 60
},
"range": {
"from": 3,
"to": 24,
"unit": "%"
},
Expand All @@ -690,6 +698,7 @@
"to": 59
},
"range": {
"from": 3,
"to": 23,
"unit": "%"
},
Expand All @@ -702,6 +711,7 @@
"to": 39
},
"range": {
"from": 3,
"to": 21,
"unit": "%"
},
Expand Down Expand Up @@ -1137,7 +1147,7 @@
"from": 8.0,
"unit": "mmol/L"
},
"target": "< 195mg/dL (5 mmol/L)"
"target": "Below 195mg/dL (5 mmol/L)"
}
],
"code": "CHOL-REFER"
Expand All @@ -1151,7 +1161,7 @@
"from": 31,
"unit": "%"
},
"target": "<195mg/dL (5mmol/L)"
"target": "Below 195mg/dL (5mmol/L)"
}
],
"code": "CHOL-VERY-HIGH-CVD-RISK"
Expand All @@ -1171,7 +1181,7 @@
"to": 7.9,
"unit": "mmol/L"
},
"target": "< 195mg/dL (5 mmol/L)"
"target": "Below 195mg/dL (5 mmol/L)"
}
],
"code": "CHOL-ELEVATED-WITH-HIGH-CVD-RISK"
Expand All @@ -1186,7 +1196,7 @@
"to": 20,
"unit": "%"
},
"target": "< 195mg/dL (5 mmol/L)"
"target": "Below 195mg/dL (5 mmol/L)"
}
],
"code": "CHOL-MOD-CVD-RISK"
Expand Down
7 changes: 7 additions & 0 deletions contents/guideline_hearts_content.json
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,13 @@
"message": "Maintain a healthy diet",
"refer": "no"
},
"CHOL-CALCULATION-FALSE": {
"eval": "No Assessment",
"grading": 0,
"tfl": "GRAY",
"message": "No assessment performed",
"refer": "no"
},
"CVD-AGE-FALSE": {
"eval": "Not Calculated",
"grading": 0,
Expand Down
2 changes: 1 addition & 1 deletion engines/assessments/body_composition.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (b *BMIGuidelines) Process(height, weight float64) (Response, error) {
if c.To != nil {
to = *c.To
}
if bmi >= from && bmi <= to {
if bmi > from && bmi <= to {
code = *g.Code
target = *c.Target
break
Expand Down
6 changes: 3 additions & 3 deletions riskmodels/whocvd.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func Calculate(
}

if len(group) == 0 {
return nil, nil, errors.New("invalid version given")
return nil, nil, errors.New("invalid risk model version given")
}

riskScore := group[row][column]
Expand Down Expand Up @@ -112,7 +112,7 @@ func processV1(colorChartPath, region string, labBased bool, gender string, ageV
if val, ok := smoking[ageRange]; ok {
ageGroup = val
} else {
return nil, -1, -1, nil, errors.New("cannot perform calculation for the given age")
return nil, -1, -1, nil, errors.New("cannot perform cvd calculation for the given age")
}

// get sbp index
Expand Down Expand Up @@ -174,7 +174,7 @@ func processV2(colorChartPath, region string, labBased bool, gender string, ageV
if val, ok := smoking[ageRange]; ok {
ageGroup = val
} else {
return nil, -1, -1, nil, errors.New("cannot perform calculation for the given age")
return nil, -1, -1, nil, errors.New("cannot perform cvd calculation for the given age")
}

// get sbp index
Expand Down

0 comments on commit 3df329e

Please sign in to comment.