Skip to content

Commit 0709fdb

Browse files
committed
code refactoring using BLACK
1 parent a21335f commit 0709fdb

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

app/models/medicalrecordDbModel.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1-
from mongoengine import EmbeddedDocument, Document, EmbeddedDocumentField, FloatField, StringField, ListField, ReferenceField, DateTimeField
1+
from mongoengine import (
2+
EmbeddedDocument,
3+
Document,
4+
EmbeddedDocumentField,
5+
FloatField,
6+
StringField,
7+
ListField,
8+
ReferenceField,
9+
DateTimeField,
10+
)
211
from mongoengine.errors import ValidationError
312
import datetime
413

514

615
# Custom modules
716
from app.models.patientDbModel import Patient
817

18+
919
class DefaultAttributes:
1020
meta = {"allow_inheritance": True}
1121
creation_date = DateTimeField()
@@ -21,11 +31,13 @@ def update(self, *args, **kwargs):
2131
self.modified_date = datetime.datetime.now()
2232
return super(DefaultAttributes, self).save(*args, **kwargs)
2333

34+
2435
class Medication(EmbeddedDocument):
2536
name = StringField(required=True)
2637
dosage = StringField(required=True)
2738
frequency = StringField(required=True)
28-
39+
40+
2941
# "MedicalRecord" model with validators
3042
class MedicalRecord(Document):
3143
bloodSugarLevel = FloatField(min_value=0, max_value=500)
@@ -40,8 +52,8 @@ class MedicalRecord(Document):
4052
# Custom validation method for the "MedicalRecord" model
4153
def clean(self):
4254
# Check if systolic pressure is greater than diastolic pressure
43-
if(self.systolicPressure and self.diastolicPressure):
55+
if self.systolicPressure and self.diastolicPressure:
4456
if self.systolicPressure < self.diastolicPressure:
4557
raise ValidationError(
4658
"Systolic pressure cannot be less than diastolic pressure"
47-
)
59+
)

app/routes/chatbotCRUD.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ def get_chatbot_user_by_id(id):
112112
# Create response body with success message and user details
113113
body = {
114114
"msg": "Successfully get single user details.",
115-
"data": json.loads(user.to_json()),
115+
# "data": json.loads(user.to_json()),
116+
"data": user.to_dict(),
116117
}
117118
# Return response with 200 OK status code and response body
118119
return response(200, body)

app/routes/medicalRecordCRUD.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ def update_medicalrecord_by_id(id):
6262

6363

6464
# * Define API, which read id and delete medical record
65-
@medicalrecord_module.route("/<id>", methods=["DELETE"], endpoint="delete-medical-record")
65+
@medicalrecord_module.route(
66+
"/<id>", methods=["DELETE"], endpoint="delete-medical-record"
67+
)
6668
@error_handler
6769
def delete_medicalrecord_by_id(id):
6870
try:
@@ -87,7 +89,9 @@ def get_all_medicalrecords():
8789

8890

8991
# * Define API, which takes document id and returns value of that document
90-
@medicalrecord_module.route("/<id>", methods=["GET"], endpoint="get-single-medical-record")
92+
@medicalrecord_module.route(
93+
"/<id>", methods=["GET"], endpoint="get-single-medical-record"
94+
)
9195
@error_handler
9296
def get_medicalrecord_by_id(id):
9397
try:

0 commit comments

Comments
 (0)