opensafely-core / ehrql

ehrQL: the electronic health record query language for OpenSAFELY
https://docs.opensafely.org/ehrql/
Other
6 stars 3 forks source link

Check cutoff date for HES/SUS archive in real data once tables are populated #2048

Closed evansd closed 2 months ago

evansd commented 2 months ago

This is a follow on from:

We can safely merge and deploy this immediately because the *_ARCHIVE tables exist and have the right schema but are empty. As soon as these are populated, and the current tables no longer contain the full historical data, we should confirm that we have chosen an appropriate cutoff date.

The date is defined here: https://github.com/opensafely-core/ehrql/blob/88e870ab7a9dcea5b4398725d98b4ddfbc87a850/ehrql/backends/tpp.py#L208

We should check the min/max values over these columns:

Table Column
APCS Admission_Date
APCS_ARCHIVED Admission_Date
OPA Appointment_Date
OPA_ARCHIVED Appointment_Date
EC Arrival_Date
EC_ARCHIVED Arrival_Date

And ensure that the cutoff date we've chosen falls safely inside the overlap of the date ranges.