package adm_employee_hist

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

type CreateDto struct {
	Encounter_Id *uint      `json:"encounter_id"`
	Employee_Id  *uint      `json:"employee_id"`
	StartedAt    *time.Time `json:"startedAt"`
	FinishedAt   *time.Time `json:"finishedAt"`
}

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

type FilterDto struct {
	Encounter_Id *uint      `json:"encounter-id"`
	Employee_Id  *uint      `json:"employee-id"`
	StartedAt    *time.Time `json:"startedAt"`
	FinishedAt   *time.Time `json:"finishedAt"`
}

type ReadDetailDto struct {
	Id       uint16 `json:"id"`
	Includes string `json:"includes"`
}

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

type DeleteDto struct {
	Id uint16 `json:"id"`
}

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

type ResponseDto struct {
	ecore.Main                // adjust this according to the needs
	Encounter_Id *uint        `json:"encounter_id"`
	Employee_Id  *uint        `json:"employee_id"`
	Employee     *ee.Employee `json:"employee,omitempty"`
	StartedAt    *time.Time   `json:"startedAt"`
	FinishedAt   *time.Time   `json:"finishedAt"`
}

func (d AdmEmployeeHist) ToResponse() ResponseDto {
	resp := ResponseDto{
		Encounter_Id: d.Encounter_Id,
		Employee_Id:  d.Employee_Id,
		Employee:     d.Employee,
		StartedAt:    d.StartedAt,
		FinishedAt:   d.FinishedAt,
	}
	resp.Main = d.Main
	return resp
}

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