Skip to content

Commit

Permalink
Adds uniqueness and a db index to the MergedMRN.mrn column
Browse files Browse the repository at this point in the history
We query this column a lot via MRN so add a db index.
If there are duplicate rows with the same MRN something wrong has
happened so enforce uniqueness.
  • Loading branch information
fredkingham committed Dec 9, 2022
1 parent 727e4de commit 3d529a1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions elcid/migrations/0067_auto_20221209_1453.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.16 on 2022-12-09 14:53

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('elcid', '0066_auto_20221201_1527'),
]

operations = [
migrations.AlterField(
model_name='mergedmrn',
name='mrn',
field=models.CharField(db_index=True, max_length=256, unique=True),
),
]
2 changes: 1 addition & 1 deletion elcid/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class MergedMRN(models.Model):
Patient 123 would have a patient merge object with MRN 77456
"""
patient = models.ForeignKey(Patient, on_delete=models.CASCADE)
mrn = models.CharField(max_length=256)
mrn = models.CharField(max_length=256, unique=True, db_index=True)
merge_comments = models.TextField(blank=True, null=True, default="")
upstream_merge_datetime = models.DateTimeField(blank=True, null=True)
our_merge_datetime = models.DateTimeField(blank=True, null=True)
Expand Down

0 comments on commit 3d529a1

Please sign in to comment.