package analytic

import (
	"git.gocasts.ir/ebhomengo/niki/patientapp/service/entity"
)

type ListPatientAnalyticRequest struct {
	// All fields are optional
	MinAge *int        `query:"minAge,omitempty"`
	MaxAge *int        `query:"maxAge,omitempty"`
	Sex    *entity.Sex `query:"sex,omitempty"`

	City     *int64 `query:"city,omitempty"`
	Province *int64 `query:"province,omitempty"`

	Search *string `query:"search,omitempty"`

	Pagination *Pagination `query:"pagination,omitempty"`
}

type PatientAnalyticItem struct {
	ID          int64          `json:"id"`
	FirstName   string         `json:"first_name"`
	LastName    string         `json:"Last_name"`
	DateOfBirth string         `json:"dob,omitempty"`
	Sex         entity.Sex     `json:"sex"`
	Phone       string         `json:"phone"`
	Address     entity.Address `json:"address"`
}
type PatientAnalyticResponse struct {
	Items      []PatientAnalyticItem `json:"items"`
	Pagination *Pagination           `json:"pagination"`
	Total      int                   `json:"total"`
}

func ToPatientResponse(patient entity.Patient) PatientAnalyticItem {
	return PatientAnalyticItem{
		ID:          patient.ID,
		FirstName:   patient.FirstName,
		LastName:    patient.LastName,
		DateOfBirth: patient.DateOfBirth,
		Sex:         patient.Sex,
		Phone:       patient.Phone,
		Address: entity.Address{
			ProvinceID: patient.Address.ProvinceID,
			CityID:     patient.Address.CityID,
		},
	}
}

// GetPatientMapSummaryRequest =========================== Map ==================================
type GetPatientMapSummaryRequest struct {
	Level    entity.MapLevel `query:"level"`
	ParentID *int            `query:"parentID"`

	MinAge *int        `query:"minAge,omitempty"`
	MaxAge *int        `query:"maxAge,omitempty"`
	Sex    *entity.Sex `query:"sex,omitempty"`
	Search *string     `query:"search,omitempty"`
}

type GetPatientMapSummaryResponse struct {
	Level entity.MapLevel                  `json:"level"`
	Items map[uint][]entity.MapSummaryItem `json:"items"`
}

// Pagination ================================ Pagination =============================
type Pagination struct {
	Limit  int `query:"limit,omitempty"`
	Offset int `query:"offset,omitempty"`
}
