package pharmacist

import (
	ecore "simrs-vx/internal/domain/base-entities/core"
	ee "simrs-vx/internal/domain/main-entities/employee"
)

type CreateDto struct {
	Code        *string `json:"code" validate:"maxLength=20"`
	Employee_Id *uint   `json:"employee_id"`
	IHS_Number  *string `json:"ihs_number" validate:"maxLength=20"`
}

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

type FilterDto struct {
	Code        *string `json:"code"`
	Employee_Id *uint   `json:"employee-id"`
	IHS_Number  *string `json:"ihs-number"`
}

type ReadDetailDto struct {
	Id          *uint16 `json:"id"`
	Code        *string `json:"code"`
	Employee_Id *uint   `json:"employee_id"`
	IHS_Number  *string `json:"ihs_number"`
}

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

type DeleteDto struct {
	Id   *uint   `json:"id"`
	Code *string `json:"code"`
}

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

type ResponseDto struct {
	ecore.Main
	Code        *string      `json:"code"`
	Employee_Id *uint        `json:"employee_id"`
	Employee    *ee.Employee `json:"employee,omitempty"`
	IHS_Number  *string      `json:"ihs_number"`
}

func (d Pharmacist) ToResponse() ResponseDto {
	resp := ResponseDto{
		Code:        d.Code,
		Employee_Id: d.Employee_Id,
		Employee:    d.Employee,
		IHS_Number:  d.IHS_Number,
	}
	resp.Main = d.Main
	return resp
}

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