枚举类显示查询相关更新

This commit is contained in:
liuhongrui
2025-03-03 13:54:24 +08:00
parent 4d1d2db899
commit 94b06a84d2
10 changed files with 71 additions and 28 deletions

View File

@@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import com.core.common.utils.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@@ -12,11 +11,16 @@ import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.core.common.core.domain.R; import com.core.common.core.domain.R;
import com.core.common.enums.AssignSeqEnum; import com.core.common.enums.AssignSeqEnum;
import com.core.common.utils.AssignSeqUtil;
import com.core.common.utils.ChineseConvertUtils;
import com.core.common.utils.MessageUtils;
import com.core.common.utils.StringUtils;
import com.core.common.utils.bean.BeanUtils; import com.core.common.utils.bean.BeanUtils;
import com.openhis.administration.domain.Patient; import com.openhis.administration.domain.Patient;
import com.openhis.administration.service.IPatientService; import com.openhis.administration.service.IPatientService;
import com.openhis.common.constant.PromptMsgConstant; import com.openhis.common.constant.PromptMsgConstant;
import com.openhis.common.enums.*; import com.openhis.common.enums.*;
import com.openhis.common.utils.EnumUtils;
import com.openhis.web.patientmanage.dto.PatientInformationDto; import com.openhis.web.patientmanage.dto.PatientInformationDto;
import com.openhis.web.patientmanage.dto.PatientListDto; import com.openhis.web.patientmanage.dto.PatientListDto;
import com.openhis.web.patientmanage.mapper.PatientManageMapper; import com.openhis.web.patientmanage.mapper.PatientManageMapper;
@@ -171,17 +175,18 @@ public class PatientInformationController {
// 使用基础采番设置病人ID // 使用基础采番设置病人ID
String code = assignSeqUtil.getSeq(AssignSeqEnum.PATIENT_NUM.getPrefix()); String code = assignSeqUtil.getSeq(AssignSeqEnum.PATIENT_NUM.getPrefix());
patient.setBusNo(code); patient.setBusNo(code);
// 设置生日
patient.setBirthDate(patientService.extractBirthday(patient.getIdCard()));
// 设置机构ID // 设置机构ID
patient.setOrganizationId(organizationId); patient.setOrganizationId(organizationId);
// 设置生日
patient.setBirthDate(patientService.extractBirthday(patient.getIdCard()));
// 设置拼音首拼 // 设置拼音首拼
patient.setPyStr(ChineseConvertUtils.toPinyinFirstLetter(patient.getName())); patient.setPyStr(ChineseConvertUtils.toPinyinFirstLetter(patient.getName()));
// 设置五笔首拼 // 设置五笔首拼
patient.setWbStr(ChineseConvertUtils.toWBFirstLetter(patient.getName())); patient.setWbStr(ChineseConvertUtils.toWBFirstLetter(patient.getName()));
// 设置地址 // 设置地址
String fullAddress = stringUtils.joinStrings(patient.getAddressProvince(), String fullAddress = stringUtils.joinStrings(patient.getAddressProvince(), patient.getAddressCity(),
patient.getAddressCity(), patient.getAddressDistrict(), patient.getAddressStreet(),patient.getAddress()); patient.getAddressDistrict(), patient.getAddressStreet(), patient.getAddress());
patient.setAddress(fullAddress); patient.setAddress(fullAddress);
// 调用服务层保存病人信息 // 调用服务层保存病人信息
@@ -212,18 +217,15 @@ public class PatientInformationController {
// 设置五笔首拼 // 设置五笔首拼
patient.setWbStr(ChineseConvertUtils.toWBFirstLetter(patient.getName())); patient.setWbStr(ChineseConvertUtils.toWBFirstLetter(patient.getName()));
// 设置地址 // 设置地址
String fullAddress = stringUtils.joinStrings(patient.getAddressProvince(), String fullAddress = stringUtils.joinStrings(patient.getAddressProvince(), patient.getAddressCity(),
patient.getAddressCity(), patient.getAddressDistrict(), patient.getAddressStreet(),patient.getAddress()); patient.getAddressDistrict(), patient.getAddressStreet(), patient.getAddress());
patient.setAddress(fullAddress); patient.setAddress(fullAddress);
// 调用服务层更新病人信息 // 调用服务层更新病人信息
boolean updateSuccess = patientService.updateById(patient); return patientService.updateById(patient)
? R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00001, new Object[] {"病人信息"}))
: R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00007, null));
if (!updateSuccess) {
return R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00007, null));
}
return R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00001, new Object[] {"病人信息"}));
} }
/** /**
@@ -249,6 +251,24 @@ public class PatientInformationController {
Page<PatientInformationDto> patientInformationPage = new Page<>(pageNo, pageSize, total); Page<PatientInformationDto> patientInformationPage = new Page<>(pageNo, pageSize, total);
patientInformationPage.setRecords(listPatients); patientInformationPage.setRecords(listPatients);
// 性别枚举类回显赋值
patientInformationPage.getRecords().forEach(
e -> e.setGenderEnum_text(EnumUtils.getInfoByValue(AdministrativeGender.class, e.getGenderEnum())));
// 婚姻状态枚举类回显赋值
patientInformationPage.getRecords().forEach(
e -> e.setMaritalStatusEnum_text(EnumUtils.getInfoByValue(MaritalStatus.class, e.getMaritalStatusEnum())));
// 职业编码枚举类回显赋值
patientInformationPage.getRecords()
.forEach(e -> e.setPrfsEnum_text(EnumUtils.getInfoByValue(OccupationType.class, e.getPrfsEnum())));
// 血型ABO枚举类回显赋值
patientInformationPage.getRecords()
.forEach(e -> e.setBloodAbo_text(EnumUtils.getInfoByValue(BloodTypeABO.class, e.getBloodAbo())));
// 血型RH枚举类回显赋值
patientInformationPage.getRecords()
.forEach(e -> e.setBloodRh_text(EnumUtils.getInfoByValue(BloodTypeRH.class, e.getBloodRh())));
// 家庭关系枚举类回显赋值
patientInformationPage.getRecords().forEach(e -> e
.setLinkRelationCode_text(EnumUtils.getInfoByValue(FamilyRelationshipType.class, e.getLinkRelationCode())));
return R.ok(patientInformationPage); return R.ok(patientInformationPage);
} }

View File

@@ -2,9 +2,13 @@ package com.openhis.web.patientmanage.dto;
import java.util.Date; import java.util.Date;
import com.openhis.common.enums.AdministrativeGender; import javax.validation.constraints.NotBlank;
import com.openhis.common.enums.MaritalStatus; import javax.validation.constraints.NotNull;
import com.openhis.common.enums.OccupationType; import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data; import lombok.Data;
@@ -17,6 +21,8 @@ import lombok.Data;
@Data @Data
public class PatientInformationDto { public class PatientInformationDto {
/** ID */
@JsonSerialize(using = ToStringSerializer.class)
private Long id; private Long id;
/** 活动标记 */ /** 活动标记 */
@@ -26,6 +32,7 @@ public class PatientInformationDto {
private Integer tempFlag; private Integer tempFlag;
/** 患者姓名 */ /** 患者姓名 */
@NotBlank(message = "患者姓名不能为空")
private String name; private String name;
/** 患者其他名称 */ /** 患者其他名称 */
@@ -36,6 +43,7 @@ public class PatientInformationDto {
/** 性别编码 */ /** 性别编码 */
private Integer genderEnum; private Integer genderEnum;
private String genderEnum_text;
/** 生日 */ /** 生日 */
private Date birthDate; private Date birthDate;
@@ -45,11 +53,17 @@ public class PatientInformationDto {
/** 婚姻状态 */ /** 婚姻状态 */
private Integer maritalStatusEnum; private Integer maritalStatusEnum;
private String maritalStatusEnum_text;
/** 职业编码 */ /** 职业编码 */
private Integer prfsEnum; private Integer prfsEnum;
private String prfsEnum_text;
/** 电话 */ /** 电话 */
@NotNull(message = "电话不能为空")
@NotBlank(message = "电话不能为空")
@Size(min = 11, max = 11, message = "电话长度必须为11位")
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "电话格式不正确")
private String phone; private String phone;
/** 地址 */ /** 地址 */
@@ -74,6 +88,9 @@ public class PatientInformationDto {
private String nationalityCode; private String nationalityCode;
/** 身份证号 */ /** 身份证号 */
@NotNull(message = "身份证号不能为空")
@Size(min = 18, max = 18, message = "身份证号必须是18位")
@Pattern(regexp = "^[0-9Xx]{18}$", message = "身份证号格式不正确")
private String idCard; private String idCard;
/** 拼音码 */ /** 拼音码 */
@@ -84,9 +101,11 @@ public class PatientInformationDto {
/** 血型ABO */ /** 血型ABO */
private Integer bloodAbo; private Integer bloodAbo;
private String bloodAbo_text;
/** 血型RH */ /** 血型RH */
private Integer bloodRh; private Integer bloodRh;
private String bloodRh_text;
/** 工作单位 */ /** 工作单位 */
private String workCompany; private String workCompany;
@@ -102,8 +121,11 @@ public class PatientInformationDto {
/** 联系人关系 */ /** 联系人关系 */
private Integer linkRelationCode; private Integer linkRelationCode;
private String linkRelationCode_text;
/** 联系人电话 */ /** 联系人电话 */
@Size(min = 11, max = 11, message = "电话长度必须为11位")
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "电话格式不正确")
private String linkTelcom; private String linkTelcom;
/** 其他联系人 */ /** 其他联系人 */
@@ -118,7 +140,4 @@ public class PatientInformationDto {
/** 创建时间 */ /** 创建时间 */
private Date createTime; private Date createTime;
/** 删除标识 */
// 0 为未删除1 为删除
private String deleteFlag;
} }

View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.openhis.web.patientmanage.mapper.PatientManageMapper"> <mapper namespace="com.openhis.web.patientmanage.mapper.PatientManageMapper">
<!-- 病人信息相关查询-->
<select id="getPatientPage" resultType="com.openhis.web.patientmanage.dto.PatientInformationDto"> <select id="getPatientPage" resultType="com.openhis.web.patientmanage.dto.PatientInformationDto">
SELECT SELECT
pt.id, pt.id,
@@ -97,4 +98,7 @@
</if> </if>
</where> </where>
</select> </select>
<!-- 门诊记录相关查询-->
</mapper> </mapper>

View File

@@ -6,7 +6,7 @@ import lombok.Getter;
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public enum AdministrativeGender { public enum AdministrativeGender implements ValueEnum {
MALE(1, "male", "男性"), MALE(1, "male", "男性"),
FEMALE(2, "female", "女性"), FEMALE(2, "female", "女性"),
OTHER(3, "other", "其他"), OTHER(3, "other", "其他"),

View File

@@ -13,7 +13,7 @@ import lombok.Getter;
*/ */
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public enum BloodTypeABO { public enum BloodTypeABO implements ValueEnum {
TYPE_A(1, "typeA", "A 型"), TYPE_A(1, "typeA", "A 型"),
TYPE_B(2, "typeB", "B 型"), TYPE_B(2, "typeB", "B 型"),

View File

@@ -12,7 +12,7 @@ import lombok.Getter;
*/ */
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public enum BloodTypeRH { public enum BloodTypeRH implements ValueEnum{
TYPE_RH_NEGATIVEB(1, "typeRHNegative", "Rh 阴性"), TYPE_RH_NEGATIVEB(1, "typeRHNegative", "Rh 阴性"),
TYPE_RH_POSITIVE(2, "typeRHPositive", "Rh 阳性"), TYPE_RH_POSITIVE(2, "typeRHPositive", "Rh 阳性"),

View File

@@ -12,7 +12,7 @@ import lombok.Getter;
*/ */
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public enum FamilyRelationshipType { public enum FamilyRelationshipType implements ValueEnum {
SELF(1, "01", "本人"), SELF(1, "01", "本人"),
HOUSEHOLDER(2, "02", "户主"), HOUSEHOLDER(2, "02", "户主"),

View File

@@ -6,7 +6,7 @@ import lombok.Getter;
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public enum MaritalStatus { public enum MaritalStatus implements ValueEnum {
UNMARRIED(10, "10", "未婚"), UNMARRIED(10, "10", "未婚"),
MARRIED(20, "20", "已婚"), MARRIED(20, "20", "已婚"),

View File

@@ -6,7 +6,7 @@ import lombok.Getter;
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public enum OccupationType { public enum OccupationType implements ValueEnum{
STATE_CIVIL_SERVANT(11, "11", "国家公务员"), STATE_CIVIL_SERVANT(11, "11", "国家公务员"),
PROFESSIONAL(13, "13", "专业技术人员"), PROFESSIONAL(13, "13", "专业技术人员"),
CLERK(17, "17", "职员"), CLERK(17, "17", "职员"),

View File

@@ -1,6 +1,5 @@
package com.openhis.administration.service.impl; package com.openhis.administration.service.impl;
import java.time.Instant;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
@@ -39,8 +38,9 @@ public class PatientServiceImpl extends ServiceImpl<PatientMapper, Patient> impl
// 将生日字符串转换为 LocalDate // 将生日字符串转换为 LocalDate
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
LocalDate date = LocalDate.parse(birthdayStr, formatter); LocalDate date = LocalDate.parse(birthdayStr, formatter);
// 使用系统默认时区,将 LocalDate 转换为 Date
return Date.from(Instant.from(date.atStartOfDay(ZoneId.systemDefault()))); // 将 LocalDate 转换为 java.util.Date
return Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
} }