Skip to content

Commit

Permalink
Merge pull request #319 from jbernal0019/master
Browse files Browse the repository at this point in the history
Add 'StudyDate' and 'ProtocolName' fields to 'PACSFile' model
  • Loading branch information
jbernal0019 authored Apr 9, 2021
2 parents d2ed29e + 7f541fe commit 5d3c2e2
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 8 deletions.
36 changes: 36 additions & 0 deletions chris_backend/pacsfiles/migrations/0004_auto_20210409_1532.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Generated by Django 2.2.12 on 2021-04-09 19:32

import datetime
from django.db import migrations, models
from django.utils.timezone import utc


class Migration(migrations.Migration):

dependencies = [
('pacsfiles', '0003_pacsfile_modality'),
]

operations = [
migrations.AddField(
model_name='pacsfile',
name='ProtocolName',
field=models.CharField(blank=True, max_length=64),
),
migrations.AddField(
model_name='pacsfile',
name='StudyDate',
field=models.DateField(db_index=True, default=datetime.datetime(2021, 4, 9, 19, 32, 14, 90971, tzinfo=utc)),
preserve_default=False,
),
migrations.AlterField(
model_name='pacsfile',
name='SeriesInstanceUID',
field=models.CharField(max_length=150),
),
migrations.AlterField(
model_name='pacsfile',
name='StudyInstanceUID',
field=models.CharField(max_length=150),
),
]
14 changes: 9 additions & 5 deletions chris_backend/pacsfiles/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ class PACSFile(models.Model):
PatientAge = models.IntegerField(blank=True, null=True)
PatientSex = models.CharField(max_length=1, choices=[('M', 'Male'), ('F', 'Female')],
blank=True)
StudyDate = models.DateField(db_index=True)
Modality = models.CharField(max_length=15, blank=True)
StudyInstanceUID = models.CharField(max_length=150, db_index=True)
ProtocolName = models.CharField(max_length=64, blank=True)
StudyInstanceUID = models.CharField(max_length=150)
StudyDescription = models.CharField(max_length=500, blank=True)
SeriesInstanceUID = models.CharField(max_length=150, db_index=True)
SeriesInstanceUID = models.CharField(max_length=150)
SeriesDescription = models.CharField(max_length=500, blank=True)
pacs = models.ForeignKey(PACS, on_delete=models.CASCADE)

Expand All @@ -43,6 +45,8 @@ class PACSFileFilter(FilterSet):
fname_exact = django_filters.CharFilter(field_name='fname', lookup_expr='exact')
PatientName = django_filters.CharFilter(field_name='PatientName',
lookup_expr='icontains')
ProtocolName = django_filters.CharFilter(field_name='ProtocolName',
lookup_expr='icontains')
StudyDescription = django_filters.CharFilter(field_name='StudyDescription',
lookup_expr='icontains')
SeriesDescription = django_filters.CharFilter(field_name='SeriesDescription',
Expand All @@ -58,6 +62,6 @@ class Meta:
model = PACSFile
fields = ['id', 'min_creation_date', 'max_creation_date', 'fname', 'fname_exact',
'PatientID', 'PatientName', 'PatientSex', 'PatientAge',
'min_PatientAge', 'max_PatientAge', 'PatientBirthDate',
'StudyInstanceUID', 'StudyDescription', 'SeriesInstanceUID',
'SeriesDescription', 'pacs_identifier']
'min_PatientAge', 'max_PatientAge', 'PatientBirthDate', 'StudyDate',
'ProtocolName', 'StudyInstanceUID', 'StudyDescription',
'SeriesInstanceUID', 'SeriesDescription', 'pacs_identifier']
5 changes: 3 additions & 2 deletions chris_backend/pacsfiles/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ class Meta:
model = PACSFile
fields = ('url', 'id', 'creation_date', 'fname', 'fsize', 'path', 'PatientID',
'PatientName', 'PatientBirthDate', 'PatientAge', 'PatientSex',
'Modality', 'StudyInstanceUID', 'StudyDescription', 'SeriesInstanceUID',
'SeriesDescription', 'pacs_identifier', 'pacs_name', 'file_resource')
'StudyDate', 'Modality', 'ProtocolName', 'StudyInstanceUID',
'StudyDescription', 'SeriesInstanceUID', 'SeriesDescription',
'pacs_identifier', 'pacs_name', 'file_resource')

def get_file_link(self, obj):
"""
Expand Down
3 changes: 3 additions & 0 deletions chris_backend/pacsfiles/tests/test_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def test_validate_updates_validated_data(self):
"""
path = 'SERVICES/PACS/MyPACS/123456-crazy/brain_crazy_study/SAG_T1_MPRAGE/file1.dcm'
data = {'PatientID': '123456', 'PatientName': 'crazy',
'StudyDate': '2020-07-15',
'StudyInstanceUID': '1.1.3432.54.6545674765.765434',
'StudyDescription': 'brain_crazy_study',
'SeriesDescription': 'SAG T1 MPRAGE',
Expand All @@ -105,6 +106,7 @@ def test_validate_validates_path_has_not_already_been_registered(self):
"""
path = 'SERVICES/PACS/MyPACS/123456-crazy/brain_crazy_study/SAG_T1_MPRAGE/file1.dcm'
data = {'PatientID': '123456', 'PatientName': 'crazy',
'StudyDate': '2020-07-15',
'StudyInstanceUID': '1.1.3432.54.6545674765.765434',
'StudyDescription': 'brain_crazy_study',
'SeriesDescription': 'SAG T1 MPRAGE',
Expand All @@ -113,6 +115,7 @@ def test_validate_validates_path_has_not_already_been_registered(self):
pacs = PACS(identifier='MyPACS')
pacs.save()
pacs_file = PACSFile(PatientID='123456',
StudyDate='2020-07-15',
StudyInstanceUID='1.1.3432.54.6545674765.765434',
SeriesInstanceUID='2.4.3432.54.845674765.763345',
pacs=pacs)
Expand Down
3 changes: 3 additions & 0 deletions chris_backend/pacsfiles/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def setUp(self):
pacs.save()
pacs_file = PACSFile(PatientID='123456',
PatientName='crazy',
StudyDate='2020-07-15',
StudyInstanceUID='1.1.3432.54.6545674765.765434',
StudyDescription='brain_crazy_study',
SeriesInstanceUID='2.4.3432.54.845674765.763345',
Expand Down Expand Up @@ -71,6 +72,7 @@ def setUp(self):
{"template": {"data": [{"name": "path", "value": path},
{"name": "PatientID", "value": "123456"},
{"name": "PatientName", "value": "crazy"},
{"name": "StudyDate", "value": '2020-07-15'},
{"name": "StudyInstanceUID",
"value": '1.1.3432.54.6545674765.765434'},
{"name": "StudyDescription", "value": "brain_crazy_study"},
Expand Down Expand Up @@ -115,6 +117,7 @@ def test_pacsfile_create_failure_already_exists(self):
path = 'SERVICES/PACS/MyPACS/123456-crazy/brain_crazy_study/SAG_T1_MPRAGE/file2.dcm'
pacs = PACS.objects.get(identifier='MyPACS')
pacs_file = PACSFile(PatientID='123456',
StudyDate='2020-07-15',
StudyInstanceUID='1.1.3432.54.6545674765.765434',
SeriesInstanceUID='2.4.3432.54.845674765.763345',
pacs=pacs)
Expand Down
3 changes: 2 additions & 1 deletion chris_backend/pacsfiles/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def list(self, request, *args, **kwargs):
# append write template
template_data = {'path': "", 'PatientID': "", 'PatientName': "",
'PatientBirthDate': "", 'PatientAge': "", 'PatientSex': "",
'Modality': "", 'StudyInstanceUID': "", 'StudyDescription': "",
'StudyDate': "", 'Modality': "", 'ProtocolName': "",
'StudyInstanceUID': "", 'StudyDescription': "",
'SeriesInstanceUID': "", 'SeriesDescription': "",
'pacs_name': ""}
return services.append_collection_template(response, template_data)
Expand Down

0 comments on commit 5d3c2e2

Please sign in to comment.