from fastapi import FastAPI from database import db from models.patient import Patient # On importe ton modèle app = FastAPI() @app.get("/") async def bonjour(): return {"message": "Serveur MedConnect actif !"} # Nouvelle route pour enregistrer un patient @app.post("/patients") 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é !"}