package chemo_protocol

import (
	// std
	"time"

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

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

	ec "simrs-vx/internal/domain/main-entities/chemo"
)

type CreateDto struct {
	Chemo_Id       *uint                `json:"chemo_id"`
	Patient_Weight *float32             `json:"patient_weight"`
	Patient_Height *float32             `json:"patient_height"`
	Diagnoses      *string              `json:"diagnoses"`
	Interval       *uint                `json:"interval"`
	Cycle          *uint                `json:"cycle"`
	Series         *uint16              `json:"series"`
	StartDate      *time.Time           `json:"startDate"`
	EndDate        *time.Time           `json:"endDate"`
	Status_Code    erc.DataVerifiedCode `json:"-"`
}

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

type FilterDto struct {
	Chemo_Id *uint `json:"chemo-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
	Chemo_Id       *uint                `json:"chemo_id"`
	Chemo          *ec.Chemo            `json:"chemo,omitempty"`
	Patient_Weight *float32             `json:"patient_weight"`
	Patient_Height *float32             `json:"patient_height"`
	Diagnoses      *string              `json:"diagnoses"`
	Interval       *uint                `json:"interval"`
	Cycle          *uint                `json:"cycle"`
	Series         *uint16              `json:"series"`
	StartDate      *time.Time           `json:"startDate"`
	EndDate        *time.Time           `json:"endDate"`
	Status_Code    erc.DataVerifiedCode `json:"status_code"`
}

func (d ChemoProtocol) ToResponse() ResponseDto {
	resp := ResponseDto{
		Chemo_Id:       d.Chemo_Id,
		Chemo:          d.Chemo,
		Patient_Weight: d.Patient_Weight,
		Patient_Height: d.Patient_Height,
		Diagnoses:      d.Diagnoses,
		Interval:       d.Interval,
		Cycle:          d.Cycle,
		Series:         d.Series,
		StartDate:      d.StartDate,
		EndDate:        d.EndDate,
		Status_Code:    d.Status_Code,
	}
	resp.Main = d.Main
	return resp
}

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