package edu_assessment

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

type CreateDto struct {
	Encounter_Id *uint   `json:"encounter_id" validate:"required"`
	GeneralEdus  *string `json:"generalEdus"`
	SpecialEdus  *string `json:"specialEdus"`
	Assessments  *string `json:"assessments" validate:"required"`
	Plan         *string `json:"plan" validate:"required"`
}

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

type FilterDto struct {
	Encounter_Id *uint `json:"encounter-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" gorm:"not null"`
	Encounter    *ee.Encounter `json:"encounter,omitempty" gorm:"foreignKey:Encounter_Id;references:Id"`
	GeneralEdus  *string       `json:"generalEdus"`
	SpecialEdus  *string       `json:"specialEdus"`
	Assessments  *string       `json:"assessments"`
	Plan         *string       `json:"plan"`
}

func (d EduAssessment) ToResponse() ResponseDto {
	resp := ResponseDto{
		Encounter_Id: d.Encounter_Id,
		Encounter:    d.Encounter,
		GeneralEdus:  d.GeneralEdus,
		SpecialEdus:  d.SpecialEdus,
		Assessments:  d.Assessments,
		Plan:         d.Plan,
	}
	resp.Main = d.Main
	return resp
}

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