from datetime import datetime
from typing import Optional

from fastapi import APIRouter, Depends
from sqlmodel import Field, SQLModel

from ...db import get_session

from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession


router = APIRouter()


class HistorySummaryTreatmsummaryConference(SQLModel, table=True):
    id: Optional[int] = Field(default=None, primary_key=True)
    history_id_order: int
    history_id_conference: int
    summary_treatmsummary_conference_id: int
    state: str
    created_at: datetime
    updated_at: datetime
    created_by: int
    updated_by: Optional[int] = None


class SummaryTreatmsummaryConference(SQLModel, table=True):
    id: Optional[int] = Field(default=None, primary_key=True)
    problem: str
    question: str
    summary_plan: str
    surgeon_summary: str
    pre_operation_abg: bool
    post_operation_abg: bool
    pre_operation_redo_abg: bool
    pre_operation_jaw_surgery: bool
    pre_operation_computing_design: bool
    pre_operation_3d_print: bool
    created_at: datetime
    updated_at: datetime
    created_by: int
    updated_by: Optional[int] = None


class SummaryTreatmsummaryConferenceDoctorMap(SQLModel, table=True):
    id: Optional[int] = Field(default=None, primary_key=True)
    summary_treatmsummary_conference_id: int
    doctor_id: int
    created_at: datetime
    updated_at: datetime
    created_by: int
    updated_by: Optional[int] = None


@router.post("/history_summary_conference", response_model=HistorySummaryTreatmsummaryConference)
async def create_history_summary_conference(history_summary_conference: HistorySummaryTreatmsummaryConference, session: AsyncSession = Depends(get_session)):
    session.add(history_summary_conference)
    await session.commit()
    await session.refresh(history_summary_conference)
    return history_summary_conference


@router.post("/summary_conference", response_model=SummaryTreatmsummaryConference)
async def create_summary_conference(summary_conference: SummaryTreatmsummaryConference, session: AsyncSession = Depends(get_session)):
    session.add(summary_conference)
    await session.commit()
    await session.refresh(summary_conference)
    return summary_conference


@router.get("/history_summary_conference/{id}", response_model=HistorySummaryTreatmsummaryConference)
async def get_history_summary_conference(id: int, session: AsyncSession = Depends(get_session)):
    history_summary_conferences = await session.execute(select(HistorySummaryTreatmsummaryConference).where(HistorySummaryTreatmsummaryConference.id == id))
    history_summary_conference = history_summary_conferences.scalars().first()
    return history_summary_conference



@router.put("/history_summary_conference/{id}", response_model=HistorySummaryTreatmsummaryConference)
async def update_history_summary_conference(id: int, session: AsyncSession = Depends(get_session)):
    return None


@router.delete("/history_summary_conference/{id}")
async def delete_history_summary_conference(session: AsyncSession = Depends(get_session)):
    return None


@router.delete("/history_summary_conference/{id}")
async def delete_summary_conference(session: AsyncSession = Depends(get_session)):
    return None
fastapi.APIRouter sqlalchemy.select fastapi.Depends sqlmodel.Field
[((256, 267), 'fastapi.APIRouter', 'APIRouter', ([], {}), '()\n', (265, 267), False, 'from fastapi import APIRouter, Depends\n'), ((361, 398), 'sqlmodel.Field', 'Field', ([], {'default': 'None', 'primary_key': '(True)'}), '(default=None, primary_key=True)\n', (366, 398), False, 'from sqlmodel import Field, SQLModel\n'), ((709, 746), 'sqlmodel.Field', 'Field', ([], {'default': 'None', 'primary_key': '(True)'}), '(default=None, primary_key=True)\n', (714, 746), False, 'from sqlmodel import Field, SQLModel\n'), ((1231, 1268), 'sqlmodel.Field', 'Field', ([], {'default': 'None', 'primary_key': '(True)'}), '(default=None, primary_key=True)\n', (1236, 1268), False, 'from sqlmodel import Field, SQLModel\n'), ((1675, 1695), 'fastapi.Depends', 'Depends', (['get_session'], {}), '(get_session)\n', (1682, 1695), False, 'from fastapi import APIRouter, Depends\n'), ((2058, 2078), 'fastapi.Depends', 'Depends', (['get_session'], {}), '(get_session)\n', (2065, 2078), False, 'from fastapi import APIRouter, Depends\n'), ((2398, 2418), 'fastapi.Depends', 'Depends', (['get_session'], {}), '(get_session)\n', (2405, 2418), False, 'from fastapi import APIRouter, Depends\n'), ((2877, 2897), 'fastapi.Depends', 'Depends', (['get_session'], {}), '(get_session)\n', (2884, 2897), False, 'from fastapi import APIRouter, Depends\n'), ((3037, 3057), 'fastapi.Depends', 'Depends', (['get_session'], {}), '(get_session)\n', (3044, 3057), False, 'from fastapi import APIRouter, Depends\n'), ((3189, 3209), 'fastapi.Depends', 'Depends', (['get_session'], {}), '(get_session)\n', (3196, 3209), False, 'from fastapi import APIRouter, Depends\n'), ((2477, 2522), 'sqlalchemy.select', 'select', (['HistorySummaryTreatmsummaryConference'], {}), '(HistorySummaryTreatmsummaryConference)\n', (2483, 2522), False, 'from sqlalchemy import select\n')]