34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
from typing import List
|
|
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.crud.base import CRUDBase
|
|
from app.models.medical_record import MedicalRecord
|
|
from app.schemas.medical_record import MedicalRecordCreate, MedicalRecordUpdate
|
|
|
|
|
|
class CRUDMedicalRecord(CRUDBase[MedicalRecord, MedicalRecordCreate, MedicalRecordUpdate]):
|
|
def get_by_patient(
|
|
self, db: Session, *, patient_id: int, skip: int = 0, limit: int = 100
|
|
) -> List[MedicalRecord]:
|
|
return (
|
|
db.query(MedicalRecord)
|
|
.filter(MedicalRecord.patient_id == patient_id)
|
|
.offset(skip)
|
|
.limit(limit)
|
|
.all()
|
|
)
|
|
|
|
def get_by_doctor(
|
|
self, db: Session, *, doctor_id: int, skip: int = 0, limit: int = 100
|
|
) -> List[MedicalRecord]:
|
|
return (
|
|
db.query(MedicalRecord)
|
|
.filter(MedicalRecord.doctor_id == doctor_id)
|
|
.offset(skip)
|
|
.limit(limit)
|
|
.all()
|
|
)
|
|
|
|
|
|
medical_record = CRUDMedicalRecord(MedicalRecord) |