using Microsoft.AspNetCore.Mvc;
using Nirvana.Common.ApiBase;
using YBDevice.Entity;
using YBDevice.Entity.ViewModel;
using YBDevice.NApi.Application.ChildBody;
using YBDevice.NApi.Application.Prescription;

namespace YBDevice.NApi.Controllers
{
    /// <summary>
    /// 儿童信息处理
    /// </summary>
    public class ChildController : BaseController
    {
        private readonly IChildService _childService;
        private readonly IChildBodyService _childBodyService;
        private readonly IPrescriptionService _prescriptionService;
        public ChildController(IChildService childService, IPrescriptionService prescriptionService, IChildBodyService childBodyService)
        {
            _childService = childService;
            _prescriptionService = prescriptionService;
            _childBodyService = childBodyService;
        }
        /// <summary>
        /// 获取儿童信息
        /// </summary>
        /// <param name="familyid"></param>
        /// <param name="devtype">设备类型</param>
        /// <param name="appid">小程序appid</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ResultInfo> GetInfoAsync(int familyid = 0, int devtype = 1, string appid = "")
        {
            return await _childService.GetInfoAsync(familyid, devtype, appid);
        }
        /// <summary>
        /// 身高/体重历史曲线图
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> GetGrowthCurveAsync([FromBody] ChildGrowthQueryModel model)
        {
            return await _childService.GetGrowthCurveAsync(model);
        }
        /// <summary>
        /// 获取身高/体重成长测评报告,与标准身高进行对比
        /// </summary>
        /// <param name="familyid"></param>
        /// <param name="devtype">设备类型</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ResultInfo> GetHWListAsync(int familyid, int devtype = 1)
        {
            return await _childService.GetHWListAsync(familyid, devtype);
        }
        /// <summary>
        /// 计算遗传身高和成年身高
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> PredictHeightAsync([FromBody] ChildPredictHeightModel model)
        {
            return await _childService.PredictHeightAsync(model);
        }

        /// <summary>
        /// 获取儿童增量信息
        /// </summary>
        /// <param name="familyid">家庭成员ID</param>
        /// <param name="devtype">设备类型</param>
        /// <param name="appid">小程序appid</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ResultInfo> GetYearHeightInfoAsync(string appid,int familyid, int devtype = 0)
        {
            return await _childService.GetYearHeightInfoAsync(familyid, devtype,appid);
        }
        /// <summary>
        /// 获取儿童体质评测列表
        /// </summary>
        /// <param name="isrestart">是否重新测评,1-是,0-否</param>
        /// <param name="familyid">家庭成员ID</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ResultInfo> GetChildPhysiqueAsync(int isrestart = 0, int familyid = 0)
        {
            return await _prescriptionService.GetChildPhysiqueAsync(isrestart, familyid);
        }

        /// <summary>
        /// 计算儿童体质
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> ChildPhysiqueAsync([FromBody] ChildPhysiqueCalcC2SDto data)
        {
            return await _prescriptionService.ChildPhysiqueAsync(data);
        }

        /// <summary>
        /// 获取儿童中医体质已经计算的结果
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> GetBodyInfoAsync([FromBody] ChildBodyInfoC2SDto input)
        {
            return await _childBodyService.GetInfoAsync(input);
        }
        /// <summary>
        /// 获取儿童中医体质问答列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> GetBodyListAsync([FromBody] ChildBodyListC2SDto input)
        {
            return await _childBodyService.GetListAsync(input);
        }
        /// <summary>
        /// 获取儿童中医体质结果计算
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> GetBodyResultInfoAsync([FromBody] ChildBodySumitC2SDto input)
        {
            return await _childBodyService.GetResultInfoAsync(input);
        }
    }
}
