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 dd2fa278..2afe78cd 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 @@ -178,9 +178,9 @@ public class PatientReportDto { @ApiModelProperty("量表类型") private String code; @ApiModelProperty("开始") - private Integer start; + private Double start; @ApiModelProperty("结束") - private Integer end; + private Double end; } @ApiModel("临床诊断统计请求") 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 077f7b88..23bdf02e 100644 --- a/ht/src/main/java/com/ccsens/ht/service/PatientReportService.java +++ b/ht/src/main/java/com/ccsens/ht/service/PatientReportService.java @@ -8,13 +8,12 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.ccsens.ht.bean.dto.PatientReportDto; import com.ccsens.ht.bean.dto.PatientReportSearchDto; +import com.ccsens.ht.bean.dto.QuestionDto; import com.ccsens.ht.bean.po.*; import com.ccsens.ht.bean.vo.PatientReportSearchVo; import com.ccsens.ht.bean.vo.PatientReportVo; -import com.ccsens.ht.persist.dao.HtDoctorDao; -import com.ccsens.ht.persist.dao.HtPatientReportDao; -import com.ccsens.ht.persist.dao.HtPositionDao; -import com.ccsens.ht.persist.dao.HtReportDao; +import com.ccsens.ht.bean.vo.QuestionVo; +import com.ccsens.ht.persist.dao.*; import com.ccsens.ht.persist.mapper.HtPatientFollowUpMapper; import com.ccsens.ht.persist.mapper.HtPatientMapper; import com.ccsens.ht.persist.mapper.HtPatientReportRecordMapper; @@ -66,6 +65,12 @@ public class PatientReportService implements IPatientReportService { private HtPatientFollowUpMapper htPatientFollowUpMapper; @Resource private HtReportDao htReportDao; + @Resource + private RedisUtil redisUtil; + @Resource + private HtQuestionDao htQuestionDao; + @Resource + private IQuestionService questionService; @Override public JsonResponse generatePatientReport(PatientReportDto.Generate generate, Long userId) { @@ -670,7 +675,7 @@ public class PatientReportService implements IPatientReportService { List analyses = htPatientReportDao.queryReportAnalyseScore(ids); - int total = 38; + int total = 124; List> rows = new ArrayList<>(); // 标题 表头 initAnalyseTitle(rows, total); @@ -680,6 +685,7 @@ public class PatientReportService implements IPatientReportService { PoiUtil.exportWB("报告单详情", rows, workbook); return workbook; } + // 填充数据 for (int i = 0; i < analyses.size(); i++) { @@ -699,6 +705,26 @@ public class PatientReportService implements IPatientReportService { return workbook; } + + private Long getQuestionId(String code, int sort) { + String key = "ht_question_" + code + "_" + sort; + Object value = redisUtil.get(key); + + if (value != null) { + return (Long) value; + } + HtQuestionExample questionExample = new HtQuestionExample(); + questionExample.createCriteria().andParentCodeEqualTo(code).andSortEqualTo(sort); + List htQuestions = htQuestionDao.selectByExample(questionExample); + if (CollectionUtil.isEmpty(htQuestions)) { + return null; + } + Long id = htQuestions.get(0).getId(); + redisUtil.set(key, id); + return id; + } + + /** * 填充导出分析 * @param row 表格 @@ -713,6 +739,7 @@ public class PatientReportService implements IPatientReportService { row.get(6).setValue(Constant.Ht.getCareer(analyse.getCareer())); row.get(7).setValue(analyse.getClinicalDiagnosis()); row.get(8).setValue(Constant.Ht.getPasi(analyse.getPasi())); + // MMSE分数 if (CollectionUtil.isNotEmpty(analyse.getMmseScores())) { analyse.getMmseScores().forEach(score->{ switch (score.getCode()) { @@ -750,7 +777,7 @@ public class PatientReportService implements IPatientReportService { } } } - + // 报告单一总成绩 if (CollectionUtil.isNotEmpty(analyse.getTotalScores())) { analyse.getTotalScores().forEach(totalScore -> { switch (totalScore.getEvaluationCode()) { @@ -763,6 +790,73 @@ public class PatientReportService implements IPatientReportService { } }); } + // 画钟 + // 画钟题目ID + Long hzId = getQuestionId("HZ", 3); + QuestionDto.QueryPatientCanvas hzQuery = new QuestionDto.QueryPatientCanvas(); + hzQuery.setPatientReportId(analyse.getId()); + hzQuery.setQuestionId(hzId); + List patientCanvas = questionService.getCanvas(hzQuery, null); + if (CollectionUtil.isNotEmpty(patientCanvas)) { + QuestionVo.Parameter parameters = patientCanvas.get(0).getParameters(); + // 完成总时间 + row.get(38).setValue(parameters.getTotalDuration() + "ms"); + row.get(39).setValue(parameters.getPaintTime() + "ms"); + row.get(40).setValue(parameters.getReflectOnTime() + "ms"); + row.get(44).setValue(String.valueOf(parameters.getLineParameterList().size())); + row.get(45).setValue(String.valueOf(parameters.getAveTimes())); + row.get(46).setValue(pxToMm(parameters.getAveLength()) + "mm"); + row.get(47).setValue(pxToMm(parameters.getLongLine()) + "mm"); + row.get(51).setValue(pxToMm(parameters.getLongSpeed()) + "mm/s"); + row.get(52).setValue(pxToSquare(parameters.getMinCircleAcreage().doubleValue()) + "mm²"); + row.get(53).setValue(pxToMm(parameters.getShowCentreCoordinate().getX()) + "mm"); + row.get(54).setValue(pxToMm(parameters.getShowCentreCoordinate().getY()) + "mm"); + } + + Long simpleId = getQuestionId("EasyOne", 4); + initSimple(row, analyse, simpleId, 55); + + Long simpleThreeId = getQuestionId("EasyTwo", 5); + initSimple(row, analyse, simpleThreeId, 78); + Long simpleTwentyId = getQuestionId("EasyThree", 6); + initSimple(row, analyse, simpleTwentyId, 101); + } + + public String pxToMm(double length) { + return new BigDecimal(144).multiply(new BigDecimal(length)).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP).toString(); + } + public String pxToSquare(double length) { + return new BigDecimal(144 * 144).multiply(new BigDecimal(length)).divide(new BigDecimal(100 * 100)).setScale(2, BigDecimal.ROUND_HALF_UP).toString(); + } + + private void initSimple(List row, PatientReportVo.Analyse analyse, Long simpleId, int startIndex) { + QuestionDto.QueryPatientCanvas simpleQuery = new QuestionDto.QueryPatientCanvas(); + simpleQuery.setPatientReportId(analyse.getId()); + simpleQuery.setQuestionId(simpleId); + List simpleCanvas = questionService.getCanvas(simpleQuery, null); + if (CollectionUtil.isNotEmpty(simpleCanvas)) { + QuestionVo.Parameter parameters = simpleCanvas.get(0).getParameters(); + // 完成总时间 + row.get(startIndex).setValue(parameters.getTotalDuration() + "ms"); + row.get(startIndex + 1).setValue(parameters.getPaintTime() + "ms"); + row.get(startIndex + 2).setValue(parameters.getReflectOnTime() + "ms"); + row.get(startIndex + 3).setValue(String.valueOf(parameters.getLineParameterList().size())); + row.get(startIndex + 4).setValue(parameters.getAveTimes() + "ms"); + row.get(startIndex + 5).setValue(pxToMm(parameters.getAveLength()) + "mm"); + row.get(startIndex + 6).setValue(pxToMm(parameters.getLongLine()) + "mm"); + row.get(startIndex + 8).setValue(pxToMm(parameters.getLongSpeed()) + "mm/s"); + row.get(startIndex + 9).setValue(pxToSquare(parameters.getMinRectangleAcreage()) + "mm²"); + row.get(startIndex + 10).setValue(pxToMm(parameters.getShowCentreCoordinate().getX()) + "mm"); + row.get(startIndex + 11).setValue(pxToMm(parameters.getShowCentreCoordinate().getY()) + "mm"); + row.get(startIndex + 12).setValue(pxToMm(parameters.getRight().getX()) + "mm"); + row.get(startIndex + 13).setValue(pxToMm(parameters.getRight().getY()) + "mm"); + row.get(startIndex + 15).setValue(String.valueOf(parameters.getLongNums())); + row.get(startIndex + 16).setValue(String.valueOf(parameters.getShortNums())); + row.get(startIndex + 17).setValue(parameters.getTransitionTime() + "ms"); + row.get(startIndex + 18).setValue(parameters.getFiveLongLinesTime() + "ms"); + row.get(startIndex + 19).setValue(parameters.getLongLineRate() + "%"); + + } } private void initAnalyseTitle(List> rows, int total) { @@ -790,9 +884,27 @@ public class PatientReportService implements IPatientReportService { oneTitleRow.add(new PoiUtil.PoiUtilCell("",1,1)); } oneTitleRow.add(new PoiUtil.PoiUtilCell("其他量表",4,1)); - for (int i = 0; i < 4; i++) { + for (int i = 0; i < 3; i++) { oneTitleRow.add(new PoiUtil.PoiUtilCell("",1,1)); } + oneTitleRow.add(new PoiUtil.PoiUtilCell("画钟",17,1)); + for (int i = 0; i < 16; i++) { + oneTitleRow.add(new PoiUtil.PoiUtilCell("",1,1)); + } + oneTitleRow.add(new PoiUtil.PoiUtilCell("简单图形测验",23,1)); + for (int i = 0; i < 22; i++) { + oneTitleRow.add(new PoiUtil.PoiUtilCell("",1,1)); + } + oneTitleRow.add(new PoiUtil.PoiUtilCell("3min回忆",23,1)); + for (int i = 0; i < 22; i++) { + oneTitleRow.add(new PoiUtil.PoiUtilCell("",1,1)); + } + oneTitleRow.add(new PoiUtil.PoiUtilCell("20min延迟回忆",23,1)); + for (int i = 0; i < 22; i++) { + oneTitleRow.add(new PoiUtil.PoiUtilCell("",1,1)); + } + + rows.add(oneTitleRow); List titleRow = new ArrayList<>(); @@ -844,9 +956,65 @@ public class PatientReportService implements IPatientReportService { titleRow.add(new PoiUtil.PoiUtilCell("HAMA总分")); titleRow.add(new PoiUtil.PoiUtilCell("HAMD总分")); titleRow.add(new PoiUtil.PoiUtilCell("NPI总分")); + + // 画钟 + //38 + titleRow.add(new PoiUtil.PoiUtilCell("完成总时间")); + titleRow.add(new PoiUtil.PoiUtilCell("落笔时间")); + titleRow.add(new PoiUtil.PoiUtilCell("思考时间")); + // 41-42 空字符 + titleRow.add(new PoiUtil.PoiUtilCell("钟面后延迟时间")); + titleRow.add(new PoiUtil.PoiUtilCell("第一指针延迟时间")); + titleRow.add(new PoiUtil.PoiUtilCell("第二指针延迟时间")); + + titleRow.add(new PoiUtil.PoiUtilCell("总笔画数")); + titleRow.add(new PoiUtil.PoiUtilCell("每分钟笔画数")); + titleRow.add(new PoiUtil.PoiUtilCell("平均长度")); + titleRow.add(new PoiUtil.PoiUtilCell("最长笔画长度")); + // 48 49 空字符串 + titleRow.add(new PoiUtil.PoiUtilCell("时针长度")); + titleRow.add(new PoiUtil.PoiUtilCell("分针长度")); + + titleRow.add(new PoiUtil.PoiUtilCell("平均速度")); + titleRow.add(new PoiUtil.PoiUtilCell("最长笔画速度")); + titleRow.add(new PoiUtil.PoiUtilCell("最小外接圆面积")); + titleRow.add(new PoiUtil.PoiUtilCell("图形中心水平位置")); + titleRow.add(new PoiUtil.PoiUtilCell("图形中心垂直位置")); + + // 简单图形测验 + // 55 + fillSimplePicture(titleRow); + fillSimplePicture(titleRow); + fillSimplePicture(titleRow); rows.add(titleRow); } + private void fillSimplePicture(List titleRow) { + titleRow.add(new PoiUtil.PoiUtilCell("完成总时间")); + titleRow.add(new PoiUtil.PoiUtilCell("落笔时间")); + titleRow.add(new PoiUtil.PoiUtilCell("思考时间")); + titleRow.add(new PoiUtil.PoiUtilCell("总笔画数")); + titleRow.add(new PoiUtil.PoiUtilCell("每分钟笔画数")); + titleRow.add(new PoiUtil.PoiUtilCell("平均长度")); + titleRow.add(new PoiUtil.PoiUtilCell("最长笔画长度")); + titleRow.add(new PoiUtil.PoiUtilCell("平均速度")); + titleRow.add(new PoiUtil.PoiUtilCell("最长笔画速度")); + titleRow.add(new PoiUtil.PoiUtilCell("最小外接长方形面积")); + titleRow.add(new PoiUtil.PoiUtilCell("图形中心水平位置")); + titleRow.add(new PoiUtil.PoiUtilCell("图形中心垂直位置")); + titleRow.add(new PoiUtil.PoiUtilCell("图形顶边距离绘图区域中心的距离")); + titleRow.add(new PoiUtil.PoiUtilCell("图形底边距离绘图区域中心的距离")); + titleRow.add(new PoiUtil.PoiUtilCell("每条笔画的长度")); + titleRow.add(new PoiUtil.PoiUtilCell("长笔画数量")); + titleRow.add(new PoiUtil.PoiUtilCell("短笔画数量")); + titleRow.add(new PoiUtil.PoiUtilCell("所有短长笔画序列的过渡时间")); + titleRow.add(new PoiUtil.PoiUtilCell("5个早期长笔画的经过时间")); + titleRow.add(new PoiUtil.PoiUtilCell("前5笔长笔画率")); + titleRow.add(new PoiUtil.PoiUtilCell("相似系数")); + titleRow.add(new PoiUtil.PoiUtilCell("图形重心水平位置")); + titleRow.add(new PoiUtil.PoiUtilCell("图形重心垂直位置")); + } + private List getReportScores(PatientReportDto.ExportCode param, List content, List reportScores, PatientReportVo.ReprotPatient reportPatient) { long reportId = param.getId(); //重新封装报告单信息 diff --git a/ht/src/main/resources/application.yml b/ht/src/main/resources/application.yml index 5889ff7f..d082c0ea 100644 --- a/ht/src/main/resources/application.yml +++ b/ht/src/main/resources/application.yml @@ -1,4 +1,4 @@ spring: profiles: - active: test - include: common, util-test \ No newline at end of file + active: prod + include: common, util-prod \ No newline at end of file diff --git a/ht/src/main/resources/mapper_dao/HtPatientReportDao.xml b/ht/src/main/resources/mapper_dao/HtPatientReportDao.xml index ed13cc55..a07db687 100644 --- a/ht/src/main/resources/mapper_dao/HtPatientReportDao.xml +++ b/ht/src/main/resources/mapper_dao/HtPatientReportDao.xml @@ -143,9 +143,33 @@ order by create_time desc