168 入科分配床位填写的住院医生、主治医生、责任护士字段的内容双击查看未显示。
This commit is contained in:
@@ -14,10 +14,13 @@ import com.core.common.utils.SecurityUtils;
|
|||||||
import com.core.common.utils.StringUtils;
|
import com.core.common.utils.StringUtils;
|
||||||
import com.openhis.administration.domain.Encounter;
|
import com.openhis.administration.domain.Encounter;
|
||||||
import com.openhis.administration.domain.EncounterLocation;
|
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.IEncounterLocationService;
|
||||||
import com.openhis.administration.service.IEncounterParticipantService;
|
import com.openhis.administration.service.IEncounterParticipantService;
|
||||||
import com.openhis.administration.service.IEncounterService;
|
import com.openhis.administration.service.IEncounterService;
|
||||||
import com.openhis.administration.service.ILocationService;
|
import com.openhis.administration.service.ILocationService;
|
||||||
|
import com.openhis.administration.service.IPractitionerService;
|
||||||
import com.openhis.common.constant.CommonConstants;
|
import com.openhis.common.constant.CommonConstants;
|
||||||
import com.openhis.common.enums.*;
|
import com.openhis.common.enums.*;
|
||||||
import com.openhis.common.utils.EnumUtils;
|
import com.openhis.common.utils.EnumUtils;
|
||||||
@@ -95,6 +98,9 @@ public class ATDManageAppServiceImpl implements IATDManageAppService {
|
|||||||
@Resource
|
@Resource
|
||||||
private IServiceRequestService serviceRequestService;
|
private IServiceRequestService serviceRequestService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IPractitionerService practitionerService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 入出转管理页面初始化
|
* 入出转管理页面初始化
|
||||||
*
|
*
|
||||||
@@ -215,12 +221,131 @@ public class ATDManageAppServiceImpl implements IATDManageAppService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public R<?> getAdmissionPatientInfo(Long encounterId) {
|
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
|
AdmissionPatientInfoDto admissionPatientInfoDto
|
||||||
= atdManageAppMapper.selectAdmissionPatientInfo(encounterId, EncounterActivityStatus.ACTIVE.getValue(),
|
= atdManageAppMapper.selectAdmissionPatientInfo(encounterId, active,
|
||||||
LocationForm.WARD.getValue(), LocationForm.HOUSE.getValue(), LocationForm.BED.getValue(),
|
LocationForm.WARD.getValue(), LocationForm.HOUSE.getValue(), LocationForm.BED.getValue(),
|
||||||
ParticipantType.PRIMARY_NURSE.getCode(), ParticipantType.ATTENDING_DOCTOR.getCode(),
|
primaryNurse, attendingDoctor, admittingDoctor, chiefDoctor);
|
||||||
ParticipantType.ADMITTING_DOCTOR.getCode(), ParticipantType.CHIEF_DOCTOR.getCode());
|
|
||||||
|
// 从 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());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查找各个角色 - 使用 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) {
|
if (admissionPatientInfoDto.getBirthDate() != null) {
|
||||||
admissionPatientInfoDto.setAge(AgeCalculatorUtil.getAge(admissionPatientInfoDto.getBirthDate()));
|
admissionPatientInfoDto.setAge(AgeCalculatorUtil.getAge(admissionPatientInfoDto.getBirthDate()));
|
||||||
@@ -233,6 +358,13 @@ public class ATDManageAppServiceImpl implements IATDManageAppService {
|
|||||||
EnumUtils.getInfoByValue(PriorityLevel.class, admissionPatientInfoDto.getPriorityEnum()));
|
EnumUtils.getInfoByValue(PriorityLevel.class, admissionPatientInfoDto.getPriorityEnum()));
|
||||||
// 获取入院体征
|
// 获取入院体征
|
||||||
getAdmissionSigns(encounterId, admissionPatientInfoDto);
|
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);
|
return R.ok(admissionPatientInfoDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,6 +420,7 @@ public class ATDManageAppServiceImpl implements IATDManageAppService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public R<?> admissionBedAssignment(AdmissionPatientInfoDto admissionPatientInfoDto) {
|
public R<?> admissionBedAssignment(AdmissionPatientInfoDto admissionPatientInfoDto) {
|
||||||
|
log.info("===== admissionBedAssignment 开始 =====");
|
||||||
|
|
||||||
// 住院id
|
// 住院id
|
||||||
Long encounterId = admissionPatientInfoDto.getEncounterId();
|
Long encounterId = admissionPatientInfoDto.getEncounterId();
|
||||||
@@ -301,7 +434,10 @@ public class ATDManageAppServiceImpl implements IATDManageAppService {
|
|||||||
Long targetBedId = admissionPatientInfoDto.getTargetBedId();
|
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) {
|
if (admissionPatientInfoDto.getPriorityEnum() != null) {
|
||||||
encounterService.updatePriorityEnumById(encounterId, admissionPatientInfoDto.getPriorityEnum());
|
encounterService.updatePriorityEnumById(encounterId, admissionPatientInfoDto.getPriorityEnum());
|
||||||
@@ -329,6 +465,13 @@ public class ATDManageAppServiceImpl implements IATDManageAppService {
|
|||||||
encounterParticipantService.creatEncounterParticipants(encounterId, startTime,
|
encounterParticipantService.creatEncounterParticipants(encounterId, startTime,
|
||||||
admissionPatientInfoDto.getChiefDoctorId(), ParticipantType.CHIEF_DOCTOR.getCode());
|
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 {
|
try {
|
||||||
saveOrUpdateAdmissionSigns(encounterId, admissionPatientInfoDto, startTime);
|
saveOrUpdateAdmissionSigns(encounterId, admissionPatientInfoDto, startTime);
|
||||||
@@ -338,6 +481,11 @@ public class ATDManageAppServiceImpl implements IATDManageAppService {
|
|||||||
return R.ok("患者信息更新成功");
|
return R.ok("患者信息更新成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 新分配床位时,校验床位信息
|
||||||
|
if (targetBedId == null || admissionPatientInfoDto.getTargetHouseId() == null) {
|
||||||
|
return R.fail("床位分配失败,请选择有效的床位");
|
||||||
|
}
|
||||||
|
|
||||||
// 判断患者是否已经在床
|
// 判断患者是否已经在床
|
||||||
if (oldBedId != null) {
|
if (oldBedId != null) {
|
||||||
// 判断目标床位是否已经被占用
|
// 判断目标床位是否已经被占用
|
||||||
|
|||||||
@@ -290,46 +290,46 @@
|
|||||||
) AS ward ON ward.encounter_id = ae.id
|
) AS ward ON ward.encounter_id = ae.id
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT aep.encounter_id,
|
SELECT aep.encounter_id,
|
||||||
pra.id AS practitioner_id,
|
aep.practitioner_id AS practitioner_id,
|
||||||
pra."name" AS practitioner_name
|
pra."name" AS practitioner_name
|
||||||
FROM adm_encounter_participant aep
|
FROM adm_encounter_participant aep
|
||||||
LEFT JOIN adm_practitioner pra ON aep.practitioner_id = pra.id AND pra.delete_flag = '0'
|
LEFT JOIN adm_practitioner pra ON aep.practitioner_id = pra.id AND pra.delete_flag = '0'
|
||||||
WHERE aep.status_enum = #{active}
|
WHERE aep.status_enum = #{active}
|
||||||
AND aep.delete_flag = '0'
|
AND aep.delete_flag = '0'
|
||||||
AND aep.type_code = #{primaryNurse}
|
AND aep.type_code::text = CAST(#{primaryNurse} AS TEXT)
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
) AS primaryNurse ON primaryNurse.encounter_id = ae.id
|
) AS primaryNurse ON primaryNurse.encounter_id = ae.id
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT aep.encounter_id,
|
SELECT aep.encounter_id,
|
||||||
pra.id AS practitioner_id,
|
aep.practitioner_id AS practitioner_id,
|
||||||
pra."name" AS practitioner_name
|
pra."name" AS practitioner_name
|
||||||
FROM adm_encounter_participant aep
|
FROM adm_encounter_participant aep
|
||||||
LEFT JOIN adm_practitioner pra ON aep.practitioner_id = pra.id AND pra.delete_flag = '0'
|
LEFT JOIN adm_practitioner pra ON aep.practitioner_id = pra.id AND pra.delete_flag = '0'
|
||||||
WHERE aep.status_enum = #{active}
|
WHERE aep.status_enum = #{active}
|
||||||
AND aep.delete_flag = '0'
|
AND aep.delete_flag = '0'
|
||||||
AND aep.type_code = #{attendingDoctor}
|
AND aep.type_code::text = CAST(#{attendingDoctor} AS TEXT)
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
) AS attendingDoctor ON attendingDoctor.encounter_id = ae.id
|
) AS attendingDoctor ON attendingDoctor.encounter_id = ae.id
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT aep.encounter_id,
|
SELECT aep.encounter_id,
|
||||||
pra.id AS practitioner_id,
|
aep.practitioner_id AS practitioner_id,
|
||||||
pra."name" AS practitioner_name
|
pra."name" AS practitioner_name
|
||||||
FROM adm_encounter_participant aep
|
FROM adm_encounter_participant aep
|
||||||
LEFT JOIN adm_practitioner pra ON aep.practitioner_id = pra.id AND pra.delete_flag = '0'
|
LEFT JOIN adm_practitioner pra ON aep.practitioner_id = pra.id AND pra.delete_flag = '0'
|
||||||
WHERE aep.status_enum = #{active}
|
WHERE aep.status_enum = #{active}
|
||||||
AND aep.delete_flag = '0'
|
AND aep.delete_flag = '0'
|
||||||
AND aep.type_code = #{admittingDoctor}
|
AND aep.type_code::text = CAST(#{admittingDoctor} AS TEXT)
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
) AS admittingDoctor ON admittingDoctor.encounter_id = ae.id
|
) AS admittingDoctor ON admittingDoctor.encounter_id = ae.id
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT aep.encounter_id,
|
SELECT aep.encounter_id,
|
||||||
pra.id AS practitioner_id,
|
aep.practitioner_id AS practitioner_id,
|
||||||
pra."name" AS practitioner_name
|
pra."name" AS practitioner_name
|
||||||
FROM adm_encounter_participant aep
|
FROM adm_encounter_participant aep
|
||||||
LEFT JOIN adm_practitioner pra ON aep.practitioner_id = pra.id AND pra.delete_flag = '0'
|
LEFT JOIN adm_practitioner pra ON aep.practitioner_id = pra.id AND pra.delete_flag = '0'
|
||||||
WHERE aep.status_enum = #{active}
|
WHERE aep.status_enum = #{active}
|
||||||
AND aep.delete_flag = '0'
|
AND aep.delete_flag = '0'
|
||||||
AND aep.type_code = #{chiefDoctor}
|
AND aep.type_code::text = CAST(#{chiefDoctor} AS TEXT)
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
) AS chiefDoctor ON chiefDoctor.encounter_id = ae.id
|
) AS chiefDoctor ON chiefDoctor.encounter_id = ae.id
|
||||||
LEFT JOIN adm_organization ao
|
LEFT JOIN adm_organization ao
|
||||||
@@ -575,7 +575,7 @@
|
|||||||
ON ae.id = aep.encounter_id
|
ON ae.id = aep.encounter_id
|
||||||
AND aep.delete_flag = '0'
|
AND aep.delete_flag = '0'
|
||||||
AND aep.status_enum = #{active}
|
AND aep.status_enum = #{active}
|
||||||
AND aep.type_code = #{admittingDoctor}
|
AND aep.type_code::text = #{admittingDoctor}::text
|
||||||
LEFT JOIN adm_practitioner pra
|
LEFT JOIN adm_practitioner pra
|
||||||
ON aep.practitioner_id = pra.id
|
ON aep.practitioner_id = pra.id
|
||||||
AND pra.delete_flag = '0'
|
AND pra.delete_flag = '0'
|
||||||
@@ -709,7 +709,7 @@
|
|||||||
ON ae.id = aep.encounter_id
|
ON ae.id = aep.encounter_id
|
||||||
AND aep.delete_flag = '0'
|
AND aep.delete_flag = '0'
|
||||||
AND aep.status_enum = #{active}
|
AND aep.status_enum = #{active}
|
||||||
AND aep.type_code = #{admittingDoctor}
|
AND aep.type_code::text = #{admittingDoctor}::text
|
||||||
LEFT JOIN adm_practitioner pra
|
LEFT JOIN adm_practitioner pra
|
||||||
ON aep.practitioner_id = pra.id
|
ON aep.practitioner_id = pra.id
|
||||||
AND pra.delete_flag = '0'
|
AND pra.delete_flag = '0'
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ public class EncounterParticipantServiceImpl extends ServiceImpl<EncounterPartic
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void creatEncounterParticipants(Long encounterId, Date startTime, Long practitionerId, String typeCode) {
|
public void creatEncounterParticipants(Long encounterId, Date startTime, Long practitionerId, String typeCode) {
|
||||||
|
log.info("创建参与者 - encounterId: {}, startTime: {}, practitionerId: {}, typeCode: {} (type: {}), status: {}",
|
||||||
|
encounterId, startTime, practitionerId, typeCode, typeCode != null ? typeCode.getClass().getSimpleName() : "null", EncounterActivityStatus.ACTIVE.getValue());
|
||||||
EncounterParticipant encounterParticipant = new EncounterParticipant();
|
EncounterParticipant encounterParticipant = new EncounterParticipant();
|
||||||
encounterParticipant.setEncounterId(encounterId)
|
encounterParticipant.setEncounterId(encounterId)
|
||||||
.setStartTime(startTime)
|
.setStartTime(startTime)
|
||||||
@@ -66,6 +68,7 @@ public class EncounterParticipantServiceImpl extends ServiceImpl<EncounterPartic
|
|||||||
.setTypeCode(typeCode)
|
.setTypeCode(typeCode)
|
||||||
.setStatusEnum(EncounterActivityStatus.ACTIVE.getValue());
|
.setStatusEnum(EncounterActivityStatus.ACTIVE.getValue());
|
||||||
int result = baseMapper.insert(encounterParticipant);
|
int result = baseMapper.insert(encounterParticipant);
|
||||||
|
log.info("创建参与者结果 - encounterId: {}, typeCode: {}, result: {}, insertId: {}", encounterId, typeCode, result, encounterParticipant.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -396,20 +396,28 @@ const loadPatientInfo = () => {
|
|||||||
if (!props.pendingInfo?.encounterId) {
|
if (!props.pendingInfo?.encounterId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
console.log('查询患者信息的 encounterId:', props.pendingInfo.encounterId);
|
||||||
getPatientInfo({ encounterId: props.pendingInfo.encounterId }).then((res) => {
|
getPatientInfo({ encounterId: props.pendingInfo.encounterId }).then((res) => {
|
||||||
|
console.log('后端返回的患者信息:', res.data);
|
||||||
pendingInfo.value = res.data;
|
pendingInfo.value = res.data;
|
||||||
// 从后端获取数据后设置医生和护士 ID
|
// 从后端获取数据后设置医生和护士 ID
|
||||||
|
// 医生使用 ToStringSerializer,返回字符串;护士直接返回数字
|
||||||
|
console.log('admittingDoctorId:', res.data.admittingDoctorId);
|
||||||
|
console.log('attendingDoctorId:', res.data.attendingDoctorId);
|
||||||
|
console.log('chiefDoctorId:', res.data.chiefDoctorId);
|
||||||
|
console.log('primaryNurseId:', res.data.primaryNurseId);
|
||||||
if (res.data.admittingDoctorId) {
|
if (res.data.admittingDoctorId) {
|
||||||
interventionForm.value.admittingDoctorId = res.data.admittingDoctorId;
|
interventionForm.value.admittingDoctorId = String(res.data.admittingDoctorId);
|
||||||
}
|
}
|
||||||
if (res.data.attendingDoctorId) {
|
if (res.data.attendingDoctorId) {
|
||||||
interventionForm.value.attendingDoctorId = res.data.attendingDoctorId;
|
interventionForm.value.attendingDoctorId = String(res.data.attendingDoctorId);
|
||||||
}
|
}
|
||||||
if (res.data.chiefDoctorId) {
|
if (res.data.chiefDoctorId) {
|
||||||
interventionForm.value.chiefDoctorId = res.data.chiefDoctorId;
|
interventionForm.value.chiefDoctorId = String(res.data.chiefDoctorId);
|
||||||
}
|
}
|
||||||
if (res.data.primaryNurseId) {
|
if (res.data.primaryNurseId) {
|
||||||
interventionForm.value.primaryNurseId = res.data.primaryNurseId;
|
// 护士ID也转换为字符串以匹配护士选项
|
||||||
|
interventionForm.value.primaryNurseId = String(res.data.primaryNurseId);
|
||||||
}
|
}
|
||||||
if (res.data.startTime) {
|
if (res.data.startTime) {
|
||||||
interventionForm.value.startTime = dayjs(res.data.startTime).format(
|
interventionForm.value.startTime = dayjs(res.data.startTime).format(
|
||||||
@@ -435,21 +443,23 @@ const loadPatientInfo = () => {
|
|||||||
watch(
|
watch(
|
||||||
() => props.pendingInfo?.encounterId,
|
() => props.pendingInfo?.encounterId,
|
||||||
(newVal, oldVal) => {
|
(newVal, oldVal) => {
|
||||||
// 只在 encounterId 存在且发生变化时才获取数据
|
// encounterId 存在时就获取数据
|
||||||
if (newVal && newVal !== oldVal) {
|
if (newVal) {
|
||||||
|
console.log('watch 触发, newVal:', newVal, 'oldVal:', oldVal);
|
||||||
loadPatientInfo();
|
loadPatientInfo();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
{ immediate: true }
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/* 初始化数据 */
|
/* 初始化数据 */
|
||||||
const init = () => {
|
const init = () => {
|
||||||
initCurrentInPatient();
|
initCurrentInPatient();
|
||||||
getInit()
|
|
||||||
|
const promises = [];
|
||||||
|
|
||||||
|
const initPromise = getInit()
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
InitInfoOptions.value = res.data;
|
InitInfoOptions.value = res.data;
|
||||||
// 安全地设置priorityListOptions
|
|
||||||
if (res.data && res.data.priorityListOptions) {
|
if (res.data && res.data.priorityListOptions) {
|
||||||
priorityListOptions.value = res.data.priorityListOptions;
|
priorityListOptions.value = res.data.priorityListOptions;
|
||||||
}
|
}
|
||||||
@@ -457,9 +467,10 @@ const init = () => {
|
|||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('获取初始化数据失败:', error);
|
console.error('获取初始化数据失败:', error);
|
||||||
});
|
});
|
||||||
|
promises.push(initPromise);
|
||||||
|
|
||||||
if (props.pendingInfo.wardLocationId) {
|
if (props.pendingInfo.wardLocationId) {
|
||||||
getBedInfo({ wardLocationId: props.pendingInfo.wardLocationId })
|
const bedPromise = getBedInfo({ wardLocationId: props.pendingInfo.wardLocationId })
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
bedInfoOptions.value = res.data || [];
|
bedInfoOptions.value = res.data || [];
|
||||||
})
|
})
|
||||||
@@ -467,16 +478,18 @@ const init = () => {
|
|||||||
console.error('获取床位信息失败:', error);
|
console.error('获取床位信息失败:', error);
|
||||||
bedInfoOptions.value = [];
|
bedInfoOptions.value = [];
|
||||||
});
|
});
|
||||||
|
promises.push(bedPromise);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.pendingInfo.organizationId) {
|
if (props.pendingInfo.organizationId) {
|
||||||
// 主任医生
|
const doctorPromise = getDoctorInfo({ organizationId: props.pendingInfo.organizationId })
|
||||||
getDoctorInfo({ organizationId: props.pendingInfo.organizationId })
|
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
doctorInfoOptions.value = res.data.records || [];
|
doctorInfoOptions.value = res.data.records || [];
|
||||||
|
// 只有在新分配床位模式(entranceType != 1)时才设置默认主任医生
|
||||||
|
// 并且只在当前没有选择主任医生时才设置默认值(避免覆盖已从后端获取的数据)
|
||||||
|
if (props.pendingInfo.entranceType != 1) {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
// 如果存在主任医师显示主任,如果没有选择第一个展示
|
if (doctorInfoOptions.value.length > 0 && !interventionForm.value.chiefDoctorId) {
|
||||||
if (doctorInfoOptions.value.length > 0) {
|
|
||||||
let selectId = '';
|
let selectId = '';
|
||||||
doctorInfoOptions.value.forEach((item: any) => {
|
doctorInfoOptions.value.forEach((item: any) => {
|
||||||
if (item.drProfttlCode == '231') {
|
if (item.drProfttlCode == '231') {
|
||||||
@@ -490,21 +503,30 @@ const init = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('获取医生信息失败:', error);
|
console.error('获取医生信息失败:', error);
|
||||||
doctorInfoOptions.value = [];
|
doctorInfoOptions.value = [];
|
||||||
});
|
});
|
||||||
|
promises.push(doctorPromise);
|
||||||
|
|
||||||
getNurseInfo({ organizationId: props.pendingInfo.organizationId })
|
const nursePromise = getNurseInfo({ organizationId: props.pendingInfo.organizationId })
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
nurseInfoOptions.value = res.data || [];
|
// 将护士ID转换为字符串以匹配医生选项的数据类型
|
||||||
|
nurseInfoOptions.value = (res.data || []).map((item: any) => ({
|
||||||
|
...item,
|
||||||
|
practitionerId: String(item.practitionerId),
|
||||||
|
}));
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('获取护士信息失败:', error);
|
console.error('获取护士信息失败:', error);
|
||||||
nurseInfoOptions.value = [];
|
nurseInfoOptions.value = [];
|
||||||
});
|
});
|
||||||
|
promises.push(nursePromise);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Promise.all(promises);
|
||||||
};
|
};
|
||||||
|
|
||||||
const rules = reactive<FormRules>({
|
const rules = reactive<FormRules>({
|
||||||
@@ -544,16 +566,27 @@ const handleSubmit = async () => {
|
|||||||
try {
|
try {
|
||||||
const valid = await interventionFormRef.value.validate();
|
const valid = await interventionFormRef.value.validate();
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
// 过滤掉空字符串的字段,只保留用户实际选择的值
|
||||||
|
const formData = {};
|
||||||
|
Object.keys(interventionForm.value).forEach(key => {
|
||||||
|
const value = interventionForm.value[key];
|
||||||
|
// 保留非空的值(0、false等有效值也需要保留)
|
||||||
|
if (value !== '' && value !== null && value !== undefined) {
|
||||||
|
formData[key] = value;
|
||||||
|
}
|
||||||
|
});
|
||||||
const params = {
|
const params = {
|
||||||
...pendingInfo.value,
|
...pendingInfo.value,
|
||||||
...interventionForm.value,
|
...formData,
|
||||||
targetBedId: props.pendingInfo.bedId,
|
targetBedId: props.pendingInfo.bedId,
|
||||||
busNo: props.pendingInfo.busNo,
|
busNo: props.pendingInfo.busNo,
|
||||||
inHosTime: props.pendingInfo.inHosTime,
|
inHosTime: props.pendingInfo.inHosTime,
|
||||||
targetHouseId: props.pendingInfo.targetHouseId,
|
targetHouseId: props.pendingInfo.targetHouseId,
|
||||||
targetEncounterId: props.pendingInfo.targetEncounterId,
|
targetEncounterId: props.pendingInfo.targetEncounterId,
|
||||||
editFlag: props.pendingInfo.entranceType == 1 ? 1 : 0,
|
editFlag: props.pendingInfo.entranceType == 1 ? '1' : '0',
|
||||||
};
|
};
|
||||||
|
console.log('提交参数:', params);
|
||||||
|
console.log('startTime:', interventionForm.value.startTime);
|
||||||
|
|
||||||
bedAssignment(params)
|
bedAssignment(params)
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
@@ -583,9 +616,10 @@ const handleSubmit = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const openAct = () => {
|
const openAct = () => {
|
||||||
init();
|
// 先初始化数据(包括医生护士列表),等待完成后再加载患者信息
|
||||||
// 重新加载患者详细信息(包括医生、护士等)
|
init().then(() => {
|
||||||
loadPatientInfo();
|
loadPatientInfo();
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const closedAct = () => {
|
const closedAct = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user