package procedureroomorder

import (
	ecore "simrs-vx/internal/domain/base-entities/core"
	ec "simrs-vx/internal/domain/main-entities/encounter"
	emp "simrs-vx/internal/domain/main-entities/material-package"
	epr "simrs-vx/internal/domain/main-entities/procedure-room"
	erc "simrs-vx/internal/domain/references/common"
)

type CreateDto struct {
	Encounter_Id uint64 `json:"encounter_id" validate:"required"`
	// Infra_Code           string `json:"infra_code" validate:"required"`
	MaterialPackage_Code *string `json:"materialPackage_code"`
}

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

type FilterDto struct {
	Encounter_Id uint64 `json:"encounter-id"`
}

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

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

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

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

type ResponseDto struct {
	ecore.BigMain
	Encounter_Id         uint64               `json:"encounter_id"`
	Encounter            *ec.Encounter        `json:"encounter,omitempty"`
	Infra_Code           string               `json:"procedure"`
	MaterialPackage_Code *string              `json:"materialPackage_code"`
	Status_Code          erc.DataStatusCode   `json:"status_code"`
	ProcedureRoom        *epr.ProcedureRoom   `json:"procedureRoom,omitempty"`
	MaterialPackage      *emp.MaterialPackage `json:"materialPackage,omitempty"`
}

func (d ProcedureRoomOrder) ToResponse() ResponseDto {
	resp := ResponseDto{
		Encounter_Id: d.Encounter_Id,
		// Infra_Code:           d.Infra_Code,
		MaterialPackage_Code: d.MaterialPackage_Code,
		Status_Code:          d.Status_Code,
	}
	resp.Id = d.Id
	return resp
}

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