fix: Bug#705 患者编辑字段不持久化修复

根因分析:
1. Patient实体/PatientBaseInfoDto缺少postalCode,hukouAddress,guardian*,patientDerived,companyAddress字段
2. PatientManageMapper.xml外层SELECT缺少这些字段导致查询不返回
3. handlePatientInfo使用updateById默认NOT_NULL策略导致null字段不更新
4. patientAddDialog.vue的reset()未初始化这些字段

修复内容:
- Patient.java: 补全缺失字段定义
- PatientBaseInfoDto.java: 补全缺失DTO字段
- PatientManageMapper.xml: SQL补全SELECT字段
- PatientInformationServiceImpl.java: updateById改为LambdaUpdateWrapper显式set所有字段
- patientAddDialog.vue: reset()/show()补全字段初始化
- V2026_0608_1: Flyway迁移脚本确保数据库字段存在
This commit is contained in:
2026-06-08 15:23:01 +08:00
parent 566ce61293
commit 207640f4ef
6 changed files with 217 additions and 11 deletions

View File

@@ -313,10 +313,59 @@ public class PatientInformationServiceImpl implements IPatientInformationService
patient.setDeceasedDate(patientInfoDto.getDeceasedDate()); // 死亡时间
patient.setNationalityCode(patientInfoDto.getNationalityCode());// 民族
patient.setActiveFlag(patientInfoDto.getActiveFlag());// 活动标识
patient.setCountryCode(patientInfoDto.getCountryCode());// 国家编码
patient.setPostalCode(patientInfoDto.getPostalCode());// 邮政编码
patient.setHukouAddress(patientInfoDto.getHukouAddress());// 户籍地址
patient.setGuardianName(patientInfoDto.getGuardianName());// 监护人姓名
patient.setGuardianRelation(patientInfoDto.getGuardianRelation());// 监护人关系
patient.setGuardianPhone(patientInfoDto.getGuardianPhone());// 监护人电话
patient.setGuardianIdType(patientInfoDto.getGuardianIdType());// 监护人证件类型
patient.setGuardianIdNo(patientInfoDto.getGuardianIdNo());// 监护人证件号码
patient.setGuardianAddress(patientInfoDto.getGuardianAddress());// 监护人地址
patient.setPatientDerived(patientInfoDto.getPatientDerived());// 患者来源
patient.setEducationLevel(patientInfoDto.getEducationLevel());// 文化程度
patient.setCompanyAddress(patientInfoDto.getCompanyAddress());// 单位地址
if (patientInfoDto.getId() != null) {
// 更新操作
patientService.updateById(patient);
// 更新操作 - 使用 LambdaUpdateWrapper 显式设置所有字段,确保 null 值也能正确更新
LambdaUpdateWrapper<Patient> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(Patient::getId, patient.getId())
.set(Patient::getName, patient.getName())
.set(Patient::getPyStr, patient.getPyStr())
.set(Patient::getWbStr, patient.getWbStr())
.set(Patient::getIdCard, patient.getIdCard())
.set(Patient::getBirthDate, patient.getBirthDate())
.set(Patient::getGenderEnum, patient.getGenderEnum())
.set(Patient::getPhone, patient.getPhone())
.set(Patient::getPrfsEnum, patient.getPrfsEnum())
.set(Patient::getWorkCompany, patient.getWorkCompany())
.set(Patient::getLinkName, patient.getLinkName())
.set(Patient::getLinkRelationCode, patient.getLinkRelationCode())
.set(Patient::getLinkTelcom, patient.getLinkTelcom())
.set(Patient::getAddress, patient.getAddress())
.set(Patient::getAddressProvince, patient.getAddressProvince())
.set(Patient::getAddressCity, patient.getAddressCity())
.set(Patient::getAddressDistrict, patient.getAddressDistrict())
.set(Patient::getAddressStreet, patient.getAddressStreet())
.set(Patient::getBloodAbo, patient.getBloodAbo())
.set(Patient::getBloodRh, patient.getBloodRh())
.set(Patient::getMaritalStatusEnum, patient.getMaritalStatusEnum())
.set(Patient::getDeceasedDate, patient.getDeceasedDate())
.set(Patient::getNationalityCode, patient.getNationalityCode())
.set(Patient::getActiveFlag, patient.getActiveFlag())
.set(Patient::getCountryCode, patient.getCountryCode())
.set(Patient::getPostalCode, patient.getPostalCode())
.set(Patient::getHukouAddress, patient.getHukouAddress())
.set(Patient::getGuardianName, patient.getGuardianName())
.set(Patient::getGuardianRelation, patient.getGuardianRelation())
.set(Patient::getGuardianPhone, patient.getGuardianPhone())
.set(Patient::getGuardianIdType, patient.getGuardianIdType())
.set(Patient::getGuardianIdNo, patient.getGuardianIdNo())
.set(Patient::getGuardianAddress, patient.getGuardianAddress())
.set(Patient::getPatientDerived, patient.getPatientDerived())
.set(Patient::getEducationLevel, patient.getEducationLevel())
.set(Patient::getCompanyAddress, patient.getCompanyAddress());
patientService.update(updateWrapper);
} else {
// 新增操作
patientService.save(patient);

View File

@@ -168,4 +168,65 @@ public class PatientBaseInfoDto {
*/
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/**
* 邮政编码
*/
private String postalCode;
/**
* 户籍地址
*/
private String hukouAddress;
/**
* 监护人姓名
*/
private String guardianName;
/**
* 监护人关系
*/
private Integer guardianRelation;
private String guardianRelation_enumText;
/**
* 监护人电话
*/
private String guardianPhone;
/**
* 监护人证件类型
*/
private String guardianIdType;
/**
* 监护人证件号码
*/
private String guardianIdNo;
/**
* 监护人地址
*/
private String guardianAddress;
/**
* 患者来源
*/
private String patientDerived;
/**
* 文化程度
*/
private String educationLevel;
/**
* 单位地址
*/
private String companyAddress;
/**
* 国家编码
*/
private String countryCode;
}

View File

@@ -0,0 +1,25 @@
-- Bug #705: 患者管理修改后字段回显丢失修复
-- 添加邮政编码、户籍地址、监护人信息、患者来源等缺失字段到adm_patient表
-- 邮政编码
ALTER TABLE adm_patient ADD COLUMN IF NOT EXISTS postal_code VARCHAR(10);
-- 户籍地址
ALTER TABLE adm_patient ADD COLUMN IF NOT EXISTS hukou_address VARCHAR(500);
-- 监护人信息
ALTER TABLE adm_patient ADD COLUMN IF NOT EXISTS guardian_name VARCHAR(50);
ALTER TABLE adm_patient ADD COLUMN IF NOT EXISTS guardian_relation INTEGER;
ALTER TABLE adm_patient ADD COLUMN IF NOT EXISTS guardian_phone VARCHAR(20);
ALTER TABLE adm_patient ADD COLUMN IF NOT EXISTS guardian_id_type VARCHAR(10);
ALTER TABLE adm_patient ADD COLUMN IF NOT EXISTS guardian_id_no VARCHAR(30);
ALTER TABLE adm_patient ADD COLUMN IF NOT EXISTS guardian_address VARCHAR(500);
-- 患者来源
ALTER TABLE adm_patient ADD COLUMN IF NOT EXISTS patient_derived VARCHAR(50);
-- 文化程度
ALTER TABLE adm_patient ADD COLUMN IF NOT EXISTS education_level VARCHAR(20);
-- 单位地址
ALTER TABLE adm_patient ADD COLUMN IF NOT EXISTS company_address VARCHAR(500);

View File

@@ -38,7 +38,19 @@
pt.link_telcom,
pt.link_jsons,
pt.organization_id,
pt.create_time
pt.create_time,
pt.postal_code,
pt.hukou_address,
pt.guardian_name,
pt.guardian_relation,
pt.guardian_phone,
pt.guardian_id_type,
pt.guardian_id_no,
pt.guardian_address,
pt.patient_derived,
pt.education_level,
pt.company_address,
pt.country_code
FROM (
SELECT
(
@@ -81,7 +93,19 @@
p.link_telcom,
p.link_jsons,
p.organization_id,
p.create_time
p.create_time,
p.postal_code,
p.hukou_address,
p.guardian_name,
p.guardian_relation,
p.guardian_phone,
p.guardian_id_type,
p.guardian_id_no,
p.guardian_address,
p.patient_derived,
p.education_level,
p.company_address,
p.country_code
FROM adm_patient p
where p.delete_flag = '0'
) AS pt

View File

@@ -130,4 +130,37 @@ public class Patient extends HisBaseEntity {
/** 机构Id */
private Long organizationId;
/** 邮政编码 */
private String postalCode;
/** 户籍地址 */
private String hukouAddress;
/** 监护人姓名 */
private String guardianName;
/** 监护人关系 */
private Integer guardianRelation;
/** 监护人电话 */
private String guardianPhone;
/** 监护人证件类型 */
private String guardianIdType;
/** 监护人证件号码 */
private String guardianIdNo;
/** 监护人地址 */
private String guardianAddress;
/** 患者来源 */
private String patientDerived;
/** 文化程度 */
private String educationLevel;
/** 单位地址 */
private String companyAddress;
}

View File

@@ -447,9 +447,9 @@
v-model="form.deceasedDate"
type="datetime"
placeholder="请选择时间"
format="YYYY/MM/DD HH:mm:ss"
format="YYYY-MM-DD HH:mm:ss"
:disabled="isViewMode"
value-format="YYYY/MM/DD HH:mm:ss"
value-format="YYYY-MM-DD HH:mm:ss"
/>
</el-form-item>
</el-col>
@@ -702,7 +702,7 @@ const getGenderOptions = async () => {
const getEducationLevelOptions = async () => {
try {
// 从字典管理获取文化程度数据
const response = await getDicts('文化程度');
const response = await getDicts('education_level');
console.log('获取到的文化程度原始数据:', response);
// 确保数据是数组
@@ -1403,10 +1403,8 @@ const getCountryCodeOptions = async () => {
// 显示弹框
function show() {
// 重置为新增模式
isEditMode.value = false;
title.value = '新增患者';
originalFormData.value = {};
// 重置表单为初始状态
reset();
// queryParams.roleId = props.roleId;
getList();
@@ -1452,6 +1450,22 @@ function reset() {
busNo: undefined,
organizationId: undefined,
birthDate: undefined,
postalCode: undefined,
hukouAddress: undefined,
hukouAddressSelect: undefined,
hukouAddressProvince: undefined,
hukouAddressCity: undefined,
hukouAddressDistrict: undefined,
hukouAddressStreet: undefined,
companyAddress: undefined,
patientDerived: undefined,
educationLevel: undefined,
guardianName: undefined,
guardianRelation: undefined,
guardianPhone: undefined,
guardianIdType: undefined,
guardianIdNo: undefined,
guardianAddress: undefined,
};
// 重置编辑模式状态
isEditMode.value = false;