Browse Source

患者和生物样本编号

recovery
zhizhi wu 4 years ago
parent
commit
a6ae493a99
  1. 11
      tcm/src/main/java/com/ccsens/tcm/bean/po/BiologicalSamples.java
  2. 70
      tcm/src/main/java/com/ccsens/tcm/bean/po/BiologicalSamplesExample.java
  3. 4
      tcm/src/main/java/com/ccsens/tcm/bean/vo/BiologicalSamplesVo.java
  4. 46
      tcm/src/main/java/com/ccsens/tcm/service/PatientService.java
  5. 41
      tcm/src/main/java/com/ccsens/tcm/uitl/Constant.java
  6. 4
      tcm/src/main/resources/application.yml
  7. 2
      tcm/src/main/resources/mapper_dao/PatientDao.xml
  8. 35
      tcm/src/main/resources/mapper_raw/BiologicalSamplesMapper.xml
  9. 2
      util/src/main/java/com/ccsens/util/CodeEnum.java

11
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);

70
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<String> values) {
addCriterion("code in", values, "code");
return (Criteria) this;
}
public Criteria andCodeNotIn(List<String> 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;

4
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("采集时间")

46
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,22 +55,22 @@ 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) {
@ -80,14 +81,20 @@ public class PatientService implements IPatientService {
// throw new BaseException(CodeEnum.ZHUYUANIDCHONGFU);
// }
Hospital hospital = selUserIdToHosId(userId);
Inpatient inpatient = inpatientMapper.selectByPrimaryKey(param.getInpatientId());
if (inpatient == null) {
throw new BaseException(CodeEnum.PARAM_ERROR);
}
log.info("医院:{},对照组:{}", hospital, inpatient);
param.setHospitalId(hospital.getId());
PatientInformation patientInformation=new PatientInformation();
BeanUtils.copyProperties(param,patientInformation);
patientInformation.setId(snowflake.nextId());
// 生成编号
String num = hospital.getCode() + "";
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);
}
@ -348,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);
}

41
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{

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

2
tcm/src/main/resources/mapper_dao/PatientDao.xml

@ -391,7 +391,7 @@
t.user_id
</select>
<select id="selBiologicalSamples" resultType="com.ccsens.tcm.bean.vo.BiologicalSamplesVo$selBiolog">
select th.name,tbs.sample_type as sampleType, tpi.hospitalization,tbs.collect_time as collectTime,tbs.update_at as updateAt
select th.name,tbs.sample_type as sampleType, tpi.hospitalization, tbs.code, tbs.collect_time as collectTime,tbs.update_at as updateAt
from t_biological_samples tbs
left join t_patient_information tpi on tpi.id=tbs.patient_information_id and tpi.rec_status=0
left join t_hospital th on th.id=tpi.hospital_id and th.rec_status=0

35
tcm/src/main/resources/mapper_raw/BiologicalSamplesMapper.xml

@ -3,6 +3,7 @@
<mapper namespace="com.ccsens.tcm.persist.mapper.BiologicalSamplesMapper">
<resultMap id="BaseResultMap" type="com.ccsens.tcm.bean.po.BiologicalSamples">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="code" jdbcType="VARCHAR" property="code" />
<result column="sample_type" jdbcType="TINYINT" property="sampleType" />
<result column="patient_information_id" jdbcType="BIGINT" property="patientInformationId" />
<result column="collect_time" jdbcType="INTEGER" property="collectTime" />
@ -70,8 +71,8 @@
</where>
</sql>
<sql id="Base_Column_List">
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
</sql>
<select id="selectByExample" parameterType="com.ccsens.tcm.bean.po.BiologicalSamplesExample" resultMap="BaseResultMap">
select
@ -104,12 +105,14 @@
</if>
</delete>
<insert id="insert" parameterType="com.ccsens.tcm.bean.po.BiologicalSamples">
insert into t_biological_samples (id, sample_type, patient_information_id,
collect_time, user_id, created_at,
update_at, rec_status)
values (#{id,jdbcType=BIGINT}, #{sampleType,jdbcType=TINYINT}, #{patientInformationId,jdbcType=BIGINT},
#{collectTime,jdbcType=INTEGER}, #{userId,jdbcType=BIGINT}, #{createdAt,jdbcType=TIMESTAMP},
#{updateAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT})
insert into t_biological_samples (id, code, sample_type,
patient_information_id, collect_time, user_id,
created_at, update_at, rec_status
)
values (#{id,jdbcType=BIGINT}, #{code,jdbcType=VARCHAR}, #{sampleType,jdbcType=TINYINT},
#{patientInformationId,jdbcType=BIGINT}, #{collectTime,jdbcType=INTEGER}, #{userId,jdbcType=BIGINT},
#{createdAt,jdbcType=TIMESTAMP}, #{updateAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT}
)
</insert>
<insert id="insertSelective" parameterType="com.ccsens.tcm.bean.po.BiologicalSamples">
insert into t_biological_samples
@ -117,6 +120,9 @@
<if test="id != null">
id,
</if>
<if test="code != null">
code,
</if>
<if test="sampleType != null">
sample_type,
</if>
@ -143,6 +149,9 @@
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="code != null">
#{code,jdbcType=VARCHAR},
</if>
<if test="sampleType != null">
#{sampleType,jdbcType=TINYINT},
</if>
@ -178,6 +187,9 @@
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.code != null">
code = #{record.code,jdbcType=VARCHAR},
</if>
<if test="record.sampleType != null">
sample_type = #{record.sampleType,jdbcType=TINYINT},
</if>
@ -207,6 +219,7 @@
<update id="updateByExample" parameterType="map">
update t_biological_samples
set id = #{record.id,jdbcType=BIGINT},
code = #{record.code,jdbcType=VARCHAR},
sample_type = #{record.sampleType,jdbcType=TINYINT},
patient_information_id = #{record.patientInformationId,jdbcType=BIGINT},
collect_time = #{record.collectTime,jdbcType=INTEGER},
@ -221,6 +234,9 @@
<update id="updateByPrimaryKeySelective" parameterType="com.ccsens.tcm.bean.po.BiologicalSamples">
update t_biological_samples
<set>
<if test="code != null">
code = #{code,jdbcType=VARCHAR},
</if>
<if test="sampleType != null">
sample_type = #{sampleType,jdbcType=TINYINT},
</if>
@ -247,7 +263,8 @@
</update>
<update id="updateByPrimaryKey" parameterType="com.ccsens.tcm.bean.po.BiologicalSamples">
update t_biological_samples
set sample_type = #{sampleType,jdbcType=TINYINT},
set code = #{code,jdbcType=VARCHAR},
sample_type = #{sampleType,jdbcType=TINYINT},
patient_information_id = #{patientInformationId,jdbcType=BIGINT},
collect_time = #{collectTime,jdbcType=INTEGER},
user_id = #{userId,jdbcType=BIGINT},

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

@ -183,7 +183,7 @@ public enum CodeEnum {
ALREADY_UPLOAD_VIDEO(150,"您已经上传了视频,请勿重复提交",true),
ALREADY_UPLOAD_FORM(151,"请勿重复提交信息",true),
MESSAGEISNULL(152,"数据为空",true),
QUANTITYERROR(153,"住院号和患者id不对应",true),
QUANTITYERROR(153,"住院号不正确",true),
NOT_HOSPITAL(154,"未找到医院信息",true),
ZHUYUANIDCHONGFU(155,"住院号重复",true),
MEIYOUGAIYISHENG(156,"该医生信息查询不正确",true),

Loading…
Cancel
Save