Skip to content

Commit 71a0998

Browse files
authored
Merge pull request #33 from 007vedant/dev
Update consultation request routes & models to included patient name in JSON response object
2 parents 3d633fc + 877fdd0 commit 71a0998

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

server/models.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
BooleanField,
1111
ObjectIdField,
1212
EmbeddedDocumentField,
13+
EmbeddedDocumentListField,
1314
)
14-
from mongoengine.fields import EmbeddedDocumentListField
1515

1616

1717
class PatientNotifications(EmbeddedDocument):
@@ -47,6 +47,7 @@ class ConsultationData(EmbeddedDocument):
4747
class ConsultationRequest(EmbeddedDocument):
4848
_id = ObjectIdField(default=ObjectId)
4949
patient = ObjectIdField()
50+
patientName = StringField()
5051
healthOfficial = ObjectIdField()
5152
consultationData = EmbeddedDocumentField(ConsultationData)
5253
approved = BooleanField(default=False)
@@ -75,4 +76,4 @@ class HealthOfficial(Document):
7576
consultationRequests = EmbeddedDocumentListField(ConsultationRequest)
7677
records = StringField()
7778

78-
meta = {"collection": "healthOfficial"}
79+
meta = {"collection": "healthOfficial"}

server/records/routes.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ def addConsultationRequest(_id):
211211
)
212212
consultationRequest = ConsultationRequest(
213213
patient=ObjectId(_id),
214+
patientName=Patient.objects.get(_id=ObjectId(_id)).name,
214215
healthOfficial=ObjectId(hid),
215216
consultationData=consultationData,
216217
)
@@ -225,4 +226,4 @@ def addConsultationRequest(_id):
225226
return jsonify({"message": "Unexpected error occurred."}), 500
226227

227228
else:
228-
return jsonify({"message": "Bad Request"}), 400
229+
return jsonify({"message": "Bad Request"}), 400

0 commit comments

Comments
 (0)