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.Business
{
    class ReadPatientProcess : AbstractProcess
    {
        public override CallResult Process(JObject input)
        {
            string patInfo = "";
            PatientService patientService = new PatientService();
            // 显示病人基本信息
            // 返回 baseinfo、insuinfo、selectedIdInfo、selectedInsuInfo
            int ret = patientService.readPatientInfo(out patInfo);
            if (ret != 0)
            {
                return Exception(ret,"获取基本信息",patInfo);
            }

            if ("RegisterOP".Equals(Global.operationType))
            {
                // 门诊挂号(医疗类别/统筹类别)  挂号收费传12医保会返回错误信息提示不存在医保类别12 这里改成传11 普通门诊
                Global.pat.medType = "11";
            }
            //Global.writeLog("医疗类别:" + Global.pat.medType);

            // 返回:data、mdtrtinfo、diseinfo、settlement
            if (hBus.showOutPatRegisterForm(patInfo, out outParam) != 0)
            {
                return Exception(-1, "显示登记面板", outParam);
            }

            //用于没有返回病人信息时增加
            JObject joInput = JObject.Parse(outParam);
            JObject joPatInfo = JObject.Parse(patInfo);
            joInput["patInfo"] = joPatInfo;

            outParam = joInput.ToString();

            return Success();
        }
    }
}