ebmdatalab / openprescribing

A Django app providing a REST API and dashboards for the HSCIC's GP prescribing data
https://openprescribing.net
MIT License
97 stars 26 forks source link

Analyse Page Totals don't match at different org levels #1768

Closed brianmackenna closed 1 year ago

brianmackenna commented 5 years ago

On the Analyse page (which is so so so handy in my role) the totals do not match up when you total at a different organisational level. See Atorvastatin national example

inglesp commented 5 years ago

Summary:

inglesp commented 5 years ago

Notes:

The April 2019 total spending is shown as:

The difference between CCGs and RTs is minimal.

The cause is that _practice_to_ccg_map/_practice_to_stp_map/_practice_to_regional_team_map return slightly different sets of practices.

>>> Practice.objects.filter(ccg__org_type='CCG').count()  # _practice_to_ccg_map
10940
>>> Practice.objects.filter(ccg__stp_id__isnull=False).count()  _practice_to_stp_map
10592
>>> Practice.objects.filter(ccg__regional_team_id__isnull=False).count()  # _practice_to_regional_team_map
11285

Since these computations are all related to properties of a practice's CCG, we can look at those instead:

>>> PCT.objects.filter(org_type='CCG').count()
221
>>> PCT.objects.filter(stp_id__isnull=False).count()
195
>>> PCT.objects.filter(regional_team_id__isnull=False).count()
245

And here's a Venn diagram:

image

inglesp commented 5 years ago

Next steps: