package specialistintern

import (
	ecore "simrs-vx/internal/domain/base-entities/core"
	ep "simrs-vx/internal/domain/main-entities/person"
	es "simrs-vx/internal/domain/main-entities/specialist"
	ess "simrs-vx/internal/domain/main-entities/subspecialist"
	eu "simrs-vx/internal/domain/main-entities/user"
)

type CreateDto struct {
	Person_Id          *uint   `json:"person_id"`
	Specialist_Code    *string `json:"specialist_code"`
	Subspecialist_Code *string `json:"subspecialist_code"`
	User_Id            *uint   `json:"user_id"`
}

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

type FilterDto struct {
	Person_Id          *uint   `json:"person-id"`
	Specialist_Code    *string `json:"specialist-code"`
	Subspecialist_Code *string `json:"subspecialist-code"`
	User_Id            *uint   `json:"user-id"`
}

type ReadDetailDto struct {
	Id      uint16 `json:"id"`
	User_Id *uint  `json:"user_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
	Person_Id          *uint              `json:"person_id"`
	Person             *ep.Person         `json:"person,omitempty"`
	Specialist_Code    *string            `json:"specialist_code"`
	Specialist         *es.Specialist     `json:"specialist,omitempty"`
	Subspecialist_Code *string            `json:"subspecialist_code"`
	Subspecialist      *ess.Subspecialist `json:"subspecialist,omitempty"`
	User_Id            *uint              `json:"user_id"`
	User               *eu.User           `json:"user,omitempty"`
}

func (d SpecialistIntern) ToResponse() ResponseDto {
	resp := ResponseDto{
		Person_Id:          d.Person_Id,
		Person:             d.Person,
		Specialist_Code:    d.Specialist_Code,
		Specialist:         d.Specialist,
		Subspecialist_Code: d.Subspecialist_Code,
		Subspecialist:      d.Subspecialist,
		User_Id:            d.User_Id,
		User:               d.User,
	}
	resp.Main = d.Main
	return resp
}

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