Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds the non zero prefixed MRN database constraint #1439

Open
wants to merge 2 commits into
base: v0.108
Choose a base branch
from

Conversation

fredkingham
Copy link
Contributor

Adds a database constraint to make it so that it is impossible to change an MRN so that it has a zero prefix.

Tested with csv imports and bulk updates.

Adds a database constraint to make it so that it is impossible to change
an MRN so that it has a zero prefix.
@davidmiller
Copy link
Member

Does the constraint work if we deploy it to a database that hasn't yet been cleansed of 0prefixes?
(If not, does this need to point at a different branch... )

@fredkingham fredkingham changed the base branch from v0.107.1 to v0.108 March 27, 2023 12:04
@@ -75,6 +75,12 @@ def age(self):

class Meta:
verbose_name_plural = "Demographics"
constraints = [
models.CheckConstraint(
check = ~models.Q(hospital_number__startswith=0),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I landed at either a different spelling or a comment explaining how bitwise not works here...

Negation of a Q expression is done with a tilda ('~') this looks wrong
at first glance so a comment has added with a link to the django
documentation to explain the syntax.
@davidmiller davidmiller self-assigned this Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants