出院步骤分为住院退床和出院结算,此操作主要是对病人要出院结算前的退床操作,可以点击在院病人列表选择未退床的病人,并且载人。
也可以单击查找弹出床位图,根据病区选择病人,退床后,相应的病区的床位会更改为空床。退床后,病人可以办理出院结算,系统会自动列出病人在院的消费明细和计算出应缴纳的款项,看病人的押金是否足够,结算时系统会根据病人的医疗性质进行对其减免一部分的消费金额。程序如下图:
首先出院退床
也可单击查找按钮查找病人,如下图;
从所有界面上可以看到我们这里用到的控件有
控件名称 | 说明 |
复选框(CheckBox) | 控件可以在工具箱直接拖动至窗体,拖至窗体后右击属性可以修改控件的样式和各种属性,还可以编辑事件。 |
下拉框(ComboBox) | |
文本(TextBox) | |
按钮(Button) | |
表格(DataGridView) |
表和关系
表 1床位分配表 ZY_BedLocationAllocationList
列名 | 数据类型 | 说明 |
BedLocationAllocationID | int - Identity | 床位分配ID |
RegisterInhospitalID | int | 住院登记ID |
BedLocationID | int | 床位ID |
EnterResideTime | datetime | 入住时间 |
QuitBedTime | datetime | 退床时间 |
QuitBedNo | bit | 退床否 |
首先解析如何实现点击在院病人列表时实现界面的转换变化的逻辑。和对应的文本赋值
/// <summary>
/// “载人病人列表”的是否选中事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void chkSelectInformation_CheckedChanged(object sender, EventArgs e)
{
pldgv.Visible = true;//病人表格显示
plXinxi.Visible = false;//病人信息文本隐藏
btnEnter.Enabled = true;//载入按钮启用
btnEnter.BackColor = Color.Gainsboro;//设置载人按钮的颜色
if (chkSelectInformation.Checked == false)//如果“载人病人列表”取消打钩
{
pldgv.Visible = false;//病人表格隐藏
plXinxi.Visible = true;//病人信息文本显示
btnEnter.Enabled = false;//载入按钮禁用
btnEnter.BackColor = Color.SlateGray;//设置载人按钮的颜色
}
}
/// <summary>
/// 载人按钮的单击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnEnter_Click(object sender, EventArgs e)
{
try
{
//给文本框对应的赋值
txtXingMing.Text = dgSickInformation.CurrentRow.Cells["BingRenName"].Value.ToString().Trim();
txtMenZhenNumber.Text = dgSickInformation.CurrentRow.Cells["InHospitalNumber"].Value.ToString().Trim();
txtZhuYuanHao1.Text = dgSickInformation.CurrentRow.Cells["InHospitalNumber"].Value.ToString().Trim();
txtXingBie.Text = dgSickInformation.CurrentRow.Cells["Sex"].Value.ToString().Trim();
txtKeShi.Text = dgSickInformation.CurrentRow.Cells["OfficeName"].Value.ToString().Trim();
txtLianXiRen.Text = dgSickInformation.CurrentRow.Cells["LinkMan"].Value.ToString().Trim();
txtLianXiRenGuanXi.Text = dgSickInformation.CurrentRow.Cells["Relation"].Value.ToString().Trim();
txtLianXiRenXingMing.Text = dgSickInformation.CurrentRow.Cells["LinkMan"].Value.ToString().Trim();
txtMenZhengHao.Text = dgSickInformation.CurrentRow.Cells["MenZhenNumber"].Value.ToString().Trim();
txtMenZhenZhenDuan.Text = dgSickInformation.CurrentRow.Cells["MenZhengDiagnosi"].Value.ToString().Trim();
txtMinZu.Text = dgSickInformation.CurrentRow.Cells["Nation"].Value.ToString().Trim();
txtRuYuanRiQi.Text = dgSickInformation.CurrentRow.Cells["EnterHospitalDate"].Value.ToString().Trim();
txtShenFenZheng.Text = dgSickInformation.CurrentRow.Cells["IdentityCardNumber"].Value.ToString().Trim();
txtYiSheng.Text = dgSickInformation.CurrentRow.Cells["DoctorName"].Value.ToString().Trim();
txtChuanWei.Text = dgSickInformation.CurrentRow.Cells["BedLocationNumber"].Value.ToString().Trim();
//文本框赋值完后执行如下操作
plXinxi.Visible = true;//病人信息文本显示
pldgv.Visible = false;//病人表格隐藏
btnEnter.Enabled = false;//载人按钮禁用
btnEnter.BackColor = Color.SlateGray;//设置载人按钮的颜色
chkSelectInformation.Checked = false;//“载人病人列表”取消打钩
}
catch { }
}
点击选择病人时病人信息对应赋值到文本并且获取床位ID,退床状态的实现
#region 窗体再次激活时给它传值
private void Frm_TuiChuang_Activated(object sender, EventArgs e)
{
if (PulicStatic.XuanZeFou == true)
{
//对应赋值文本
txtXingMing.Text = Frm_ChuangWeiTu.XingMing;
txtMenZhenNumber.Text = Frm_ChuangWeiTu.ZhuYuanHao;
txtXingBie.Text = Frm_ChuangWeiTu.XingBie;
txtKeShi.Text = Frm_ChuangWeiTu.KeShi;
txtLianXiRen.Text = Frm_ChuangWeiTu.LianXiRen;
txtLianXiRenGuanXi.Text = Frm_ChuangWeiTu.LianXiRenGuanXi;
txtLianXiRenXingMing.Text = Frm_ChuangWeiTu.LianXiRenXingMing;
txtMenZhengHao.Text = Frm_ChuangWeiTu.MenZhengHao;
txtMenZhenZhenDuan.Text = Frm_ChuangWeiTu.MenZhenZhenDuan;
txtMinZu.Text = Frm_ChuangWeiTu.MinZu;
txtRuYuanRiQi.Text = Frm_ChuangWeiTu.RuYuanRiQi;
txtShenFenZheng.Text = Frm_ChuangWeiTu.ShenFenZheng;
txtYiSheng.Text = Frm_ChuangWeiTu.YiSheng;
txtChuanWei.Text = Frm_ChuangWeiTu.ChuanWei;
txtZhuYuanHao1.Text = Frm_ChuangWeiTu.ZhuYuanHao;
//查询退床状态
dgOutBedInformation.DataSource = myFrm_ChuangWeiTuClient.
Frm_ChuangWeiTu_select_ChuangWeiFenPeiBiao(PulicStatic.ZhuYuanDengjiID).Tables[0];
if (dgOutBedInformation.Rows.Count > 0)
{ //获取退床状态
TuiChuFou = dgOutBedInformation.Rows[0].Cells["QuitBedNo"].Value.ToString().Trim();
}
}
}
#endregion
其他为一些简单的查询和表格的绑定,已经在我的前几篇博客中用详细的介绍。接下是退出时的实现代码
数据库存储过程
if @Type='Frm_ChuangWeiTu_TuiChuang'
begin
begin tran
update ZY_BedLocationAllocationList
set QuitBedTime=@QuitBedTime, QuitBedNo=1
where ZY_BedLocationAllocationList.BedLocationID=@BedLocationID
update ZY_BedLocationList
set StatusID=107
where ZY_BedLocationList.BedLocationID=@BedLocationID
commit tran
end--修改床位状态
逻辑层代码
[OperationContract]
public int Frm_ChuangWeiTu_TuiChuang(DateTime TuiChuangShiJian,int ChuangWeiID)
{
SqlParameter[] mySqlParameters = {
new SqlParameter ("@Type",SqlDbType .Char),
new SqlParameter ("@QuitBedTime",SqlDbType .DateTime),
new SqlParameter ("@BedLocationID",SqlDbType .Int),
};
mySqlParameters[0].Value = "Frm_ChuangWeiTu_TuiChuang";
mySqlParameters[1].Value =TuiChuangShiJian;
mySqlParameters[2].Value = ChuangWeiID;
return myDALMethod.UpdateData("住院登记_Frm_ChuangWeiTu", mySqlParameters);
}
界面层代码
private void btnOutBed_Click(object sender, EventArgs e)
{
DateTime TuiChuangShiJian = DateTime.Now;//获取当前时间
int ChuangWeiID = PulicStatic.ChuangWeiID;//获取单击的床位ID
if (TuiChuFou == "未退床")//如果退床状态为“未退床”
{
if (MessageBox.Show("是否退床?", "提示!", MessageBoxButtons.YesNo) == DialogResult.Yes)
{ //单击是执行如下操作
//修改床位状态
int i = myFrm_ChuangWeiTuClient.Frm_ChuangWeiTu_TuiChuang(TuiChuangShiJian, ChuangWeiID);
if (i > 0)//返回受影响行数>0
{
//提示成功
MessageBox.Show("退床成功!!");
//查询床位分配信息
dgOutBedInformation.DataSource = myFrm_ChuangWeiTuClient.
Frm_ChuangWeiTu_select_ChuangWeiFenPeiBiao(PulicStatic.ZhuYuanDengjiID).Tables[0];
PulicStatic.XuanZeFou = false;
}
}
}
else
{
MessageBox.Show("此病人已经退床!");
}
}
退床以后可以办理出院结算,系统会自动计算出该病人的费用信息点击收费结算:如下图
结算时的表和关系
表 2 结算表
列名 | 数据类型 | 说明 |
LeaveHospitalID | int - Identity | 出院结算ID |
RegisterInhospitalID | int | 住院登记ID |
SettleAccountsID | int | 结算方式ID |
LeaveHospitalWayID | int | 出院情况Id |
LeaveHospitalDate | date | 出院日期 |
SumCashPledge | decimal (18, 2) | 总金额 |
SurplusMoney | decimal (18, 2) | 剩余金额 |
SumMoney | decimal (18, 2) | 总金额 |
EffectiveNo | bit | 有效否 |
XiangMuMingCheng | nchar (10) | 项目名称 |
从界面看到病人消费的详细的信息,实现了多表查询的合并。代码如下:
数据库存储过程
if @Type='Frm_ChuYuanJieSuan_SelectJiZhang'
begin
SELECT ZY_InHospitalTallyMingXiList.ProjectName, ZY_InHospitalTallyMingXiList.SumMoney,
ZY_InHospitalTallyMingXiList.MedicineID
FROM ZY_InHospitalTallyMingXiList INNER JOIN
ZY_InHospitalTallyList ON ZY_InHospitalTallyMingXiList.InHospitalTallyID =
ZY_InHospitalTallyList.InHospitalTallyID
where ZY_InHospitalTallyList.RegisterInhospitalID=@RegisterInhospitalID
and ZY_InHospitalTallyList.LeaveHospitalNo=0
union
SELECT KC_MedicineList.MedicineName as ProjectName,
MZ_PrescriptionBillsMingXiList.PayMoney as SumMoney,
MZ_PrescriptionBillsMingXiList.MedicineID
FROM MZ_PrescriptionBillsMingXiList INNER JOIN
KC_MedicineList ON MZ_PrescriptionBillsMingXiList.MedicineID
= KC_MedicineList.MedicineID
where MZ_PrescriptionBillsMingXiList.InhospitalNo=1
and MZ_PrescriptionBillsMingXiList.PrescriptionBillsID=@RegisterInhospitalID
end--查询记账信息
逻辑层代码
[OperationContract]
public DataSet Frm_ChuYuanJieSuan_SelectJiZhang(int RegisterInhospitalID)
{
SqlParameter[] mySqlParameters = {
new SqlParameter ("@Type",SqlDbType .Char),
new SqlParameter ("@RegisterInhospitalID",SqlDbType.Int),
};
mySqlParameters[0].Value = "Frm_ChuYuanJieSuan_SelectJiZhang";
mySqlParameters[1].Value = RegisterInhospitalID;
DataTable dt = myDALMethod.QueryDataTable("住院登记_Frm_ChuYuanJieSuan", mySqlParameters);
DataSet ds = new DataSet();
ds.Tables.Add(dt);
return ds;
}
界面层代码
dgCost.DataSource = myFrm_ChuYuanJieSuanClient.Frm_ChuYuanJieSuan_SelectJiZhang
(PulicStatic.ZhuYuanDengjiID).Tables[0];
绑定病人信息时,计算住院天数代码;
#region 计算住院天数
public void ChaiFenZhuYuanTianShu()
{
TianShu[0] = "";
//定义一个char型数组长度为拆分的字符的长度
char[] myc = new char[ZhuYuanTianShu.Count()];
//把要拆分的字符复制到Char型数组中
// sourceIndex:
// 要复制的此实例中第一个字符的索引。
//
// destination:
// 此实例中的字符所复制到的 Unicode 字符数组。
//
// destinationIndex:
// destination 中的索引,在此处开始复制操作。
//
// count:
// 此实例中要复制到 destination 的字符数。
//
ZhuYuanTianShu.CopyTo(0, myc, 0, ZhuYuanTianShu.Count());
for (int i = 0; i < ZhuYuanTianShu.Count(); i++)
{
//获取字符串中的"."号
string ZiFu = Convert.ToString(myc[i]);
//判断是否为"."是就跳出循环
if (ZiFu == ".")
{
return;
}
//赋值到字符串数组
TianShu[0] += myc[i];
}
}
#endregion
对应的押金总额,自付金的计算实现
#region 计算押金和项目费用等
public void JiSuanYaJi()
{
//查询绑定病人所有消费的项目
dgCost.DataSource = myFrm_ChuYuanJieSuanClient.Frm_ChuYuanJieSuan_SelectJiZhang
(PulicStatic.ZhuYuanDengjiID).Tables[0];
//查询病人缴纳所有押金
DataTable dtYaJin = myFrm_ChuYuanJieSuanClient.Frm_ChuYuanJieSuan_SelectYaJin
(PulicStatic.ZhuYuanDengjiID).Tables[0];
//for循环计算
for (int i = 0; i < dtYaJin.Rows.Count; i++)
{
//计算总押金
YaJi += Convert.ToDecimal(dtYaJin.Rows[i]["PledgeGold"]);
}
//赋值
txtSumPledgeGoldBills.Text = Convert.ToString(YaJi);
//for循环计算总金和自付金
for (int j = 0; j < dgCost.Rows.Count; j++)
{
//计算项目总金和自付金
XianMuZongJin += Convert.ToDecimal(dgCost.Rows[j].Cells["SumMoney"].Value);
int YoPingID = Convert.ToInt32(dgCost.Rows[j].Cells["MedicineID"].Value);
//按病人医疗性质和病项目ID查询对应的折扣率
DataTable dtZheKouLv = myFrm_ChuYuanJieSuanClient.Frm_ChuYuanJieSuan_FeiYongXinXi_SelectZheKouLi
(PulicStatic.YiLiaoFangShi, YoPingID).Tables[0];
if (dtZheKouLv.Rows.Count > 0)//如果病人消费的项目存在折扣率
{
//获取总金额
decimal ZongJinE = Convert.ToDecimal(dgCost.Rows[j].Cells["SumMoney"].Value);
//自付金=总金额*折扣率
dgCost.Rows[j].Cells["PayOneselfMoney"].Value = ZongJinE * Convert.ToDecimal(dtZheKouLv.Rows[0][0]);
}
else
{
//获取总金额
decimal ZongJinE = Convert.ToDecimal(dgCost.Rows[j].Cells["SumMoney"].Value);
//如果没有对应的折扣率则自付金=总金额
dgCost.Rows[j].Cells["PayOneselfMoney"].Value = ZongJinE;
}
//对应的自付金赋值
ZhiFuJin += Convert.ToDecimal(dgCost.Rows[j].Cells["PayOneselfMoney"].Value);
}
//对应文本赋值
txtSumCost.Text = Convert.ToString(XianMuZongJin);
//余额=押金-自付金
Yu = YaJi - ZhiFuJin;
txtSurplus.Text = Convert.ToString(Yu);
txtRealityMoney.Text = Convert.ToString(-Yu);
}
#endregion
最后点击收费结算
数据库存储过程
if @Type='Frm_ChuYuanJieSuan_insertChuYuanJieSuan'
begin
if EXISTS (select RegisterInhospitalID
from ZY_LeaveHospitalList
where ZY_LeaveHospitalList.RegisterInhospitalID=@RegisterInhospitalID
)--查询表中是否存在RegisterInhospitalID
begin
update ZY_InHospitalRegisterList
set ZY_InHospitalRegisterList.LeaveHospitalNo=1
where ZY_InHospitalRegisterList.RegisterInhospitalID=@RegisterInhospitalID
insert ZY_LeaveHospitalList(RegisterInhospitalID, SettleAccountsID, LeaveHospitalWayID, LeaveHospitalDate,
SumCashPledge, SurplusMoney, SumMoney,EffectiveNo,XiangMuMingCheng)
values (@RegisterInhospitalID, @SettleAccountsID, @LeaveHospitalWayID, @LeaveHospitalDate,@SumCashPledge,
@SurplusMoney, @SumMoney,1,'复诊单')--如果存在RegisterInhospitalID新增复诊单
end
else
begin
insert ZY_LeaveHospitalList(RegisterInhospitalID, SettleAccountsID, LeaveHospitalWayID, LeaveHospitalDate,
SumCashPledge, SurplusMoney, SumMoney,EffectiveNo,XiangMuMingCheng)
values (@RegisterInhospitalID, @SettleAccountsID, @LeaveHospitalWayID, @LeaveHospitalDate,@SumCashPledge,
@SurplusMoney, @SumMoney,1,'结算单')-- 否则为结算单
update ZY_InHospitalRegisterList
set ZY_InHospitalRegisterList.LeaveHospitalNo=1
where ZY_InHospitalRegisterList.RegisterInhospitalID=@RegisterInhospitalID
end
end--新增结算表数据
逻辑层代码
[OperationContract]
public DataSet Frm_ChuYuanJieSuan_cboChuYuanQingKuan()
{
SqlParameter[] mySqlParameters = {
new SqlParameter ("@Type",SqlDbType .Char),
};
mySqlParameters[0].Value = "Frm_ChuYuanJieSuan_cboChuYuanQingKuan";
DataTable dt = myDALMethod.QueryDataTable("住院登记_Frm_ChuYuanJieSuan", mySqlParameters);
DataSet ds = new DataSet();
ds.Tables.Add(dt);
return ds;
}
[OperationContract]
public int Frm_ChuYuanJieSuan_insertChuYuanJieSuan(int RegisterInhospitalID, int SettleAccountsID,
int LeaveHospitalWayID, DateTime LeaveHospitalDate, decimal SumCashPledge, decimal SurplusMoney,
decimal SumMoney)
{
SqlParameter[] mySqlParameters = {
new SqlParameter ("@Type",SqlDbType .Char),
new SqlParameter ("@RegisterInhospitalID",SqlDbType .Int),
new SqlParameter ("@SettleAccountsID",SqlDbType .Int),
new SqlParameter ("@LeaveHospitalWayID",SqlDbType .Int),
new SqlParameter ("@LeaveHospitalDate",SqlDbType .DateTime),
new SqlParameter ("@SumCashPledge",SqlDbType .Decimal),
new SqlParameter ("@SurplusMoney",SqlDbType .Decimal),
new SqlParameter ("@SumMoney",SqlDbType .Decimal),
};
mySqlParameters[0].Value = "Frm_ChuYuanJieSuan_insertChuYuanJieSuan";
mySqlParameters[1].Value = RegisterInhospitalID;
mySqlParameters[2].Value = SettleAccountsID;
mySqlParameters[3].Value = LeaveHospitalWayID;
mySqlParameters[4].Value = LeaveHospitalDate;
mySqlParameters[5].Value = SumCashPledge;
mySqlParameters[6].Value = SurplusMoney;
mySqlParameters[7].Value = SumMoney;
return myDALMethod.UpdateData("住院登记_Frm_ChuYuanJieSuan", mySqlParameters);
}
界面层代码
#region 收费结算
private void btnCostSettleAccounts_Click(object sender, EventArgs e)
{
if (Yu < 0)//如果剩余的金额<0
{
if (txtEnterMoney.Text == "")//如果收到金额为空
{
MessageBox.Show("还未付款不能现金结算!");//提示
return;//跳出方法
}
}
if (ZaoLing < 0)//如果找零<0
{
MessageBox.Show("付款不足不能现金结算!");//提示
return;//跳出方法
}
//对应的获取值
int RegisterInhospitalID = PulicStatic.ZhuYuanDengjiID;
int SettleAccountsID = Convert.ToInt32(cboSettleAccountsWay.SelectedValue);
int LeaveHospitalWayID = Convert.ToInt32(cboOutHospitalCondition.SelectedValue);
DateTime LeaveHospitalDate = DateTime.Now;
decimal SumCashPledge = Convert.ToDecimal(txtSumPledgeGoldBills.Text);
decimal SurplusMoney = Convert.ToDecimal(txtSurplus.Text);
decimal SumMoney = Convert.ToDecimal(txtSumCost.Text);
int ChengGong = myFrm_ChuYuanJieSuanClient.Frm_ChuYuanJieSuan_insertChuYuanJieSuan
(RegisterInhospitalID, SettleAccountsID, LeaveHospitalWayID, LeaveHospitalDate,
SumCashPledge, SurplusMoney, SumMoney);
int j = myFrm_ChuYuanJieSuanClient.Frm_ChuYuanJieSuan_updateAllLeaveHospitalNo(PulicStatic.ZhuYuanDengjiID);
if (ChengGong > 0 && j > 0)
{
MessageBox.Show("结算成功!");
}
}
#endregion