|
|
@@ -908,25 +908,25 @@ public class StandardReportServiceImpl implements StandardReportService {
|
|
|
* @return 病种成本明细列表
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<HospitalServiceProjectCostVO> getDiseaseCostDetail(String computeDate) {
|
|
|
- List<HospitalServiceProjectCostVO> projectCostAccountList = computePatientCostAccountRepository.getDiseaseCostDetailList(computeDate);
|
|
|
+ public List<DiseaseCostDetailVO> getDiseaseCostDetail(String computeDate) {
|
|
|
+ List<DiseaseCostDetailVO> projectCostAccountList = computePatientCostAccountRepository.getDiseaseCostDetailList(computeDate);
|
|
|
if(CollectionUtils.isEmpty(projectCostAccountList)){
|
|
|
throw new CostException("请先计算患者成本");
|
|
|
}
|
|
|
// 获取所有的标准字典数据
|
|
|
StandCostDictMapVO standCostDictMaps = getStandCostDictMaps();
|
|
|
// 记录项目类别对象
|
|
|
- Map<String, HospitalServiceProjectCostVO> projectCostMap = new HashMap<>();
|
|
|
- for (HospitalServiceProjectCostVO projectCostAccount : projectCostAccountList) {
|
|
|
+ Map<String, DiseaseCostDetailVO> diseaseCostMap = new HashMap<>();
|
|
|
+ for (DiseaseCostDetailVO projectCostAccount : projectCostAccountList) {
|
|
|
//按项目类型累加数据
|
|
|
DictDataVo costType = standCostDictMaps.getCostTypeMap().get(projectCostAccount.getCostTypeCode());
|
|
|
- HospitalServiceProjectCostVO vo = new HospitalServiceProjectCostVO();
|
|
|
+ DiseaseCostDetailVO vo = new DiseaseCostDetailVO();
|
|
|
//已有的项目类别
|
|
|
- if (projectCostMap.containsKey(projectCostAccount.getItemCode())) {
|
|
|
- vo = projectCostMap.get(projectCostAccount.getItemCode());
|
|
|
+ if (diseaseCostMap.containsKey(projectCostAccount.getDiseaseCode())) {
|
|
|
+ vo = diseaseCostMap.get(projectCostAccount.getDiseaseCode());
|
|
|
} else {
|
|
|
//新建一个项目类别对象
|
|
|
- projectCostMap.put(projectCostAccount.getItemCode(), projectCostAccount);
|
|
|
+ diseaseCostMap.put(projectCostAccount.getDiseaseCode(), projectCostAccount);
|
|
|
}
|
|
|
// 医疗成本
|
|
|
if ("1".equals(costType.getExpandOne())) {
|
|
|
@@ -938,11 +938,182 @@ public class StandardReportServiceImpl implements StandardReportService {
|
|
|
}
|
|
|
// 医院全成本
|
|
|
vo.setHospitalFullCost(vo.getHospitalFullCost().add(projectCostAccount.getHospitalFullCost()));
|
|
|
- }
|
|
|
- List<HospitalServiceProjectCostVO> medServiceCostDetailList =new ArrayList<>(projectCostMap.values());
|
|
|
+ // 服务量
|
|
|
+ vo.setServiceVolume(projectCostAccount.getServiceVolume());
|
|
|
+ }
|
|
|
+ List<DiseaseCostDetailVO> medServiceCostDetailList =new ArrayList<>(diseaseCostMap.values());
|
|
|
+ //计算单个病种的成本
|
|
|
+ medServiceCostDetailList.forEach(vo -> {
|
|
|
+ vo.setMedicalCost(getPercent(vo.getServiceVolume(),vo.getMedicalCost()));
|
|
|
+ vo.setMedicalFullCost(getPercent(vo.getServiceVolume(),vo.getMedicalFullCost()));
|
|
|
+ vo.setHospitalFullCost(getPercent(vo.getServiceVolume(),vo.getHospitalFullCost()));
|
|
|
+ });
|
|
|
return medServiceCostDetailList;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取病种成本构成明细表数据
|
|
|
+ *
|
|
|
+ * @return 病种成本明细列表,包含各病种的成本明细及总计行
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<DiseaseCostDetailVO> getDiseaseCostCompositionDetail(String computeDate) {
|
|
|
+
|
|
|
+ List<DiseaseCostDetailVO> projectCostAccountList = computePatientCostAccountRepository.getDiseaseCostCompositionDetail(computeDate);
|
|
|
+ if(CollectionUtils.isEmpty(projectCostAccountList)){
|
|
|
+ throw new CostException("请先计算患者成本");
|
|
|
+ }
|
|
|
+ // 获取所有的标准字典数据
|
|
|
+ StandCostDictMapVO standCostDictMaps = getStandCostDictMaps();
|
|
|
+ // 记录项目类别对象
|
|
|
+ Map<String, DiseaseCostDetailVO> diseaseCostMap = new HashMap<>();
|
|
|
+ for (DiseaseCostDetailVO projectCostAccount : projectCostAccountList) {
|
|
|
+ //按项目类型累加数据
|
|
|
+ DictDataVo accountType = standCostDictMaps.getAccountingTypeMap().get(projectCostAccount.getCostTypeCode());
|
|
|
+ DiseaseCostDetailVO vo = new DiseaseCostDetailVO();
|
|
|
+ //已有的项目类别
|
|
|
+ if (diseaseCostMap.containsKey(projectCostAccount.getDiseaseCode())) {
|
|
|
+ vo = diseaseCostMap.get(projectCostAccount.getDiseaseCode());
|
|
|
+ } else {
|
|
|
+ vo.setDiseaseCode(projectCostAccount.getDiseaseCode());
|
|
|
+ vo.setDiseaseName(projectCostAccount.getDiseaseName());
|
|
|
+ //新建一个项目类别对象
|
|
|
+ diseaseCostMap.put(projectCostAccount.getDiseaseCode(), vo);
|
|
|
+ }
|
|
|
+ //按会计科目类型累加费用
|
|
|
+ addAccountTypeExpense(accountType.getExpandOne(), projectCostAccount.getHospitalFullCost(), vo);
|
|
|
+ //累加数量
|
|
|
+ vo.setServiceVolume(vo.getServiceVolume().add(projectCostAccount.getServiceVolume()));
|
|
|
+ }
|
|
|
+ List<DiseaseCostDetailVO> diseaseCostDetailList =new ArrayList<>(diseaseCostMap.values());
|
|
|
+ //按会计科目类型计算占比
|
|
|
+ diseaseCostDetailList.forEach(vo -> setAccountTypeExpenseRatio(vo));
|
|
|
+ return diseaseCostDetailList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取服务单元病种成本构成明细表数据
|
|
|
+ * @param computeDate
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ComputeProfitCollectResponse getDeptDiseaseCostCompositionDetail(String computeDate) {
|
|
|
+ List<DiseaseCostDetailVO> projectCostAccountList = computePatientCostAccountRepository.getDeptDiseaseCostCompositionDetail(computeDate);
|
|
|
+ if(CollectionUtils.isEmpty(projectCostAccountList)){
|
|
|
+ throw new CostException("请先计算患者成本");
|
|
|
+ }
|
|
|
+ // 获取所有的标准字典数据
|
|
|
+ StandCostDictMapVO standCostDictMaps = getStandCostDictMaps();
|
|
|
+ List<CommonResponsibilityReportVo> titleList = new ArrayList<>();
|
|
|
+ // 提取科室名称作为列标题
|
|
|
+ for (Responsibility dept : standCostDictMaps.getResponsibilityDict()) {
|
|
|
+ CommonResponsibilityReportVo title = new CommonResponsibilityReportVo();
|
|
|
+ title.setResponsibilityName(dept.getResponsibilityName());
|
|
|
+ title.setResponsibilityCode(dept.getResponsibilityCode());
|
|
|
+ title.setSort(dept.getSort());
|
|
|
+ //添加子级标题
|
|
|
+ addCommonResponsibilityChild(title);
|
|
|
+ titleList.add(title);
|
|
|
+ }
|
|
|
+ // 记录项目类别对象
|
|
|
+ Map<String, ReportFormCustomVo> diseaseCostMap = new HashMap<>();
|
|
|
+ // 遍历每个项目生成科室金额
|
|
|
+ for (DiseaseCostDetailVO costItem : projectCostAccountList) {
|
|
|
+ ReportFormCustomVo itemVo = new ReportFormCustomVo();
|
|
|
+ if(diseaseCostMap.containsKey(costItem.getDiseaseCode())){
|
|
|
+ itemVo=diseaseCostMap.get(costItem.getDiseaseCode());
|
|
|
+ }else{
|
|
|
+ itemVo.setReportName(costItem.getDiseaseName());
|
|
|
+ itemVo.setData(new ArrayList<>());
|
|
|
+ itemVo.setTotalValue(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ //金额对象
|
|
|
+ ReportVo amountReportVo = new ReportVo();
|
|
|
+ amountReportVo.setCode(getResponsibilityAmountCode(costItem.getDepartmentCode()));
|
|
|
+ // 设置金额
|
|
|
+ amountReportVo.setValue(costItem.getHospitalFullCost());
|
|
|
+ // 添加金额
|
|
|
+ itemVo.getData().add(amountReportVo);
|
|
|
+ //计算总额
|
|
|
+ itemVo.setTotalValue(itemVo.getTotalValue().add(costItem.getHospitalFullCost()));
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ReportFormCustomVo> diseaseCostDetailList =new ArrayList<>(diseaseCostMap.values());
|
|
|
+
|
|
|
+ // 遍历每个成本项目(列转行)
|
|
|
+ for (ReportFormCustomVo costItem : diseaseCostDetailList) {
|
|
|
+ if(CollectionUtils.isEmpty(costItem.getData())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ for (ReportVo amountReportVo : costItem.getData()) {
|
|
|
+ //占比对象
|
|
|
+ ReportVo percentReportVo = new ReportVo();
|
|
|
+ percentReportVo.setCode(amountReportVo.getCode());
|
|
|
+ //计算百分比
|
|
|
+ BigDecimal percent = getPercent((BigDecimal)amountReportVo.getValue() , costItem.getTotalValue());
|
|
|
+ percentReportVo.setValue(percent);
|
|
|
+ // 添加百分比
|
|
|
+ costItem.getData().add(percentReportVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ComputeProfitCollectResponse response = new ComputeProfitCollectResponse();
|
|
|
+ response.setTitle(titleList);
|
|
|
+ response.setData(diseaseCostDetailList);
|
|
|
+
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 按会计科目类型计算占比
|
|
|
+ * @param vo
|
|
|
+ */
|
|
|
+ public void setAccountTypeExpenseRatio(DiseaseCostDetailVO vo){
|
|
|
+ vo.setPersonnelExpenseRatio(getPercent(vo.getPersonnelExpense(),vo.getTotalCost()));
|
|
|
+ vo.setDrugExpenseRatio(getPercent(vo.getDrugExpense(),vo.getTotalCost()));
|
|
|
+ vo.setMedicalMaterialExpenseRatio(getPercent(vo.getMedicalMaterialExpense(),vo.getTotalCost()));
|
|
|
+ vo.setFixedAssetDepreciationRatio(getPercent(vo.getFixedAssetDepreciation(),vo.getTotalCost()));
|
|
|
+ vo.setIntangibleAssetAmortizationRatio(getPercent(vo.getIntangibleAssetAmortization(),vo.getTotalCost()));
|
|
|
+ vo.setMedicalRiskFundRatio(getPercent(vo.getMedicalRiskFund(),vo.getTotalCost()));
|
|
|
+ vo.setOtherMedicalExpensesRatio(getPercent(vo.getOtherMedicalExpenses(),vo.getTotalCost()));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 按会计科目类型累加费用
|
|
|
+ * @param accountType
|
|
|
+ * @param expense
|
|
|
+ * @param vo
|
|
|
+ */
|
|
|
+ public void addAccountTypeExpense(String accountType, BigDecimal expense,DiseaseCostDetailVO vo) {
|
|
|
+ // 根据费用类型累加到对应字段
|
|
|
+ switch (accountType) {
|
|
|
+ case "1":
|
|
|
+ vo.setPersonnelExpense(vo.getPersonnelExpense().add(expense));
|
|
|
+ break;
|
|
|
+ case "2":
|
|
|
+ vo.setMedicalMaterialExpense(vo.getMedicalMaterialExpense().add(expense));
|
|
|
+ break;
|
|
|
+ case "3":
|
|
|
+ vo.setDrugExpense(vo.getDrugExpense().add(expense));
|
|
|
+ break;
|
|
|
+ case "4":
|
|
|
+ vo.setFixedAssetDepreciation(vo.getFixedAssetDepreciation().add(expense));
|
|
|
+ break;
|
|
|
+ case "5":
|
|
|
+ vo.setIntangibleAssetAmortization(vo.getIntangibleAssetAmortization().add(expense));
|
|
|
+ break;
|
|
|
+ case "6":
|
|
|
+ vo.setMedicalRiskFund(vo.getMedicalRiskFund().add(expense));
|
|
|
+ break;
|
|
|
+ case "7":
|
|
|
+ vo.setOtherMedicalExpenses(vo.getOtherMedicalExpenses().add(expense));
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ vo.setTotalCost(vo.getTotalCost().add(expense));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取项目归属的项目类型
|
|
|
* @param standItemCode
|