Skip to content

Commit

Permalink
Update blood pressure assessment for age check
Browse files Browse the repository at this point in the history
  • Loading branch information
samhq committed Feb 13, 2019
1 parent 76edf8f commit 6e30f72
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 42 deletions.
93 changes: 60 additions & 33 deletions guideline_hearts.json
Original file line number Diff line number Diff line change
Expand Up @@ -723,15 +723,15 @@
"from": 141,
"unit": "mmHg"
},
"target": "130/80"
"target": "120/80"
},
{
"diabetes": false,
"dbp": {
"from": 91,
"unit": "mmHg"
},
"target": "130/80"
"target": "120/80"
}
],
"code": "BP-HTN"
Expand All @@ -758,27 +758,54 @@
],
"code": "BP-DM-TARGET"
},
{
"category": "Suspected secondary Hypertension",
"definition": "Elevated blood pressure in patient age < 40",
"conditions": [{
"diabetes": false,
"age": {
"to": 40
},
"sbp": {
"from": 140,
"unit": "mmHg"
},
"target": "140/90"
},
{
"diabetes": false,
"dbp": {
"from": 81,
"to": 90,
"unit": "mmHg"
},
"target": "120/80"
}
],
"code": "BP-ELEVATED"
},
{
"category": "Elevated bp",
"definition": "elevated blood pressure, not hypertension",
"conditions": [{
"diabetes": false,
"sbp": {
"from": 121,
"to": 140,
"unit": "mmHg"
},
"target": "120/80"
},
{
"diabetes": false,
"dbp": {
"from": 81,
"to": 90,
"unit": "mmHg"
"diabetes": false,
"sbp": {
"from": 121,
"to": 140,
"unit": "mmHg"
},
"target": "120/80"
},
"target": "120/80"
}],
{
"diabetes": false,
"dbp": {
"from": 81,
"to": 90,
"unit": "mmHg"
},
"target": "120/80"
}
],
"code": "BP-ELEVATED"
},
{
Expand Down Expand Up @@ -825,7 +852,7 @@
"to": 7.0,
"unit": "%"
},
"target": "&lt; 7%"
"target": "< 7%"
}],
"code": "DM-EXISTING-GOOD-CONTROL"
},
Expand All @@ -839,7 +866,7 @@
"to": 4,
"unit": "%"
},
"target": "&lt; 7%"
"target": "< 7%"
}],
"code": "DM-EXISTING-OVER-CONTROL"
},
Expand All @@ -853,7 +880,7 @@
"from": 7.1,
"unit": "%"
},
"target": "&lt; 7%"
"target": "< 7%"
}],
"code": "DM-EXISTING-POOR-CONTROL"
},
Expand All @@ -867,7 +894,7 @@
"to": 7.0,
"unit": "mmol/L"
},
"target": "&lt; 126 mg/dL (7.0 mmol/L)"
"target": "< 126 mg/dL (7.0 mmol/L)"
}],
"code": "DM-EXISTING-GOOD-CONTROL"
},
Expand All @@ -881,7 +908,7 @@
"to": 4,
"unit": "mmol/L"
},
"target": "&lt; 126 mg/dL (7.0 mmol/L)"
"target": "< 126 mg/dL (7.0 mmol/L)"
}],
"code": "DM-EXISTING-OVER-CONTROL"
},
Expand All @@ -895,7 +922,7 @@
"from": 7.1,
"unit": "mmol/L"
},
"target": "&lt; 126 mg/dL (7.0 mmol/L)"
"target": "< 126 mg/dL (7.0 mmol/L)"
}],
"code": "DM-EXISTING-POOR-CONTROL"
},
Expand All @@ -909,7 +936,7 @@
"from": 7.1,
"unit": "mmol/L"
},
"target": "&lt; 126 mg/dL (7.0 mmol/L)"
"target": "< 126 mg/dL (7.0 mmol/L)"
},
{
"hx_diabetes": false,
Expand All @@ -918,7 +945,7 @@
"from": 6.5,
"unit": "%"
},
"target": "&lt; 7%"
"target": "< 7%"
}
],
"code": "DM-NEW-DIAGNOSIS"
Expand All @@ -934,7 +961,7 @@
"to": 6.4,
"unit": "%"
},
"target": "&lt; 6.5%"
"target": "< 6.5%"
},
{
"hx_diabetes": false,
Expand All @@ -944,7 +971,7 @@
"to": 7.0,
"unit": "mmol/L"
},
"target": "&lt; 100 mg/dL (6.0 mmol/L)"
"target": "< 100 mg/dL (6.0 mmol/L)"
}
],
"code": "DM-PRE-DIABETES"
Expand All @@ -959,7 +986,7 @@
"to": 5.6,
"unit": "%"
},
"target": "&lt; 6.5%"
"target": "< 6.5%"
},
{
"hx_diabetes": false,
Expand All @@ -968,7 +995,7 @@
"to": 5.5,
"unit": "mmol/L"
},
"target": "&lt; 100 mg/dL (6.0 mmol/L)"
"target": "< 100 mg/dL (6.0 mmol/L)"
}
],
"code": "DM-NONE"
Expand Down Expand Up @@ -1039,7 +1066,7 @@
"to": 10,
"unit": "%"
},
"target": "< 90mg/dL (5 mmol/L)"
"target": "Below 90mg/dL (5 mmol/L)"
}],
"code": "CHOL-LOW-CVD-RISK"
},
Expand All @@ -1051,14 +1078,14 @@
"to": 1,
"unit": "%"
},
"target": "< 90mg/dL (5 mmol/L)"
"target": "Below 90mg/dL (5 mmol/L)"
},
{
"range": {
"to": 8.0,
"unit": "mmol/L"
},
"target": "< 90mg/dL (5 mmol/L)"
"target": "Below 90mg/dL (5 mmol/L)"
}
],
"code": "CHOL-NO-CVD-RISK"
Expand Down
2 changes: 1 addition & 1 deletion pkg/algorithms/hearts/hearts.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ func (d *Data) get(ctx context.Context) error {
if diabetes.Value == "diabetes" {
diab = true
}
bp, err := engineGuide.Body.BloodPressure.Process(diab, p.Sbp, p.Dbp)
bp, err := engineGuide.Body.BloodPressure.Process(diab, p.Sbp, p.Dbp, p.Age)
if err != nil {
errs = append(errs, err.Error())
} else {
Expand Down
25 changes: 19 additions & 6 deletions pkg/engine/blood_pressure.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import (

// BloodPressureCondition object
type BloodPressureCondition struct {
Diabetes *bool `json:"diabetes"`
SBP *RangeInt `json:"sbp"`
DBP *RangeInt `json:"dbp"`
Target *string `json:"target"`
Diabetes *bool `json:"diabetes"`
SBP *RangeInt `json:"sbp"`
DBP *RangeInt `json:"dbp"`
Age *RangeFloat `json:"age"`
Target *string `json:"target"`
}

// BloodPressureConditions slice
Expand All @@ -28,13 +29,25 @@ type BloodPressureGuideline struct {
type BloodPressureGuidelines []BloodPressureGuideline

// Process function
func (b *BloodPressureGuidelines) Process(diabetes bool, sbp, dbp int) (Response, error) {
func (b *BloodPressureGuidelines) Process(diabetes bool, sbp, dbp int, age float64) (Response, error) {
code := ""
value := fmt.Sprintf("%d/%d", sbp, dbp)
target := ""

for _, g := range *b {
for _, c := range *g.Conditions {
ageFrom := 0.0
ageTo := math.MaxFloat64

if c.Age != nil {
if c.Age.From != nil {
ageFrom = *c.Age.From
}
if c.Age.To != nil {
ageTo = *c.Age.To
}
}

sbpFrom := 0
sbpTo := math.MaxInt32

Expand Down Expand Up @@ -64,7 +77,7 @@ func (b *BloodPressureGuidelines) Process(diabetes bool, sbp, dbp int) (Response
conditionDiabetes = false
}

if conditionDiabetes && sbpFrom <= sbp && sbpTo >= sbp && dbpFrom <= dbp && dbpTo >= dbp {
if conditionDiabetes && (age >= ageFrom && age <= ageTo) && sbpFrom <= sbp && sbpTo >= sbp && dbpFrom <= dbp && dbpTo >= dbp {
code = *g.Code
target = *c.Target
break
Expand Down
2 changes: 1 addition & 1 deletion pkg/engine/body_composition.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ type BodyFatGuideline struct {
type BodyFatGuidelines []BodyFatGuideline

// Process function
func (b *BodyFatGuidelines) Process(gender string, age float64, bodyFat float64) (Response, error) {
func (b *BodyFatGuidelines) Process(gender string, age, bodyFat float64) (Response, error) {
code := ""
value := fmt.Sprintf("%.1f%%", bodyFat)
target := ""
Expand Down
2 changes: 1 addition & 1 deletion pkg/version.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package pkg

const version = "v0.4.7"
const version = "v0.4.8"

// GetVersion returns the current version
func GetVersion() string {
Expand Down

0 comments on commit 6e30f72

Please sign in to comment.