package deviceorder

import (
	erc "simrs-vx/internal/domain/references/common"

	ecore "simrs-vx/internal/domain/base-entities/core"
	edoi "simrs-vx/internal/domain/main-entities/device-order-item/base"
	ed "simrs-vx/internal/domain/main-entities/doctor"
	ee "simrs-vx/internal/domain/main-entities/encounter"
)

type DeviceOrder struct {
	ecore.Main                          // adjust this according to the needs
	Encounter_Id *uint                  `json:"encounter_id"`
	Encounter    *ee.Encounter          `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
	Doctor_Code  *string                `json:"doctor_code"`
	Doctor       *ed.Doctor             `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"`
	Status_Code  erc.DataStatusCode     `json:"status_code"`
	Items        []edoi.DeviceOrderItem `json:"items" gorm:"foreignKey:DeviceOrder_Id;references:Id"`
}

func (d DeviceOrder) IsCompleted() bool {
	return d.Status_Code == erc.DSCDone
}

func (d DeviceOrder) IsSameDoctor(doctor_code *string) bool {
	return d.Doctor_Code == doctor_code
}
