diff --git a/ht/src/main/java/com/ccsens/ht/api/PatientReportExportController.java b/ht/src/main/java/com/ccsens/ht/api/PatientReportExportController.java index 13877f69..325425e1 100644 --- a/ht/src/main/java/com/ccsens/ht/api/PatientReportExportController.java +++ b/ht/src/main/java/com/ccsens/ht/api/PatientReportExportController.java @@ -120,4 +120,19 @@ public class PatientReportExportController { workbook.write(response.getOutputStream()); } + + @ApiOperation(value = "导出有指定题目分数的报告单分析",notes = "导出有指定题目分数的报告单分析") + @ApiImplicitParams({ + @ApiImplicitParam(name = "json", value = "指定题目", required = true) + }) + @RequestMapping(value="/exportAnalyseAll", method = RequestMethod.GET) + public void exportAnalyseAll(@RequestParam(value = "ids")@ApiParam @Valid PatientReportDto.Answer answer, HttpServletResponse response) throws IOException { + //查询报告单信息 + log.info("导出有指定题目分数的报告单分析:{}", answer); + Workbook workbook = patientReportService.exportAnalyseAll(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/vo/PatientReportVo.java b/ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java index f59b4a4b..f788933e 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 @@ -282,7 +282,7 @@ public class PatientReportVo { } public List toRow() { - int colNum = 8; + int colNum = 9; int headNum = 2; List rows = new ArrayList<>(); if (CollectionUtil.isEmpty(subReport)) { @@ -349,7 +349,8 @@ public class PatientReportVo { } public List toSingleRow() { - int colNum = Constant.Ht.Report.HAMD.equalsIgnoreCase(code) ? 9 : 8; + int colNum = Constant.Ht.Report.HAMD.equalsIgnoreCase(code) + || Constant.Ht.Report.MOCA.equalsIgnoreCase(code) ? 9 : 8; int headNum = 2; List rows = new ArrayList<>(); if (CollectionUtil.isEmpty(subReport)) { @@ -503,11 +504,18 @@ public class PatientReportVo { PdfUtil.Row row2 = new PdfUtil.Row(); // fillBlankCell(row2); //子测评项 - this.subReport.forEach(reportScore -> { + for (int i = 0; i < this.subReport.size(); i++) { + ReportScore reportScore = this.subReport.get(i); String score = (reportScore.score == null ? "" : reportScore.score) + (reportScore.getTotalScore() > 0 ? "/" + reportScore.getTotalScore() : ""); boolean isLast = npi.equalsIgnoreCase(this.code) && this.subReport.indexOf(reportScore) == this.subReport.size() - 1; - fillRow(row1,row2, reportScore.getName(), score, mmse.equalsIgnoreCase(this.code), isLast, npi.equalsIgnoreCase(this.code) ? new int[]{3,3} : null); - }); + boolean isMMSE = mmse.equalsIgnoreCase(this.code); + if (isMMSE) { + fillRow(row1,row2, reportScore.getName(), score, true, isLast, null); + } else { + fillRow(row1,row2, reportScore.getName(), score, false, isLast, i==0 ? new int[]{3,3} : new int[]{4,4}); + } + } + // 总分 if (mmse.equalsIgnoreCase(this.code)) { fillRow(row1,row2, "总分", (this.score == null ? "" : this.score) + (this.totalScore > 0 ? "/" + this.totalScore : ""), mmse.equalsIgnoreCase(this.code), true); @@ -528,7 +536,7 @@ public class PatientReportVo { //moca PdfUtil.Row row = new PdfUtil.Row(); PdfUtil.Cell purposeCell = new PdfUtil.Cell(Constant.Export.MOCA_PURPOSE); - purposeCell.setColSpan(8); + purposeCell.setColSpan(9); purposeCell.setCenter(false); purposeCell.setBorderRight(1); purposeCell.setHeight(36); @@ -553,7 +561,7 @@ public class PatientReportVo { fillRow(row1, row2, reportScore.getName(), " ", false, false, i == 0 ? new int[]{2,2}: null); } else { String score = (reportScore.score == null ? "" : reportScore.score) + (reportScore.getTotalScore() > 0 ? "/" + reportScore.getTotalScore() : ""); - fillRow(row1, row2, reportScore.getName(), score, false, false, i == 0 ? new int[]{2,2}: null); + fillRow(row1, row2, reportScore.getName(), score, false, false, i == 0 || i == firstIndex - 1 ? new int[]{2,2}: null); } } PdfUtil.Cell scoreNameCell = new PdfUtil.Cell(); @@ -600,7 +608,6 @@ public class PatientReportVo { scoreScoreCell.setRowSpan(2); scoreScoreCell.setColSpan(ychy.equalsIgnoreCase(reportScore.getCode()) ? 2 : 1); row4.addCell(scoreScoreCell); - } rows.add(row3); rows.add(row4); @@ -824,6 +831,14 @@ public class PatientReportVo { private String code; @ApiModelProperty("分数") private BigDecimal score; + + public MMSEScore() { + } + + public MMSEScore(String code, BigDecimal score) { + this.code = code; + this.score = score; + } } @ApiModel("moca分数-导出分析") diff --git a/ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientScoreDao.java b/ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientScoreDao.java index e24ff86f..5a7672ed 100644 --- a/ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientScoreDao.java +++ b/ht/src/main/java/com/ccsens/ht/persist/dao/HtPatientScoreDao.java @@ -1,5 +1,6 @@ package com.ccsens.ht.persist.dao; +import com.ccsens.ht.bean.dto.PatientReportDto; import com.ccsens.ht.bean.po.HtPatientScore; import com.ccsens.ht.persist.mapper.HtPatientScoreMapper; @@ -18,4 +19,11 @@ public interface HtPatientScoreDao extends HtPatientScoreMapper { *@date: 2019/11/14 9:29 */ void insertBatch(List scores); + + /** + * 查询有指定题目分数的报告单ID + * @param answer 指定题目 + * @return + */ + List queryIdsByAnswer(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 32ff00e3..2c08f244 100644 --- a/ht/src/main/java/com/ccsens/ht/service/IPatientReportService.java +++ b/ht/src/main/java/com/ccsens/ht/service/IPatientReportService.java @@ -187,4 +187,11 @@ public interface IPatientReportService { * @return 表格 */ Workbook exportAnswer(PatientReportDto.Answer answer); + + /** + * 查询有指定题目的分数的报告单,导出试题分析 + * @param answer 题目 + * @return 表格 + */ + Workbook exportAnalyseAll(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 7982c4cc..b36853ad 100644 --- a/ht/src/main/java/com/ccsens/ht/service/PatientReportService.java +++ b/ht/src/main/java/com/ccsens/ht/service/PatientReportService.java @@ -76,6 +76,8 @@ public class PatientReportService implements IPatientReportService { private HtReportRelevanceMapper reportRelevanceMapper; @Resource private IExportService exportService; + @Resource + private HtPatientScoreDao htPatientScoreDao; @Override public JsonResponse generatePatientReport(PatientReportDto.Generate generate, Long userId) { @@ -404,12 +406,12 @@ public class PatientReportService implements IPatientReportService { PdfUtil.Row row = new PdfUtil.Row(); PdfUtil.Cell initWordCell = addCell(row, "初步印象", 2, 2); initWordCell.setHeight(PdfUtil.Cell.defaultHeight * 2); - PdfUtil.Cell initImplCell = addCell(row, detail.getPatient().getInitialImpression(), 6, 2); + PdfUtil.Cell initImplCell = addCell(row, detail.getPatient().getInitialImpression(), 9, 2); initImplCell.setHeight(PdfUtil.Cell.defaultHeight * 2); initImplCell.setBorderRight(1); initImplCell.setCenter(false); content.add(row); - initLast(content, 8); + initLast(content, 9); String[] split = detail.getPatient().getHospital().split(""); String title = String.join(" ", split); @@ -710,7 +712,8 @@ public class PatientReportService implements IPatientReportService { public Workbook exportAnalyse(List ids) { List analyses = htPatientReportDao.queryReportAnalyseScore(ids); - + // 处理MMSE的时间定向力和地点定向力 + dealMMSEScored(analyses); int total = 124; List> rows = new ArrayList<>(); @@ -742,6 +745,26 @@ public class PatientReportService implements IPatientReportService { return workbook; } + private void dealMMSEScored(List analyses) { + analyses.forEach(analyse -> { + List mmseScores = analyse.getMmseScores(); + if (CollectionUtil.isNotEmpty(mmseScores)) { + BigDecimal mmseDxl = null; + for (PatientReportVo.MMSEScore score: mmseScores) { + if (Constant.Ht.Report.MMSE_SJDXL.equals(score.getCode()) + && score.getScore() != null) { + mmseDxl = score.getScore().add(new BigDecimal((mmseDxl == null ? 0 : mmseDxl.intValue()))); + } + if (Constant.Ht.Report.MMSE_DDDXL.equals(score.getCode()) + && score.getScore() != null) { + mmseDxl = score.getScore().add(new BigDecimal((mmseDxl == null ? 0 : mmseDxl.intValue()))); + } + } + mmseScores.add(new PatientReportVo.MMSEScore(Constant.Ht.Report.MMSE_DXL, mmseDxl)); + } + }); + } + private Long getQuestionId(String code, int sort) { String key = "ht_question_" + code + "_" + sort; @@ -807,10 +830,16 @@ public class PatientReportService implements IPatientReportService { row.get(26).setValue(String.valueOf(s + score.getScore().intValue())); } else if (score.getSort() >= 15 && score.getSort() <= 17) { row.get(12+score.getSort()).setValue(score.getScore().intValue() + ""); - } else if (score.getSort()== 20 || score.getSort() == 21) { + } else if (score.getSort()== 21 || score.getSort() == 22) { row.get(10+score.getSort()).setValue(score.getScore().intValue() + ""); - } else if (score.getSort() == 18) { - row.get(32).setValue(score.getScore().intValue() + ""); + } else if (score.getSort() == 18 || score.getSort() == 19) { + if (score.getScore() != null) { + String value = row.get(32).getValue(); + int dxlScore = StrUtil.isEmpty(value) ? 0 : Integer.parseInt(value); + row.get(32).setValue(dxlScore + score.getScore().intValue() + ""); + } + + } } } @@ -1062,7 +1091,8 @@ public class PatientReportService implements IPatientReportService { List scores = getReportScores(reportScores, reportId); // 分数汇总 - int colNum = Constant.Ht.Report.HAMD.equalsIgnoreCase(param.getCode()) ? 9 : 8; + int colNum = Constant.Ht.Report.HAMD.equalsIgnoreCase(param.getCode()) + || Constant.Ht.Report.MOCA.equals(param.getCode()) ? 9 : 8; scores.forEach(reportScore -> content.addAll(reportScore.toSingleRow())); PdfUtil.Row row = new PdfUtil.Row(); @@ -1161,6 +1191,14 @@ public class PatientReportService implements IPatientReportService { return workbook; } + @Override + public Workbook exportAnalyseAll(PatientReportDto.Answer answer) { + log.info("导出全部分析:{}", answer); + List reportIds = htPatientScoreDao.queryIdsByAnswer(answer); + log.info("报告单数量:{}", reportIds.size()); + return exportAnalyse(reportIds); + } + 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/java/com/ccsens/ht/uitl/Constant.java b/ht/src/main/java/com/ccsens/ht/uitl/Constant.java index 065bb495..4d5ca2cd 100644 --- a/ht/src/main/java/com/ccsens/ht/uitl/Constant.java +++ b/ht/src/main/java/com/ccsens/ht/uitl/Constant.java @@ -341,6 +341,13 @@ public class Constant { public final static String NPI = "NPI"; public final static String REY = "Rey"; public final static String XFXPD = "XFXPD"; + public final static String MMSE_SJDXL = "SJDXL"; + public final static String MMSE_DDDXL = "DDDXL"; + public final static String MMSE_DXL = "DXL"; + public final static String MOCA_SJDXL = "SJDX"; + public final static String MOCA_DDDXL = "DDDX"; + public final static String MOCA_DXL = "DX"; + /**报告单未完成*/ public final static Byte COMPLETE_NO = 0; /**报告单已完成*/ diff --git a/ht/src/main/resources/application.yml b/ht/src/main/resources/application.yml index 4ecd13fd..f59084b0 100644 --- a/ht/src/main/resources/application.yml +++ b/ht/src/main/resources/application.yml @@ -1,5 +1,5 @@ spring: profiles: - active: dev - include: common, util-dev + active: test + include: common, util-test diff --git a/ht/src/main/resources/druid-dev.yml b/ht/src/main/resources/druid-dev.yml index b3326f7f..d18113f6 100644 --- a/ht/src/main/resources/druid-dev.yml +++ b/ht/src/main/resources/druid-dev.yml @@ -27,8 +27,8 @@ spring: testOnReturn: false testWhileIdle: true timeBetweenEvictionRunsMillis: 60000 -# url: jdbc:mysql://49.233.89.188:3306/ht?useUnicode=true&characterEncoding=UTF-8 - url: jdbc:mysql://81.70.54.64:3306/ht?useUnicode=true&characterEncoding=UTF-8 + url: jdbc:mysql://49.233.89.188:3306/ht?useUnicode=true&characterEncoding=UTF-8 +# url: jdbc:mysql://81.70.54.64:3306/ht?useUnicode=true&characterEncoding=UTF-8 username: root validationQuery: SELECT 1 FROM DUAL env: CCSENS_HT \ No newline at end of file diff --git a/ht/src/main/resources/mapper_dao/HtPatientScoreDao.xml b/ht/src/main/resources/mapper_dao/HtPatientScoreDao.xml index 85c5c1be..61bc89e9 100644 --- a/ht/src/main/resources/mapper_dao/HtPatientScoreDao.xml +++ b/ht/src/main/resources/mapper_dao/HtPatientScoreDao.xml @@ -31,5 +31,27 @@ #{score.answer,jdbcType=VARCHAR}, #{score.remark,jdbcType=VARCHAR}, now()) + \ No newline at end of file