Skip to content

Commit 1ec67de

Browse files
authored
Merge pull request #34 from 007vedant/dev
Updated PatientNofifications Model and introduced new field of rtype
2 parents 71a0998 + 59e24bf commit 1ec67de

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

server/healthOfficial/routes.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from bson import ObjectId
44
from flask import request, jsonify, Blueprint
55
from server.utils import token_required
6-
from server.models import Patient, HealthOfficial, Record, ConsultationRequest
6+
from server.models import Patient, HealthOfficial, Record, PatientNotifications
77
from flask_cors import CORS
88

99
healthOfficial = Blueprint("healthOfficial", __name__)
@@ -169,9 +169,15 @@ def deleteRequest(_id):
169169
crequests.append(crequest)
170170

171171
healthOfficial.consultationRequests = crequests
172+
pnotif = PatientNotifications(healthOfficial=ObjectId(_id), rtype="consult")
172173

173174
if approved == "True":
174175
healthOfficial.patients.append(ObjectId(p_id))
176+
pnotif.approved = True
175177

178+
patient = Patient.objects(_id=ObjectId(p_id)).first()
179+
patient.notifs.append(pnotif)
180+
181+
patient.save()
176182
healthOfficial.save()
177183
return jsonify({"message": "Request executed successfully."})

server/models.py

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class PatientNotifications(EmbeddedDocument):
1919
approved = BooleanField(default=False)
2020
healthOfficial = ObjectIdField()
2121
record = ObjectIdField()
22+
rtype = StringField()
2223

2324
meta = {"collection": "patientNotifications"}
2425

server/notifications/routes.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def getNotifications(_id):
1717

1818
try:
1919
notif = PatientNotifications(
20-
healthOfficial=ObjectId(_id), record=ObjectId(rid)
20+
healthOfficial=ObjectId(_id), record=ObjectId(rid), rtype="consent"
2121
)
2222
patient = Patient.objects(_id=ObjectId(pid)).first()
2323
patient.notifs.append(notif)
@@ -37,6 +37,7 @@ def getNotifications(_id):
3737
notif_obj = dict()
3838
notif_obj["id"] = str(notif._id)
3939
notif_obj["approved"] = notif.approved
40+
notif_obj["rtype"] = notif.rtype
4041

4142
rid = notif.record
4243
record_obj = dict()

0 commit comments

Comments
 (0)