病人换床
换床,就是给病人另一张空床,换过去之后原本的床位就是空的了,我们怎么去实现呢!
当我们点击选中要换床的病人时,就会获取到当前的床位ID,然后根据这个床号ID查询到入院ID,点击换床时就会弹出模态框,然后输入床号,这时我们就根据输入的床号查询到床号ID,查到输入的床号ID后就是在控制器写修改,把入院表的床位ID修改成查到的床号ID。然后就是床位的状态,床位有2个状态,有病人就是true,没有病人就是false。
所以还要修改床位的状态。
打开模特框,点击保存:
function sfaidejiakeus() {
var StateaanA = false;//床号的状态赋值
var Stateaanw = true;
var BedNumber = $("#formhuanBedNumber [name='BedNumber']").val();
var ClinicalID = $("#formUpdateExamine [name='ClinicalCenterName']").val();
//加载层
var load = layer.load();
// BedNumberIDs是通过点击后获取到的,要怎么获取下面有载图
$.post("fesfefBedNumber", { BedNumberID: BedNumberIDs }, function (data) {
var AdmissionFormIDw = data.AdmissionFormID;//根据床号ID查询到的入院ID
$.post("/NursesStation/Bedbrowse/selectStateaan", { ClinicalID: ClinicalID, BedNumber: BedNumber }, function (data) {
//根据输入的床号查询到的床号ID
var BedNumberIDw = data[0].BedNumberID;
$.post("/NursesStation/Bedbrowse/UhuancBedNumber",
{
BedNumberID: BedNumberIDw,
AdmissionFormID: AdmissionFormIDw,
Stateaan: Stateaanw,
}, function (data) {
//关闭加载层
layer.close(load);
if (data.State) {
//当病人换床成功后,就把原来的床位状态修改成false$.post("huancBedNumber", { Stateaan: StateaanA, BedNumberID: BedNumberIDs }, function (data) { });
//关闭模态框
$("#huanBedNumber").modal("hide");
layer.msg(data.Text, { icon: 1, title: "提示" });
//刷新表格
tabPatientSurface1.reload();
} else {
layer.alert(data.Text, { icon: 0, title: "提示" });
}
});
});
});
}
控制器:
1、根据获取到的床号ID,查询到入院ID(AdmissionFormID)
public ActionResult fesfefBedNumber( int BedNumberID)
{
studentVo dbAdmissionForm = (from tbAdmissionForm in myModel.PW_AdmissionForm
join tbPatientSurface in myModel.PW_PatientSurface on tbAdmissionForm.PatientSurfaceID equals tbPatientSurface.PatientSurfaceID
where tbAdmissionForm.BedNumberID == BedNumberID
select new studentVo
{
BedNumberID=tbAdmissionForm.BedNumberID,
AdmissionFormID=tbAdmissionForm.AdmissionFormID,
PatientSurfaceID=tbPatientSurface.PatientSurfaceID
}).Single();
return Json(dbAdmissionForm, JsonRequestBehavior.AllowGet);
}
2、根据输入的床号,查询到床号ID,有这一步就直接用,不用另外再写
public ActionResult selectStateaan(int ClinicalID, string BedNumber)
{
List<studentVo> linqStateaan = (from tbClinicalCenter in myModel.PW_ClinicalCenter
join tbBedNumber in myModel.PW_BedNumber on tbClinicalCenter.ClinicalCenterID equals tbBedNumber.ClinicalCenterID
where tbClinicalCenter.ClinicalCenterID == ClinicalID && tbBedNumber.BedNumber == BedNumber
select new studentVo
{
Stateaan = tbBedNumber.Stateaan,
BedNumberID = tbBedNumber.BedNumberID,
BedNumber = tbBedNumber.BedNumber,
ClinicalCenterID = tbClinicalCenter.ClinicalCenterID,
}).ToList();
return Json(linqStateaan, JsonRequestBehavior.AllowGet);
}
3、修改入院表的床号ID和现在的床号状态
public ActionResult UhuancBedNumber(PW_BedNumber pwBedNumber, PW_AdmissionForm pwAdmissionForm, bool Stateaan)
{
ReturnJsonVo returnJson = new ReturnJsonVo();
returnJson.State = false;
try
{
PW_AdmissionForm dbAdmissionForm = (from tbAdmissionForm in myModel.PW_AdmissionForm
where tbAdmissionForm.AdmissionFormID == pwAdmissionForm.AdmissionFormID
select tbAdmissionForm).Single();
dbAdmissionForm.BedNumberID = pwAdmissionForm.BedNumberID;
myModel.Entry(dbAdmissionForm).State = EntityState.Modified;
PW_BedNumber dbBedNumber = (from tbBedNumber in myModel.PW_BedNumber
where tbBedNumber.BedNumberID == pwBedNumber.BedNumberID
select tbBedNumber).Single();
dbBedNumber.Stateaan = pwBedNumber.Stateaan;
myModel.Entry(dbBedNumber).State = EntityState.Modified;
if (myModel.SaveChanges() > 0)
{
returnJson.State = true;
returnJson.Text = "换床成功^-^";
}
else
{
returnJson.Text = "换床失败";
}
}
catch (Exception)
{
returnJson.Text = "数据异常!";
}
return Json(returnJson, JsonRequestBehavior.AllowGet);
}
4、修改原来的床号状态
public ActionResult huancBedNumber(PW_BedNumber pwBedNumber)
{
ReturnJsonVo returnJson = new ReturnJsonVo();
returnJson.State = false;
PW_BedNumber dbBedNumber = (from tbBedNumber in myModel.PW_BedNumber
where tbBedNumber.BedNumberID == pwBedNumber.BedNumberID
select tbBedNumber).Single();
dbBedNumber.Stateaan = pwBedNumber.Stateaan;
myModel.Entry(dbBedNumber).State = EntityState.Modified;
if (myModel.SaveChanges() > 0)
{
returnJson.State = true;
}
return Json(dbBedNumber, JsonRequestBehavior.AllowGet);
}