diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/appservice/IInfectiousCardAppService.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/appservice/IInfectiousCardAppService.java index 6ef9bd32..ebad467e 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/appservice/IInfectiousCardAppService.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/appservice/IInfectiousCardAppService.java @@ -4,7 +4,7 @@ import com.core.common.core.domain.R; import com.openhis.web.reportManagement.dto.InfectiousCardParam; import javax.servlet.http.HttpServletResponse; -// import java.util.List; // 批量操作功能暂未实现 +import java.util.List; /** * 传染病报卡 AppService 接口 @@ -41,44 +41,44 @@ public interface IInfectiousCardAppService { R getByCardNo(String cardNo); /** - * 审核传染病报卡(功能暂未实现) + * 审核传染病报卡 * * @param cardNo 报卡编号 * @param auditOpinion 审核意见 * @param status 审核状态 * @return 结果 */ - // R audit(String cardNo, String auditOpinion, String status); + R audit(String cardNo, String auditOpinion, String status); /** - * 退回传染病报卡(功能暂未实现) + * 退回传染病报卡 * * @param cardNo 报卡编号 * @param returnReason 退回原因 * @param status 审核状态 * @return 结果 */ - // R returnCard(String cardNo, String returnReason, String status); + R returnCard(String cardNo, String returnReason, String status); /** - * 批量审核传染病报卡(功能暂未实现) + * 批量审核传染病报卡 * * @param cardNos 报卡编号列表 * @param auditOpinion 审核意见 * @param status 审核状态 * @return 结果 */ - // R batchAudit(List cardNos, String auditOpinion, String status); + R batchAudit(List cardNos, String auditOpinion, String status); /** - * 批量退回传染病报卡(功能暂未实现) + * 批量退回传染病报卡 * * @param cardNos 报卡编号列表 * @param returnReason 退回原因 * @param status 审核状态 * @return 结果 */ - // R batchReturn(List cardNos, String returnReason, String status); + R batchReturn(List cardNos, String returnReason, String status); /** * 导出传染病报卡 diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/appservice/impl/InfectiousCardAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/appservice/impl/InfectiousCardAppServiceImpl.java index 50001aa1..9cb86f10 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/appservice/impl/InfectiousCardAppServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/appservice/impl/InfectiousCardAppServiceImpl.java @@ -4,9 +4,7 @@ import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.core.common.core.domain.R; -import com.openhis.administration.domain.InfectiousDiseaseReport; import com.openhis.administration.domain.Organization; -import com.openhis.administration.mapper.InfectiousDiseaseReportMapper; import com.openhis.administration.service.IOrganizationService; import com.openhis.web.reportManagement.appservice.IInfectiousCardAppService; import com.openhis.web.reportManagement.dto.InfectiousCardDto; @@ -17,9 +15,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.servlet.http.HttpServletResponse; +import java.io.PrintWriter; import java.util.ArrayList; -import java.util.Date; - import java.util.List; +import java.util.List; /** * 传染病报卡 AppService 实现 @@ -34,9 +32,6 @@ public class InfectiousCardAppServiceImpl implements IInfectiousCardAppService { @Autowired private ReportManageCardMapper reportManageCardMapper; - @Autowired - private InfectiousDiseaseReportMapper infectiousDiseaseReportMapper; - @Autowired private IOrganizationService organizationService; @@ -104,110 +99,122 @@ public class InfectiousCardAppServiceImpl implements IInfectiousCardAppService { } /** - * 审核传染病报卡(功能暂未实现) + * 审核传染病报卡 * @param cardNo 卡号 * @param auditOpinion 审核意见 * @param status 审核状态 * @return 审核结果 */ - // @Override - // public R audit(String cardNo, String auditOpinion, String status) { - // try { - // InfectiousDiseaseReport report = infectiousDiseaseReportMapper.selectById(cardNo); - // if (report == null) { - // return R.fail("报卡不存在"); - // } + @Override + public R audit(String cardNo, String auditOpinion, String status) { + try { + InfectiousCardDto dto = reportManageCardMapper.selectCardByCardNo(cardNo); + if (dto == null) { + return R.fail("报卡不存在"); + } - // report.setStatus(Integer.parseInt(status)); - // report.setUpdateTime(new Date()); - - // infectiousDiseaseReportMapper.updateById(report); - - // return R.ok("审核成功"); - // } catch (Exception e) { - // log.error("审核传染病报卡失败", e); - // return R.fail("审核失败:" + e.getMessage()); - // } - // } + int rows = reportManageCardMapper.auditCard(cardNo, Integer.parseInt(status)); + if (rows > 0) { + return R.ok("审核成功"); + } else { + return R.fail("审核失败:未更新任何记录"); + } + } catch (Exception e) { + log.error("审核传染病报卡失败", e); + return R.fail("审核失败:" + e.getMessage()); + } + } /** - * 退回传染病报卡(功能暂未实现) + * 退回传染病报卡 * @param cardNo 卡号 * @param returnReason 退回原因 * @param status 退回状态 * @return 退回结果 */ - // @Override - // public R returnCard(String cardNo, String returnReason, String status) { - // try { - // InfectiousDiseaseReport report = infectiousDiseaseReportMapper.selectById(cardNo); - // if (report == null) { - // return R.fail("报卡不存在"); - // } + @Override + public R returnCard(String cardNo, String returnReason, String status) { + try { + InfectiousCardDto dto = reportManageCardMapper.selectCardByCardNo(cardNo); + if (dto == null) { + return R.fail("报卡不存在"); + } - // report.setStatus(Integer.parseInt(status)); - // report.setWithdrawReason(returnReason); - // report.setUpdateTime(new Date()); - - // infectiousDiseaseReportMapper.updateById(report); - - // return R.ok("退回成功"); - // } catch (Exception e) { - // log.error("退回传染病报卡失败", e); - // return R.fail("退回失败:" + e.getMessage()); - // } - // } + int rows = reportManageCardMapper.returnCard(cardNo, Integer.parseInt(status), returnReason); + if (rows > 0) { + return R.ok("退回成功"); + } else { + return R.fail("退回失败:未更新任何记录"); + } + } catch (Exception e) { + log.error("退回传染病报卡失败", e); + return R.fail("退回失败:" + e.getMessage()); + } + } /** - * 批量审核传染病报卡(功能暂未实现) + * 批量审核传染病报卡 * @param cardNos 卡号列表 * @param auditOpinion 审核意见 * @param status 审核状态 * @return 批量审核结果 */ - // @Override - // public R batchAudit(List cardNos, String auditOpinion, String status) { - // try { - // for (String cardNo : cardNos) { - // InfectiousDiseaseReport report = infectiousDiseaseReportMapper.selectById(cardNo); - // if (report != null) { - // report.setStatus(Integer.parseInt(status)); - // report.setUpdateTime(new Date()); - // infectiousDiseaseReportMapper.updateById(report); - // } - // } - // return R.ok("批量审核成功"); - // } catch (Exception e) { - // log.error("批量审核传染病报卡失败", e); - // return R.fail("批量审核失败:" + e.getMessage()); - // } - // } + @Override + public R batchAudit(List cardNos, String auditOpinion, String status) { + try { + int successCount = 0; + int failCount = 0; + for (String cardNo : cardNos) { + try { + int rows = reportManageCardMapper.auditCard(cardNo, Integer.parseInt(status)); + if (rows > 0) { + successCount++; + } else { + failCount++; + } + } catch (Exception e) { + log.error("批量审核卡号 {} 失败", cardNo, e); + failCount++; + } + } + return R.ok(String.format("批量审核完成:成功 %d 条,失败 %d 条", successCount, failCount)); + } catch (Exception e) { + log.error("批量审核传染病报卡失败", e); + return R.fail("批量审核失败:" + e.getMessage()); + } + } /** - * 批量退回传染病报卡(功能暂未实现) + * 批量退回传染病报卡 * @param cardNos 卡号列表 * @param returnReason 退回原因 * @param status 退回状态 * @return 批量退回结果 */ - // @Override - // public R batchReturn(List cardNos, String returnReason, String status) { - // try { - // for (String cardNo : cardNos) { - // InfectiousDiseaseReport report = infectiousDiseaseReportMapper.selectById(cardNo); - // if (report != null) { - // report.setStatus(Integer.parseInt(status)); - // report.setWithdrawReason(returnReason); - // report.setUpdateTime(new Date()); - // infectiousDiseaseReportMapper.updateById(report); - // } - // } - // return R.ok("批量退回成功"); - // } catch (Exception e) { - // log.error("批量退回传染病报卡失败", e); - // return R.fail("批量退回失败:" + e.getMessage()); - // } - // } + @Override + public R batchReturn(List cardNos, String returnReason, String status) { + try { + int successCount = 0; + int failCount = 0; + for (String cardNo : cardNos) { + try { + int rows = reportManageCardMapper.returnCard(cardNo, Integer.parseInt(status), returnReason); + if (rows > 0) { + successCount++; + } else { + failCount++; + } + } catch (Exception e) { + log.error("批量退回卡号 {} 失败", cardNo, e); + failCount++; + } + } + return R.ok(String.format("批量退回完成:成功 %d 条,失败 %d 条", successCount, failCount)); + } catch (Exception e) { + log.error("批量退回传染病报卡失败", e); + return R.fail("批量退回失败:" + e.getMessage()); + } + } /** * 导出传染病报卡数据 @@ -216,7 +223,143 @@ public class InfectiousCardAppServiceImpl implements IInfectiousCardAppService { */ @Override public void export(InfectiousCardParam param, HttpServletResponse response) { - log.warn("导出功能暂未实现"); + try { + // 查询所有符合条件的数据 + List list = reportManageCardMapper.selectAllCards(param); + + // 设置响应头 + response.setContentType("text/csv;charset=UTF-8"); + response.setHeader("Content-Disposition", + "attachment; filename=infectious_cards_" + System.currentTimeMillis() + ".csv"); + + // 写入 CSV 内容 + java.io.PrintWriter writer = response.getWriter(); + + // 写入 BOM,防止中文乱码 + writer.print('\uFEFF'); + + // 写入表头 + writer.println("报卡编号,报卡名称,病种名称,患者姓名,性别,年龄,上报科室,登记来源,上报时间,审核状态," + + "身份证号,联系电话,现住地址,职业,病例分类,发病日期,诊断日期,报告单位,报告医生,填卡日期,备注"); + + // 写入数据 + for (InfectiousCardDto dto : list) { + writer.println(String.format("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s", + escapeCsv(dto.getCardNo()), + escapeCsv(dto.getCardName()), + escapeCsv(dto.getDiseaseName()), + escapeCsv(dto.getPatientName()), + "1".equals(dto.getSex()) ? "男" : "2".equals(dto.getSex()) ? "女" : "未知", + dto.getAge() + getAgeUnit(dto.getAgeUnit()), + escapeCsv(dto.getDeptName()), + getRegistrationSourceName(dto.getRegistrationSource()), + dto.getReportDate(), + getStatusName(dto.getStatus()), + escapeCsv(dto.getIdNo()), + escapeCsv(dto.getPhone()), + escapeCsv(getFullAddress(dto)), + escapeCsv(dto.getOccupation()), + getCaseClassName(dto.getCaseClass()), + dto.getOnsetDate(), + dto.getDiagDate() != null ? dto.getDiagDate().toString().substring(0, 10) : "", + escapeCsv(dto.getReportOrg()), + escapeCsv(dto.getReportDoc()), + dto.getReportDate(), + escapeCsv(dto.getRemark() != null ? dto.getRemark() : "") + )); + } + + writer.flush(); + log.info("导出传染病报卡数据成功,共 {} 条", list.size()); + } catch (Exception e) { + log.error("导出传染病报卡数据失败", e); + throw new RuntimeException("导出失败:" + e.getMessage()); + } + } + + /** + * CSV 字段转义 + */ + private String escapeCsv(String value) { + if (value == null) { + return ""; + } + if (value.contains(",") || value.contains("\"") || value.contains("\n")) { + return "\"" + value.replace("\"", "\"\"") + "\""; + } + return value; + } + + /** + * 获取年龄单位 + */ + private String getAgeUnit(String unit) { + if (unit == null) return "岁"; + switch (unit) { + case "1": return "岁"; + case "2": return "月"; + case "3": return "天"; + default: return "岁"; + } + } + + /** + * 获取登记来源名称 + */ + private String getRegistrationSourceName(Integer source) { + if (source == null) return "未知"; + switch (source) { + case 1: return "门诊"; + case 2: return "住院"; + case 3: return "急诊"; + case 4: return "体检"; + default: return "未知"; + } + } + + /** + * 获取状态名称 + */ + private String getStatusName(Integer status) { + if (status == null) return "未知"; + switch (status) { + case 0: return "草稿"; + case 1: return "待审核"; + case 2: return "审核通过"; + case 3: return "已上报"; + case 4: return "已撤回"; + case 5: return "审核失败"; + default: return "未知"; + } + } + + /** + * 获取病例分类名称 + */ + private String getCaseClassName(Integer caseClass) { + if (caseClass == null) return "未知"; + switch (caseClass) { + case 1: return "疑似病例"; + case 2: return "临床诊断病例"; + case 3: return "确诊病例"; + case 4: return "病原携带者"; + case 5: return "阳性检测结果"; + default: return "未知"; + } + } + + /** + * 获取完整地址 + */ + private String getFullAddress(InfectiousCardDto dto) { + StringBuilder sb = new StringBuilder(); + if (dto.getAddressProv() != null) sb.append(dto.getAddressProv()); + if (dto.getAddressCity() != null) sb.append(dto.getAddressCity()); + if (dto.getAddressCounty() != null) sb.append(dto.getAddressCounty()); + if (dto.getAddressTown() != null) sb.append(dto.getAddressTown()); + if (dto.getAddressVillage() != null) sb.append(dto.getAddressVillage()); + if (dto.getAddressHouse() != null) sb.append(dto.getAddressHouse()); + return sb.toString(); } /** diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/controller/reportManagementController.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/controller/reportManagementController.java index ff92cfdc..ca76c77e 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/controller/reportManagementController.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/controller/reportManagementController.java @@ -3,11 +3,16 @@ package com.openhis.web.reportManagement.controller; import com.core.common.core.domain.R; import com.openhis.web.reportManagement.appservice.IInfectiousCardAppService; import com.openhis.web.reportManagement.dto.InfectiousCardParam; +import com.openhis.web.reportManagement.dto.AuditInfectiousCardRequest; +import com.openhis.web.reportManagement.dto.ReturnInfectiousCardRequest; +import com.openhis.web.reportManagement.dto.BatchAuditInfectiousCardRequest; +import com.openhis.web.reportManagement.dto.BatchReturnInfectiousCardRequest; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; // import java.util.List; // 批量操作功能暂未实现 /** @@ -62,64 +67,48 @@ public class reportManagementController { } /** - * 审核传染病报卡(功能暂未实现) + * 审核传染病报卡 * - * @param cardNo 报卡编号 - * @param auditOpinion 审核意见 - * @param status 审核状态 + * @param request 审核请求 * @return 结果 */ - // @PostMapping("/audit") - // public R audit(@RequestParam String cardNo, - // @RequestParam String auditOpinion, - // @RequestParam String status) { - // return infectiousCardAppService.audit(cardNo, auditOpinion, status); - // } + @PostMapping("/audit") + public R audit(@RequestBody AuditInfectiousCardRequest request) { + return infectiousCardAppService.audit(request.getCardNo(), request.getAuditOpinion(), request.getStatus()); + } /** - * 退回传染病报卡(功能暂未实现) + * 退回传染病报卡 * - * @param cardNo 报卡编号 - * @param returnReason 退回原因 - * @param status 审核状态 + * @param request 退回请求 * @return 结果 */ - // @PostMapping("/return") - // public R returnCard(@RequestParam String cardNo, - // @RequestParam String returnReason, - // @RequestParam String status) { - // return infectiousCardAppService.returnCard(cardNo, returnReason, status); - // } + @PostMapping("/return") + public R returnCard(@Valid @RequestBody ReturnInfectiousCardRequest request) { + return infectiousCardAppService.returnCard(request.getCardNo(), request.getReturnReason(), request.getStatus()); + } /** - * 批量审核传染病报卡(功能暂未实现) + * 批量审核传染病报卡 * - * @param cardNos 报卡编号列表 - * @param auditOpinion 审核意见 - * @param status 审核状态 + * @param request 批量审核请求 * @return 结果 */ - // @PostMapping("/batchAudit") - // public R batchAudit(@RequestBody List cardNos, - // @RequestParam String auditOpinion, - // @RequestParam String status) { - // return infectiousCardAppService.batchAudit(cardNos, auditOpinion, status); - // } + @PostMapping("/batchAudit") + public R batchAudit(@RequestBody BatchAuditInfectiousCardRequest request) { + return infectiousCardAppService.batchAudit(request.getCardNos(), request.getAuditOpinion(), request.getStatus()); + } /** - * 批量退回传染病报卡(功能暂未实现) + * 批量退回传染病报卡 * - * @param cardNos 报卡编号列表 - * @param returnReason 退回原因 - * @param status 审核状态 + * @param request 批量退回请求 * @return 结果 */ - // @PostMapping("/batchReturn") - // public R batchReturn(@RequestBody List cardNos, - // @RequestParam String returnReason, - // @RequestParam String status) { - // return infectiousCardAppService.batchReturn(cardNos, returnReason, status); - // } + @PostMapping("/batchReturn") + public R batchReturn(@Valid @RequestBody BatchReturnInfectiousCardRequest request) { + return infectiousCardAppService.batchReturn(request.getCardNos(), request.getReturnReason(), request.getStatus()); + } /** * 导出传染病报卡 @@ -127,7 +116,7 @@ public class reportManagementController { * @param param 查询参数 * @param response 响应对象 */ - @PostMapping("/export") + @GetMapping("/export") public void export(InfectiousCardParam param, HttpServletResponse response) { infectiousCardAppService.export(param, response); } diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/dto/AuditInfectiousCardRequest.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/dto/AuditInfectiousCardRequest.java new file mode 100644 index 00000000..c8a0f0a0 --- /dev/null +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/dto/AuditInfectiousCardRequest.java @@ -0,0 +1,23 @@ +package com.openhis.web.reportManagement.dto; + +import lombok.Data; + +/** + * 审核传染病报卡请求 DTO + * + * @author system + * @date 2026-04-13 + */ +@Data +public class AuditInfectiousCardRequest { + + /** 卡片编号(主键) */ + private String cardNo; + + /** 审核意见 */ + private String auditOpinion; + + /** 审核状态 (0 暂存/1 待审核/2 已审核/3 已上报/4 失败/5 退回) */ + private String status; + +} \ No newline at end of file diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/dto/BatchAuditInfectiousCardRequest.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/dto/BatchAuditInfectiousCardRequest.java new file mode 100644 index 00000000..16b1f28b --- /dev/null +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/dto/BatchAuditInfectiousCardRequest.java @@ -0,0 +1,25 @@ +package com.openhis.web.reportManagement.dto; + +import lombok.Data; + +import java.util.List; + +/** + * 批量审核传染病报卡请求 DTO + * + * @author system + * @date 2026-04-13 + */ +@Data +public class BatchAuditInfectiousCardRequest { + + /** 卡片编号列表 */ + private List cardNos; + + /** 审核意见 */ + private String auditOpinion; + + /** 审核状态 (0 暂存/1 待审核/2 已审核/3 已上报/4 失败/5 退回) */ + private String status; + +} \ No newline at end of file diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/dto/BatchReturnInfectiousCardRequest.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/dto/BatchReturnInfectiousCardRequest.java new file mode 100644 index 00000000..2a0994d5 --- /dev/null +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/dto/BatchReturnInfectiousCardRequest.java @@ -0,0 +1,27 @@ +package com.openhis.web.reportManagement.dto; + +import lombok.Data; + +import javax.validation.constraints.Size; +import java.util.List; + +/** + * 批量退回传染病报卡请求 DTO + * + * @author system + * @date 2026-04-13 + */ +@Data +public class BatchReturnInfectiousCardRequest { + + /** 卡片编号列表 */ + private List cardNos; + + /** 退回原因 */ + @Size(max = 50, message = "退回原因不能超过50个字符") + private String returnReason; + + /** 审核状态 (0 暂存/1 待审核/2 已审核/3 已上报/4 失败/5 退回) */ + private String status; + +} \ No newline at end of file diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/dto/ReturnInfectiousCardRequest.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/dto/ReturnInfectiousCardRequest.java new file mode 100644 index 00000000..0a0b8383 --- /dev/null +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/dto/ReturnInfectiousCardRequest.java @@ -0,0 +1,26 @@ +package com.openhis.web.reportManagement.dto; + +import lombok.Data; + +import javax.validation.constraints.Size; + +/** + * 退回传染病报卡请求 DTO + * + * @author system + * @date 2026-04-13 + */ +@Data +public class ReturnInfectiousCardRequest { + + /** 卡片编号(主键) */ + private String cardNo; + + /** 退回原因 */ + @Size(max = 50, message = "退回原因不能超过50个字符") + private String returnReason; + + /** 审核状态 (0 暂存/1 待审核/2 已审核/3 已上报/4 失败/5 退回) */ + private String status; + +} \ No newline at end of file diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/mapper/ReportManageCardMapper.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/mapper/ReportManageCardMapper.java index c750e350..370792e0 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/mapper/ReportManageCardMapper.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/reportManagement/mapper/ReportManageCardMapper.java @@ -7,6 +7,8 @@ import com.openhis.web.reportManagement.dto.InfectiousCardParam; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; +import java.util.List; + /** * 传染病报卡 Mapper 接口 * @@ -30,4 +32,28 @@ public interface ReportManageCardMapper { * @return 报卡详情 */ InfectiousCardDto selectCardByCardNo(@Param("cardNo") String cardNo); + + /** + * 审核传染病报卡 + * @param cardNo 卡号 + * @param status 审核状态 + * @return 影响行数 + */ + int auditCard(@Param("cardNo") String cardNo, @Param("status") Integer status); + + /** + * 退回传染病报卡 + * @param cardNo 卡号 + * @param status 退回状态 + * @param returnReason 退回原因 + * @return 影响行数 + */ + int returnCard(@Param("cardNo") String cardNo, @Param("status") Integer status, @Param("returnReason") String returnReason); + + /** + * 查询所有报卡数据(用于导出) + * @param param 查询参数 + * @return 报卡列表 + */ + List selectAllCards(@Param("param") InfectiousCardParam param); } diff --git a/openhis-server-new/openhis-application/src/main/resources/mapper/reportManagement/InfectiousCardMapper.xml b/openhis-server-new/openhis-application/src/main/resources/mapper/reportManagement/InfectiousCardMapper.xml index 638f8ff5..4f8a30ba 100644 --- a/openhis-server-new/openhis-application/src/main/resources/mapper/reportManagement/InfectiousCardMapper.xml +++ b/openhis-server-new/openhis-application/src/main/resources/mapper/reportManagement/InfectiousCardMapper.xml @@ -70,7 +70,7 @@ AND t1.pat_name LIKE CONCAT('%', #{param.patientName}, '%') - AND t1.status = #{param.status} + AND t1.status::INTEGER = #{param.status} AND t1.registration_source = #{param.registrationSource} @@ -150,4 +150,106 @@ WHERE t1.delete_flag = '0' AND t1.card_no = #{cardNo} + + + UPDATE infectious_card + SET status = #{status}::INTEGER, + update_time = CURRENT_TIMESTAMP + WHERE card_no = #{cardNo} + + + + + UPDATE infectious_card + SET status = #{status}::INTEGER, + return_reason = #{returnReason}, + update_time = CURRENT_TIMESTAMP + WHERE card_no = #{cardNo} + + + + + diff --git a/openhis-server-new/openhis-domain/src/main/java/com/openhis/administration/domain/InfectiousDiseaseReport.java b/openhis-server-new/openhis-domain/src/main/java/com/openhis/administration/domain/InfectiousDiseaseReport.java index 71809aa9..3755e338 100644 --- a/openhis-server-new/openhis-domain/src/main/java/com/openhis/administration/domain/InfectiousDiseaseReport.java +++ b/openhis-server-new/openhis-domain/src/main/java/com/openhis/administration/domain/InfectiousDiseaseReport.java @@ -1,6 +1,7 @@ package com.openhis.administration.domain; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.core.common.core.domain.HisBaseEntity; @@ -121,7 +122,8 @@ public class InfectiousDiseaseReport extends HisBaseEntity { /** 订正病名(订正报告必填) */ private String correctName; - /** 退卡原因(退卡时必填�?*/ + /** 退卡原因(退卡时必填) */ + @TableField("return_reason") private String withdrawReason; /** 报告单位(统一信用代码/医院名称�?*/ diff --git a/openhis-ui-vue3/src/views/diseaseReportManagement/ReportManagement/api.js b/openhis-ui-vue3/src/views/diseaseReportManagement/ReportManagement/api.js index 44ce4627..ffce5931 100644 --- a/openhis-ui-vue3/src/views/diseaseReportManagement/ReportManagement/api.js +++ b/openhis-ui-vue3/src/views/diseaseReportManagement/ReportManagement/api.js @@ -68,64 +68,64 @@ export function deleteInfectiousCard(cardNo) { } /** - * 审核传染病报卡(功能暂未实现) + * 审核传染病报卡 * @param {Object} data - 审核数据 * @param {string} data.cardNo - 报卡编号 * @param {string} data.auditOpinion - 审核意见 * @param {string} data.status - 审核状态(2:通过) */ -// export function auditInfectiousCard(data) { -// return request({ -// url: '/report-manage/infectiousDiseaseReport/audit', -// method: 'post', -// data, -// }); -// } +export function auditInfectiousCard(data) { + return request({ + url: '/report-manage/infectiousDiseaseReport/audit', + method: 'post', + data, + }); +} /** - * 退回传染病报卡(功能暂未实现) + * 退回传染病报卡 * @param {Object} data - 退回数据 * @param {string} data.cardNo - 报卡编号 * @param {string} data.returnReason - 退回原因 * @param {string} data.status - 审核状态(5:审核失败) */ -// export function returnInfectiousCard(data) { -// return request({ -// url: '/report-manage/infectiousDiseaseReport/return', -// method: 'post', -// data, -// }); -// } +export function returnInfectiousCard(data) { + return request({ + url: '/report-manage/infectiousDiseaseReport/return', + method: 'post', + data, + }); +} /** - * 批量审核传染病报卡(功能暂未实现) + * 批量审核传染病报卡 * @param {Object} data - 批量审核数据 * @param {Array} data.cardNos - 报卡编号数组 * @param {string} data.auditOpinion - 审核意见 * @param {string} data.status - 审核状态(2:通过) */ -// export function batchAuditCards(data) { -// return request({ -// url: '/report-manage/infectiousDiseaseReport/batchAudit', -// method: 'post', -// data, -// }); -// } +export function batchAuditCards(data) { + return request({ + url: '/report-manage/infectiousDiseaseReport/batchAudit', + method: 'post', + data, + }); +} /** - * 批量退回传染病报卡(功能暂未实现) + * 批量退回传染病报卡 * @param {Object} data - 批量退回数据 * @param {Array} data.cardNos - 报卡编号数组 * @param {string} data.returnReason - 退回原因 * @param {string} data.status - 审核状态(5:审核失败) */ -// export function batchReturnCards(data) { -// return request({ -// url: '/report-manage/infectiousDiseaseReport/batchReturn', -// method: 'post', -// data, -// }); -// } +export function batchReturnCards(data) { + return request({ + url: '/report-manage/infectiousDiseaseReport/batchReturn', + method: 'post', + data, + }); +} /** * 获取科室树 @@ -149,3 +149,16 @@ export function getAuditRecords(cardNo) { method: 'get', }); } + +/** + * 导出传染病报卡 + * @param {Object} params - 查询参数 + */ +export function exportInfectiousCards(params) { + return request({ + url: '/report-manage/infectiousDiseaseReport/export', + method: 'get', + params, + responseType: 'blob' + }); +} diff --git a/openhis-ui-vue3/src/views/diseaseReportManagement/ReportManagement/index.vue b/openhis-ui-vue3/src/views/diseaseReportManagement/ReportManagement/index.vue index 47dc1b78..a96b6471 100644 --- a/openhis-ui-vue3/src/views/diseaseReportManagement/ReportManagement/index.vue +++ b/openhis-ui-vue3/src/views/diseaseReportManagement/ReportManagement/index.vue @@ -497,6 +497,8 @@ type="textarea" :rows="3" placeholder="如需退回,请填写退回原因" + maxlength="50" + show-word-limit /> @@ -556,6 +558,8 @@ type="textarea" :rows="3" placeholder="请填写退回原因" + maxlength="50" + show-word-limit /> @@ -576,11 +580,12 @@ import useUserStore from '@/store/modules/user'; import { listInfectiousCards, getInfectiousCard, - // auditInfectiousCard, // 功能暂未实现 - // returnInfectiousCard, // 功能暂未实现 - // batchAuditCards, // 功能暂未实现 - // batchReturnCards, // 功能暂未实现 - getDeptTree + auditInfectiousCard, + returnInfectiousCard, + batchAuditCards, + batchReturnCards, + getDeptTree, + exportInfectiousCards } from './api'; const { proxy } = getCurrentInstance(); @@ -876,67 +881,77 @@ function handleDrawerClose() { } // 审核通过 -function handlePassCard() { - ElMessage.info('审核通过功能暂未实现'); - // if (!auditForm.value.auditOpinion) { - // ElMessage.warning('请填写审核意见'); - // return; - // } +async function handlePassCard() { + if (!auditForm.value.auditOpinion) { + ElMessage.warning('请填写审核意见'); + return; + } - // try { - // const res = await auditInfectiousCard({ - // cardNo: currentCard.value.cardNo, - // auditOpinion: auditForm.value.auditOpinion, - // status: '2' - // }); + try { + const res = await auditInfectiousCard({ + cardNo: currentCard.value.cardNo, + auditOpinion: auditForm.value.auditOpinion, + status: '2' + }); - // if (res.code === 200) { - // ElMessage.success('审核通过'); - // handleDrawerClose(); - // loadTableData(); - // loadStats(); - // } else { - // ElMessage.error(res.msg || '审核失败'); - // } - // } catch (err) { - // ElMessage.error('审核失败'); - // console.error(err); - // } + if (res.code === 200) { + ElMessage.success('审核通过'); + handleDrawerClose(); + loadTableData(); + loadStats(); + } else { + ElMessage.error(res.msg || '审核失败'); + } + } catch (err) { + ElMessage.error('审核失败'); + console.error(err); + } } // 退回修改 -function handleReturnCard() { - ElMessage.info('退回修改功能暂未实现'); - // if (!auditForm.value.returnReason) { - // ElMessage.warning('请填写退回原因'); - // return; - // } +async function handleReturnCard() { + if (!auditForm.value.returnReason) { + ElMessage.warning('请填写退回原因'); + return; + } - // try { - // const res = await returnInfectiousCard({ - // cardNo: currentCard.value.cardNo, - // returnReason: auditForm.value.returnReason, - // status: '5' - // }); + // 验证退回原因长度 + if (auditForm.value.returnReason.length > 50) { + ElMessage.warning('退回原因不能超过50个字符'); + return; + } - // if (res.code === 200) { - // ElMessage.success('已退回修改'); - // handleDrawerClose(); - // loadTableData(); - // loadStats(); - // } else { - // ElMessage.error(res.msg || '退回失败'); - // } - // } catch (err) { - // ElMessage.error('退回失败'); - // console.error(err); - // } + try { + const res = await returnInfectiousCard({ + cardNo: currentCard.value.cardNo, + returnReason: auditForm.value.returnReason, + status: '5' + }); + + if (res.code === 200) { + ElMessage.success('已退回修改'); + handleDrawerClose(); + loadTableData(); + loadStats(); + } else { + ElMessage.error(res.msg || '退回失败'); + } + } catch (err) { + ElMessage.error('退回失败'); + console.error(err); + } } // 批量审核 function handleBatchAudit() { - ElMessage.info('批量审核功能暂未实现'); - // batchAuditDialogVisible.value = true; + // 检查是否包含非待审核状态的报卡 + const nonPendingCards = selectedRows.value.filter(row => row.status !== 1); + if (nonPendingCards.length > 0) { + ElMessage.warning('只能选择待审核状态的报卡'); + return; + } + + batchAuditDialogVisible.value = true; } function handleBatchAuditClose() { @@ -944,41 +959,47 @@ function handleBatchAuditClose() { batchAuditForm.auditOpinion = ''; } -// async function confirmBatchAudit() { -// if (!batchAuditForm.auditOpinion) { -// ElMessage.warning('请填写审核意见'); -// return; -// } +async function confirmBatchAudit() { + if (!batchAuditForm.auditOpinion) { + ElMessage.warning('请填写审核意见'); + return; + } -// batchLoading.value = true; -// try { -// const cardNos = selectedRows.value.map(row => row.cardNo); -// const res = await batchAuditCards({ -// cardNos, -// auditOpinion: batchAuditForm.auditOpinion, -// status: '2' -// }); + batchLoading.value = true; + try { + const cardNos = selectedRows.value.map(row => row.cardNo); + const res = await batchAuditCards({ + cardNos, + auditOpinion: batchAuditForm.auditOpinion, + status: '2' + }); -// if (res.code === 200) { -// ElMessage.success('批量审核成功'); -// handleBatchAuditClose(); -// loadTableData(); -// loadStats(); -// } else { -// ElMessage.error(res.msg || '批量审核失败'); -// } -// } catch (err) { -// ElMessage.error('批量审核失败'); -// console.error(err); -// } finally { -// batchLoading.value = false; -// } -// } + if (res.code === 200) { + ElMessage.success('批量审核成功'); + handleBatchAuditClose(); + loadTableData(); + loadStats(); + } else { + ElMessage.error(res.msg || '批量审核失败'); + } + } catch (err) { + ElMessage.error('批量审核失败'); + console.error(err); + } finally { + batchLoading.value = false; + } +} // 批量退回 function handleBatchReturn() { - ElMessage.info('批量退回功能暂未实现'); - // batchReturnDialogVisible.value = true; + // 检查是否包含非待审核状态的报卡 + const nonPendingCards = selectedRows.value.filter(row => row.status !== 1); + if (nonPendingCards.length > 0) { + ElMessage.warning('只能选择待审核状态的报卡'); + return; + } + + batchReturnDialogVisible.value = true; } function handleBatchReturnClose() { @@ -986,40 +1007,84 @@ function handleBatchReturnClose() { batchReturnForm.returnReason = ''; } -// async function confirmBatchReturn() { -// if (!batchReturnForm.returnReason) { -// ElMessage.warning('请填写退回原因'); -// return; -// } +async function confirmBatchReturn() { + if (!batchReturnForm.returnReason) { + ElMessage.warning('请填写退回原因'); + return; + } -// batchLoading.value = true; -// try { -// const cardNos = selectedRows.value.map(row => row.cardNo); -// const res = await batchReturnCards({ -// cardNos, -// returnReason: batchReturnForm.returnReason, -// status: '5' -// }); + // 验证退回原因长度 + if (batchReturnForm.returnReason.length > 50) { + ElMessage.warning('退回原因不能超过50个字符'); + return; + } -// if (res.code === 200) { -// ElMessage.success('批量退回成功'); -// handleBatchReturnClose(); -// loadTableData(); -// loadStats(); -// } else { -// ElMessage.error(res.msg || '批量退回失败'); -// } -// } catch (err) { -// ElMessage.error('批量退回失败'); -// console.error(err); -// } finally { -// batchLoading.value = false; -// } -// } + batchLoading.value = true; + try { + const cardNos = selectedRows.value.map(row => row.cardNo); + const res = await batchReturnCards({ + cardNos, + returnReason: batchReturnForm.returnReason, + status: '5' + }); + + if (res.code === 200) { + ElMessage.success('批量退回成功'); + handleBatchReturnClose(); + loadTableData(); + loadStats(); + } else { + ElMessage.error(res.msg || '批量退回失败'); + } + } catch (err) { + ElMessage.error('批量退回失败'); + console.error(err); + } finally { + batchLoading.value = false; + } +} // 导出 -function handleExport() { - ElMessage.info('导出功能暂未实现'); +async function handleExport() { + try { + // 构建查询参数 + const params = { + cardNo: filterForm.cardNo, + patientName: filterForm.patientName, + status: filterForm.status, + registrationSource: filterForm.source, + deptId: filterForm.deptId, + }; + + if (filterForm.dateRange && filterForm.dateRange.length === 2) { + params.startDate = filterForm.dateRange[0]; + params.endDate = filterForm.dateRange[1]; + } + + // 使用导出 API 发起请求,携带认证信息 + const res = await exportInfectiousCards(params); + + // 创建 Blob 对象 + const blob = new Blob([res], { type: 'text/csv;charset=utf-8' }); + + // 创建下载链接 + const url = window.URL.createObjectURL(blob); + const link = document.createElement('a'); + link.href = url; + link.download = '传染病报告卡_' + new Date().getTime() + '.csv'; + link.style.display = 'none'; + document.body.appendChild(link); + link.click(); + + // 释放资源 + document.body.removeChild(link); + window.URL.revokeObjectURL(url); + + ElMessage.success('导出成功'); + } catch (err) { + ElMessage.error('导出失败'); + console.error(err); + } } // 分页处理