Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kpi aggregations #282

Merged
merged 119 commits into from
Sep 28, 2024
Merged

Kpi aggregations #282

merged 119 commits into from
Sep 28, 2024

Conversation

anchit-chandran
Copy link
Contributor

@anchit-chandran anchit-chandran commented Sep 21, 2024

It's still WIP, but @mbarton discussed merging it into live so people can upload and view numbers. If a calculation method is not implemented, it is handled as 'Not implemented' in the table.

View calculation results at temp URL: https://npda.localhost/kpis/aggregation/pdu/PZ999 (note: you'd have to upload the dummy_csv_invalid first (or any csv but have updated values in there to ensure they get shown in aggregations due to particular KPI eligibilities).

Important changes:

  • Adds modular CalculateKPIS class
  • Adds associated tests for each kpi implemented so far (and architecture to make this easier) (NOTE: for debugging, I've set postcode for seeded patients as some particular name, as it's just a non-validated string field)

Note

have also patched call to imd_for_postcode globally across tests so now they run much faster, ~1-2 mins down to a few seconds, I should have done this earlier

  • Updates to dummy_sheet_invalid.csv to ensure some kpi values show (e.g. has T1DM, setting ages around 12 etc)
  • Adds KPI excel spreadsheets so centralised and version controlled changes
  • Adds temp view with simple table as template visualising kpi results, accessible at URL above

anchit-chandran and others added 30 commits July 19, 2024 18:14
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
… and build large query with single transaction

Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
creates kpi folder with file for each kpi query
kpi 1-4 added
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
…it cohort to enable debugging of kip calcs

Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
@anchit-chandran anchit-chandran marked this pull request as ready for review September 21, 2024 11:35
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
Copy link
Member

@mbarton mbarton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a big enough PR that I can't really review it in a meaningful sense but I've run it up locally and it calculates KPIs for dummy_sheet_invalid.csv and the tests all pass.

The debugging endpoint doesn't have any permissions checking on it but I guess that's fine since we're planning to replace it with dashboarding at the PDU level and upwards anyway.

So shall we merge this @anchit-chandran and then we can raise additional PRs against live to implement the other KPIs?

# So, we use a custom lazy fn to generate unique emails
@classmethod
def generate_unique_email(cls):
"""Generate a unique email address."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not as readable when debugging tests perhaps but we could use a UUID here instead:

email = f"npda_test_user_{str(uuid.uuid4())}@nhs.net"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

much nicer, good shout! once i make this change, will merge

@anchit-chandran
Copy link
Contributor Author

anchit-chandran commented Sep 25, 2024

This is a big enough PR that I can't really review it in a meaningful sense but I've run it up locally and it calculates KPIs for dummy_sheet_invalid.csv and the tests all pass.

So shall we merge this @anchit-chandran and then we can raise additional PRs against live to implement the other KPIs?

Agreed it's definitely too large, the real review will come from people using and seeing whether numbers are as expected. Hopefully after the first few kinks, should be easy to sort as will be related to definition nuances; particularly if there's issues in KPI calculations 1-12, it'll lead to downstream issues in other calculations. But equally, a fix there will fix any downstream issues too.

An important note here is that the tests should definitely pass but that doesn't mean the calculations are correct as depends on KPI definitions which have required updating / confirming as I work through each calculation. Have made updates to the excel sheet which is git tracked in the repo

The debugging endpoint doesn't have any permissions checking on it but I guess that's fine since we're planning to replace it with dashboarding at the PDU level and upwards anyway.

Also re permissions - we're not using any real data currently? That was the main reason I hadn't put perms checks as just a quick debugging view with intention; but is quick to add the perms mixin

@mbarton
Copy link
Member

mbarton commented Sep 25, 2024

Also re permissions - we're not using any real data currently? That was the main reason I hadn't put perms checks as just a quick debugging view with intention; but is quick to add the perms mixin

My only worry is that we might forget about it - so lets raise an issue to track removing it

Signed-off-by: anchit-chandran <anchit97123@gmail.com>
@anchit-chandran
Copy link
Contributor Author

Add issue and updated email field. Will merge

@anchit-chandran anchit-chandran merged commit c9f4731 into live Sep 28, 2024
1 check passed
@anchit-chandran anchit-chandran deleted the kpi-aggregations branch September 28, 2024 10:06
@mbarton
Copy link
Member

mbarton commented Sep 28, 2024

Seen on STAGING (merged by @anchit-chandran 5 minutes and 21 seconds ago) Please check your changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants