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

namespace PTMedicalInsurance.Business.Core.SelfServiceMachine.Process.OutPat
{
    class UploadAdmInfo : AbstractProcess
    {
        public override CallResult Process(JObject input)
        {
            string errMsg;
            JObject joParams = (JObject)input.DeepClone();
            joParams.Remove("data");
            joParams.Remove("settlement");
            joParams.Remove("patInfo");

            JObject jo2203Inpar = new JObject();
            JObject jo2203Inpar_plain = new JObject();
            jo2203Inpar.Add("mdtrtinfo", JObject.Parse(JsonHelper.getDestValue(input, "mdtrtinfo")));
            jo2203Inpar.Add("diseinfo", JArray.Parse(JsonHelper.getDestValue(input, "diseinfo")));
            jo2203Inpar["mdtrtinfo"]["mdtrt_id"] = Global.pat.mdtrtID;
            //兰州要求挂号的时候，2201医疗类别传12，2203医疗类别不能传12
            if (!Global.operationType.Equals("SettlementOP"))
            {
                jo2203Inpar["mdtrtinfo"]["med_type"] = "11";
            }
            //门诊就诊信息上传                            
            JObject jo2203Rtn = invoker.invokeCenterService("2203", JsonHelper.setCenterInpar("2203", jo2203Inpar));
            if (JsonHelper.parseCenterRtnValue(jo2203Rtn, out errMsg) != 0)
            {
                outParam = JsonHelper.setExceptionJson(-1, "门诊就诊信息上传", errMsg).ToString();
                return Exception(-1,"",outParam);
            }

            outParam = input.ToString();
            return Success();
        }
    }
}
