diff --git a/care/facility/migrations/0443_remove_patientconsultation_consent_records_and_more.py b/care/facility/migrations/0443_remove_patientconsultation_consent_records_and_more.py index d6f72ca5ef..b9e012db41 100644 --- a/care/facility/migrations/0443_remove_patientconsultation_consent_records_and_more.py +++ b/care/facility/migrations/0443_remove_patientconsultation_consent_records_and_more.py @@ -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") @@ -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"), diff --git a/care/facility/models/patient_consultation.py b/care/facility/models/patient_consultation.py index 4db0163f30..889f2a4067 100644 --- a/care/facility/models/patient_consultation.py +++ b/care/facility/models/patient_consultation.py @@ -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"