package materialorder

import (
	// internal - lib
	pa "simrs-vx/internal/lib/auth"

	// internal - domain - base-entities
	ecore "simrs-vx/internal/domain/base-entities/core"

	// internal - domain - references
	erc "simrs-vx/internal/domain/references/common"

	// internal - domain - main-entities
	ed "simrs-vx/internal/domain/main-entities/doctor"
	ee "simrs-vx/internal/domain/main-entities/encounter"
)

type CreateDto struct {
	Encounter_Id *uint              `json:"encounter_id"`
	Status_Code  erc.DataStatusCode `json:"status_code"`
	Doctor_Code  *string            `json:"doctor_code"`

	pa.AuthInfo
}

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

type FilterDto struct {
	Encounter_Id *uint              `json:"encounter-id"`
	Status_Code  erc.DataStatusCode `json:"status_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"`
	Encounter    *ee.Encounter      `json:"encounter,omitempty"`
	Doctor_Code  *string            `json:"doctor_code"`
	Doctor       *ed.Doctor         `json:"doctor,omitempty"`
	Status_Code  erc.DataStatusCode `json:"status_code"`
}

func (d MaterialOrder) ToResponse() ResponseDto {
	resp := ResponseDto{
		Encounter_Id: d.Encounter_Id,
		Encounter:    d.Encounter,
		Doctor_Code:  d.Doctor_Code,
		Doctor:       d.Doctor,
		Status_Code:  d.Status_Code,
	}
	resp.Main = d.Main
	return resp
}

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