|
|
@@ -459,27 +459,21 @@ public class StandardReportServiceImpl implements StandardReportService {
|
|
|
//计算科室的床日成本及诊次成本
|
|
|
if(responsibilityParamValueMap.containsKey(item.getResponsibilityCode())){
|
|
|
List<ShareParamValue> shareParamValues = responsibilityParamValueMap.get(item.getResponsibilityCode());
|
|
|
- //获取诊次参数
|
|
|
- Optional<ShareParamValue> firstVisitParam = shareParamValues.stream().filter(shareParamValue -> shareParamValue.getShareParamCode().equals(visitsBedDaysParamCode[0])).findFirst();
|
|
|
- if(firstVisitParam.isPresent()){
|
|
|
- // 计算诊次成本=总成本/诊次数
|
|
|
- item.setVisitsCost(getPercent(item.getTotal(),firstVisitParam.get().getValueNum()));
|
|
|
- }else{
|
|
|
- item.setVisitsCost(BigDecimal.ZERO);
|
|
|
- }
|
|
|
- Optional<ShareParamValue> firstBedDayParam = shareParamValues.stream().filter(shareParamValue -> shareParamValue.getShareParamCode().equals(visitsBedDaysParamCode[1])).findFirst();
|
|
|
- if(firstBedDayParam.isPresent()){
|
|
|
- // 床日成本=总成本/床日数
|
|
|
- item.setBedDaysCost(getPercent(item.getTotal(),firstBedDayParam.get().getValueNum()));
|
|
|
- }else{
|
|
|
- item.setBedDaysCost(BigDecimal.ZERO);
|
|
|
- }
|
|
|
+
|
|
|
+ // 诊次分摊参数值
|
|
|
+ BigDecimal visitParamValue = getParamValue(shareParamValues, visitsBedDaysParamCode[NumberConstant.ZERO]);
|
|
|
+ // 床日分摊参数值
|
|
|
+ BigDecimal bedDaysParamValue = getParamValue(shareParamValues, visitsBedDaysParamCode[NumberConstant.ONE]);
|
|
|
+ // 计算诊次成本及床日成本
|
|
|
+ item.setVisitsCost(getPercent(item.getTotal(),visitParamValue));
|
|
|
+ item.setBedDaysCost(getPercent(item.getTotal(),bedDaysParamValue));
|
|
|
}else{
|
|
|
item.setBedDaysCost(BigDecimal.ZERO);
|
|
|
item.setVisitsCost(BigDecimal.ZERO);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 获取百分比
|
|
|
* @param amount
|
|
|
@@ -1118,6 +1112,89 @@ public class StandardReportServiceImpl implements StandardReportService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取医院诊次成本构成表数据
|
|
|
+ * @param computeDate 核算年月
|
|
|
+ * @return 报表数据
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<HospitalVisitCostCompositionVO> getHospitalVisitCostComposition(String computeDate) {
|
|
|
+ DateTime parse = DateUtil.parse(computeDate);
|
|
|
+ int year = DateUtil.year(parse);
|
|
|
+ int month = DateUtil.month(parse) + 1;
|
|
|
+
|
|
|
+ // 获取科室成本
|
|
|
+ List<AllocationQuery> allocationQueryList = allocationQueryService.getAcountAccounts(UserContext.getCurrentLoginHospId(), year, month);
|
|
|
+ if (CollectionUtils.isEmpty(allocationQueryList)) {
|
|
|
+ throw new CostException("医院未分摊本月数据");
|
|
|
+ }
|
|
|
+ //获取分摊参数
|
|
|
+ List<ShareParamValue> shareParamValueList = shareParamValueRepository.getList(computeDate);
|
|
|
+ if (CollectionUtils.isEmpty(shareParamValueList)) {
|
|
|
+ throw new CostException("未获取医院本月分摊参数数据");
|
|
|
+ }
|
|
|
+ // 获取所有的标准字典数据
|
|
|
+ StandCostDictMapVO standCostDictMaps = getStandCostDictMaps();
|
|
|
+ //获取成本会计科目字典
|
|
|
+ List<DictDataVo> accountingTypeDict = standCostDictMaps.getAccountingTypeDict();
|
|
|
+ List<DictDataVo> costAccountingTypeDict = accountingTypeDict.stream().filter(dictDataVo -> NumberConstant.TWO_S.equals(dictDataVo.getValue())).collect(Collectors.toList());
|
|
|
+ // 初始化成本项目映射
|
|
|
+ Map<String, HospitalVisitCostCompositionVO> costItemMap =createHospitalVisitCostCompositionVO(costAccountingTypeDict);
|
|
|
+ // 处理分配查询数据
|
|
|
+ for (AllocationQuery allocationQuery : allocationQueryList) {
|
|
|
+ String accountingCode = allocationQuery.getAccountingCode();
|
|
|
+ Accounting account = standCostDictMaps.getAccountingMap().get(accountingCode);
|
|
|
+ if (account == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ DictDataVo costType = standCostDictMaps.getCostTypeMap().get(account.getCostType());
|
|
|
+ HospitalVisitCostCompositionVO vo = costItemMap.get(account.getType());
|
|
|
+ // 医疗成本
|
|
|
+ if ("1".equals(costType.getExpandOne())) {
|
|
|
+ vo.setMedicalCost(vo.getMedicalCost().add(allocationQuery.getAmount()));
|
|
|
+ }
|
|
|
+ // 医疗全成本
|
|
|
+ if (!"3".equals(costType.getExpandOne())) {
|
|
|
+ vo.setMedicalFullCost(vo.getMedicalFullCost().add(allocationQuery.getAmount()));
|
|
|
+ }
|
|
|
+ // 医院全成本
|
|
|
+ vo.setHospitalFullCost(vo.getHospitalFullCost().add(allocationQuery.getAmount()));
|
|
|
+ }
|
|
|
+ //获取诊次床日分摊参数代码
|
|
|
+ String[] visitsBedDaysParamCode = getVisitsBedDaysParamCode();
|
|
|
+
|
|
|
+ // 诊次分摊参数值
|
|
|
+ BigDecimal visitParamValue = getParamValue(shareParamValueList, visitsBedDaysParamCode[NumberConstant.ZERO]);
|
|
|
+// // 床日分摊参数值
|
|
|
+// BigDecimal bedDaysParamValue = getParamValue(shareParamValueList, visitsBedDaysParamCode[NumberConstant.ONE]);
|
|
|
+
|
|
|
+ //处理总计和药品小计
|
|
|
+ HospitalVisitCostCompositionVO totalVo = new HospitalVisitCostCompositionVO();
|
|
|
+ totalVo.setCostItem("总计");
|
|
|
+ HospitalVisitCostCompositionVO drugTotalVo = new HospitalVisitCostCompositionVO();
|
|
|
+ totalVo.setCostItem("药品费");
|
|
|
+ // 转成List便于处理
|
|
|
+ List<HospitalVisitCostCompositionVO> reportList = costItemMap.values().stream().collect(Collectors.toList());
|
|
|
+ for (HospitalVisitCostCompositionVO item : reportList) {
|
|
|
+ //计算每诊次的医疗全成本
|
|
|
+ item.setHospitalFullCost(getPercent(visitParamValue,totalVo.getHospitalFullCost()));
|
|
|
+ //计算每诊次的医疗成本
|
|
|
+ item.setMedicalCost(getPercent(visitParamValue,totalVo.getMedicalCost()));
|
|
|
+ //计算每诊次的医院全成本
|
|
|
+ item.setHospitalFullCost(getPercent(visitParamValue,totalVo.getMedicalFullCost()));
|
|
|
+ // 将金额加到总计对象中
|
|
|
+ addBigDecimalFields(item, totalVo);
|
|
|
+ /// 将金额加到药品对象中
|
|
|
+ if(NumberConstant.THREE_S.equals(item.getCostType())){
|
|
|
+ addBigDecimalFields(item, drugTotalVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //添加到列表的指定位置
|
|
|
+ reportList.add(NumberConstant.TWO,drugTotalVo);
|
|
|
+ reportList.add(NumberConstant.ZERO,totalVo);
|
|
|
+ return reportList;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 添加医院科室成本分摊数据
|
|
|
* @param deptCostAllocationMap 科室成本分摊Map
|
|
|
@@ -1200,4 +1277,42 @@ public class StandardReportServiceImpl implements StandardReportService {
|
|
|
.add(allocationQuery.getAmount()));
|
|
|
deptCostAllocationMap.put(responsibilityCode, costAllocationVO);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取指定分摊参数的数值
|
|
|
+ * @param shareParamValues
|
|
|
+ * @param paramCode
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public BigDecimal getParamValue(List<ShareParamValue> shareParamValues, String paramCode){
|
|
|
+ BigDecimal sum = shareParamValues.stream()
|
|
|
+ .filter(shareParamValue -> shareParamValue.getShareParamCode().equals(paramCode))
|
|
|
+ .map(ShareParamValue::getValueNum)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ return sum;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建医院诊次成本构成表数据
|
|
|
+ * @param costAccountingTypeDict
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, HospitalVisitCostCompositionVO> createHospitalVisitCostCompositionVO(List<DictDataVo> costAccountingTypeDict) {
|
|
|
+ // 初始化成本项目映射
|
|
|
+ Map<String, HospitalVisitCostCompositionVO> costItemMap = new HashMap<>();
|
|
|
+ for (DictDataVo dictDataVo : costAccountingTypeDict) {
|
|
|
+ HospitalVisitCostCompositionVO vo = new HospitalVisitCostCompositionVO();
|
|
|
+ vo.setCostCode(dictDataVo.getCode());
|
|
|
+ vo.setCostItem(dictDataVo.getName());
|
|
|
+ vo.setCostType(dictDataVo.getExpandOne());
|
|
|
+ vo.setMedicalCost(BigDecimal.ZERO);
|
|
|
+ vo.setMedicalFullCost(BigDecimal.ZERO);
|
|
|
+ vo.setHospitalFullCost(BigDecimal.ZERO);
|
|
|
+ costItemMap.put(dictDataVo.getCode(), vo);
|
|
|
+ }
|
|
|
+ return costItemMap;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|