442 lines
18 KiB
C#
442 lines
18 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using SOH.Kernel;
|
|
using EAS.Services;
|
|
using SOH.BLL;
|
|
using SOH.Entities;
|
|
using SOH.Data;
|
|
using SOH.Common;
|
|
using System.Text.RegularExpressions;
|
|
using SOH;
|
|
using System.Data.SqlClient;
|
|
using System.Data.OleDb;
|
|
|
|
|
|
namespace TiJianJieGuo
|
|
{
|
|
[ModuleAttribute(ModuleID = "8B8A98FC-AAD1-42A3-9C7F-50E2ECF12842", ModuleName = "DR登记处")]
|
|
public partial class frmDRDengJi : SOH.Window.baseChildForm
|
|
{
|
|
public frmDRDengJi()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private static SqlConnection connection;
|
|
private static SqlConnection connection1;
|
|
|
|
private static OleDbConnection zbconnection;
|
|
private static SqlConnection zbconnection1;
|
|
|
|
int fddm;
|
|
|
|
private void textBox1_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.KeyCode != Keys.Enter)
|
|
{
|
|
return;
|
|
}
|
|
string tmh = this.txtDr.Text.Trim();
|
|
|
|
var vservice = ServiceContainer.GetService<IZongJian>();
|
|
String data = vservice.GetCxDybgBytmh(tmh.Trim());
|
|
if (data.Equals("1"))
|
|
{
|
|
MessageBox.Show("条码号不存在!");
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
if (fddm == 1)
|
|
{
|
|
DataTable xxDt;
|
|
xxDt = Newtonsoft.Json.JsonConvert.DeserializeObject(data, typeof(DataTable)) as DataTable;
|
|
|
|
string strSelJcxm = "select * from t_jcxm where jcxmbm in (" +
|
|
" select xmbm from t_zhxmmx where zhbm in (select zhbm from t_tempdjxm where tm=" + xxDt.Rows[0]["tm"] + " " +
|
|
"and ksbm in (9,10,11,12,13,62,65)))";
|
|
|
|
DataTable dtJcxm = GetDataSet1(strSelJcxm);
|
|
if (dtJcxm.Rows.Count > 0)
|
|
{
|
|
|
|
string strMaxPatient = "SELECT isnull(max(pID)+1,1) FROM Patient with(UPDLOCK,PAGLOCK) ";
|
|
int pid = GetScalar(strMaxPatient);
|
|
|
|
string strMasStudy = "SELECT isnull(max(stuid)+1,1) FROM Study with(UPDLOCK,PAGLOCK)";
|
|
int stuid = GetScalar(strMasStudy);
|
|
|
|
List<string> SQLStringList = new List<string>();
|
|
|
|
int xb = Convert.ToInt32(xxDt.Rows[0]["xb"]) + 1;
|
|
string strInterPatinet = "INSERT INTO Patient(pID,pName,pNamePinYin,Sex,SexTitle,Weight,Birdat,Hadd,Hphone," +
|
|
" IDcard,PostCode,Email,BLKH,YBKH,JZKH,PY,His_PatientID,HisMZ_PatientID)" +
|
|
" values(" + pid + ",'" + xxDt.Rows[0]["xm"].ToString() + "','" + StrToPinyin.GetChineseFullSpell(xxDt.Rows[0]["xm"].ToString()) + "'," +
|
|
" '" + xb + "','" + xxDt.Rows[0]["xb1"].ToString() + "','','" + xxDt.Rows[0]["csrq"].ToString() + "','','','','','','','','','','','')";
|
|
|
|
|
|
|
|
string strInterStudy = "INSERT INTO study(PatientID,VID,StuID,Accnum, StuInsUID, rMOd, rItem, Status,schDate," +
|
|
" StuDate,SchStudyRoomID,Fee,FeeType,RegDate,rOperator,pImgID,HisStudyID," +
|
|
" TiaoXingMa,MDeptCode) Values" +
|
|
" (" + pid + ",0," + stuid + ", '" + pid + "','" + pid + "', 'XR','', '500', '" + DateTime.Now + "', '" + DateTime.Now + "','81', " +
|
|
" 0,'自费','" + DateTime.Now + "', '1', '" + xxDt.Rows[0]["tm"] + "','','','Ris')";
|
|
|
|
|
|
SQLStringList.Add(strInterPatinet);
|
|
SQLStringList.Add(strInterStudy);
|
|
ExecuteSqlTran(SQLStringList);
|
|
|
|
foreach (DataRow dr in dtJcxm.Rows)
|
|
{
|
|
string strInterStudyItem = "INSERT INTO StudyItemIndex(StudyID,SubItemID,Amount,Price,Money,ItemTitle) Values(" + stuid + " , '" + dr["tqbm"] + "','0','0','0','" + dr["jcxmmc"] + "')";
|
|
int i = ExecuteCommand(strInterStudyItem);
|
|
if (i == 0)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
this.txtDr.Text = "";
|
|
this.txtDr.Focus();
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
else if (fddm == 2)
|
|
{
|
|
DateTime dtnow = DateTime.Now;
|
|
string dateresult = dtnow.ToString("yyyyMMddHHmmssfff");
|
|
string StudyInstanceUID = "11.10.1106.1147.1163.18."+ dtnow.ToString("yyyyMMddHHmmss")+".8";
|
|
string SeriesInstanceUID = "11.10.1106.1147.1163.18." + dtnow.ToString("yyyyMMddHHmmss") + ".10";
|
|
DataTable xxDt;
|
|
xxDt = Newtonsoft.Json.JsonConvert.DeserializeObject(data, typeof(DataTable)) as DataTable;
|
|
|
|
string strSelJcxm = "select * from t_jcxm where jcxmbm in (" +
|
|
" select xmbm from t_zhxmmx where zhbm in (select zhbm from t_tempdjxm where tm=" + xxDt.Rows[0]["tm"] + " " +
|
|
"and ksbm in (9,10,11,12,13,62,65)))";
|
|
|
|
DataTable dtJcxm = ZBGetDataSet1(strSelJcxm);
|
|
if (dtJcxm.Rows.Count > 0)
|
|
{
|
|
string jcxmstr = "";
|
|
if (dtJcxm.Rows.Count > 1)
|
|
{
|
|
foreach (DataRow dr in dtJcxm.Rows)
|
|
{
|
|
jcxmstr += dr["jcxmmc"].ToString() + "+";
|
|
}
|
|
jcxmstr = jcxmstr.Substring(0, jcxmstr.Length - 1);
|
|
}
|
|
else
|
|
{
|
|
jcxmstr = dtJcxm.Rows[0]["jcxmmc"].ToString();
|
|
}
|
|
|
|
string sex = "";
|
|
if (xxDt.Rows[0]["xb"].ToString() == "0")
|
|
{
|
|
sex = "M";
|
|
}
|
|
else if (xxDt.Rows[0]["xb"].ToString() == "1")
|
|
{
|
|
sex = "F";
|
|
}
|
|
else
|
|
{
|
|
sex = "O";
|
|
}
|
|
string RoadPath = @"Provider=Microsoft.Jet.OleDb.4.0;Data Source=Z:\\DROC_5.22.1306.2\\Database\\ECOM_DROC_UM_Database.mdb";
|
|
|
|
DataSet ds = new DataSet();
|
|
OleDbConnection AccessConnect = new OleDbConnection(RoadPath); //定义数据库连接对象
|
|
//string ReadSql = "select StudyID,AccessionNum,PatientID,PatientName,PatientSize,PatientAge,PatientDOB,PatientSex,AdmittingTime,RegSource,StudyStatus from work";
|
|
AccessConnect.Open();
|
|
//OleDbDataAdapter adp = new OleDbDataAdapter(ReadSql, AccessConnect);//从数据库读出数据到数据库适配器
|
|
string Add_Grop = "insert into [work] ([StudyID],[AccessionNum],[PatientID],[PatientName],[PatientSize],[PatientAge],[PatientDOB],[PatientSex],[AdmittingTime],[RegSource],[StudyInstanceUID],[StudyStatus],[PerformedProtocolCodeValue],[PerformedProtocolCodeMeaning],[StudyDescription],[StudyStartDatetime],[StudyLock],[OperateName],[Modality],[Reserve1],[Reserve2]) " +//PerformedProtocolCodeValue,PerformedProtocolCodeMeaning,StudyDescription,StudyStartDatetime,StudyLock,OperateName,Modality,Reserve1,Reserve2
|
|
"values('" + dateresult.Substring(0,16) + "','" + dateresult.Substring(0,16) + "','" + xxDt.Rows[0]["tm"].ToString() + "','" + xxDt.Rows[0]["xm"].ToString() + "','MEDIUM','" + xxDt.Rows[0]["nl"].ToString() + "Y','" +xxDt.Rows[0]["csrq"]+ "','" + sex + "','" + DateTime.Now + "','L','"+ StudyInstanceUID + "','IN PROGRESS','P5-000310','Chest PA','" + "胸部后前位" + "','"+DateTime.Now+ " ','UNLOCKED','mgr','DX','Normal','0')"; //构造sql语句
|
|
OleDbCommand cmd = new OleDbCommand(Add_Grop, AccessConnect); //定义Command对象
|
|
//将账号密码存入数据库
|
|
|
|
|
|
string Add_VIEW = "insert into [VIEW] ([StudyID],[StudyDescription],[SeriesInstanceUID],[ViewID],[ViewDescription],[KW],[KVP],[TechMode],[AECDensity],[MA],[MS],[MAS],[DAP],[EXI],[SID],[Order],[ExposeStatus],[BodyPart],[Reserve1],[SeriesNumber])"+
|
|
"values('" + dateresult.Substring(0, 16) + "','胸部后前位','"+ SeriesInstanceUID + "','Chest PA','胸部后前位','0','0','0','0','0','0','0','0','0','0','1','UNEXPOSE','THORAX','Table','1')";
|
|
OleDbCommand cmd1 = new OleDbCommand(Add_VIEW, AccessConnect); //定义Command对象
|
|
|
|
cmd.ExecuteNonQuery(); //执行Command命令
|
|
cmd1.ExecuteNonQuery();
|
|
AccessConnect.Close();
|
|
|
|
ds.Dispose();
|
|
//adp.Dispose();
|
|
AccessConnect.Dispose();
|
|
AccessConnect.Close();
|
|
this.txtDr.Text = "";
|
|
this.txtDr.Focus();
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
public static SqlConnection Connection
|
|
{
|
|
get
|
|
{
|
|
string con = "";
|
|
System.Configuration.Configuration cm = System.Configuration.ConfigurationManager.OpenExeConfiguration(AppDomain.CurrentDomain.BaseDirectory + "\\local.ext");
|
|
con = cm.AppSettings.Settings["dr"].Value;
|
|
if (connection == null)
|
|
{
|
|
connection = new SqlConnection(con);
|
|
connection.Open();
|
|
}
|
|
else if (connection.State == System.Data.ConnectionState.Closed)
|
|
{
|
|
connection.Open();
|
|
}
|
|
else if (connection.State == System.Data.ConnectionState.Broken)
|
|
{
|
|
connection.Close();
|
|
connection.Open();
|
|
}
|
|
return connection;
|
|
|
|
}
|
|
}
|
|
|
|
public static OleDbConnection zbConnection
|
|
{
|
|
get
|
|
{
|
|
string con = "";
|
|
System.Configuration.Configuration cm = System.Configuration.ConfigurationManager.OpenExeConfiguration(AppDomain.CurrentDomain.BaseDirectory + "\\local.ext");
|
|
con = cm.AppSettings.Settings["zbdr"].Value;
|
|
if (zbconnection == null)
|
|
{
|
|
zbconnection = new OleDbConnection(con);
|
|
zbconnection.Open();
|
|
}
|
|
//else if (zbconnection.State == System.Data.OleDb.OleDbConnection..Closed)
|
|
//{
|
|
// zbconnection.Open();
|
|
//}
|
|
//else if (zbconnection.State == System.Data.ConnectionState.Broken)
|
|
//{
|
|
// zbconnection.Close();
|
|
// zbconnection.Open();
|
|
//}
|
|
return zbconnection;
|
|
|
|
}
|
|
}
|
|
|
|
public static SqlConnection Connection1
|
|
{
|
|
get
|
|
{
|
|
string con = "";
|
|
System.Configuration.Configuration cm = System.Configuration.ConfigurationManager.OpenExeConfiguration(AppDomain.CurrentDomain.BaseDirectory + "\\local.ext");
|
|
con = cm.AppSettings.Settings["bodycheck"].Value;
|
|
if (connection1 == null)
|
|
{
|
|
connection1 = new SqlConnection(con);
|
|
connection1.Open();
|
|
}
|
|
else if (connection1.State == System.Data.ConnectionState.Closed)
|
|
{
|
|
connection1.Open();
|
|
}
|
|
else if (connection1.State == System.Data.ConnectionState.Broken)
|
|
{
|
|
connection1.Close();
|
|
connection1.Open();
|
|
}
|
|
return connection1;
|
|
|
|
}
|
|
}
|
|
|
|
public static SqlConnection zbConnection1
|
|
{
|
|
get
|
|
{
|
|
string con = "";
|
|
System.Configuration.Configuration cm = System.Configuration.ConfigurationManager.OpenExeConfiguration(AppDomain.CurrentDomain.BaseDirectory + "\\local.ext");
|
|
con = cm.AppSettings.Settings["zbbodycheck"].Value;
|
|
if (zbconnection1 == null)
|
|
{
|
|
zbconnection1 = new SqlConnection(con);
|
|
zbconnection1.Open();
|
|
}
|
|
else if (zbconnection1.State == System.Data.ConnectionState.Closed)
|
|
{
|
|
zbconnection1.Open();
|
|
}
|
|
else if (zbconnection1.State == System.Data.ConnectionState.Broken)
|
|
{
|
|
zbconnection1.Close();
|
|
zbconnection1.Open();
|
|
}
|
|
return zbconnection1;
|
|
|
|
}
|
|
}
|
|
|
|
public static DataTable GetDataSet1(string safeSql)
|
|
{
|
|
DataSet ds = new DataSet();
|
|
SqlCommand cmd = new SqlCommand(safeSql, Connection1);
|
|
SqlDataAdapter da = new SqlDataAdapter(cmd);
|
|
da.Fill(ds);
|
|
return ds.Tables[0];
|
|
}
|
|
|
|
public static DataTable ZBGetDataSet1(string safeSql)
|
|
{
|
|
DataSet ds = new DataSet();
|
|
SqlCommand cmd = new SqlCommand(safeSql, zbConnection1);
|
|
SqlDataAdapter da = new SqlDataAdapter(cmd);
|
|
da.Fill(ds);
|
|
return ds.Tables[0];
|
|
}
|
|
|
|
public static DataTable ExecuteCommand(string procName, string value)
|
|
{
|
|
SqlCommand cmd = new SqlCommand();
|
|
cmd.Connection = Connection;
|
|
cmd.CommandText = procName;
|
|
cmd.CommandType = CommandType.StoredProcedure;
|
|
cmd.Parameters.AddWithValue("@khbm", value);
|
|
SqlDataAdapter sda = new SqlDataAdapter(cmd);
|
|
DataTable dt = new DataTable();
|
|
sda.Fill(dt);
|
|
return dt;
|
|
}
|
|
|
|
public static int ExecuteCommand(string safeSql)
|
|
{
|
|
SqlCommand cmd = new SqlCommand(safeSql, Connection);
|
|
int result = cmd.ExecuteNonQuery();
|
|
return result;
|
|
}
|
|
|
|
public static int ExecuteCommand(string sql, params SqlParameter[] values)
|
|
{
|
|
SqlCommand cmd = new SqlCommand(sql, Connection);
|
|
cmd.Parameters.AddRange(values);
|
|
return cmd.ExecuteNonQuery();
|
|
}
|
|
|
|
public static int GetScalar(string safeSql)
|
|
{
|
|
SqlCommand cmd = new SqlCommand(safeSql, Connection);
|
|
int result = Convert.ToInt32(cmd.ExecuteScalar());
|
|
return result;
|
|
}
|
|
|
|
public static int GetScalar(params SqlParameter[] values)
|
|
{
|
|
SqlCommand cmd = new SqlCommand();
|
|
cmd.Connection = Connection;
|
|
cmd.CommandText = "Pro_InsertOrder";
|
|
cmd.CommandType = CommandType.StoredProcedure;
|
|
cmd.Parameters.AddRange(values);
|
|
int result = Convert.ToInt32(cmd.ExecuteScalar());
|
|
return result;
|
|
}
|
|
|
|
public static int GetScalar(string sql, params SqlParameter[] values)
|
|
{
|
|
SqlCommand cmd = new SqlCommand(sql, Connection);
|
|
cmd.Parameters.AddRange(values);
|
|
int result = Convert.ToInt32(cmd.ExecuteScalar());
|
|
return result;
|
|
}
|
|
|
|
public static SqlDataReader GetReader(string safeSql)
|
|
{
|
|
SqlCommand cmd = new SqlCommand(safeSql, Connection);
|
|
SqlDataReader reader = cmd.ExecuteReader();
|
|
return reader;
|
|
}
|
|
|
|
public static SqlDataReader GetReader(string sql, params SqlParameter[] values)
|
|
{
|
|
SqlCommand cmd = new SqlCommand(sql, Connection);
|
|
cmd.Parameters.AddRange(values);
|
|
SqlDataReader reader = cmd.ExecuteReader();
|
|
return reader;
|
|
}
|
|
|
|
public static DataTable GetDataSet(string safeSql)
|
|
{
|
|
DataSet ds = new DataSet();
|
|
SqlCommand cmd = new SqlCommand(safeSql, Connection);
|
|
SqlDataAdapter da = new SqlDataAdapter(cmd);
|
|
da.Fill(ds);
|
|
return ds.Tables[0];
|
|
}
|
|
|
|
public static DataTable GetDataSet(string sql, params SqlParameter[] values)
|
|
{
|
|
DataSet ds = new DataSet();
|
|
SqlCommand cmd = new SqlCommand(sql, Connection);
|
|
cmd.Parameters.AddRange(values);
|
|
SqlDataAdapter da = new SqlDataAdapter(cmd);
|
|
da.Fill(ds);
|
|
return ds.Tables[0];
|
|
}
|
|
public static void ExecuteSqlTran(List<string> SQLStringList)
|
|
{
|
|
|
|
SqlCommand cmd = new SqlCommand();
|
|
cmd.Connection = Connection;
|
|
SqlTransaction tx = Connection.BeginTransaction();
|
|
cmd.Transaction = tx;
|
|
try
|
|
{
|
|
for (int n = 0; n < SQLStringList.Count; n++)
|
|
{
|
|
string strsql = SQLStringList[n].ToString();
|
|
if (strsql.Trim().Length > 1)
|
|
{
|
|
cmd.CommandText = strsql;
|
|
cmd.ExecuteNonQuery();
|
|
}
|
|
}
|
|
tx.Commit();
|
|
|
|
}
|
|
catch (System.Data.SqlClient.SqlException E)
|
|
{
|
|
tx.Rollback();
|
|
//throw new Exception(E.Message);
|
|
MessageBox.Show("登记失败!");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
private void frmDRDengJi_Load(object sender, EventArgs e)
|
|
{
|
|
fddm = short.Parse(LoginUser.yydm);
|
|
}
|
|
}
|
|
}
|