Spaces:
Sleeping
Sleeping
Update api/routes.py
Browse files- api/routes.py +2 -2
api/routes.py
CHANGED
|
@@ -53,12 +53,12 @@ async def get_me(current_user: dict = Depends(get_current_user)):
|
|
| 53 |
async def add_patient(data: PatientCreate, current_user: dict = Depends(get_current_user)):
|
| 54 |
patient_doc = {
|
| 55 |
"full_name": data.full_name,
|
| 56 |
-
"date_of_birth": data.date_of_birth,
|
| 57 |
"gender": data.gender,
|
| 58 |
"notes": data.notes,
|
| 59 |
"contact": data.contact.dict() if data.contact else {},
|
| 60 |
"created_by": current_user["email"],
|
| 61 |
-
"created_at":
|
| 62 |
}
|
| 63 |
result = await patients_collection.insert_one(patient_doc)
|
| 64 |
return { "id": str(result.inserted_id), "message": "Patient created successfully" }
|
|
|
|
| 53 |
async def add_patient(data: PatientCreate, current_user: dict = Depends(get_current_user)):
|
| 54 |
patient_doc = {
|
| 55 |
"full_name": data.full_name,
|
| 56 |
+
"date_of_birth": datetime.combine(data.date_of_birth, datetime.min.time()), # ✅ fix date type
|
| 57 |
"gender": data.gender,
|
| 58 |
"notes": data.notes,
|
| 59 |
"contact": data.contact.dict() if data.contact else {},
|
| 60 |
"created_by": current_user["email"],
|
| 61 |
+
"created_at": datetime.utcnow() # ✅ use datetime instead of date
|
| 62 |
}
|
| 63 |
result = await patients_collection.insert_one(patient_doc)
|
| 64 |
return { "id": str(result.inserted_id), "message": "Patient created successfully" }
|