|
|
|
@ -150,10 +150,33 @@ public class RmsServiceImpl implements IRmsService { |
|
|
|
//查询报告单分数
|
|
|
|
List<RmsVo.ReportScore> reportScore = rmsDao.queryReportScore1(dto.getEvaluationId(), null, dto.getSex()); |
|
|
|
//重新封装报告单信息
|
|
|
|
scores = getReportScores(reportScore, dto.getEvaluationId(), report.getId()); |
|
|
|
scores = getReportScores(reportScore, dto.getEvaluationId()); |
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(scores)) { |
|
|
|
scores.forEach(score -> { |
|
|
|
//添加体质辨识结论
|
|
|
|
List<TzbsRmsReportResult> reportResultList = score.getReportResultList(); |
|
|
|
if (CollUtil.isNotEmpty(reportResultList)) { |
|
|
|
reportResultList.forEach(reportResult -> { |
|
|
|
reportResult.setReportId(report.getId()); |
|
|
|
}); |
|
|
|
clientEvaDao.batchInsertReportResult(reportResultList); |
|
|
|
} |
|
|
|
|
|
|
|
//添加体质辨识养生建议
|
|
|
|
List<TzbsRmsReportYsjy> reportYsjyList = score.getReportYsjyList(); |
|
|
|
if (CollUtil.isNotEmpty(reportYsjyList)) { |
|
|
|
reportYsjyList.forEach(reportResult -> { |
|
|
|
reportResult.setReportId(report.getId()); |
|
|
|
rmsReportYsjyMapper.insertSelective(reportResult); |
|
|
|
}); |
|
|
|
} |
|
|
|
//获取初步印象
|
|
|
|
ClientEvaVo.ReportView reportView = reportView(dto.getEvaluationId(), score.getCode()); |
|
|
|
if (reportView != null) { |
|
|
|
score.setImpression(reportView.getResult()); |
|
|
|
score.setScore(reportView.getTotalScore()); |
|
|
|
} |
|
|
|
//添加量表分数统计
|
|
|
|
RmsReportScaleScore reportScaleScore = new RmsReportScaleScore(); |
|
|
|
reportScaleScore.setId(IDGenerator.nextSnowflakeId()); |
|
|
|
@ -162,9 +185,7 @@ public class RmsServiceImpl implements IRmsService { |
|
|
|
reportScaleScore.setImpression(score.getImpression()); |
|
|
|
reportScaleScore.setScore(score.getScore()); |
|
|
|
rmsReportScaleScoreMapper.insertSelective(reportScaleScore); |
|
|
|
|
|
|
|
reportScaleScoreMap.put(score.getCode(), reportScaleScore); |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} else { |
|
|
|
@ -194,6 +215,7 @@ public class RmsServiceImpl implements IRmsService { |
|
|
|
List<RmsReportScaleScore> rmsReportScaleScores = rmsReportScaleScoreMapper.selectByExample(scoreExample); |
|
|
|
if (CollUtil.isNotEmpty(rmsReportScaleScores)) { |
|
|
|
score.setImpression(rmsReportScaleScores.get(0).getImpression()); |
|
|
|
score.setScore(rmsReportScaleScores.get(0).getScore()); |
|
|
|
reportScaleScoreMap.put(score.getCode(), rmsReportScaleScores.get(0)); |
|
|
|
} |
|
|
|
|
|
|
|
@ -332,54 +354,54 @@ public class RmsServiceImpl implements IRmsService { |
|
|
|
return vo; |
|
|
|
} |
|
|
|
|
|
|
|
private void zytzbs(Long evaluationId, Long reportId, RmsVo.ReportScore score) { |
|
|
|
if ("TZBS_LN".equals(score.getCode()) || "TZBS_BZ".equals(score.getCode())) { |
|
|
|
//3.2 生成报告单辨识结果
|
|
|
|
List<ReportVo.EvaResult> resultList = countReportResult(evaluationId, reportId); |
|
|
|
List<TzbsRmsReportResult> reportResultList = CollectionUtil.newArrayList(); |
|
|
|
for (ReportVo.EvaResult resultVo : resultList) { |
|
|
|
//转换为RmsReportResult对象
|
|
|
|
TzbsRmsReportResult reportResult = new TzbsRmsReportResult(); |
|
|
|
reportResult.setResultId(IDGenerator.nextSnowflakeId()); |
|
|
|
reportResult.setScaleCode(score.getCode()); |
|
|
|
reportResult.setReportId(reportId); |
|
|
|
reportResult.setConstiCode(resultVo.getConstiCode()); |
|
|
|
reportResult.setConstiName(resultVo.getConstiName()); |
|
|
|
reportResult.setConstiLevel(resultVo.getConstiLevel()); |
|
|
|
reportResult.setConstiScore(resultVo.getZhScore()); |
|
|
|
reportResult.setMainFlag(resultVo.getMainFlag()); |
|
|
|
reportResult.setCreateBy(SecurityUtils.getUsername()); |
|
|
|
reportResultList.add(reportResult); |
|
|
|
} |
|
|
|
clientEvaDao.batchInsertReportResult(reportResultList); |
|
|
|
|
|
|
|
//3.3 生成养生建议
|
|
|
|
for (TzbsRmsReportResult result : reportResultList) { |
|
|
|
if (StrUtil.isEmpty(result.getConstiLevel()) || result.getConstiLevel().equals("20")) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
TzbsRmsReportYsjy rmsReportYsjy = new TzbsRmsReportYsjy(); |
|
|
|
rmsReportYsjy.setYsjyId(IDGenerator.nextSnowflakeId()); |
|
|
|
rmsReportYsjy.setReportId(result.getReportId()); |
|
|
|
rmsReportYsjy.setConstiCode(result.getConstiCode()); |
|
|
|
rmsReportYsjy.setConstiName(result.getConstiName()); |
|
|
|
rmsReportYsjy.setScaleCode(score.getCode()); |
|
|
|
rmsReportYsjy.setConstiYsjy( |
|
|
|
clientEvaDao.queryYsjy(result.getConstiCode()) |
|
|
|
); |
|
|
|
rmsReportYsjyMapper.insertSelective(rmsReportYsjy); |
|
|
|
private void zytzbs(Long evaluationId, RmsVo.ReportScore score) { |
|
|
|
//3.2 生成报告单辨识结果
|
|
|
|
List<ReportVo.EvaResult> resultList = countReportResult(evaluationId, score.getCode()); |
|
|
|
List<TzbsRmsReportResult> reportResultList = CollectionUtil.newArrayList(); |
|
|
|
for (ReportVo.EvaResult resultVo : resultList) { |
|
|
|
//转换为RmsReportResult对象
|
|
|
|
TzbsRmsReportResult reportResult = new TzbsRmsReportResult(); |
|
|
|
reportResult.setResultId(IDGenerator.nextSnowflakeId()); |
|
|
|
reportResult.setScaleCode(score.getCode()); |
|
|
|
reportResult.setConstiCode(resultVo.getConstiCode()); |
|
|
|
reportResult.setConstiName(resultVo.getConstiName()); |
|
|
|
reportResult.setConstiLevel(resultVo.getConstiLevel()); |
|
|
|
reportResult.setConstiScore(resultVo.getZhScore()); |
|
|
|
reportResult.setMainFlag(resultVo.getMainFlag()); |
|
|
|
reportResult.setCreateBy(SecurityUtils.getUsername()); |
|
|
|
reportResultList.add(reportResult); |
|
|
|
|
|
|
|
RmsVo.ReportScore reportScore = new RmsVo.ReportScore(); |
|
|
|
reportScore.setCode(resultVo.getConstiCode()); |
|
|
|
reportScore.setName(resultVo.getConstiName()); |
|
|
|
reportScore.setScore(reportResult.getConstiScore()); |
|
|
|
score.addSub(reportScore); |
|
|
|
} |
|
|
|
score.setReportResultList(reportResultList); |
|
|
|
|
|
|
|
//3.3 生成养生建议
|
|
|
|
List<TzbsRmsReportYsjy> reportYsjyList = CollectionUtil.newArrayList(); |
|
|
|
for (TzbsRmsReportResult result : reportResultList) { |
|
|
|
if (StrUtil.isEmpty(result.getConstiLevel()) || result.getConstiLevel().equals("20")) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
//获取初步印象
|
|
|
|
ClientEvaVo.ReportView reportView = reportView(evaluationId, score.getCode()); |
|
|
|
score.setImpression(reportView.getResult()); |
|
|
|
score.setScore(reportView.getTotalScore()); |
|
|
|
TzbsRmsReportYsjy rmsReportYsjy = new TzbsRmsReportYsjy(); |
|
|
|
rmsReportYsjy.setYsjyId(IDGenerator.nextSnowflakeId()); |
|
|
|
rmsReportYsjy.setReportId(result.getReportId()); |
|
|
|
rmsReportYsjy.setConstiCode(result.getConstiCode()); |
|
|
|
rmsReportYsjy.setConstiName(result.getConstiName()); |
|
|
|
rmsReportYsjy.setScaleCode(score.getCode()); |
|
|
|
rmsReportYsjy.setConstiYsjy( |
|
|
|
clientEvaDao.queryYsjy(result.getConstiCode()) |
|
|
|
); |
|
|
|
reportYsjyList.add(rmsReportYsjy); |
|
|
|
} |
|
|
|
score.setReportYsjyList(reportYsjyList); |
|
|
|
} |
|
|
|
|
|
|
|
private List<ReportVo.EvaResult> countReportResult(@NotNull Long evaId, Long reportId) { |
|
|
|
private List<ReportVo.EvaResult> countReportResult(@NotNull Long evaId, String scaleCode) { |
|
|
|
//1.查询体质分数(原始分)
|
|
|
|
List<ReportVo.EvaResult> resultList = clientEvaDao.countReportResult(evaId); |
|
|
|
List<ReportVo.EvaResult> resultList = clientEvaDao.countReportResult(evaId, scaleCode); |
|
|
|
if (CollectionUtil.isEmpty(resultList)) { |
|
|
|
throw new BaseException("未找到体质信息"); |
|
|
|
} |
|
|
|
@ -1020,123 +1042,8 @@ public class RmsServiceImpl implements IRmsService { |
|
|
|
//生成中医体质辨识结果
|
|
|
|
scores.forEach(score -> { |
|
|
|
if ("TZBS_LN".equals(score.getCode()) || "TZBS_BZ".equals(score.getCode())) { |
|
|
|
//获取初步印象
|
|
|
|
ClientEvaVo.ReportView reportView = reportView(evaluationId, score.getCode()); |
|
|
|
score.setImpression(reportView.getResult()); |
|
|
|
score.setScore(reportView.getTotalScore()); |
|
|
|
} |
|
|
|
}); |
|
|
|
return scores; |
|
|
|
} |
|
|
|
|
|
|
|
public List<RmsVo.ReportScore> getReportScores(List<RmsVo.ReportScore> reportScores, long evaluationId, Long reportId) { |
|
|
|
Map<String, RmsVo.ReportScore> map = new HashMap<>(32); |
|
|
|
List<RmsVo.ReportScore> scores = new ArrayList<>(); |
|
|
|
reportScores.forEach(score -> { |
|
|
|
if (ObjectUtil.isNotNull(score.getScore())) { |
|
|
|
if (BigDecimal.valueOf(score.getScore().intValue()).compareTo(score.getScore()) == 0) { |
|
|
|
score.setScore(score.getScore().setScale(0, BigDecimal.ROUND_HALF_UP)); |
|
|
|
} |
|
|
|
} |
|
|
|
map.put(score.getCode(), score); |
|
|
|
//测评类(MOCA等)
|
|
|
|
if (GenConstants.Ht.Report.TYPE_EVALUATION == score.getType()) { |
|
|
|
String specialCode = "NPI"; |
|
|
|
if (specialCode.equalsIgnoreCase(score.getCode())) { |
|
|
|
initNPI(evaluationId, score); |
|
|
|
} |
|
|
|
//特殊处理NMS
|
|
|
|
if (GenConstants.Ht.Report.NMS.equalsIgnoreCase(score.getCode())) { |
|
|
|
BigDecimal nms = rmsDao.countNmsScore(evaluationId); |
|
|
|
score.setScore(nms); |
|
|
|
} |
|
|
|
//特殊处理CDR
|
|
|
|
if (GenConstants.Ht.Report.CDR.equalsIgnoreCase(score.getCode())) { |
|
|
|
BigDecimal cdr = scoreService.getCDR(evaluationId); |
|
|
|
score.setScore(cdr); |
|
|
|
} |
|
|
|
scores.add(score); |
|
|
|
} else { |
|
|
|
log.info("score:{}", score); |
|
|
|
if (MoCA_B_8.equalsIgnoreCase(score.getCode())) { |
|
|
|
//3个或3个以下物品 0
|
|
|
|
//4~5个物品 1
|
|
|
|
//6~8个物品 2
|
|
|
|
//9~10个物品 3
|
|
|
|
BigDecimal score1 = score.getScore(); |
|
|
|
if (score1 != null) { |
|
|
|
|
|
|
|
if (new BigDecimal(3).compareTo(score1) >= 0) { |
|
|
|
score.setScore(new BigDecimal(0)); |
|
|
|
} |
|
|
|
if (new BigDecimal(5).compareTo(score1) >= 0 && new BigDecimal(4).compareTo(score1) <= 0) { |
|
|
|
score.setScore(new BigDecimal(1)); |
|
|
|
} |
|
|
|
if (new BigDecimal(8).compareTo(score1) >= 0 && new BigDecimal(6).compareTo(score1) <= 0) { |
|
|
|
score.setScore(new BigDecimal(2)); |
|
|
|
} |
|
|
|
if (new BigDecimal(10).compareTo(score1) >= 0 && new BigDecimal(9).compareTo(score1) <= 0) { |
|
|
|
score.setScore(new BigDecimal(3)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (StrUtil.isEmpty(score.getParentCode())) { |
|
|
|
return; |
|
|
|
} |
|
|
|
RmsVo.ReportScore reportScore = map.get(score.getParentCode()); |
|
|
|
if (reportScore != null) { |
|
|
|
reportScore.addSub(score); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
scores.forEach(score -> { |
|
|
|
if (GenConstants.Ht.Report.MOCA_SJZ.equalsIgnoreCase(score.getCode())) { |
|
|
|
return; |
|
|
|
} |
|
|
|
if (GenConstants.Ht.Report.ADAS.equalsIgnoreCase(score.getCode())) { |
|
|
|
scoreService.getADAS(evaluationId, score); |
|
|
|
} |
|
|
|
if (GenConstants.Ht.Report.ADAS14.equalsIgnoreCase(score.getCode())) { |
|
|
|
scoreService.getADAS14(evaluationId, score); |
|
|
|
} |
|
|
|
sumScore(score); |
|
|
|
//量表的分数为空,表示量表下没有其他认知域,直接使用量表的得分为总分
|
|
|
|
if (score.getScore() == null) { |
|
|
|
score.setScore(score.getScaleScore()); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
scores.forEach(score -> { |
|
|
|
if (score.getCode().equals("CTT")) { |
|
|
|
if (CollectionUtil.isNotEmpty(score.getSubReport())) { |
|
|
|
score.getSubReport().forEach(sub -> { |
|
|
|
String errorNumKey = ""; |
|
|
|
if (sub.getCode().equals("ASJCS")) { |
|
|
|
errorNumKey = "CTT_A_ERROR_NUMBER"; |
|
|
|
} else if (sub.getCode().equals("BSJCS")) { |
|
|
|
errorNumKey = "CTT_B_ERROR_NUMBER"; |
|
|
|
} |
|
|
|
if (StrUtil.isNotEmpty(errorNumKey)) { |
|
|
|
//qms_question_record表中没有code字段用以标识record,此处只能先用show_title进行过滤
|
|
|
|
AmsPatientQuestionRecordDesc desc = queryCTTRecordDesc(evaluationId, sub.getCode(), "错误数"); |
|
|
|
sub.getRecordDescMap().put(errorNumKey, desc != null ? desc.getAnswer() : ""); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
scores.forEach(score -> { |
|
|
|
if (score.getCode().equals("PSQI")) { |
|
|
|
initPSQI(evaluationId, score); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
//生成中医体质辨识结果
|
|
|
|
scores.forEach(score -> { |
|
|
|
if ("TZBS_LN".equals(score.getCode()) || "TZBS_BZ".equals(score.getCode())) { |
|
|
|
zytzbs(evaluationId, reportId, score); |
|
|
|
score.setSubReport(new ArrayList<>()); |
|
|
|
zytzbs(evaluationId, score); |
|
|
|
} |
|
|
|
}); |
|
|
|
return scores; |
|
|
|
|