rcpch / digital-growth-charts-react-component-library

A typescript React library for displaying RCPCH Digital Growth Charts from API data
https://growth.rcpch.ac.uk
MIT License
7 stars 11 forks source link

Not showing Adjusted/Unadjusted toggle buttons when 40 weeks gestation #40

Closed snield1150 closed 1 year ago

snield1150 commented 1 year ago

When adding a measurement with gestation weeks exactly 40, and regardless of gestation days, the chart does not show the adjusted/unadjusted/Both toggle buttons.

For example: Weeks = 39, Days = 6 then they show OK Weeks = 40, Days = 0 to 6 then they do NOT show Weeks = 41, Days = 1 then they show OK

I found a line in defaultToggles.ts (line 19) which is checking the gestation weeks and setting showToggle to false. I have recently upgraded the version we are using to 6.1.7 but we saw this issue in 6.1.4 also.

eatyourpeas commented 1 year ago

Thanks @snield1150 - thanks for picking this up. You cannot correct for gestation at 40 weeks gestation exactly since that is the exact due date from last menstrual period. Up until quite recently we would not correct for gestation for any babies born between 37-42 weeks as that is technically term, and the flux that occurs (particularly in babies' weight over that time) led the committee to prefer to average all LMS values between those gestations irrespective of age and report SDS/centiles at 40 weeks gestation even if they were say 37+2 weeks. Now that it is all calculated and plotted electronically rather than on paper, as used to be the case, no precision is lost and therefore we now correct for all gestations that are not exactly 40 weeks. You have identified the conditional test for gestation to show or hide the buttons references gestation_weeks but not gestation_days, hence the omission of the buttons at gestations over 40 weeks but below 41. I have fixed this and bumped the version as a patch.

snield1150 commented 1 year ago

Thanks @eatyourpeas. We have now integrated the recent version and all is working as expected. Thanks for the quick turn around on a Friday evening!