/// <summary> /// 处理诊疗类项目 /// </summary> private void DisposeTreatment(InterfaceFyqdDetail item, IList <MsSfmx> msSfmxSet) { //诊疗费用 var yj01 = Ctx.MsYj01Set.Where(p => p.Yjxh == item.itemNo).Include(p => p.MsYj02).FirstOrDefault(); if (yj01 == null) { throw new Exception("检查单信息不存在,请重试!"); } if (!string.IsNullOrEmpty(yj01.Fphm)) { throw new Exception($"检查单{item.itemNo}已经进行了结算,不能重复结算!"); } if (!yj01.MsYj02.Any()) { throw new Exception($"检查单{item.itemNo}没有检查项目,请医生检查开单内容!"); } //his单据金额 var hisItemCost = yj01.MsYj02.Sum(p => p.Hjje); if (Math.Abs(item.itemCost - hisItemCost) > (decimal)0.05) { throw new Exception("传入检查单金额与HIS不符,无法结算,请重试!"); } yj01.Fphm = InPara.OtherPara.Fphm; yj01.Mzxh = InPara.OtherPara.MsMzxx_Mzxh; yj01.Jzxh = InPara.OtherPara.YsMzJzls_Jzxh; //存在ms_ykkdyz则更新fphm字段,目前我院不存在医技开单 if (InPara.OtherPara.Ybpb == 1) { foreach (var detail in item.item) { var yj02 = yj01.MsYj02.FirstOrDefault(p => p.Sbxh == detail.itemNumber); if (yj02 != null) { yj02.Tsxx = detail.BZXX; yj02.Zfbl = detail.SelfPayRate; } } } //修改或插入MS_SFMX foreach (var yj in yj01.MsYj02) { var temp = msSfmxSet.FirstOrDefault(p => p.Sfxm == yj.Fygb); if (temp == null) { temp = new MsSfmx { Mzxh = InPara.OtherPara.MsMzxx_Mzxh, Sfxm = yj.Fygb, Zjje = hisItemCost, Zfje = yj.Hjje * yj.Zfbl, Fphm = InPara.OtherPara.Fphm, Jgid = 1 }; Ctx.MsSfmxSet.Add(temp); } else { temp.Zjje += hisItemCost; temp.Zfje += yj.Hjje * yj.Zfbl; } } Ctx.SaveChanges(); }
private void DisposeRecipe(InterfaceFyqdDetail item, IList <MsSfmx> msSfmxSet, IList <GyXtcs> gyXtcsSet) { var cf01 = Ctx.MsCf01Set.Where(p => p.Cfsb == item.itemNo).Include(p => p.MsCf02).FirstOrDefault(); if (cf01 == null) { throw new Exception("处方信息不存在,请重试!"); } if (!string.IsNullOrEmpty(cf01.Fphm)) { throw new Exception($"处方{item.itemNo}已经进行了结算,不能重复结算!"); } if (!cf01.MsCf02.Any()) { throw new Exception($"处方{item.itemNo}没有药品信息,请医生检查开方内容!"); } //单据金额 var hisItemCost = cf01.MsCf02.Sum(p => p.Hjje); if (Math.Abs(item.itemCost - hisItemCost) > (decimal)0.05) { throw new Exception("传入处方金额与HIS不符,无法结算,请重试!"); } cf01.Fphm = InPara.OtherPara.Fphm; cf01.Mzxh = InPara.OtherPara.MsMzxx_Mzxh; cf01.Jzxh = InPara.OtherPara.YsMzJzls_Jzxh; if (InPara.OtherPara.Ybpb == 1) { foreach (var detail in item.item) { var cf02 = cf01.MsCf02.FirstOrDefault(p => p.Sbxh == detail.itemNumber); if (cf02 != null) { cf02.Tsxx = detail.BZXX; cf02.Zfbl = detail.SelfPayRate; } } } //产生单据明细计算信息及医保分类明细临时表数据MS_SFMX,WXYB_FLMX,WXYB_JSMX var sfxm = GetChargeType(gyXtcsSet, cf01.Cflx); var temp = msSfmxSet.FirstOrDefault(p => p.Sfxm == sfxm); if (temp == null) { temp = new MsSfmx { Mzxh = InPara.OtherPara.MsMzxx_Mzxh, Sfxm = sfxm, Zjje = hisItemCost, Zfje = item.item.Sum(p => p.SelfPay), Fphm = InPara.OtherPara.Fphm, Jgid = 1 }; Ctx.MsSfmxSet.Add(temp); } else { temp.Zjje += hisItemCost; temp.Zfje += 0; } Ctx.SaveChanges(); }