package encounter_document

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

	ee "simrs-vx/internal/domain/main-entities/employee"
)

type CreateDto struct {
	Encounter_Id       *uint           `json:"encounter_id"`
	Type_Code          ere.DocTypeCode `json:"type_code"`
	Name               string          `json:"name"`
	FilePath           string          `json:"filePath"`
	Filename           string          `json:"-"`
	Upload_Employee_Id *uint           `form:"upload_employee_id"`
}

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

type FilterDto struct {
	Encounter_Id       *uint           `json:"encounter-id"`
	Type_Code          ere.DocTypeCode `json:"type-code"`
	Upload_Employee_Id *string         `json:"encounter-document-employee-id"`
}

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
	Encounter_Id       *uint           `json:"encounter_id"`
	Type_Code          ere.DocTypeCode `json:"type_code"`
	Name               string          `json:"name"`
	FilePath           *string         `json:"filePath"`
	FileName           *string         `json:"fileName"`
	Upload_Employee_Id *uint           `json:"upload_employee_id"`
	Upload_Employee    *ee.Employee    `json:"upload_employee,omitempty"`
}

func (d EncounterDocument) ToResponse() ResponseDto {
	resp := ResponseDto{
		Encounter_Id:       d.Encounter_Id,
		Type_Code:          d.Type_Code,
		Name:               d.Name,
		FilePath:           d.FilePath,
		FileName:           d.FileName,
		Upload_Employee_Id: d.Upload_Employee_Id,
		Upload_Employee:    d.Upload_Employee,
	}
	resp.Main = d.Main
	return resp
}

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