Browse Source

Merge branch 'pt' of dd.tall.wiki:ccsens_wiki/ccsenscloud into pt

recovery
zy_Java 4 years ago
parent
commit
36968df4f8
  1. 46
      tcm/src/main/java/com/ccsens/tcm/service/PatientService.java
  2. 20
      tcm/src/main/resources/mapper_dao/QuestionDao.xml
  3. 1
      util/src/main/java/com/ccsens/util/CodeEnum.java

46
tcm/src/main/java/com/ccsens/tcm/service/PatientService.java

@ -107,30 +107,50 @@ public class PatientService implements IPatientService {
@Override
public void saveCaseMes(PatientDto.saveCaseMes param, Long userId) {
if(param.getList().size()==0){
throw new BaseException(CodeEnum.QINGTIJIAOSHITI);
}
//拿到这个患者的基本信息
PatientInformation patientInformation = patientInformationMapper.selectByPrimaryKey(param.getPatientId());
//处理过的答案信息集合
List<PatientRecord> patientRecordList1=new ArrayList<PatientRecord>();
//处理过的提交的试题id集合
//处理过的提交的答案试题id,答案类型为0,1 集合
Set<Long> longSet=new HashSet<Long>();
//处理过的提交的答案试题id,答案类型为2 集合
Set<Long> longSet1=new HashSet<Long>();
//用来装试题答案id和其数量
Map<Long,Integer> shitiwei2de=new HashMap<Long, Integer>();
//下面是对试题进行处理
if(param.getList().size()>0) {
//在这个地方修改其中得集合
List<PatientDto.saveCaseMesSig> saveCaseMesSigList= param.getList();
Set<String> stringSet=new HashSet<String>();
//类型为2的数组
Set<String> stringSet1=new HashSet<String>();
saveCaseMesSigList.forEach(saveCaseMesSig -> {
if(saveCaseMesSig.getContentsType()==(byte)1){
stringSet.add(saveCaseMesSig.getTestQuestionsId()+"-"+saveCaseMesSig.getContents().substring(0,saveCaseMesSig.getContents().indexOf(":")));
}
});
for (int i = param.getList().size() - 1; i >= 0; i--) {
//先统计一下数量
if(shitiwei2de.containsKey(param.getList().get(i))){
shitiwei2de.put( param.getList().get(i).getTestQuestionsId(),shitiwei2de.get(param.getList().get(i).getTestQuestionsId())+1);
}else {
shitiwei2de.put( param.getList().get(i).getTestQuestionsId(),1);
}
if(param.getList().get(i).getContentsType()==(byte) 0){
if(stringSet.contains(param.getList().get(i).getTestQuestionsId()+"-"+param.getList().get(i).getContents())){
param.getList().remove(i);
}
}
}
for (int i = 0; i < param.getList().size(); i++) {
//拿出答案类型为2的并且数量为1的
if((param.getList().get(i).getContentsType()==(byte) 2 )&&(shitiwei2de.get(param.getList().get(i).getTestQuestionsId())==1)){
longSet1.add(param.getList().get(i).getTestQuestionsId());
}
}
for (int i = 0; i < param.getList().size(); i++) {
PatientRecord patientRecord=new PatientRecord();
BeanUtils.copyProperties(param.getList().get(i),patientRecord);
@ -142,17 +162,29 @@ public class PatientService implements IPatientService {
patientRecord.setId(param.getList().get(i).getPatientRecordId());
}
patientRecord.setUserId(userId);
if(!longSet1.contains(param.getList().get(i).getTestQuestionsId())){
longSet.add(patientRecord.getTestQuestionsId());
}
//因为得删除之前得内容,所以把试题集合都抽出来,另外再写循环进行插入
patientRecordList1.add(patientRecord);
}
}
//对答案进行更新删除
PatientRecordExample patientRecordExample=new PatientRecordExample();
if(longSet.size()>0) {
//对答案 0 和 1 进行更新删除
PatientRecordExample patientRecordExample = new PatientRecordExample();
patientRecordExample.createCriteria().andTestQuestionsIdIn(new ArrayList<Long>(longSet)).andRecStatusEqualTo((byte) 0).andPatientIdEqualTo(param.getPatientId()).andCollectTimeEqualTo(param.getNums());
PatientRecord patientRecord=new PatientRecord();
patientRecord.setRecStatus((byte)2);
patientRecordMapper.updateByExampleSelective(patientRecord,patientRecordExample);
PatientRecord patientRecord = new PatientRecord();
patientRecord.setRecStatus((byte) 2);
patientRecordMapper.updateByExampleSelective(patientRecord, patientRecordExample);
}
//对答案是2的进行删除
if(longSet1.size()>0) {
PatientRecordExample patientRecordExample1 = new PatientRecordExample();
patientRecordExample1.createCriteria().andTestQuestionsIdIn(new ArrayList<Long>(longSet1)).andRecStatusEqualTo((byte) 0).andPatientIdEqualTo(param.getPatientId()).andCollectTimeEqualTo(param.getNums()).andContentsTypeEqualTo((byte) 2);
PatientRecord patientRecord2 = new PatientRecord();
patientRecord2.setRecStatus((byte) 2);
patientRecordMapper.updateByExampleSelective(patientRecord2, patientRecordExample1);
}
//插入答案
patientRecordList1.forEach(patientRecord1 -> {
patientRecord1.setId(snowflake.nextId());

20
tcm/src/main/resources/mapper_dao/QuestionDao.xml

@ -123,7 +123,8 @@
<select id="getQuestionByCodeAndPatientId" resultMap="getQuestionByCodeAndPatientId">
SELECT
*
*,
tpr.contents AS explains
FROM
(
SELECT
@ -146,7 +147,6 @@
r.id as recordId,
if(r.collect_time is null, 0,r.collect_time) as collect_time,
r.contents as answer,
if(r.contents_type = 2,r.contents,null) as explains,
if(r.contents_type = 1 and SUBSTRING_INDEX(r.contents,':',1) = o.submit_value,
SUBSTRING(r.contents,char_length(o.submit_value)+2),null
@ -163,8 +163,20 @@
and q.rec_status = 0
and q.`code` = #{code}
)a
ORDER BY a.qsort,a.osort,a.choose DESC,-a.otherInformation DESC
) qq left join (
SELECT
test_questions_id,
contents
FROM
t_patient_record tpr
WHERE
tpr.contents_type = 2
AND tpr.patient_id = #{patientId}
AND tpr.collect_time = #{nums}
AND tpr.rec_status = 0
) tpr on tpr.test_questions_id = qq.qid
ORDER BY qq.qsort,qq.osort,qq.choose DESC,-qq.otherInformation DESC
</select>
<resultMap id="getQuestionByOptionId" type="com.ccsens.tcm.bean.vo.QuestionVo$PatientQuestion">

1
util/src/main/java/com/ccsens/util/CodeEnum.java

@ -185,6 +185,7 @@ public enum CodeEnum {
NOT_HOSPITAL(154,"未找到医院信息",true),
ZHUYUANIDCHONGFU(155,"住院号重复",true),
MEIYOUGAIYISHENG(156,"该医生信息查询不正确",true),
QINGTIJIAOSHITI(157,"请提交答案",true),
;

Loading…
Cancel
Save