Skip to content

Commit

Permalink
Merge pull request #1657 from openhealthcare/opat-report-with-breakdown
Browse files Browse the repository at this point in the history
Opat report with breakdown
  • Loading branch information
davidmiller authored Oct 26, 2018
2 parents c84339f + 89f3866 commit 7ccd9db
Show file tree
Hide file tree
Showing 22 changed files with 5,138 additions and 3,906 deletions.
7,652 changes: 3,832 additions & 3,820 deletions elcid/data/lookuplists/lookuplists.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions elcid/migrations/0059_migrate_symptom.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Migration(migrations.Migration):

dependencies = [
('elcid', '0058_auto_20180326_1801'),
('walkin', '0011_auto_20170720_1435'),
]

operations = [
Expand Down
2 changes: 2 additions & 0 deletions elcid/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

DEBUG = True

BASE_URL = "http://elcidl"

ADMINS = (
('Support', '[email protected]',),
)
Expand Down
16 changes: 6 additions & 10 deletions infectiousdiseases/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class IdLiasionReport(Report):
slug = "id-liasion-report"
display_name = "ID Liasion Report"
description = "A Monthly Summary of the ID Liasion Teams Output"
template = "reports/infectiousdiseases/id_liasion_report.html"

def get_queryset(self, month_start):
next_month_beginning = month_start + relativedelta(months=1)
Expand Down Expand Up @@ -123,7 +122,7 @@ def get_headers(self):
return result

@cached_property
def reports_available(self):
def _report_options(self):
"""
A list of lists of available reports for the template
"""
Expand All @@ -148,17 +147,14 @@ def reports_available(self):
for i in range(num):
key_date = first_date + relativedelta(months=i)
months.append(dict(
display_month=key_date.strftime("%B"),
display_year=key_date.strftime("%Y"),
value=key_date.strftime("%d/%m/%Y")
display_name=key_date.strftime("%B %Y"),
criteria=dict(reporting_month=key_date.strftime("%d/%m/%Y")),
))

months.reverse()
rows = []
return months

for i in range(0, len(months), 4):
rows.append(months[i:i+4])
return rows
def report_options(self):
return self._report_options

def generate_report_data(self, criteria=None, **kwargs):
month_start = datetime.datetime.strptime(
Expand Down

This file was deleted.

42 changes: 18 additions & 24 deletions infectiousdiseases/tests/test_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ def test_generate_report_data(self):
)

@patch("infectiousdiseases.reports.datetime")
def test_reports_available_only_2(self, dt):
def test_get_report_options_only_2(self, dt):

# override datetime.date.today
class NewDate(datetime.date):
Expand All @@ -420,35 +420,33 @@ def today(cls):
value="id_liaison",
archived=True,
)
ctx = self.report.reports_available
ctx = self.report.report_options()
self.assertEqual(
len(ctx),
1
)
self.assertEqual(
len(ctx[0]),
2
)
self.assertEqual(
ctx[0][0],
{
'display_month': 'June',
'value': '01/06/2017',
'display_year': '2017'
ctx[0],
{'criteria':
{
'reporting_month': '01/05/2017'
},
'display_name': 'May 2017'
}
)

self.assertEqual(
ctx[0][1],
{
'display_month': 'May',
'value': '01/05/2017',
'display_year': '2017'
ctx[1],
{'criteria':
{
'reporting_month': '01/06/2017'
},
'display_name': 'June 2017'
}
)

@patch("infectiousdiseases.reports.datetime")
def test_reports_available_chunking(self, dt):
def test_reports_available_many(self, dt):

# override datetime.date.today
class NewDate(datetime.date):
Expand All @@ -464,15 +462,11 @@ def today(cls):
value="id_liaison",
archived=True,
)
ctx = self.report.reports_available
ctx = self.report.report_options()
self.assertEqual(
len(ctx),
4
)
self.assertEqual(
len(ctx[3]),
2
14
)

def test_reports_available_none(self):
self.assertIsNone(self.report.reports_available)
self.assertIsNone(self.report.report_options())
61 changes: 61 additions & 0 deletions opat/migrations/0008_opat_outcome.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.8 on 2018-08-17 19:22
from __future__ import unicode_literals

from django.db import migrations

PATIENT_OUTCOME_MAPPING = dict(
Cure='Cured',
Improved='Improved',
Failure='Failed'
)

OPAT_OUTCOME_MAPPING = {
'Success': 'Success',
'Partial Success': 'Parcial',
'Failure of OPAT': 'Failed',
'Intermidiate Outcome': 'Undeterminate'
}


def forward(apps, *args):
OPATOutcome = apps.get_model('opat', 'OPATOutcome')
for i, v in PATIENT_OUTCOME_MAPPING.items():
OPATOutcome.objects.filter(
patient_outcome=i
).update(
patient_outcome=v
)
for i, v in OPAT_OUTCOME_MAPPING.items():
OPATOutcome.objects.filter(
opat_outcome=i
).update(
opat_outcome=v
)


def backwards(apps, *args):
OPATOutcome = apps.get_model('opat', 'OPATOutcome')
for i, v in PATIENT_OUTCOME_MAPPING.items():
OPATOutcome.objects.filter(
patient_outcome=v
).update(
patient_outcome=i
)
for i, v in OPAT_OUTCOME_MAPPING.items():
OPATOutcome.objects.filter(
opat_outcome=v
).update(
opat_outcome=i
)


class Migration(migrations.Migration):

dependencies = [
('opat', '0007_auto_20180303_1431'),
]

operations = [
migrations.RunPython(forward, reverse_code=backwards)
]
25 changes: 25 additions & 0 deletions opat/migrations/0009_auto_20180817_2042.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.8 on 2018-08-17 19:42
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('opat', '0008_opat_outcome'),
]

operations = [
migrations.AlterField(
model_name='opatoutcome',
name='opat_outcome',
field=models.CharField(blank=True, choices=[(b'Success', b'Success'), (b'Parcial', b'Parcial'), (b'Failed', b'Failed'), (b'Undeterminate', b'Undeterminate')], max_length=200, null=True),
),
migrations.AlterField(
model_name='opatoutcome',
name='patient_outcome',
field=models.CharField(blank=True, choices=[(b'Cured', b'Cured'), (b'Improved', b'Improved'), (b'Failed', b'Failed')], max_length=200, null=True),
),
]
47 changes: 47 additions & 0 deletions opat/migrations/0010_lookuplist_spelling_corrections.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.8 on 2018-08-19 10:11
from __future__ import unicode_literals

from django.db import migrations

MAPPINGS = {
('opal', 'Line_complication',): {
"Infection - Phelbitis": "Infection - Phlebitis"
},
('opal', 'Antimicrobial_adverse_event',): {
"Esosinophilia": "Eosinophilia"
}
}


def forward(apps, *args, **kwargs):
for model, translations in MAPPINGS.items():
some_model = apps.get_model(*model)
for from_translation, to_translation in translations.items():
some_model.objects.filter(
name=from_translation
).update(
name=to_translation
)


def backwards(apps, *args, **kwargs):
for model, translations in MAPPINGS.items():
some_model = apps.get_model(*model)
for from_translation, to_translation in translations.items():
some_model.objects.filter(
name=to_translation
).update(
name=from_translation
)


class Migration(migrations.Migration):

dependencies = [
('opat', '0009_auto_20180817_2042'),
]

operations = [
migrations.RunPython(forward, reverse_code=backwards)
]
22 changes: 20 additions & 2 deletions opat/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,28 @@ class OPATOutcome(EpisodeSubrecord):
_title = "OPAT Outcome"
_clonable = False

PATIENT_OUTCOME_CHOICES = (
('Cured', 'Cured',),
('Improved', 'Improved'),
('Failed', 'Failed'),
)

OPAT_OUTCOME_CHOICES = (
('Success', 'Success',),
('Parcial', 'Parcial',),
('Failed', 'Failed',),
('Undeterminate', 'Undeterminate',),
)

outcome_stage = models.CharField(max_length=200, blank=True, null=True)
treatment_outcome = models.CharField(max_length=200, blank=True, null=True)
patient_outcome = models.CharField(max_length=200, blank=True, null=True)
opat_outcome = models.CharField(max_length=200, blank=True, null=True)
patient_outcome = models.CharField(
max_length=200, blank=True, null=True, choices=PATIENT_OUTCOME_CHOICES
)

opat_outcome = models.CharField(
max_length=200, blank=True, null=True, choices=OPAT_OUTCOME_CHOICES
)
deceased = models.NullBooleanField(default=False)
death_category = models.CharField(max_length=200, blank=True, null=True)
cause_of_death = models.CharField(max_length=200, blank=True, null=True)
Expand Down
Loading

0 comments on commit 7ccd9db

Please sign in to comment.