package apmcuorder

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

	ecore "simrs-vx/internal/domain/base-entities/core"
	eamob "simrs-vx/internal/domain/main-entities/ap-mcu-order/base"
	ed "simrs-vx/internal/domain/main-entities/doctor"
	ee "simrs-vx/internal/domain/main-entities/encounter"
)

type CreateDto struct {
	eamob.CreateDto
	la.AuthInfo
}

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

type FilterDto struct {
	McuOrder_Id string `json:"mcu-order-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      uint `json:"encounter_id"`
	Encounter         *ee.Encounter
	Number            uint64 `json:"number"`
	Doctor_Code       string `json:"doctor_code"`
	Doctor            *ed.Doctor
	Substances        string  `json:"substances"`
	Fictations        string  `json:"fictations"`
	Localization      string  `json:"localization"`
	ClinicalDiagnoses string  `json:"clinicalDiagnoses"`
	Stadium           string  `json:"stadium"`
	ClinicalNotes     *string `json:"clinicalNotes"`
	PastHistory       string  `json:"pastHistory"`
	CurrentHistory    string  `json:"currentHistory"`
	PrevApMcu         *string `json:"prevApMcu"`
	PrevApMcuNotes    *string `json:"prevApMcuNotes"`
	SupportingExams   *string `json:"supportingExams"`
}

func (d ApMcuOrder) ToResponse() ResponseDto {
	resp := ResponseDto{
		Encounter_Id:      d.Encounter_Id,
		Encounter:         d.Encounter,
		Number:            d.Number,
		Doctor_Code:       d.Doctor_Code,
		Doctor:            d.Doctor,
		Substances:        d.Substances,
		Fictations:        d.Fictations,
		Localization:      d.Localization,
		ClinicalDiagnoses: d.ClinicalDiagnoses,
		Stadium:           d.Stadium,
		ClinicalNotes:     d.ClinicalNotes,
		PastHistory:       d.PastHistory,
		CurrentHistory:    d.CurrentHistory,
		PrevApMcu:         d.PrevApMcu,
		PrevApMcuNotes:    d.PrevApMcuNotes,
		SupportingExams:   d.SupportingExams,
	}
	resp.BigMain = d.BigMain
	return resp
}

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