Skip to content

Commit

Permalink
fix: updated migration steps
Browse files Browse the repository at this point in the history
  • Loading branch information
aeswibon committed Aug 9, 2023
1 parent 4286de9 commit 4c85bbe
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions care/facility/migrations/0346_add_recommend_discharge_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@

def update_recommend_discharge(apps, schema_editor):
patient_model = apps.get_model("facility", "PatientRegistration")
patient_objs = []
for patient in patient_model.objects.all():
if patient.last_consultation.last_daily_round.recommend_discharge:
if (
patient.last_consultation
and patient.last_consultation.last_daily_round
and patient.last_consultation.last_daily_round.recommend_discharge
):
patient.action = 90
patient.save()
patient_objs.append(patient)
patient_model.objects.bulk_update(patient_objs, ["action"])


class Migration(migrations.Migration):
Expand Down

0 comments on commit 4c85bbe

Please sign in to comment.