package cpmcuorder

import (
	ecmoi "simrs-vx/internal/domain/main-entities/cp-mcu-order-item/base"
	eamob "simrs-vx/internal/domain/main-entities/cp-mcu-order/base"
	ed "simrs-vx/internal/domain/main-entities/doctor"
	ee "simrs-vx/internal/domain/main-entities/encounter"
	erc "simrs-vx/internal/domain/references/common"
)

type CpMcuOrder struct {
	eamob.CpMcuOrder
	Encounter *ee.Encounter           `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
	Doctor    *ed.Doctor              `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"`
	Items     []*ecmoi.CpMcuOrderItem `json:"items" gorm:"foreignKey:CpMcuOrder_Id;references:Id"`
}

func (d CpMcuOrder) IsNotNew() bool {
	return d.Status_Code != erc.DSCNew
}

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

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