package antibioticinuse

import (
	ecore "simrs-vx/internal/domain/base-entities/core"
	eas "simrs-vx/internal/domain/main-entities/antibiotic-src"
	emo "simrs-vx/internal/domain/main-entities/mcu-order"
	erc "simrs-vx/internal/domain/references/common"
	"time"
)

type CreateDto struct {
	McuOrder_Id      *uint `json:"mcuOrder_id"`
	AntibioticSrc_Id *uint `json:"antibioticSrc_id"`
}

type ReadListDto struct {
	FilterDto
	Includes   string `json:"includes"`
	Pagination ecore.Pagination
}

type FilterDto struct {
	McuOrder_Id      *uint              `json:"mcu-order-id"`
	AntibioticSrc_Id *uint              `json:"mcu-src-id"`
	Result           *string            `json:"result"`
	Status_Code      erc.DataStatusCode `json:"status-code"`
	Includes         string             `json:"includes"`
}
type ReadDetailDto struct {
	Id       uint   `json:"id"`
	Includes string `json:"includes"`
}

type UpdateDto struct {
	Id uint `json:"id"`
	CreateDto
}

type DeleteDto struct {
	Id uint `json:"id"`
}

type SetScheduleDto struct {
	Id              uint       `json:"id"`
	ExaminationDate *time.Time `json:"examinationDate"`
}

type MetaDto struct {
	PageNumber int `json:"page_number"`
	PageSize   int `json:"page_size"`
	Count      int `json:"count"`
}

type ResponseDto struct {
	ecore.Main
	McuOrder_Id      *uint          `json:"mcuOrder_id"`
	McuOrder         *emo.McuOrder  `json:"mcuOrder,omitempty"`
	AntibioticSrc_Id *uint          `json:"antibioticSrc_id"`
	Antibiotic       *eas.CreateDto `json:"mcuSrc,omitempty"`
}

func (d AntibioticInUse) ToResponse() ResponseDto {
	resp := ResponseDto{
		McuOrder_Id:      d.McuOrder_Id,
		McuOrder:         d.McuOrder,
		AntibioticSrc_Id: d.AntibioticSrc_Id,
	}
	resp.Main = d.Main
	return resp
}

func ToResponseList(data []AntibioticInUse) []ResponseDto {
	resp := make([]ResponseDto, len(data))
	for i, u := range data {
		resp[i] = u.ToResponse()
	}
	return resp
}
