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

Updated PatientNofifications Model and introduced new field of rtype #34

Merged
merged 3 commits into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 7 additions & 1 deletion server/healthOfficial/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from bson import ObjectId
from flask import request, jsonify, Blueprint
from server.utils import token_required
from server.models import Patient, HealthOfficial, Record, ConsultationRequest
from server.models import Patient, HealthOfficial, Record, PatientNotifications
from flask_cors import CORS

healthOfficial = Blueprint("healthOfficial", __name__)
Expand Down Expand Up @@ -169,9 +169,15 @@ def deleteRequest(_id):
crequests.append(crequest)

healthOfficial.consultationRequests = crequests
pnotif = PatientNotifications(healthOfficial=ObjectId(_id), rtype="consult")

if approved == "True":
healthOfficial.patients.append(ObjectId(p_id))
pnotif.approved = True

patient = Patient.objects(_id=ObjectId(p_id)).first()
patient.notifs.append(pnotif)

patient.save()
healthOfficial.save()
return jsonify({"message": "Request executed successfully."})
1 change: 1 addition & 0 deletions server/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class PatientNotifications(EmbeddedDocument):
approved = BooleanField(default=False)
healthOfficial = ObjectIdField()
record = ObjectIdField()
rtype = StringField()

meta = {"collection": "patientNotifications"}

Expand Down
3 changes: 2 additions & 1 deletion server/notifications/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def getNotifications(_id):

try:
notif = PatientNotifications(
healthOfficial=ObjectId(_id), record=ObjectId(rid)
healthOfficial=ObjectId(_id), record=ObjectId(rid), rtype="consent"
)
patient = Patient.objects(_id=ObjectId(pid)).first()
patient.notifs.append(notif)
Expand All @@ -37,6 +37,7 @@ def getNotifications(_id):
notif_obj = dict()
notif_obj["id"] = str(notif._id)
notif_obj["approved"] = notif.approved
notif_obj["rtype"] = notif.rtype

rid = notif.record
record_obj = dict()
Expand Down