package admin_api_controllers

import (
	"XT_Admin_Api/models"
	"XT_Admin_Api/models/admin_models"
	"XT_Admin_Api/service"
	"XT_Admin_Api/utils"
	"time"
)

type AnalysisAPIController struct {
	AdminBaseAPIAuthController
	// AdminBaseAPIController
}

// /admin/api/org/regist [get] RegistOrg
func (this *AnalysisAPIController) RegistOrg() {
	totalOrg, getTotalOrgErr := service.GetTotalOrgCount()
	if getTotalOrgErr != nil {
		this.ErrorLog("获取总机构数失败:%v", getTotalOrgErr)
	}

	now := time.Now()
	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
	registOrgCountToday, getRegistOrgCountTodayErr := service.GetRegistedOrgCountFromDayToDay(zeroHourTimeOfToday, now)
	if getRegistOrgCountTodayErr != nil {
		this.ErrorLog("获取今日注册机构数失败:%v", getRegistOrgCountTodayErr)
	}

	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&now)
	registOrgCountThisWeek, getRegistOrgCountThisWeekErr := service.GetRegistedOrgCountFromDayToDay(monday, sunday)
	if getRegistOrgCountThisWeekErr != nil {
		this.ErrorLog("获取本周注册机构数失败:%v", getRegistOrgCountThisWeekErr)
	}

	thisYear := now.Year()
	thisMonth := int(now.Month())
	beginningOfMonth, endOfMonth := utils.MonthBeginningToEnd(thisYear, thisMonth)
	registOrgCountThisMonth, getRegistOrgCountThisMonthErr := service.GetRegistedOrgCountFromDayToDay(beginningOfMonth, endOfMonth)
	if getRegistOrgCountThisMonthErr != nil {
		this.ErrorLog("获取本月注册机构数失败:%v", getRegistOrgCountThisMonthErr)
	}

	monthRegistOrgCounts := make([]map[string]interface{}, 0, 12)
	for m := 1; m < 12; m++ {
		if m > thisMonth {
			break
		}
		if m == thisMonth {
			monthRegistOrgCounts = append(monthRegistOrgCounts, map[string]interface{}{
				"month": m,
				"count": registOrgCountThisMonth,
			})

		} else {
			BOM, EOM := utils.MonthBeginningToEnd(thisYear, m)
			registOrgCount, getRegistOrgCountErr := service.GetRegistedOrgCountFromDayToDay(BOM, EOM)
			if getRegistOrgCountErr != nil {
				this.ErrorLog("获取%v月注册机构数失败:%v", m, getRegistOrgCountErr)
			}
			monthRegistOrgCounts = append(monthRegistOrgCounts, map[string]interface{}{
				"month": m,
				"count": registOrgCount,
			})
		}
	}

	registOrgsThisWeek, getRegistOrgThisWeekErr := service.GetRegistedOrgsFromDayToDay(monday, sunday)
	if getRegistOrgThisWeekErr != nil {
		this.ErrorLog("获取本周注册机构失败:%v", getRegistOrgThisWeekErr)
		registOrgsThisWeek = make([]*models.Org, 0)
	}

	registOrgsThisMonth, getRegistOrgThisMonthErr := service.GetRegistedOrgsFromDayToDay(beginningOfMonth, endOfMonth)
	if getRegistOrgThisMonthErr != nil {
		this.ErrorLog("获取本月注册机构失败:%v", getRegistOrgThisMonthErr)
		registOrgsThisMonth = make([]*models.Org, 0)
	}

	this.ServeSuccessJSON(map[string]interface{}{
		"total_org_count":         totalOrg,
		"regist_org_count_today":  registOrgCountToday,
		"regist_org_count_week":   registOrgCountThisWeek,
		"regist_org_count_month":  registOrgCountThisMonth,
		"regist_org_count_months": monthRegistOrgCounts,
		"regist_orgs_week":        registOrgsThisWeek,
		"regist_orgs_month":       registOrgsThisMonth,
	})
}

// /admin/api/org/active [get] ActiveOrg
func (this *AnalysisAPIController) ActiveOrg() {
	now := time.Now()
	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
	activeOrgCountToday, getActiveTodayErr := service.GetActiveOrgCountFromDayToDay(zeroHourTimeOfToday, now)
	if getActiveTodayErr != nil {
		this.ErrorLog("获取今日活跃机构数失败:%v", getActiveTodayErr)
	}

	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&now)
	activeOrgCountThisWeek, getActiveOrgCountThisWeekErr := service.GetActiveOrgCountFromDayToDay(monday, sunday)
	if getActiveOrgCountThisWeekErr != nil {
		this.ErrorLog("获取本周活跃机构数失败:%v", getActiveOrgCountThisWeekErr)
	}

	thisYear := now.Year()
	thisMonth := int(now.Month())
	beginningOfMonth, endOfMonth := utils.MonthBeginningToEnd(thisYear, thisMonth)
	activeOrgCountThisMonth, getActiveOrgCountThisMonthErr := service.GetActiveOrgCountFromDayToDay(beginningOfMonth, endOfMonth)
	if getActiveOrgCountThisMonthErr != nil {
		this.ErrorLog("获取本月活跃机构数失败:%v", getActiveOrgCountThisMonthErr)
	}

	monthActiveOrgCounts := make([]map[string]interface{}, 0, 12)
	for m := 1; m < 12; m++ {
		if m > thisMonth {
			break
		}
		if m == thisMonth {
			monthActiveOrgCounts = append(monthActiveOrgCounts, map[string]interface{}{
				"month": m,
				"count": activeOrgCountThisMonth,
			})

		} else {
			BOM, EOM := utils.MonthBeginningToEnd(thisYear, m)
			activeOrgCount, getActiveOrgCountErr := service.GetActiveOrgCountFromDayToDay(BOM, EOM)
			if getActiveOrgCountErr != nil {
				this.ErrorLog("获取%v月活跃机构数失败:%v", m, getActiveOrgCountErr)
			}
			monthActiveOrgCounts = append(monthActiveOrgCounts, map[string]interface{}{
				"month": m,
				"count": activeOrgCount,
			})
		}
	}

	activeOrgsThisWeek, getActiveOrgThisWeekErr := service.GetActiveOrgsFromDayToDay(monday, sunday)
	if getActiveOrgThisWeekErr != nil {
		this.ErrorLog("获取本周活跃机构失败:%v", getActiveOrgThisWeekErr)
		activeOrgsThisWeek = make([]*service.ActiveOrgListVM, 0)
	}

	activeOrgsThisMonth, getActiveOrgThisMonthErr := service.GetActiveOrgsFromDayToDay(beginningOfMonth, endOfMonth)
	if getActiveOrgThisMonthErr != nil {
		this.ErrorLog("获取本月活跃机构失败:%v", getActiveOrgThisMonthErr)
		activeOrgsThisMonth = make([]*service.ActiveOrgListVM, 0)
	}

	this.ServeSuccessJSON(map[string]interface{}{
		"active_org_count_today":  activeOrgCountToday,
		"active_org_count_week":   activeOrgCountThisWeek,
		"active_org_count_month":  activeOrgCountThisMonth,
		"active_org_count_months": monthActiveOrgCounts,
		"active_orgs_week":        activeOrgsThisWeek,
		"active_orgs_month":       activeOrgsThisMonth,
	})
}

// /admin/api/user/active [get] ActiveUser
func (this *AnalysisAPIController) ActiveUser() {
	now := time.Now()
	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
	activeAdminCountToday, getActiveTodayErr := service.GetActiveAdminUserCountFromDayToDay(zeroHourTimeOfToday, now)
	if getActiveTodayErr != nil {
		this.ErrorLog("获取今日活跃账户数失败:%v", getActiveTodayErr)
	}

	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&now)
	activeAdminCountThisWeek, getActiveAdminCountThisWeekErr := service.GetActiveAdminUserCountFromDayToDay(monday, sunday)
	if getActiveAdminCountThisWeekErr != nil {
		this.ErrorLog("获取本周活跃账户数失败:%v", getActiveAdminCountThisWeekErr)
	}

	thisYear := now.Year()
	thisMonth := int(now.Month())
	beginningOfMonth, endOfMonth := utils.MonthBeginningToEnd(thisYear, thisMonth)
	activeAdminCountThisMonth, getActiveAdminCountThisMonthErr := service.GetActiveAdminUserCountFromDayToDay(beginningOfMonth, endOfMonth)
	if getActiveAdminCountThisMonthErr != nil {
		this.ErrorLog("获取本月活跃账户数失败:%v", getActiveAdminCountThisMonthErr)
	}

	monthActiveAdminCounts := make([]map[string]interface{}, 0, 12)
	for m := 1; m < 12; m++ {
		if m > thisMonth {
			break
		}
		if m == thisMonth {
			monthActiveAdminCounts = append(monthActiveAdminCounts, map[string]interface{}{
				"month": m,
				"count": activeAdminCountThisMonth,
			})

		} else {
			BOM, EOM := utils.MonthBeginningToEnd(thisYear, m)
			activeAdminCount, getActiveAdminCountErr := service.GetActiveAdminUserCountFromDayToDay(BOM, EOM)
			if getActiveAdminCountErr != nil {
				this.ErrorLog("获取%v月活跃账户数失败:%v", m, getActiveAdminCountErr)
			}
			monthActiveAdminCounts = append(monthActiveAdminCounts, map[string]interface{}{
				"month": m,
				"count": activeAdminCount,
			})
		}
	}

	activeAdminsThisWeek, getActiveAdminThisWeekErr := service.GetActiveAdminUsersFromDayToDay(monday, sunday)
	if getActiveAdminThisWeekErr != nil {
		this.ErrorLog("获取本周活跃账户失败:%v", getActiveAdminThisWeekErr)
		activeAdminsThisWeek = make([]*service.ActiveAdminUserListVM, 0)
	}

	activeAdminsThisMonth, getActiveAdminThisMonthErr := service.GetActiveAdminUsersFromDayToDay(beginningOfMonth, endOfMonth)
	if getActiveAdminThisMonthErr != nil {
		this.ErrorLog("获取本月活跃账户失败:%v", getActiveAdminThisMonthErr)
		activeAdminsThisMonth = make([]*service.ActiveAdminUserListVM, 0)
	}

	this.ServeSuccessJSON(map[string]interface{}{
		"active_admin_count_today":  activeAdminCountToday,
		"active_admin_count_week":   activeAdminCountThisWeek,
		"active_admin_count_month":  activeAdminCountThisMonth,
		"active_admin_count_months": monthActiveAdminCounts,
		"active_admins_week":        activeAdminsThisWeek,
		"active_admins_month":       activeAdminsThisMonth,
	})
}

// /admin/api/org/expiring [get] ExpiringOrg
func (this *AnalysisAPIController) ExpiringOrg() {
	now := time.Now()
	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
	// endTimeOfToday := time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 59, 999, time.Local)
	timeAfter15Days := zeroHourTimeOfToday.AddDate(0, 0, 15)
	timeBefore15Days := zeroHourTimeOfToday.AddDate(0, 0, -15)

	countOfWillExpireOrg, getWillExpireOrgCountErr := service.GetWillExpireOrgCountFromDayToDay(zeroHourTimeOfToday, timeAfter15Days)
	if getWillExpireOrgCountErr != nil {
		this.ErrorLog("获取即将到期机构数失败:%v", getWillExpireOrgCountErr)
	}

	countOfExpiredOrg, getExpiredOrgCountErr := service.GetDidExpiredOrgCountFromDayToDay(timeBefore15Days, zeroHourTimeOfToday)
	if getExpiredOrgCountErr != nil {
		this.ErrorLog("获取刚到期机构数失败:%v", getExpiredOrgCountErr)
	}

	willExpireOrgs, getWillExpireOrgsErr := service.GetWillExpireOrgsFromDayToDay(zeroHourTimeOfToday, timeAfter15Days)
	if getWillExpireOrgsErr != nil {
		this.ErrorLog("获取即将到期机构失败:%v", getWillExpireOrgsErr)
		willExpireOrgs = make([]*service.ExpireOrgListVM, 0, 0)
	}

	expiredOrgs, getExpiredOrgsErr := service.GetDidExpireOrgsFromDayToDay(timeBefore15Days, zeroHourTimeOfToday)
	if getExpiredOrgsErr != nil {
		this.ErrorLog("获取已到期机构失败:%v", getExpiredOrgsErr)
		expiredOrgs = make([]*service.ExpireOrgListVM, 0, 0)
	}

	this.ServeSuccessJSON(map[string]interface{}{
		"will_expire_org_count": countOfWillExpireOrg,
		"did_expired_org_count": countOfExpiredOrg,
		"will_expire_orgs":      willExpireOrgs,
		"did_expired_orgs":      expiredOrgs,
	})
}

// /admin/api/dialysis/analysis [get] DialysisAnalysis
func (this *AnalysisAPIController) DialysisAnalysis() {
	now := time.Now()
	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
	endTimeOfToday := time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 59, 999, time.Local)

	timesToday, getTimesTodayErr := service.GetDialysisTimesFromDayToDay(zeroHourTimeOfToday, endTimeOfToday)
	if getTimesTodayErr != nil {
		this.ErrorLog("获取今日透析次数失败:%v", getTimesTodayErr)
	}

	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&now)
	timesThisWeek, getTimesThisWeekErr := service.GetDialysisTimesFromDayToDay(monday, sunday)
	if getTimesThisWeekErr != nil {
		this.ErrorLog("获取本周透析次数失败:%v", getTimesThisWeekErr)
	}

	thisYear := now.Year()
	thisMonth := int(now.Month())
	beginningOfMonth, endOfMonth := utils.MonthBeginningToEnd(thisYear, thisMonth)
	timesThisMonth, getTimesThisMonthErr := service.GetDialysisTimesFromDayToDay(beginningOfMonth, endOfMonth)
	if getTimesThisMonthErr != nil {
		this.ErrorLog("获取本月透析次数失败:%v", getTimesThisMonthErr)
	}

	monthTimes := make([]map[string]interface{}, 0, 12)
	for m := 1; m < 12; m++ {
		if m > thisMonth {
			break
		}
		if m == thisMonth {
			monthTimes = append(monthTimes, map[string]interface{}{
				"month": m,
				"count": timesThisMonth,
			})

		} else {
			BOM, EOM := utils.MonthBeginningToEnd(thisYear, m)
			times, getTimesErr := service.GetDialysisTimesFromDayToDay(BOM, EOM)
			if getTimesErr != nil {
				this.ErrorLog("获取%v月透析次数失败:%v", m, getTimesErr)
			}
			monthTimes = append(monthTimes, map[string]interface{}{
				"month": m,
				"count": times,
			})
		}
	}

	this.ServeSuccessJSON(map[string]interface{}{
		"times_today":  timesToday,
		"times_week":   timesThisWeek,
		"times_month":  timesThisMonth,
		"times_months": monthTimes,
	})
}

// /admin/api/monitor/analysis [get] MonitorAnalysis
func (this *AnalysisAPIController) MonitorAnalysis() {
	now := time.Now()
	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
	endTimeOfToday := time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 59, 999, time.Local)

	timesToday, getTimesTodayErr := service.GetMonitoringTimesFromDayToDay(zeroHourTimeOfToday, endTimeOfToday)
	if getTimesTodayErr != nil {
		this.ErrorLog("获取今日监控次数失败:%v", getTimesTodayErr)
	}

	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&now)
	timesThisWeek, getTimesThisWeekErr := service.GetMonitoringTimesFromDayToDay(monday, sunday)
	if getTimesThisWeekErr != nil {
		this.ErrorLog("获取本周监控次数失败:%v", getTimesThisWeekErr)
	}

	thisYear := now.Year()
	thisMonth := int(now.Month())
	beginningOfMonth, endOfMonth := utils.MonthBeginningToEnd(thisYear, thisMonth)
	timesThisMonth, getTimesThisMonthErr := service.GetMonitoringTimesFromDayToDay(beginningOfMonth, endOfMonth)
	if getTimesThisMonthErr != nil {
		this.ErrorLog("获取本月监控次数失败:%v", getTimesThisMonthErr)
	}

	monthTimes := make([]map[string]interface{}, 0, 12)
	for m := 1; m < 12; m++ {
		if m > thisMonth {
			break
		}
		if m == thisMonth {
			monthTimes = append(monthTimes, map[string]interface{}{
				"month": m,
				"count": timesThisMonth,
			})

		} else {
			BOM, EOM := utils.MonthBeginningToEnd(thisYear, m)
			times, getTimesErr := service.GetMonitoringTimesFromDayToDay(BOM, EOM)
			if getTimesErr != nil {
				this.ErrorLog("获取%v月监控次数失败:%v", m, getTimesErr)
			}
			monthTimes = append(monthTimes, map[string]interface{}{
				"month": m,
				"count": times,
			})
		}
	}

	this.ServeSuccessJSON(map[string]interface{}{
		"times_today":  timesToday,
		"times_week":   timesThisWeek,
		"times_month":  timesThisMonth,
		"times_months": monthTimes,
	})
}

// /admin/api/patient/analysis [get] PatientAnalysis
func (this *AnalysisAPIController) PatientAnalysis() {
	now := time.Now()
	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
	newCountToday, getNewCountTodayErr := service.GetNewPatientCountFromDayToDay(zeroHourTimeOfToday, now)
	if getNewCountTodayErr != nil {
		this.ErrorLog("获取今日新增病人数失败:%v", getNewCountTodayErr)
	}

	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&now)
	newCountThisWeek, getNewCountThisWeekErr := service.GetNewPatientCountFromDayToDay(monday, sunday)
	if getNewCountThisWeekErr != nil {
		this.ErrorLog("获取本周新增病人数失败:%v", getNewCountThisWeekErr)
	}

	thisYear := now.Year()
	thisMonth := int(now.Month())
	beginningOfMonth, endOfMonth := utils.MonthBeginningToEnd(thisYear, thisMonth)
	newCountThisMonth, getNewCountThisMonthErr := service.GetNewPatientCountFromDayToDay(beginningOfMonth, endOfMonth)
	if getNewCountThisMonthErr != nil {
		this.ErrorLog("获取本月新增病人数失败:%v", getNewCountThisMonthErr)
	}

	monthNewCounts := make([]map[string]interface{}, 0, 12)
	for m := 1; m < 12; m++ {
		if m > thisMonth {
			break
		}
		if m == thisMonth {
			monthNewCounts = append(monthNewCounts, map[string]interface{}{
				"month": m,
				"count": newCountThisMonth,
			})

		} else {
			BOM, EOM := utils.MonthBeginningToEnd(thisYear, m)
			newCount, getNewCountErr := service.GetNewPatientCountFromDayToDay(BOM, EOM)
			if getNewCountErr != nil {
				this.ErrorLog("获取%v月新增病人数失败:%v", m, getNewCountErr)
			}
			monthNewCounts = append(monthNewCounts, map[string]interface{}{
				"month": m,
				"count": newCount,
			})
		}
	}

	maleCount, femaleCount, unknowGenderCount, getGenderCountErr := service.GetPatientGenderDistribution()
	if getGenderCountErr != nil {
		this.ErrorLog("获取病人性别分布失败:%v", getGenderCountErr)
	}

	// 1乙肝 2丙肝 3艾滋病 4肺结核 5梅毒
	// 不写错误日志了，累了
	normalPCount, _ := service.GetInfectiousDiseasePatientCount(0)
	type1PCount, _ := service.GetInfectiousDiseasePatientCount(1)
	type2PCount, _ := service.GetInfectiousDiseasePatientCount(2)
	type3PCount, _ := service.GetInfectiousDiseasePatientCount(3)
	type4PCount, _ := service.GetInfectiousDiseasePatientCount(4)
	type5PCount, _ := service.GetInfectiousDiseasePatientCount(5)

	ageDistribution, getAgeDistributionErr := service.GetPatientAgeDistribution()
	if getAgeDistributionErr != nil {
		this.ErrorLog("获取病人年龄分布失败:%v", getAgeDistributionErr)
		ageDistribution = make([]*service.PatientAgeCountStruct, 0, 0)
	}

	this.ServeSuccessJSON(map[string]interface{}{
		"new_patient_count_today":  newCountToday,
		"new_patient_count_week":   newCountThisWeek,
		"new_patient_count_month":  newCountThisMonth,
		"new_patient_count_months": monthNewCounts,

		"male_count":   maleCount,
		"female_count": femaleCount,
		"total_count":  maleCount + femaleCount + unknowGenderCount,

		"disease_type_0_count": normalPCount,
		"disease_type_1_count": type1PCount,
		"disease_type_2_count": type2PCount,
		"disease_type_3_count": type3PCount,
		"disease_type_4_count": type4PCount,
		"disease_type_5_count": type5PCount,

		"age_counts": ageDistribution,
	})
}

func (this *AnalysisAPIController) HomeStatistics() {
	range_data := this.GetString("range_data")
	range_type, _ := this.GetInt64("range_type")

	var rangeDate *time.Time
	var parseDateErr error
	var rangeTimeStamp int64

	if len(range_data) > 0 {
		rangeDate, parseDateErr = utils.ParseTimeStringToTime("2006-01-02", range_data)
		if parseDateErr != nil {
			this.ErrorLog("日期(%v)解析错误：%v", range_data, parseDateErr)
			return
		}
		rangeTimeStamp = rangeDate.Unix()
	} else {
		rangeTimeStamp = 0
	}
	now := time.Now().Unix()

	newOrgCount, _ := service.GetRegistedOrgCount(rangeTimeStamp, now)
	totalOrg, _ := service.GetTotalOrgCount()

	activeOrgCount, _ := service.GetActiveOrgCount(rangeTimeStamp, now)
	totalActiveOrg, _ := service.GetActiveOrgTotalCount()

	activeAdminCount, _ := service.GetActiveAdminUserCount(rangeTimeStamp, now)
	adminTotalCount, _ := service.GetAdminUserTotalCount()

	patientCount, _ :=service.GetNewPatientCount(rangeTimeStamp, now)
	patientTotalCount, _ := service.GetPatientTotalCount()

	var orgRegisterStatistics []*admin_models.Statistics
	var newPatientStatistics []*admin_models.Statistics
	var orgActiveAdminStatistics []*admin_models.Statistics
	var orgActiveStatistics []*admin_models.Statistics

	switch range_type {
	case 3:
		orgRegisterStatistics, _ = service.GetWeekRegistedOrgCount()
		newPatientStatistics, _ = service.GetWeekNewPatientCount()
		orgActiveAdminStatistics, _ = service.GetWeekActiveAdminUserCount()
		orgActiveStatistics,_ = service.GetWeekActiveOrgCount()

		//newOrgCount, _ = service.GetWeekRegistedOrgTotalCount()
		//activeOrgCount, _ = service.GetWeekRegistedOrgTotalCount()
		//activeAdminCount, _ = service.GetWeekRegistedOrgTotalCount()
		//activeAdminCount, _ = service.GetWeekRegistedOrgTotalCount()
		//
		//

		break
	case 4:
		orgRegisterStatistics, _ = service.GetMonthRegistedOrgCount()
		newPatientStatistics, _ = service.GetMonthNewPatientCount()
		orgActiveAdminStatistics, _ = service.GetMonthActiveAdminUserCount()
		orgActiveStatistics,_ = service.GetMonthActiveOrgCount()

		break
	case 5:
		orgRegisterStatistics, _ = service.GetThreeMonthRegistedOrgCount()
		newPatientStatistics, _ = service.GetThreeMonthNewPatientCount()
		orgActiveAdminStatistics, _ = service.GetThreeMonthActiveAdminUserCount()
		orgActiveStatistics,_ = service.GetThreeMonthActiveOrgCount()

		break
	case 6:
		orgRegisterStatistics, _ = service.GetSixMonthRegistedOrgCount()
		newPatientStatistics, _ = service.GetSixMonthNewPatientCount()
		orgActiveAdminStatistics, _ = service.GetSixMonthActiveAdminUserCount()
		orgActiveStatistics,_ = service.GetSixMonthActiveOrgCount()

		break
	case 7:
		orgRegisterStatistics, _ = service.GetYearRegistedOrgCount()
		newPatientStatistics, _ = service.GetYearNewPatientCount()
		orgActiveAdminStatistics, _ = service.GetYearActiveAdminUserCount()
		orgActiveStatistics,_ = service.GetYearActiveOrgCount()

		break
	}

	this.ServeSuccessJSON(map[string]interface{}{
		"org_count":  newOrgCount,
		"org_total_count":   totalOrg,
		"active_org_count":  activeOrgCount,
		"active_org_total_count": totalActiveOrg,
		"active_admin_count":   activeAdminCount,
		"active_admin_total_count": adminTotalCount,
		"patient_count":  patientCount,
		"patient_total_count":  patientTotalCount,
		"org_count_list": orgRegisterStatistics,
		"patient_count_list": newPatientStatistics,
		"active_count_list": orgActiveAdminStatistics,
		"active_org_list": orgActiveStatistics,
	})

}
