package doctorfee

import (
	ecore "simrs-vx/internal/domain/base-entities/core"
	ed "simrs-vx/internal/domain/main-entities/doctor"
	ei "simrs-vx/internal/domain/main-entities/item"
	ero "simrs-vx/internal/domain/references/organization"
)

type CreateDto struct {
	Doctor_Id    *uint                  `json:"doctor_id"`
	FeeType_Code *ero.DoctorFeeTypeCode `json:"feeType_code" validate:"maxLength=11"`
	Price        *float64               `json:"price"`
	Item_Id      *uint                  `json:"item_id"`
}

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

type FilterDto struct {
	Doctor_Id    *uint                  `json:"doctor-id"`
	FeeType_Code *ero.DoctorFeeTypeCode `json:"feeType-code"`
	Price        *float64               `json:"price"`
	Item_Id      *uint                  `json:"item-id"`
}

type ReadDetailDto struct {
	Id        uint16 `json:"id"`
	Doctor_Id *uint  `json:"doctor_id"`
	Item_Id   *uint  `json:"item_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
	Doctor_Id    *uint                  `json:"doctor_id"`
	Doctor       *ed.Doctor             `json:"doctor,omitempty"`
	FeeType_Code *ero.DoctorFeeTypeCode `json:"feeType_code"`
	Price        *float64               `json:"price"`
	Item_Id      *uint                  `json:"item_id"`
	Item         *ei.Item               `json:"item,omitempty"`
}

func (d DoctorFee) ToResponse() ResponseDto {
	resp := ResponseDto{
		Doctor_Id:    d.Doctor_Id,
		Doctor:       d.Doctor,
		FeeType_Code: d.FeeType_Code,
		Price:        d.Price,
		Item_Id:      d.Item_Id,
		Item:         d.Item,
	}
	resp.Main = d.Main
	return resp
}

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