refactor(infection): 移除CDSS临床决策支持相关功能
- 删除CdssAppServiceImpl实现类及其接口ICdssAppService - 移除CdssController控制器及相关的API端点 - 删除BusinessAnalyticsController业务分析控制器 - 移除V71__cdss.sql数据库迁移脚本 - 清理所有与CDSS规则和告警相关的代码
This commit is contained in:
@@ -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<String, Object> evaluateRules(Long encounterId);
|
||||
List<CdssAlert> getAlerts(Long encounterId);
|
||||
boolean acknowledgeAlert(Long alertId);
|
||||
List<CdssRule> getRules(Map<String, Object> params);
|
||||
}
|
||||
@@ -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<String, Object> evaluateRules(Long encounterId) {
|
||||
log.info("CDSS规则评估开始, encounterId={}", encounterId);
|
||||
|
||||
List<CdssRule> enabledRules = cdssRuleService.list(
|
||||
new LambdaQueryWrapper<CdssRule>()
|
||||
.eq(CdssRule::getEnabled, true)
|
||||
);
|
||||
|
||||
List<CdssAlert> 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<String, Object> 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<CdssAlert> getAlerts(Long encounterId) {
|
||||
LambdaQueryWrapper<CdssAlert> 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<CdssRule> getRules(Map<String, Object> params) {
|
||||
LambdaQueryWrapper<CdssRule> 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<String, Object> params, String key) {
|
||||
Object v = params.get(key);
|
||||
return v != null ? v.toString() : 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<String, Object> 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));
|
||||
}
|
||||
}
|
||||
@@ -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<BusinessAnalytics> 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<String, Object> summary = new HashMap<>();
|
||||
List<BusinessAnalytics> 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);
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
);
|
||||
Reference in New Issue
Block a user