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

KPI download fails in staging #899

Closed mbarton closed 4 months ago

mbarton commented 4 months ago
django-1   | ERROR [django.request] Internal Server Error: /kpi_download_file
django-1   | Traceback (most recent call last):
django-1   |   File "/usr/local/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
django-1   |     response = get_response(request)
django-1   |                ^^^^^^^^^^^^^^^^^^^^^
django-1   |   File "/usr/local/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
django-1   |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
django-1   |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django-1   |   File "/app/epilepsy12/decorator.py", line 380, in wrapper
django-1   |     return view(request, *args, **kwargs)
django-1   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django-1   |   File "/usr/local/lib/python3.11/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapper_view
django-1   |     return view_func(request, *args, **kwargs)
django-1   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django-1   |   File "/app/epilepsy12/views/organisation_views.py", line 450, in kpi_download_file
django-1   |     country_df, trust_hb_df, icb_df, region_df, network_df, national_df, reference_df = download_kpi_summary_as_csv(cohort=6)
django-1   |                                                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django-1   |   File "/app/epilepsy12/kpi.py", line 101, in download_kpi_summary_as_csv
django-1   |     trust_hb_df = create_KPI_aggregation_dataframe("LocalHealthBoardKPIAggregation", LOCAL_HEALTH_BOARDS, cohort, measures, measures_titles, KPI_model2="TrustKPIAggregation", constants_list2=TRUSTS)
django-1   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django-1   |   File "/app/epilepsy12/common_view_functions/aggregate_by.py", line 874, in create_KPI_aggregation_dataframe
django-1   |     "Percentage": object[f"{kpi}_passed"]
django-1   |                   ^^^^^^^^^^^^^^^^^^^^^^^
django-1   | TypeError: unsupported operand type(s) for /: 'NoneType' and 'NoneType'
mbarton commented 4 months ago

The line number means if constants_list2 == TRUSTS must be true so we should be failing on HBT (Trusts & Health Boards) - SHEET 2

https://github.com/rcpch/rcpch-audit-engine/blob/18fbf56d77850833fc57465d5a8ffe836fc24eb7/epilepsy12/kpi.py#L101

I'm not really sure it's going to be possible to work out what KPI is missing values without adding some additional logging

mbarton commented 4 months ago

Added additional logging:

django-1  | INFO [epilepsy12.common_view_functions.aggregate_by:798] Missing numerator for 7A6 1. Paediatrician with expertise paediatrician_with_expertise_in_epilepsies
django-1  | INFO [epilepsy12.common_view_functions.aggregate_by:801] Missing denominator for 7A6 1. Paediatrician with expertise paediatrician_with_expertise_in_epilepsies

however in #902 I didn't add the correct early returns so it still crashes. Will address in a new PR