Skip to content

Commit

Permalink
realised not specifying diagnosis_date so being randomly set
Browse files Browse the repository at this point in the history
Signed-off-by: anchit-chandran <anchit97123@gmail.com>
  • Loading branch information
anchit-chandran committed Nov 7, 2024
1 parent bc0a4cd commit 603f40d
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions project/npda/kpi_class/kpis.py
Original file line number Diff line number Diff line change
Expand Up @@ -3277,11 +3277,31 @@ def calculate_kpi_45_median_hba1c(
).values("patient__postcode", "hba1c", "patient__pk")

# debugging
from pprint import pprint
from pprint import pprint, pformat
tmp_pts_data = defaultdict(list)
for v in Visit.objects.all().values('visit_date', 'hba1c_date','patient__diagnosis_date', 'hba1c', 'patient__postcode'):
pprint(v)
tmp_pts_data[(v['patient__postcode'], v['patient__diagnosis_date'])].append({
v['visit_date']: {
'hba1c_date': v['hba1c_date'],
'hba1c': v['hba1c'],
}
})
for (pt_name, diagnosis_date), visit_data in tmp_pts_data.items():
print(f'{pt_name=}, diagnosed on {diagnosis_date}')
pprint(visit_data)
print()

breakpoint()
# diagnosis_date = v['patient__diagnosis_date']
# hba1c_date = v['hba1c_date']
# print(f'{v["patient__postcode"]}')
# print(f"{v['patient__diagnosis_date']=} {v['hba1c_date']=}")
# if diagnosis_date and hba1c_date:
# print(f"Measurement taken {v['hba1c_date'] - v['patient__diagnosis_date']} days after diagnosis: {'excluded' if (hba1c_date - diagnosis_date).days < 90 else 'included'}")
# else:
# print(f"Taken after 90 days of diabetes diagnosis: False")
# print(f"{v['visit_date']=}")
# print(f"{v['hba1c']=}")
# print()

# Group HbA1c values by patient ID into a list so can use
# calculate_median method
Expand Down

0 comments on commit 603f40d

Please sign in to comment.