-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #661 from openhealthcare/660-labs-module-move
moves the lab module accross from a plugin to part of the application…
- Loading branch information
Showing
42 changed files
with
2,144 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
""" | ||
Package definition | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from reversion.admin import VersionAdmin | ||
from reversion import revisions as reversion | ||
from lab.models import LabTest, Observation | ||
from opal.utils import _itersubclasses | ||
from django.contrib import admin | ||
|
||
|
||
class LabTestAdmin(VersionAdmin): | ||
pass | ||
|
||
|
||
def register_lab_tests(): | ||
for lab_test in LabTest.list(): | ||
if not getattr(lab_test, "_no_admin", False): | ||
admin.site.register(lab_test, LabTestAdmin) | ||
|
||
for obs in _itersubclasses(Observation): | ||
if not reversion.is_registered(obs): | ||
admin.site.register(obs, LabTestAdmin) | ||
|
||
|
||
register_lab_tests() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from django.utils.functional import SimpleLazyObject | ||
from lab.models import LabTest | ||
|
||
|
||
class LabTestContextProcessor(object): | ||
def __init__(self): | ||
for i in LabTest.list(): | ||
setattr(self, i.__name__, i) | ||
|
||
|
||
def lab_tests(request): | ||
return { | ||
"lab_tests": SimpleLazyObject(LabTestContextProcessor) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from opal.core import metadata | ||
from lab.models import LabTest | ||
|
||
|
||
class LabTestMetadata(metadata.Metadata): | ||
slug = "lab_tests" | ||
|
||
@classmethod | ||
def to_dict(klass, **kw): | ||
result = dict(lab_tests=dict(all_tests=[])) | ||
for lab_test in LabTest.list(): | ||
for synonym in lab_test.get_synonyms(): | ||
result["lab_tests"][synonym] = dict( | ||
result_form_url=lab_test.get_result_form_url(), | ||
record_url=lab_test.get_record_url(), | ||
display_name=lab_test.get_display_name() | ||
) | ||
if lab_test.HAS_FORM: | ||
result["lab_tests"]["all_tests"].append(synonym) | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
import jsonfield.fields | ||
import opal.models | ||
from django.conf import settings | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('opal', '0025_merge'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='LabTest', | ||
fields=[ | ||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | ||
('created', models.DateTimeField(null=True, blank=True)), | ||
('updated', models.DateTimeField(null=True, blank=True)), | ||
('consistency_token', models.CharField(max_length=8)), | ||
('status', models.CharField(blank=True, max_length=256, null=True, choices=[(b'pending', b'pending'), (b'complete', b'complete')])), | ||
('lab_test_type', models.CharField(max_length=256, null=True, blank=True)), | ||
('date_ordered', models.DateField(null=True, blank=True)), | ||
('date_received', models.DateField(null=True, blank=True)), | ||
('extras', jsonfield.fields.JSONField(null=True, blank=True)), | ||
('created_by', models.ForeignKey(related_name='created_lab_labtest_subrecords', blank=True, to=settings.AUTH_USER_MODEL, null=True)), | ||
('patient', models.ForeignKey(to='opal.Patient')), | ||
('resistant_antibiotics', models.ManyToManyField(related_name='test_resistant', to='opal.Antimicrobial')), | ||
('sensitive_antibiotics', models.ManyToManyField(related_name='test_sensitive', to='opal.Antimicrobial')), | ||
('updated_by', models.ForeignKey(related_name='updated_lab_labtest_subrecords', blank=True, to=settings.AUTH_USER_MODEL, null=True)), | ||
], | ||
options={ | ||
'abstract': False, | ||
}, | ||
bases=(opal.models.UpdatesFromDictMixin, opal.models.ToDictMixin, models.Model), | ||
), | ||
migrations.CreateModel( | ||
name='Observation', | ||
fields=[ | ||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | ||
('created', models.DateTimeField(null=True, blank=True)), | ||
('updated', models.DateTimeField(null=True, blank=True)), | ||
('consistency_token', models.CharField(max_length=8)), | ||
('observation_type', models.CharField(max_length=256)), | ||
('extras', jsonfield.fields.JSONField(null=True, blank=True)), | ||
('result', models.CharField(max_length=256, null=True, blank=True)), | ||
('name', models.CharField(max_length=255)), | ||
('created_by', models.ForeignKey(related_name='created_lab_observation_subrecords', blank=True, to=settings.AUTH_USER_MODEL, null=True)), | ||
('lab_test', models.ForeignKey(related_name='observations', to='lab.LabTest')), | ||
('updated_by', models.ForeignKey(related_name='updated_lab_observation_subrecords', blank=True, to=settings.AUTH_USER_MODEL, null=True)), | ||
], | ||
options={ | ||
'abstract': False, | ||
}, | ||
bases=(opal.models.UpdatesFromDictMixin, opal.models.ToDictMixin, models.Model), | ||
), | ||
migrations.CreateModel( | ||
name='Antimicrobial', | ||
fields=[ | ||
], | ||
options={ | ||
'proxy': True, | ||
}, | ||
bases=('lab.observation',), | ||
), | ||
migrations.CreateModel( | ||
name='DynamicLookupList', | ||
fields=[ | ||
], | ||
options={ | ||
'proxy': True, | ||
}, | ||
bases=('lab.observation',), | ||
), | ||
migrations.CreateModel( | ||
name='DynamicResultChoices', | ||
fields=[ | ||
], | ||
options={ | ||
'proxy': True, | ||
}, | ||
bases=('lab.observation',), | ||
), | ||
migrations.CreateModel( | ||
name='GenericInput', | ||
fields=[ | ||
], | ||
options={ | ||
'proxy': True, | ||
}, | ||
bases=('lab.observation',), | ||
), | ||
migrations.CreateModel( | ||
name='Organism', | ||
fields=[ | ||
], | ||
options={ | ||
'proxy': True, | ||
}, | ||
bases=('lab.observation',), | ||
), | ||
migrations.CreateModel( | ||
name='PendingPosNeg', | ||
fields=[ | ||
], | ||
options={ | ||
'proxy': True, | ||
}, | ||
bases=('lab.observation',), | ||
), | ||
migrations.CreateModel( | ||
name='PosNeg', | ||
fields=[ | ||
], | ||
options={ | ||
'proxy': True, | ||
}, | ||
bases=('lab.observation',), | ||
), | ||
migrations.CreateModel( | ||
name='PosNegEquivicalNotDone', | ||
fields=[ | ||
], | ||
options={ | ||
'proxy': True, | ||
}, | ||
bases=('lab.observation',), | ||
), | ||
migrations.CreateModel( | ||
name='PosNegUnknown', | ||
fields=[ | ||
], | ||
options={ | ||
'proxy': True, | ||
}, | ||
bases=('lab.observation',), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('lab', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameField( | ||
model_name='labtest', | ||
old_name='extras', | ||
new_name='details', | ||
), | ||
migrations.RenameField( | ||
model_name='observation', | ||
old_name='extras', | ||
new_name='details', | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('lab', '0002_auto_20161127_1849'), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameField( | ||
model_name='labtest', | ||
old_name='details', | ||
new_name='extras', | ||
), | ||
migrations.RenameField( | ||
model_name='observation', | ||
old_name='details', | ||
new_name='extras', | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('lab', '0003_auto_20161127_1952'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='observation', | ||
name='result', | ||
field=models.CharField(default=None, max_length=256, null=True, blank=True), | ||
), | ||
] |
Oops, something went wrong.