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

Daily Rounds External Id in Notification Handler #2641

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 5.1.3 on 2024-12-07 14:15

from django.db import migrations


def update_daily_rounds(apps, schema_editor):
Notification = apps.get_model("facility", "Notification")
DailyRound = apps.get_model("facility", "DailyRound")

for notification in Notification.objects.all():

if daily_round_id := notification.caused_objects.get("daily_round"):
try:
daily_round = DailyRound.objects.get(id=daily_round_id)
notification.caused_objects["daily_round"] = str(daily_round.external_id)
notification.save()
except DailyRound.DoesNotExist:
# Handle the case where the DailyRound does not exist
pass

class Migration(migrations.Migration):

dependencies = [
('facility', '0467_alter_hospitaldoctors_area'),
]

operations = [
migrations.RunPython(update_daily_rounds),
]
2 changes: 1 addition & 1 deletion care/utils/notification_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def generate_cause_objects(self):
self.caused_objects["patient"] = str(
self.caused_object.consultation.patient.external_id
)
self.caused_objects["daily_round"] = str(self.caused_object.id)
self.caused_objects["daily_round"] = str(self.caused_object.external_id)
if self.caused_object.consultation.patient.facility:
self.caused_objects["facility"] = str(
self.caused_object.consultation.facility.external_id
Expand Down
Loading