diff --git a/ht/src/main/java/com/ccsens/ht/api/PatientReportController.java b/ht/src/main/java/com/ccsens/ht/api/PatientReportController.java index fb8e6253..5e01a450 100644 --- a/ht/src/main/java/com/ccsens/ht/api/PatientReportController.java +++ b/ht/src/main/java/com/ccsens/ht/api/PatientReportController.java @@ -1,6 +1,7 @@ package com.ccsens.ht.api; +import cn.hutool.core.util.CharsetUtil; import com.ccsens.ht.annotation.DoctorAudit; import com.ccsens.cloudutil.annotation.MustLogin; import com.ccsens.ht.bean.dto.PatientReportDto; @@ -14,14 +15,14 @@ import com.ccsens.util.JsonResponse; import com.github.pagehelper.PageInfo; import io.swagger.annotations.*; import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; +import org.apache.poi.ss.usermodel.Workbook; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.io.IOException; +import java.net.URLEncoder; import java.util.List; /** @@ -252,4 +253,18 @@ public class PatientReportController { } + @ApiOperation(value = "导出指定题型的分数和答案",notes = "导出指定题型的分数和答案") + @ApiImplicitParams({ + }) + @RequestMapping(value="/exportAnswer", method = RequestMethod.GET) + public void exportAnswer(@ApiParam PatientReportDto.Answer answer, HttpServletResponse response) throws Exception { + //查询报告单信息 + log.info("导出指定题型的分数和答案:{}", answer); + Workbook workbook = patientReportService.exportAnswer(answer); + log.info("导出指定题型的分数和答案结束"); + String fileName = "答案记录.xlsx"; + response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, CharsetUtil.UTF_8)); + workbook.write(response.getOutputStream()); + } + } diff --git a/ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java b/ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java index 87096b46..58edd35d 100644 --- a/ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java +++ b/ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java @@ -232,4 +232,16 @@ public class PatientReportDto { @ApiModelProperty("题目id") private Long questionId; } + + @ApiModel("分数导出") + @Data + public static class Answer { + @NotBlank(message = "题目类型不能为空") + @ApiModelProperty("题目类型 MMSE") + private String questionCode; + + @NotBlank(message = "请指定第几题") + @ApiModelProperty("排序") + private int sort; + } } diff --git a/ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java b/ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java index 15633ee7..f59b4a4b 100644 --- a/ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java +++ b/ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java @@ -844,4 +844,19 @@ public class PatientReportVo { private BigDecimal totalScore; } + @ApiModel("分数和答案") + @Data + public static class AnswerAndScore{ + @ApiModelProperty("报告单ID") + private Long patientReportId; + @ApiModelProperty("患者ID") + private Long patientId; + @ApiModelProperty("分数") + private String score; + @ApiModelProperty("答案") + private String recordValue; + @ApiModelProperty("诊断结果") + private String clinicalDiagnosis; + } + } diff --git a/ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientReportDao.java b/ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientReportDao.java index 48eaa3e0..f7b6bbdb 100644 --- a/ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientReportDao.java +++ b/ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientReportDao.java @@ -130,5 +130,10 @@ public interface HtPatientReportDao extends HtPatientReportMapper { */ List queryReportAnalyseScore(@Param("ids") List ids); - + /** + * 查询指定答案和分数 + * @param answer 请求参数 + * @return 分数、记录、临床诊断 + */ + List queryAnswer(@Param("param") PatientReportDto.Answer answer); } diff --git a/ht/src/main/java/com/ccsens/ht/service/IPatientReportService.java b/ht/src/main/java/com/ccsens/ht/service/IPatientReportService.java index df3f66b4..32ff00e3 100644 --- a/ht/src/main/java/com/ccsens/ht/service/IPatientReportService.java +++ b/ht/src/main/java/com/ccsens/ht/service/IPatientReportService.java @@ -180,4 +180,11 @@ public interface IPatientReportService { * @return */ List getReportScores(List reportScores, long reportId); + + /*** + * 导出指定题目的所有答案 + * @param answer param + * @return 表格 + */ + Workbook exportAnswer(PatientReportDto.Answer answer); } diff --git a/ht/src/main/java/com/ccsens/ht/service/PatientReportService.java b/ht/src/main/java/com/ccsens/ht/service/PatientReportService.java index 59619252..3af596ff 100644 --- a/ht/src/main/java/com/ccsens/ht/service/PatientReportService.java +++ b/ht/src/main/java/com/ccsens/ht/service/PatientReportService.java @@ -1117,6 +1117,50 @@ public class PatientReportService implements IPatientReportService { return scores; } + @Override + public Workbook exportAnswer(PatientReportDto.Answer answer) { + + List scores = htPatientReportDao.queryAnswer(answer); + + List> allRows = new ArrayList<>(); + // 标题 表头 + List headRow = new ArrayList<>(); + headRow.add(new PoiUtil.PoiUtilCell("报告单ID")); + headRow.add(new PoiUtil.PoiUtilCell("患者ID")); + headRow.add(new PoiUtil.PoiUtilCell("临床诊断")); + headRow.add(new PoiUtil.PoiUtilCell("分数")); + headRow.add(new PoiUtil.PoiUtilCell("记录")); + allRows.add(headRow); + + + String sheetName = "分数和答案"; + if (CollectionUtil.isEmpty(scores)) { + Workbook workbook = new XSSFWorkbook(); + PoiUtil.exportWB(sheetName, allRows, workbook); + return workbook; + } + + // 填充数据 + + for (PatientReportVo.AnswerAndScore score: scores) { + + List dataRow = new ArrayList<>(); + + dataRow.add(new PoiUtil.PoiUtilCell(score.getPatientReportId() + "",1,1)); + dataRow.add(new PoiUtil.PoiUtilCell(score.getPatientId() + "",1,1)); + dataRow.add(new PoiUtil.PoiUtilCell(score.getClinicalDiagnosis(),1,1)); + dataRow.add(new PoiUtil.PoiUtilCell(score.getScore(),1,1)); + dataRow.add(new PoiUtil.PoiUtilCell(score.getRecordValue(),1,1)); + allRows.add(dataRow); + } + + + + Workbook workbook = new XSSFWorkbook(); + PoiUtil.exportWB(sheetName, allRows, workbook); + return workbook; + } + private void initQuestionBody(int questionSpan, PatientReportVo.QuestionAndAnswer question, PdfUtil.Row row, boolean isLast, int optionSize) { addCell(row, question == null ? Constant.Ht.STRING_DEFAULT : String.valueOf(question.getSort()), 1, 1); addCell(row, question == null ? Constant.Ht.STRING_DEFAULT : question.getQuestion(), questionSpan, 1); diff --git a/ht/src/main/resources/logback-spring.xml b/ht/src/main/resources/logback-spring.xml index 95019edc..bf991b03 100644 --- a/ht/src/main/resources/logback-spring.xml +++ b/ht/src/main/resources/logback-spring.xml @@ -80,7 +80,7 @@ 100MB - 15 + diff --git a/ht/src/main/resources/mapper_dao/HtPatientReportDao.xml b/ht/src/main/resources/mapper_dao/HtPatientReportDao.xml index 6a0a210c..e12dc794 100644 --- a/ht/src/main/resources/mapper_dao/HtPatientReportDao.xml +++ b/ht/src/main/resources/mapper_dao/HtPatientReportDao.xml @@ -443,6 +443,33 @@ group by q.evaluation_code, s.patient_report_id) score on report.id = score.scoreReportId + \ No newline at end of file