Skip to content

Commit

Permalink
Fix consent records migration (#2250)
Browse files Browse the repository at this point in the history
  • Loading branch information
sainak committed Jun 6, 2024
1 parent 1e962ec commit 85a9cb1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@ def migrate_consents(apps, schema_editor):
for consent in consultation.consent_records:
new_consent = PatientConsent.objects.create(
consultation=consultation,
type=consent["type"],
patient_code_status=consent.get("patient_code_status", None),
type=consent.get("type", 5),
patient_code_status=(
consent.get("patient_code_status", 0)
if consent.get("type", 5) == 2
else None
),
created_by=consultation.created_by,
archived=consent.get("deleted", False),
is_migrated=True,
created_date=consultation.modified_date,
)

old_id = consent.get("id")
Expand Down Expand Up @@ -116,6 +121,7 @@ def reverse_migrate(apps, schema_editor):
models.IntegerField(
blank=True,
choices=[
(0, "Not Specified"),
(1, "Do Not Hospitalize"),
(2, "Do Not Resuscitate"),
(3, "Comfort Care Only"),
Expand Down
1 change: 1 addition & 0 deletions care/facility/models/patient_consultation.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ class ConsentType(models.IntegerChoices):


class PatientCodeStatusType(models.IntegerChoices):
NOT_SPECIFIED = 0, "Not Specified"
DNH = 1, "Do Not Hospitalize"
DNR = 2, "Do Not Resuscitate"
COMFORT_CARE = 3, "Comfort Care Only"
Expand Down

0 comments on commit 85a9cb1

Please sign in to comment.