package medicalactionsrcitem

import (
	ecore "simrs-vx/internal/domain/base-entities/core"
	ei "simrs-vx/internal/domain/main-entities/item"
	emas "simrs-vx/internal/domain/main-entities/medical-action-src"
	eps "simrs-vx/internal/domain/main-entities/procedure-src"
)

type CreateDto struct {
	MedicalActionSrc_Code *string `json:"medicalActionSrc_code"`
	ProcedureSrc_Code     *string `json:"procedureSrc_code"`
	Item_Code             *string `json:"item_code"`
}

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

type FilterDto struct {
	MedicalActionSrc_Code *string `json:"medicalActionSrc-code"`
	ProcedureSrc_Code     *string `json:"procedureSrc-code"`
	Item_Code             *string `json:"item-code"`
}

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
	MedicalActionSrc_Code *string                `json:"medicalActionSrc_code"`
	MedicalActionSrc      *emas.MedicalActionSrc `json:"medicalActionSrc,omitempty"`
	ProcedureSrc_Code     *string                `json:"procedureSrc_code"`
	ProcedureSrc          *eps.ProcedureSrc      `json:"procedureSrc,omitempty"`
	Item_Code             *string                `json:"item_code"`
	Item                  *ei.Item               `json:"item,omitempty"`
}

func (d MedicalActionSrcItem) ToResponse() ResponseDto {
	resp := ResponseDto{
		MedicalActionSrc_Code: d.MedicalActionSrc_Code,
		MedicalActionSrc:      d.MedicalActionSrc,
		ProcedureSrc_Code:     d.ProcedureSrc_Code,
		ProcedureSrc:          d.ProcedureSrc,
		Item_Code:             d.Item_Code,
		Item:                  d.Item,
	}
	resp.Main = d.Main
	return resp
}

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