下面是對醫生工作站的一些主體的功能進行描述,和解析說明;
醫師對分配好牀位的病人進行醫囑錄入和處方錄入還有一些輔助的檢查和對病人的信息修改查看等,功能如下圖:
醫師點擊菜單欄——》護理——》體溫單進行對病人的體溫錄入
錄入完成點擊保存,保存後可以編輯修改。
醫師點擊菜單欄——》護理——》過敏藥品錄入,進行對病人的過敏藥品錄入,如下圖:這部尤爲關鍵,如果病人對某種藥品過敏的話,在醫生開藥的時
候會對病人過敏的藥品進行限制
醫生對上面的操做好了以後可以進行對病人的處方錄入,錄入藥品時回對病人的過敏藥品進行檢測,如果病人對某些藥品過敏是不能進行此藥品的錄入的。如下圖
錄入處方後,醫生會對病人屬性一些醫囑,就是護士要根據醫囑來對病人進行料理:如下圖
除了這些以外,醫生站還可以查看病人信息和修改病人資料。
修改資料圖如下
從所有界面上可以看到我們這裏用到的控件有
控件名稱 |
說明 |
日期控件(DateTimePicker) |
控件可以在工具箱直接拖動至窗體,拖至窗體後右擊屬性可以修改控件的樣式和各種屬性,還可以編輯事件。 |
下拉框(ComboBox) |
|
文本(TextBox) |
|
按鈕(Button) |
|
表格(DataGridView) |
醫囑錄入關係圖如下圖:
病歷書寫
處方錄入
過敏藥品錄入
表1 醫囑表 ZY_DoctorAdviceList
列名 |
數據類型/主外鍵 |
說明 |
DoctorAdviceID |
int - Identity(主鍵) |
醫囑ID |
CheckProject |
nchar (20) |
檢查項目 |
DoctorAdviceContent |
nchar (50) |
醫囑內容 |
EntrustNo |
bit |
囑託否 |
ParturitionManufacturers |
nchar (50) |
生產廠家 |
ChineseMedicinFuShu |
decimal (18) |
中藥付數 |
Number |
decimal (18) |
數量 |
OnceDose |
nchar (20) |
單次劑量 |
Unit |
nchar (20) |
單位 |
Specification |
nchar (20) |
規格 |
Contents |
nchar (10) |
含量 |
UnitPrice |
decimal (18, 2) |
單價 |
Money |
decimal (18, 2) |
金額 |
UseMethod |
nchar (20) |
用法 |
Frequency |
decimal (18) |
頻率 |
OpenEntrustDate |
datetime |
開囑日期 |
DoctorID |
Int(外鍵) |
開囑醫生ID |
ExecuteNurseID |
int(外鍵) |
執行護士ID |
StopEntrustDate |
datetime |
停囑日期 |
StopEntrustNo |
bit |
停囑否 |
RegisterInhospitalID |
int(外鍵) |
住院登記ID |
SubmitNo |
bit |
提交否 |
表 2牀位分配表 ZY_BedLocationAllocationList
列名 |
數據類型/主外鍵 |
說明 |
BedLocationAllocationID |
int - Identity(主鍵) |
牀位分配ID |
RegisterInhospitalID |
int(外鍵) |
住院登記ID |
BedLocationID |
int(外鍵) |
牀位ID |
EnterResideTime |
datetime |
入住時間 |
QuitBedTime |
datetime |
退牀時間 |
QuitBedNo |
bit |
退牀否 |
表3過敏藥品錄入表
列名 |
數據類型 |
說明 |
AllergicMedicineID |
int - Identity |
過敏藥品ID |
MedicineID |
int(外鍵) |
藥品ID |
MedicineName |
nchar (20) |
藥品名稱 |
AllergicReason |
nchar (50) |
過敏原因 |
CheckResultID |
int(外鍵) |
藥品ID |
RegisterInhospitalID |
int(外鍵) |
住院登記ID |
Encoding |
nchar (20) |
編碼 |
表4影像表
列名 |
數據類型 |
說明 |
ImageID |
int - Identity(主鍵) |
影像ID |
Date |
nchar (20) |
日期 |
FileName |
nvarchar (MAX) |
文件名 |
Describe |
nvarchar (50) |
描述 |
RegisterInhospitalID |
Int(外鍵) |
住院登記ID |
表5 體溫表
列名 |
數據類型 |
說明 |
TemperatureID |
int - Identity(主鍵) |
體溫ID |
BillsDate |
datetime |
單據日期 |
OperationDate |
datetime |
手術日期 |
InHospitalData |
decimal (18) |
住院天數 |
Temperature1 |
decimal (18, 1) |
體溫1 |
Temperature2 |
decimal (18, 1) |
體溫2 |
Temperature3 |
decimal (18, 1) |
體溫3 |
Temperature4 |
decimal (18, 1) |
體溫4 |
Temperature5 |
decimal (18, 1) |
體溫5 |
Temperature6 |
decimal (18, 1) |
體溫6 |
Pulse1 |
decimal (18, 1) |
脈搏1 |
Pulse2 |
decimal (18, 1) |
脈搏2 |
Pulse3 |
decimal (18, 1) |
脈搏3 |
Pulse4 |
decimal (18, 1) |
脈搏4 |
Pulse5 |
decimal (18, 1) |
脈搏5 |
Pulse6 |
decimal (18, 1) |
脈搏6 |
Breathe1 |
decimal (18) |
呼吸1 |
Breathe2 |
decimal (18) |
呼吸2 |
Breathe3 |
decimal (18) |
呼吸3 |
Breathe4 |
decimal (18) |
呼吸4 |
Breathe5 |
decimal (18) |
呼吸5 |
Breathe6 |
decimal (18) |
呼吸6 |
DefecateNumber |
decimal (18) |
大便次數 |
PeeNumber |
decimal (18) |
小便次數 |
EffluentMeasure |
decimal (18) |
出水量 |
RuWorterMeasure |
decimal (18) |
入水量 |
BloodPressure |
decimal (18) |
血壓 |
Height |
decimal (18, 2) |
身高 |
Weight |
decimal (18, 2) |
體重 |
MedicineAllergic |
nvarchar (150) |
藥物過敏 |
RegisterInhospitalID |
Int(外鍵) |
住院登記ID |
表6:病歷表
Primary Key(s): BingLiID
列名 |
數據類型 |
說明 |
BingLiID |
int - Identity |
病歷ID |
ZhuSu |
nchar (50) |
主訴 |
NowIllnessHistory |
nchar (50) |
現病史 |
BeforeHistory |
nchar (50) |
既往史 |
AllergyHistory |
nchar (50) |
過敏史 |
CheckBuild |
nchar (50) |
體格檢查 |
PreliminaryDiagnosis |
nchar (50) |
初步診斷 |
DealwithIdea |
nchar (100) |
處理意見 |
BeforeNo |
bit |
以往否 |
MenZhenRegisterID |
int |
門診登記ID |
RegisterTime |
datetime |
登記時間 |
InHospitalNo |
bit |
住院否 |
表7:處方明細表
dbo.MZ_PrescriptionBillsMingXiList
Primary Key(s): PrescriptionBillsMingXiID
列名 |
數據類型 |
說明 |
PrescriptionBillsMingXiID |
int - Identity |
處方明細ID |
MedicineID |
int |
藥品ID |
Number |
decimal (18, 2) |
數量 |
PrescriptionBillsID |
int |
處方ID |
SendOutMedicineNo |
bit |
發藥否 |
SkinTestID |
int |
皮試ID |
UsageID |
int |
用法ID |
UseMedicineFrequencyID |
int |
用藥頻率ID |
AtEveryTurnNumber |
decimal (18) |
每次數量 |
AtEveryTurnDoseID |
int |
每次劑量ID |
PayMoney |
decimal (18, 2) |
自付金額 |
OfficeID |
int |
科室ID |
RetreatMedicineNumber |
decimal (18) |
退藥數量 |
InhospitalNo |
bit |
住院否 |
具體實現(一)進入醫生工作站的主界面病人資料卡片的實現
private void Frm_ZhuYuanYiShengZhancs_Load(object sender, EventArgs e)
{
//清空後再加載
plSickMap.Controls.Clear();
if (radNoOutHospital.Checked == true && Selecting==false)//如果選擇未出院
{
DataTable dtBingRen = myFrm_ZhuYuanYiShengZhanClient.
Frm_ZhuYuanYiShengZhan_SelectBingRenXinXi().Tables[0];
//創建數據集把數據表裝進去
DataView dv = new DataView(dtBingRen);
//給數據集條件篩選數據,條件爲出院否=0,相當於數據庫存儲過程中的Where條件
dv.RowFilter = "(LeaveHospitalNo=0 and QuitBedNo=0)";
//把篩選的數據集轉化爲數據表
dtBingRenXinXi = dv.ToTable();
}
for (int i = 0, leftX = 10, leftY = 80; i < dtBingRenXinXi.Rows.Count; i++)
{
int RowCount = i / 4;
if (i % 4== 0)
{
leftX = 20;
}
else
{
leftX += 200;
}
leftY = RowCount * 180;
Button btnXinXi = new Button();
btnXinXi.Size = new Size(150, 25);//設置控件的大小
btnXinXi.FlatAppearance.BorderSize = 1;//獲取用於指示選中狀態和鼠標狀態的邊框外觀和顏色。
btnXinXi.BackColor = Color.SkyBlue;//設置控件的背景色。
btnXinXi.TextAlign = System.Drawing.ContentAlignment.TopLeft;//設置文本對齊方式
btnXinXi.FlatStyle = FlatStyle.Flat;//設置按鈕控件的平面樣式外觀。
btnXinXi.Location = new Point(leftX, leftY);//控件的座標
string XingBie = dtBingRenXinXi.Rows[i]["Sex"].ToString().Trim();
string XingMing = dtBingRenXinXi.Rows[i]["Name"].ToString().Trim();
btnXinXi.Text = XingMing;
//判斷病人性別
int QuBie;
//如果爲男性
if (XingBie == "男")
{
//QuBie賦值爲0
QuBie = 0;
}
else
{
//爲女性QuBie賦值爲1
QuBie = 1;
}
switch (QuBie)
{
case 0:
//QuBie賦值爲0頭像爲男
btnXinXi.Image = ImgTuiPian.Images["man.gif"];
break;
case 1:
//QuBie賦值爲1頭像爲女
btnXinXi.Image = ImgTuiPian.Images["wife.gif"];
break;
}
PictureBox pbXinXi = new PictureBox();//實例化PictureBox
pbXinXi.Tag = dtBingRenXinXi.Rows[i]["RegisterInhospitalID"].ToString().Trim();
pbXinXi.Size = new Size(150, 150);//設置大小
pbXinXi.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;//指示控件的邊框樣式
pbXinXi.Location = new Point(leftX, leftY+25);
plSickMap.Controls.Add(btnXinXi);
plSickMap.Controls.Add(pbXinXi);
pbXinXi.MouseClick += new MouseEventHandler(pbXinXi_MouseClick);//鼠標單擊事件
pbXinXi.MouseLeave += new EventHandler(pbXinXi_MouseLeave);//鼠標離開事件
pbXinXi.MouseEnter += new EventHandler(pbXinXi_MouseEnter);//鼠標進入事件
pbXinXi.Paint+=new PaintEventHandler(pbXinXi_Paint);//窗體重繪事件
}
}
public void pbXinXi_Paint(object sender, PaintEventArgs e)
{
PictureBox pb = sender as PictureBox;//把觸發事件的對象轉換爲圖片對象
Graphics g = e.Graphics;//實例化圖片的繪圖對象
int tag = Convert.ToInt32(pb.Tag); //獲取圖片對應的住院ID
foreach (DataRow dt in dtBingRenXinXi.Rows)//遍歷全局變量myDataTable住院表
{
if (Convert.ToInt32(dt["RegisterInhospitalID"]) == tag)//如果住院表的住院ID與圖片對應的ID相等
{
//給相應變量賦值
string Name = dt["Name"].ToString().Trim();
string ZhuYuanHao = dt["InHospitalNumber"].ToString().Trim();
string XingBie = dt["Sex"].ToString().Trim();
string NianLing = dt["Age"].ToString().Trim();
string ZhuYuangRiQi = dt["EnterHospitalDate"].ToString().Trim();
string YiSheng = dt["DoctorName"].ToString().Trim();
g.DrawString( "住院號:" + ZhuYuanHao+"\n"+"\n"+"姓名:" + Name
+ " " + "性別:" + XingBie + "\n"+"\n" + "年齡:" + NianLing + " "
+ "醫生:" + YiSheng + "\n"+"\n" + "住院日期:" + ZhuYuangRiQi,
new Font("宋體", 10, FontStyle.Regular), SystemBrushes.ControlText, new PointF(10, 5));
}
}
}
然後醫生對病人進行檢查對對過敏藥品的錄入。次操作直接影響到醫生的開藥。具體的實現如下:
單擊HbsAg,HCV_Ab。HIV—Ab是實現的代碼
private void txtCheck_Click(object sender, EventArgs e)
{
//for 循環爲了檢查表格中是否存在"HIV-Ab"項目
for (int index = 0; index < dgDrugallergicRecord.Rows.Count;index++ )
{
if(Convert.ToString( dgDrugallergicRecord.Rows[index].Cells["MedicineName"].Value.ToString().Trim()) == "HIV-Ab")
{
//如果存在則跳出次方法
return;
}
}
dgDrugallergicRecord.Rows.Add(3);//添加3行
//對應的賦值
dgDrugallergicRecord.Rows[dgDrugallergicRecord.Rows.Count - 1].Cells["MedicineName"].Value = "HIV-Ab";
dgDrugallergicRecord.Rows[dgDrugallergicRecord.Rows.Count - 2].Cells["MedicineName"].Value = "HCV-Ab";
dgDrugallergicRecord.Rows[dgDrugallergicRecord.Rows.Count - 3].Cells["MedicineName"].Value = "HbsAg";
dgDrugallergicRecord.Rows[dgDrugallergicRecord.Rows.Count - 1].Cells["AllergicMedicineID"].Value =0;
dgDrugallergicRecord.Rows[dgDrugallergicRecord.Rows.Count - 2].Cells["AllergicMedicineID"].Value = 0;
dgDrugallergicRecord.Rows[dgDrugallergicRecord.Rows.Count - 3].Cells["AllergicMedicineID"].Value = 0;
}
點擊刪除時要用到數組記錄已經移除的項目ID,移除並不是刪除,實際刪除要單擊保存,避免誤操作。刪除時的操作代碼,
#region 刪除功能
int i = 0;//定義一個變量
private void btnShanChu_Click(object sender, EventArgs e)
{
if (dgDrugallergicRecord.Rows.Count > 0)//如果過敏藥品表>0
{
ShuZhu[i] = Convert.ToInt32(dgDrugallergicRecord.Rows
[dgDrugallergicRecord.Rows.Count - 1].Cells["AllergicMedicineID"].Value);//用數組記錄移除了的ID
dgDrugallergicRecord.Rows.RemoveAt(dgDrugallergicRecord.Rows.Count - 1);//移除行
i++;//變量每一次都加一
}
}
保存過敏記錄的實現
第一步:數據庫存儲過程
if @Type='Frm_ZhuYuanYiShengZhan_InsertGuoMinYaoPing'
begin
insert ZY_AllergicMedicineCheckRecordList ( MedicineID,MedicineName,
AllergicReason, CheckResultID,RegisterInhospitalID,Encoding)
values ( @MedicineID,@MedicineName, @AllergicReason, @CheckResultID,@RegisterInhospitalID,@Encoding)
end
第二步:邏輯層(BLL)代碼
[OperationContract]
public int Frm_ZhuYuanYiShengZhan_InsertGuoMinYaoPing(int MedicineID, string MedicineName,string AllergicReason,
int CheckResultID, int RegisterInhospitalID, string Encoding)
{
SqlParameter[] mySqlParameters = {
new SqlParameter ("@Type",SqlDbType .Char),
new SqlParameter ("@MedicineID",SqlDbType.Int),
new SqlParameter ("@MedicineName",SqlDbType.Char),
new SqlParameter ("@AllergicReason",SqlDbType.Char),
new SqlParameter ("@CheckResultID",SqlDbType.Int),
new SqlParameter ("@RegisterInhospitalID",SqlDbType.Int),
new SqlParameter ("@Encoding",SqlDbType.Char),
};
mySqlParameters[0].Value = "Frm_ZhuYuanYiShengZhan_InsertGuoMinYaoPing";
mySqlParameters[1].Value = MedicineID;
mySqlParameters[2].Value = MedicineName;
mySqlParameters[3].Value = AllergicReason;
mySqlParameters[4].Value = CheckResultID;
mySqlParameters[5].Value = RegisterInhospitalID;
mySqlParameters[6].Value = Encoding;
return myDALMethod.UpdateData("住院登記_Frm_ZhuYuanYiShengZhan", mySqlParameters);
}
第三步:界面層(UIL)代碼
int Sum;//聲明變量
int inCount;//聲明變量
int ChengGong;//聲明變量
private void btnBaoCun_Click(object sender, EventArgs e)
{
for (int j = 0; j < dgDrugallergicRecord.Rows.Count;j++ )
{
if (Convert.ToInt32(dgDrugallergicRecord.Rows[j].Cells["AllergicMedicineID"].Value) == 0)
{ //循環判斷檢查ID是否爲空
int CheckResultID = Convert.ToInt32(dgDrugallergicRecord.Rows[j].Cells["CheckResult"].Value);
if (CheckResultID ==0)
{
MessageBox.Show("檢查結果不能留空!");
//爲空則跳出該方法
return;
}
else
{
//否則變量加一
Sum++;
}
}
}
//for循環獲取每一行對應的值
for (int i = 0; i < dgDrugallergicRecord.Rows.Count;i++ )
{
if (Convert.ToInt32(dgDrugallergicRecord.Rows[i].Cells["AllergicMedicineID"].Value )==0)
{
int MedicineID =Convert.ToInt32( dgDrugallergicRecord.Rows[i].Cells["MedicineID"].Value);
string MedicineName =Convert.ToString(dgDrugallergicRecord.Rows[i].Cells["MedicineName"].Value);
string AllergicReason =Convert.ToString( dgDrugallergicRecord.Rows[i].Cells["AllergicReason"].Value);
int CheckResultID = Convert.ToInt32(dgDrugallergicRecord.Rows[i].Cells["CheckResult"].Value);
string Encoding = Convert.ToString(dgDrugallergicRecord.Rows[i].Cells["Encoding"].Value);
myFrm_ZhuYuanYiShengZhanClient.Frm_ZhuYuanYiShengZhan_InsertGuoMinYaoPing
(MedicineID, MedicineName, AllergicReason, CheckResultID, PulicStatic.ZhuYuanDengjiID, Encoding);
inCount++;//變量加一
}
}
//for 循環數組刪除
for (int k = 0; k < ShuZhu.Length;k++ )
{
ChengGong= myFrm_ZhuYuanYiShengZhanClient.Frm_ZhuYuanYiShengZhan_DeleteGuoMinYaoPing(ShuZhu[k]);
}
if (Sum == inCount || ChengGong>0)
{
MessageBox.Show("保存成功!");
}
}
過敏藥物記錄以後,醫生可對病人進行病歷的書寫,和處方的錄入
處方錄入的實現解析代碼如下:
如圖看到的自付金和總金額的實現
#region 計算總金和自付金
public void JiSuZongJinZiFuJin()
{ //獲取單價
decimal DanJia = Convert.ToDecimal(dgvMedicineInformation.CurrentRow.Cells["RetailPrice_J"].Value);
//獲取數量
decimal ShuLiang = Convert.ToDecimal(dgvMedicineInformation.CurrentRow.Cells["SumNumber"].Value);
//判斷庫房數量
if (門診管理.Frm_MenZhenYiShengGongZuoZhanYaoPin_Insert.decStockNumber > 0)
{ //比較獲取的數量和庫房數量
if (ShuLiang > 門診管理.Frm_MenZhenYiShengGongZuoZhanYaoPin_Insert.decStockNumber)
{ //如果數量>庫房數則跳出次方法
MessageBox.Show("總數量不能大於該藥品的庫存數量!");
return;
}
}
//計算當前選擇的行的總金額=單價*數量
dgvMedicineInformation.CurrentRow.Cells["SumMoney"].Value =( DanJia * ShuLiang).ToString("0.00");
//獲取藥品ID
YoPingID = Convert.ToInt32(dgvMedicineInformation.CurrentRow.Cells["MedicineID"].Value);
//查詢病人對應的折扣率(根據醫療方式和藥品ID)
DataTable dtZheKouLv = myFrm_ZhuYuanJiZhangClient.
Frm_ZhuYuanJiZhang_SelectZheKouLi(PulicStatic.YiLiaoFangShi, YoPingID).Tables[0];
//如果查詢的折扣率的表>0
if (dtZheKouLv.Rows.Count > 0)
{
//獲取當前行的總金額
decimal ZongJinE = Convert.ToDecimal(dgvMedicineInformation.CurrentRow.Cells["SumMoney"].Value);
//計算自付金額=總金額*折扣率
dgvMedicineInformation.CurrentRow.Cells["PayMoney"].Value =
(ZongJinE * Convert.ToDecimal(dtZheKouLv.Rows[0][0])).ToString("0.00");
}
else
{
//如果該藥每有折扣率則自付金額=總金額
decimal ZongJinE = Convert.ToDecimal(dgvMedicineInformation.CurrentRow.Cells["SumMoney"].Value);
dgvMedicineInformation.CurrentRow.Cells["PayMoney"].Value = (ZongJinE).ToString("0.00");
}
JiSuSumMoney();//調用計算每行的累計總金額和自付金方法。
}
#endregion
計算每行的累計總金額和自付金方法。
#region 累計總金和 自付金額
public void JiSuSumMoney()
{
decimal ZongJin = 0;//定義變量總金
decimal ZiFuJi = 0;//定義變量自付金
int i = 0;
//for循環累計總金和 自付金額
for (i = 0; i < dgvMedicineInformation.Rows.Count; i++)
{
ZongJin += Convert.ToDecimal(dgvMedicineInformation.Rows[i].Cells["SumMoney"].Value);
ZiFuJi += Convert.ToDecimal(dgvMedicineInformation.Rows[i].Cells["PayMoney"].Value);
}
//給文本賦值
lblSumMoney.Text = ZongJin.ToString("0.00").Trim();
lblZiFuJin.Text = ZiFuJi.ToString("0.00").Trim();
}
#endregion
處方單藥品的保存和庫房的修改的實現
第一步:數據庫存儲過程
if(@Type='Frm_MenZhenYiShengGongZuoZhan_UpdateKuCunShu')
begin
update KC_StockList
set StockNumber=StockNumber-@StockNumber
where KC_StockList.MedicineID=@MedicineID AND KC_StockList.StoreroomID=@StoreroomID
end --庫房數的修改
if(@Type='Frm_MenZhenYiShengGongZuoZhan_InsertChuFangDanMingXi')
begin
insert MZ_PrescriptionBillsMingXiList(MedicineID, Number, PrescriptionBillsID,
SendOutMedicineNo, SkinTestID, UsageID, UseMedicineFrequencyID, AtEveryTurnNumber,
AtEveryTurnDoseID, PayMoney,OfficeID,InhospitalNo)
values (@MedicineID, @Number, @PrescriptionBillsID, @SendOutMedicineNo, @SkinTestID,
@UsageID, @UseMedicineFrequencyID, @AtEveryTurnNumber, @AtEveryTurnDoseID,
@PayMoney,@OfficeID,@InhospitalNo)
end --處方的新增
第二步:邏輯層(BLL)代碼
[OperationContract]
public int Frm_MenZhenYiShengGongZuoZhan_UpdateKuCunShu(decimal decStockNumber, int intMedicineID,
int intStoreroomID)
{
SqlParameter[] mySqlParameters = {
new SqlParameter ("@Type",SqlDbType .Char),
new SqlParameter ("@StockNumber",SqlDbType.Decimal),
new SqlParameter ("@MedicineID",SqlDbType.Int),
new SqlParameter ("@StoreroomID",SqlDbType.Int),
};
mySqlParameters[0].Value = "Frm_MenZhenYiShengGongZuoZhan_UpdateKuCunShu";
mySqlParameters[1].Value = decStockNumber;
mySqlParameters[2].Value = intMedicineID;
mySqlParameters[3].Value = intStoreroomID;
return myDALMethod.UpdateData("門診登記_Frm_MenZhenYiShengGongZuoZhan", mySqlParameters);
}
[OperationContract]
public int Frm_MenZhenYiShengGongZuoZhan_InsertChuFangDanMingXi(int intMedicineID,
decimal strNumber, int intPrescriptionBillsID, bool bitSendOutMedicineNo,
int intSkinTestID, int intUsageID, int intUseMedicineFrequencyID,
decimal decAtEveryTurnNumber,int intAtEveryTurnDoseID, decimal decPayMoney,
int intOfficeID,bool InhospitalNo)
{
SqlParameter[] mySqlParameters = {
new SqlParameter ("@Type",SqlDbType .Char),
new SqlParameter ("@MedicineID",SqlDbType.Int),
new SqlParameter ("@Number",SqlDbType.Decimal),
new SqlParameter ("@PrescriptionBillsID",SqlDbType .Int),
new SqlParameter ("@SendOutMedicineNo",SqlDbType.Bit),
new SqlParameter ("@SkinTestID",SqlDbType.Int),
new SqlParameter ("@UsageID",SqlDbType.Int),
new SqlParameter ("@UseMedicineFrequencyID",SqlDbType.Int),
new SqlParameter ("@AtEveryTurnNumber",SqlDbType.Decimal),
new SqlParameter ("@AtEveryTurnDoseID",SqlDbType.Int),
new SqlParameter ("@PayMoney",SqlDbType.Decimal),
new SqlParameter ("@OfficeID",SqlDbType.Int),
new SqlParameter ("@InhospitalNo",SqlDbType.Bit),
};
mySqlParameters[0].Value = "Frm_MenZhenYiShengGongZuoZhan_InsertChuFangDanMingXi";
mySqlParameters[1].Value = intMedicineID;
mySqlParameters[2].Value = strNumber;
mySqlParameters[3].Value = intPrescriptionBillsID;
mySqlParameters[4].Value = bitSendOutMedicineNo;
mySqlParameters[5].Value = intSkinTestID;
mySqlParameters[6].Value = intUsageID;
mySqlParameters[7].Value = intUseMedicineFrequencyID;
mySqlParameters[8].Value = decAtEveryTurnNumber;
mySqlParameters[9].Value = intAtEveryTurnDoseID;
mySqlParameters[10].Value = decPayMoney;
mySqlParameters[11].Value = intOfficeID;
mySqlParameters[12].Value = InhospitalNo;
int i = myDALMethod.UpdateData("門診登記_Frm_MenZhenYiShengGongZuoZhan", mySqlParameters);
return i;
}
第三步:界面層(UIL)代碼
int intMedicineID;
private void btSave_Click(object sender, EventArgs e)
{ //判斷是否添加行
if (dgvMedicineInformation.Rows.Count == 0)
{
MessageBox.Show("還沒添加藥品");
return;
}
//for循環獲取每一行的值檢查必填的是否爲空
for (int K = 0; K < dgvMedicineInformation.Rows.Count; K++)
{
intMedicineID = Convert.ToInt32(dgvMedicineInformation.Rows[K].Cells["MedicineID"].Value);
if (intMedicineID > 0)
{
int intSkinTestID = Convert.ToInt32(dgvMedicineInformation.Rows[K].Cells["SkinTestNo"].Value);
int intUsageID = Convert.ToInt32(dgvMedicineInformation.Rows[K].Cells["Usage"].Value);
int intUseMedicineFrequencyID = Convert.ToInt32(dgvMedicineInformation.Rows[K].Cells["UseMedicineFrequency"].Value);
int intAtEveryTurnDoseID = Convert.ToInt32(dgvMedicineInformation.Rows[K].Cells["AtEveryTurnDose"].Value);
int intOfficeID = Convert.ToInt32(dgvMedicineInformation.Rows[K].Cells["OfficeName"].Value);
if (intSkinTestID == 0 || intUsageID == 0 || intUseMedicineFrequencyID == 0 || intAtEveryTurnDoseID == 0 || intOfficeID == 0) //判斷dgvYaoPinXinXi裏面的cbo值是否爲空
{
MessageBox.Show("請填寫完整!");
return;
}
}
}
int J = 0;
decimal decSumNumber = 0;
foreach (DataGridViewRow dgvr in dgvMedicineInformation.Rows)
{
intMedicineID = Convert.ToInt32(dgvr.Cells["MedicineID"].Value);
//區別變量,開始給區別變量賦值爲1,目的爲了區分那是新增的藥品
int TianJiaID = Convert.ToInt32(dgvr.Cells["TianJiaID"].Value);
if ( TianJiaID==1)
{
decimal decNumber = Convert.ToDecimal(dgvr.Cells["SumNumber"].Value);
bool bitSendOutMedicineNo = false;
int SkinTestID = Convert.ToInt32(dgvr.Cells["SkinTestNo"].Value);
int UsageID = Convert.ToInt32(dgvr.Cells["Usage"].Value);
int UseMedicineFrequencyID = Convert.ToInt32(dgvr.Cells["UseMedicineFrequency"].Value);
decimal decAtEveryTurnNumber = Convert.ToDecimal(dgvr.Cells["AtEveryTurnNumber"].Value);
int AtEveryTurnDoseID = Convert.ToInt32(dgvr.Cells["AtEveryTurnDose"].Value);
int OfficeID = Convert.ToInt32(dgvr.Cells["OfficeName"].Value);
decimal decPayMoney = Convert.ToDecimal(dgvr.Cells["SumMoney"].Value);
decSumNumber = Convert.ToDecimal(dgvr.Cells["SumNumber"].Value);
int intStoreroomID = Convert.ToInt32(dgvr.Cells["StoreroomID"].Value);
//修改藥品庫房數量
myFrm_MenZhenYiShengGongZuoZhanClient.Frm_MenZhenYiShengGongZuoZhan_UpdateKuCunShu
(decSumNumber, intMedicineID, intStoreroomID);
// 新增藥品處方
J = myFrm_MenZhenYiShengGongZuoZhanClient.
Frm_MenZhenYiShengGongZuoZhan_InsertChuFangDanMingXi
(intMedicineID, decNumber, PulicStatic.ZhuYuanDengjiID, bitSendOutMedicineNo,
SkinTestID, UsageID, UseMedicineFrequencyID, decAtEveryTurnNumber,
AtEveryTurnDoseID, decPayMoney, OfficeID, true);
}
}
if (J > 0)
{
MessageBox.Show("保存成功!");
}
}
醫生對病人錄入處方以後進行醫囑的錄入,對應的醫囑錄入也只是新增的過程,由於前面描述太多的新增,所以不進一步的詳細描述了。除此外,還有些簡單的操作,如體溫單的錄入,病人信息的修改,和病人的消費情況的查詢,都是簡單的新增。
還有,醫生可以對病人檢查拍的影像進行查閱和管理。
如下圖1爲影像的新增,圖2 爲影像的查看
圖1
圖2
實現代碼如下:
1.影像的新增:
第一步:數據庫存儲過程
if @Type='Frm_YingXiangGuanLi_InsertImg'
begin
Insert ZY_ImageList(Date, FileName, Describe,RegisterInhospitalID)
values (@Date, @FileName, @Describe,@RegisterInhospitalID)
end
第二步:邏輯層(BLL)代碼
#region 新增影像
[OperationContract]
public int Frm_YingXiangGuanLi_InsertImg(string Date, byte[][] FileName,
string Describe, int RegisterInhospitalID)
{
string strFileName= FileNameLiu(FileName);
SqlParameter[] mySqlParameters = {
new SqlParameter ("@Type",SqlDbType .Char),
new SqlParameter ("@Date",SqlDbType.Char),
new SqlParameter ("@FileName",SqlDbType .Char),
new SqlParameter ("@Describe",SqlDbType .Char),
new SqlParameter ("@RegisterInhospitalID",SqlDbType .Int),
};
mySqlParameters[0].Value = "Frm_YingXiangGuanLi_InsertImg";
mySqlParameters[1].Value = Date;
mySqlParameters[2].Value = strFileName;
mySqlParameters[3].Value = Describe;
mySqlParameters[4].Value = RegisterInhospitalID;
return myDALMethod.UpdateData("住院登記_Frm_YingXiangGuanLi", mySqlParameters);
}
#endregion
#region 新增時文件流轉換
public string FileNameLiu(byte[][] FileLiu)
{
string strWenJanQianZui = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() +
DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString();
string FileName = "";
for (int i = 0; i < FileLiu.Length; i++)
{
//生成文件名
string WenJianMing = strWenJanQianZui + ".png";
//獲取路徑
string WenjianLuJing = System.AppDomain.CurrentDomain.BaseDirectory;
WenjianLuJing = WenjianLuJing + "image\\" + WenJianMing;
FileInfo fi = new System.IO.FileInfo(WenjianLuJing);//創建地址
FileStream fs;//文件流對象
fs = fi.OpenWrite();//文件流寫入
fs.Write(FileLiu[i], 0, FileLiu[i].Length);//文件流插入數據
fs.Close();//關閉文件流
FileName = WenJianMing;
}
return FileName;
}
#endregion
第三步:界面層(UIL)代碼
添加影像代碼:
private void btnInsertImage_Click(object sender, EventArgs e)
{
//lisBytes.Clear();//清空List數組
OpenFileDialog myOpenFileDialog = new OpenFileDialog();//打開文件
myOpenFileDialog.Filter = "*.jpg|*.jpg|*.mp4|*.mp4";//文件格式
myOpenFileDialog.Multiselect = false;//設置是否多選
if (myOpenFileDialog.ShowDialog() == DialogResult.OK)
{
dgImageInformation.Rows.Add(1);
string WenJianMing = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() +
DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() +
DateTime.Now.Minute.ToString()+".png";
//把當前日期轉化爲0000-00--00的格式
string wenJianRiQi = DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString();
dgImageInformation.Rows[dgImageInformation.Rows.Count - 1].Cells["FileName"].Value = WenJianMing;
dgImageInformation.Rows[dgImageInformation.Rows.Count - 1].Cells["Date"].Value = wenJianRiQi;
using (Stream sm = new FileStream(myOpenFileDialog.FileName, FileMode.Open, FileAccess.ReadWrite, FileShare.None))
{ //二進制文件長度
int length = (int)sm.Length;
//二進制文件存放的二進制數組
byte[] bytes = new byte[length];
//內存流讀取
sm.Read(bytes, 0, length);
//關閉內存流
sm.Close();
lisBytes.Add(bytes);
MemoryStream stmBLOBData = new MemoryStream(bytes);
}
}
}
保存影像代碼:
int j;
private void btnSaveImage_Click(object sender, EventArgs e)
{
//定義二進制數組,長度爲1
byte[][] byWenJian = new byte[1][];
//循環新增
for (int i = 0; i < lisBytes.Count; i++)
{
try
{
//對應賦值二進制數組
byWenJian[0] = lisBytes[i];
string WenJianDate = Convert.ToString(dgImageInformation.Rows[i].Cells["Date"].Value);
string MiaoShu = Convert.ToString(dgImageInformation.Rows[i].Cells["Describe"].Value);
j = myFrm_YingXiangGuanLiClient.
Frm_YingXiangGuanLi_InsertImg(WenJianDate, byWenJian, MiaoShu, PulicStatic.ZhuYuanDengjiID);
}
catch { }
}
if (j > 0)
{
MessageBox.Show("新增成功");
Frm_YingXiangGuanLi_Load(null,null);
}
}
2.影像的查看
第一步:數據庫存儲過程
if @Type='Frm_YingXiangGuanLi_SelectImg'
begin
SELECT ZY_ImageList.*
FROM ZY_ImageList
where RegisterInhospitalID=@RegisterInhospitalID
end--獲取影像
if @Type='Frm_YingXiangGuanLi_SelectFileName'
begin
SELECT FileName
FROM ZY_ImageList
where ZY_ImageList.ImageID=@ImageID
end--獲取文件名
第二步:邏輯層(BLL)代碼
[OperationContract]
public DataSet Frm_YingXiangGuanLi_SelectImg(int RegisterInhospitalID)
{
SqlParameter[] mySqlParameters = {
new SqlParameter ("@Type",SqlDbType .Char),
new SqlParameter ("@RegisterInhospitalID",SqlDbType .Int),
};
mySqlParameters[0].Value = "Frm_YingXiangGuanLi_SelectImg";
mySqlParameters[1].Value = RegisterInhospitalID;
DataTable dt = myDALMethod.QueryDataTable("住院登記_Frm_YingXiangGuanLi", mySqlParameters);
DataSet ds = new DataSet();
ds.Tables.Add(dt);
return ds;
}
[OperationContract]
public DataSet Frm_YingXiangGuanLi_SelectFileName(int ImageID)
{
SqlParameter[] mySqlParameters = {
new SqlParameter ("@Type",SqlDbType .Char),
new SqlParameter ("@ImageID",SqlDbType .Int),
};
mySqlParameters[0].Value = "Frm_YingXiangGuanLi_SelectFileName";
mySqlParameters[1].Value = ImageID;
DataTable dt = myDALMethod.QueryDataTable("住院登記_Frm_YingXiangGuanLi", mySqlParameters);
DataSet ds = new DataSet();
ds.Tables.Add(dt);
return ds;
}
#region 查看影像路徑轉換文件流
private byte[][] WenJianLiuZhuanHuanLuJing(string strLuJing)
{
byte[][] lstbytes = new byte[1][];
if (strLuJing != "")
{
string strBaoCunLuJIng = System.AppDomain.CurrentDomain.BaseDirectory;
strLuJing = strBaoCunLuJIng + "image\\" + strLuJing;
using (Stream sm = new FileStream(strLuJing, FileMode.Open, FileAccess.ReadWrite, FileShare.None))
{
//二進制文件長度
int length = (int)sm.Length;
//二進制文件存放的二進制數組
byte[] bytes = new byte[length];
//內存流讀取
sm.Read(bytes, 0, length);
//關閉內存流
sm.Close();
////將數據保存到數據庫中
lstbytes[0] = bytes;
}
}
return lstbytes;
}
#endregion
第三步:界面層(UIL)代碼
byte[][] TuPian;//定義二進制數組
private void Frm_ChaKanYingXiang_Load(object sender, EventArgs e)
{ //查詢文件名你
DataTable dt = myFrm_YingXiangGuanLiClient.
Frm_YingXiangGuanLi_SelectFileName(Frm_YingXiangGuanLi.ImageID).Tables[0];
if (dt.Rows.Count > 0)
{
TuPian = myFrm_YingXiangGuanLiClient.Frm_YingXiangGuanLi_UpdateFileName
(dt.Rows[0]["FileName"].ToString().Trim());
MemoryStream stmBLOBData = new MemoryStream(TuPian[0]);
XianShiTuPian(stmBLOBData);
}
else
{
MessageBox.Show("請選擇影像");
}
}
void XianShiTuPian(Stream st)
{
//實例化PictureBox
PictureBox myPictureBox = new PictureBox();
//從指定的數據流創建
Image myImage = Image.FromStream(st);
//影像大小
myPictureBox.Size = myImage.Size;
myPictureBox.BackgroundImage = myImage;
//獲取或設置在 System.Windows.Forms.ImageLayout 枚舉中定義的背景圖像佈局。
myPictureBox.BackgroundImageLayout = ImageLayout.Zoom;
plImage.Controls.Add(myPictureBox);
}
僅供學習,禁止用於商業用途!