diff --git a/.bumpversion.cfg b/.bumpversion.cfg index ce461d3..741b3ed 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 4.2.7 +current_version = 4.2.8 tag = False commit = True diff --git a/rcpchgrowth/age_advice_strings.py b/rcpchgrowth/age_advice_strings.py index 2fc58a8..425ae99 100644 --- a/rcpchgrowth/age_advice_strings.py +++ b/rcpchgrowth/age_advice_strings.py @@ -1,8 +1,11 @@ +from rcpchgrowth.constants import CDC + def comment_prematurity_correction( chronological_decimal_age: float, corrected_decimal_age: float, gestation_weeks: int, - gestation_days: int): + gestation_days: int, + reference: str): """ Returns interpretations on age correction as a string """ @@ -14,7 +17,7 @@ def comment_prematurity_correction( lay_chronological_decimal_age_comment = "Your child was born on their due date." clinician_chronological_decimal_age_comment = "Born Term. No correction has been made for gestation." # These fields should only apply to CDC reference, since UK-WHO corrects for all gestations (and therefore corrected_decimal_age will never be equal to chronological_decimal_age if gestation_weeks is not 40) - if gestation_weeks < 42: + if gestation_weeks < 42 and reference == CDC: if gestation_weeks < 37: lay_chronological_decimal_age_comment = f"Your child was born at {gestation_weeks}+{gestation_days} weeks gestation. No correction is made for this beyond 2 years of age." clinician_chronological_decimal_age_comment =f"Born preterm at {gestation_weeks}+{gestation_days} weeks gestation. No correction is made for this beyond 2 years of age." @@ -22,9 +25,14 @@ def comment_prematurity_correction( clinician_corrected_decimal_age_comment = f"Born preterm at {gestation_weeks}+{gestation_days} weeks gestation. No correction is made for this beyond 2 years of age." else: lay_chronological_decimal_age_comment = f"Your child was born at {gestation_weeks}+{gestation_days} weeks gestation. This is considered term and no correction for gestation has been made." - clinician_chronological_decimal_age_comment = f"Born at term at {gestation_weeks}+{gestation_days} weeks gestation. No correction for gestation has been made." + clinician_chronological_decimal_age_comment = f"Born at term ({gestation_weeks}+{gestation_days} weeks gestation). No correction for gestation has been made." lay_corrected_decimal_age_comment = f"Your child was born at {gestation_weeks}+{gestation_days} weeks gestation. This is considered term and no correction for gestation has been made." - clinician_corrected_decimal_age_comment = f"Born at term at {gestation_weeks}+{gestation_days} weeks gestation. No correction for gestation has been made." + clinician_corrected_decimal_age_comment = f"Born at term ({gestation_weeks}+{gestation_days} weeks gestation). No correction for gestation has been made." + if gestation_weeks == 40 and gestation_days == 0: + lay_chronological_decimal_age_comment = "Your child was born at term. No correction for gestation has been made." + clinician_chronological_decimal_age_comment = "Born at term. No correction for gestation has been made." + lay_corrected_decimal_age_comment = "Your child was born at term. No correction for gestation has been made." + clinician_corrected_decimal_age_comment = "Born at term. No correction for gestation has been made." elif chronological_decimal_age > corrected_decimal_age or chronological_decimal_age < corrected_decimal_age: ## adjustment for gestational age has been made - even if >=37 weeks lay_corrected_decimal_age_comment = f"Because your child was born at {gestation_weeks}+{gestation_days} weeks gestation an adjustment has been made to take this into account." diff --git a/rcpchgrowth/measurement.py b/rcpchgrowth/measurement.py index 7f7a362..7f7873d 100644 --- a/rcpchgrowth/measurement.py +++ b/rcpchgrowth/measurement.py @@ -395,10 +395,6 @@ def __calculate_ages( gestation_weeks = 40 # calculate ages from dates and gestational ages at birth - # if reference is CDC, we must treat >37 week infants as term. - if self.reference == CDC and gestation_weeks >= 37: - gestation_weeks = 40 - gestation_days = 0 try: self.corrected_decimal_age = corrected_decimal_age( @@ -418,9 +414,10 @@ def __calculate_ages( self.chronological_decimal_age = None chronological_decimal_age_error = f"{err}" - # if the reference is CDC, we also stop correcting for prematurity at 2 years of age - if self.reference == CDC and self.corrected_decimal_age >= 2: - self.corrected_decimal_age = self.chronological_decimal_age + # if reference is CDC, we must treat >37 week infants as term and we also stop correcting for prematurity at 2 years of age + if self.reference == CDC: + 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 if self.corrected_decimal_age is None: self._age_comments = None @@ -433,7 +430,8 @@ def __calculate_ages( chronological_decimal_age=self.chronological_decimal_age, corrected_decimal_age=self.corrected_decimal_age, gestation_weeks=gestation_weeks, - gestation_days=gestation_days) + gestation_days=gestation_days, + reference=self.reference) except: self.age_comments = None corrected_decimal_age_error = "Error in comment on prematurity." diff --git a/setup.py b/setup.py index a495aa7..74ad907 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( name="rcpchgrowth", - version="4.2.7", + version="4.2.8", 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",