Skip to content

Commit

Permalink
Fix Whatsapp Messages
Browse files Browse the repository at this point in the history
  • Loading branch information
vigneshhari committed Jun 23, 2021
1 parent b70204a commit 3bce6e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions care/facility/api/serializers/patient_consultation.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ def update(self, instance, validated_data):
if validated_data["is_kasp"] and (not instance.is_kasp):
validated_data["kasp_enabled_date"] = localtime(now())

_temp = instance.assigned_to

consultation = super().update(instance, validated_data)

if "assigned_to" in validated_data:
if validated_data["assigned_to"] != instance.assigned_to:
if validated_data["assigned_to"] != _temp and validated_data["assigned_to"]:
NotificationGenerator(
event=Notification.Event.PATIENT_CONSULTATION_ASSIGNMENT,
caused_by=self.context["request"].user,
Expand All @@ -105,8 +109,6 @@ def update(self, instance, validated_data):
notification_mediums=[Notification.Medium.SYSTEM, Notification.Medium.WHATSAPP],
).generate()

consultation = super().update(instance, validated_data)

NotificationGenerator(
event=Notification.Event.PATIENT_CONSULTATION_UPDATED,
caused_by=self.context["request"].user,
Expand Down
2 changes: 1 addition & 1 deletion care/utils/notification_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,9 @@ def generate(self):
elif medium == Notification.Medium.WHATSAPP.value and settings.ENABLE_WHATSAPP:
for user in self.generate_whatsapp_users():
number = user.alt_phone_number
message = self.generate_whatsapp_message()
notification_obj = self.generate_message_for_user(
user, message, Notification.Medium.WHATSAPP.value
)
message = self.generate_whatsapp_message()
sendWhatsappMessage(number, message, notification_obj.external_id)

0 comments on commit 3bce6e6

Please sign in to comment.