/// <summary> /// Controller 调用此方法 /// </summary> /// <param name="taskCode"></param> /// <param name="PatientOrder"></param> /// <returns></returns> public void getPatientCharge(string taskCode, string PatientOrder, out List <PatientChargeInfo> listYP, out List <PatientChargeInfo> listCL, out List <PatientChargeInfo> listJC, out List <PatientChargeInfo> listZL, out dynamic pinfo, out dynamic editinfo) { int pOrder = Convert.ToInt32(PatientOrder); //当状态为未收,PatientRecord取内容,只取PatientRecord中的Name,SendAddress,LocalAddress pinfo = new M_PatientRecordBLL().DALContext.IM_PatientRecordDAL.GetDynamicListWithOrderBy(p => p.TaskCode == taskCode && p.PatientOrder == pOrder, p => new { CallOrder = p.CallOrder, Name = p.Name, SendAddress = p.SendAddress, LocalAddress = p.LocalAddress }, p => p.TaskCode).FirstOrDefault(); //当状态为已收,PatientCharge取内容供编辑 editinfo = new M_PatientChargeBLL().DALContext.IM_PatientChargeDAL.GetDynamicListWithOrderBy(p => p.TaskCode == taskCode && p.PatientOrder == pOrder, p => new { PatientName = p.PatientName, AddressStart = p.AddressStart, AddressEnd = p.AddressEnd, InvoiceNumber = p.InvoiceNumber, OutStationRoadCode = p.OutStationRoadCode, PointRoadCode = p.PointRoadCode, ArriveHospitalRoadCode = p.ArriveHospitalRoadCode, ReturnStationRoadCode = p.ReturnStationRoadCode, OneWayKM = p.OneWayKM, ChargeKM = p.ChargeKM, CarFee = p.CarFee, WaitingFee = p.WaitingFee, EmergencyFee = p.EmergencyFee, DrugFeeTotal = p.DrugFeeTotal, ExamineFeeTotal = p.ExamineFeeTotal, ConsumableFeeTotal = p.ConsumableFeeTotal, MeasureFeeTotal = p.MeasureFeeTotal, PaidMoney = p.PaidMoney, ReceivableTotal = p.ReceivableTotal }, p => p.TaskCode).FirstOrDefault(); List <PatientChargeInfo> listALL = new M_PatientChargeBLL().DALContext.IM_PatientChargeDAL.getPatientCharge(taskCode, PatientOrder).ToList(); listYP = listALL.Where(p => p.ChargeType.Equals("药费")).ToList(); //药品 PatientChargeInfo infoYP = new PatientChargeInfo(); infoYP.Name = "合计"; if (listYP.Count() > 0) { infoYP.TotalPrice = listYP.Sum(p => p.TotalPrice); } else { infoYP.TotalPrice = 0; } listYP.Add(infoYP); listCL = listALL.Where(p => p.ChargeType.Equals("材料费")).ToList(); //材料 PatientChargeInfo infoCL = new PatientChargeInfo(); infoCL.Name = "合计"; if (listCL.Count() > 0) { infoCL.TotalPrice = listCL.Sum(p => p.TotalPrice); } else { infoCL.TotalPrice = 0; } listCL.Add(infoCL); listJC = listALL.Where(p => p.ChargeType.Equals("检查费")).ToList(); //检查 PatientChargeInfo infoJC = new PatientChargeInfo(); infoJC.Name = "合计"; if (listJC.Count() > 0) { infoJC.TotalPrice = listJC.Sum(p => p.TotalPrice); } else { infoJC.TotalPrice = 0; } listJC.Add(infoJC); listZL = listALL.Where(p => p.ChargeType.Equals("治疗费")).ToList(); //治疗 PatientChargeInfo infoZL = new PatientChargeInfo(); infoZL.Name = "合计"; if (listZL.Count() > 0) { infoZL.TotalPrice = listZL.Sum(p => p.TotalPrice); } else { infoZL.TotalPrice = 0; } listZL.Add(infoZL); }
/// <summary> /// 获取病历收费相关 /// </summary> /// <param name="taskCode"></param> /// <param name="PatientOrder"></param> public IEnumerable <PatientChargeInfo> getPatientCharge(string taskCode, string PatientOrder) { string sqlStr = @" select Name=prd.DrugName ,Price= prd.Price ,Counts= sum(prd.Dosage) ,ChargeCounts =case when sum(prd.Dosage)%isnull(prd.FeeScale,1)>0 then round((sum(prd.Dosage)/isnull(prd.FeeScale,1)),0)+1 else round((sum(prd.Dosage)/isnull(prd.FeeScale,1)),0) end ,ChargeWay =prd.ChargeWay ,FeeScale = prd.FeeScale ,TotalPrice =case when (im.LimitMaxPrice is not null ) then (case when (prd.Price * (case when sum(prd.Dosage)%isnull(prd.FeeScale,1)>0 then round((sum(prd.Dosage)/isnull(prd.FeeScale,1)),0)+1 else round((sum(prd.Dosage)/isnull(prd.FeeScale,1)),0) end) > im.LimitMaxPrice) then im.LimitMaxPrice else prd.Price * (case when sum(prd.Dosage)%isnull(prd.FeeScale,1)>0 then round((sum(prd.Dosage)/isnull(prd.FeeScale,1)),0)+1 else round((sum(prd.Dosage)/isnull(prd.FeeScale,1)),0) end) end) else prd.Price * (case when sum(prd.Dosage)%isnull(prd.FeeScale,1)>0 then round((sum(prd.Dosage)/isnull(prd.FeeScale,1)),0)+1 else round((sum(prd.Dosage)/isnull(prd.FeeScale,1)),0) end) end ,ChargeType = '药费' from M_PatientRecordDrug prd left join I_Material im on prd.DrugCode=im.ID where TaskCode=@TaskCode and PatientOrder =@PatientOrder and im.IsActive = 1 group by prd.DrugName,prd.Price,prd.ChargeWay,prd.FeeScale,im.LimitMaxPrice union all select Name=prs.SanitationName ,Price= isnull(prs.Price,0) ,Counts= sum(isnull(prs.NumberOfTimes,0)) ,ChargeCounts = sum(isnull(prs.NumberOfTimes,0)) ,ChargeWay =prs.ChargeWay ,FeeScale = 1 ,TotalPrice = case when im.LimitMaxPrice is not null then (case when ( isnull(prs.Price,0) * sum(isnull(prs.NumberOfTimes,0))> im.LimitMaxPrice) then im.LimitMaxPrice else isnull(prs.Price,0) * sum(isnull(prs.NumberOfTimes,0)) end ) else isnull(prs.Price,0) * sum(isnull(prs.NumberOfTimes,0)) end ,ChargeType = '材料费' from M_PatientRecordSanitation prs left join I_Material im on prs.SanitationCode = im.ID where TaskCode=@TaskCode and PatientOrder =@PatientOrder and im.IsActive=1 group by prs.SanitationName,prs.Price,prs.ChargeWay,im.LimitMaxPrice union all select Name=prm.RescueMeasureName ,Price= isnull(prm.Price,0) ,Counts= sum(isnull(prm.NumberOfTimes,0)) ,ChargeCounts = sum(isnull(prm.NumberOfTimes,0)) ,ChargeWay =prm.ChargeWay ,FeeScale = 1 ,TotalPrice = case when im.LimitMaxPrice is not null then (case when ( isnull(prm.Price,0) * sum(isnull(prm.NumberOfTimes,0))> im.LimitMaxPrice) then im.LimitMaxPrice else isnull(prm.Price,0) * sum(isnull(prm.NumberOfTimes,0)) end ) else isnull(prm.Price,0) * sum(isnull(prm.NumberOfTimes,0)) end ,ChargeType = '检查费' from M_PatientRecordMeasure prm left join I_Material im on prm.RescueMeasureCode = im.ID where TaskCode=@TaskCode and PatientOrder =@PatientOrder and prm.OtherTypeID = 'PRMeasureType-99' and im.IsActive=1 group by prm.RescueMeasureName,prm.Price,prm.ChargeWay,im.LimitMaxPrice union all select Name=prm.RescueMeasureName ,Price= isnull(prm.Price,0) ,Counts= sum(isnull(prm.NumberOfTimes,0)) ,ChargeCounts = sum(isnull(prm.NumberOfTimes,0)) ,ChargeWay =prm.ChargeWay ,FeeScale = 1 ,TotalPrice = case when im.LimitMaxPrice is not null then (case when ( isnull(prm.Price,0) * sum(isnull(prm.NumberOfTimes,0))> im.LimitMaxPrice) then im.LimitMaxPrice else isnull(prm.Price,0) * sum(isnull(prm.NumberOfTimes,0)) end ) else isnull(prm.Price,0) * sum(isnull(prm.NumberOfTimes,0)) end ,ChargeType = '治疗费' from M_PatientRecordMeasure prm left join I_Material im on prm.RescueMeasureCode = im.ID where TaskCode=@TaskCode and PatientOrder =@PatientOrder and prm.OtherTypeID <> 'PRMeasureType-99' and im.IsActive=1 group by prm.RescueMeasureName,prm.Price,prm.ChargeWay,im.LimitMaxPrice union all select Name=pr.RescueType ,Price= case when RescueType='小抢救' then 30 else 40 end ,Counts=1 ,ChargeCounts = 1 ,ChargeWay = case when RescueType='小抢救' then '30.00元/次' else '40.00元/次' end ,FeeScale = 1 ,TotalPrice =case when RescueType='小抢救' then 30 else 40 end ,ChargeType = '治疗费' from M_PatientRecord pr where TaskCode=@TaskCode and PatientOrder =@PatientOrder and pr.RescueType in ('中抢救','小抢救') "; //List<SqlParameter> listPara = new List<SqlParameter>(); //listPara.Add(new SqlParameter("@TaskCode", taskCode)); //listPara.Add(new SqlParameter("@PatientOrder", PatientOrder)); //listPara.ToArray() SqlParameter[] prams = new SqlParameter[] { new SqlParameter("@TaskCode", SqlDbType.NVarChar, 100), new SqlParameter("@PatientOrder", SqlDbType.Int) }; prams[0].Value = taskCode; prams[1].Value = PatientOrder; DataSet ds = SqlHelper.ExecuteDataSet(SqlHelper.MainConnectionString, CommandType.Text, sqlStr, prams); List <PatientChargeInfo> list = new List <PatientChargeInfo>(); if (ds.Tables[0].Rows.Count > 0) { PatientChargeInfo info = new PatientChargeInfo(); foreach (DataRow dr in ds.Tables[0].Rows) { info = new PatientChargeInfo(); info.Name = dr["Name"].ToString(); info.Price = DBConvert.ConvertDBTypeToNullableDecimal(dr["Price"]); info.Counts = DBConvert.ConvertDBTypeToNullableInt(dr["Counts"]); info.ChargeCounts = DBConvert.ConvertDBTypeToNullableInt(dr["ChargeCounts"]); info.ChargeWay = dr["ChargeWay"].ToString(); info.FeeScale = Convert.ToInt32(dr["FeeScale"]); info.TotalPrice = DBConvert.ConvertDBTypeToNullableDecimal(dr["TotalPrice"]); info.ChargeType = dr["ChargeType"].ToString(); list.Add(info); } } return(list); }