168 入科分配床位填写的住院医生、主治医生、责任护士字段的内容双击查看未显示。
This commit is contained in:
@@ -14,10 +14,13 @@ import com.core.common.utils.SecurityUtils;
|
||||
import com.core.common.utils.StringUtils;
|
||||
import com.openhis.administration.domain.Encounter;
|
||||
import com.openhis.administration.domain.EncounterLocation;
|
||||
import com.openhis.administration.domain.EncounterParticipant;
|
||||
import com.openhis.administration.domain.Practitioner;
|
||||
import com.openhis.administration.service.IEncounterLocationService;
|
||||
import com.openhis.administration.service.IEncounterParticipantService;
|
||||
import com.openhis.administration.service.IEncounterService;
|
||||
import com.openhis.administration.service.ILocationService;
|
||||
import com.openhis.administration.service.IPractitionerService;
|
||||
import com.openhis.common.constant.CommonConstants;
|
||||
import com.openhis.common.enums.*;
|
||||
import com.openhis.common.utils.EnumUtils;
|
||||
@@ -95,6 +98,9 @@ public class ATDManageAppServiceImpl implements IATDManageAppService {
|
||||
@Resource
|
||||
private IServiceRequestService serviceRequestService;
|
||||
|
||||
@Resource
|
||||
private IPractitionerService practitionerService;
|
||||
|
||||
/**
|
||||
* 入出转管理页面初始化
|
||||
*
|
||||
@@ -215,24 +221,150 @@ public class ATDManageAppServiceImpl implements IATDManageAppService {
|
||||
*/
|
||||
@Override
|
||||
public R<?> getAdmissionPatientInfo(Long encounterId) {
|
||||
// 查询住院患者详细信息
|
||||
log.info("========== 查询患者信息 - encounterId: {} ==========", encounterId);
|
||||
Integer active = EncounterActivityStatus.ACTIVE.getValue();
|
||||
String primaryNurse = ParticipantType.PRIMARY_NURSE.getCode();
|
||||
String attendingDoctor = ParticipantType.ATTENDING_DOCTOR.getCode();
|
||||
String admittingDoctor = ParticipantType.ADMITTING_DOCTOR.getCode();
|
||||
String chiefDoctor = ParticipantType.CHIEF_DOCTOR.getCode();
|
||||
log.info("查询参数 - encounterId: {}, active: {} (type: {}), primaryNurse: {} (type: {}), attendingDoctor: {} (type: {}), admittingDoctor: {} (type: {}), chiefDoctor: {} (type: {})",
|
||||
encounterId, active, active.getClass().getSimpleName(),
|
||||
primaryNurse, primaryNurse.getClass().getSimpleName(),
|
||||
attendingDoctor, attendingDoctor.getClass().getSimpleName(),
|
||||
admittingDoctor, admittingDoctor.getClass().getSimpleName(),
|
||||
chiefDoctor, chiefDoctor.getClass().getSimpleName());
|
||||
|
||||
// 先通过简单的 SQL 查询患者基本信息
|
||||
AdmissionPatientInfoDto admissionPatientInfoDto
|
||||
= atdManageAppMapper.selectAdmissionPatientInfo(encounterId, EncounterActivityStatus.ACTIVE.getValue(),
|
||||
= atdManageAppMapper.selectAdmissionPatientInfo(encounterId, active,
|
||||
LocationForm.WARD.getValue(), LocationForm.HOUSE.getValue(), LocationForm.BED.getValue(),
|
||||
ParticipantType.PRIMARY_NURSE.getCode(), ParticipantType.ATTENDING_DOCTOR.getCode(),
|
||||
ParticipantType.ADMITTING_DOCTOR.getCode(), ParticipantType.CHIEF_DOCTOR.getCode());
|
||||
// 年龄
|
||||
if (admissionPatientInfoDto.getBirthDate() != null) {
|
||||
admissionPatientInfoDto.setAge(AgeCalculatorUtil.getAge(admissionPatientInfoDto.getBirthDate()));
|
||||
primaryNurse, attendingDoctor, admittingDoctor, chiefDoctor);
|
||||
|
||||
// 从 EncounterParticipant 表手动获取医生护士信息
|
||||
List<EncounterParticipant> participantList = encounterParticipantService.getEncounterParticipantList(encounterId);
|
||||
log.info("从 EncounterParticipant 获取到 {} 条记录", participantList.size());
|
||||
|
||||
// 调试:打印所有 participant 的详细信息
|
||||
for (EncounterParticipant ep : participantList) {
|
||||
log.info("调试 - typeCode: '{}', practitionerId: {}, statusEnum: {}, deleteFlag: '{}'",
|
||||
ep.getTypeCode(), ep.getPractitionerId(), ep.getStatusEnum(), ep.getDeleteFlag());
|
||||
}
|
||||
// 性别
|
||||
admissionPatientInfoDto.setGenderEnum_enumText(
|
||||
EnumUtils.getInfoByValue(AdministrativeGender.class, admissionPatientInfoDto.getGenderEnum()));
|
||||
// 病情
|
||||
admissionPatientInfoDto.setPriorityEnum_enumText(
|
||||
EnumUtils.getInfoByValue(PriorityLevel.class, admissionPatientInfoDto.getPriorityEnum()));
|
||||
// 获取入院体征
|
||||
getAdmissionSigns(encounterId, admissionPatientInfoDto);
|
||||
|
||||
// 查找各个角色 - 使用 Integer 类型进行比较
|
||||
Integer primaryNurseValue = ParticipantType.PRIMARY_NURSE.getValue();
|
||||
Integer attendingDoctorValue = ParticipantType.ATTENDING_DOCTOR.getValue();
|
||||
Integer admittingDoctorValue = ParticipantType.ADMITTING_DOCTOR.getValue();
|
||||
Integer chiefDoctorValue = ParticipantType.CHIEF_DOCTOR.getValue();
|
||||
|
||||
log.info("枚举值 - primaryNurse: {} ({})", primaryNurseValue, primaryNurse);
|
||||
log.info("枚举值 - attendingDoctor: {} ({})", attendingDoctorValue, attendingDoctor);
|
||||
log.info("枚举值 - admittingDoctor: {} ({})", admittingDoctorValue, admittingDoctor);
|
||||
log.info("枚举值 - chiefDoctor: {} ({})", chiefDoctorValue, chiefDoctor);
|
||||
|
||||
// 查找各个角色
|
||||
Long primaryNurseId = null;
|
||||
String primaryNurseName = null;
|
||||
Long attendingDoctorId = null;
|
||||
String attendingDoctorName = null;
|
||||
Long admittingDoctorId = null;
|
||||
String admittingDoctorName = null;
|
||||
Long chiefDoctorId = null;
|
||||
String chiefDoctorName = null;
|
||||
|
||||
for (EncounterParticipant ep : participantList) {
|
||||
if (ep.getStatusEnum() == null || !ep.getStatusEnum().equals(active)) {
|
||||
log.info("跳过 - statusEnum: {} vs active: {}", ep.getStatusEnum(), active);
|
||||
continue;
|
||||
}
|
||||
if (ep.getTypeCode() == null) {
|
||||
log.info("跳过 - typeCode 为空");
|
||||
continue;
|
||||
}
|
||||
|
||||
// 尝试将 typeCode 转换为 Integer 进行比较
|
||||
Integer typeCodeValue = null;
|
||||
try {
|
||||
typeCodeValue = Integer.parseInt(ep.getTypeCode().trim());
|
||||
} catch (NumberFormatException e) {
|
||||
log.warn("typeCode 无法转换为 Integer: {}", ep.getTypeCode());
|
||||
}
|
||||
|
||||
log.info("检查 typeCode: {} (Integer: {}) vs primaryNurseValue: {}, attendingDoctorValue: {}, admittingDoctorValue: {}, chiefDoctorValue: {}",
|
||||
ep.getTypeCode(), typeCodeValue, primaryNurseValue, attendingDoctorValue, admittingDoctorValue, chiefDoctorValue);
|
||||
|
||||
// 根据 typeCode 的 Integer 值匹配并获取 practitioner 名称
|
||||
if (typeCodeValue != null && typeCodeValue.equals(primaryNurseValue)) {
|
||||
primaryNurseId = ep.getPractitionerId();
|
||||
// 查询 practitioner 名称
|
||||
if (primaryNurseId != null) {
|
||||
Practitioner practitioner = practitionerService.getById(primaryNurseId);
|
||||
if (practitioner != null) {
|
||||
primaryNurseName = practitioner.getName();
|
||||
}
|
||||
}
|
||||
log.info("找到责任护士 - id: {}, name: {}", primaryNurseId, primaryNurseName);
|
||||
} else if (typeCodeValue != null && typeCodeValue.equals(attendingDoctorValue)) {
|
||||
attendingDoctorId = ep.getPractitionerId();
|
||||
if (attendingDoctorId != null) {
|
||||
Practitioner practitioner = practitionerService.getById(attendingDoctorId);
|
||||
if (practitioner != null) {
|
||||
attendingDoctorName = practitioner.getName();
|
||||
}
|
||||
}
|
||||
log.info("找到主治医生 - id: {}, name: {}", attendingDoctorId, attendingDoctorName);
|
||||
} else if (typeCodeValue != null && typeCodeValue.equals(admittingDoctorValue)) {
|
||||
admittingDoctorId = ep.getPractitionerId();
|
||||
if (admittingDoctorId != null) {
|
||||
Practitioner practitioner = practitionerService.getById(admittingDoctorId);
|
||||
if (practitioner != null) {
|
||||
admittingDoctorName = practitioner.getName();
|
||||
}
|
||||
}
|
||||
log.info("找到入院医生 - id: {}, name: {}", admittingDoctorId, admittingDoctorName);
|
||||
} else if (typeCodeValue != null && typeCodeValue.equals(chiefDoctorValue)) {
|
||||
chiefDoctorId = ep.getPractitionerId();
|
||||
if (chiefDoctorId != null) {
|
||||
Practitioner practitioner = practitionerService.getById(chiefDoctorId);
|
||||
if (practitioner != null) {
|
||||
chiefDoctorName = practitioner.getName();
|
||||
}
|
||||
}
|
||||
log.info("找到主任医生 - id: {}, name: {}", chiefDoctorId, chiefDoctorName);
|
||||
} else {
|
||||
log.info("未匹配到任何角色 typeCode: {} (value: {})", ep.getTypeCode(), typeCodeValue);
|
||||
}
|
||||
}
|
||||
|
||||
// 手动设置医生护士信息到 DTO
|
||||
if (admissionPatientInfoDto != null) {
|
||||
admissionPatientInfoDto.setPrimaryNurseId(primaryNurseId);
|
||||
admissionPatientInfoDto.setPrimaryNurseName(primaryNurseName);
|
||||
admissionPatientInfoDto.setAttendingDoctorId(attendingDoctorId);
|
||||
admissionPatientInfoDto.setAttendingDoctorName(attendingDoctorName);
|
||||
admissionPatientInfoDto.setAdmittingDoctorId(admittingDoctorId);
|
||||
admissionPatientInfoDto.setAdmittingDoctorName(admittingDoctorName);
|
||||
admissionPatientInfoDto.setChiefDoctorId(chiefDoctorId);
|
||||
admissionPatientInfoDto.setChiefDoctorName(chiefDoctorName);
|
||||
|
||||
// 年龄
|
||||
if (admissionPatientInfoDto.getBirthDate() != null) {
|
||||
admissionPatientInfoDto.setAge(AgeCalculatorUtil.getAge(admissionPatientInfoDto.getBirthDate()));
|
||||
}
|
||||
// 性别
|
||||
admissionPatientInfoDto.setGenderEnum_enumText(
|
||||
EnumUtils.getInfoByValue(AdministrativeGender.class, admissionPatientInfoDto.getGenderEnum()));
|
||||
// 病情
|
||||
admissionPatientInfoDto.setPriorityEnum_enumText(
|
||||
EnumUtils.getInfoByValue(PriorityLevel.class, admissionPatientInfoDto.getPriorityEnum()));
|
||||
// 获取入院体征
|
||||
getAdmissionSigns(encounterId, admissionPatientInfoDto);
|
||||
}
|
||||
|
||||
log.info("查询结果 - admittingDoctorId: {}, attendingDoctorId: {}, chiefDoctorId: {}, primaryNurseId: {}",
|
||||
admissionPatientInfoDto != null ? admissionPatientInfoDto.getAdmittingDoctorId() : "null",
|
||||
admissionPatientInfoDto != null ? admissionPatientInfoDto.getAttendingDoctorId() : "null",
|
||||
admissionPatientInfoDto != null ? admissionPatientInfoDto.getChiefDoctorId() : "null",
|
||||
admissionPatientInfoDto != null ? admissionPatientInfoDto.getPrimaryNurseId() : "null");
|
||||
return R.ok(admissionPatientInfoDto);
|
||||
}
|
||||
|
||||
@@ -288,6 +420,7 @@ public class ATDManageAppServiceImpl implements IATDManageAppService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<?> admissionBedAssignment(AdmissionPatientInfoDto admissionPatientInfoDto) {
|
||||
log.info("===== admissionBedAssignment 开始 =====");
|
||||
|
||||
// 住院id
|
||||
Long encounterId = admissionPatientInfoDto.getEncounterId();
|
||||
@@ -301,7 +434,10 @@ public class ATDManageAppServiceImpl implements IATDManageAppService {
|
||||
Long targetBedId = admissionPatientInfoDto.getTargetBedId();
|
||||
|
||||
// 进入编辑患者信息,不更换床位
|
||||
if (Whether.YES.getCode().equals(admissionPatientInfoDto.getEditFlag())) {
|
||||
if ("1".equals(admissionPatientInfoDto.getEditFlag())) {
|
||||
log.info("编辑模式 - encounterId: {}, admittingDoctorId: {}, attendingDoctorId: {}, chiefDoctorId: {}, primaryNurseId: {}",
|
||||
encounterId, admissionPatientInfoDto.getAdmittingDoctorId(), admissionPatientInfoDto.getAttendingDoctorId(),
|
||||
admissionPatientInfoDto.getChiefDoctorId(), admissionPatientInfoDto.getPrimaryNurseId());
|
||||
// 更新患者病情(如果提供了)
|
||||
if (admissionPatientInfoDto.getPriorityEnum() != null) {
|
||||
encounterService.updatePriorityEnumById(encounterId, admissionPatientInfoDto.getPriorityEnum());
|
||||
@@ -329,6 +465,13 @@ public class ATDManageAppServiceImpl implements IATDManageAppService {
|
||||
encounterParticipantService.creatEncounterParticipants(encounterId, startTime,
|
||||
admissionPatientInfoDto.getChiefDoctorId(), ParticipantType.CHIEF_DOCTOR.getCode());
|
||||
}
|
||||
// 保存后立即查询确认数据
|
||||
List<EncounterParticipant> savedParticipants = encounterParticipantService.getEncounterParticipantList(encounterId);
|
||||
log.info("保存后查询参与者 - encounterId: {}, 数量: {}", encounterId, savedParticipants.size());
|
||||
for (EncounterParticipant ep : savedParticipants) {
|
||||
log.info("参与者详情 - typeCode: {}, practitionerId: {}, statusEnum: {}",
|
||||
ep.getTypeCode(), ep.getPractitionerId(), ep.getStatusEnum());
|
||||
}
|
||||
// 更新入院体征(在事务外执行,避免影响参与者数据保存)
|
||||
try {
|
||||
saveOrUpdateAdmissionSigns(encounterId, admissionPatientInfoDto, startTime);
|
||||
@@ -338,6 +481,11 @@ public class ATDManageAppServiceImpl implements IATDManageAppService {
|
||||
return R.ok("患者信息更新成功");
|
||||
}
|
||||
|
||||
// 新分配床位时,校验床位信息
|
||||
if (targetBedId == null || admissionPatientInfoDto.getTargetHouseId() == null) {
|
||||
return R.fail("床位分配失败,请选择有效的床位");
|
||||
}
|
||||
|
||||
// 判断患者是否已经在床
|
||||
if (oldBedId != null) {
|
||||
// 判断目标床位是否已经被占用
|
||||
|
||||
@@ -289,49 +289,49 @@
|
||||
LIMIT 1
|
||||
) AS ward ON ward.encounter_id = ae.id
|
||||
LEFT JOIN (
|
||||
SELECT aep.encounter_id,
|
||||
pra.id AS practitioner_id,
|
||||
pra."name" AS practitioner_name
|
||||
FROM adm_encounter_participant aep
|
||||
LEFT JOIN adm_practitioner pra ON aep.practitioner_id = pra.id AND pra.delete_flag = '0'
|
||||
WHERE aep.status_enum = #{active}
|
||||
AND aep.delete_flag = '0'
|
||||
AND aep.type_code = #{primaryNurse}
|
||||
LIMIT 1
|
||||
) AS primaryNurse ON primaryNurse.encounter_id = ae.id
|
||||
SELECT aep.encounter_id,
|
||||
aep.practitioner_id AS practitioner_id,
|
||||
pra."name" AS practitioner_name
|
||||
FROM adm_encounter_participant aep
|
||||
LEFT JOIN adm_practitioner pra ON aep.practitioner_id = pra.id AND pra.delete_flag = '0'
|
||||
WHERE aep.status_enum = #{active}
|
||||
AND aep.delete_flag = '0'
|
||||
AND aep.type_code::text = CAST(#{primaryNurse} AS TEXT)
|
||||
LIMIT 1
|
||||
) AS primaryNurse ON primaryNurse.encounter_id = ae.id
|
||||
LEFT JOIN (
|
||||
SELECT aep.encounter_id,
|
||||
pra.id AS practitioner_id,
|
||||
pra."name" AS practitioner_name
|
||||
FROM adm_encounter_participant aep
|
||||
LEFT JOIN adm_practitioner pra ON aep.practitioner_id = pra.id AND pra.delete_flag = '0'
|
||||
WHERE aep.status_enum = #{active}
|
||||
AND aep.delete_flag = '0'
|
||||
AND aep.type_code = #{attendingDoctor}
|
||||
LIMIT 1
|
||||
) AS attendingDoctor ON attendingDoctor.encounter_id = ae.id
|
||||
SELECT aep.encounter_id,
|
||||
aep.practitioner_id AS practitioner_id,
|
||||
pra."name" AS practitioner_name
|
||||
FROM adm_encounter_participant aep
|
||||
LEFT JOIN adm_practitioner pra ON aep.practitioner_id = pra.id AND pra.delete_flag = '0'
|
||||
WHERE aep.status_enum = #{active}
|
||||
AND aep.delete_flag = '0'
|
||||
AND aep.type_code::text = CAST(#{attendingDoctor} AS TEXT)
|
||||
LIMIT 1
|
||||
) AS attendingDoctor ON attendingDoctor.encounter_id = ae.id
|
||||
LEFT JOIN (
|
||||
SELECT aep.encounter_id,
|
||||
pra.id AS practitioner_id,
|
||||
pra."name" AS practitioner_name
|
||||
FROM adm_encounter_participant aep
|
||||
LEFT JOIN adm_practitioner pra ON aep.practitioner_id = pra.id AND pra.delete_flag = '0'
|
||||
WHERE aep.status_enum = #{active}
|
||||
AND aep.delete_flag = '0'
|
||||
AND aep.type_code = #{admittingDoctor}
|
||||
LIMIT 1
|
||||
) AS admittingDoctor ON admittingDoctor.encounter_id = ae.id
|
||||
SELECT aep.encounter_id,
|
||||
aep.practitioner_id AS practitioner_id,
|
||||
pra."name" AS practitioner_name
|
||||
FROM adm_encounter_participant aep
|
||||
LEFT JOIN adm_practitioner pra ON aep.practitioner_id = pra.id AND pra.delete_flag = '0'
|
||||
WHERE aep.status_enum = #{active}
|
||||
AND aep.delete_flag = '0'
|
||||
AND aep.type_code::text = CAST(#{admittingDoctor} AS TEXT)
|
||||
LIMIT 1
|
||||
) AS admittingDoctor ON admittingDoctor.encounter_id = ae.id
|
||||
LEFT JOIN (
|
||||
SELECT aep.encounter_id,
|
||||
pra.id AS practitioner_id,
|
||||
pra."name" AS practitioner_name
|
||||
FROM adm_encounter_participant aep
|
||||
LEFT JOIN adm_practitioner pra ON aep.practitioner_id = pra.id AND pra.delete_flag = '0'
|
||||
WHERE aep.status_enum = #{active}
|
||||
AND aep.delete_flag = '0'
|
||||
AND aep.type_code = #{chiefDoctor}
|
||||
LIMIT 1
|
||||
) AS chiefDoctor ON chiefDoctor.encounter_id = ae.id
|
||||
SELECT aep.encounter_id,
|
||||
aep.practitioner_id AS practitioner_id,
|
||||
pra."name" AS practitioner_name
|
||||
FROM adm_encounter_participant aep
|
||||
LEFT JOIN adm_practitioner pra ON aep.practitioner_id = pra.id AND pra.delete_flag = '0'
|
||||
WHERE aep.status_enum = #{active}
|
||||
AND aep.delete_flag = '0'
|
||||
AND aep.type_code::text = CAST(#{chiefDoctor} AS TEXT)
|
||||
LIMIT 1
|
||||
) AS chiefDoctor ON chiefDoctor.encounter_id = ae.id
|
||||
LEFT JOIN adm_organization ao
|
||||
ON ao.id = ae.organization_id
|
||||
AND ao.delete_flag = '0'
|
||||
@@ -575,7 +575,7 @@
|
||||
ON ae.id = aep.encounter_id
|
||||
AND aep.delete_flag = '0'
|
||||
AND aep.status_enum = #{active}
|
||||
AND aep.type_code = #{admittingDoctor}
|
||||
AND aep.type_code::text = #{admittingDoctor}::text
|
||||
LEFT JOIN adm_practitioner pra
|
||||
ON aep.practitioner_id = pra.id
|
||||
AND pra.delete_flag = '0'
|
||||
@@ -709,7 +709,7 @@
|
||||
ON ae.id = aep.encounter_id
|
||||
AND aep.delete_flag = '0'
|
||||
AND aep.status_enum = #{active}
|
||||
AND aep.type_code = #{admittingDoctor}
|
||||
AND aep.type_code::text = #{admittingDoctor}::text
|
||||
LEFT JOIN adm_practitioner pra
|
||||
ON aep.practitioner_id = pra.id
|
||||
AND pra.delete_flag = '0'
|
||||
|
||||
Reference in New Issue
Block a user