Browse Source

Merge branch 'master' of gitee.com:ccsens_s/ccsenscloud

master
zhangye 6 years ago
parent
commit
46e1d73f12
  1. 7
      ht/src/main/java/com/ccsens/ht/bean/dto/QuestionDto.java
  2. 3
      ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java
  3. 2
      ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java
  4. 5
      ht/src/main/java/com/ccsens/ht/service/PatientReportService.java
  5. 106
      ht/src/main/java/com/ccsens/ht/service/QuestionService.java
  6. 12
      ht/src/main/java/com/ccsens/ht/uitl/Constant.java

7
ht/src/main/java/com/ccsens/ht/bean/dto/QuestionDto.java

@ -40,6 +40,8 @@ public class QuestionDto {
private Long questionId;
@ApiModelProperty("选项集合")
private List<Option> options;
@ApiModelProperty("病友画图或录音")
private String path;
}
@Data
@ApiModel("QuestionDtoOption")
@ -47,9 +49,8 @@ public class QuestionDto {
@NotNull(message = "选项ID不能为空")
@ApiModelProperty("选项ID")
private Long id;
@NotNull(message = "病友画图或录音不能为空")
@ApiModelProperty("病友画图或录音")
private String path;
// @ApiModelProperty("病友画图或录音")
// private String path;
}

3
ht/src/main/java/com/ccsens/ht/bean/vo/PatientReportVo.java

@ -296,9 +296,6 @@ public class PatientReportVo {
rows.add(row5);
}
}
PdfUtil.Row descRow = new PdfUtil.Row();
PdfUtil.Cell cell = new PdfUtil.Cell();

2
ht/src/main/java/com/ccsens/ht/bean/vo/QuestionVo.java

@ -138,6 +138,8 @@ public class QuestionVo {
private Integer clearTimes;
@ApiModelProperty("定时器时长")
private Integer timingLength;
@ApiModelProperty("答案路径")
private String path;
@ApiModelProperty("关联试题")
List<QuestionOption> relationQuestions = new ArrayList<>();

5
ht/src/main/java/com/ccsens/ht/service/PatientReportService.java

@ -137,7 +137,10 @@ public class PatientReportService implements IPatientReportService {
htPatientFollowUpMapper.insertSelective(followUp);
}
//修改报告单
htPatientReportDao.updateByPrimaryKeySelective(patientReport.copy());
HtPatientReport copy = patientReport.copy();
copy.setUrl(Constant.Ht.STRING_DEFAULT);
copy.setQrCodeUrl(Constant.Ht.STRING_DEFAULT);
htPatientReportDao.updateByPrimaryKeySelective(copy);
log.info("成功编辑报告单信息");
HtPatientReportRecord record = new HtPatientReportRecord();
record.setId(snowflake.nextId());

106
ht/src/main/java/com/ccsens/ht/service/QuestionService.java

@ -14,10 +14,7 @@ import com.ccsens.ht.bean.vo.QuestionVo;
import com.ccsens.ht.persist.dao.*;
import com.ccsens.ht.persist.mapper.*;
import com.ccsens.ht.uitl.Constant;
import com.ccsens.util.CodeEnum;
import com.ccsens.util.NotSupportedFileTypeException;
import com.ccsens.util.PropUtil;
import com.ccsens.util.UploadFileUtil_Servlet3;
import com.ccsens.util.*;
import com.ccsens.util.exception.BaseException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -201,33 +198,8 @@ public class QuestionService implements IQuestionService {
HtQuestionScoringRule rule = ruleList.get(0);
if (rule.getType() == null || rule.getType().byteValue() == Constant.Ht.Rule.SMALL) {
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);
// 计算分数
countScore(score, parentCode, report, scores, rule);
} else {
return CodeEnum.QUESTION_RULE_NOT_FOUND;
}
@ -242,10 +214,74 @@ public class QuestionService implements IQuestionService {
if (CollectionUtil.isNotEmpty(scores)) {
htPatientScoreDao.insertBatch(scores);
}
// 保存答案
saveAnswerRecord(score, question);
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
@ -287,7 +323,7 @@ public class QuestionService implements IQuestionService {
List<HtPatientScore> scores = new ArrayList<>();
for(QuestionDto.Option option : score.getOptions()) {
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";
if (special.equalsIgnoreCase(question.getEvaluationCode())) {
@ -295,7 +331,7 @@ public class QuestionService implements IQuestionService {
example.createCriteria().andQuestionIdEqualTo(question.getId()).andNameEqualTo("result");
List<HtQuestionOption> htQuestionOptions = htQuestionOptionDao.selectByExample(example);
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 scores
* @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();
patientScore.setId(snowflake.nextId());
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.setAnswer(StringUtils.isEmpty(path) ? Constant.Ht.STRING_DEFAULT : path);
scores.add(patientScore);
}

12
ht/src/main/java/com/ccsens/ht/uitl/Constant.java

@ -53,6 +53,18 @@ public class Constant {
public static final byte SCORE = 2;
}
/**
* 病人答案记录类型
*/
public final static class Record{
//答案文本
public static final String ANSWER_TEXT = "answer_text";
//答案图片
public static final String ANSWER_IMG = "answer_img";
// 答案语音
public static final String ANSWER_AUDIO = "answer_audio";
}
public final static class Doctor {
public static final byte CHECK_WAIT = 0;

Loading…
Cancel
Save