package mcuorder

import (
	ecore "simrs-vx/internal/domain/base-entities/core"
	ed "simrs-vx/internal/domain/main-entities/doctor"
	ee "simrs-vx/internal/domain/main-entities/encounter"
	emoib "simrs-vx/internal/domain/main-entities/mcu-order-item/base"
	"time"

	ercl "simrs-vx/internal/domain/references/clinical"
	erc "simrs-vx/internal/domain/references/common"
)

type McuOrder 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"`
	Status_Code       erc.DataStatusCode       `json:"status_code" gorm:"not null;size:10"`
	Doctor_Code       *string                  `json:"doctor_code"`
	Doctor            *ed.Doctor               `json:"doctor,omitempty" gorm:"foreignKey:Doctor_Code;references:Code"`
	SpecimenPickTime  *time.Time               `json:"specimenPickTime"`
	ExaminationDate   *time.Time               `json:"examinationDate"`
	Number            uint8                    `json:"number"`
	Temperature       float64                  `json:"temperature"`
	UrgencyLevel_Code ercl.McuUrgencyLevelCode `json:"urgencyLevel_code" gorm:"not null;size:15"`
	Scope_Code        ercl.McuScopeCode        `json:"scope_code" gorm:"index;size:10"`
	Items             []*emoib.McuOrderItem    `json:"items" gorm:"foreignKey:McuOrder_Id;references:Id"`
}

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

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

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