Skip to content

Commit

Permalink
Merge pull request #64 from rcpch/eatyourpeas/issue63
Browse files Browse the repository at this point in the history
returns who data not cdc data for under 2s in cdc weight/height/bmi. ofc remains cdc
  • Loading branch information
eatyourpeas authored Jan 17, 2025
2 parents b5e9249 + 9d15111 commit 9a21193
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 4.3.4
current_version = 4.3.5
tag = False
commit = True

Expand Down
14 changes: 12 additions & 2 deletions rcpchgrowth/cdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
json_file.close()
# public functions

data_path = Path(
data_directory, "who_infants.json") # 2 weeks to 2 years
with open(data_path) as json_file:
WHO_INFANTS_DATA = json.load(json_file)
json_file.close()


def reference_data_absent(age: float, measurement_method: str, sex: str):
"""
Expand Down Expand Up @@ -88,10 +94,14 @@ def cdc_reference(age: float, measurement_method, default_youngest_reference: bo
# Below 40 weeks, Fenton data is always used
return FENTON_DATA

elif age < 2 or (age == 2 and default_youngest_reference) or (measurement_method == HEAD_CIRCUMFERENCE and age <= 3):
# Below 2 years, CDC interpretation of WHO is used
if measurement_method == HEAD_CIRCUMFERENCE and age <= 3:
# CDC data is used for head circumference up to 3 years
return CDC_INFANT_DATA

elif age < 2 or (age == 2 and default_youngest_reference):
# Below 2 years, CDC interpretation of WHO is used
return WHO_INFANTS_DATA

elif age <= CDC_UPPER_THRESHOLD:
# CDC data is used for all children 2-20 years
return CDC_CHILD_DATA
Expand Down
2 changes: 1 addition & 1 deletion rcpchgrowth/measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def __calculate_ages(
chronological_decimal_age_error = f"{err}"

# if reference is CDC or WHO, we must treat >37 week infants as term and we also stop correcting for prematurity at 2 years of age
if self.reference == CDC or self.reference == WHO:
if self.reference == CDC or self.reference == WHO and self.corrected_decimal_age is not None:
if (self.corrected_decimal_age >= 2 and gestation_weeks < 37) or (gestation_weeks >= 37 and gestation_weeks <= 42):
self.corrected_decimal_age = self.chronological_decimal_age

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name="rcpchgrowth",
version="4.3.4",
version="4.3.5",
description="SDS and Centile calculations for UK Growth Data",
long_description=long_description,
url="https://github.com/rcpch/digital-growth-charts/blob/master/README.md",
Expand Down

0 comments on commit 9a21193

Please sign in to comment.