|
@ -14,10 +14,7 @@ import com.ccsens.ht.bean.vo.QuestionVo; |
|
|
import com.ccsens.ht.persist.dao.*; |
|
|
import com.ccsens.ht.persist.dao.*; |
|
|
import com.ccsens.ht.persist.mapper.*; |
|
|
import com.ccsens.ht.persist.mapper.*; |
|
|
import com.ccsens.ht.uitl.Constant; |
|
|
import com.ccsens.ht.uitl.Constant; |
|
|
import com.ccsens.util.CodeEnum; |
|
|
import com.ccsens.util.*; |
|
|
import com.ccsens.util.NotSupportedFileTypeException; |
|
|
|
|
|
import com.ccsens.util.PropUtil; |
|
|
|
|
|
import com.ccsens.util.UploadFileUtil_Servlet3; |
|
|
|
|
|
import com.ccsens.util.exception.BaseException; |
|
|
import com.ccsens.util.exception.BaseException; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
@ -201,33 +198,8 @@ public class QuestionService implements IQuestionService { |
|
|
|
|
|
|
|
|
HtQuestionScoringRule rule = ruleList.get(0); |
|
|
HtQuestionScoringRule rule = ruleList.get(0); |
|
|
if (rule.getType() == null || rule.getType().byteValue() == Constant.Ht.Rule.SMALL) { |
|
|
if (rule.getType() == null || rule.getType().byteValue() == Constant.Ht.Rule.SMALL) { |
|
|
int currentNum = getCurrentNum(scores); |
|
|
// 计算分数
|
|
|
JSONArray ruleDetails = JSON.parseArray(rule.getDetail()); |
|
|
countScore(score, parentCode, report, scores, rule); |
|
|
AtomicInteger patientScore = new AtomicInteger(); |
|
|
|
|
|
for (int i = 0; i < ruleDetails.size() - 1; i++) { |
|
|
|
|
|
JSONObject small = (JSONObject)ruleDetails.get(i); |
|
|
|
|
|
JSONObject next = (JSONObject)ruleDetails.get(i+1); |
|
|
|
|
|
if (i == 0 && currentNum <= small.getIntValue(Constant.Ht.Rule.SMALL_NUM)) { |
|
|
|
|
|
patientScore.set(small.getIntValue(Constant.Ht.Rule.SMALL_SCORE)); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
if (currentNum > small.getIntValue(Constant.Ht.Rule.SMALL_NUM) && currentNum <= next.getIntValue(Constant.Ht.Rule.SMALL_NUM)) { |
|
|
|
|
|
patientScore.set(next.getIntValue(Constant.Ht.Rule.SMALL_SCORE)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
HtPatientScore singleScore = new HtPatientScore(); |
|
|
|
|
|
singleScore.setId(snowflake.nextId()); |
|
|
|
|
|
singleScore.setPatientReportId(score.getPatientReportId()); |
|
|
|
|
|
singleScore.setPatientId(report.getPatientId()); |
|
|
|
|
|
singleScore.setQuestionId(score.getQuestionId()); |
|
|
|
|
|
singleScore.setQuestionParentCode(parentCode); |
|
|
|
|
|
singleScore.setOptionId((long)Constant.Ht.NUMBER_DEFAULT); |
|
|
|
|
|
singleScore.setOptionName(Constant.Ht.STRING_DEFAULT); |
|
|
|
|
|
singleScore.setScore(patientScore.get()); |
|
|
|
|
|
singleScore.setType(Constant.Ht.Score.SCORE); |
|
|
|
|
|
singleScore.setAnswer(Constant.Ht.STRING_DEFAULT); |
|
|
|
|
|
scores.add(singleScore); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
return CodeEnum.QUESTION_RULE_NOT_FOUND; |
|
|
return CodeEnum.QUESTION_RULE_NOT_FOUND; |
|
|
} |
|
|
} |
|
@ -242,10 +214,74 @@ public class QuestionService implements IQuestionService { |
|
|
if (CollectionUtil.isNotEmpty(scores)) { |
|
|
if (CollectionUtil.isNotEmpty(scores)) { |
|
|
htPatientScoreDao.insertBatch(scores); |
|
|
htPatientScoreDao.insertBatch(scores); |
|
|
} |
|
|
} |
|
|
|
|
|
// 保存答案
|
|
|
|
|
|
saveAnswerRecord(score, question); |
|
|
|
|
|
|
|
|
return CodeEnum.SUCCESS; |
|
|
return CodeEnum.SUCCESS; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void saveAnswerRecord(QuestionDto.Score score, HtQuestion question) { |
|
|
|
|
|
if (StrUtil.isNotBlank(score.getPath())) { |
|
|
|
|
|
HtPatientQuestionRecordExample example = new HtPatientQuestionRecordExample(); |
|
|
|
|
|
String type = ""; |
|
|
|
|
|
switch (question.getOperateType()) { |
|
|
|
|
|
case 1://语音
|
|
|
|
|
|
case 4://敲击
|
|
|
|
|
|
type = Constant.Ht.Record.ANSWER_AUDIO; |
|
|
|
|
|
break; |
|
|
|
|
|
case 2: //画图
|
|
|
|
|
|
type = Constant.Ht.Record.ANSWER_IMG; |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
type = Constant.Ht.Record.ANSWER_TEXT; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
example.createCriteria().andPatientReportIdEqualTo(score.getPatientReportId()).andQuestionIdEqualTo(score.getQuestionId()).andRecordTypeEqualTo(type); |
|
|
|
|
|
HtPatientQuestionRecord delRecord = new HtPatientQuestionRecord(); |
|
|
|
|
|
delRecord.setIsDel(Constant.Ht.IS_DEL); |
|
|
|
|
|
htPatientQuestionRecordMapper.updateByExampleSelective(delRecord, example); |
|
|
|
|
|
|
|
|
|
|
|
HtPatientQuestionRecord record = new HtPatientQuestionRecord(); |
|
|
|
|
|
record.setId(snowflake.nextId()); |
|
|
|
|
|
record.setPatientReportId(score.getPatientReportId()); |
|
|
|
|
|
record.setQuestionId(score.getQuestionId()); |
|
|
|
|
|
record.setRecordTime(System.currentTimeMillis()); |
|
|
|
|
|
record.setRecordType(type); |
|
|
|
|
|
record.setRecordValue(score.getPath()); |
|
|
|
|
|
htPatientQuestionRecordMapper.insertSelective(record); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void countScore(QuestionDto.Score score, String parentCode, HtPatientReport report, List<HtPatientScore> scores, HtQuestionScoringRule rule) { |
|
|
|
|
|
int currentNum = getCurrentNum(scores); |
|
|
|
|
|
JSONArray ruleDetails = JSON.parseArray(rule.getDetail()); |
|
|
|
|
|
AtomicInteger patientScore = new AtomicInteger(); |
|
|
|
|
|
for (int i = 0; i < ruleDetails.size() - 1; i++) { |
|
|
|
|
|
JSONObject small = (JSONObject)ruleDetails.get(i); |
|
|
|
|
|
JSONObject next = (JSONObject)ruleDetails.get(i+1); |
|
|
|
|
|
if (i == 0 && currentNum <= small.getIntValue(Constant.Ht.Rule.SMALL_NUM)) { |
|
|
|
|
|
patientScore.set(small.getIntValue(Constant.Ht.Rule.SMALL_SCORE)); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
if (currentNum > small.getIntValue(Constant.Ht.Rule.SMALL_NUM) && currentNum <= next.getIntValue(Constant.Ht.Rule.SMALL_NUM)) { |
|
|
|
|
|
patientScore.set(next.getIntValue(Constant.Ht.Rule.SMALL_SCORE)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
HtPatientScore singleScore = new HtPatientScore(); |
|
|
|
|
|
singleScore.setId(snowflake.nextId()); |
|
|
|
|
|
singleScore.setPatientReportId(score.getPatientReportId()); |
|
|
|
|
|
singleScore.setPatientId(report.getPatientId()); |
|
|
|
|
|
singleScore.setQuestionId(score.getQuestionId()); |
|
|
|
|
|
singleScore.setQuestionParentCode(parentCode); |
|
|
|
|
|
singleScore.setOptionId((long)Constant.Ht.NUMBER_DEFAULT); |
|
|
|
|
|
singleScore.setOptionName(Constant.Ht.STRING_DEFAULT); |
|
|
|
|
|
singleScore.setScore(patientScore.get()); |
|
|
|
|
|
singleScore.setType(Constant.Ht.Score.SCORE); |
|
|
|
|
|
singleScore.setAnswer(Constant.Ht.STRING_DEFAULT); |
|
|
|
|
|
|
|
|
|
|
|
scores.add(singleScore); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 查询试题正确个数 |
|
|
* 查询试题正确个数 |
|
|
* @param scores |
|
|
* @param scores |
|
@ -287,7 +323,7 @@ public class QuestionService implements IQuestionService { |
|
|
List<HtPatientScore> scores = new ArrayList<>(); |
|
|
List<HtPatientScore> scores = new ArrayList<>(); |
|
|
for(QuestionDto.Option option : score.getOptions()) { |
|
|
for(QuestionDto.Option option : score.getOptions()) { |
|
|
HtQuestionOption questionOption = idOption.get(option.getId()); |
|
|
HtQuestionOption questionOption = idOption.get(option.getId()); |
|
|
assembleScore(score, question, report, ruleList, nameOption, scores, questionOption, option.getPath()); |
|
|
assembleScore(score, question, report, ruleList, nameOption, scores, questionOption); |
|
|
} |
|
|
} |
|
|
String special = "NPI"; |
|
|
String special = "NPI"; |
|
|
if (special.equalsIgnoreCase(question.getEvaluationCode())) { |
|
|
if (special.equalsIgnoreCase(question.getEvaluationCode())) { |
|
@ -295,7 +331,7 @@ public class QuestionService implements IQuestionService { |
|
|
example.createCriteria().andQuestionIdEqualTo(question.getId()).andNameEqualTo("result"); |
|
|
example.createCriteria().andQuestionIdEqualTo(question.getId()).andNameEqualTo("result"); |
|
|
List<HtQuestionOption> htQuestionOptions = htQuestionOptionDao.selectByExample(example); |
|
|
List<HtQuestionOption> htQuestionOptions = htQuestionOptionDao.selectByExample(example); |
|
|
for (HtQuestionOption option: htQuestionOptions) { |
|
|
for (HtQuestionOption option: htQuestionOptions) { |
|
|
assembleScore(score, question, report, ruleList, nameOption, scores, option, null); |
|
|
assembleScore(score, question, report, ruleList, nameOption, scores, option); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -311,9 +347,8 @@ public class QuestionService implements IQuestionService { |
|
|
* @param nameOption |
|
|
* @param nameOption |
|
|
* @param scores |
|
|
* @param scores |
|
|
* @param questionOption |
|
|
* @param questionOption |
|
|
* @param path |
|
|
|
|
|
*/ |
|
|
*/ |
|
|
private void assembleScore(QuestionDto.Score score, HtQuestion question, HtPatientReport report, List<HtQuestionScoringRule> ruleList, Map<String, HtQuestionOption> nameOption, List<HtPatientScore> scores, HtQuestionOption questionOption, String path) { |
|
|
private void assembleScore(QuestionDto.Score score, HtQuestion question, HtPatientReport report, List<HtQuestionScoringRule> ruleList, Map<String, HtQuestionOption> nameOption, List<HtPatientScore> scores, HtQuestionOption questionOption) { |
|
|
HtPatientScore patientScore = new HtPatientScore(); |
|
|
HtPatientScore patientScore = new HtPatientScore(); |
|
|
patientScore.setId(snowflake.nextId()); |
|
|
patientScore.setId(snowflake.nextId()); |
|
|
patientScore.setPatientReportId(score.getPatientReportId()); |
|
|
patientScore.setPatientReportId(score.getPatientReportId()); |
|
@ -330,7 +365,6 @@ public class QuestionService implements IQuestionService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
patientScore.setType(CollectionUtil.isNotEmpty(ruleList) ? Constant.Ht.Score.ANSWER : Constant.Ht.Score.ANSWER_SCORE); |
|
|
patientScore.setType(CollectionUtil.isNotEmpty(ruleList) ? Constant.Ht.Score.ANSWER : Constant.Ht.Score.ANSWER_SCORE); |
|
|
patientScore.setAnswer(StringUtils.isEmpty(path) ? Constant.Ht.STRING_DEFAULT : path); |
|
|
|
|
|
scores.add(patientScore); |
|
|
scores.add(patientScore); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|