From 45cd2c182c20cda4ba35f3411346f7eab320f140 Mon Sep 17 00:00:00 2001 From: lxd <1004405501@qq.com> Date: Tue, 31 Dec 2024 10:56:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=9A=E5=8A=A1=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1200gFtp/DbHelperMySQL.cs | 640 ++++++++++++++++++++++++ 1200gFtp/Form1.cs | 259 ++++++---- 1200gFtp/Hl7EcgOptions.cs | 1 + 1200gFtp/MySQLHelper.cs | 84 ++++ 1200gFtp/app.config | 11 +- 1200gFtp/云心电ECG数据解析服务端.csproj | 6 + 6 files changed, 904 insertions(+), 97 deletions(-) create mode 100644 1200gFtp/DbHelperMySQL.cs create mode 100644 1200gFtp/MySQLHelper.cs diff --git a/1200gFtp/DbHelperMySQL.cs b/1200gFtp/DbHelperMySQL.cs new file mode 100644 index 0000000..a04e519 --- /dev/null +++ b/1200gFtp/DbHelperMySQL.cs @@ -0,0 +1,640 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using MySql.Data.MySqlClient; + +namespace 云心电ECG数据解析服务端 +{ + /// + /// 数据访问抽象基础类 + /// + public abstract class DbHelperMySQL + { + //数据库连接字符串(web.config来配置),可以动态更改connectionString支持多数据库. + public static string connectionString = ConfigurationManager.ConnectionStrings["MYSQLConnectionString"].ConnectionString;//连接语句,请按照自己的连接修改 + public DbHelperMySQL() + { + } + + #region 公用方法 + /// + /// 得到最大值 + /// + /// + /// + /// + public static int GetMaxID(string FieldName, string TableName) + { + string strsql = "select max(" + FieldName + ")+1 from " + TableName; + object obj = GetSingle(strsql); + if (obj == null) + { + return 1; + } + else + { + return int.Parse(obj.ToString()); + } + } + /// + /// 是否存在 + /// + /// + /// + public static bool Exists(string strSql) + { + object obj = GetSingle(strSql); + int cmdresult; + if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value))) + { + cmdresult = 0; + } + else + { + cmdresult = int.Parse(obj.ToString()); + } + if (cmdresult == 0) + { + return false; + } + else + { + return true; + } + } + /// + /// 是否存在(基于MySqlParameter) + /// + /// + /// + /// + public static bool Exists(string strSql, params MySqlParameter[] cmdParms) + { + object obj = GetSingle(strSql, cmdParms); + int cmdresult; + if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value))) + { + cmdresult = 0; + } + else + { + cmdresult = int.Parse(obj.ToString()); + } + if (cmdresult == 0) + { + return false; + } + else + { + return true; + } + } + #endregion + + #region 执行简单SQL语句 + + /// + /// 执行SQL语句,返回影响的记录数 + /// + /// SQL语句 + /// 影响的记录数 + public static int ExecuteSql(string SQLString) + { + using (MySqlConnection connection = new MySqlConnection(connectionString)) + { + using (MySqlCommand cmd = new MySqlCommand(SQLString, connection)) + { + try + { + connection.Open(); + int rows = cmd.ExecuteNonQuery(); + return rows; + } + catch (MySql.Data.MySqlClient.MySqlException e) + { + connection.Close(); + throw e; + } + } + } + } + + public static int ExecuteSqlByTime(string SQLString, int Times) + { + using (MySqlConnection connection = new MySqlConnection(connectionString)) + { + using (MySqlCommand cmd = new MySqlCommand(SQLString, connection)) + { + try + { + connection.Open(); + cmd.CommandTimeout = Times; + int rows = cmd.ExecuteNonQuery(); + return rows; + } + catch (MySql.Data.MySqlClient.MySqlException e) + { + connection.Close(); + throw e; + } + } + } + } + + /// + /// 执行多条SQL语句,实现数据库事务。 + /// + /// 多条SQL语句 + public static int ExecuteSqlTran(List SQLStringList) + { + using (MySqlConnection conn = new MySqlConnection(connectionString)) + { + conn.Open(); + MySqlCommand cmd = new MySqlCommand(); + cmd.Connection = conn; + MySqlTransaction tx = conn.BeginTransaction(); + cmd.Transaction = tx; + try + { + int count = 0; + for (int n = 0; n < SQLStringList.Count; n++) + { + string strsql = SQLStringList[n]; + if (strsql.Trim().Length > 1) + { + cmd.CommandText = strsql; + count += cmd.ExecuteNonQuery(); + } + } + tx.Commit(); + return count; + } + catch(Exception ex) + { + tx.Rollback(); + return 0; + } + } + } + /// + /// 执行带一个存储过程参数的的SQL语句。 + /// + /// SQL语句 + /// 参数内容,比如一个字段是格式复杂的文章,有特殊符号,可以通过这个方式添加 + /// 影响的记录数 + public static int ExecuteSql(string SQLString, string content) + { + using (MySqlConnection connection = new MySqlConnection(connectionString)) + { + MySqlCommand cmd = new MySqlCommand(SQLString, connection); + MySql.Data.MySqlClient.MySqlParameter myParameter = new MySql.Data.MySqlClient.MySqlParameter("@content", SqlDbType.NText); + myParameter.Value = content; + cmd.Parameters.Add(myParameter); + try + { + connection.Open(); + int rows = cmd.ExecuteNonQuery(); + return rows; + } + catch (MySql.Data.MySqlClient.MySqlException e) + { + throw e; + } + finally + { + cmd.Dispose(); + connection.Close(); + } + } + } + /// + /// 执行带一个存储过程参数的的SQL语句。 + /// + /// SQL语句 + /// 参数内容,比如一个字段是格式复杂的文章,有特殊符号,可以通过这个方式添加 + /// 影响的记录数 + public static object ExecuteSqlGet(string SQLString, string content) + { + using (MySqlConnection connection = new MySqlConnection(connectionString)) + { + MySqlCommand cmd = new MySqlCommand(SQLString, connection); + MySql.Data.MySqlClient.MySqlParameter myParameter = new MySql.Data.MySqlClient.MySqlParameter("@content", SqlDbType.NText); + myParameter.Value = content; + cmd.Parameters.Add(myParameter); + try + { + connection.Open(); + object obj = cmd.ExecuteScalar(); + if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value))) + { + return null; + } + else + { + return obj; + } + } + catch (MySql.Data.MySqlClient.MySqlException e) + { + throw e; + } + finally + { + cmd.Dispose(); + connection.Close(); + } + } + } + /// + /// 向数据库里插入图像格式的字段(和上面情况类似的另一种实例) + /// + /// SQL语句 + /// 图像字节,数据库的字段类型为image的情况 + /// 影响的记录数 + public static int ExecuteSqlInsertImg(string strSQL, byte[] fs) + { + using (MySqlConnection connection = new MySqlConnection(connectionString)) + { + MySqlCommand cmd = new MySqlCommand(strSQL, connection); + MySql.Data.MySqlClient.MySqlParameter myParameter = new MySql.Data.MySqlClient.MySqlParameter("@fs", SqlDbType.Image); + myParameter.Value = fs; + cmd.Parameters.Add(myParameter); + try + { + connection.Open(); + int rows = cmd.ExecuteNonQuery(); + return rows; + } + catch (MySql.Data.MySqlClient.MySqlException e) + { + throw e; + } + finally + { + cmd.Dispose(); + connection.Close(); + } + } + } + + /// + /// 执行一条计算查询结果语句,返回查询结果(object)。 + /// + /// 计算查询结果语句 + /// 查询结果(object) + public static object GetSingle(string SQLString) + { + using (MySqlConnection connection = new MySqlConnection(connectionString)) + { + using (MySqlCommand cmd = new MySqlCommand(SQLString, connection)) + { + try + { + connection.Open(); + object obj = cmd.ExecuteScalar(); + if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value))) + { + return null; + } + else + { + return obj; + } + } + catch (MySql.Data.MySqlClient.MySqlException e) + { + connection.Close(); + throw e; + } + } + } + } + public static object GetSingle(string SQLString, int Times) + { + using (MySqlConnection connection = new MySqlConnection(connectionString)) + { + using (MySqlCommand cmd = new MySqlCommand(SQLString, connection)) + { + try + { + connection.Open(); + cmd.CommandTimeout = Times; + object obj = cmd.ExecuteScalar(); + if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value))) + { + return null; + } + else + { + return obj; + } + } + catch (MySql.Data.MySqlClient.MySqlException e) + { + connection.Close(); + throw e; + } + } + } + } + /// + /// 执行查询语句,返回MySqlDataReader ( 注意:调用该方法后,一定要对MySqlDataReader进行Close ) + /// + /// 查询语句 + /// MySqlDataReader + public static MySqlDataReader ExecuteReader(string strSQL) + { + MySqlConnection connection = new MySqlConnection(connectionString); + MySqlCommand cmd = new MySqlCommand(strSQL, connection); + try + { + connection.Open(); + MySqlDataReader myReader = cmd.ExecuteReader(CommandBehavior.CloseConnection); + return myReader; + } + catch (MySql.Data.MySqlClient.MySqlException e) + { + throw e; + } + + } + /// + /// 执行查询语句,返回DataSet + /// + /// 查询语句 + /// DataSet + public static DataSet Query(string SQLString) + { + using (MySqlConnection connection = new MySqlConnection(connectionString)) + { + DataSet ds = new DataSet(); + try + { + connection.Open(); + MySqlDataAdapter command = new MySqlDataAdapter(SQLString, connection); + command.Fill(ds, "ds"); + } + catch (MySql.Data.MySqlClient.MySqlException ex) + { + throw new Exception(ex.Message); + } + return ds; + } + } + public static DataSet Query(string SQLString, int Times) + { + using (MySqlConnection connection = new MySqlConnection(connectionString)) + { + DataSet ds = new DataSet(); + try + { + connection.Open(); + MySqlDataAdapter command = new MySqlDataAdapter(SQLString, connection); + command.SelectCommand.CommandTimeout = Times; + command.Fill(ds, "ds"); + } + catch (MySql.Data.MySqlClient.MySqlException ex) + { + throw new Exception(ex.Message); + } + return ds; + } + } + + + + #endregion + + #region 执行带参数的SQL语句 + + /// + /// 执行SQL语句,返回影响的记录数 + /// + /// SQL语句 + /// 影响的记录数 + public static int ExecuteSql(string SQLString, params MySqlParameter[] cmdParms) + { + using (MySqlConnection connection = new MySqlConnection(connectionString)) + { + using (MySqlCommand cmd = new MySqlCommand()) + { + try + { + PrepareCommand(cmd, connection, null, SQLString, cmdParms); + int rows = cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + return rows; + } + catch (MySql.Data.MySqlClient.MySqlException e) + { + throw e; + } + } + } + } + + + /// + /// 执行多条SQL语句,实现数据库事务。 + /// + /// SQL语句的哈希表(key为sql语句,value是该语句的MySqlParameter[]) + public static void ExecuteSqlTran(Hashtable SQLStringList) + { + using (MySqlConnection conn = new MySqlConnection(connectionString)) + { + conn.Open(); + using (MySqlTransaction trans = conn.BeginTransaction()) + { + MySqlCommand cmd = new MySqlCommand(); + try + { + //循环 + foreach (DictionaryEntry myDE in SQLStringList) + { + string cmdText = myDE.Key.ToString(); + MySqlParameter[] cmdParms = (MySqlParameter[])myDE.Value; + PrepareCommand(cmd, conn, trans, cmdText, cmdParms); + int val = cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); + } + trans.Commit(); + } + catch + { + trans.Rollback(); + throw; + } + } + } + } + /// + /// 执行多条SQL语句,实现数据库事务。 + /// + /// SQL语句的哈希表(key为sql语句,value是该语句的MySqlParameter[]) + public static void ExecuteSqlTranWithIndentity(Hashtable SQLStringList) + { + using (MySqlConnection conn = new MySqlConnection(connectionString)) + { + conn.Open(); + using (MySqlTransaction trans = conn.BeginTransaction()) + { + MySqlCommand cmd = new MySqlCommand(); + try + { + int indentity = 0; + //循环 + foreach (DictionaryEntry myDE in SQLStringList) + { + string cmdText = myDE.Key.ToString(); + MySqlParameter[] cmdParms = (MySqlParameter[])myDE.Value; + foreach (MySqlParameter q in cmdParms) + { + if (q.Direction == ParameterDirection.InputOutput) + { + q.Value = indentity; + } + } + PrepareCommand(cmd, conn, trans, cmdText, cmdParms); + int val = cmd.ExecuteNonQuery(); + foreach (MySqlParameter q in cmdParms) + { + if (q.Direction == ParameterDirection.Output) + { + indentity = Convert.ToInt32(q.Value); + } + } + cmd.Parameters.Clear(); + } + trans.Commit(); + } + catch + { + trans.Rollback(); + throw; + } + } + } + } + /// + /// 执行一条计算查询结果语句,返回查询结果(object)。 + /// + /// 计算查询结果语句 + /// 查询结果(object) + public static object GetSingle(string SQLString, params MySqlParameter[] cmdParms) + { + using (MySqlConnection connection = new MySqlConnection(connectionString)) + { + using (MySqlCommand cmd = new MySqlCommand()) + { + try + { + PrepareCommand(cmd, connection, null, SQLString, cmdParms); + object obj = cmd.ExecuteScalar(); + cmd.Parameters.Clear(); + if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value))) + { + return null; + } + else + { + return obj; + } + } + catch (MySql.Data.MySqlClient.MySqlException e) + { + throw e; + } + } + } + } + + /// + /// 执行查询语句,返回MySqlDataReader ( 注意:调用该方法后,一定要对MySqlDataReader进行Close ) + /// + /// 查询语句 + /// MySqlDataReader + public static MySqlDataReader ExecuteReader(string SQLString, params MySqlParameter[] cmdParms) + { + MySqlConnection connection = new MySqlConnection(connectionString); + MySqlCommand cmd = new MySqlCommand(); + try + { + PrepareCommand(cmd, connection, null, SQLString, cmdParms); + MySqlDataReader myReader = cmd.ExecuteReader(CommandBehavior.CloseConnection); + cmd.Parameters.Clear(); + return myReader; + } + catch (MySql.Data.MySqlClient.MySqlException e) + { + throw e; + } + // finally + // { + // cmd.Dispose(); + // connection.Close(); + // } + + } + + /// + /// 执行查询语句,返回DataSet + /// + /// 查询语句 + /// DataSet + public static DataSet Query(string SQLString, params MySqlParameter[] cmdParms) + { + using (MySqlConnection connection = new MySqlConnection(connectionString)) + { + MySqlCommand cmd = new MySqlCommand(); + PrepareCommand(cmd, connection, null, SQLString, cmdParms); + using (MySqlDataAdapter da = new MySqlDataAdapter(cmd)) + { + DataSet ds = new DataSet(); + try + { + da.Fill(ds, "ds"); + cmd.Parameters.Clear(); + } + catch (MySql.Data.MySqlClient.MySqlException ex) + { + throw new Exception(ex.Message); + } + return ds; + } + } + } + + + private static void PrepareCommand(MySqlCommand cmd, MySqlConnection conn, MySqlTransaction trans, string cmdText, MySqlParameter[] cmdParms) + { + if (conn.State != ConnectionState.Open) + conn.Open(); + cmd.Connection = conn; + cmd.CommandText = cmdText; + if (trans != null) + cmd.Transaction = trans; + cmd.CommandType = CommandType.Text;//cmdType; + if (cmdParms != null) + { + + + foreach (MySqlParameter parameter in cmdParms) + { + if ((parameter.Direction == ParameterDirection.InputOutput || parameter.Direction == ParameterDirection.Input) && + (parameter.Value == null)) + { + parameter.Value = DBNull.Value; + } + cmd.Parameters.Add(parameter); + } + } + } + + #endregion + + + + } +} diff --git a/1200gFtp/Form1.cs b/1200gFtp/Form1.cs index 8efa1a8..c09040e 100644 --- a/1200gFtp/Form1.cs +++ b/1200gFtp/Form1.cs @@ -170,7 +170,7 @@ namespace _1200gFtp /// /// 上传诊断结论到福乐云平台 /// - string FlySubmit(string patientId,int status1) + string FlySubmit(string patientId, int status1) { //上传报告到福乐云平台 FLYecgReport FER = new FLYecgReport(); @@ -199,25 +199,26 @@ namespace _1200gFtp /// 提交患者信息到福乐云 /// /// - string submitPatientInfoToFLY(string patientId1) + string submitPatientInfoToFLY(string patientId1,string examid,string orgid,string orgname) { - string sql = "select * from Tb_PatientInfo where PatientID='" + patientId1 + "'"; - DataTable dt_1 = SqliteOptions_sql.CreateInstance().ExcuteSqlite(sql); + + string sql = "select * from tb_patientexamlist where regId='" + patientId1 + "' and examId='"+ examid + "'"; + DataTable dt_1 = MySQLHelper.GetTable(sql); PatientMd PMD = new PatientMd(); string orgSN = string.Empty; string orgName = string.Empty; if (dt_1.Rows.Count == 1) { PMD.ID = dt_1.Rows[0]["ID"].ToString(); - PMD.PatientID = dt_1.Rows[0]["PatientID"].ToString(); - PMD.PatientName = dt_1.Rows[0]["PatientName"].ToString(); - PMD.P_Id = dt_1.Rows[0]["P_Id"].ToString(); - PMD.Gender = dt_1.Rows[0]["Gender"].ToString(); - PMD.Birthday = dt_1.Rows[0]["Birthday"].ToString(); - PMD.Folk = dt_1.Rows[0]["Folk"].ToString(); - DataTable dt_org = SqliteOptions_sql.CreateInstance().ExcuteSqlite("select * from tb_org where orgID='" + dt_1.Rows[0]["orgID"].ToString() + "'"); - orgSN = dt_org.Rows[0]["orgSN"].ToString(); - orgName = dt_org.Rows[0]["orgName"].ToString(); + PMD.PatientID = dt_1.Rows[0]["regId"].ToString(); + PMD.PatientName = dt_1.Rows[0]["pName"].ToString(); + PMD.P_Id ="-"; + PMD.Gender = dt_1.Rows[0]["gender"].ToString(); + PMD.Birthday = dt_1.Rows[0]["birthday"].ToString(); + PMD.Folk =""; + // DataTable dt_org = SqliteOptions_sql.CreateInstance().ExcuteSqlite("select * from tb_org where orgID='" + dt_1.Rows[0]["orgID"].ToString() + "'"); + orgSN = orgid; + orgName = orgname; } patientInfoFLY pfy = new patientInfoFLY(); @@ -303,10 +304,8 @@ namespace _1200gFtp //将分析参数写入到分析参数表中 //----------------------------------- if (string.IsNullOrEmpty(alp.patientid)) - alp.patientid = Guid.NewGuid().ToString(); - string ecgAnalysisJson = JsonConvert.SerializeObject(alp);//把心电数据保存成json文件 - string jsonFilePath = fi1.DirectoryName + @"\" + Guid.NewGuid().ToString() + ".txt"; - File.WriteAllText(jsonFilePath, ecgAnalysisJson, Encoding.UTF8);//保存json文件到指定的目标统一http访问目录下 + alp.patientid = Guid.NewGuid().ToString("N"); + if (File.Exists(ecgFilePath)) { fi1.Delete();//转成jpg后 将XML图删掉 @@ -327,6 +326,7 @@ namespace _1200gFtp FileInfo fi = new FileInfo(ecgFilePath); string patientId2 = alp.patientid; string patientname = alp.patientName; + string examid = string.Empty; //if (fi.Name.Contains("[")) // patientId2 = fi.Name.Substring(fi.Name.IndexOf('[') + 1, fi.Name.IndexOf(']') - fi.Name.IndexOf('[') - 1); //else @@ -336,75 +336,146 @@ namespace _1200gFtp //if (fi.Name.IndexOf('[') > 0) // patientname = fi.Name.Substring(0, fi.Name.IndexOf('[')); string orgSN = fi.Directory.Name; - DataTable dt_org1 = SqliteOptions_sql.CreateInstance().ExcuteSqlite("select * from tb_org where orgSN='" + orgSN + "'"); + DataTable dt_org1 = MySQLHelper.GetTable("select * from tb_org where orgSN='" + orgSN + "'"); + // DataTable dt_org1 = DbHelperMySQL.Query(a).Tables[0]; + // DataTable dt_org1 = SqliteOptions_sql.CreateInstance().ExcuteSqlite("select * from tb_org where orgSN='" + orgSN + "'"); string orgid = ""; string highLevelOrgid = ""; string inHisCode = ""; + string oragname = string.Empty; if (dt_org1.Rows.Count == 1) { orgid = dt_org1.Rows[0]["orgID"].ToString(); highLevelOrgid = dt_org1.Rows[0]["highLevelOrgID"].ToString(); inHisCode = dt_org1.Rows[0]["inHisCode"].ToString().Trim();//在福乐云his中的机构代码 + oragname = dt_org1.Rows[0]["orgName"].ToString(); } string queryDate = fi.CreationTime.ToString("yyyy-MM-dd");//文件的创建时间作为 his中患者信息查询的 查询日期 //获取福乐云HIS接口的token - string hisToken = commonOptions.getHisToken(ConfigurationManager.AppSettings["hisGetEcgTokenUrl"], ConfigurationManager.AppSettings["hisAppkey"], ConfigurationManager.AppSettings["appsecret"]); + string hisToken = commonOptions.getHisToken(ConfigurationManager.AppSettings["hisGetEcgTokenUrl"], ConfigurationManager.AppSettings["hisAppkey"], ConfigurationManager.AppSettings["appsecret"]); FlyHisEcgDataModel FHEDM = commonOptions.GetHisEcgData(ConfigurationManager.AppSettings["hisGetEcgDataUrl"], inHisCode, queryDate, hisToken); // 将患者姓名 和 his结果里的患者姓名进行对比 如果姓名匹配 那么就将这个人的 patientid 修改为 his结果里的 jianchaid patientInfo pi = ComparePatientInfo(FHEDM, patientname); - if(pi!=null) + if (pi != null) + { patientId2 = pi.jianchaid;//检查id作为患者patientid + // alp.patientid = patientId2; + examid = pi.jianchabh; + } + if (string.IsNullOrEmpty(examid)) + examid = Guid.NewGuid().ToString("N"); //string returnStrx = FlySubmit(patientId2,7);//收到心电数据后,将心电数据状态传到福乐云平台 string newEcgFilePath1 = fi.DirectoryName + @"\" + patientId2 + fi.Extension; fi.CopyTo(newEcgFilePath1); + #region 插入业务数据 + //插入tb_patientexamlist表数据 + string idStr = Guid.NewGuid().ToString(); + string gender1 = pi != null ? pi.sex : ""; + string birthday1 = pi != null ? pi.birthdate : "null"; + StringBuilder patientexamlist = new StringBuilder(); + patientexamlist.Append(" insert into "); + patientexamlist.Append(" tb_patientexamlist "); + patientexamlist.Append("("); + patientexamlist.Append("ID,examId,pName,gender,birthday,examDate,deviceType,se_dc,examItemName,reportstatus,applicationDate,orgName,orgId,createDate,"); + patientexamlist.Append("examItemCode,regId"); + patientexamlist.Append(")"); + patientexamlist.Append("values ("); + patientexamlist.Append("'" + Guid.NewGuid().ToString("N") + "','" + examid + "','" + patientname + "','" + gender1 + "'," + birthday1 + ",'" + fi.CreationTime.ToString("yyyy-MM-dd HH:mm:ss") + "',"); + patientexamlist.Append("'ECG','1/1','心电图','待分析','" + fi.CreationTime.ToString("yyyy-MM-dd HH:mm:ss") + "','" + oragname + "','" + orgid + "','" + fi.CreationTime.ToString("yyyy-MM-dd HH:mm:ss") + "',"); + patientexamlist.Append(" '','"+ patientId2 + "'"); + patientexamlist.Append(")"); + bool bol = MySQLHelper.ExecuteNonQuery(patientexamlist.ToString()); - string sql = "select * from Tb_PatientInfo where PatientID='" + patientId2 + "' and orgID='" + orgid + "' and isXinDianTu = '1'"; - DataTable dt_getData = SqliteOptions_sql.CreateInstance().ExcuteSqlite(sql); - if (dt_getData.Rows.Count == 1) + //先创建ftp文件夹 + FtpHelper.MakeDir(patientId2); + //上传心电图xml转换的图片 + string returnStr = FtpHelper.FileUpLoad(fi.FullName, patientId2, patientId2 + fi.Extension); + if (returnStr == "上传成功") { - string patientId = dt_getData.Rows[0]["PatientID"].ToString(); - string sql1 = "update Tb_PatientInfo set CreateDate='" + fi.CreationTime.ToString("yyyy-MM-dd HH:mm:ss") + "' where PatientID='" + patientId + "'"; - SqliteOptions_sql.CreateInstance().SqliteUpdate(sql1); - //string fileMd5 = GetMD5HashFromFile(fi.FullName); - //string returnMd5 = oss.PutObject("aecgdatas", patientId + fi.Extension, ecgFilePath); - string returnStr = FtpHelper.FileUpLoad(fi.FullName, "", patientId2 + fi.Extension);//把生成的心电图和心电json文件 放到一个统一的http访问的一个文件夹里 - if (returnStr == "上传成功") + textBox2.AppendText(patientexamlist.ToString() + "文件: " + fi.Name + " 上传成功:" + patientId2 + fi.Extension + " | " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n"); + fi.Delete(); + } + //把生成的json文件进行上传和插入表 + string ecgAnalysisJson = JsonConvert.SerializeObject(alp);//把心电数据保存成json文件 + string jsonFilePath = fi1.DirectoryName + @"\" + Guid.NewGuid().ToString() + ".txt"; + File.WriteAllText(jsonFilePath, ecgAnalysisJson, Encoding.UTF8);//保存json文件到指定的目标统一http访问目录下 + FileInfo filejson = new FileInfo(jsonFilePath); + if (filejson.Exists) + { + //插入表tb_ecganalysisparas + StringBuilder ecganalysisparas = new StringBuilder(); + ecganalysisparas.Append(" insert into "); + ecganalysisparas.Append(" tb_ecganalysisparas "); + ecganalysisparas.Append("("); + ecganalysisparas.Append(" ID,orgId,examId,CollectionTime,HR,P_Axle,QRS_Axle,T_Axle,PTimeLimit,PR,qrsTimeLimit,QT,QTC,RV5,SV1,RV5_SV1,snapshotTime,"); + ecganalysisparas.Append(" ecgJsonDataFilePath,createDate,regId"); + ecganalysisparas.Append(")"); + ecganalysisparas.Append("values ("); + ecganalysisparas.Append(" '" + Guid.NewGuid().ToString("N") + "','" + orgid + "','" + examid + "','" + fi.CreationTime.ToString("yyyy-MM-dd HH:mm:ss") + "',"); + ecganalysisparas.Append(" '" + alp.heartRate + "','" + alp.P_degrees + "','" + alp.QRS_degrees + "','" + alp.T_degrees + "','" + alp.P + "','" + alp.PR + "','" + alp.QRS + "',"); + ecganalysisparas.Append("'" + alp.QT + "','" + alp.QTc + "','" + alp.RV5 + "','" + alp.SV1 + "','" + alp.RV5PLUSSV1 + "','" + fi.CreationTime.ToString("yyyy-MM-dd HH:mm:ss") + "',"); + ecganalysisparas.Append(" '" + ConfigurationManager.AppSettings["jsonurl"] + patientId2+"/"+ patientId2 + filejson.Extension + "','" + fi.CreationTime.ToString("yyyy-MM-dd HH:mm:ss") + "','" + patientId2 + "'"); + ecganalysisparas.Append(" )"); + bool bolecganalysisparas = MySQLHelper.ExecuteNonQuery(ecganalysisparas.ToString()); + //上传心电图xml转换的图片 + string returnStrjson = FtpHelper.FileUpLoad(filejson.FullName, patientId2, patientId2 + filejson.Extension); + if (returnStrjson == "上传成功") { - textBox2.AppendText(sql1 + "文件: " + fi.Name + "修改成功:" + patientId + fi.Extension + " | " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n"); - fi.Delete(); - // fi_1.Delete(); - } - } - else - { - string idStr = Guid.NewGuid().ToString(); - string gender1 = pi != null ? pi.sex : ""; - string birthday1 = pi != null ? pi.birthdate : ""; - string sql2 = "insert into Tb_PatientInfo (ID,PatientID,CreateDate,isXinDianTu,orgID,highLevelOrgID,medicalSN,PatientName,Gender,Birthday) values ('" + idStr + "','" + patientId2 + "','" + fi.CreationTime.ToString("yyyy-MM-dd HH:mm:ss") + "','1','" + orgid + "','" + highLevelOrgid + "','','" + patientname + "','" + gender1 + "','" + birthday1 + "')"; - SqliteOptions_sql.CreateInstance().SqliteAdd(sql2); - //string fileMd5 = GetMD5HashFromFile(fi.FullName); - //string returnMd5 = oss.PutObject("aecgdatas", patientId2 + fi.Extension, ecgFilePath); - string returnStr = FtpHelper.FileUpLoad(fi.FullName, "", patientId2 + fi.Extension); - if (returnStr == "上传成功") - { - textBox2.AppendText(sql2 + "文件: " + fi.Name + " 上传成功:" + patientId2 + fi.Extension + " | " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n"); - fi.Delete(); - // fi_1.Delete(); + textBox2.AppendText("文件: " + filejson.Name + " 上传成功:" + patientId2 + filejson.Extension + " | " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n"); + filejson.Delete(); } } + #endregion + #region 之前的 + //string sql = "select * from Tb_PatientInfo where PatientID='" + patientId2 + "' and orgID='" + orgid + "' and isXinDianTu = '1'"; + //DataTable dt_getData = SqliteOptions_sql.CreateInstance().ExcuteSqlite(sql); + //if (dt_getData.Rows.Count == 1) + //{ + // string patientId = dt_getData.Rows[0]["PatientID"].ToString(); + // string sql1 = "update Tb_PatientInfo set CreateDate='" + fi.CreationTime.ToString("yyyy-MM-dd HH:mm:ss") + "' where PatientID='" + patientId + "'"; + // SqliteOptions_sql.CreateInstance().SqliteUpdate(sql1); + // //string fileMd5 = GetMD5HashFromFile(fi.FullName); + // //string returnMd5 = oss.PutObject("aecgdatas", patientId + fi.Extension, ecgFilePath); + // string returnStr = FtpHelper.FileUpLoad(fi.FullName, "", patientId2 + fi.Extension);//把生成的心电图和心电json文件 放到一个统一的http访问的一个文件夹里 + // if (returnStr == "上传成功") + // { + // textBox2.AppendText(sql1 + "文件: " + fi.Name + "修改成功:" + patientId + fi.Extension + " | " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n"); + // fi.Delete(); + // // fi_1.Delete(); + // } + //} + //else + //{ + // string idStr = Guid.NewGuid().ToString(); + // string gender1 = pi != null ? pi.sex : ""; + // string birthday1 = pi != null ? pi.birthdate : ""; + // string sql2 = "insert into Tb_PatientInfo (ID,PatientID,CreateDate,isXinDianTu,orgID,highLevelOrgID,medicalSN,PatientName,Gender,Birthday) values ('" + idStr + "','" + patientId2 + "','" + fi.CreationTime.ToString("yyyy-MM-dd HH:mm:ss") + "','1','" + orgid + "','" + highLevelOrgid + "','','" + patientname + "','" + gender1 + "','" + birthday1 + "')"; + // SqliteOptions_sql.CreateInstance().SqliteAdd(sql2); + // //string fileMd5 = GetMD5HashFromFile(fi.FullName); + // //string returnMd5 = oss.PutObject("aecgdatas", patientId2 + fi.Extension, ecgFilePath); + // string returnStr = FtpHelper.FileUpLoad(fi.FullName, "", patientId2 + fi.Extension); + // if (returnStr == "上传成功") + // { + // textBox2.AppendText(sql2 + "文件: " + fi.Name + " 上传成功:" + patientId2 + fi.Extension + " | " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n"); + // fi.Delete(); + // // fi_1.Delete(); + // } + //} + #endregion - string returnStrxs= submitPatientInfoToFLY(patientId2);//先把患者信息提交到福乐云医共体平台 + + string returnStrxs = submitPatientInfoToFLY(patientId2,examid,orgid, oragname);//先把患者信息提交到福乐云医共体平台 string returnStrx = FlySubmit(patientId2, 3);//收到心电数据后,将心电数据状态传到福乐云平台 - FileInfo fi_1= new FileInfo(newEcgFilePath1); + FileInfo fi_1 = new FileInfo(newEcgFilePath1); if (fi_1.Exists) { FlyEcgReportFileSubmit(patientId2, newEcgFilePath1);//不管三七二十一,先把收到的心电图文件到福乐云平台 fi_1.Delete(); } - + //if (!fi_1.Exists) // FlyEcgReportFileSubmit(patientId2, ecgFilePath);//不管三七二十一,先把收到的心电图文件到福乐云平台 //else @@ -751,33 +822,33 @@ namespace _1200gFtp private void timer1_Tick(object sender, EventArgs e) { ftpDataJieXi();//解析FTP传上来的xml - // startExe(); + // startExe(); } void startExe() { //try //{ - string exePath = File.ReadAllText(Application.StartupPath + @"\exePath.txt",Encoding.Default); - // MessageBox.Show(exePath); - Process[] mProcs = Process.GetProcessesByName(@"HbAutoDiagnosisPro"); - Process[] mProcs1 = Process.GetProcessesByName(@"HL_Holter"); - if (mProcs.Length == 0) - { - if (mProcs1.Length > 0) - foreach (var p in mProcs1) - p.Kill(); - Process.Start(exePath); + string exePath = File.ReadAllText(Application.StartupPath + @"\exePath.txt", Encoding.Default); + // MessageBox.Show(exePath); + Process[] mProcs = Process.GetProcessesByName(@"HbAutoDiagnosisPro"); + Process[] mProcs1 = Process.GetProcessesByName(@"HL_Holter"); + if (mProcs.Length == 0) + { + if (mProcs1.Length > 0) + foreach (var p in mProcs1) + p.Kill(); + Process.Start(exePath); - //System.Diagnostics.Process myprocess = new System.Diagnostics.Process(); - //System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(exePath, ""); - //myprocess.StartInfo = startInfo; - //myprocess.StartInfo.UseShellExecute = false; - //myprocess.Start(); - } + //System.Diagnostics.Process myprocess = new System.Diagnostics.Process(); + //System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(exePath, ""); + //myprocess.StartInfo = startInfo; + //myprocess.StartInfo.UseShellExecute = false; + //myprocess.Start(); + } //} //catch (Exception ex) { MessageBox.Show(ex.ToString()); } - + } //解析FTP传上来的xml @@ -788,7 +859,7 @@ namespace _1200gFtp { if (!string.IsNullOrEmpty(textBox1.Text)) { - string[] diList=Directory.GetDirectories(textBox1.Text); + string[] diList = Directory.GetDirectories(textBox1.Text); foreach (string dir in diList) { List fileList = GetFiles(dir); @@ -802,7 +873,7 @@ namespace _1200gFtp } } - + } catch (Exception ex) @@ -941,7 +1012,7 @@ namespace _1200gFtp var ea = (BasicDeliverEventArgs)consumer.Queue.Dequeue(); var body = ea.Body; var message = Encoding.UTF8.GetString(body); - DoData("接收到MQ消息:"+ message + "\r\n"); + DoData("接收到MQ消息:" + message + "\r\n"); submitHis03(message);// 提交数据到 his03 Thread.Sleep(2000); string messageStr = message; @@ -965,41 +1036,41 @@ namespace _1200gFtp void submitHis03(string jsonStr) { panduReturnModel prm = JsonConvert.DeserializeObject(jsonStr); - DataTable dt01 = SqliteOptions_sql.CreateInstance().ExcuteSqlite("select * from guanxinPatients where applyId='"+prm.applyId+"'"); + DataTable dt01 = SqliteOptions_sql.CreateInstance().ExcuteSqlite("select * from guanxinPatients where applyId='" + prm.applyId + "'"); if (dt01.Rows.Count > 0) { - string jsonStr2= DecodeBase64("utf-8", dt01.Rows[0]["patientJson"].ToString()); + string jsonStr2 = DecodeBase64("utf-8", dt01.Rows[0]["patientJson"].ToString()); his03Model hm = JsonConvert.DeserializeObject(jsonStr2); hm.pdfUrl = dt01.Rows[0]["pdfUrl"].ToString(); hm.dicomUrl = dt01.Rows[0]["dicomUrl"].ToString(); - hm.testDate =Convert.ToDateTime(prm.reportTime).ToString("yyyyMMddTHHmmss"); + hm.testDate = Convert.ToDateTime(prm.reportTime).ToString("yyyyMMddTHHmmss"); hm.evidence = prm.reportFeatures;// 心电图xml里的自动结论 hm.conclusion = prm.reportConclusion;// 如果没有判读的 xml 这个字段为空即可。 string jsonStr1 = JsonConvert.SerializeObject(hm); jsonStr1 = ("[" + jsonStr1 + "]"); //string returnStr = netOptions.HttpPost("http://his.hebjcws.com:7086/pm-s-report/ECG/HIS03", jsonStr1, "POST"); string returnStr = netOptions.HttpPost(apiList.his03, jsonStr1, "POST"); - DoData(returnStr+"远程判读已传给his03|MQ数据接收中:" + jsonStr1 + "\r\n"); + DoData(returnStr + "远程判读已传给his03|MQ数据接收中:" + jsonStr1 + "\r\n"); } } private void button7_Click(object sender, EventArgs e) { - // string yy = "eyJzdGF0dXMiOjAsImFnZSI6MjQsImNvbmNsdXNpb24iOiIiLCJldmlkZW5jZSI6IumrmOS+p+WjgeW/g+ail+mZiOaXp+acnzvnlLXovbTovbvluqblj7PlgY87IiwidGVzdERhdGUiOiIyMDE5MTIyMVQxNDE1NTciLCJkaWNvbVVybCI6Imh0dHA6Ly8xMC4xMy4xLjM2OjkwODkvQjQzQjE2NUQ0QjJGRkY1MjZCNkM3RTUyOEQzQUJDOUUuWE1MIiwicGRmVXJsIjoiaHR0cDovLzEwLjEzLjEuMzY6OTA4OS9CNDNCMTY1RDRCMkZGRjUyNkI2QzdFNTI4RDNBQkM5RS5qcGciLCJwZXJzb25ObyI6IjIwMDAwMDYwMTgxMzE3Iiwic291cmNlVHlwZSI6IjIiLCJwZXJzb25JZCI6IjhhOGQ4MWEzNmZjMmMxOWUwMTcwNTZhZDhkNTMyYTI0IiwidHlwZSI6IjIiLCJwb3NJZCI6IjUwY2U5Y2M1LTYzMmMtN2M4My1lMDUzLTEyNjQwMTBhZGRmNSIsInNhbXBsZXN0YXRlIjoi5ZCmIiwicGF0aWVudFR5cGUiOiLkvY/pmaIiLCJkaXNlYXNlIjoi5LiK5ZG85ZC46YGT5oSf5p+TIiwiYXBwbHlUaW1lIjoiMjAyMDAyMThUMTMxMzE3IiwiaXRlbVByaWNlIjoiOCIsIml0ZW1OYW1lIjoi5bi46KeE5b+D55S15Zu+5qOA5p+lIiwiaXRlbUlkIjoiOGE4ZDgxYTE2YTljMmM0YTAxNmM3OTIwNWM4NjUyYjkiLCJkb2N0b3JOYW1lIjoi5byg5by6IiwiZG9jdG9ySWQiOiIwN2RjZjU5Zi1hZTQ5LTRjZWYtOGE4MC0yYTVkMGM5OTljNDAiLCJkZXBhcnRtZW50SWQiOiJkM2ZkZGIyOC03NWY2LTQ0MzItYWQ4Yi01ODg3MDgyNzk0MDYiLCJiZWROdW0iOiIxNeWupDQy5bqKIiwiYWdlVW5pdCI6IuWygSIsInNleCI6IuWlsyIsImlkZW50aXR5Q29kZSI6IjEzMDI4MzE5OTUxMDI5NzcwOCIsIm5hbWUiOiLmnpfnj4oiLCJoaXNDb2RlIjoiMjAwMDAwNjAiLCJpZCI6IjhhOGQ4MWEzNmZjMmMxOWUwMTcwNTZiNmZjOGEyYTdlIn0="; - // string jsonStr111= DecodeBase64("utf-8", yy); - //// string jsonStr111 = "{\"applyId\":\"8a8d81aa7058ab1601705c85c8630024\",\"applyStatus\":2,\"auditorTime\":\"2020-02-19 16:24:48\",\"auditorUserId\":\"8a81e39f6d6d77b9017056bd4c83130b\",\"auditorUserName\":\"测试医生\",\"crisis\":\"0\",\"diagnosticPosId\":\"8a81e39f6d6d77b901703d17065a0cfd\",\"patientBirthday\":\"1996-02-19 08:00:00\",\"patientId\":\"130283199510297708\",\"patientName\":\"林珊\",\"patientSex\":\"女\",\"positive\":\"2\",\"reportConclusion\":\"测试数据。\",\"reportFeatures\":\"测试数据。\",\"reportPdf\":\"http://10.13.1.42:9096/ygt-diagnose-service/diagnose_res/pdf/20200219/8a8d81aa705b812901705c85c8b1001d.pdf\",\"reportTime\":\"2020-02-19 16:24:48\",\"reportUserId\":\"8a81e39f6d6d77b9017056bd4c83130b\",\"reportUserName\":\"测试医生\",\"supplierId\":\"8a8d81aa703d250601703d7c10f40004\"}"; - // // string jsonStr111 = "{\"status\":0,\"age\":40,\"conclusion\":\"\",\"evidence\":\"高侧壁心梗陈旧期;电轴轻度右偏;\",\"testDate\":\"20191221T141557\",\"dicomUrl\":\"https://zjkecgdatas.oss-cn-beijing.aliyuncs.com/D8B72AB5BD32A797B9D4AAF87D5E184B.XML\",\"pdfUrl\":\"https://zjkecgdatas.oss-cn-beijing.aliyuncs.com/D8B72AB5BD32A797B9D4AAF87D5E184B.jpg\",\"personNo\":\"2002140007143601\",\"sourceType\":\"1\",\"personId\":\"2c9a9cad7041fe9f017042d6500c02ec\",\"type\":\"2\",\"posId\":\"2c9580826a94e012016a968c21920164\",\"samplestate\":\"否\",\"patientType\":\"门诊\",\"disease\":\"沙门氏菌(亚利桑那)小肠炎\",\"applyTime\":\"20200214T163601\",\"itemPrice\":\"3\",\"itemName\":\"无创心电监测\",\"itemId\":\"ff8080816bbacdf9016bc00b83f90333\",\"doctorName\":\"基层医生\",\"departmentName\":\"全科\",\"doctorId\":\"2c9580826ab8eca6016ab9db50600000\",\"departmentId\":\"2c9580826a94e012016a968df29601bd\",\"ageUnit\":\"岁\",\"birthday\":\"1980-01-01 00:00:00.0\",\"sex\":\"男\",\"identityCode\":\"450101198001010772\",\"name\":\"联调测试004\",\"hisCode\":\"2002140007\",\"id\":\"2c9a9cad7041fe9f017042d727a702fb\"}"; - // his03Model hm = JsonConvert.DeserializeObject(jsonStr111); - // hm.pdfUrl = "http://10.13.1.42:9096/ygt-diagnose-service/diagnose_res/pdf/20200219/8a8d81aa705b812901705c85c8b1001d.pdf"; - // //hm.dicomUrl = "https://zjkecgdatas.oss-cn-beijing.aliyuncs.com/8B63CCE5E3856D86460CB4CDA856C63C.XML"; - // hm.testDate = "20200219T165609"; - // hm.evidence = "高侧壁心梗陈旧期;电轴轻度右偏;";// 心电图xml里的自动结论 - // hm.conclusion = "测试数据。";// 如果没有判读的 xml 这个字段为空即可。 - //// hm.posId = "50ce9cc5-632c-7c83-e053-1264010addf5"; - // string jsonStr = JsonConvert.SerializeObject(hm); - // jsonStr = ("[" + jsonStr + "]"); + // string yy = "eyJzdGF0dXMiOjAsImFnZSI6MjQsImNvbmNsdXNpb24iOiIiLCJldmlkZW5jZSI6IumrmOS+p+WjgeW/g+ail+mZiOaXp+acnzvnlLXovbTovbvluqblj7PlgY87IiwidGVzdERhdGUiOiIyMDE5MTIyMVQxNDE1NTciLCJkaWNvbVVybCI6Imh0dHA6Ly8xMC4xMy4xLjM2OjkwODkvQjQzQjE2NUQ0QjJGRkY1MjZCNkM3RTUyOEQzQUJDOUUuWE1MIiwicGRmVXJsIjoiaHR0cDovLzEwLjEzLjEuMzY6OTA4OS9CNDNCMTY1RDRCMkZGRjUyNkI2QzdFNTI4RDNBQkM5RS5qcGciLCJwZXJzb25ObyI6IjIwMDAwMDYwMTgxMzE3Iiwic291cmNlVHlwZSI6IjIiLCJwZXJzb25JZCI6IjhhOGQ4MWEzNmZjMmMxOWUwMTcwNTZhZDhkNTMyYTI0IiwidHlwZSI6IjIiLCJwb3NJZCI6IjUwY2U5Y2M1LTYzMmMtN2M4My1lMDUzLTEyNjQwMTBhZGRmNSIsInNhbXBsZXN0YXRlIjoi5ZCmIiwicGF0aWVudFR5cGUiOiLkvY/pmaIiLCJkaXNlYXNlIjoi5LiK5ZG85ZC46YGT5oSf5p+TIiwiYXBwbHlUaW1lIjoiMjAyMDAyMThUMTMxMzE3IiwiaXRlbVByaWNlIjoiOCIsIml0ZW1OYW1lIjoi5bi46KeE5b+D55S15Zu+5qOA5p+lIiwiaXRlbUlkIjoiOGE4ZDgxYTE2YTljMmM0YTAxNmM3OTIwNWM4NjUyYjkiLCJkb2N0b3JOYW1lIjoi5byg5by6IiwiZG9jdG9ySWQiOiIwN2RjZjU5Zi1hZTQ5LTRjZWYtOGE4MC0yYTVkMGM5OTljNDAiLCJkZXBhcnRtZW50SWQiOiJkM2ZkZGIyOC03NWY2LTQ0MzItYWQ4Yi01ODg3MDgyNzk0MDYiLCJiZWROdW0iOiIxNeWupDQy5bqKIiwiYWdlVW5pdCI6IuWygSIsInNleCI6IuWlsyIsImlkZW50aXR5Q29kZSI6IjEzMDI4MzE5OTUxMDI5NzcwOCIsIm5hbWUiOiLmnpfnj4oiLCJoaXNDb2RlIjoiMjAwMDAwNjAiLCJpZCI6IjhhOGQ4MWEzNmZjMmMxOWUwMTcwNTZiNmZjOGEyYTdlIn0="; + // string jsonStr111= DecodeBase64("utf-8", yy); + //// string jsonStr111 = "{\"applyId\":\"8a8d81aa7058ab1601705c85c8630024\",\"applyStatus\":2,\"auditorTime\":\"2020-02-19 16:24:48\",\"auditorUserId\":\"8a81e39f6d6d77b9017056bd4c83130b\",\"auditorUserName\":\"测试医生\",\"crisis\":\"0\",\"diagnosticPosId\":\"8a81e39f6d6d77b901703d17065a0cfd\",\"patientBirthday\":\"1996-02-19 08:00:00\",\"patientId\":\"130283199510297708\",\"patientName\":\"林珊\",\"patientSex\":\"女\",\"positive\":\"2\",\"reportConclusion\":\"测试数据。\",\"reportFeatures\":\"测试数据。\",\"reportPdf\":\"http://10.13.1.42:9096/ygt-diagnose-service/diagnose_res/pdf/20200219/8a8d81aa705b812901705c85c8b1001d.pdf\",\"reportTime\":\"2020-02-19 16:24:48\",\"reportUserId\":\"8a81e39f6d6d77b9017056bd4c83130b\",\"reportUserName\":\"测试医生\",\"supplierId\":\"8a8d81aa703d250601703d7c10f40004\"}"; + // // string jsonStr111 = "{\"status\":0,\"age\":40,\"conclusion\":\"\",\"evidence\":\"高侧壁心梗陈旧期;电轴轻度右偏;\",\"testDate\":\"20191221T141557\",\"dicomUrl\":\"https://zjkecgdatas.oss-cn-beijing.aliyuncs.com/D8B72AB5BD32A797B9D4AAF87D5E184B.XML\",\"pdfUrl\":\"https://zjkecgdatas.oss-cn-beijing.aliyuncs.com/D8B72AB5BD32A797B9D4AAF87D5E184B.jpg\",\"personNo\":\"2002140007143601\",\"sourceType\":\"1\",\"personId\":\"2c9a9cad7041fe9f017042d6500c02ec\",\"type\":\"2\",\"posId\":\"2c9580826a94e012016a968c21920164\",\"samplestate\":\"否\",\"patientType\":\"门诊\",\"disease\":\"沙门氏菌(亚利桑那)小肠炎\",\"applyTime\":\"20200214T163601\",\"itemPrice\":\"3\",\"itemName\":\"无创心电监测\",\"itemId\":\"ff8080816bbacdf9016bc00b83f90333\",\"doctorName\":\"基层医生\",\"departmentName\":\"全科\",\"doctorId\":\"2c9580826ab8eca6016ab9db50600000\",\"departmentId\":\"2c9580826a94e012016a968df29601bd\",\"ageUnit\":\"岁\",\"birthday\":\"1980-01-01 00:00:00.0\",\"sex\":\"男\",\"identityCode\":\"450101198001010772\",\"name\":\"联调测试004\",\"hisCode\":\"2002140007\",\"id\":\"2c9a9cad7041fe9f017042d727a702fb\"}"; + // his03Model hm = JsonConvert.DeserializeObject(jsonStr111); + // hm.pdfUrl = "http://10.13.1.42:9096/ygt-diagnose-service/diagnose_res/pdf/20200219/8a8d81aa705b812901705c85c8b1001d.pdf"; + // //hm.dicomUrl = "https://zjkecgdatas.oss-cn-beijing.aliyuncs.com/8B63CCE5E3856D86460CB4CDA856C63C.XML"; + // hm.testDate = "20200219T165609"; + // hm.evidence = "高侧壁心梗陈旧期;电轴轻度右偏;";// 心电图xml里的自动结论 + // hm.conclusion = "测试数据。";// 如果没有判读的 xml 这个字段为空即可。 + //// hm.posId = "50ce9cc5-632c-7c83-e053-1264010addf5"; + // string jsonStr = JsonConvert.SerializeObject(hm); + // jsonStr = ("[" + jsonStr + "]"); - // //string returnStr= netOptions.HttpPost("http://39.99.134.67:8080/pm-s-report/ECG/HIS03", jsonStr, "POST"); - // string returnStr = netOptions.HttpPost("http://47.104.9.78:8033/pm-s-report/ECG/HIS03", jsonStr, "POST"); + // //string returnStr= netOptions.HttpPost("http://39.99.134.67:8080/pm-s-report/ECG/HIS03", jsonStr, "POST"); + // string returnStr = netOptions.HttpPost("http://47.104.9.78:8033/pm-s-report/ECG/HIS03", jsonStr, "POST"); string tt = "[{\"status\":0,\"posId\":\"50ce9cc5-632c-7c83-e053-1264010addf5\",\"id\":\"8a8d81a36fc2c19e017056b3d1452a67\",\"testDate\":\"20200219T183430\",\"hisCode\":\"20000062\",\"name\":\"刘艳芳\",\"identityCode\":\"130728198911015028\",\"sex\":\"女\",\"age\":30,\"ageUnit\":\"岁\",\"itemId\":\"8a8d81a16a9c2c4a016c79205c8652b9\",\"itemName\":\"常规心电图检查\",\"departmentId\":\"d3fddb28-75f6-4432-ad8b-588708279406\",\"doctorId\":\"07dcf59f-ae49-4cef-8a80-2a5d0c999c40\",\"patientType\":\"住院\",\"evidence\":\"心电图正常\",\"pdfUrl\":\"http://10.13.1.36:9089/A375510E9601A39CB51628F14AD9E2EF.jpg\",\"optName\":null,\"auditName\":null,\"bedNum\":\"15室40床\",\"testNum\":null,\"barCode\":null,\"specimenType\":null,\"dicomUrl\":\"http://10.13.1.36:9089/A375510E9601A39CB51628F14AD9E2EF.XML\",\"conclusion\":\"心电图正常2\",\"departmentName\":null,\"doctorName\":\"张强\",\"birthday\":null,\"negaPosiTive\":null}]"; string returnStr = netOptions.HttpPost("http://47.104.9.78:8033/pm-s-report/ECG/HIS03", tt, "POST"); @@ -1015,7 +1086,7 @@ namespace _1200gFtp /// /// /// - private EcgViewModel ReadXMLByPath(string path) + private EcgViewModel ReadXMLByPath(string path) { var evm = new EcgViewModel { diff --git a/1200gFtp/Hl7EcgOptions.cs b/1200gFtp/Hl7EcgOptions.cs index 16d5deb..a730e59 100644 --- a/1200gFtp/Hl7EcgOptions.cs +++ b/1200gFtp/Hl7EcgOptions.cs @@ -203,6 +203,7 @@ namespace 云心电ECG数据解析服务端 ap.Gain = valueStr + "mm/mV"; } } + reader.Close(); return ap; } catch (Exception ex) { } diff --git a/1200gFtp/MySQLHelper.cs b/1200gFtp/MySQLHelper.cs new file mode 100644 index 0000000..80740b4 --- /dev/null +++ b/1200gFtp/MySQLHelper.cs @@ -0,0 +1,84 @@ +using MySql.Data.MySqlClient; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace 云心电ECG数据解析服务端 +{ + internal class MySQLHelper + { + + //连接数据库 + static string connectionStrings = ConfigurationManager.ConnectionStrings["MYSQLConnectionString"].ConnectionString;//连接语句,请按照自己的连接修改 + static MySqlConnection conn = new MySqlConnection(connectionStrings); + + private static void InitConn() + { + if (conn.State == ConnectionState.Closed) + { + conn.Open(); + } + else if (conn.State == ConnectionState.Broken) + { + conn.Close(); + conn.Open(); + } + } + + //增删改 + public static bool ExecuteNonQuery(string sqlStr) + { + InitConn(); + MySqlCommand cmd = new MySqlCommand(sqlStr, conn); + int result = cmd.ExecuteNonQuery(); + conn.Close(); + return result > 0; + } + + //执行集合函数 + public static object ExecuteScalar(string sqlStr) + { + InitConn(); + MySqlCommand cmd = new MySqlCommand(sqlStr, conn); + object result = cmd.ExecuteScalar(); + conn.Close(); + return result; + } + + //查询,获取DataTable + public static DataTable GetTable(string sqlStr) + { + InitConn(); + MySqlCommand cmd = new MySqlCommand(sqlStr); + cmd.Connection = conn; + MySqlDataAdapter da = new MySqlDataAdapter(cmd); + DataTable dt = new DataTable(); + da.Fill(dt); + conn.Close(); + return dt; + } + + //二进制数据增删改 + public static bool Binary(string sqlStr, Dictionary parameters) + { + InitConn(); + MySqlCommand cmd = new MySqlCommand(sqlStr, conn); + int i = 0; + foreach (KeyValuePair kvp in parameters) + { + cmd.Parameters.Add("@" + kvp.Key, MySqlDbType.LongBlob); + cmd.Parameters[i].Value = kvp.Value; + i++; + } + int result = cmd.ExecuteNonQuery(); + conn.Close(); + return result > 0; + } + } + + +} diff --git a/1200gFtp/app.config b/1200gFtp/app.config index 85cfd9f..7d7ee58 100644 --- a/1200gFtp/app.config +++ b/1200gFtp/app.config @@ -1,10 +1,13 @@ + + + - - - + + + @@ -15,5 +18,7 @@ + + diff --git a/1200gFtp/云心电ECG数据解析服务端.csproj b/1200gFtp/云心电ECG数据解析服务端.csproj index 83d94c2..3515037 100644 --- a/1200gFtp/云心电ECG数据解析服务端.csproj +++ b/1200gFtp/云心电ECG数据解析服务端.csproj @@ -46,6 +46,10 @@ ..\packages\Microsoft.Diagnostics.Tracing.EventSource.Redist.1.1.28\lib\net46\Microsoft.Diagnostics.Tracing.EventSource.dll True + + False + bin\Debug\MySql.Data.dll + False bin\Debug\Newtonsoft.Json.dll @@ -70,7 +74,9 @@ + +