Browse Source

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

recovery
zy_Java 4 years ago
parent
commit
02a1525e01
  1. 4
      tcm/src/main/java/com/ccsens/tcm/bean/dto/PatientDto.java
  2. 114
      tcm/src/main/java/com/ccsens/tcm/service/PatientService.java
  3. 4
      tcm/src/main/resources/application.yml

4
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("患者的某个病例信息")

114
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<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) {
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<PatientRecord> patientRecordList1=new ArrayList<PatientRecord>();
//处理过的提交的试题id集合
Set<Long> longSet=new HashSet<Long>();
//算出的提交天数
Integer da=0;
//患者id
Long paId=0L;
//下面是对试题进行提交
//下面是对试题进行处理
if(param.getList().size()>0) {
//在这个地方修改其中得集合
List<PatientDto.saveCaseMesSig> saveCaseMesSigList= param.getList();
Set<String> stringSet=new HashSet<String>();
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){
//记录的one之前的
patientRecord.setCollectTime(oneFront);
}else if(cha>=one && cha<two){
//记录oneh和two之间的
patientRecord.setCollectTime(oneAfter);
}else if(cha>=two){
//记录two之后的
patientRecord.setCollectTime(twoAfter);
}
}else if(inpatient.getCollectionNum()==2){
//试题需要记录两次的
int cha=timeDifference(param.getTimeSlot(),onsetTime);
if(cha<three){
patientRecord.setCollectTime(threeFront);
}else {
patientRecord.setCollectTime(threeAfter);
}
}
//删除之前的答题内容,想的是先把这些题的id全存起来,这里可以不用考虑去重的问题,然后呢,根据答题id数组和患者id和collectime删除之前的内容。
da=patientRecord.getCollectTime();
paId=patientRecord.getPatientId();
longSet.add(patientRecord.getTestQuestionsId());
//因为得删除之前得内容,所以把试题集合都抽出来,另外再写循环进行插入
patientRecordList1.add(patientRecord);
// //进行数据更新
// if(patientRecord.getId()!=null){
// //更新
// patientRecordMapper.updateByPrimaryKeySelective(patientRecord);
//
// }else {
// //添加
// patientRecord.setId(snowflake.nextId());
// patientRecordMapper.insertSelective(patientRecord);
// update=true;
// }
}
}
//对答案进行更新删除
PatientRecordExample patientRecordExample=new PatientRecordExample();
patientRecordExample.createCriteria().andTestQuestionsIdIn(new ArrayList<Long>(longSet)).andRecStatusEqualTo((byte) 0).andPatientIdEqualTo(paId).andCollectTimeEqualTo(da);
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);
//插入答案
patientRecordList1.forEach(patientRecord1 -> {
patientRecord1.setId(snowflake.nextId());
patientRecordMapper.insertSelective(patientRecord1);
});
//根据获取的发病时间答案数和需要搜集次数以及本次是需要更新,还是插入答案 , 来做修改基本信息中的录入状态
if (update){
if(patientRecordList.size()+1<inpatient.getCollectionNum()){
if(param.getNums()==365){
//数据搜集中
patientInformation.setInputStatus((byte)1);
}else if(patientRecordList.size()+1==inpatient.getCollectionNum()){
patientInformation.setInputStatus((byte)2);
}
patientInformationMapper.updateByPrimaryKeySelective(patientInformation);
patientInformation.setInputStatus((byte)2);
}else{
patientInformation.setInputStatus((byte)1);
}
patientInformationMapper.updateByPrimaryKeySelective(patientInformation);
}
@Override

4
tcm/src/main/resources/application.yml

@ -1,5 +1,5 @@
spring:
profiles:
active: dev
include: common, util-dev
active: green
include: common, util-green

Loading…
Cancel
Save