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

*based on PR #510 'Finished KPI Tests'* Finishes first round of testing #517

Merged
merged 469 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
469 commits
Select commit Hold shift + click to select a range
0edfd82
adds 6_8_10 kpi ansawers to aggregate_kpi score test
anchit-chandran Jun 28, 2023
fd34933
initial draft, finished test_aggregate_all_eligible_kpi_fields_correc…
anchit-chandran Jun 28, 2023
b109e98
refactors test aggregate kpi score
anchit-chandran Jun 28, 2023
ffbfe44
refactors test case uknown postcode
anchit-chandran Jun 28, 2023
6ef00d2
rms unnecessary CaseFactory constructors in test_update_actions
anchit-chandran Jun 29, 2023
4321abe
adds avg to test_aggregate_all_eligible_kpi_fields_correct_kpi_scoring
anchit-chandran Jun 29, 2023
c10b461
selects start
eatyourpeas Jun 29, 2023
b04442e
docstrings for testing recalculate_form_ fn
anchit-chandran Jun 29, 2023
9c4d28e
add test form calculations
eatyourpeas Jun 29, 2023
de7f53f
Merge branch 'perms-tests' of https://github.com/rcpch/rcpch-audit-en…
anchit-chandran Jun 29, 2023
7246609
adds test_form_calc initial docstrings
anchit-chandran Jun 29, 2023
a9c2c2a
adds first completed_fields test for registration
anchit-chandran Jun 29, 2023
600e6f5
adds tests completed_fields(first_paediatric_assessment)
anchit-chandran Jun 29, 2023
25e0db4
adds completed_fields(epliepsycontext) tests
anchit-chandran Jun 29, 2023
3a700f9
completed test update
eatyourpeas Jun 29, 2023
c5ff1fe
investigations/management docstrings form test
eatyourpeas Jun 29, 2023
337373f
Merge branch 'perms-tests' of https://github.com/rcpch/rcpch-audit-en…
anchit-chandran Jun 30, 2023
dfafdb9
fixes test seeding errors
anchit-chandran Jun 30, 2023
4a0a7c8
skips failing test in test_update_actions
anchit-chandran Jun 30, 2023
b2035bc
adds assessment form calc tests
anchit-chandran Jun 30, 2023
b5c856b
adds investigations completed fields tests
anchit-chandran Jun 30, 2023
fe9d5c6
fix E12Managementfactory setting has_an_aed_been_given=True when sodi…
anchit-chandran Jun 30, 2023
9eea501
adds management completefields test ALL fields
anchit-chandran Jun 30, 2023
57ae860
multiaxial diagnosis docstrings
eatyourpeas Jun 30, 2023
c2ebaa5
dbaction comorbidity
eatyourpeas Jul 1, 2023
606df3a
update docstrings
eatyourpeas Jul 1, 2023
dbd22fc
fix select list
eatyourpeas Jul 1, 2023
c0fd1e7
complete selects
eatyourpeas Jul 1, 2023
e89d0d0
add select fails db action tests
eatyourpeas Jul 1, 2023
bd5b816
Merge branch 'perms-tests' of https://github.com/rcpch/rcpch-audit-en…
anchit-chandran Jul 3, 2023
23b1bf9
small fix to test_completed_fields_assessment_random_fields
anchit-chandran Jul 3, 2023
f4c5a84
renames test file to `test_completed_fields`, adds test_completed_fie…
anchit-chandran Jul 3, 2023
1364676
rms unused imports multiax factory
anchit-chandran Jul 3, 2023
48cec02
adds RANDOM completed_fields(model_instance=multiaxial_diagnosis)
anchit-chandran Jul 3, 2023
c1f11a2
rm default syndrome from SyndromeFactory
anchit-chandran Jul 3, 2023
d5b4414
updates docstrings finished test_completed_fields
anchit-chandran Jul 3, 2023
e38452c
adds syndrome==None case for str repr of Syndrome model
anchit-chandran Jul 3, 2023
82b3894
change str repr empty syndrome
anchit-chandran Jul 3, 2023
8bea596
adds episode tests for count completed fields related model
anchit-chandran Jul 4, 2023
4f5ac92
formats test_number completed fields file
anchit-chandran Jul 4, 2023
7d2ffb3
test gpg cred
anchit-chandran Jul 4, 2023
ace6c7e
rm commented code e12aemfactory
anchit-chandran Jul 4, 2023
192af34
adds count related model fields tests for Syndrome
anchit-chandran Jul 4, 2023
7872d27
adds completed fields related model count for Comorbidity
anchit-chandran Jul 4, 2023
455baf4
adds test_related_model_fields_count_management
anchit-chandran Jul 4, 2023
52b50b7
adds test_related_model_fields_count_registration, finishes tests for…
anchit-chandran Jul 5, 2023
3627247
adds `test_correct_output_scoreable_fields_for_model_class_name`, add…
anchit-chandran Jul 5, 2023
cd03daa
refactors `scoreable_fields_for_model_class_name` to use dataclass co…
anchit-chandran Jul 5, 2023
66c4005
adds initial `test_count_episode_fields` and `test_total_fields_expec…
anchit-chandran Jul 5, 2023
cb36858
adds test_total_fields_expected_multiaxial_diagnosis_syndrome_fields
anchit-chandran Jul 5, 2023
61b41b2
Adds test_total_fields_expected_multiaxial_diagnosis_general_fields a…
anchit-chandran Jul 6, 2023
0aee38e
Adds test_total_fields_expected_investigations and registration
anchit-chandran Jul 6, 2023
aedf59a
adds test_total_fields_expected_management
anchit-chandran Jul 6, 2023
43a4148
adds tests for expected_score_for_single_episode for all non-epilepti…
anchit-chandran Jul 6, 2023
4209a53
`avoid_fields` adds `META_VARIABLES` constant for lookup
anchit-chandran Jul 7, 2023
efe4490
better contrast colors for kpi agg bar charts
anchit-chandran Jul 7, 2023
fac8b1d
eeg tooltip text update as per issue Add NICE guidance re investigati…
anchit-chandran Jul 7, 2023
46695b6
updates test_measure_2 docstrings - more accurately describes test
anchit-chandran Jul 7, 2023
27e19b2
adds nhs-number to the common requirements
pacharanero Jul 7, 2023
1d6a782
Merge pull request #510 from rcpch/further-tests
pacharanero Jul 7, 2023
497bbee
perms tests doc strings
anchit-chandran Jul 7, 2023
01faebe
adds CRUDT perms test files + docstrings
anchit-chandran Jul 7, 2023
1e05467
adds test for permissions view success
anchit-chandran Jul 7, 2023
58cb932
adds test permissions view user list forbidden
anchit-chandran Jul 7, 2023
40a5f52
improves test perms view assertion msgs
anchit-chandran Jul 7, 2023
be0b66c
custom permissions
eatyourpeas Jul 7, 2023
86c5eb2
view only assessment perms tests
eatyourpeas Jul 7, 2023
04eebf4
add episode, multiaxial diagnosis syndrome
eatyourpeas Jul 7, 2023
b9fb71c
fix edit description labels permission
eatyourpeas Jul 7, 2023
c7d6888
view management permissions + fix
eatyourpeas Jul 7, 2023
7909c03
change first paediatric assessment
eatyourpeas Jul 7, 2023
4889a90
first paediatric assessment tests
eatyourpeas Jul 7, 2023
863041f
epilepsy context test
eatyourpeas Jul 7, 2023
87531ae
comorbidity tests
eatyourpeas Jul 7, 2023
c0d1c60
fix comorbidity view permissions
eatyourpeas Jul 7, 2023
8660b94
investigations change tests
eatyourpeas Jul 7, 2023
dff630b
change tests complete
eatyourpeas Jul 7, 2023
9960a41
fix disabled false toggle button
eatyourpeas Jul 7, 2023
ba0b254
create tests complete
eatyourpeas Jul 7, 2023
040bfe4
add delete tests
eatyourpeas Jul 7, 2023
3dd8513
adds registration view tests, refactors tests to use fewer db queries…
anchit-chandran Jul 7, 2023
729ecf6
adds permission view reg forbidden
anchit-chandran Jul 7, 2023
c87c65f
adds FPA view permissions success + forbidden tests
anchit-chandran Jul 7, 2023
a9bfc00
adds epilep_context success+forbidden view tests
anchit-chandran Jul 7, 2023
ca330f9
adds multi ax diagnosis view success+forbidden tests
anchit-chandran Jul 7, 2023
33df350
adds Episode+Syndrome view perms testing (200+403)
anchit-chandran Jul 7, 2023
abf883d
updates test_perms_docstrings
anchit-chandran Jul 7, 2023
147a870
update admin remove twitter add first_signed_in
eatyourpeas Jul 7, 2023
7ba40a1
adds seed groups cases users fixture
anchit-chandran Jul 7, 2023
bcd7a1a
adds comborbidities perms tests
anchit-chandran Jul 7, 2023
306a62a
adds assessment tests
anchit-chandran Jul 7, 2023
35c13db
xfails aggregate kpi test
anchit-chandran Jul 7, 2023
de282b3
cleans up cases+users seed fixture
anchit-chandran Jul 7, 2023
4ee3036
xfails unfinished aggregate by test
anchit-chandran Jul 7, 2023
ad912dd
ensure first run test is seeding test
anchit-chandran Jul 7, 2023
634ced3
adds AEM field perm checks
anchit-chandran Jul 7, 2023
e255cbd
refactors cases + user list perm view tests into 2 tests
anchit-chandran Jul 7, 2023
48924f2
refactors fpa, Epilep Contex, multiax diag into single larger test vi…
anchit-chandran Jul 7, 2023
bc273f0
refactors forbidden view tests into single for fpa, EC, multiax diag
anchit-chandran Jul 7, 2023
2d1867d
user refactor
eatyourpeas Jul 7, 2023
60f3594
refactors into single test asserting success cases for episode_syndro…
anchit-chandran Jul 7, 2023
5894d40
rms print statement and fix incorrect status code check
anchit-chandran Jul 7, 2023
87b5cd8
improves doc string formatting
anchit-chandran Jul 7, 2023
d86313d
refactor epilepsy12user
eatyourpeas Jul 7, 2023
3826abd
refactor groups
eatyourpeas Jul 7, 2023
ddc0179
fix tests for RCPCH Audit Team
eatyourpeas Jul 7, 2023
016f945
refactor doc strings with rcpch audit team
eatyourpeas Jul 7, 2023
9b7c636
add new user management tests
eatyourpeas Jul 7, 2023
1623b0b
update group permissions
eatyourpeas Jul 7, 2023
58b0361
apply can_unlock_child_case_data_from_editing and can_lock_child_case…
eatyourpeas Jul 7, 2023
02790e3
fix validate_form_update_model
eatyourpeas Jul 7, 2023
66d564b
create edit/transfer lead site template partial
eatyourpeas Jul 7, 2023
f3a719b
fix transfer permissions and email work flow
eatyourpeas Jul 7, 2023
914ead2
fix transfer lead site workflow
eatyourpeas Jul 7, 2023
9ac7140
add consent forms, view and urls
eatyourpeas Jul 7, 2023
81dcb2f
fix #488
eatyourpeas Jul 7, 2023
0f85f5f
add mkdocs tags
eatyourpeas Jul 7, 2023
f1cd171
Adds clinical audit team person
anchit-chandran Jul 7, 2023
69d679d
makes first update permisisons test
anchit-chandran Jul 7, 2023
ddb7ff2
adds test user seeding py shell code
anchit-chandran Jul 7, 2023
d69183a
updates doc strings
anchit-chandran Jul 7, 2023
1e5ad88
accounts for CLINICAL_AUDIT_TEAM role in perm view tests
anchit-chandran Jul 7, 2023
cc8736f
updates doc strings perms view
anchit-chandran Jul 7, 2023
a60f52b
formats docstrings test perm create
anchit-chandran Jul 7, 2023
dff913e
epilepsy12users update tests
eatyourpeas Jul 7, 2023
2020895
fix seed users fixture + adds first test create perms e12 user
anchit-chandran Jul 7, 2023
cbaf068
update cases permissions tests
eatyourpeas Jul 7, 2023
d0c9355
update cases tests
eatyourpeas Jul 7, 2023
be57b77
first paediatric assessment update
eatyourpeas Jul 7, 2023
5b92303
refactors all view tests to use HTTP.Status constants instead of hard…
anchit-chandran Jul 7, 2023
4098e1c
adds create perms test
anchit-chandran Jul 7, 2023
35273ee
update epilepsy context tests
eatyourpeas Jul 7, 2023
2d0f5e8
status codes epilepsy context
eatyourpeas Jul 7, 2023
eaa1160
update multiaxial diagnosis tests
eatyourpeas Jul 7, 2023
9ea05d4
add epilepsy causes fixture
eatyourpeas Jul 7, 2023
28eb0ea
deprecates seed_epilepsy_cause fixture
anchit-chandran Jul 7, 2023
32a84d7
adds forbidden user creation test
anchit-chandran Jul 7, 2023
a006ccd
adds create pts test success
anchit-chandran Jul 7, 2023
1f455e8
adds test forbidden create case
anchit-chandran Jul 7, 2023
5e2be57
changes client.get to client.post in test_users_update_muiltiaxial_di…
anchit-chandran Jul 7, 2023
df02690
adds test_update_multiaxial_diagnosis_cause_success
anchit-chandran Jul 7, 2023
5781620
first draft of test_add_episode_success
anchit-chandran Jul 7, 2023
9bc19a8
improves test_add_episode_success
anchit-chandran Jul 7, 2023
bd99079
updates seed test user administrator group setting according to role
anchit-chandran Jul 7, 2023
0af0a76
changes edit_aem view's perms to view_aem perm
anchit-chandran Jul 7, 2023
b6cdced
adds extra test asserting 200 add episode for diff Trust
anchit-chandran Jul 7, 2023
91a0b89
adds forbidden add_episode tests (xfailed)
anchit-chandran Jul 7, 2023
f2ec58d
xfails the forbidden add_episode
anchit-chandran Jul 7, 2023
2d6d6dd
adds comborbidity+syndrome success+forbidden add tests
anchit-chandran Jul 7, 2023
7f92cff
adds perms for add aem
anchit-chandran Jul 7, 2023
e704e48
test delete perm docstrings
anchit-chandran Jul 7, 2023
52feb94
episode
eatyourpeas Jul 7, 2023
5acc397
permission update episode
eatyourpeas Jul 7, 2023
ef0729a
update docstrings
eatyourpeas Jul 7, 2023
1540370
adds test user delete 200 perms
anchit-chandran Jul 7, 2023
359aa9e
adds test delete user forbidden
anchit-chandran Jul 7, 2023
1141a8d
adds pt delete success / forbidden tests
anchit-chandran Jul 7, 2023
0d6209f
adds perm check to deny administrators from deleting a case
anchit-chandran Jul 7, 2023
c245dd0
adds test perm del episode
anchit-chandran Jul 7, 2023
a313dbe
adds syndrome, comorbidity, aem delete tests
anchit-chandran Jul 7, 2023
00837e4
refactors test perms create+view
anchit-chandran Jul 7, 2023
13eb9e0
comorbidities failing for admin, passing all others
eatyourpeas Jul 7, 2023
14d5c14
update user_first_names_test
eatyourpeas Jul 7, 2023
5a51ee0
fixed update_tests perms
eatyourpeas Jul 7, 2023
86429bd
remove x-fail from add_episode/comorbidity
eatyourpeas Jul 7, 2023
f5fdd0e
add future validation to registration model
eatyourpeas Jul 7, 2023
2968ced
fix multiaxial diagnosis DESSCRIBE label styling
eatyourpeas Jul 7, 2023
700d9d4
fix aggregation_by test errors
eatyourpeas Jul 7, 2023
e768101
add nhs_number fix failing tests
eatyourpeas Jul 7, 2023
b919fbe
update assessment permissions tests
eatyourpeas Jul 7, 2023
77cd53d
investigations update tests
eatyourpeas Jul 7, 2023
04d57c5
update management permissions tests
eatyourpeas Jul 7, 2023
aabc7c3
update antiepilepsy medicine tests
eatyourpeas Jul 7, 2023
61390c4
db_actions
eatyourpeas Jul 7, 2023
8f49e51
remove excludes
eatyourpeas Jul 7, 2023
12b1a8f
renames test permissions folder to `permissions_tests`
anchit-chandran Jul 7, 2023
0343254
refactors e12casefactory to use `nhs-number` library
anchit-chandran Jul 7, 2023
ff2891b
refactors test_permisions_view to fix User querysets/nhs_num in case …
anchit-chandran Jul 7, 2023
664f139
refactors post-review `test_[permissions_create.py`
anchit-chandran Jul 7, 2023
10ecaa2
refactors test_permissions_delete for test_user queryset
anchit-chandran Jul 7, 2023
c314775
refactors test_perm_update re User querysets
anchit-chandran Jul 7, 2023
55ec1f8
test_perm_update refactors: rm .mark.parametrize, replace implicit Us…
anchit-chandran Jul 7, 2023
bf9174c
rms unused vars
anchit-chandran Jul 7, 2023
0759965
test update actions episode, epilepsy context, fpa
eatyourpeas Jul 7, 2023
f2386c6
more fields to doc strings update db
eatyourpeas Jul 7, 2023
acd4930
refactor queryset cases aggregate by deprivation - adds str map as ex…
anchit-chandran Jul 7, 2023
1664262
handles None in cases aggregate by deprivation
anchit-chandran Jul 7, 2023
48efb4e
adds deprivation score test and refactors aggregate fn
anchit-chandran Jul 7, 2023
a888f30
adds test_cases_aggregated_by_ethnicity
anchit-chandran Jul 7, 2023
fe584a5
adds test_aggregate_all_eligible_kpi_fields_correct_fields_present
anchit-chandran Jul 7, 2023
ab6b250
changes deprivation score agg test to use chelwest instead of gosh
anchit-chandran Jul 7, 2023
daea7a1
tes db_actions all toggles
eatyourpeas Jul 7, 2023
db434ab
test toggle true and false
eatyourpeas Jul 7, 2023
cd84385
initial test_kpi_aggregate_score (unfinished for setting KPIs6,8,10 t…
anchit-chandran Jul 7, 2023
2bd879b
adds 6_8_10 kpi ansawers to aggregate_kpi score test
anchit-chandran Jul 7, 2023
753c131
initial draft, finished test_aggregate_all_eligible_kpi_fields_correc…
anchit-chandran Jul 7, 2023
42eb636
refactors test aggregate kpi score
anchit-chandran Jul 7, 2023
3d18f69
refactors test case uknown postcode
anchit-chandran Jul 7, 2023
f92782e
rms unnecessary CaseFactory constructors in test_update_actions
anchit-chandran Jul 7, 2023
d85d36b
adds avg to test_aggregate_all_eligible_kpi_fields_correct_kpi_scoring
anchit-chandran Jul 7, 2023
cc5a9e4
selects start
eatyourpeas Jul 7, 2023
682feb5
docstrings for testing recalculate_form_ fn
anchit-chandran Jul 7, 2023
e898b5d
add test form calculations
eatyourpeas Jul 7, 2023
6895739
adds test_form_calc initial docstrings
anchit-chandran Jul 7, 2023
953fd1a
adds first completed_fields test for registration
anchit-chandran Jul 7, 2023
4e3581e
adds tests completed_fields(first_paediatric_assessment)
anchit-chandran Jul 7, 2023
773cf1d
adds completed_fields(epliepsycontext) tests
anchit-chandran Jul 7, 2023
c563025
completed test update
eatyourpeas Jul 7, 2023
f9f37aa
investigations/management docstrings form test
eatyourpeas Jul 7, 2023
f27d543
fixes test seeding errors
anchit-chandran Jul 7, 2023
b763c3f
skips failing test in test_update_actions
anchit-chandran Jul 7, 2023
af18241
adds assessment form calc tests
anchit-chandran Jul 7, 2023
4966499
adds investigations completed fields tests
anchit-chandran Jul 7, 2023
e10ffcf
fix E12Managementfactory setting has_an_aed_been_given=True when sodi…
anchit-chandran Jul 7, 2023
0cab4e9
adds management completefields test ALL fields
anchit-chandran Jul 7, 2023
a1c592a
multiaxial diagnosis docstrings
eatyourpeas Jul 7, 2023
27224da
dbaction comorbidity
eatyourpeas Jul 7, 2023
3be8e4a
update docstrings
eatyourpeas Jul 7, 2023
6c7568f
fix select list
eatyourpeas Jul 7, 2023
6fdad99
complete selects
eatyourpeas Jul 7, 2023
7a71596
add select fails db action tests
eatyourpeas Jul 7, 2023
4156a5a
small fix to test_completed_fields_assessment_random_fields
anchit-chandran Jul 7, 2023
6cc4bf8
renames test file to `test_completed_fields`, adds test_completed_fie…
anchit-chandran Jul 7, 2023
65f019f
rms unused imports multiax factory
anchit-chandran Jul 7, 2023
9dc9e81
adds RANDOM completed_fields(model_instance=multiaxial_diagnosis)
anchit-chandran Jul 7, 2023
d577ba3
rm default syndrome from SyndromeFactory
anchit-chandran Jul 7, 2023
5e69a5f
updates docstrings finished test_completed_fields
anchit-chandran Jul 7, 2023
133fae5
adds syndrome==None case for str repr of Syndrome model
anchit-chandran Jul 7, 2023
a2b2455
change str repr empty syndrome
anchit-chandran Jul 7, 2023
dfacdf7
adds episode tests for count completed fields related model
anchit-chandran Jul 7, 2023
8d8cccd
formats test_number completed fields file
anchit-chandran Jul 7, 2023
cf4fe1b
test gpg cred
anchit-chandran Jul 7, 2023
95fbef3
rm commented code e12aemfactory
anchit-chandran Jul 7, 2023
b1dff9b
adds count related model fields tests for Syndrome
anchit-chandran Jul 7, 2023
740553e
adds completed fields related model count for Comorbidity
anchit-chandran Jul 7, 2023
6e2551e
adds test_related_model_fields_count_management
anchit-chandran Jul 7, 2023
6de70da
adds test_related_model_fields_count_registration, finishes tests for…
anchit-chandran Jul 7, 2023
83ac32d
adds `test_correct_output_scoreable_fields_for_model_class_name`, add…
anchit-chandran Jul 7, 2023
8de00fa
refactors `scoreable_fields_for_model_class_name` to use dataclass co…
anchit-chandran Jul 7, 2023
6d9df7b
adds initial `test_count_episode_fields` and `test_total_fields_expec…
anchit-chandran Jul 7, 2023
2781b5d
adds test_total_fields_expected_multiaxial_diagnosis_syndrome_fields
anchit-chandran Jul 7, 2023
0c879e4
Adds test_total_fields_expected_multiaxial_diagnosis_general_fields a…
anchit-chandran Jul 7, 2023
610ba64
Adds test_total_fields_expected_investigations and registration
anchit-chandran Jul 7, 2023
2d14e2f
adds test_total_fields_expected_management
anchit-chandran Jul 7, 2023
f15aac3
adds tests for expected_score_for_single_episode for all non-epilepti…
anchit-chandran Jul 7, 2023
34dd68b
`avoid_fields` adds `META_VARIABLES` constant for lookup
anchit-chandran Jul 7, 2023
6a8e5d6
better contrast colors for kpi agg bar charts
anchit-chandran Jul 7, 2023
7a5d2b5
eeg tooltip text update as per issue Add NICE guidance re investigati…
anchit-chandran Jul 7, 2023
15f3542
updates test_measure_2 docstrings - more accurately describes test
anchit-chandran Jul 7, 2023
3046ece
Merge branch 'perms-tests' of https://github.com/rcpch/rcpch-audit-en…
anchit-chandran Jul 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions epilepsy12/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class Epilepsy12UserAdmin(UserAdmin, SimpleHistoryAdmin):
"email",
"surname",
"role",
"organisation_employer",
"is_active",
)
list_display = (
Expand All @@ -28,7 +27,6 @@ class Epilepsy12UserAdmin(UserAdmin, SimpleHistoryAdmin):
"first_name",
"surname",
"is_active",
"twitter_handle",
"role",
"organisation_employer",
"is_superuser",
Expand All @@ -52,20 +50,30 @@ class Epilepsy12UserAdmin(UserAdmin, SimpleHistoryAdmin):
},
),
("Epilepsy12 Centre", {"fields": ("organisation_employer", "role")}),
("Contacts", {"fields": ("email", "twitter_handle")}),
("Contacts", {"fields": ("email",)}),
(
"Permissions",
{
"fields": (
"is_active",
"is_staff",
"is_rcpch_staff",
"is_rcpch_audit_team_member",
"is_superuser",
"email_confirmed",
"view_preference",
)
},
),
(
"Access",
{
"fields": (
"last_login",
"date_joined",
)
},
),
(
"Group Permissions",
{
Expand All @@ -76,7 +84,6 @@ class Epilepsy12UserAdmin(UserAdmin, SimpleHistoryAdmin):
),
},
),
("Personal", {"fields": ("bio",)}),
)
add_fieldsets = (
(
Expand All @@ -89,6 +96,7 @@ class Epilepsy12UserAdmin(UserAdmin, SimpleHistoryAdmin):
"first_name",
"surname",
"is_staff",
"is_rcpch_staff",
"is_active",
"is_rcpch_audit_team_member",
"role",
Expand All @@ -114,6 +122,8 @@ def get_form(self, request, obj=None, **kwargs):
form.base_fields["title"].disabled = True
form.base_fields["email"].disabled = True
form.base_fields["is_staff"].disabled = True
form.base_fields["is_rcpch_staff"].disabled = True
form.base_fields["is_rcpch_audit_team_member"].disabled = True
return form


Expand Down
60 changes: 35 additions & 25 deletions epilepsy12/common_view_functions/aggregate_by.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Literal

# Django imports
from django.apps import apps
from django.contrib.gis.db.models import (
Q,
F,
Expand All @@ -16,7 +17,8 @@

# E12 imports
from epilepsy12.constants import ETHNICITIES, SEX_TYPE
from ..models import Case

# from ..models import Case
from .report_queries import (
get_all_organisations,
get_all_trusts,
Expand All @@ -34,12 +36,12 @@
def cases_aggregated_by_sex(selected_organisation):
# aggregate queries on trust level cases

Case = apps.get_model("epilepsy12", "Case")

sex_long_list = [When(sex=k, then=Value(v)) for k, v in SEX_TYPE]

cases_aggregated_by_sex = (
Case.objects.filter(
organisations__OrganisationName__contains=selected_organisation
)
Case.objects.filter(organisations=selected_organisation)
.values("sex")
.annotate(sex_display=DJANGO_CASE(*sex_long_list, output_field=CharField()))
.values("sex_display")
Expand All @@ -52,34 +54,37 @@ def cases_aggregated_by_sex(selected_organisation):

def cases_aggregated_by_deprivation_score(selected_organisation):
# aggregate queries on trust level cases
Case = apps.get_model("epilepsy12", "Case")

deprivation_quintiles = ((1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (None, 6))

imd_long_list = [
When(index_of_multiple_deprivation_quintile=k, then=Value(v))
for k, v in deprivation_quintiles
]
cases_in_selected_organisation = Case.objects.filter(
organisations__OrganisationName__contains=selected_organisation
)

cases_aggregated_by_deprivation = (
Case.objects.filter(
organisations__OrganisationName__contains=selected_organisation
)
# Filter just Cases in selected org
cases_in_selected_organisation
# Get list of IMD quintiles
.values("index_of_multiple_deprivation_quintile")
# Converting 'None' to 6 in a new index_of_multiple_deprivation_quintile_display "column"
.annotate(
index_of_multiple_deprivation_quintile_display=DJANGO_CASE(
*imd_long_list, output_field=PositiveSmallIntegerField()
When(index_of_multiple_deprivation_quintile=None, then=Value(6)),
default="index_of_multiple_deprivation_quintile",
output_field=PositiveSmallIntegerField(),
)
)
# Keeps only the new column
.values("index_of_multiple_deprivation_quintile_display")
# Value count the new column
.annotate(
cases_aggregated_by_deprivation=Count(
"index_of_multiple_deprivation_quintile"
)
"index_of_multiple_deprivation_quintile_display"
),
)
.order_by("index_of_multiple_deprivation_quintile")
.order_by('index_of_multiple_deprivation_quintile_display')

)

# map quintile num to string repr

deprivation_quintile_str_map = {
1: "1st quintile",
2: "2nd quintile",
Expand All @@ -89,19 +94,23 @@ def cases_aggregated_by_deprivation_score(selected_organisation):
6: "Not known",
}

for index, q in enumerate(cases_aggregated_by_deprivation):
q[
"index_of_multiple_deprivation_quintile_display"
] = deprivation_quintile_str_map.get(
q.get("index_of_multiple_deprivation_quintile_display")
)
for aggregate in cases_aggregated_by_deprivation:
quintile = aggregate["index_of_multiple_deprivation_quintile_display"]

str_map = deprivation_quintile_str_map.get(quintile)

aggregate.update(
{"index_of_multiple_deprivation_quintile_display_str": str_map}
)

return cases_aggregated_by_deprivation


def cases_aggregated_by_ethnicity(selected_organisation):
# aggregate queries on trust level cases

Case = apps.get_model("epilepsy12", "Case")

ethnicity_long_list = [When(ethnicity=k, then=Value(v)) for k, v in ETHNICITIES]

cases_aggregated_by_ethnicity = (
Expand Down Expand Up @@ -219,6 +228,7 @@ def return_all_aggregated_kpis_for_cohort_and_abstraction_level_annotated_by_sub
"""
Returns aggregated KPIS for given cohort annotated by sublevel of abstraction (eg kpis in each NHS England region, labelled by region)
"""
Case = apps.get_model("epilepsy12", "Case")

if abstraction_level == "organisation":
abstraction_sublevels = get_all_organisations()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,19 @@ def score_kpi_1(registration_instance) -> int:
# score KPI
if all_consultant_paediatrician_fields_complete:
passed_metric = (
relativedelta(
assessment.consultant_paediatrician_input_date,
assessment.consultant_paediatrician_referral_date,
).days
<= 14
)
assessment.consultant_paediatrician_input_date
- assessment.consultant_paediatrician_referral_date
).days <= 14
if passed_metric:
return KPI_SCORE["PASS"]
else:
return KPI_SCORE["FAIL"]

elif all_paediatric_neurologist_fields_complete:
passed_metric = (
relativedelta(
assessment.paediatric_neurologist_input_date,
assessment.paediatric_neurologist_referral_date,
).days
<= 14
)
assessment.paediatric_neurologist_input_date
- assessment.paediatric_neurologist_referral_date
).days <= 14
if passed_metric:
return KPI_SCORE["PASS"]
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

# django imports
from django.contrib.gis.db.models import Q
from django.apps import apps

# E12 imports
from epilepsy12.constants import KPI_SCORE
from epilepsy12.models import AntiEpilepsyMedicine, Episode


def score_kpi_3(registration_instance, age_at_first_paediatric_assessment) -> int:
"""3. tertiary_input
Expand All @@ -20,6 +21,9 @@ def score_kpi_3(registration_instance, age_at_first_paediatric_assessment) -> in

assessment = registration_instance.assessment

AntiEpilepsyMedicine = apps.get_model("epilepsy12", "AntiEpilepsyMedicine")
Episode = apps.get_model("epilepsy12", "Episode")

# EVALUATE ELIGIBILITY CRITERIA

# first gather relevant data
Expand Down Expand Up @@ -69,6 +73,7 @@ def score_kpi_3(registration_instance, age_at_first_paediatric_assessment) -> in
else:
return KPI_SCORE["FAIL"]


def score_kpi_3b(registration_instance) -> int:
"""3b. epilepsy_surgery_referral
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ def score_kpi_4(registration_instance) -> int:
epilepsy_context = registration_instance.epilepsycontext
investigations = registration_instance.investigations

# ineligible
if epilepsy_context.were_any_of_the_epileptic_seizures_convulsive is False:
return KPI_SCORE["INELIGIBLE"]

# not scored / ineligible guard clauses
if (epilepsy_context.were_any_of_the_epileptic_seizures_convulsive is None) or (
investigations.twelve_lead_ecg_status is None
):
return KPI_SCORE["NOT_SCORED"]
if epilepsy_context.were_any_of_the_epileptic_seizures_convulsive is False:
return KPI_SCORE["INELIGIBLE"]

# Convulsive seizure - score ECG status

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

# django imports
from django.contrib.gis.db.models import Q
from django.apps import apps

# E12 imports
from epilepsy12.models import Syndrome
# from epilepsy12.models import Syndrome
from epilepsy12.constants import KPI_SCORE


def score_kpi_5(registration_instance, age_at_first_paediatric_assessment) -> int:
"""5. MRI

Expand All @@ -19,13 +21,15 @@ def score_kpi_5(registration_instance, age_at_first_paediatric_assessment) -> in
multiaxial_diagnosis = registration_instance.multiaxialdiagnosis
investigations = registration_instance.investigations

Syndrome = apps.get_model("epilepsy12", "Syndrome")

# not scored
if multiaxial_diagnosis.syndrome_present is None:
if (age_at_first_paediatric_assessment >= 2) and (
multiaxial_diagnosis.syndrome_present is None
):
return KPI_SCORE["NOT_SCORED"]

# ineligible
if age_at_first_paediatric_assessment >= 2:
return KPI_SCORE["INELIGIBLE"]
# define eligibility criteria 1
ineligible_syndrome_present = Syndrome.objects.filter(
Q(multiaxial_diagnosis=multiaxial_diagnosis)
&
Expand All @@ -39,29 +43,35 @@ def score_kpi_5(registration_instance, age_at_first_paediatric_assessment) -> in
]
)
).exists()
if ineligible_syndrome_present:
return KPI_SCORE["INELIGIBLE"]

# not scored
mri_dates_are_none = [
(investigations.mri_brain_requested_date is None),
(investigations.mri_brain_reported_date is None),
]
if any(mri_dates_are_none):
return KPI_SCORE["NOT_SCORED"]
# check eligibility criteria 1 & 2
# 1 = none of the specified syndromes present
# 2 = age in years < 2
if (not ineligible_syndrome_present) or (age_at_first_paediatric_assessment < 2):
# not scored
mri_dates_are_none = [
(investigations.mri_brain_requested_date is None),
(investigations.mri_brain_reported_date is None),
]
if any(mri_dates_are_none):
return KPI_SCORE["NOT_SCORED"]

# eligible for this measure - score kpi
passing_criteria_met = (
abs(
(
investigations.mri_brain_requested_date
- investigations.mri_brain_reported_date
).days
# eligible for this measure - score kpi
passing_criteria_met = (
abs(
(
investigations.mri_brain_requested_date
- investigations.mri_brain_reported_date
).days
)
<= 42
)
<= 42
)

if passing_criteria_met:
return KPI_SCORE["PASS"]
if passing_criteria_met:
return KPI_SCORE["PASS"]
else:
return KPI_SCORE["FAIL"]

# ineligible
else:
return KPI_SCORE["FAIL"]
return KPI_SCORE["INELIGIBLE"]
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ def score_kpi_6(registration_instance, age_at_first_paediatric_assessment) -> in

multiaxial_diagnosis = registration_instance.multiaxialdiagnosis

# ineligible
if age_at_first_paediatric_assessment < 5:
return KPI_SCORE["INELIGIBLE"]

# not scored
if multiaxial_diagnosis.mental_health_screen is None:
return KPI_SCORE["NOT_SCORED"]

# ineligible
if age_at_first_paediatric_assessment < 5:
return KPI_SCORE["INELIGIBLE"]

# score kpi
if multiaxial_diagnosis.mental_health_screen:
Expand Down
Loading