package controllers

import "sws_xcx/service"

type SysDicApiController struct {
	BaseApiController
}

// @Title GetIllness
// @Description 获取病情字典
// @Success 200 {array} models.DicResp success
// @Failure 500 error
// @router /getillness [get]
func (c *SysDicApiController) GetIllness() {
	s := service.NewSysDicService()
	dics, err := s.GetDicsByType("ILLNESS")
	if err != nil {
		c.ServeDynamicFailJsonSend(err.Error())
		return
	}

	c.ServeSuccessJSON(s.Transform(dics))
}

// @Title GetRenalStatus
// @Description 获取肾功能情况列表
// @Success 200 {array} models.DicResp success
// @Failure 500 error
// @router /getrenalstatus [get]
func (c *SysDicApiController) GetRenalStatus() {
	s := service.NewSysDicService()
	dics, err := s.GetDicsByType("RENAL")
	if err != nil {
		c.ServeDynamicFailJsonSend(err.Error())
		return
	}

	c.ServeSuccessJSON(s.Transform(dics))
}

// @Title GetDeviceTypes
// @Description 获取设备类型列表
// @Success 200 {array} models.DicResp success
// @Failure 500 error
// @router /getdevicetypes [get]
func (c *SysDicApiController) GetDeviceTypes() {
	s := service.NewSysDicService()
	dics, err := s.GetDicsByType("DEVICE_TYPE")
	if err != nil {
		c.ServeDynamicFailJsonSend(err.Error())
		return
	}

	c.ServeSuccessJSON(s.Transform(dics))
}

// @Title GetCheckItems
// @Description 获取检测项目列表
// @Success 200 {array} models.CheckItem success
// @Failure 500 error
// @router /getcheckitems [get]
func (c *SysDicApiController) GetCheckItems() {
	s := service.NewCheckItemService()
	dics, err := s.GetCheckItems("cn", "")
	if err != nil {
		c.ServeDynamicFailJsonSend(err.Error())
		return
	}
	c.ServeSuccessJSON(dics)
}
