package models

type Schedule struct {
	ID           int64 `gorm:"column:id" json:"id" form:"id"`
	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
	BedId        int64 `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
	PatientId    int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
	ModeId       int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
	Status       int64 `gorm:"column:status" json:"status" form:"status"`
	CreatedTime  int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
	IsExport     int64 `gorm:"column:is_export" json:"is_export" form:"is_export"`

	Patient       string        `gorm:"-" json:"patient" form:"patient"`
	DeviceZone    DeviceZone    `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
	DeviceNumber  DeviceNumber  `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
	TreatmentMode TreatmentMode `json:"mode" gorm:"foreignkey:ModeId"`
	DialysisOrder DialysisOrder `json:"order" gorm:"foreignkey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`

	PatientInfectiousDiseases []InfectiousDiseases `json:"patient_contagions" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
}

func (Schedule) TableName() string {
	return "xt_schedule"
}

type SchedulePatients struct {
	ID           int64 `gorm:"column:id" json:"id" form:"id"`
	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
	BedId        int64 `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
	PatientId    int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
	ModeId       int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
	Status       int64 `gorm:"column:status" json:"status" form:"status"`
	CreatedTime  int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
	IsExport     int64 `gorm:"column:is_export" json:"is_export" form:"is_export"`
	Patient      PatientListForFace        `json:"patient" gorm:"foreignkey:ID;AssociationForeignKey:PatientId;"`
}

func (SchedulePatients) TableName() string {
	return "xt_schedule"
}


type PatientSchedule struct {
	Schedule

	DeviceZone   DeviceZone   `json:"zone" gorm:"foreignkey:PartitionId"`
	DeviceNumber DeviceNumber `json:"bed" gorm:"foreignkey:BedId"`

	Week int64 `gorm:"-" json:"week" form:"week"`

	TreatmentMode TreatmentMode `json:"mode" gorm:"foreignkey:ModeId"`
}

type Partition struct {
	DeviceZone

	Jihaos []DeviceNumber `json:"jihaos" gorm:"foreignkey:ZoneID"`
}

type Search_Schedule struct {
	ID           int64 `gorm:"column:id" json:"id" form:"id"`
	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
	BedId        int64 `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
	PatientId    int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
	ModeId       int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
	Status       int64 `gorm:"column:status" json:"status" form:"status"`
	CreatedTime  int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
	IsExport     int64 `gorm:"column:is_export" json:"is_export" form:"is_export"`

	Patient string `gorm:"-" json:"patient" form:"patient"`
}

func (Search_Schedule) TableName() string {
	return "xt_schedule"
}

type WeekSchedule struct {
	ID           int64 `gorm:"column:id" json:"id" form:"id"`
	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
	BedId        int64 `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
	PatientId    int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
	ModeId       int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
	Status       int64 `gorm:"column:status" json:"status" form:"status"`
	CreatedTime  int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
	IsExport     int64 `gorm:"column:is_export" json:"is_export" form:"is_export"`

	Patient              string           `gorm:"-" json:"patient" form:"patient"`
	DeviceZone           DeviceZone       `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
	DeviceNumber         DeviceNumber     `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
	DialysisPrescription DialysisSolution `json:"prescription" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId"`
	DoctorAdvice         []*DoctorAdvice  `json:"doctor_advice" gorm:"-"`
}

func (WeekSchedule) TableName() string {
	return "xt_schedule"
}
