Spaces:
No application file
No application file
| from fastapi import FastAPI | |
| from database import db | |
| from models.patient import Patient # On importe ton modèle | |
| app = FastAPI() | |
| async def bonjour(): | |
| return {"message": "Serveur MedConnect actif !"} | |
| # Nouvelle route pour enregistrer un patient | |
| async def creer_patient(patient: Patient): | |
| # On transforme les données en dictionnaire pour MongoDB | |
| nouveau_patient = patient.model_dump() | |
| # On l'insère dans une collection nommée "liste_patients" | |
| resultat = await db.liste_patients.insert_one(nouveau_patient) | |
| return {"id": str(resultat.inserted_id), "status": "Patient enregistré !"} |