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

Reply feature for Doctor notes #2160

Open
wants to merge 30 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
62baf51
doctor notes reply
UdaySagar-Git May 13, 2024
c0311bf
bug fix
UdaySagar-Git May 13, 2024
73b233e
checks to validated same thread and consultation
UdaySagar-Git May 14, 2024
49b60e1
Merge branch 'develop' into doctor-notes-replies
UdaySagar-Git May 14, 2024
b19e9f5
fix conflict
UdaySagar-Git May 14, 2024
3aaca5f
lint fix
UdaySagar-Git May 14, 2024
3e56057
code review
UdaySagar-Git May 15, 2024
c3a48fa
Merge branch 'develop' into doctor-notes-replies
UdaySagar-Git May 15, 2024
17b4ba3
added ReplyToPatientNoteSerializer
UdaySagar-Git May 15, 2024
2035260
code review
UdaySagar-Git May 16, 2024
07b66b7
adds tests
UdaySagar-Git May 17, 2024
344e5c0
Merge branch 'develop' into doctor-notes-replies
rithviknishad May 18, 2024
1ad7e51
resolve migration conflicts
May 20, 2024
75187a6
code review
UdaySagar-Git May 21, 2024
ac0d5ee
Merge branch 'doctor-notes-replies' of https://github.com/UdaySagar-G…
UdaySagar-Git May 21, 2024
ee953cd
Merge branch 'develop' into doctor-notes-replies
UdaySagar-Git May 21, 2024
106e355
Merge branch 'develop' into doctor-notes-replies
rithviknishad May 23, 2024
08fd2df
rebase migrations
rithviknishad May 23, 2024
255a520
Update care/facility/api/viewsets/patient.py
sainak May 28, 2024
ef6f66a
lint
sainak May 28, 2024
ad49411
Merge remote-tracking branch 'origin/develop' into doctor-notes-replies
sainak May 28, 2024
e72e072
rebase migrations
sainak May 28, 2024
02567b1
Adds validation for "consultation" field
UdaySagar-Git Jul 3, 2024
15bf7aa
Merge branch 'develop' into doctor-notes-replies
UdaySagar-Git Jul 3, 2024
70ac2b0
fix lint
UdaySagar-Git Jul 3, 2024
1453191
Merge branch 'doctor-notes-replies' of https://github.com/UdaySagar-G…
UdaySagar-Git Jul 3, 2024
4fc9416
rebase migration
UdaySagar-Git Jul 3, 2024
386102f
fix lint
rithviknishad Jul 8, 2024
d95d93c
Merge remote-tracking branch 'origin/develop' into doctor-notes-replies
sainak Sep 21, 2024
a9e1a74
rebase migrations
sainak Sep 21, 2024
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
13 changes: 13 additions & 0 deletions care/facility/api/serializers/patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,13 @@ class PatientNotesSerializer(serializers.ModelSerializer):
thread = serializers.ChoiceField(
choices=PatientNoteThreadChoices, required=False, allow_null=False
)
reply_to = serializers.UUIDField(required=False, allow_null=True)

def to_representation(self, instance):
ret = super().to_representation(instance)
if ret.get("reply_to"):
ret["reply_to"] = instance.reply_to.external_id
return ret
UdaySagar-Git marked this conversation as resolved.
Show resolved Hide resolved

def validate_empty_values(self, data):
if not data.get("note", "").strip():
Expand All @@ -539,6 +546,11 @@ def create(self, validated_data):
# If the user is not a doctor then the user type is the same as the user type
validated_data["user_type"] = user_type

if validated_data.get("reply_to"):
validated_data["reply_to"] = PatientNotes.objects.get(
external_id=validated_data["reply_to"]
)

UdaySagar-Git marked this conversation as resolved.
Show resolved Hide resolved
user = self.context["request"].user
note = validated_data.get("note")
with transaction.atomic():
Expand Down Expand Up @@ -587,6 +599,7 @@ class Meta:
"modified_date",
"last_edited_by",
"last_edited_date",
"reply_to",
)
read_only_fields = (
"id",
Expand Down
25 changes: 25 additions & 0 deletions care/facility/migrations/0432_patientnotes_reply_to.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 4.2.10 on 2024-05-13 19:26

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
("facility", "0431_patientnotes_thread"),
]

operations = [
migrations.AddField(
model_name="patientnotes",
name="reply_to",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="replies",
to="facility.patientnotes",
),
),
]
7 changes: 7 additions & 0 deletions care/facility/models/patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,13 @@ class PatientNotes(FacilityBaseModel, ConsultationRelatedPermissionMixin):
db_index=True,
default=PatientNoteThreadChoices.DOCTORS,
)
reply_to = models.ForeignKey(
"self",
on_delete=models.SET_NULL,
null=True,
blank=True,
related_name="replies",
)
note = models.TextField(default="", blank=True)

def get_related_consultation(self):
Expand Down