rcpch / rcpch-audit-engine

Epilepsy12 Audit Platform
https://e12.rcpch.ac.uk/
GNU Affero General Public License v3.0
5 stars 5 forks source link

Fixes s/seed bug where first paediatric assessment date was in the future #928

Closed dc2007git closed 3 months ago

dc2007git commented 3 months ago

Overview

When generating dummy data, a first paediatric assessment date is randomly generated at some date between the current cohort's start and end date. This, however, means that the assessment date could be in the future, which is impossible.

This PR contains a simple fix to set the range of possible FPA dates from the cohort start date to today, no longer using the cohort end date

Code changes

Changes range of random date generation in complete_registrations() in seed.py

Documentation changes (done or required as a result of this PR)

N/A

Related Issues

Closes #927

Mentions

@mbarton @eatyourpeas this is a simple fix that we should be able to merge without any problems - but I am quite curious as to why this error popped up all of a sudden today? The last time I ran a fresh s/up I had no such issues.

dc2007git commented 3 months ago

NOTE BEFORE MERGING

The logic for selecting a random should still factor in previous cohorts (ie cohort 6, which is fully in the past), which would not happen if the current merge happened. I will implement some logic to discern between a historical cohort (in which case the range the FPA date CAN be from cohort start date to end date) and the current cohort (in which case the range has to be from cohort start date to today)

eatyourpeas commented 3 months ago

Sorry a little late in the conversation here, but a bit of context. I recently added a new flag to the seed_registrations function to allow the dev to seed the database with children who had completed a full year of care, in addition to the cohort. Cohort 6 is not yet in the past, since although we are nolonger recruiting to cohort 6, those that joined cohort 6 last November still have a full year of care still to go. To generate random dates where a full year of care has completed therefore, the logic in the function (which I can see might be broken), is to select a first paediatric assessment date within the range for cohort 6, but also a random date before today which is one year on from the first paediatric assessment date. I hope that makes sense. If --full-year is true, then dates where FPA is cohort 6 <end April 2023 only are selected, if false, then dates up to November 30th 2023 are allowed.

I am wary of changing the nomenclature around recruiting and submitting cohorts because that is littered throughout the application. Happy to talk it through and perhaps we can merge this together?

dc2007git commented 3 months ago

Ah that explains it! Happy to go through and merge together. When are you free?

dc2007git commented 3 months ago

@eatyourpeas when do you fancy going through and merging this together?