diff --git a/apps/tb/migrations/0042_auto_20190617_1458.py b/apps/tb/migrations/0042_auto_20190617_1458.py new file mode 100644 index 000000000..abd109065 --- /dev/null +++ b/apps/tb/migrations/0042_auto_20190617_1458.py @@ -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), + ), + ] diff --git a/apps/tb/migrations/0043_auto_20190617_1458.py b/apps/tb/migrations/0043_auto_20190617_1458.py new file mode 100644 index 000000000..faa759c5a --- /dev/null +++ b/apps/tb/migrations/0043_auto_20190617_1458.py @@ -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 + ) + ] diff --git a/apps/tb/migrations/0044_auto_20190617_1530.py b/apps/tb/migrations/0044_auto_20190617_1530.py new file mode 100644 index 000000000..8bd1e53e3 --- /dev/null +++ b/apps/tb/migrations/0044_auto_20190617_1530.py @@ -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', + ), + ] diff --git a/apps/tb/models.py b/apps/tb/models.py index 35cac78d5..dcdc377f3 100644 --- a/apps/tb/models.py +++ b/apps/tb/models.py @@ -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 @@ -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" @@ -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 @@ -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): diff --git a/apps/tb/templates/detail/tb.html b/apps/tb/templates/detail/tb.html index bd8efb3f7..2b1c2864c 100644 --- a/apps/tb/templates/detail/tb.html +++ b/apps/tb/templates/detail/tb.html @@ -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 %} @@ -113,4 +114,4 @@ {% include "inline_forms/patient_consultation.html" %} - \ No newline at end of file + diff --git a/apps/tb/templates/forms/index_case_form.html b/apps/tb/templates/forms/index_case_form.html new file mode 100644 index 000000000..effbcb33a --- /dev/null +++ b/apps/tb/templates/forms/index_case_form.html @@ -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" %} +
Primary diagnosis:
{% if primary_diagnosis_list.exists %}
{% for diagnosis in primary_diagnosis_list %}
- {{ diagnosis.condition }}
- {% if diagnosis.provisional %}?{% endif %}
- {% if diagnosis.details %}
- {{ diagnosis.details }}
- {% endif %}
+ {{ diagnosis.condition }}
+ {% if diagnosis.provisional %}?{% endif %}
+ {% if diagnosis.details %}
+
+ {{ diagnosis.details }}
+ {% endif %}
{% endfor %}
{% else %}
@@ -20,9 +22,10 @@
Secondary diagnos{{ secondary_diagnosis_list|pluralize:"is,es" }}:
{% if secondary_diagnosis_list.exists %}
{% for diagnosis in secondary_diagnosis_list %}
- {{ diagnosis.condition }}
+ - {{ diagnosis.condition }}
{% if diagnosis.provisional %}?{% endif %}
{% if diagnosis.details %}
+
{{ diagnosis.details }}
{% endif %}
@@ -86,23 +89,16 @@
Travel: No recorded travel
{% endif %}
- Previous TB diagnosis:
- {% if tb_history.tb_type %}
- {{ tb_history.tb_type }}
- {% else %}
- None recorded
- {% endif %}
-
- Previous TB contact:
- {% if tb_history.previous_tb_contact_details %}
- {{ tb_history.previous_tb_contact_details }}
- {% else %}
- None recorded
- {% endif %}
-
Place of birth: {{ demographics.birth_place }}
+ {% include "tb/letters/partials/tb_history.html" %} +
++ {% include "tb/letters/partials/index_case.html" %} +
+
Progress:
diff --git a/apps/tb/templates/tb/letters/ltbi_initial_assessment.html b/apps/tb/templates/tb/letters/ltbi_initial_assessment.html
index 40726b306..95c37225d 100644
--- a/apps/tb/templates/tb/letters/ltbi_initial_assessment.html
+++ b/apps/tb/templates/tb/letters/ltbi_initial_assessment.html
@@ -6,6 +6,7 @@
{{ diagnosis.condition }}
{% if diagnosis.provisional %}?{% endif %}
{% if diagnosis.details %}
+
{{ diagnosis.details }}
{% endif %}
@@ -20,9 +21,10 @@
Secondary diagnos{{ secondary_diagnosis_list|pluralize:"is,es" }}:
{% if secondary_diagnosis_list.exists %}
{% for diagnosis in secondary_diagnosis_list %}
- {{ diagnosis.condition }}
+ - {{ diagnosis.condition }}
{% if diagnosis.provisional %}?{% endif %}
{% if diagnosis.details %}
+
{{ diagnosis.details }}
{% endif %}
@@ -45,9 +47,11 @@
Language:
- {{ communication_considerations.language }}
- {% if communication_considerations.needs_an_interpreter %}
- (needs an interpreter)
+ {% if not communication_considerations.language == "English" %}
+ {{ communication_considerations.language }}
+ {% if communication_considerations.needs_an_interpreter %}
+ (needs an interpreter)
+ {% endif %}
{% endif %}
+ {% include "tb/letters/partials/tb_history.html" %} +
++ {% include "tb/letters/partials/index_case.html" %} +
Symptoms:
{% for symptom_complex in symptom_complex_list %}
@@ -191,7 +185,7 @@
{% endif %}
- Discussion:
+ Discussion: