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 e530909d..2e67898d 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 @@ -20,8 +20,8 @@ public class PatientDto { @Data @ApiModel("保存患者基本信息") public static class SavePatient { - @ApiModelProperty("住院号") - private String hospitalization; +// @ApiModelProperty("住院号") +// private String hospitalization; @ApiModelProperty("对照组id") private Long inpatientId; @ApiModelProperty("录入状态:0:新建 1:数据搜集中 2数据搜集完成 3数据搜集超时 4:废弃") diff --git a/tcm/src/main/java/com/ccsens/tcm/bean/po/BiologicalSamples.java b/tcm/src/main/java/com/ccsens/tcm/bean/po/BiologicalSamples.java index 1e36ad0d..7b16a3fd 100644 --- a/tcm/src/main/java/com/ccsens/tcm/bean/po/BiologicalSamples.java +++ b/tcm/src/main/java/com/ccsens/tcm/bean/po/BiologicalSamples.java @@ -6,6 +6,8 @@ import java.util.Date; public class BiologicalSamples implements Serializable { private Long id; + private String code; + private Byte sampleType; private Long patientInformationId; @@ -30,6 +32,14 @@ public class BiologicalSamples implements Serializable { this.id = id; } + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code == null ? null : code.trim(); + } + public Byte getSampleType() { return sampleType; } @@ -93,6 +103,7 @@ public class BiologicalSamples implements Serializable { sb.append(" ["); sb.append("Hash = ").append(hashCode()); sb.append(", id=").append(id); + sb.append(", code=").append(code); sb.append(", sampleType=").append(sampleType); sb.append(", patientInformationId=").append(patientInformationId); sb.append(", collectTime=").append(collectTime); diff --git a/tcm/src/main/java/com/ccsens/tcm/bean/po/BiologicalSamplesExample.java b/tcm/src/main/java/com/ccsens/tcm/bean/po/BiologicalSamplesExample.java index 591f2da5..5068090e 100644 --- a/tcm/src/main/java/com/ccsens/tcm/bean/po/BiologicalSamplesExample.java +++ b/tcm/src/main/java/com/ccsens/tcm/bean/po/BiologicalSamplesExample.java @@ -165,6 +165,76 @@ public class BiologicalSamplesExample { return (Criteria) this; } + public Criteria andCodeIsNull() { + addCriterion("code is null"); + return (Criteria) this; + } + + public Criteria andCodeIsNotNull() { + addCriterion("code is not null"); + return (Criteria) this; + } + + public Criteria andCodeEqualTo(String value) { + addCriterion("code =", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeNotEqualTo(String value) { + addCriterion("code <>", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeGreaterThan(String value) { + addCriterion("code >", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeGreaterThanOrEqualTo(String value) { + addCriterion("code >=", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeLessThan(String value) { + addCriterion("code <", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeLessThanOrEqualTo(String value) { + addCriterion("code <=", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeLike(String value) { + addCriterion("code like", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeNotLike(String value) { + addCriterion("code not like", value, "code"); + return (Criteria) this; + } + + public Criteria andCodeIn(List values) { + addCriterion("code in", values, "code"); + return (Criteria) this; + } + + public Criteria andCodeNotIn(List values) { + addCriterion("code not in", values, "code"); + return (Criteria) this; + } + + public Criteria andCodeBetween(String value1, String value2) { + addCriterion("code between", value1, value2, "code"); + return (Criteria) this; + } + + public Criteria andCodeNotBetween(String value1, String value2) { + addCriterion("code not between", value1, value2, "code"); + return (Criteria) this; + } + public Criteria andSampleTypeIsNull() { addCriterion("sample_type is null"); return (Criteria) this; diff --git a/tcm/src/main/java/com/ccsens/tcm/bean/vo/BiologicalSamplesVo.java b/tcm/src/main/java/com/ccsens/tcm/bean/vo/BiologicalSamplesVo.java index 9e913781..41d383e9 100644 --- a/tcm/src/main/java/com/ccsens/tcm/bean/vo/BiologicalSamplesVo.java +++ b/tcm/src/main/java/com/ccsens/tcm/bean/vo/BiologicalSamplesVo.java @@ -14,8 +14,10 @@ public class BiologicalSamplesVo { public static class selBiolog { @ApiModelProperty("医院名称") private String name; - @ApiModelProperty("患者住院号") + @ApiModelProperty("患者编号") private String hospitalization; + @ApiModelProperty("生物样本编号") + private String code; @ApiModelProperty("样本类型 0:抗血凝10ml 1:促凝血5ml 2:晨尿10ml 3:24小时尿10ml") private Byte sampleType; @ApiModelProperty("采集时间") diff --git a/tcm/src/main/java/com/ccsens/tcm/service/ImportService.java b/tcm/src/main/java/com/ccsens/tcm/service/ImportService.java index 4fc45e74..7ac5069b 100644 --- a/tcm/src/main/java/com/ccsens/tcm/service/ImportService.java +++ b/tcm/src/main/java/com/ccsens/tcm/service/ImportService.java @@ -283,18 +283,17 @@ public class ImportService implements IImportService { } question.setRelevanceOptionId(optionId == null ? 0 : optionId); // 设置关联那个医院 - List hospitalIds = null; + List hospitalIds = new ArrayList<>(); int hospitalIndex = 10; if (objs.length > hospitalIndex && !StringUtils.isEmpty(objs[hospitalIndex])) { - hospitalMap.forEach((key, value)->{ - hospitalIds.add(value); - - }); - } else { String[] codes = ((String) objs[hospitalIndex]).split("[,,]"); for (String code:codes) { hospitalIds.add(hospitalMap.get(code)); } + } else { + hospitalMap.forEach((key, value)->{ + hospitalIds.add(value); + }); } hospitalIds.forEach(id->{ @@ -302,7 +301,7 @@ public class ImportService implements IImportService { questionHospital.setId(snowflake.nextId()); questionHospital.setQuestionId(question.getId()); questionHospital.setHospitalId(id); - questionHospitalDao.insert(questionHospital); + questionHospitalDao.insertSelective(questionHospital); }); log.info("导入试题:{}", question); 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 12e990f1..e15086c2 100644 --- a/tcm/src/main/java/com/ccsens/tcm/service/PatientService.java +++ b/tcm/src/main/java/com/ccsens/tcm/service/PatientService.java @@ -26,6 +26,7 @@ import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.text.DecimalFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; @@ -54,35 +55,47 @@ public class PatientService implements IPatientService { private HospitalMapper hospitalMapper; @Resource private DoctorMapper doctorMapper; - @Value("${day.one}") - public int one; - @Value("${day.two}") - public int two; - @Value("${day.oneFront}") - public int oneFront; - @Value("${day.oneAfter}") - public int oneAfter; - @Value("${day.twoAfter}") - public int twoAfter; - @Value("${day.three}") - public int three; - @Value("${day.threeFront}") - public int threeFront; - @Value("${day.threeAfter}") - public int threeAfter; +// @Value("${day.one}") +// public int one; +// @Value("${day.two}") +// public int two; +// @Value("${day.oneFront}") +// public int oneFront; +// @Value("${day.oneAfter}") +// public int oneAfter; +// @Value("${day.twoAfter}") +// public int twoAfter; +// @Value("${day.three}") +// public int three; +// @Value("${day.threeFront}") +// public int threeFront; +// @Value("${day.threeAfter}") +// public int threeAfter; @Override public void savePatient(PatientDto.SavePatient param, Long userId) { - PatientInformationExample patientInformationExample=new PatientInformationExample(); - patientInformationExample.createCriteria().andHospitalizationEqualTo(param.getHospitalization()).andRecStatusEqualTo((byte)0); - long l = patientInformationMapper.countByExample(patientInformationExample); - if(l>0){ - throw new BaseException(CodeEnum.ZHUYUANIDCHONGFU); +// PatientInformationExample patientInformationExample=new PatientInformationExample(); +// patientInformationExample.createCriteria().andHospitalizationEqualTo(param.getHospitalization()).andRecStatusEqualTo((byte)0); +// long l = patientInformationMapper.countByExample(patientInformationExample); +// if(l>0){ +// throw new BaseException(CodeEnum.ZHUYUANIDCHONGFU); +// } + Hospital hospital = selUserIdToHosId(userId); + Inpatient inpatient = inpatientMapper.selectByPrimaryKey(param.getInpatientId()); + if (inpatient == null) { + throw new BaseException(CodeEnum.PARAM_ERROR); } - param.setHospitalId(selUserIdToHosId(userId).getId()); + log.info("医院:{},对照组:{}", hospital, inpatient); + param.setHospitalId(hospital.getId()); PatientInformation patientInformation=new PatientInformation(); BeanUtils.copyProperties(param,patientInformation); patientInformation.setId(snowflake.nextId()); + // 生成编号 + long incr = redisUtil.incr(Constant.Redis.HOSPITAL_NUM + hospital.getCode(), 1) + 1; + DecimalFormat df=new DecimalFormat("000"); + String num = hospital.getCode() + "" + inpatient.getCode() + df.format(incr); + log.info("编号:{}", num); + patientInformation.setHospitalization(num); patientInformationMapper.insertSelective(patientInformation); } @@ -342,6 +355,7 @@ public class PatientService implements IPatientService { biologicalSamples.setId(snowflake.nextId()); biologicalSamples.setPatientInformationId(patientInformations.get(0).getId()); BeanUtils.copyProperties(param,biologicalSamples); + biologicalSamples.setCode(param.getHospitalization() + Constant.SPLIT_STRIKE + Constant.Biological.getByType(param.getSampleType()).getCode() + Constant.SPLIT_STRIKE + param.getCollectTime()); biologicalSamplesMapper.insertSelective(biologicalSamples); } diff --git a/tcm/src/main/java/com/ccsens/tcm/uitl/Constant.java b/tcm/src/main/java/com/ccsens/tcm/uitl/Constant.java index 9a7efbff..93effda2 100644 --- a/tcm/src/main/java/com/ccsens/tcm/uitl/Constant.java +++ b/tcm/src/main/java/com/ccsens/tcm/uitl/Constant.java @@ -20,6 +20,8 @@ public class Constant { public static final String VIDEO = ".flv,swf,mkv,avi,rm,rmvb,mpeg,mpg,.ogg,ogv,mov,wmv,mp4,webm,mp3,wav,mid,.wma"; /**上传图片访问路径*/ public static final String UPLOAD_URL = "uploads/"; + /**中划线*/ + public static final String SPLIT_STRIKE = "-"; /**选择选项后关联其他题目*/ @@ -35,6 +37,43 @@ public class Constant { public final static byte SEX_MAN = 0; public final static byte SEX_WOMAN = 1; + public enum Biological { + /**抗血凝*/ + ANTICOAGULATION((byte)0, "X-1", "血标本上清液"), + THROMBOPLASTIN((byte)1, "X-2", "血标本细胞"), + MORNING_URINE((byte)2, "N-3", "尿标本"), + ; + private byte type; + private String code; + private String name; + + Biological(byte type, String code, String name) { + this.type = type; + this.code = code; + this.name = name; + } + public static Biological getByType(byte type){ + for (Biological cal: Biological.values()) { + if (cal.type == type) { + return cal; + } + } + return null; + } + + public byte getType() { + return type; + } + + public String getCode() { + return code; + } + + public String getName() { + return name; + } + } + public static class Report{ public final static String PARENT_CODE = "TCM"; public final static String CODE_BSXG = "BSXG"; @@ -63,6 +102,8 @@ public class Constant { public final static String DISEASE_TIME = "disease_time"; /**所有题目按code分类*/ public final static String CODE_QUESTION = "code_question"; + /**医院排序*/ + public final static String HOSPITAL_NUM = "hospital_num_"; } public static class File{ diff --git a/tcm/src/main/resources/mapper_dao/PatientDao.xml b/tcm/src/main/resources/mapper_dao/PatientDao.xml index 26999425..149a59d8 100644 --- a/tcm/src/main/resources/mapper_dao/PatientDao.xml +++ b/tcm/src/main/resources/mapper_dao/PatientDao.xml @@ -391,7 +391,7 @@ t.user_id - + - + - + @@ -298,11 +301,11 @@ AND trc.rec_status =0 order by trc.sort,trc1.sort,tq.sort - + - + diff --git a/tcm/src/main/resources/mapper_dao/ReportCodeDao.xml b/tcm/src/main/resources/mapper_dao/ReportCodeDao.xml index 0283429c..bc304f6f 100644 --- a/tcm/src/main/resources/mapper_dao/ReportCodeDao.xml +++ b/tcm/src/main/resources/mapper_dao/ReportCodeDao.xml @@ -149,7 +149,7 @@ c.code = t.code and t.recode_time = #{nums} and c.`level` = 2 - and crec_status = 0 + and c.rec_status = 0 and t.rec_status = 0 ) c2 on c1.`code` = c2.parent_code diff --git a/tcm/src/main/resources/mapper_raw/BiologicalSamplesMapper.xml b/tcm/src/main/resources/mapper_raw/BiologicalSamplesMapper.xml index 7d05b3f3..92210ca1 100644 --- a/tcm/src/main/resources/mapper_raw/BiologicalSamplesMapper.xml +++ b/tcm/src/main/resources/mapper_raw/BiologicalSamplesMapper.xml @@ -3,6 +3,7 @@ + @@ -70,8 +71,8 @@ - id, sample_type, patient_information_id, collect_time, user_id, created_at, update_at, - rec_status + id, code, sample_type, patient_information_id, collect_time, user_id, created_at, + update_at, rec_status