/// <summary>
 /// 浙大输出接口 LY 2015-10-29
 /// </summary>
 /// <param name="PatientId"></param>
 /// <returns></returns>
 public List<TypeAndName> GetPatientInfo(DataConnection pclsCache, string PatientId)
 {
     List<TypeAndName> List = new List<TypeAndName>();
     PatBasicInfo BasicInfo = new UsersRepository().GetPatBasicInfo(pclsCache, PatientId);
     TypeAndName NewLine1 = new TypeAndName
     {
         Type = "name",
         Name = BasicInfo.UserName
     };
     List.Add(NewLine1);
     TypeAndName NewLine2 = new TypeAndName
     {
         Type = "age",
         Name = BasicInfo.Age
     };
     List.Add(NewLine2);
     TypeAndName NewLine3 = new TypeAndName
     {
         Type = "sex",
         Name = BasicInfo.Gender
     };
     List.Add(NewLine3);
     string Height = new VitalInfoRepository().GetLatestPatientVitalSigns(pclsCache, PatientId, "Height", "Height_1");
     TypeAndName NewLine4 = new TypeAndName
     {
         Type = "height",
         Name = Height
     };
     List.Add(NewLine4);
     string Weight = new VitalInfoRepository().GetLatestPatientVitalSigns(pclsCache, PatientId, "Weight", "Weight_1");
     TypeAndName NewLine5 = new TypeAndName
     {
         Type = "weight",
         Name = Weight
     };
     List.Add(NewLine5);
     string PhoneNumber = new UsersMethod().GetPhoneNoByUserId(pclsCache, PatientId);
     TypeAndName NewLine6 = new TypeAndName
     {
         Type = "mobilephone",
         Name = PhoneNumber
     };
     List.Add(NewLine6);
     return List;
 }
Example #2
0
        /// <summary>
        /// 浙大输出接口 LY 2015-10-29
        /// </summary>
        /// <param name="PatientId"></param>
        /// <returns></returns>
        public string GetPatientInfo(DataConnection pclsCache, string PatientId)
        {
            List<TypeAndName> List = new List<TypeAndName>();
            List.Add(new TypeAndName
            {
                Type = "ubid",
                Name = "DW0101111447049158"
            });
            PatBasicInfo BasicInfo = new UsersRepository().GetPatBasicInfo(pclsCache, PatientId);
            if (BasicInfo == null)
                return "病人不存在";
            List.Add(new TypeAndName
            {
                Type = "name",
                Name = BasicInfo.UserName
            });
            List.Add(new TypeAndName
            {
                Type = "age",
                Name = BasicInfo.Age
            });
            List.Add(new TypeAndName
            {
                Type = "sex",
                Name = BasicInfo.Gender
            });
            string PhoneNumber = new UsersMethod().GetPhoneNoByUserId(pclsCache, PatientId);
            List.Add(new TypeAndName
            {
                Type = "mobilephone",
                Name = PhoneNumber
            });
            ValueTime H = new ValueTime();
            H = new VitalInfoRepository().GetLatestPatientVitalSigns(pclsCache, PatientId, "Height", "Height_1");
            string Height = H.Value;

            ValueTime W = new ValueTime();
            W = new VitalInfoRepository().GetLatestPatientVitalSigns(pclsCache, PatientId, "Weight", "Weight_1");
            string Weight = W.Value;

            ValueTime Wa = new ValueTime();
            Wa = new VitalInfoRepository().GetLatestPatientVitalSigns(pclsCache, PatientId, "Waistline", "Waistline_1");
            string Waistline = Wa.Value;
            if (Height == null)
                Height = "";
            if (Weight == null)
                Weight = "";
            List.Add(new TypeAndName
            {
                Type = "height",
                Name = Height
            });
            List.Add(new TypeAndName
            {
                Type = "weight",
                Name = Weight
            });
            List.Add(new TypeAndName
            {
                Type = "birthday",
                Name = BasicInfo.Birthday.Insert(4,"-").Insert(7,"-")
            });
            if (Waistline != null)
                List.Add(new TypeAndName
                {
                    Type = "waistline",
                    Name = Waistline
                });
            try
            {
                string BasicJson = "{";
                foreach (TypeAndName Line in List)
                {
                    BasicJson = BasicJson + '"' + Line.Type + '"' + ':' + '"' + Line.Name + '"' + ',';
                }
                BasicJson = BasicJson.TrimEnd(',');
                BasicJson += "}";
                byte[] bytedata = Encoding.UTF8.GetBytes(BasicJson);
                string content = Convert.ToBase64String(bytedata, 0, bytedata.Length);
                content = "type=docapp&action=004&content=" + content + "&contentkey=#HQ*" + content;
                string Url = "http://qacsupport.duapp.com/port/port.php";
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
                request.Method = "POST";
                request.ContentType = "application/x-www-form-urlencoded";
                byte[] bytes = Encoding.UTF8.GetBytes(content);
                request.ContentLength = bytes.Length;
                //request.Timeout = 10000;
                Stream reqstream = request.GetRequestStream();
                reqstream.Write(bytes, 0, bytes.Length);
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                Stream streamReceive = response.GetResponseStream();
                Encoding encoding = Encoding.UTF8;
                StreamReader streamReader = new StreamReader(streamReceive, encoding);
                string strResult = streamReader.ReadToEnd();
                streamReceive.Dispose();
                streamReader.Dispose();
                return strResult;
            }
            catch (WebException ex)
            {
                using (WebResponse response = ex.Response)
                {
                    HttpWebResponse httpResponse = (HttpWebResponse)response;
                    Console.WriteLine("Error code: {0}", httpResponse.StatusCode);
                    using (Stream data = response.GetResponseStream())
                    using (var reader = new StreamReader(data))
                    {
                        string text = reader.ReadToEnd();
                        Console.WriteLine(text);
                    }
                }
                return ex.Message;
            }
        }