Skip to content

Commit

Permalink
Merge 0f9ceb8 into 157ad34
Browse files Browse the repository at this point in the history
  • Loading branch information
fredkingham committed Jun 18, 2019
2 parents 157ad34 + 0f9ceb8 commit 98c95b8
Show file tree
Hide file tree
Showing 19 changed files with 600 additions and 169 deletions.
66 changes: 66 additions & 0 deletions apps/tb/migrations/0042_auto_20190617_1458.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Generated by Django 2.0.13 on 2019-06-17 14:58

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import opal.models


class Migration(migrations.Migration):

dependencies = [
('opal', '0037_auto_20181114_1445'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('tb', '0041_auto_20190418_1515'),
]

operations = [
migrations.CreateModel(
name='IndexCase',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created', models.DateTimeField(blank=True, null=True)),
('updated', models.DateTimeField(blank=True, null=True)),
('consistency_token', models.CharField(max_length=8)),
('ltbr_number', models.CharField(blank=True, max_length=200, null=True, verbose_name='LTBR Number')),
('hospital_number', models.CharField(blank=True, max_length=200, null=True)),
('sputum_smear', models.CharField(blank=True, choices=[('+ve', '+ve'), ('-ve', '-ve'), ('Unknown', 'Unknown')], max_length=200, null=True)),
('culture', models.CharField(blank=True, choices=[('+ve', '+ve'), ('-ve', '-ve'), ('Unknown', 'Unknown')], max_length=200, null=True)),
('drug_susceptibility', models.CharField(blank=True, choices=[('Fully sensitive', 'Fully sensitive'), ('Not fully sensitive', 'Not fully sensitive'), ('Unknown', 'Unknown')], max_length=200, null=True)),
('index_case_diagnosis_year', models.IntegerField(blank=True, null=True)),
('index_case_diagnosis_month', models.IntegerField(blank=True, null=True)),
('index_case_diagnosis_day', models.IntegerField(blank=True, null=True)),
('relationship', models.CharField(blank=True, choices=[('Household', 'Household'), ('Healthcare (workor)', 'Healthcare (worker)'), ('Healthcare (patient)', 'Healthcare (patient)'), ('Workplace (non healthcare)', 'Workplace (non healthcare)'), ('Education', 'Education'), ('Prison', 'Prison')], max_length=200, null=True, verbose_name='Relationship to index case')),
('relationship_other', models.CharField(blank=True, max_length=200, null=True)),
('details', models.TextField(blank=True)),
('index_case_site_of_tb_ft', models.CharField(blank=True, default='', max_length=255, null=True)),
('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='created_tb_indexcase_subrecords', to=settings.AUTH_USER_MODEL)),
('index_case_site_of_tb_fk', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='tb.TBSite')),
('patient', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='opal.Patient')),
('updated_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='updated_tb_indexcase_subrecords', to=settings.AUTH_USER_MODEL)),
],
options={
'abstract': False,
},
bases=(opal.models.UpdatesFromDictMixin, opal.models.ToDictMixin, models.Model),
),
migrations.AlterModelOptions(
name='tbhistory',
options={'verbose_name': 'Personal history of TB', 'verbose_name_plural': 'Personal histories of TB'},
),
migrations.AddField(
model_name='tbhistory',
name='diagnosis_date_day',
field=models.IntegerField(blank=True, null=True),
),
migrations.AddField(
model_name='tbhistory',
name='diagnosis_date_month',
field=models.IntegerField(blank=True, null=True),
),
migrations.AddField(
model_name='tbhistory',
name='diagnosis_date_year',
field=models.IntegerField(blank=True, null=True),
),
]
36 changes: 36 additions & 0 deletions apps/tb/migrations/0043_auto_20190617_1458.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Generated by Django 2.0.13 on 2019-06-17 14:58

from django.db import migrations


def forwards(apps, schema_editor):
TBHistory = apps.get_model(
'tb', 'TBHistory'
)
IndexCase = apps.get_model(
'tb', 'IndexCase'
)
tb_histories = TBHistory.objects.exclude(previous_tb_contact=False)
for tb_history in tb_histories:
IndexCase.objects.get_or_create(
patient=tb_history.patient,
details=tb_history.previous_tb_contact_details,
created_by_id=tb_history.updated_by_id
)


def backwards(apps, schema_editor):
pass


class Migration(migrations.Migration):

dependencies = [
('tb', '0042_auto_20190617_1458'),
]

operations = [
migrations.RunPython(
forwards, backwards
)
]
28 changes: 28 additions & 0 deletions apps/tb/migrations/0044_auto_20190617_1530.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 2.0.13 on 2019-06-17 15:30

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('tb', '0043_auto_20190617_1458'),
]

operations = [
migrations.RenameField(
model_name='indexcase',
old_name='index_case_diagnosis_day',
new_name='diagnosis_day',
),
migrations.RenameField(
model_name='indexcase',
old_name='index_case_diagnosis_month',
new_name='diagnosis_month',
),
migrations.RenameField(
model_name='indexcase',
old_name='index_case_diagnosis_year',
new_name='diagnosis_year',
),
]
116 changes: 113 additions & 3 deletions apps/tb/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ class Treatment(models.Treatment):
TB = "tb"



class TBHistory(models.PatientSubrecord):
""" Used if the person has clicked that they
have a personal history of TB in the
Expand All @@ -315,6 +314,8 @@ class TBHistory(models.PatientSubrecord):

_is_singleton = True

# TODO After we get sign off from the doctors the below
# fields can be removed
previous_tb_contact = fields.BooleanField(
default=False,
verbose_name="Previous TB contact"
Expand Down Expand Up @@ -343,6 +344,17 @@ class TBHistory(models.PatientSubrecord):
diagnosis_how_long_ago_days = fields.IntegerField(
blank=True, null=True
)
# end todo

diagnosis_date_year = fields.IntegerField(
blank=True, null=True
)
diagnosis_date_month = fields.IntegerField(
blank=True, null=True
)
diagnosis_date_day = fields.IntegerField(
blank=True, null=True
)

how_long_treated_years = fields.IntegerField(
blank=True, null=True
Expand All @@ -368,8 +380,106 @@ class TBHistory(models.PatientSubrecord):
diagnosis_details = fields.TextField(default="")

class Meta:
verbose_name = "TB Exposure"
verbose_name_plural = "TB Exposures"
verbose_name = "Personal history of TB"
verbose_name_plural = "Personal histories of TB"


class IndexCase(models.PatientSubrecord):
_icon = 'fa fa-chain'

POS_NEG = (
("+ve", "+ve"),
("-ve", "-ve"),
("Unknown", "Unknown"),
)

DRUG_susceptibility = (
("Fully sensitive", "Fully sensitive",),
("Not fully sensitive", "Not fully sensitive",),
("Unknown", "Unknown"),
)

RELATIONSHIP = (
("Household", "Household",),
("Healthcare (workor)", "Healthcare (worker)",),
("Healthcare (patient)", "Healthcare (patient)",),
(
"Workplace (non healthcare)",
"Workplace (non healthcare)",
),
(
"Education",
"Education",
),
(
"Prison",
"Prison",
),
)

ltbr_number = fields.CharField(
max_length=200,
blank=True,
null=True,
verbose_name="LTBR Number"
)
hospital_number = fields.CharField(
max_length=200,
blank=True,
null=True,
)
sputum_smear = fields.CharField(
max_length=200,
blank=True,
null=True,
choices=POS_NEG
)
culture = fields.CharField(
max_length=200,
blank=True,
null=True,
choices=POS_NEG
)
drug_susceptibility = fields.CharField(
max_length=200,
blank=True,
null=True,
choices=DRUG_susceptibility
)

diagnosis_year = fields.IntegerField(
blank=True, null=True
)

diagnosis_month = fields.IntegerField(
blank=True, null=True
)

diagnosis_day = fields.IntegerField(
blank=True, null=True
)

index_case_site_of_tb = ForeignKeyOrFreeText(
TBSite, verbose_name="Site of TB"
)

relationship = fields.CharField(
max_length=200,
blank=True,
null=True,
choices=RELATIONSHIP,
verbose_name="Relationship to index case"
)

relationship_other = fields.CharField(
max_length=200,
blank=True,
null=True,
)

details = fields.TextField(
blank=True
)


class Allergies(models.Allergies):
Expand Down
3 changes: 2 additions & 1 deletion apps/tb/templates/detail/tb.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
{% include 'panels/nationality.html' %}
{% record_panel models.Travel %}
{% record_panel models.TBHistory %}
{% record_panel models.IndexCase title="Index Cases" %}
{% include "panels/symptoms.html" %}
{% record_panel models.Allergies %}
{% record_panel models.SocialHistory %}
Expand Down Expand Up @@ -113,4 +114,4 @@
{% include "inline_forms/patient_consultation.html" %}

</div>
</div>
</div>
28 changes: 28 additions & 0 deletions apps/tb/templates/forms/index_case_form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{% load forms %}
{% load elcid_forms %}
{% input field="IndexCase.ltbr_number" %}
{% input field="IndexCase.hospital_number" %}
{% radio_columns field="IndexCase.relationship" %}
{% radio field="IndexCase.sputum_smear" %}
{% radio field="IndexCase.culture" %}
{% radio field="IndexCase.drug_susceptibility" %}
<div class="form-group">
<label class="control-label col-sm-3">
Diagnosis date
</label>
<div class="col-sm-9">
<div class="row">
<div class="col-md-3">
<input placeholder="Day" class="form-control" type="number" ng-model="editing.index_case.diagnosis_day" autocomplete="off">
</div>
<div class="col-md-3">
<input placeholder="Month" class="form-control" type="number" ng-model="editing.index_case.diagnosis_month" autocomplete="off">
</div>
<div class="col-md-3">
<input placeholder="Year" class="form-control" type="number" ng-model="editing.index_case.diagnosis_year" autocomplete="off">
</div>
</div>
</div>
</div>
{% input field="IndexCase.index_case_site_of_tb" %}
{% textarea field="IndexCase.details" %}
Loading

0 comments on commit 98c95b8

Please sign in to comment.