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    *string `query:"sex,omitempty"`

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

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

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

type PatientAnalyticItem struct {
	ID          uint64         `json:"id"`
	FirstName   string         `json:"first_name"`
	LastName    string         `json:"Last_name"`
	DateOfBirth string         `json:"dob,omitempty"`
	Sex         string         `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.UserMeta) PatientAnalyticItem {
	return PatientAnalyticItem{
		ID:          patient.ID,
		FirstName:   patient.Name,
		LastName:    patient.LastName,
		DateOfBirth: patient.BirthDate,
		Sex:         patient.Gender,
		Phone:       *patient.Mobile,
		Address: entity.Address{
			ProvinceID: patient.AddressState,
			CityID:     patient.AddressCity,
		},
	}
}

// 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"`
}
