public ActionResult Create([Bind()] Models.ViewModels.RescueRoomConsultations.Create.Create targetV) { if (ModelState.IsValid) { var db = new EiSDbContext(); var target = targetV.GetReturn(); Models.BusinessModels.TrasenInformationConvertor.FromEmployeeNumberToName(target); db.RescueRoomConsultations.Add(target); db.SaveChanges(); //处理返回页面 if (targetV.GoToGreenPath == true) { var rescueRoomInfo = db.RescueRoomInfos.Find(targetV.RescueRoomInfoId); return(RedirectToAction(rescueRoomInfo.GreenPathActionName, "GreenPaths", new { id = rescueRoomInfo.GreenPathId })); } return(RedirectToAction("Details", "RescueRoomInfos", new { id = targetV.RescueRoomInfoId })); } var targetW = new Models.ViewModels.RescueRoomConsultations.Create.SelectionWorker(targetV); ViewBag.ConsultationDepartmentId = targetW.ConsultationDepartments; return(View(targetV)); }
public ActionResult EditAmi([Bind()] Models.ViewModels.GreenPaths.EditAmi.EditAmi targetV) { //var db = new EiSDbContext(); //var rescueRoomInfo = db.RescueRoomInfos.Find(greenPathAmi.RescueRoomInfoId); ////1-须先有首次心电图才能有再次心电图。 //if (greenPathAmi.EcgSecondTime.HasValue && !greenPathAmi.EcgFirstTime.HasValue) // ModelState.AddModelError("EcgSecondTime", "须先有首次心电图才能有再次心电图。"); ////2-再次心电图时间不可早于首次心电图时间。 //if (greenPathAmi.EcgSecondTime.HasValue && greenPathAmi.EcgFirstTime.HasValue && greenPathAmi.EcgFirstTime.Value > greenPathAmi.EcgSecondTime.Value) // ModelState.AddModelError("EcgSecondTime", "再次心电图时间不可早于首次心电图时间。"); ////3-完成通道时,发病时间不可为空。 //if (greenPathAmi.IsFinished && !greenPathAmi.OccurrenceTime.HasValue) // ModelState.AddModelError("OccurrenceTime", "完成通道时,发病时间不可为空。"); ////4-发病时间不可晚于接诊时间。 //if (rescueRoomInfo.ReceiveTime.HasValue && greenPathAmi.OccurrenceTime.HasValue && rescueRoomInfo.ReceiveTime.Value < greenPathAmi.OccurrenceTime.Value) // ModelState.AddModelError("OccurrenceTime", "发病时间不可晚于接诊时间。"); ////5-首次心电图时间不能早于接诊时间。 ////if (rescueRoomInfo.ReceiveTime.HasValue && greenPathAmi.EcgFirstTime.HasValue && rescueRoomInfo.ReceiveTime.Value > greenPathAmi.EcgFirstTime.Value) //// ModelState.AddModelError("EcgFirstTime", "首次心电图时间不能早于接诊时间。"); ////6-再次心电图时间不能晚于完成通道时间。 //if (greenPathAmi.FinishPathTime.HasValue && greenPathAmi.EcgSecondTime.HasValue && greenPathAmi.FinishPathTime.Value < greenPathAmi.EcgSecondTime.Value) // ModelState.AddModelError("EcgSecondTime", "再次心电图时间不能晚于完成通道时间。"); ////7-完成通道时间不能早于接诊时间。 //if (rescueRoomInfo.ReceiveTime.HasValue && greenPathAmi.FinishPathTime.HasValue && rescueRoomInfo.ReceiveTime.Value > greenPathAmi.FinishPathTime.Value) // ModelState.AddModelError("EcgFirstTime", "完成通道时间不能早于接诊时间。"); if (ModelState.IsValid) { var db = new EiSDbContext(); var target = db.GreenPathAmis.Find(targetV.GreenPathAmiId); if (target == null) { return(HttpNotFound()); } targetV.GetReturn(target); db.SaveChanges(); return(RedirectToAction("DetailsAmi", new { id = target.GreenPathAmiId })); } return(View(targetV)); }
/// <summary> /// 急性心肌梗死新增。 /// </summary> /// <param name="rescueRoomInfoId">归属的抢救室病例ID。</param> /// <remarks>直接生成后,跳转到Edit。</remarks> public ActionResult CreateAmi(Guid rescueRoomInfoId) { var db = new EiSDbContext(); var rescueRoomInfo = db.RescueRoomInfos.Find(rescueRoomInfoId); if (rescueRoomInfo == null) { return(HttpNotFound()); } if (db.GreenPathAmis.Any(c => c.RescueRoomInfoId == rescueRoomInfoId)) { return(HttpNotFound()); } var target = new GreenPathAmi(); target.GreenPathAmiId = Guid.NewGuid(); target.RescueRoomInfoId = rescueRoomInfoId; target.UpdateTime = DateTime.Now; db.GreenPathAmis.Add(target); db.SaveChanges(); //**已用索引保证唯一性** //if (db.GreenPathAmis.Count(c => c.RescueRoomInfoId == rescueRoomInfoId) > 1) //{ // db.GreenPathAmis.Remove(target); // db.SaveChanges(); // return HttpNotFound(); //} return(RedirectToAction("EditAmi", new { id = target.GreenPathAmiId })); }
/// <summary> /// 刷新。 /// </summary> /// <param name="id">归属的抢救室病例ID。</param> public ActionResult Refresh(Guid rescueRoomInfoId) { var db = new EiSDbContext(); var target = db.RescueRoomInfos.Find(rescueRoomInfoId); if (target == null) { return(HttpNotFound()); } Oracle.ManagedDataAccess.Client.OracleConnection connection; Oracle.ManagedDataAccess.Client.OracleCommand command; Oracle.ManagedDataAccess.Client.OracleDataAdapter dataAdapter; connection = new Oracle.ManagedDataAccess.Client.OracleConnection("Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.100.9)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=hzsydb)));User Id=pacsinterface;Password=pubpacs;"); command = new Oracle.ManagedDataAccess.Client.OracleCommand(string.Format("select * from pacstations.PACS_CHECK_VIEW where cureid='{0}' AND chktime>= to_date('{1}','yyyy-mm-dd')", target.OutPatientNumber, target.InDepartmentTime.ToString("yyyy-MM-dd")), connection); var dataSet = new System.Data.DataSet(); dataAdapter = new Oracle.ManagedDataAccess.Client.OracleDataAdapter(command); dataAdapter.Fill(dataSet); foreach (System.Data.DataRow row in dataSet.Tables[0].Rows) { var newRescueRoomImageRecord = new RescueRoomImageRecord(); newRescueRoomImageRecord.BOOKID = (string)row["BOOKID"]; if (db.RescueRoomImageRecords.Any(c => c.BOOKID == newRescueRoomImageRecord.BOOKID) || (target.OutDepartmentTime.HasValue && target.OutDepartmentTime.Value <= (DateTime?)row["CHKTIME"])) { continue; } newRescueRoomImageRecord.RescueRoomImageRecordId = Guid.NewGuid(); newRescueRoomImageRecord.RescueRoomInfoId = target.RescueRoomInfoId; newRescueRoomImageRecord.BookTime = (DateTime?)row["BOOKDATE"]; newRescueRoomImageRecord.CheckTime = (DateTime?)row["CHKTIME"]; newRescueRoomImageRecord.ReportTime = (DateTime?)row["REPTIME"]; newRescueRoomImageRecord.Part = (string)row["CHKPARTS"]; newRescueRoomImageRecord.Category = (string)row["CHKTYPENAME"]; var originCode = row["IMGTYPE"].ToString(); var imageCategory = db.ImageCategories.FirstOrDefault(c => c.OriginCode == originCode); newRescueRoomImageRecord.ImageCategoryId = imageCategory.ImageCategoryId; newRescueRoomImageRecord.UpdateTime = DateTime.Now; db.RescueRoomImageRecords.Add(newRescueRoomImageRecord); db.SaveChanges(); } //删除检查时间早于入室时间的影像项 if (false) { var listRescueRoomImageRecord = db.RescueRoomImageRecords.Where(c => c.RescueRoomInfoId == target.RescueRoomInfoId && c.CheckTime < target.InDepartmentTime).ToList(); db.RescueRoomImageRecords.RemoveRange(listRescueRoomImageRecord); db.SaveChanges(); } //删除检查时间超过离室时间的影像项 if (target.OutDepartmentTime.HasValue) { var listRescueRoomImageRecord = db.RescueRoomImageRecords.Where(c => c.RescueRoomInfoId == target.RescueRoomInfoId && target.OutDepartmentTime <= c.CheckTime).ToList(); db.RescueRoomImageRecords.RemoveRange(listRescueRoomImageRecord); db.SaveChanges(); } return(RedirectToAction("IndexPartial", new { rescueRoomInfoId = rescueRoomInfoId })); }
/// <summary> /// 刷新。 /// </summary> /// <param name="rescueRoomInfoId">归属的抢救室病例ID。</param> public ActionResult Refresh(Guid rescueRoomInfoId) { var db = new EiSDbContext(); var dbTrasen = new TrasenDbContext("TrasenConnection"); var target = db.RescueRoomInfos.Find(rescueRoomInfoId); if (target == null) { return(HttpNotFound()); } //设置时段起点、结点 DateTime?timeUpperBound; DateTime?timeLowerBound; { timeUpperBound = target.ReceiveTime; var itemJZJL = dbTrasen.MZYS_JZJL.Where(c => c.JZID == target.JZID).FirstOrDefault(); timeLowerBound = itemJZJL.WCSJ; } //==获取指定GHXXID的“处方表”记录。== var queryCFB = dbTrasen.VI_MZ_CFB.Where(c => c.GHXXID == target.GHXXID); //设置时段起点 queryCFB = queryCFB.Where(c => timeUpperBound <= c.SFRQ); //设置时段结点 if (timeLowerBound.HasValue) { queryCFB = queryCFB.Where(c => c.SFRQ <= timeLowerBound.Value);//该结点边界特殊,使用闭区间——结束的瞬间可能同时有医嘱。 } var listCFB = queryCFB.ToList(); foreach (var itemCFB in listCFB) { //获取指定CFID的“处方表明细”记录。 var queryCFBMX = dbTrasen.VI_MZ_CFB_MX.Where(c => c.CFID == itemCFB.CFID); var listCFBMX = queryCFBMX.ToList(); foreach (var itemCFBMX in listCFBMX) { if (db.RescueRoomDrugRecordDefinitions.Any(c => c.DrugCode == itemCFBMX.BM)) { //判断是新增的药品还是退费的药品 if (!itemCFBMX.TYID.HasValue) { var rescueRoomDrugRecord = db.RescueRoomDrugRecords.Where(c => c.CFMXID == itemCFBMX.CFMXID).FirstOrDefault(); if (rescueRoomDrugRecord == null) { rescueRoomDrugRecord = new RescueRoomDrugRecord(); rescueRoomDrugRecord.RescueRoomDrugRecordId = Guid.NewGuid(); rescueRoomDrugRecord.RescueRoomInfoId = target.RescueRoomInfoId; rescueRoomDrugRecord.ProductCode = itemCFBMX.BM; rescueRoomDrugRecord.ProductName = itemCFBMX.PM; rescueRoomDrugRecord.GoodsName = itemCFBMX.SPM; rescueRoomDrugRecord.DosageQuantity = itemCFBMX.YL; rescueRoomDrugRecord.DosageUnit = itemCFBMX.YLDW; rescueRoomDrugRecord.PrescriptionTime = itemCFB.SFRQ; rescueRoomDrugRecord.Usage = itemCFBMX.YFMC; rescueRoomDrugRecord.CFMXID = itemCFBMX.CFMXID; rescueRoomDrugRecord.CFID = itemCFBMX.CFID; rescueRoomDrugRecord.UpdateTime = DateTime.Now; db.RescueRoomDrugRecords.Add(rescueRoomDrugRecord); db.SaveChanges(); } else { rescueRoomDrugRecord.RescueRoomInfoId = target.RescueRoomInfoId; rescueRoomDrugRecord.ProductCode = itemCFBMX.BM; rescueRoomDrugRecord.ProductName = itemCFBMX.PM; rescueRoomDrugRecord.GoodsName = itemCFBMX.SPM; rescueRoomDrugRecord.DosageQuantity = itemCFBMX.YL; rescueRoomDrugRecord.DosageUnit = itemCFBMX.YLDW; rescueRoomDrugRecord.PrescriptionTime = itemCFB.SFRQ; rescueRoomDrugRecord.Usage = itemCFBMX.YFMC; rescueRoomDrugRecord.CFMXID = itemCFBMX.CFMXID; rescueRoomDrugRecord.CFID = itemCFBMX.CFID; db.SaveChanges(); } } else { var rescueRoomDrugRecord = db.RescueRoomDrugRecords.Where(c => c.CFMXID == itemCFBMX.TYID.Value).FirstOrDefault(); if (rescueRoomDrugRecord != null) { rescueRoomDrugRecord.DosageQuantity -= itemCFBMX.YL; if (rescueRoomDrugRecord.DosageQuantity == 0) { db.RescueRoomDrugRecords.Remove(rescueRoomDrugRecord); } db.SaveChanges(); } else { throw new Exception("无对应原始处方明细记录。"); } } } } } //删除处方时间早于时段起点的用药项 if (timeUpperBound.HasValue) { var listRescueRoomDrugRecord = db.RescueRoomDrugRecords.Where(c => c.RescueRoomInfoId == target.RescueRoomInfoId && c.PrescriptionTime < timeUpperBound).ToList(); db.RescueRoomDrugRecords.RemoveRange(listRescueRoomDrugRecord); db.SaveChanges(); } //删除处方时间超过时段结点的用药项 if (timeLowerBound.HasValue) { var listRescueRoomDrugRecord = db.RescueRoomDrugRecords.Where(c => c.RescueRoomInfoId == target.RescueRoomInfoId && timeLowerBound < c.PrescriptionTime).ToList(); db.RescueRoomDrugRecords.RemoveRange(listRescueRoomDrugRecord); db.SaveChanges(); } //删除编码在定义外的用药项 if (true) { var listRescueRoomDrugRecord = db.RescueRoomDrugRecords.ToList(); var listRescueRoomDrugRecordDefinition = db.RescueRoomDrugRecordDefinitions.Where(c => c.GreenPathCode == "Ami").ToList(); foreach (var itemRescueRoomDrugRecord in listRescueRoomDrugRecord) { if (!listRescueRoomDrugRecordDefinition.Any(c => c.DrugCode == itemRescueRoomDrugRecord.ProductCode)) { db.RescueRoomDrugRecords.Remove(itemRescueRoomDrugRecord); } } db.SaveChanges(); } return(RedirectToAction("IndexPartial", new { rescueRoomInfoId })); }