15 lines
459 B
Python
15 lines
459 B
Python
from typing import Optional
|
|
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.crud.base import CRUDBase
|
|
from app.models.patient import Patient
|
|
from app.schemas.patient import PatientCreate, PatientUpdate
|
|
|
|
|
|
class CRUDPatient(CRUDBase[Patient, PatientCreate, PatientUpdate]):
|
|
def get_by_user_id(self, db: Session, *, user_id: int) -> Optional[Patient]:
|
|
return db.query(Patient).filter(Patient.user_id == user_id).first()
|
|
|
|
|
|
patient = CRUDPatient(Patient) |