using Newtonsoft.Json.Linq;
using PTMedicalInsurance.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PTMedicalInsurance.Business.Core.SelfServiceMachine.Process.InPat
{
    class CancelAdmissionRegistration : AbstractProcess
    {
        public override CallResult Process(JObject input)
        {
            CenterBusiness cBus = new CenterBusiness();
            //取消中心登记
            if (cBus.cancleRegister("2404", out outParam) != 0)
            {
                return Exception(outParam);
            }

            //取消医保平台登记
            if (mIS.cancleRegister(1, out outParam) != 0)
            {
                outParam = JsonHelper.setExceptionJson(-1, "中心取消登记成功，但云医保平台取消失败，", outParam).ToString();
                return Exception(outParam);
            }

            //取消HIS 登记
            if (hIS.cancleRegister(out outParam) != 0)
            {
                outParam = JsonHelper.setExceptionJson(-1, "中心和云医保平台取消登记成功，但HIS取消失败，", outParam).ToString();
                return Exception(outParam);
            }
            else
            {
                //CM 20230602 删除医保平台医保费用明细上传表数据
                mIS.deleteFee(out errMsg);
                outParam = JsonHelper.setIrisReturnValue(0, "取消医保登记成功", null).ToString();
                return Success();
            }
        }
    }
}
