package emergency

import (
	ecore "simrs-vx/internal/domain/base-entities/core"
	ere "simrs-vx/internal/domain/references/encounter"
)

type CreateDto struct {
	Encounter_Id *uint                  `json:"encounter_id"`
	Class_Code   ere.EmergencyClassCode `json:"class_code" validate:"maxLength=10"`
}

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

type FilterDto struct {
	Encounter_Id *uint                  `json:"encounter-id"`
	Class_Code   ere.EmergencyClassCode `json:"class-code"`
}

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

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
	Encounter_Id *uint                  `json:"encounter_id"`
	Class_Code   ere.EmergencyClassCode `json:"class_code"`
}

func (d Emergency) ToResponse() ResponseDto {
	resp := ResponseDto{
		Encounter_Id: d.Encounter_Id,
		Class_Code:   d.Class_Code,
	}
	resp.Main = d.Main
	return resp
}

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