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

            // 返回: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();
        }
    }
}
