package medicinemixitem

import (
	ecore "simrs-vx/internal/domain/base-entities/core"
	em "simrs-vx/internal/domain/main-entities/medicine"
)

type CreateDto struct {
	MedicineMix_Id *uint   `json:"medicineMix_id"`
	Medicine_Code  *string `json:"medicine_code"`
	Dose           *uint8  `json:"dose"`
	Note           *string `json:"note" gom:"size:1024"`
}

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

type FilterDto struct {
	MedicineMix_Id *uint   `json:"medicineMix-id"`
	Medicine_Code  *string `json:"medicine-code"`
	Dose           *uint8  `json:"dose"`
	Note           *string `json:"note" gom:"size:1024"`
}

type ReadDetailDto struct {
	Id uint16 `json:"id"`
}

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

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

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

type ResponseDto struct {
	ecore.Main
	MedicineMix_Id *uint        `json:"medicineMix_id"`
	Medicine_Code  *string      `json:"medicine_code"`
	Medicine       *em.Medicine `json:"medicine,omitempty"`
	Dose           *uint8       `json:"dose"`
	Note           *string      `json:"note" gom:"size:1024"`
}

func (d MedicineMixItem) ToResponse() ResponseDto {
	resp := ResponseDto{
		MedicineMix_Id: d.MedicineMix_Id,
		Medicine_Code:  d.Medicine_Code,
		Medicine:       d.Medicine,
		Dose:           d.Dose,
		Note:           d.Note,
	}
	resp.Main = d.Main
	return resp
}

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