from datetime import datetime

from pydantic import BaseModel


class SignInModel(BaseModel):
    accessToken: str
    refreshToken: str


class ObservationModel(BaseModel):
    uid: str
    createdAt: datetime
    updatedAt: datetime
    realmUid: str
    patientUid: str
    nosologyUid: str
    exclusionReasonUid: str | None
    exclusionComment: str | None
    exclusionDate: datetime | None
    employeeUid: str
    mobileId: str | None


class ObservationsModel(BaseModel):
    items: list[ObservationModel]
    total: int


class MeasurementModel(BaseModel):
    uid: str
    createdAt: datetime
    updatedAt: datetime
    code: str
    title: str
    order: int
    isSelfControl: bool


class MetricModel(BaseModel):
    uid: str
    createdAt: datetime
    updatedAt: datetime
    code: str
    title: str
    order: int
    shortName: str
    measureUid: str | None
    format: str


class ObservationMtMetricModel(BaseModel):
    uid: str
    createdAt: datetime
    updatedAt: datetime
    obsrvMeasurementUid: str
    metricUid: str
    mobileId: str | None
    metric: MetricModel


class ObservationMeasurementModel(BaseModel):
    uid: str
    createdAt: datetime
    updatedAt: datetime
    observationUid: str
    measurementUid: str
    timeFrequency: int
    timePeriod: int
    timePeriodMeasureUid: str
    timeOfDay: list[str] | None
    comment: str | None
    mobileId: str | None
    measurement: MeasurementModel
    obsrvMtMetrics: list[ObservationMtMetricModel]


class ObservationMeasurementsModel(BaseModel):
    items: list[ObservationMeasurementModel]
    total: int


class SeriesRealmModel(BaseModel):
    uid: str


class SeriesModel(BaseModel):
    observationUid: str
    obsrvMeasurementUid: str
    date: str
    realm: SeriesRealmModel
    mobileId: str | None
    uid: str
    createdAt: datetime
    updatedAt: datetime


class SeriesValueModel(BaseModel):
    uid: str
    seriesUid: str
    obsrvMtMetricUid: str
    realm: SeriesRealmModel
    createdAt: datetime
    updatedAt: datetime
    nvalue: int | None
    fvalue: float | None
    svalue: str | None
    filepath: str | None
    mobileId: str | None
    tisId: str | None


class EkgModel(BaseModel):
    success: bool
    # result: ...
