Exemple #1
0
        private List <Model.PatientDiagnose> StrTObject(string xmlStr, out string msg, Model.DTO.PatientDiagnoseResuest request)
        {
            XmlDocument xd = HospitalXmlStrHelper.HospitalXmlStrToXmlDoc(xmlStr);
            List <Model.PatientDiagnose> list = new List <Model.PatientDiagnose>();

            msg = "";
            if (xd == null)
            {
            }
            else
            {
                if (xd.HasChildNodes)
                {
                    XmlNode xn = xd.SelectSingleNode("//ResultCode");
                    if (xn != null)
                    {
                        if (xn.InnerText == "0")
                        {
                            try
                            {
                                string strNode = JsonConvert.SerializeXmlNode(xd.SelectSingleNode("//reocrd"), Newtonsoft.Json.Formatting.None, true);

                                XmlNodeList xns = xd.SelectNodes("//DiagnoseInfo");
                                foreach (XmlNode item in xns)
                                {
                                    Model.PatientDiagnose patientDiagnoseModel = new Model.PatientDiagnose();
                                    patientDiagnoseModel = JsonConvert.DeserializeObject <Model.PatientDiagnose>(strNode);
                                    string diagnoseInfoNode        = JsonConvert.SerializeXmlNode(item, Newtonsoft.Json.Formatting.None, true);
                                    Model.DTO.DiagnoseInfoModel dg = JsonConvert.DeserializeObject <Model.DTO.DiagnoseInfoModel>(diagnoseInfoNode);
                                    patientDiagnoseModel.RegisterNo   = dg.RegisterNo;
                                    patientDiagnoseModel.Type         = dg.Type;
                                    patientDiagnoseModel.Icd          = dg.Icd;
                                    patientDiagnoseModel.Flag         = dg.Flag;
                                    patientDiagnoseModel.DiagnoseDate = dg.DiagnoseDate;
                                    patientDiagnoseModel.Diagnose     = dg.Diagnose;
                                    patientDiagnoseModel.Cardno       = request.cardno;
                                    patientDiagnoseModel.Csrq00       = request.cxrq00;
                                    list.Add(patientDiagnoseModel);
                                }
                            }
                            catch (Exception ex)
                            {
                                Common.LogHelper.WriteError(ex);
                            }
                        }
                        else
                        {
                            //查询数据出错,联接无问题
                            msg = xd.SelectSingleNode("//ErrorMsg").InnerText;
                        }
                    }
                    else
                    {
                        //查询数据出错,联接无问题
                        msg = xd.InnerText;
                    }
                }
            }
            return(list);
        }
Exemple #2
0
        /// <summary>
        /// 将数据转换成对象
        /// </summary>
        /// <param name="xmlStr">要转换成对象的数据</param>
        /// <returns></returns>
        private Model.DTO.JsonModel StrTObject(string xmlStr, Model.DTO.PatientDiagnoseResuest request)
        {
            XmlDocument xd = HospitalXmlStrHelper.HospitalXmlStrToXmlDoc(xmlStr);

            Model.DTO.JsonModel jsonData = new Model.DTO.JsonModel()
            {
                Statu = "err", Data = "", Msg = "无数据"
            };
            if (xd == null)
            {
            }
            else
            {
                if (xd.HasChildNodes)
                {
                    XmlNode xn = xd.SelectSingleNode("//ResultCode");
                    if (xn != null)
                    {
                        if (xn.InnerText == "0")
                        {
                            string strNode = JsonConvert.SerializeXmlNode(xd.SelectSingleNode("//reocrd"), Newtonsoft.Json.Formatting.None, true);
                            Model.PatientDiagnose patientDiagnoseData = JsonConvert.DeserializeObject <Model.PatientDiagnose>(strNode);
                            string diagnoseInfoNode        = JsonConvert.SerializeXmlNode(xd.SelectSingleNode("//DiagnoseInfo"), Newtonsoft.Json.Formatting.None, true);
                            Model.DTO.DiagnoseInfoModel dg = JsonConvert.DeserializeObject <Model.DTO.DiagnoseInfoModel>(diagnoseInfoNode);
                            patientDiagnoseData.RegisterNo   = dg.RegisterNo;
                            patientDiagnoseData.Type         = dg.Type;
                            patientDiagnoseData.Icd          = dg.Icd;
                            patientDiagnoseData.Flag         = dg.Flag;
                            patientDiagnoseData.DiagnoseDate = dg.DiagnoseDate;
                            patientDiagnoseData.Diagnose     = dg.Diagnose;
                            patientDiagnoseData.Cardno       = request.cardno;
                            patientDiagnoseData.Csrq00       = request.cxrq00;
                            if (patientDiagnoseData == null || patientDiagnoseData.PatientName == "")
                            {
                            }
                            else
                            {
                                jsonData.Data  = patientDiagnoseData;
                                jsonData.Statu = "ok";
                                jsonData.Msg   = "查询成功";
                            }
                        }
                        else
                        {
                            //查询数据出错,联接无问题
                            jsonData.Msg   = xd.SelectSingleNode("//ErrorMsg").InnerText;
                            jsonData.Statu = "err";
                        }
                    }
                    else
                    {
                        //查询数据出错,联接无问题
                        jsonData.Msg   = xd.InnerText;
                        jsonData.Statu = "err";
                    }
                }
            }
            return(jsonData);
        }