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

Anchit/kpis/implement-pdu-vs-patient-calc-methods #311

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
aba7521
update `KPICalculatationsObject` as no longer will return 'NOT IMPLEM…
anchit-chandran Oct 8, 2024
7a37cd0
initial refactor into 2 separate methods `calculate_kpis_for_pdus` `c…
anchit-chandran Oct 8, 2024
b440879
formatting
anchit-chandran Oct 8, 2024
3bb1c34
refactor home view to use `calculate_kpis_for_pdus` method
anchit-chandran Oct 8, 2024
fe26df4
rm pz_code attribute from `KPICalculationsObject` interface as no lon…
anchit-chandran Oct 8, 2024
8d77e7c
refactor visit view to implement calculate_kpis_for_patients
anchit-chandran Oct 8, 2024
71a9fea
update `calculate_kpis_for_patients` to take Queryset of patients
anchit-chandran Oct 8, 2024
bf6544d
fix kpi calc meta tests
anchit-chandran Oct 8, 2024
809fdb4
add `CalculateKPIS` fixture and replace test 1 with it
anchit-chandran Oct 8, 2024
fbb265d
Revert "add `CalculateKPIS` fixture and replace test 1 with it"
anchit-chandran Oct 8, 2024
cce0000
fix all kpi 1-12 test with refactor
anchit-chandran Oct 8, 2024
62e96d6
refactor kpi 13-20 tests
anchit-chandran Oct 8, 2024
0a5dbd3
fix kpi tests 21-23
anchit-chandran Oct 8, 2024
5417348
fix test kpi 24
anchit-chandran Oct 8, 2024
332a9c3
fix tests kpis 25-31
anchit-chandran Oct 8, 2024
069f289
fixes kpis 32 tests using .distinct
anchit-chandran Oct 8, 2024
296e78f
update doc strings
anchit-chandran Oct 9, 2024
6ab1080
refactor kp33-40 tests
anchit-chandran Oct 9, 2024
4515d7c
refactor tests kpi41-43
anchit-chandran Oct 9, 2024
91df8ce
refactor kpi tests 44-49
anchit-chandran Oct 9, 2024
f1fc6da
update docstrings
anchit-chandran Oct 9, 2024
3d62121
rm kpi debugging view as no longer needed
anchit-chandran Oct 9, 2024
7071a07
update nhs number method name
anchit-chandran Oct 9, 2024
c6a7a1a
rm unused imports
anchit-chandran Oct 9, 2024
66dc4e2
rm old view
anchit-chandran Oct 9, 2024
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
7 changes: 3 additions & 4 deletions project/constants/types/kpi_types.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Object types
from dataclasses import dataclass
from datetime import date, datetime
from typing import Dict, Union
from typing import Dict


@dataclass
Expand All @@ -14,12 +14,11 @@ class KPIResult:

@dataclass
class KPICalculationsObject:
pz_code: str
calculation_datetime: datetime
audit_start_date: date
audit_end_date: date
total_patients_count: int
calculated_kpi_values: Dict[
str,
Union[KPIResult, str],
] # looks like { 'kpi_name' : KPIResult OR "Not implemented"}
KPIResult,
]
31 changes: 13 additions & 18 deletions project/npda/forms/patient_form.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
# python imports
from datetime import date
import logging
from datetime import date

# project imports
import nhs_number
# third-party imports
from dateutil.relativedelta import relativedelta
from django import forms
# django imports
from django.apps import apps
from django.core.exceptions import ValidationError
from django import forms

# third-party imports
from dateutil.relativedelta import relativedelta
from requests import RequestException

# project imports
import nhs_number
from ..models import Patient
from ...constants.styles.form_styles import *
from ..general_functions import (
validate_postcode,
gp_ods_code_for_postcode,
gp_details_for_ods_code,
imd_for_postcode
)
from ..general_functions import (gp_details_for_ods_code,
gp_ods_code_for_postcode, imd_for_postcode,
validate_postcode)
from ..models import Patient
from ..validators import not_in_the_future_validator


logger = logging.getLogger(__name__)


Expand All @@ -34,7 +29,7 @@ class DateInput(forms.DateInput):
class NHSNumberField(forms.CharField):
def to_python(self, value):
number = super().to_python(value)
normalised = nhs_number.normalise_number(number)
normalised = nhs_number.standardise_format(number)

# For some combinations we get back an empty string (eg '719-573 0220')
return normalised or value
Expand Down Expand Up @@ -103,13 +98,13 @@ def clean_date_of_birth(self):
)

return date_of_birth

def clean_postcode(self):
postcode = self.cleaned_data["postcode"]

try:
result = validate_postcode(postcode)

if not result:
self.add_error(
"postcode",
Expand Down
Loading