using Newtonsoft.Json.Linq;
using PTMedicalInsurance.Common;
using PTMedicalInsurance.Entity;
using PTMedicalInsurance.Forms;
using PTMedicalInsurance.Helper;
using PTMedicalInsurance.Variables;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PTMedicalInsurance.Business.Core.Process
{
    class ReadCardProcess : AbstractProcess
    {
        public override CallResult Process(JObject input)
        {
            return Success();
        }

        /// <summary>
        /// 通过证件号获取基本信息（无卡）
        /// </summary>
        /// <param name="cardNo"></param>
        /// <param name="outParam"></param>
        /// <returns></returns>
        public int trade1101(out string outParam)
        {

            #region【1101获取身份信息】
            JObject joData = new JObject();
            joData.Add("mdtrt_cert_type", Global.pat.mdtrtcertType);
            joData.Add("mdtrt_cert_no", Global.pat.mdtrtcertNO);
            joData.Add("card_sn", Global.pat.card.SN);
            joData.Add("begntime", "");
            joData.Add("psn_cert_type", Global.pat.certType);
            joData.Add("certno", Global.pat.certNO); //证件号码
            joData.Add("psn_name", Global.pat.name);
            JObject joInput = new JObject();
            joInput.Add("data", joData);

            //InvokeHelper invoker = new InvokeHelper();
            JObject joRtn = invoker.invokeCenterService("1101", JsonHelper.setCenterInpar("1101", joInput));
            if (JsonHelper.parseCenterRtnValue(joRtn, out outParam) != 0)
            {
                outParam = "读卡失败：" + outParam;
                return -1;
            }
            else
            {
                //joRtn.Add("cardinfo",joCardInfo);                    
                outParam = joRtn.ToString();
                Global.pat.insuplc_admdvs = JsonHelper.getDestValue(JObject.Parse(outParam), "output.insuinfo.insuplc_admdvs"); //参保地
                Global.pat.certNO = JsonHelper.getDestValue(JObject.Parse(outParam), "output.baseinfo.certno"); //证件号码
                Global.pat.psn_no = JsonHelper.getDestValue(JObject.Parse(outParam), "output.baseinfo.psn_no"); //人员编号
                outParam = outParam.Replace(@"\", "").Replace("\"{", "{").Replace("}\"", "}");
                return 0;
            }
            #endregion
        }

    }
}
