package nurse

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

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"`
	Unit_Code   *string `json:"unit_code"`
	Infra_Code  *string `json:"infra_code"`
}

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"`
	Unit_Code   *string `json:"unit-code"`
	Infra_Code  *string `json:"infra-code"`
}
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"`
	Unit_Code   *string      `json:"unit_code"`
	Unit        *eu.Unit     `json:"unit,omitempty"`
	Infra_Code  *string      `json:"infra_code"`
	Infra       *ei.Infra    `json:"infra,omitempty"`
}

func (d Nurse) ToResponse() ResponseDto {
	resp := ResponseDto{
		Code:        d.Code,
		Employee_Id: d.Employee_Id,
		Employee:    d.Employee,
		IHS_Number:  d.IHS_Number,
		Unit_Code:   d.Unit_Code,
		Unit:        d.Unit,
		Infra_Code:  d.Infra_Code,
		Infra:       d.Infra,
	}
	resp.Main = d.Main
	return resp
}

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