opensafely / SRO-Measures

1 stars 0 forks source link

Population count #116

Closed LFISHER7 closed 2 years ago

LFISHER7 commented 2 years ago

The population count currently used double counts any patients who move between a TPP and EMIS practice. See this doc for details.

This adds a script to allow counting of patients who join or leave TPP during the study period. We assume these people move to or from EMIS (a small % could be from another provider, they could be leaving the country etc so this is imperfect, but better than we currently have).

These counts will be subtracted from the counts in the [SRO paper(https://docs.google.com/document/d/1IT3yVqcoRlsEcLwO7fRXMa_SaUALjy5zCEptu8rqUNk/edit) to provide more reliable summary counts

LFISHER7 commented 2 years ago

Thanks for reviewing. I think some tests are probably a good idea. I'll give it a go.

LFISHER7 commented 2 years ago

I've added some tests for this, which caught an error in identifying patients who have left during the study period.

I was wrongly going on the assumption that people leave a backend when they die - they don't. We therefore don't need to worry about any logic around people dying when finding people who have left, we simply find people in the first extract who are not in subsequent extracts.

For patients who do leave, the demographic info is taken from the first month. It was previously being taken from the monthly extracts (where the people who have left are not present).

Hopefully the tests make this easier to digest, let me know if anything is unclear!