diff --git a/tcm/src/main/java/com/ccsens/tcm/bean/dto/PatientDto.java b/tcm/src/main/java/com/ccsens/tcm/bean/dto/PatientDto.java index 5b105cf2..fe447190 100644 --- a/tcm/src/main/java/com/ccsens/tcm/bean/dto/PatientDto.java +++ b/tcm/src/main/java/com/ccsens/tcm/bean/dto/PatientDto.java @@ -47,7 +47,6 @@ public class PatientDto { @ApiModelProperty("每页数量") private Integer pageSize=10; } - @Data @ApiModel("保存患者的多个病例信息") public static class saveCaseMes { @@ -59,6 +58,9 @@ public class PatientDto { @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8") @ApiModelProperty("诊断时间") private Date timeSlot=new Date(System.currentTimeMillis()); + @NotNull + @ApiModelProperty("保存天数") + private Integer nums; } @Data @ApiModel("患者的某个病例信息") diff --git a/tcm/src/main/java/com/ccsens/tcm/service/PatientService.java b/tcm/src/main/java/com/ccsens/tcm/service/PatientService.java index effb4ce2..37500b55 100644 --- a/tcm/src/main/java/com/ccsens/tcm/service/PatientService.java +++ b/tcm/src/main/java/com/ccsens/tcm/service/PatientService.java @@ -109,152 +109,64 @@ public class PatientService implements IPatientService { 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))); - //升序查询,发病试题答案的数量 - PatientRecordExample patientRecordExample1=new PatientRecordExample(); - patientRecordExample1.setOrderByClause("created_at"); - patientRecordExample1.createCriteria().andPatientIdEqualTo(param.getPatientId()).andTestQuestionsIdEqualTo(disease_time).andRecStatusEqualTo((byte)0); - List 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) { - onsetTime=patientInformation.getCreatedAt(); - e.printStackTrace(); - } - }else { - //没有病发试题的情况 - onsetTime=patientInformation.getCreatedAt(); - } - - - - //试题只需要记录3次的 9 和30 算分界限 <9 =0 ;<30 =14 ; >30 =90 记录2次的 270 算分界线 <270 算180 ,>270 算365 - //是否需要去修改基本信息表中的录入状态 - Boolean update=true; - //先查看这个患者的需要的记录次数,在下面的这个对照组对象中呢 - Inpatient inpatient = inpatientMapper.selectByPrimaryKey(patientInformation.getInpatientId()); - //处理过的答案信息集合 List patientRecordList1=new ArrayList(); //处理过的提交的试题id集合 Set longSet=new HashSet(); - //算出的提交天数 - Integer da=0; - //患者id - Long paId=0L; - - //下面是对试题进行提交 + //下面是对试题进行处理 if(param.getList().size()>0) { //在这个地方修改其中得集合 List saveCaseMesSigList= param.getList(); Set stringSet=new HashSet(); saveCaseMesSigList.forEach(saveCaseMesSig -> { - if(saveCaseMesSig.getContentsType()==(byte)0){ - stringSet.add(saveCaseMesSig.getTestQuestionsId()+"-"+saveCaseMesSig.getContents()); + 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(param.getList().get(i).getContentsType()==(byte) 1){ - if(!stringSet.contains(param.getList().get(i).getTestQuestionsId()+"-"+param.getList().get(i).getContents())){ + 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++) { -// //先查询试题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.setTimeSlot(param.getTimeSlot()); + patientRecord.setCollectTime(param.getNums()); if(param.getList().get(i).getPatientRecordId()!=null){ //患者记录表的id patientRecord.setId(param.getList().get(i).getPatientRecordId()); } patientRecord.setUserId(userId); - if(inpatient.getCollectionNum()==1){ - //试题只需要记录一次的 - patientRecord.setCollectTime(0); - }else if(inpatient.getCollectionNum()==3){ - //需要记录三次的 - - //算出时间差 - int cha=timeDifference(param.getTimeSlot(),onsetTime); - if(cha=one && cha=two){ - //记录two之后的 - patientRecord.setCollectTime(twoAfter); - } - - }else if(inpatient.getCollectionNum()==2){ - //试题需要记录两次的 - int cha=timeDifference(param.getTimeSlot(),onsetTime); - if(cha(longSet)).andRecStatusEqualTo((byte) 0).andPatientIdEqualTo(paId).andCollectTimeEqualTo(da); + patientRecordExample.createCriteria().andTestQuestionsIdIn(new ArrayList(longSet)).andRecStatusEqualTo((byte) 0).andPatientIdEqualTo(param.getPatientId()).andCollectTimeEqualTo(param.getNums()); PatientRecord patientRecord=new PatientRecord(); patientRecord.setRecStatus((byte)2); patientRecordMapper.updateByExampleSelective(patientRecord,patientRecordExample); - + //插入答案 patientRecordList1.forEach(patientRecord1 -> { patientRecord1.setId(snowflake.nextId()); patientRecordMapper.insertSelective(patientRecord1); }); //根据获取的发病时间答案数和需要搜集次数以及本次是需要更新,还是插入答案 , 来做修改基本信息中的录入状态 - if (update){ - if(patientRecordList.size()+1