From 7aa0b130690763c3527b052b98ad61bfd2d32143 Mon Sep 17 00:00:00 2001 From: liuhongrui Date: Sat, 15 Mar 2025 13:19:12 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=A8=E8=AF=8A=E8=BE=93=E6=B6=B2=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IOutpatientInfusionRecordService.java | 17 +++- .../OutpatientInfusionRecordServiceImpl.java | 86 ++++++++++++++++++- .../OutpatientInfusionRecordController.java | 58 ++++++++++++- .../dto/OutpatientInfusionPatientDto.java | 3 + .../dto/OutpatientInfusionRecordDto.java | 3 +- .../OutpatientManageMapper.xml | 7 +- 6 files changed, 161 insertions(+), 13 deletions(-) diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/appservice/IOutpatientInfusionRecordService.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/appservice/IOutpatientInfusionRecordService.java index aadcb1f5..4ab030a4 100644 --- a/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/appservice/IOutpatientInfusionRecordService.java +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/appservice/IOutpatientInfusionRecordService.java @@ -48,8 +48,6 @@ public interface IOutpatientInfusionRecordService { */ List getPatientInfusionRecord(OutpatientInfusionPatientDto outpatientInfusionPatientDto); - - /** * 执行单个患者门诊输液 * @@ -59,4 +57,19 @@ public interface IOutpatientInfusionRecordService { */ boolean editPatientInfusionRecord(OutpatientInfusionRecordDto outpatientInfusionRecordDto,Long exeCount); + /** + * 执行输液后,修改执行结束时间 + * + * @param outpatientInfusionRecordDto 患者输液信息 + * @return 修改成功/失败 + */ + boolean editPatientInfusionTime(OutpatientInfusionRecordDto outpatientInfusionRecordDto); + + /** + * 显示门诊输液执行记录查询 + * + * @return 门诊输液记录列表 + */ + List getPatientInfusionPerformRecord(); + } diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/appservice/impl/OutpatientInfusionRecordServiceImpl.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/appservice/impl/OutpatientInfusionRecordServiceImpl.java index e4e3d529..085bd73a 100644 --- a/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/appservice/impl/OutpatientInfusionRecordServiceImpl.java +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/appservice/impl/OutpatientInfusionRecordServiceImpl.java @@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.core.common.utils.AgeCalculatorUtil; @@ -21,6 +22,8 @@ import com.core.common.utils.AssignSeqUtil; import com.core.common.utils.DateUtils; import com.core.common.utils.SecurityUtils; import com.openhis.administration.domain.Practitioner; +import com.openhis.administration.domain.PractitionerRole; +import com.openhis.administration.service.IPractitionerRoleService; import com.openhis.administration.service.IPractitionerService; import com.openhis.common.enums.AdministrativeGender; import com.openhis.common.enums.ClinicalStatus; @@ -34,6 +37,7 @@ import com.openhis.web.outpatientmanage.dto.OutpatientInfusionRecordDto; import com.openhis.web.outpatientmanage.dto.OutpatientInfusionSearchParam; import com.openhis.web.outpatientmanage.mapper.OutpatientManageMapper; import com.openhis.workflow.domain.ServiceRequest; +import com.openhis.workflow.mapper.ServiceRequestMapper; import com.openhis.workflow.service.IServiceRequestService; /** @@ -54,6 +58,12 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR @Autowired IPractitionerService practitionerService; + @Autowired + IPractitionerRoleService practitionerRoleService; + + @Autowired + ServiceRequestMapper serviceRequestMapper; + @Override /** * 获取门诊输液记录初期数据列表 @@ -129,6 +139,10 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR // 构建查询条件 QueryWrapper queryWrapper = HisQueryUtils.buildQueryWrapper(null, searchKey, new HashSet<>(Arrays.asList("patient_busNo", "encounter_busNo", "patient_name")), null); + // based_on_id 是为空的 + queryWrapper.eq("based_on_id",null); + // 状态是未完成的 + queryWrapper.in("status_enum", EventStatus.IN_PROGRESS.getValue(), EventStatus.NOT_DONE.getValue()); // 添加时间段查询条件 if (beginTime != null && endTime != null) { queryWrapper.ge("begin_time", beginTime); @@ -164,7 +178,10 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR // 创建查询包装器 QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("patient_id", outpatientInfusionPatientDto.getPatientId()); - + // based_on_id 是为空的 + queryWrapper.eq("based_on_id",null); + // 状态是未完成的 + queryWrapper.in("status_enum", EventStatus.IN_PROGRESS.getValue(), EventStatus.NOT_DONE.getValue()); // 从数据库获取输液记录列表 List infusionList = outpatientManageMapper.getOutpatientInfusionRecord(queryWrapper); @@ -187,9 +204,12 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR // 根据执行人ID,通过登录userId获取 Practitioner practitioner = practitionerService.getPractitionerByUserId(SecurityUtils.getLoginUser().getUserId()); - if (practitioner == null) { + // 以执行人ID,获取执行人的身份类别 + PractitionerRole practitionerRole = practitionerRoleService.getPractitionerRoleById(practitioner.getId()); + if (practitioner == null || practitionerRole == null) { return false; } + String busNo = AssignSeqUtil.formatString(outpatientInfusionRecordDto.getBusNo(), exeCount, 3); // 当输液未被全部执行时,可以修改继续执行,生成一条执行记录 if ((BigDecimal.valueOf(exeCount)).compareTo(outpatientInfusionRecordDto.getMedicationAntity()) < 0) { @@ -204,26 +224,84 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR .setStatusEnum(EventStatus.COMPLETED.getValue()) // 设置请求code 和原来一致 .setActivityId(outpatientInfusionRecordDto.getActivityId()) - //患者id + // 患者id .setPatientId(outpatientInfusionRecordDto.getPatientId()) - //就诊id + // 就诊id .setEncounterId(outpatientInfusionRecordDto.getEncounterId()) // 执行人id,通过登录userId获取 .setPerformerId(practitioner.getId()) + // 设置执行人身份类别 + .setPerformerTypeCode(practitionerRole.getRoleCode()) // 设置执行日期为当前时间 .setOccurrenceStartTime(DateUtils.getNowDate()) // 默认30结束 .setOccurrenceEndTime(DateUtils.addDateMinute(DateUtils.getNowDate(), 30)); + boolean result = serviceRequestService.save(serviceRequest); if (!result) { return false; } + // 判断如果是执行该患者最后一次记录,更新原来的服请求状态 + if ((BigDecimal.valueOf(exeCount + 1)).compareTo(outpatientInfusionRecordDto.getMedicationAntity()) == 0) { + // 以id为主条件更新服务申请管理表 + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.eq("id", outpatientInfusionRecordDto.getServiceId()) + .set("status_enum", EventStatus.COMPLETED.getValue()) + .set("performer_type_code", practitionerRole.getRoleCode()) + .set("performer_id", practitioner.getId()) + .set("occurrence_start_time", DateUtils.getNowDate()) + .set("occurrence_end_time", DateUtils.getNowDate()); + int countUpdate = serviceRequestMapper.update(null, updateWrapper); + if (countUpdate < 0) { + return false; + } + } return true; } return false; + } + /** + * 执行输液后,修改执行结束时间 + * + * @param outpatientInfusionRecordDto 患者输液信息 + * @return 修改成功/失败 + */ + @Override + public boolean editPatientInfusionTime(OutpatientInfusionRecordDto outpatientInfusionRecordDto) { + // 以id为主条件更新服务申请管理表 + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.eq("id", outpatientInfusionRecordDto.getServiceId()).set("occurrence_end_time", + DateUtils.parseDate(outpatientInfusionRecordDto.getOccurrenceEndTime())); + int countUpdate = serviceRequestMapper.update(null, updateWrapper); + if (countUpdate < 0) { + return false; + } else { + return true; + } + } + + /** + * 显示门诊输液执行记录查询 + * + * @return 门诊输液记录列表 + */ + @Override + public List getPatientInfusionPerformRecord() { + // 创建查询包装器 + QueryWrapper queryWrapper = new QueryWrapper<>(); + // based_on_id 不为空 + queryWrapper.isNotNull("based_on_id"); + // 状态是已完成 + queryWrapper.eq("status_enum", EventStatus.COMPLETED.getValue()); + + // 从数据库获取输液记录列表 + List infusionPerformList = + outpatientManageMapper.getOutpatientInfusionRecord(queryWrapper); + + return infusionPerformList; } } diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/controller/OutpatientInfusionRecordController.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/controller/OutpatientInfusionRecordController.java index 9579ceef..dccae7bb 100644 --- a/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/controller/OutpatientInfusionRecordController.java +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/controller/OutpatientInfusionRecordController.java @@ -16,6 +16,8 @@ import com.openhis.workflow.service.IServiceRequestService; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import java.util.List; + /** * 门诊输液记录 * @@ -80,15 +82,63 @@ public class OutpatientInfusionRecordController { * @param outpatientInfusionRecordDto 患者输液信息 * @return 门诊输液记录列表 */ - @PutMapping("/outpatient-record-skintest") + @PutMapping("/infusion-perform") public R editPatientInfusionRecord(@Validated @RequestBody OutpatientInfusionRecordDto outpatientInfusionRecordDto) { - //获取执行次数 + // 获取执行次数 Long exeCount = serviceRequestService.countServiceRequestByBasedOnId(outpatientInfusionRecordDto.getServiceId()); - outpatientInfusionRecordService.editPatientInfusionRecord(outpatientInfusionRecordDto,exeCount); - + boolean res = outpatientInfusionRecordService.editPatientInfusionRecord(outpatientInfusionRecordDto, exeCount); + if (!res) { + return R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00007, null)); + } return R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00001, new Object[] {"患者门诊输液执行"})); } + /** + * 批量执行患者门诊输液 + * + * @param outpatientInfusionRecordDtoList 患者输液信息列表 + * @return 门诊输液记录列表 + */ + @PutMapping("/infusion-perform/batch") + public R batchEditPatientInfusionRecord( + @Validated @RequestBody List outpatientInfusionRecordDtoList) { + // 获取执行次数 + for (OutpatientInfusionRecordDto dto : outpatientInfusionRecordDtoList) { + Long exeCount = serviceRequestService.countServiceRequestByBasedOnId(dto.getServiceId()); + boolean res = outpatientInfusionRecordService.editPatientInfusionRecord(dto, exeCount); + if (!res) { + return R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00007, null)); + } + } + return R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00001, new Object[] {"患者门诊输液执行"})); + } + + /** + * 执行输液后,修改执行结束时间 + * + * @param outpatientInfusionRecordDto 患者输液信息 + */ + @PutMapping("/infusion-perform-time") + public R + editPatientInfusionTime(@Validated @RequestBody OutpatientInfusionRecordDto outpatientInfusionRecordDto) { + boolean res = outpatientInfusionRecordService.editPatientInfusionTime(outpatientInfusionRecordDto); + if (!res) { + return R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00007, null)); + } + return R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00001, new Object[] {"患者门诊输液记录"})); + } + + /** + * 显示门诊输液执行记录查询 + * + * @return 门诊输液记录列表 + */ + @GetMapping(value = "/infusion-perform-Record") + public R getPatientInfusionPerformRecord() { + + return R.ok(outpatientInfusionRecordService.getPatientInfusionPerformRecord()); + } + } diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/dto/OutpatientInfusionPatientDto.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/dto/OutpatientInfusionPatientDto.java index 6af8bed6..00a29224 100644 --- a/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/dto/OutpatientInfusionPatientDto.java +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/dto/OutpatientInfusionPatientDto.java @@ -44,6 +44,9 @@ public class OutpatientInfusionPatientDto { /** 病人生日 */ private Date birthDate; + /** 病人身份证号 */ + private String idCard; + /** 病人年龄 */ private String ageString; diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/dto/OutpatientInfusionRecordDto.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/dto/OutpatientInfusionRecordDto.java index a8d65e57..70b85060 100644 --- a/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/dto/OutpatientInfusionRecordDto.java +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/outpatientmanage/dto/OutpatientInfusionRecordDto.java @@ -57,7 +57,8 @@ public class OutpatientInfusionRecordDto { private String genderEnum_enumText; /** 已执行数量 */ - private Integer executionCount; + @JsonSerialize(using = ToStringSerializer.class) + private Long executionCount; /** 执行护士 */ @Dict(dictCode = "id", dictTable = "adm_practitioner", dictText = "name") diff --git a/openhis-server/openhis-application/src/main/resources/mapper/outpatientmanage/OutpatientManageMapper.xml b/openhis-server/openhis-application/src/main/resources/mapper/outpatientmanage/OutpatientManageMapper.xml index 835bb7fb..e3e4a4ba 100644 --- a/openhis-server/openhis-application/src/main/resources/mapper/outpatientmanage/OutpatientManageMapper.xml +++ b/openhis-server/openhis-application/src/main/resources/mapper/outpatientmanage/OutpatientManageMapper.xml @@ -140,6 +140,7 @@ T1.patient_busNo, T1.patient_id, T1.patient_name, + T1.id_card, T1.gender_enum, T1.create_time from @@ -152,6 +153,7 @@ pt.bus_no AS patient_busNo, --病人ID(前台显示用) sr.patient_id, --病人ID pt.name AS patient_name, --病人姓名 + pt.name AS id_card, --病人身份证号 pt.gender_enum AS gender_enum, --病人性别 mr.create_time AS create_time --开单时间 FROM @@ -177,6 +179,7 @@ SELECT T1.service_id, T1.bus_no, + T1.execution_count, T1.based_on_id, T1.activity_id, T1.prescription_no, @@ -203,7 +206,8 @@ ( SELECT sr.id AS service_id, --服务申请管理ID - sr.bus_no, --服务请求编码 + sr.bus_no, -- 服务请求编码 + (SELECT COUNT(*) FROM wor_service_request WHERE based_on_id = SPLIT_PART(sr.bus_no, '.', 1)) AS execution_count, -- 执行次数 sr.based_on_id, --请求基于什么的ID sr.activity_id,--请求code,输液 sr.prescription_no, --处方号 @@ -242,7 +246,6 @@ ad.bus_no = 'sy001' -- 皮试检查的编号,todo:编号未定,后期修改 AND mr.infusion_flag = 1 AND md.infusion_flag = 1 - AND sr.status_enum in (2,3) --服务状态未完成 ORDER BY