diff --git a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/reportmanage/appservice/IReportDimensionAppService.java b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/reportmanage/appservice/IReportDimensionAppService.java new file mode 100644 index 000000000..3e1528813 --- /dev/null +++ b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/reportmanage/appservice/IReportDimensionAppService.java @@ -0,0 +1,9 @@ +package com.healthlink.his.web.reportmanage.appservice; + +import java.util.List; +import java.util.Map; + +public interface IReportDimensionAppService { + + Map getReportByDimension(String dimension, Map filters); +} diff --git a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/reportmanage/appservice/impl/ReportDimensionAppServiceImpl.java b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/reportmanage/appservice/impl/ReportDimensionAppServiceImpl.java new file mode 100644 index 000000000..bfc49d72e --- /dev/null +++ b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/reportmanage/appservice/impl/ReportDimensionAppServiceImpl.java @@ -0,0 +1,96 @@ +package com.healthlink.his.web.reportmanage.appservice.impl; + +import com.healthlink.his.mrhomepage.domain.MrHomepage; +import com.healthlink.his.mrhomepage.service.IMrHomepageService; +import com.healthlink.his.web.reportmanage.appservice.IReportDimensionAppService; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.*; +import java.util.stream.Collectors; + +@Service +@AllArgsConstructor +public class ReportDimensionAppServiceImpl implements IReportDimensionAppService { + + private final IMrHomepageService mrHomepageService; + + @Override + public Map getReportByDimension(String dimension, Map filters) { + List allData = mrHomepageService.list(); + + String startDate = filters != null ? filters.get("startDate") : null; + String endDate = filters != null ? filters.get("endDate") : null; + + if (StringUtils.hasText(startDate)) { + allData = allData.stream() + .filter(h -> h.getDischargeDate() != null && + h.getDischargeDate().toString().compareTo(startDate) >= 0) + .collect(Collectors.toList()); + } + if (StringUtils.hasText(endDate)) { + allData = allData.stream() + .filter(h -> h.getDischargeDate() != null && + h.getDischargeDate().toString().compareTo(endDate) <= 0) + .collect(Collectors.toList()); + } + + Map result = new HashMap<>(); + result.put("totalCount", allData.size()); + + BigDecimal totalCost = allData.stream() + .map(MrHomepage::getTotalCost) + .filter(Objects::nonNull) + .reduce(BigDecimal.ZERO, BigDecimal::add); + result.put("totalCost", totalCost); + result.put("avgCost", allData.isEmpty() ? BigDecimal.ZERO : + totalCost.divide(BigDecimal.valueOf(allData.size()), 2, RoundingMode.HALF_UP)); + + Map> grouped; + switch (dimension != null ? dimension : "status") { + case "drg": + grouped = allData.stream() + .filter(h -> h.getDrgGroup() != null) + .collect(Collectors.groupingBy(MrHomepage::getDrgGroup)); + break; + case "diagnosis": + grouped = allData.stream() + .filter(h -> h.getPrimaryDiagnosisName() != null) + .collect(Collectors.groupingBy(MrHomepage::getPrimaryDiagnosisName)); + break; + case "status": + default: + grouped = allData.stream() + .collect(Collectors.groupingBy( + h -> h.getQualityStatus() != null ? h.getQualityStatus() : "UNKNOWN")); + break; + } + + List> dimensionData = new ArrayList<>(); + grouped.forEach((key, items) -> { + Map entry = new HashMap<>(); + entry.put("dimension", key); + entry.put("count", items.size()); + BigDecimal cost = items.stream() + .map(MrHomepage::getTotalCost) + .filter(Objects::nonNull) + .reduce(BigDecimal.ZERO, BigDecimal::add); + entry.put("totalCost", cost); + entry.put("avgCost", items.isEmpty() ? BigDecimal.ZERO : + cost.divide(BigDecimal.valueOf(items.size()), 2, RoundingMode.HALF_UP)); + long totalLos = items.stream() + .mapToInt(h -> h.getLosDays() != null ? h.getLosDays() : 0) + .sum(); + entry.put("avgLosDays", items.isEmpty() ? 0 : + Math.round(totalLos * 10.0 / items.size()) / 10.0); + dimensionData.add(entry); + }); + + result.put("dimension", dimension); + result.put("data", dimensionData); + return result; + } +} diff --git a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/reportmanage/controller/ReportDimensionController.java b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/reportmanage/controller/ReportDimensionController.java new file mode 100644 index 000000000..87697adf5 --- /dev/null +++ b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/reportmanage/controller/ReportDimensionController.java @@ -0,0 +1,36 @@ +package com.healthlink.his.web.reportmanage.controller; + +import com.core.common.core.domain.R; +import com.healthlink.his.web.reportmanage.appservice.IReportDimensionAppService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.HashMap; +import java.util.Map; + +@Tag(name = "多维度报表") +@RestController +@RequestMapping("/report-manage/report-dimension") +@Slf4j +@AllArgsConstructor +public class ReportDimensionController { + + private final IReportDimensionAppService reportDimensionAppService; + + @Operation(summary = "多维度报表查询") + @PreAuthorize("@ss.hasPermi('reportmanage:report:list')") + @GetMapping("/query") + public R> getReportByDimension( + @RequestParam(value = "dimension", defaultValue = "status") String dimension, + @RequestParam(value = "startDate", required = false) String startDate, + @RequestParam(value = "endDate", required = false) String endDate) { + Map filters = new HashMap<>(); + if (startDate != null) filters.put("startDate", startDate); + if (endDate != null) filters.put("endDate", endDate); + return R.ok(reportDimensionAppService.getReportByDimension(dimension, filters)); + } +} diff --git a/healthlink-his-ui/src/api/reportmanage/dimension.js b/healthlink-his-ui/src/api/reportmanage/dimension.js new file mode 100644 index 000000000..b6a86ec94 --- /dev/null +++ b/healthlink-his-ui/src/api/reportmanage/dimension.js @@ -0,0 +1,5 @@ +import request from '@/utils/request' + +export function getReportByDimension(params) { + return request({ url: '/report-manage/report-dimension/query', method: 'get', params }) +} diff --git a/healthlink-his-ui/src/views/reportmanage/ReportDimension.vue b/healthlink-his-ui/src/views/reportmanage/ReportDimension.vue new file mode 100644 index 000000000..50d3c7168 --- /dev/null +++ b/healthlink-his-ui/src/views/reportmanage/ReportDimension.vue @@ -0,0 +1,125 @@ + + + + +