diff --git a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/infection/appservice/ICdssAppService.java b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/infection/appservice/ICdssAppService.java deleted file mode 100644 index 8502ed885..000000000 --- a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/infection/appservice/ICdssAppService.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.healthlink.his.web.infection.appservice; - -import com.healthlink.his.infection.domain.CdssAlert; -import com.healthlink.his.infection.domain.CdssRule; - -import java.util.List; -import java.util.Map; - -public interface ICdssAppService { - Map evaluateRules(Long encounterId); - List getAlerts(Long encounterId); - boolean acknowledgeAlert(Long alertId); - List getRules(Map params); -} diff --git a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/infection/appservice/impl/CdssAppServiceImpl.java b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/infection/appservice/impl/CdssAppServiceImpl.java deleted file mode 100644 index 85f2513ba..000000000 --- a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/infection/appservice/impl/CdssAppServiceImpl.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.healthlink.his.web.infection.appservice.impl; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.healthlink.his.infection.domain.CdssAlert; -import com.healthlink.his.infection.domain.CdssRule; -import com.healthlink.his.infection.service.ICdssAlertService; -import com.healthlink.his.infection.service.ICdssRuleService; -import com.healthlink.his.web.infection.appservice.ICdssAppService; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; -import java.util.stream.Collectors; - -@Service -@Slf4j -@AllArgsConstructor -public class CdssAppServiceImpl implements ICdssAppService { - - private final ICdssRuleService cdssRuleService; - private final ICdssAlertService cdssAlertService; - - @Override - @Transactional(rollbackFor = Exception.class) - public Map evaluateRules(Long encounterId) { - log.info("CDSS规则评估开始, encounterId={}", encounterId); - - List enabledRules = cdssRuleService.list( - new LambdaQueryWrapper() - .eq(CdssRule::getEnabled, true) - ); - - List newAlerts = new ArrayList<>(); - for (CdssRule rule : enabledRules) { - CdssAlert alert = new CdssAlert(); - alert.setEncounterId(encounterId); - alert.setPatientId(0L); - alert.setRuleId(rule.getId()); - alert.setAlertType(rule.getRuleType()); - alert.setAlertMessage("[" + rule.getRuleName() + "] " + rule.getSuggestion()); - alert.setSeverity(rule.getSeverity()); - alert.setAcknowledged(false); - cdssAlertService.save(alert); - newAlerts.add(alert); - } - - Map result = new HashMap<>(); - result.put("totalRules", enabledRules.size()); - result.put("newAlertCount", newAlerts.size()); - result.put("newAlerts", newAlerts); - result.put("evaluateTime", new Date()); - - log.info("CDSS规则评估完成: {}条规则, 生成{}条告警", enabledRules.size(), newAlerts.size()); - return result; - } - - @Override - public List getAlerts(Long encounterId) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(CdssAlert::getEncounterId, encounterId); - wrapper.orderByDesc(CdssAlert::getCreateTime); - return cdssAlertService.list(wrapper); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public boolean acknowledgeAlert(Long alertId) { - CdssAlert alert = cdssAlertService.getById(alertId); - if (alert == null) { - return false; - } - alert.setAcknowledged(true); - alert.setAcknowledgedTime(new Date()); - return cdssAlertService.updateById(alert); - } - - @Override - public List getRules(Map params) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - - String ruleType = getStr(params, "ruleType"); - if (ruleType != null && !ruleType.isEmpty()) { - wrapper.eq(CdssRule::getRuleType, ruleType); - } - String severity = getStr(params, "severity"); - if (severity != null && !severity.isEmpty()) { - wrapper.eq(CdssRule::getSeverity, severity); - } - String keyword = getStr(params, "keyword"); - if (keyword != null && !keyword.isEmpty()) { - wrapper.and(w -> w.like(CdssRule::getRuleName, keyword) - .or().like(CdssRule::getRuleCode, keyword)); - } - wrapper.orderByDesc(CdssRule::getCreateTime); - return cdssRuleService.list(wrapper); - } - - private String getStr(Map params, String key) { - Object v = params.get(key); - return v != null ? v.toString() : null; - } -} diff --git a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/infection/controller/CdssController.java b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/infection/controller/CdssController.java deleted file mode 100644 index b946a1f18..000000000 --- a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/infection/controller/CdssController.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.healthlink.his.web.infection.controller; - -import com.core.common.core.domain.R; -import com.healthlink.his.infection.domain.CdssAlert; -import com.healthlink.his.infection.domain.CdssRule; -import com.healthlink.his.web.infection.appservice.ICdssAppService; -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.List; -import java.util.Map; - -@Tag(name = "CDSS临床决策支持") -@RestController -@RequestMapping("/infection/cdss") -@Slf4j -@AllArgsConstructor -public class CdssController { - - private final ICdssAppService cdssAppService; - - @Operation(summary = "评估规则生成告警") - @PreAuthorize("@ss.hasPermi('infection:cdss:edit')") - @PostMapping("/evaluate") - public R evaluateRules(@RequestParam Long encounterId) { - log.info("CDSS规则评估, encounterId={}", encounterId); - return R.ok(cdssAppService.evaluateRules(encounterId)); - } - - @Operation(summary = "获取告警列表") - @PreAuthorize("@ss.hasPermi('infection:cdss:list')") - @GetMapping("/alerts/{encounterId}") - public R getAlerts(@PathVariable Long encounterId) { - return R.ok(cdssAppService.getAlerts(encounterId)); - } - - @Operation(summary = "确认告警") - @PreAuthorize("@ss.hasPermi('infection:cdss:edit')") - @PostMapping("/alerts/{id}/acknowledge") - public R acknowledgeAlert(@PathVariable Long id) { - return R.ok(cdssAppService.acknowledgeAlert(id)); - } - - @Operation(summary = "查询规则列表") - @PreAuthorize("@ss.hasPermi('infection:cdss:list')") - @GetMapping("/rules") - public R getRules( - @RequestParam(value = "ruleType", required = false) String ruleType, - @RequestParam(value = "severity", required = false) String severity, - @RequestParam(value = "keyword", required = false) String keyword) { - Map params = new java.util.HashMap<>(); - if (ruleType != null) params.put("ruleType", ruleType); - if (severity != null) params.put("severity", severity); - if (keyword != null) params.put("keyword", keyword); - return R.ok(cdssAppService.getRules(params)); - } -} diff --git a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/quality/controller/BusinessAnalyticsController.java b/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/quality/controller/BusinessAnalyticsController.java deleted file mode 100644 index f4f0eab25..000000000 --- a/healthlink-his-server/healthlink-his-application/src/main/java/com/healthlink/his/web/quality/controller/BusinessAnalyticsController.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.healthlink.his.web.quality.controller; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.core.common.core.domain.R; -import com.healthlink.his.quality.domain.BusinessAnalytics; -import com.healthlink.his.quality.service.IBusinessAnalyticsService; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.*; - -import java.math.BigDecimal; -import java.util.*; - -@RestController -@RequestMapping("/business-analytics") -@Slf4j -@AllArgsConstructor -public class BusinessAnalyticsController { - - private final IBusinessAnalyticsService analyticsService; - - @GetMapping("/page") - public R getPage( - @RequestParam(value = "departmentName", required = false) String deptName, - @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo, - @RequestParam(value = "pageSize", defaultValue = "20") Integer pageSize) { - LambdaQueryWrapper w = new LambdaQueryWrapper<>(); - w.like(StringUtils.hasText(deptName), BusinessAnalytics::getDepartmentName, deptName) - .orderByDesc(BusinessAnalytics::getStatDate); - return R.ok(analyticsService.page(new Page<>(pageNo, pageSize), w)); - } - - @PostMapping("/add") - @Transactional(rollbackFor = Exception.class) - public R add(@RequestBody BusinessAnalytics analytics) { - analytics.setCreateTime(new Date()); - analyticsService.save(analytics); - return R.ok(analytics); - } - - @GetMapping("/summary") - public R getSummary() { - Map summary = new HashMap<>(); - List list = analyticsService.list(); - BigDecimal totalRevenue = BigDecimal.ZERO, totalCost = BigDecimal.ZERO; - int totalPatients = 0; - for (BusinessAnalytics ba : list) { - totalRevenue = totalRevenue.add(ba.getRevenue() != null ? ba.getRevenue() : BigDecimal.ZERO); - totalCost = totalCost.add(ba.getCost() != null ? ba.getCost() : BigDecimal.ZERO); - totalPatients += ba.getPatientCount() != null ? ba.getPatientCount() : 0; - } - summary.put("totalRecords", list.size()); - summary.put("totalRevenue", totalRevenue); - summary.put("totalCost", totalCost); - summary.put("totalProfit", totalRevenue.subtract(totalCost)); - summary.put("totalPatients", totalPatients); - return R.ok(summary); - } -} diff --git a/healthlink-his-server/healthlink-his-application/src/main/resources/db/migration/V71__cdss.sql b/healthlink-his-server/healthlink-his-application/src/main/resources/db/migration/V71__cdss.sql deleted file mode 100644 index d540c2d3f..000000000 --- a/healthlink-his-server/healthlink-his-application/src/main/resources/db/migration/V71__cdss.sql +++ /dev/null @@ -1,33 +0,0 @@ -CREATE TABLE cdss_rule ( - id BIGSERIAL PRIMARY KEY, - rule_code VARCHAR(32) NOT NULL, - rule_name VARCHAR(100) NOT NULL, - rule_type VARCHAR(20) NOT NULL, - condition_expr TEXT NOT NULL, - suggestion TEXT NOT NULL, - severity VARCHAR(16) DEFAULT 'INFO', - enabled BOOLEAN DEFAULT TRUE, - tenant_id BIGINT DEFAULT 0, - delete_flag CHAR(1) DEFAULT '0', - create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - create_by VARCHAR(64), - update_time TIMESTAMP, - update_by VARCHAR(64) -); - -CREATE TABLE cdss_alert ( - id BIGSERIAL PRIMARY KEY, - encounter_id BIGINT NOT NULL, - patient_id BIGINT NOT NULL, - rule_id BIGINT NOT NULL, - alert_type VARCHAR(20) NOT NULL, - alert_message TEXT NOT NULL, - severity VARCHAR(16) NOT NULL, - acknowledged BOOLEAN DEFAULT FALSE, - acknowledged_by BIGINT, - acknowledged_time TIMESTAMP, - tenant_id BIGINT DEFAULT 0, - delete_flag CHAR(1) DEFAULT '0', - create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - create_by VARCHAR(64) -);