Browse Source

报告单分析导出

sd
zhizhi wu 4 years ago
parent
commit
223b39cef7
  1. 4
      ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java
  2. 182
      ht/src/main/java/com/ccsens/ht/service/PatientReportService.java
  3. 4
      ht/src/main/resources/application.yml
  4. 74
      ht/src/main/resources/mapper_dao/HtPatientReportDao.xml

4
ht/src/main/java/com/ccsens/ht/bean/dto/PatientReportDto.java

@ -178,9 +178,9 @@ public class PatientReportDto {
@ApiModelProperty("量表类型") @ApiModelProperty("量表类型")
private String code; private String code;
@ApiModelProperty("开始") @ApiModelProperty("开始")
private Integer start; private Double start;
@ApiModelProperty("结束") @ApiModelProperty("结束")
private Integer end; private Double end;
} }
@ApiModel("临床诊断统计请求") @ApiModel("临床诊断统计请求")

182
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 cn.hutool.core.util.StrUtil;
import com.ccsens.ht.bean.dto.PatientReportDto; import com.ccsens.ht.bean.dto.PatientReportDto;
import com.ccsens.ht.bean.dto.PatientReportSearchDto; 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.po.*;
import com.ccsens.ht.bean.vo.PatientReportSearchVo; import com.ccsens.ht.bean.vo.PatientReportSearchVo;
import com.ccsens.ht.bean.vo.PatientReportVo; import com.ccsens.ht.bean.vo.PatientReportVo;
import com.ccsens.ht.persist.dao.HtDoctorDao; import com.ccsens.ht.bean.vo.QuestionVo;
import com.ccsens.ht.persist.dao.HtPatientReportDao; import com.ccsens.ht.persist.dao.*;
import com.ccsens.ht.persist.dao.HtPositionDao;
import com.ccsens.ht.persist.dao.HtReportDao;
import com.ccsens.ht.persist.mapper.HtPatientFollowUpMapper; import com.ccsens.ht.persist.mapper.HtPatientFollowUpMapper;
import com.ccsens.ht.persist.mapper.HtPatientMapper; import com.ccsens.ht.persist.mapper.HtPatientMapper;
import com.ccsens.ht.persist.mapper.HtPatientReportRecordMapper; import com.ccsens.ht.persist.mapper.HtPatientReportRecordMapper;
@ -66,6 +65,12 @@ public class PatientReportService implements IPatientReportService {
private HtPatientFollowUpMapper htPatientFollowUpMapper; private HtPatientFollowUpMapper htPatientFollowUpMapper;
@Resource @Resource
private HtReportDao htReportDao; private HtReportDao htReportDao;
@Resource
private RedisUtil redisUtil;
@Resource
private HtQuestionDao htQuestionDao;
@Resource
private IQuestionService questionService;
@Override @Override
public JsonResponse<PatientReportVo.Generate> generatePatientReport(PatientReportDto.Generate generate, Long userId) { public JsonResponse<PatientReportVo.Generate> generatePatientReport(PatientReportDto.Generate generate, Long userId) {
@ -670,7 +675,7 @@ public class PatientReportService implements IPatientReportService {
List<PatientReportVo.Analyse> analyses = htPatientReportDao.queryReportAnalyseScore(ids); List<PatientReportVo.Analyse> analyses = htPatientReportDao.queryReportAnalyseScore(ids);
int total = 38; int total = 124;
List<List< PoiUtil.PoiUtilCell >> rows = new ArrayList<>(); List<List< PoiUtil.PoiUtilCell >> rows = new ArrayList<>();
// 标题 表头 // 标题 表头
initAnalyseTitle(rows, total); initAnalyseTitle(rows, total);
@ -680,6 +685,7 @@ public class PatientReportService implements IPatientReportService {
PoiUtil.exportWB("报告单详情", rows, workbook); PoiUtil.exportWB("报告单详情", rows, workbook);
return workbook; return workbook;
} }
// 填充数据 // 填充数据
for (int i = 0; i < analyses.size(); i++) { for (int i = 0; i < analyses.size(); i++) {
@ -699,6 +705,26 @@ public class PatientReportService implements IPatientReportService {
return workbook; 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<HtQuestion> htQuestions = htQuestionDao.selectByExample(questionExample);
if (CollectionUtil.isEmpty(htQuestions)) {
return null;
}
Long id = htQuestions.get(0).getId();
redisUtil.set(key, id);
return id;
}
/** /**
* 填充导出分析 * 填充导出分析
* @param row 表格 * @param row 表格
@ -713,6 +739,7 @@ public class PatientReportService implements IPatientReportService {
row.get(6).setValue(Constant.Ht.getCareer(analyse.getCareer())); row.get(6).setValue(Constant.Ht.getCareer(analyse.getCareer()));
row.get(7).setValue(analyse.getClinicalDiagnosis()); row.get(7).setValue(analyse.getClinicalDiagnosis());
row.get(8).setValue(Constant.Ht.getPasi(analyse.getPasi())); row.get(8).setValue(Constant.Ht.getPasi(analyse.getPasi()));
// MMSE分数
if (CollectionUtil.isNotEmpty(analyse.getMmseScores())) { if (CollectionUtil.isNotEmpty(analyse.getMmseScores())) {
analyse.getMmseScores().forEach(score->{ analyse.getMmseScores().forEach(score->{
switch (score.getCode()) { switch (score.getCode()) {
@ -750,7 +777,7 @@ public class PatientReportService implements IPatientReportService {
} }
} }
} }
// 报告单一总成绩
if (CollectionUtil.isNotEmpty(analyse.getTotalScores())) { if (CollectionUtil.isNotEmpty(analyse.getTotalScores())) {
analyse.getTotalScores().forEach(totalScore -> { analyse.getTotalScores().forEach(totalScore -> {
switch (totalScore.getEvaluationCode()) { 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<QuestionVo.PatientCanvas> 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<PoiUtil.PoiUtilCell> row, PatientReportVo.Analyse analyse, Long simpleId, int startIndex) {
QuestionDto.QueryPatientCanvas simpleQuery = new QuestionDto.QueryPatientCanvas();
simpleQuery.setPatientReportId(analyse.getId());
simpleQuery.setQuestionId(simpleId);
List<QuestionVo.PatientCanvas> 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<List<PoiUtil.PoiUtilCell>> rows, int total) { private void initAnalyseTitle(List<List<PoiUtil.PoiUtilCell>> rows, int total) {
@ -790,9 +884,27 @@ public class PatientReportService implements IPatientReportService {
oneTitleRow.add(new PoiUtil.PoiUtilCell("",1,1)); oneTitleRow.add(new PoiUtil.PoiUtilCell("",1,1));
} }
oneTitleRow.add(new PoiUtil.PoiUtilCell("其他量表",4,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("",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); rows.add(oneTitleRow);
List<PoiUtil.PoiUtilCell> titleRow = new ArrayList<>(); List<PoiUtil.PoiUtilCell> titleRow = new ArrayList<>();
@ -844,9 +956,65 @@ public class PatientReportService implements IPatientReportService {
titleRow.add(new PoiUtil.PoiUtilCell("HAMA总分")); titleRow.add(new PoiUtil.PoiUtilCell("HAMA总分"));
titleRow.add(new PoiUtil.PoiUtilCell("HAMD总分")); titleRow.add(new PoiUtil.PoiUtilCell("HAMD总分"));
titleRow.add(new PoiUtil.PoiUtilCell("NPI总分")); 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); rows.add(titleRow);
} }
private void fillSimplePicture(List<PoiUtil.PoiUtilCell> 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<PatientReportVo.ReportScore> getReportScores(PatientReportDto.ExportCode param, List<PdfUtil.Row> content, List<PatientReportVo.ReportScore> reportScores, PatientReportVo.ReprotPatient reportPatient) { private List<PatientReportVo.ReportScore> getReportScores(PatientReportDto.ExportCode param, List<PdfUtil.Row> content, List<PatientReportVo.ReportScore> reportScores, PatientReportVo.ReprotPatient reportPatient) {
long reportId = param.getId(); long reportId = param.getId();
//重新封装报告单信息 //重新封装报告单信息

4
ht/src/main/resources/application.yml

@ -1,4 +1,4 @@
spring: spring:
profiles: profiles:
active: test active: prod
include: common, util-test include: common, util-prod

74
ht/src/main/resources/mapper_dao/HtPatientReportDao.xml

@ -143,9 +143,33 @@
order by create_time desc order by create_time desc
</select> </select>
<select id="queryAllReports" resultType="com.ccsens.ht.bean.vo.PatientReportVo$ReportName"> <select id="queryAllReports" resultType="com.ccsens.ht.bean.vo.PatientReportVo$ReportName">
select r.id, r.name, r.url, r.doctor_id as doctorId, 1 as authority select t.* from
(select r.id, r.name, r.url, r.doctor_id as doctorId, 1 as authority, r.create_time
<if test="scores != null and scores.size() > 0">
,
SUM(CASE report.code WHEN 'moca' THEN s.score ELSE 0 END) as 'moca',
SUM(CASE report.code WHEN 'mmse' THEN s.score ELSE 0 END) as 'mmse',
SUM(CASE report.code WHEN 'rey' THEN s.score ELSE 0 END) as 'rey',
SUM(CASE report.code WHEN 'hama' THEN s.score ELSE 0 END) as 'hama',
SUM(CASE report.code WHEN 'hamd' THEN s.score ELSE 0 END) as 'hamd',
SUM(CASE report.code WHEN 'adl' THEN s.score ELSE 0 END) as 'adl',
SUM(CASE report.code WHEN 'npi' THEN s.score ELSE 0 END) as 'npi'
</if>
from t_ht_patient_report r, t_ht_patient p from t_ht_patient_report r, t_ht_patient p
<if test="scores != null and scores.size() > 0">
,
t_ht_report report,
t_ht_question q,
t_ht_patient_score s
</if>
where r.patient_id = p.id where r.patient_id = p.id
<if test="scores != null and scores.size() > 0">
AND r.id = s.patient_report_id
AND report.CODE = q.evaluation_code
AND q.id = s.question_id
AND report.type = 2
AND s.type IN ( 0, 2 )
</if>
<if test="patientSex != null"> <if test="patientSex != null">
and p.sex = #{patientSex} and p.sex = #{patientSex}
</if> </if>
@ -176,39 +200,23 @@
<if test="endTime != null"> <if test="endTime != null">
and r.report_time &lt;= #{endTime} and r.report_time &lt;= #{endTime}
</if> </if>
<if test="scores != null and scores.size() > 0">
and r.id in (
SELECT DISTINCT
s.patient_report_id
FROM
t_ht_report r,
t_ht_question q,
t_ht_patient_score s
WHERE
r.CODE = q.evaluation_code
AND q.id = s.question_id
AND r.type = 2
AND s.type IN ( 0, 2 )
GROUP BY
s.patient_report_id,
r.CODE
HAVING
<foreach collection="scores" item="score" separator="and" open="(" close=")">
( r.CODE = #{score.code}
<if test="score.start != null">
AND sum( s.score ) &gt;= #{score.start}
</if>
<if test="score.end != null">
AND sum( s.score ) &lt;= #{score.end}
</if>
)
</foreach>
)
</if>
and r.show_status = 1 and r.show_status = 1
AND r.complete_status = 1 AND r.complete_status = 1
and r.is_del = 0 and r.is_del = 0
order by r.create_time desc group by r.id
) t
where 1=1
<if test="scores != null and scores.size() > 0">
<foreach collection="scores" item="score">
<if test="score.start != null">
AND ${score.code} &gt;= #{score.start}
</if>
<if test="score.end != null">
AND ${score.code} &lt;= #{score.end}
</if>
</foreach>
</if>
order by create_time desc
</select> </select>
<select id="countByClinicalDiagnosis" resultType="com.ccsens.ht.bean.vo.PatientReportVo$ClinicalDiagnosis"> <select id="countByClinicalDiagnosis" resultType="com.ccsens.ht.bean.vo.PatientReportVo$ClinicalDiagnosis">
select clinical_diagnosis as diagnosis, count(*) as count from t_ht_patient_report select clinical_diagnosis as diagnosis, count(*) as count from t_ht_patient_report
@ -407,6 +415,7 @@
<foreach collection="ids" item="id" open="(" close=")" separator=","> <foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>
and s.type in (0, 2)
group by s.patient_report_id, t.code) mmse group by s.patient_report_id, t.code) mmse
on report.id = mmse.mmseReportId on report.id = mmse.mmseReportId
left join left join
@ -417,7 +426,8 @@
<foreach collection="ids" item="id" open="(" close=")" separator=","> <foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>
and s.is_del = 0 ) moca and s.type in (0, 2)
and s.is_del = 0 ) moca
on report.id = moca.mocaReportId on report.id = moca.mocaReportId
left join left join
-- 总成绩 -- 总成绩

Loading…
Cancel
Save