Browse Source

提交修改保存病人答题信息

recovery
wang1007152140 5 years ago
parent
commit
1b8c3f371b
  1. 54
      tcm/src/main/java/com/ccsens/tcm/service/PatientService.java

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

@ -5,15 +5,13 @@ import cn.hutool.core.lang.Snowflake;
import com.ccsens.tcm.bean.dto.ConRecDto;
import com.ccsens.tcm.bean.dto.PatientDto;
import com.ccsens.tcm.bean.dto.StatisticDto;
import com.ccsens.tcm.bean.po.PatientInformation;
import com.ccsens.tcm.bean.po.PatientRecord;
import com.ccsens.tcm.bean.po.PatientRecordExample;
import com.ccsens.tcm.bean.po.ReportCode;
import com.ccsens.tcm.bean.po.*;
import com.ccsens.tcm.bean.vo.ConRecVo;
import com.ccsens.tcm.bean.vo.PatientVo;
import com.ccsens.tcm.bean.vo.QuestionVo;
import com.ccsens.tcm.bean.vo.StatisticVo;
import com.ccsens.tcm.persist.dao.PatientDao;
import com.ccsens.tcm.persist.mapper.InpatientMapper;
import com.ccsens.tcm.persist.mapper.PatientInformationMapper;
import com.ccsens.tcm.persist.mapper.PatientRecordMapper;
import com.ccsens.tcm.persist.mapper.ReportCodeMapper;
@ -53,6 +51,8 @@ public class PatientService implements IPatientService {
private PatientRecordMapper patientRecordMapper;
@Resource
private PatientDao patientDao;
@Resource
private InpatientMapper inpatientMapper;
@Override
public void savePatient(PatientDto.SavePatient param, Long userId) {
@ -64,29 +64,32 @@ public class PatientService implements IPatientService {
@Override
public void saveCaseMes(PatientDto.saveCaseMes param, Long userId) {
//获取上次的发病时间
//拿到这个患者的基本信息
PatientInformation patientInformation = patientInformationMapper.selectByPrimaryKey(param.getPatientId());
//发病时间的试题id
Long disease_time=Long.parseLong(String.valueOf(redisUtil.get(Constant.Redis.DISEASE_TIME)));
//Long disease_time=1355131504711442432L;
//升序查询,发病试题答案的数量
PatientRecordExample patientRecordExample1=new PatientRecordExample();
patientRecordExample1.setOrderByClause("rec_status");
patientRecordExample1.createCriteria().andPatientIdEqualTo(param.getPatientId()).andTestQuestionsIdEqualTo(disease_time).andRecStatusEqualTo((byte)0);
List<PatientRecord> patientRecordList = patientRecordMapper.selectByExample(patientRecordExample1);
Date onsetTime=null;
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//获取上次的发病时间
if(patientRecordList.size()>0){
//有病发试题的情况
try {
onsetTime=format.parse(patientRecordList.get(0).getContents().trim());
} catch (ParseException e) {
PatientInformation patientInformation = patientInformationMapper.selectByPrimaryKey(param.getPatientId());
onsetTime=patientInformation.getCreatedAt();
e.printStackTrace();
}
}else {
//没有病发试题的情况
PatientInformation patientInformation = patientInformationMapper.selectByPrimaryKey(param.getPatientId());
onsetTime=patientInformation.getCreatedAt();
}
//先查一下需要搜集多少次
//试题只需要记录3次的 9 和30 算分界限 <9 =0 ;<30 =14 ; >30 =90 记录2次的 270 算分界线 <270 算180 ,>270 算365
int one=9;
@ -97,25 +100,30 @@ public class PatientService implements IPatientService {
int three=270;
int threeFront=180;
int threeAfter=365;
//是否需要去修改基本信息表中的录入状态
Boolean update=false;
//先查看这个患者的需要的记录次数,在下面的这个对照组对象中呢
Inpatient inpatient = inpatientMapper.selectByPrimaryKey(patientInformation.getInpatientId());
//下面是对试题进行提交
if(param.getList().size()>0) {
for (int i = 0; i < param.getList().size(); i++) {
//先查询试题id,查看试题需要记录的次数
ReportCode reportCode = reportCodeMapper.selectByPrimaryKey(param.getList().get(i).getTestQuestionsId());
// //先查询试题id,查看试题需要记录的次数
// ReportCode reportCode = reportCodeMapper.selectByPrimaryKey(param.getList().get(i).getTestQuestionsId());
//生成一个患者记录表的实例,并且赋值
PatientRecord patientRecord=new PatientRecord();
BeanUtils.copyProperties(param.getList().get(i),patientRecord);
patientRecord.setPatientId(param.getPatientId());
patientRecord.setId(param.getList().get(i).getPatientRecordId());
if(param.getList().get(i).getPatientRecordId()!=null){
//患者记录表的id
patientRecord.setId(param.getList().get(i).getPatientRecordId());
}
patientRecord.setUserId(userId);
if(reportCode.getReportType()==(byte)0){
if(inpatient.getCollectionNum()==1){
//试题只需要记录一次的
patientRecord.setCollectTime(0);
}else if(reportCode.getReportType()==(byte)1){
}else if(inpatient.getCollectionNum()==3){
//需要记录三次的
//算出时间差
int cha=timeDifference(patientRecord.getTimeSlot(),onsetTime);
if(cha<one){
@ -129,7 +137,7 @@ public class PatientService implements IPatientService {
patientRecord.setCollectTime(twoAfter);
}
}else if(reportCode.getReportType()==(byte)2){
}else if(inpatient.getCollectionNum()==2){
//试题需要记录两次的
int cha=timeDifference(patientRecord.getTimeSlot(),onsetTime);
if(cha<three){
@ -142,13 +150,25 @@ public class PatientService implements IPatientService {
if(patientRecord.getId()!=null){
//更新
patientRecordMapper.updateByPrimaryKeySelective(patientRecord);
}else {
//添加
patientRecord.setId(snowflake.nextId());
patientRecordMapper.insertSelective(patientRecord);
update=true;
}
}
}
//根据获取的发病时间答案数和需要搜集次数以及本次是需要更新,还是插入答案 , 来做修改基本信息中的录入状态
if (update){
if(patientRecordList.size()+1<inpatient.getCollectionNum()){
//数据搜集中
patientInformation.setInputStatus((byte)1);
}else if(patientRecordList.size()+1==inpatient.getCollectionNum()){
patientInformation.setInputStatus((byte)2);
}
}
}
@Override

Loading…
Cancel
Save