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

namespace PTMedicalInsurance.CardReaders
{
    class ECReader
    {
        //static string URL = "https://fuwu-test.nhsa.gov.cn/localcfc/api/hsecfc/localQrCodeQuery";

        //[DllImport("NationECCode.dll", EntryPoint = "NationEcTrans", CharSet = CharSet.Ansi, ExactSpelling = false, CallingConvention = CallingConvention.StdCall)]
        //static extern string NationEcTrans(string strUrl,string InData,StringBuilder OutData);

        public  int Read(JObject jo,out string msg)
        {
            msg = "";
            InvokeHelper invoker = new InvokeHelper();
            JObject joRtn = invoker.invokeCenterService("1161",jo);

            string errorMsg;
            if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
            {
                msg = "获取病人信息失败：" + errorMsg;
                return -1;
            }
            else
            {
                msg = joRtn["OutData"].ToString();
                return 0;
            }
        }


    }


    class ECTokenData
    {
        /// <summary>
        /// 医保定点机构代码
        /// </summary>
        public string orgId { get; set; }
        /// <summary>
        /// 用码业务类型
        /// </summary>
        public string businessType { get; set; }
        /// <summary>
        /// 收款员编号
        /// </summary>
        public object operatorId { get; set; }
        /// <summary>
        /// 收款员姓名
        /// </summary>
        public string operatorName { get; set; }
        /// <summary>
        /// 医保科室编号
        /// </summary>
        public string officeId { get; set; }
        /// <summary>
        /// 科室名称
        /// </summary>
        public string officeName { get; set; }

        //public string outBizNo { get; set; }

        //public string authNo { get; set; }

        public string deviceType { get; set; }

        public string extData { get; set; }

    }
}
