From 244e5e58f480e36fefd2ea2298417d25e338d78c Mon Sep 17 00:00:00 2001 From: lxd <1004405501@qq.com> Date: Mon, 6 Jan 2025 17:36:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=8A=E4=BC=A0=E8=AF=8A?= =?UTF-8?q?=E6=96=AD=E7=BB=93=E8=AE=BA=E5=88=B0=E5=B9=B3=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1200Gxml心电图绘制/App.config | 5 + 1200Gxml心电图绘制/心电图绘制.csproj | 6 + 1200Gxml心电图绘制/服务/FLYecgReport.cs | 24 + 1200Gxml心电图绘制/服务/FlyHisEcgdataModel.cs | 45 ++ 1200Gxml心电图绘制/服务/FlyHisTokenMsg.cs | 23 + 1200Gxml心电图绘制/服务/PatientInfo.cs | 8 +- 1200Gxml心电图绘制/服务/UniversalFun.cs | 10 +- 1200Gxml心电图绘制/服务/commonOptions.cs | 636 ++++++++++++++++++ 1200Gxml心电图绘制/服务/loginPara.cs | 14 + 1200Gxml心电图绘制/服务/print.cs | 37 + 1200Gxml心电图绘制/服务/tokenMsg.cs | 15 + 11 files changed, 818 insertions(+), 5 deletions(-) create mode 100644 1200Gxml心电图绘制/服务/FLYecgReport.cs create mode 100644 1200Gxml心电图绘制/服务/FlyHisEcgdataModel.cs create mode 100644 1200Gxml心电图绘制/服务/FlyHisTokenMsg.cs create mode 100644 1200Gxml心电图绘制/服务/commonOptions.cs create mode 100644 1200Gxml心电图绘制/服务/loginPara.cs create mode 100644 1200Gxml心电图绘制/服务/tokenMsg.cs diff --git a/1200Gxml心电图绘制/App.config b/1200Gxml心电图绘制/App.config index ea3c09c..480323a 100644 --- a/1200Gxml心电图绘制/App.config +++ b/1200Gxml心电图绘制/App.config @@ -14,5 +14,10 @@ + + + + + diff --git a/1200Gxml心电图绘制/心电图绘制.csproj b/1200Gxml心电图绘制/心电图绘制.csproj index 11ef250..8c26c12 100644 --- a/1200Gxml心电图绘制/心电图绘制.csproj +++ b/1200Gxml心电图绘制/心电图绘制.csproj @@ -82,11 +82,17 @@ + + + + + + Form3.cs diff --git a/1200Gxml心电图绘制/服务/FLYecgReport.cs b/1200Gxml心电图绘制/服务/FLYecgReport.cs new file mode 100644 index 0000000..f52d8c2 --- /dev/null +++ b/1200Gxml心电图绘制/服务/FLYecgReport.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _1200Gxml心电图绘制 +{ + public class FLYecgReport + { + public string appointmentId { get; set; } + public string reportTime { get; set;} + public string reportDoctor { get; set; } + public string reportDoctorCode { get; set; } + public string reportDepartmentCode { get; set; } + public string reportDepartmentName { get; set; } + public string reportHospitalCode { get; set; } + public string reportHospitalName { get; set; } + public string dcmFileUrl { get; set; } + public string isAbnormal { get; set; }//是否正常 是否异常0阳性1阴性 + public string remark { get; set; }//结论 + public int status { get; set; } + } +} diff --git a/1200Gxml心电图绘制/服务/FlyHisEcgdataModel.cs b/1200Gxml心电图绘制/服务/FlyHisEcgdataModel.cs new file mode 100644 index 0000000..4f41eca --- /dev/null +++ b/1200Gxml心电图绘制/服务/FlyHisEcgdataModel.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _1200Gxml心电图绘制 +{ + public class FlyHisEcgDataModel + { + public int total { get; set; } + public List rows { get; set; } + } + + public class patientInfo + { + public string jianchaid { get; set; } + public string jianchabh { get; set; } + public string name { get; set; } + public string sfz { get; set; } + public string birthdate { get; set; } + public int age { get; set; } + public string sex { get; set; } + public string yiyuanname { get; set; } + public string yiyuanid { get; set; } + public string kaifangsj { get; set; } + public string departmentCode { get; set; } + public string departmentName { get; set; } + public string resDoctorName { get; set; } + public string resDoctorCode { get; set; } + public string nation { get; set; } + public string patientCode { get; set; } + public string visitType { get; set; } + public List projects { get; set; } + public int code { get; set; } + public string msg { get; set; } + } + + public class projectsInfo + { + public string jianchamingcheng { get; set; } + public string nhbm { get; set; } + public string category { get; set;} + } +} diff --git a/1200Gxml心电图绘制/服务/FlyHisTokenMsg.cs b/1200Gxml心电图绘制/服务/FlyHisTokenMsg.cs new file mode 100644 index 0000000..b84f6cc --- /dev/null +++ b/1200Gxml心电图绘制/服务/FlyHisTokenMsg.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _1200Gxml心电图绘制 +{ + + //福乐云HIS的token信息结构 + public class FlyHisTokenMsgModel + { + public int code { get; set; } + public dataInfo data { get; set; } + } + + public class dataInfo + { + public string access_token { get; set; } + public string expires_in { get; set; } + } + +} diff --git a/1200Gxml心电图绘制/服务/PatientInfo.cs b/1200Gxml心电图绘制/服务/PatientInfo.cs index d48cdb2..8458ad2 100644 --- a/1200Gxml心电图绘制/服务/PatientInfo.cs +++ b/1200Gxml心电图绘制/服务/PatientInfo.cs @@ -43,7 +43,13 @@ namespace 心电图绘制 public string orgname { get; set; } + public string orgid { get; set; } + public string ptimelimit { get; set; } - + + public string isAbnormal { get; set; } + + + } } diff --git a/1200Gxml心电图绘制/服务/UniversalFun.cs b/1200Gxml心电图绘制/服务/UniversalFun.cs index fad1879..4570552 100644 --- a/1200Gxml心电图绘制/服务/UniversalFun.cs +++ b/1200Gxml心电图绘制/服务/UniversalFun.cs @@ -22,8 +22,8 @@ namespace 心电图绘制 /// public static System.Drawing.Image ConvertFromBase64String(string base64String) { - string [] baseary= base64String.Split(','); - if(baseary.Length<2) + string[] baseary = base64String.Split(','); + if (baseary.Length < 2) { return null; } @@ -81,7 +81,7 @@ namespace 心电图绘制 // 打开文档以便添加内容 document.Open(); // 设置页面尺寸与图像尺寸一致 - iTextSharp.text.Rectangle pageSize = new iTextSharp.text.Rectangle(bitmap.Width, bitmap.Height+50); + iTextSharp.text.Rectangle pageSize = new iTextSharp.text.Rectangle(bitmap.Width, bitmap.Height + 50); document.SetPageSize(pageSize); // 将Bitmap转换为iTextSharp的Image对象 iTextSharp.text.Image image = ConvertBitmapToImageSharp(bitmap); @@ -111,7 +111,7 @@ namespace 心电图绘制 /// /// 文本文件的 URL /// 返回文件内容的字符串,如果失败则返回 null - public static string GetTextFileContent(string url) + public static string GetTextFileContent(string url) { // 忽略 SSL 证书错误 ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true; @@ -129,5 +129,7 @@ namespace 心电图绘制 } } } + + } } diff --git a/1200Gxml心电图绘制/服务/commonOptions.cs b/1200Gxml心电图绘制/服务/commonOptions.cs new file mode 100644 index 0000000..de8d852 --- /dev/null +++ b/1200Gxml心电图绘制/服务/commonOptions.cs @@ -0,0 +1,636 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Drawing; +using System.Drawing.Imaging; +using System.IO; +using System.Linq; +using System.Net; + +using System.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; + + +namespace _1200Gxml心电图绘制 +{ + public class commonOptions + { + /// + /// 获取福乐云HIS系统的token + /// + /// + /// + /// + public static string getHisToken(string url1,string appkey, string appsecret) + { + Dictionary dic = new Dictionary(); + dic.Add("appkey", appkey); + dic.Add("appsecret", appsecret); + + string resultV = commonOptions.PostFile3(url1, dic); + FlyHisTokenMsgModel tm = JsonConvert.DeserializeObject(resultV); + return tm.data.access_token; + } + + /// + /// 获取福乐云HIS系统的患者基本信息 + /// + /// + /// + /// + public static FlyHisEcgDataModel GetHisEcgData(string url1, string Yiyuanid, string kaifangsj,string token) + { + Dictionary dic = new Dictionary(); + dic.Add("Yiyuanid", Yiyuanid); + dic.Add("kaifangsj", kaifangsj); + dic.Add("token", token); + string resultV = commonOptions.PostFile3(url1, dic); + FlyHisEcgDataModel tm = JsonConvert.DeserializeObject(resultV); + return tm; + } + + + + /// + /// post form-data 参数 + /// + /// + /// + /// + public static string PostFile3(string url, Dictionary items) + { + string boundary = DateTime.Now.Ticks.ToString("x"); + HttpWebRequest request = null; + //如果是发送HTTPS请求               + if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase)) + { + //处理HttpWebRequest访问https有安全证书的问题( 请求被中止: 未能创建 SSL/TLS 安全通道。) + ServicePointManager.ServerCertificateValidationCallback += (s, cert, chain, sslPolicyErrors) => true; + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; + + //ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult); + request = WebRequest.Create(url) as HttpWebRequest; + request.ProtocolVersion = HttpVersion.Version10; + } + else + { + request = WebRequest.Create(url) as HttpWebRequest; + } + + request.ContentType = "multipart/form-data; boundary=" + boundary; + request.Method = "POST"; + // request.Headers.Add("Authorization", "Bearer " + token); + // 最后的结束符 + var endBoundary = Encoding.UTF8.GetBytes("\r\n--" + boundary + "--\r\n"); + + //文件数据 + string fileFormdataTemplate = + "--" + boundary + + "\r\nContent-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"" + + "\r\nContent-Type: application/octet-stream" + + "\r\n\r\n"; + + //文本数据 + string dataFormdataTemplate = + "\r\n--" + boundary + + "\r\nContent-Disposition: form-data; name=\"{0}\"" + + "\r\n\r\n{1}"; + //FileInfo fi = new FileInfo(filePath); + //string fileHeader = string.Format(fileFormdataTemplate, "file", fi.Name); + //var fileBytes = Encoding.UTF8.GetBytes(fileHeader); + + using (var postStream = new MemoryStream()) + { + ////写入文件格式串 + //postStream.Write(fileBytes, 0, fileBytes.Length); + + //#region 写入文件流 + //using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) + //{ + // byte[] buffer = new byte[1024]; + // int bytesRead = 0; + // while ((bytesRead = fs.Read(buffer, 0, buffer.Length)) != 0) + // { + // postStream.Write(buffer, 0, bytesRead); + // } + //} + //#endregion + + #region 写入其他表单参数 + foreach (KeyValuePair key in items) + { + var p = string.Format(dataFormdataTemplate, key.Key, key.Value); + var bp = Encoding.UTF8.GetBytes(p); + postStream.Write(bp, 0, bp.Length); + } + #endregion + + //写入结束边界 + postStream.Write(endBoundary, 0, endBoundary.Length); + + #region 写入流 + + request.ContentLength = postStream.Length; + postStream.Position = 0; + using (Stream ds = request.GetRequestStream()) + { + byte[] buffer = new byte[1024]; + int bytesRead = 0; + while ((bytesRead = postStream.Read(buffer, 0, buffer.Length)) != 0) + { + ds.Write(buffer, 0, bytesRead); + } + } + #endregion + + #region 获取返回值 + + string result = string.Empty; + using (HttpWebResponse rep = (HttpWebResponse)request.GetResponse()) + { + using (Stream ds = rep.GetResponseStream()) + { + using (StreamReader sr = new StreamReader(ds)) + { + result = sr.ReadToEnd(); + } + } + } + + return result; + + #endregion + } + } + + + + //public static string PostMoths8(string url, string appkey, string appsecret) + //{ + // string strURL = url; + // HttpWebRequest request; + // request = (HttpWebRequest)WebRequest.Create(strURL); + // request.Method = "POST"; + // request.ContentType = "application/json;charset=UTF-8"; + // string paraUrlCoded = param; + // byte[] payload; + // payload = Encoding.UTF8.GetBytes(paraUrlCoded); + // request.ContentLength = payload.Length; + // Stream writer = request.GetRequestStream(); + // writer.Write(payload, 0, payload.Length); + // writer.Close(); + // System.Net.HttpWebResponse response; + // response = (System.Net.HttpWebResponse)request.GetResponse(); + // System.IO.Stream s; + // s = response.GetResponseStream(); + // string StrDate = ""; + // string strValue = ""; + // StreamReader Reader = new StreamReader(s, Encoding.UTF8); + // while ((StrDate = Reader.ReadLine()) != null) + // { + // strValue += StrDate + "\r\n"; + // } + // return strValue; + //} + + + /// + /// 获取福乐云的token + /// + /// + /// + /// + public static string gettoken(string username, string pwd, string url1) + { + loginPara lp = new loginPara(); + lp.username = username; + lp.password = commonOptions.Encrypt(pwd);//非对称公钥加密 + string loginJson = JsonConvert.SerializeObject(lp); + string resultV = commonOptions.PostMoths(url1, loginJson); + tokenMsg tm = JsonConvert.DeserializeObject(resultV); + return tm.data; + } + + // 非对称公钥加密 使用公钥加密数据 + public static string Encrypt(string plainText) + { + string base64EncryptedData = string.Empty; + // 创建 RSA 密钥对 + using (var rsa = new RSACryptoServiceProvider()) + { + // 获取公钥 + string publicKey = rsa.ToXmlString(false); + // 加载公钥 + rsa.FromXmlString("gMIre8vicEqHjwhyrMUSMbwyR+STy9vGDyqmOd9xA4JI9/ghqAQAl5T9R8z87gwKMosPsEaRf4/1tg8taa/q2g0xwcZZ3dZlBzDSQ7k7I7t/Cv+m3YUZDp1U1TooSw8NzX3MQ36u1uiniWAUMvA0PT17dR6dxsQmMdDN4xSJO/0=AQAB"); + // 将待加密数据转换成字节数组 + byte[] dataToEncrypt = Encoding.UTF8.GetBytes(plainText); + // 使用公钥加密数据 + byte[] encryptedData = rsa.Encrypt(dataToEncrypt, false); + // 将加密后的数据转换为 Base64 编码的字符串 + base64EncryptedData = Convert.ToBase64String(encryptedData); + string aaa = "公钥:" + publicKey; + + } + return base64EncryptedData; + //byte[] encryptedData = Encoding.UTF8.GetBytes(plainText); + //using (RSA rsa = RSA.Create()) + //{ + // rsa.ImportParameters(publicKey); + // // return rsa.Encrypt(data, RSAEncryptionPadding.Pkcs1); + // return Encoding.UTF8.GetString(rsa.Encrypt(encryptedData, RSAEncryptionPadding.Pkcs1)); + //} + } + +//---------------------------------------------------------------------------------------------------------------------------- + + + + + + // 非对称公钥加密 使用公钥加密数据 + public static string Encrypt(string plainText, RSAParameters publicKey) + { + byte[] encryptedData = Encoding.UTF8.GetBytes(plainText); + using (RSA rsa = RSA.Create()) + { + rsa.ImportParameters(publicKey); + // return rsa.Encrypt(data, RSAEncryptionPadding.Pkcs1); + return Encoding.UTF8.GetString(rsa.Encrypt(encryptedData, RSAEncryptionPadding.Pkcs1)); + } + } + + + /// + /// DES加密 + /// + /// 加密数据 + /// 8位字符的密钥字符串 + /// 8位字符的初始化向量字符串 + /// + public static string DESEncrypt(string data, string key, string iv) + { + byte[] byKey = System.Text.ASCIIEncoding.ASCII.GetBytes(key); + byte[] byIV = System.Text.ASCIIEncoding.ASCII.GetBytes(iv); + + DESCryptoServiceProvider cryptoProvider = new DESCryptoServiceProvider(); + int i = cryptoProvider.KeySize; + MemoryStream ms = new MemoryStream(); + CryptoStream cst = new CryptoStream(ms, cryptoProvider.CreateEncryptor(byKey, byIV), CryptoStreamMode.Write); + + StreamWriter sw = new StreamWriter(cst); + sw.Write(data); + sw.Flush(); + cst.FlushFinalBlock(); + sw.Flush(); + return Convert.ToBase64String(ms.GetBuffer(), 0, (int)ms.Length); + } + + /// + /// DES解密 + /// + /// 解密数据 + /// 8位字符的密钥字符串(需要和加密时相同) + /// 8位字符的初始化向量字符串(需要和加密时相同) + /// + public static string DESDecrypt(string data, string key, string iv) + { + byte[] byKey = System.Text.ASCIIEncoding.ASCII.GetBytes(key); + byte[] byIV = System.Text.ASCIIEncoding.ASCII.GetBytes(iv); + + byte[] byEnc; + try + { + byEnc = Convert.FromBase64String(data); + } + catch + { + return null; + } + + DESCryptoServiceProvider cryptoProvider = new DESCryptoServiceProvider(); + MemoryStream ms = new MemoryStream(byEnc); + CryptoStream cst = new CryptoStream(ms, cryptoProvider.CreateDecryptor(byKey, byIV), CryptoStreamMode.Read); + StreamReader sr = new StreamReader(cst); + return sr.ReadToEnd(); + } + + public static string PostMoths(string url, string param) + { + string strURL = url; + HttpWebRequest request; + request = (HttpWebRequest)WebRequest.Create(strURL); + request.Method = "POST"; + request.ContentType = "application/json;charset=UTF-8"; + string paraUrlCoded = param; + byte[] payload; + payload = Encoding.UTF8.GetBytes(paraUrlCoded); + request.ContentLength = payload.Length; + Stream writer = request.GetRequestStream(); + writer.Write(payload, 0, payload.Length); + writer.Close(); + System.Net.HttpWebResponse response; + response = (System.Net.HttpWebResponse)request.GetResponse(); + System.IO.Stream s; + s = response.GetResponseStream(); + string StrDate = ""; + string strValue = ""; + StreamReader Reader = new StreamReader(s, Encoding.UTF8); + while ((StrDate = Reader.ReadLine()) != null) + { + strValue += StrDate + "\r\n"; + } + return strValue; + } + + + /// + /// + /// + /// + /// + /// + /// + public static string PostByParas(string url, string token, string jsonContent) + { + string result = ""; + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Method = "POST"; + req.ContentType = "application/json"; + req.Headers.Add("Authorization", "Bearer " + token); + byte[] data = Encoding.UTF8.GetBytes(jsonContent); + req.ContentLength = data.Length; + using (Stream reqStream = req.GetRequestStream()) + { + reqStream.Write(data, 0, data.Length); + reqStream.Close(); + } + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + //获取响应内容 + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + result = reader.ReadToEnd(); + } + return result; + } + + + + + + + + /// + /// 海军给的 http 上传文件 好用版 + /// + /// + /// + /// + /// + /// + public static string PostFile2(string url, string filePath, Dictionary items, string token) + { + string boundary = DateTime.Now.Ticks.ToString("x"); + HttpWebRequest request = null; + //如果是发送HTTPS请求               + if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase)) + { + //处理HttpWebRequest访问https有安全证书的问题( 请求被中止: 未能创建 SSL/TLS 安全通道。) + ServicePointManager.ServerCertificateValidationCallback += (s, cert, chain, sslPolicyErrors) => true; + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; + + //ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult); + request = WebRequest.Create(url) as HttpWebRequest; + request.ProtocolVersion = HttpVersion.Version10; + } + else + { + request = WebRequest.Create(url) as HttpWebRequest; + } + + request.ContentType = "multipart/form-data; boundary=" + boundary; + request.Method = "POST"; + request.Headers.Add("Authorization", "Bearer " + token); + // 最后的结束符 + var endBoundary = Encoding.UTF8.GetBytes("\r\n--" + boundary + "--\r\n"); + + //文件数据 + string fileFormdataTemplate = + "--" + boundary + + "\r\nContent-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"" + + "\r\nContent-Type: application/octet-stream" + + "\r\n\r\n"; + + //文本数据 + string dataFormdataTemplate = + "\r\n--" + boundary + + "\r\nContent-Disposition: form-data; name=\"{0}\"" + + "\r\n\r\n{1}"; + FileInfo fi = new FileInfo(filePath); + string fileHeader = string.Format(fileFormdataTemplate, "file", fi.Name); + var fileBytes = Encoding.UTF8.GetBytes(fileHeader); + + using (var postStream = new MemoryStream()) + { + //写入文件格式串 + postStream.Write(fileBytes, 0, fileBytes.Length); + + #region 写入文件流 + using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) + { + byte[] buffer = new byte[1024]; + int bytesRead = 0; + while ((bytesRead = fs.Read(buffer, 0, buffer.Length)) != 0) + { + postStream.Write(buffer, 0, bytesRead); + } + } + #endregion + + #region 写入其他表单参数 + foreach (KeyValuePair key in items) + { + var p = string.Format(dataFormdataTemplate, key.Key, key.Value); + var bp = Encoding.UTF8.GetBytes(p); + postStream.Write(bp, 0, bp.Length); + + //System.Diagnostics.Debug.WriteLine(p); + } + #endregion + + //写入结束边界 + postStream.Write(endBoundary, 0, endBoundary.Length); + + #region 写入流 + + request.ContentLength = postStream.Length; + postStream.Position = 0; + using (Stream ds = request.GetRequestStream()) + { + byte[] buffer = new byte[1024]; + int bytesRead = 0; + while ((bytesRead = postStream.Read(buffer, 0, buffer.Length)) != 0) + { + ds.Write(buffer, 0, bytesRead); + } + } + #endregion + + #region 获取返回值 + + string result = string.Empty; + using (HttpWebResponse rep = (HttpWebResponse)request.GetResponse()) + { + using (Stream ds = rep.GetResponseStream()) + { + using (StreamReader sr = new StreamReader(ds)) + { + result = sr.ReadToEnd(); + } + } + } + + return result; + + #endregion + } + } + + + + + + + + + /// + /// 指定Post地址使用Get 方式获取全部字符串 + /// + /// 请求后台地址 + /// + public static string PostByParas(string url, Dictionary dic) + { + string result = ""; + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); + req.Method = "POST"; + req.ContentType = "application/x-www-form-urlencoded"; + #region 添加Post 参数 + StringBuilder builder = new StringBuilder(); + int i = 0; + foreach (var item in dic) + { + if (i > 0) + builder.Append("&"); + builder.AppendFormat("{0}={1}", item.Key, item.Value); + i++; + } + byte[] data = Encoding.UTF8.GetBytes(builder.ToString()); + req.ContentLength = data.Length; + using (Stream reqStream = req.GetRequestStream()) + { + reqStream.Write(data, 0, data.Length); + reqStream.Close(); + } + #endregion + HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); + Stream stream = resp.GetResponseStream(); + //获取响应内容 + using (StreamReader reader = new StreamReader(stream, Encoding.UTF8)) + { + result = reader.ReadToEnd(); + } + return result; + } + + + + public static string HttpGet(string url) + { + //ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult); + Encoding encoding = Encoding.UTF8; + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); + request.Method = "GET"; + request.Accept = "text/html, application/xhtml+xml, */*"; + request.ContentType = "application/json"; + + HttpWebResponse response = (HttpWebResponse)request.GetResponse(); + using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8)) + { + return reader.ReadToEnd(); + } + } + + + //public static Image CreateBarCode(string content) + //{ + // using (var barcode = new Barcode() + // { + // //true显示content,false反之 + // IncludeLabel = true, + + // //content的位置 + // Alignment = AlignmentPositions.CENTER, + + // //条形码的宽高 + // Width = 145, + // Height = 39, + + // //类型 + // RotateFlipType = RotateFlipType.RotateNoneFlipNone, + + // //颜色 + // BackColor = Color.White, + // ForeColor = Color.Black, + // }) + // { + // return barcode.Encode(TYPE.CODE128B, content); + // } + //} + + + /// + /// 格式化磁盘 + /// + /// 盘符名称:C:、D:、E:、F: + /// + public static bool FormatDisk(string DiskName) + { + ProcessStartInfo processStartInfo = new ProcessStartInfo("cmd.exe"); + processStartInfo.RedirectStandardInput = true; + processStartInfo.RedirectStandardOutput = true; + processStartInfo.UseShellExecute = false; + Process process = Process.Start(processStartInfo); + if (process != null) + { + process.StandardInput.WriteLine($"FORMAT {DiskName} /y /FS:FAT32 /V:BMECG /Q"); + process.StandardInput.Close(); + string outputString = process.StandardOutput.ReadToEnd(); + if (outputString.Contains("已完成")) + { + return true; + } + } + return false; + } + + + + + //public static void PdfToImages(string pdfFilePath, string outputFolder) + //{ + + // string imgpath = @"D:/PDFFF/"; + // var pathList = GetPdfAllPageImgs(pdfFilePath, imgpath, "11556699"); + + //} + + + + + + + +} +} diff --git a/1200Gxml心电图绘制/服务/loginPara.cs b/1200Gxml心电图绘制/服务/loginPara.cs new file mode 100644 index 0000000..76146de --- /dev/null +++ b/1200Gxml心电图绘制/服务/loginPara.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _1200Gxml心电图绘制 +{ + public class loginPara + { + public string username { get; set; } + public string password { get; set; } + } +} diff --git a/1200Gxml心电图绘制/服务/print.cs b/1200Gxml心电图绘制/服务/print.cs index 9c6b078..b55de97 100644 --- a/1200Gxml心电图绘制/服务/print.cs +++ b/1200Gxml心电图绘制/服务/print.cs @@ -325,5 +325,42 @@ namespace 心电图绘制 _calibrationVoltage = 8.0; } } + + + + /// + /// 上传诊断结论到福乐云平台 + /// + public string FlySubmit3(PatientInfo patientInfo) + { + //上传报告到福乐云平台 + FLYecgReport FER = new FLYecgReport(); + FER.appointmentId = patientInfo.regid; + FER.reportTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + FER.reportDoctor = patientInfo.doctorName;//判读医生 + FER.reportDoctorCode = "2247"; + FER.reportDepartmentCode = "4758"; + FER.reportDepartmentName = "判读中心"; + FER.reportHospitalCode = patientInfo.orgid; + FER.reportHospitalName = patientInfo.orgname; + FER.dcmFileUrl = "";//不传URL了 + FER.isAbnormal = patientInfo.isAbnormal; + FER.remark = patientInfo.diagContent; + FER.status = 4;//状态 0-已预约 1-已登记 2-审核中 3-已上传报告 4-查看报告8-撤回登记 9-取消预约 7-检查中 5-.放弃诊断 6.-已退费 + return submitInfoToFLY6(FER); + } + + + /// + /// 提交诊断结论到福乐云 + /// + /// + public string submitInfoToFLY6(FLYecgReport FER) + { + string jsonContent = JsonConvert.SerializeObject(FER); + string token = commonOptions.gettoken(ConfigurationManager.AppSettings["flowygtUserName"], ConfigurationManager.AppSettings["flowygtUserPwd"], ConfigurationManager.AppSettings["flowygtLoginUrl"]);//获取token + string resultStr = commonOptions.PostByParas(ConfigurationManager.AppSettings["flowygtReportAddUrl"], token, jsonContent); + return resultStr; + } } } diff --git a/1200Gxml心电图绘制/服务/tokenMsg.cs b/1200Gxml心电图绘制/服务/tokenMsg.cs new file mode 100644 index 0000000..4e53a03 --- /dev/null +++ b/1200Gxml心电图绘制/服务/tokenMsg.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace _1200Gxml心电图绘制 +{ + internal class tokenMsg + { + public string msg { get; set; } + public string code { get; set; } + public string data { get; set; } + } +}