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 937c18db..29e71f4f 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 @@ -201,7 +201,7 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR if (exeCount < record.getExecuteNum()) { ServiceRequest serviceRequest = new ServiceRequest(); serviceRequest.setPrescriptionNo(record.getPrescriptionNo()) - .setBusNo(AssignSeqUtil.formatString(prefixBusNo, exeCount, 3)) + .setBusNo(AssignSeqUtil.formatString(prefixBusNo, exeCount + 1, 3)) .setBasedOnId(record.getServiceId()).setStatusEnum(EventStatus.COMPLETED.getValue()) .setActivityId(record.getActivityId()).setPatientId(record.getPatientId()) .setEncounterId(record.getEncounterId()).setPerformerId(practitioner.getId()) @@ -219,7 +219,7 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR return false; // 如果批量插入失败,返回 false } // 批量更新执行状态 - List serviceIds = checkServiceRequestIsCompleted(serviceRecords); + List serviceIds = checkServiceRequestIsCompleted(); int updateRes = batchUpdateRecordStatus(serviceIds); // 如果更新失败,返回 false @@ -234,23 +234,28 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR /** * 检查该条服务申请的所有输液信息都完成 * - * @param serviceRecords 同一个服务请求的输液信息列表 * @return 更新的ID集合 */ - public List checkServiceRequestIsCompleted(Map> serviceRecords) { + public List checkServiceRequestIsCompleted() { + + //获取全部执行输液记录 + List patientInfusionList =getPatientInfusionPerformRecord(null,false); + // 按 serviceId 分组 + Map> servicePatientInfusionList = patientInfusionList.stream() + .collect(Collectors.groupingBy(OutpatientInfusionRecordDto::getServiceId)); // 存储更新的serviceId List serviceIds = new ArrayList<>(); // 遍历每个分组 - for (Map.Entry> entry : serviceRecords.entrySet()) { + for (Map.Entry> entry : servicePatientInfusionList.entrySet()) { // 获取当前分组的 serviceId Long serviceId = entry.getKey(); // 获取当前分组的记录列表 List groupRecords = entry.getValue(); // 创建一个数组来记录每个记录是否满足条件 - int[] flags = new int[serviceRecords.size()]; + int[] flags = new int[groupRecords.size()]; int index = 0; // 用于记录当前索引 for (OutpatientInfusionRecordDto record : groupRecords) { @@ -260,7 +265,7 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR Long exeCount = outpatientManageMapper.countExecuteNumOrGroupNum(serviceId, prefixBusNo, null, true); // 判断是否满足条件 - if (exeCount.equals(record.getExecuteNum())) { + if (exeCount != null && exeCount.longValue() == record.getExecuteNum().longValue()) { flags[index] = 1; // 如果满足条件,设置为 1 } else { flags[index] = 0; // 如果不满足条件,设置为 0 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 03803f1c..7fdf81f2 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 @@ -233,8 +233,15 @@ mr.status_enum AS medication_status_enum, --药品状态 mr.rate_code, --药品状态 mr.execute_num, -- 总执行次数 - (select count (*) from wor_service_request wor where wor.based_on_id = sr.id) as done_num ,-- 已执行次数 mr.group_id, --注射药品组号 + (SELECT COUNT(*) + FROM wor_service_request wor + WHERE wor.based_on_id = sr.id + AND CAST(md.id AS CHAR) = LEFT(split_part(wor.bus_no, '-', 3), POSITION('.' IN split_part(wor.bus_no, '-', 3)) - 1) --药品ID +-- AND CAST(mr.group_id AS CHAR) = split_part(wor.bus_no, '-', 2) -- 组号ID + AND wor.bus_no LIKE '%-%' + + ) AS done_num ,-- 已执行次数 mr.perform_org,--执行科室 CASE mr.skin_test_flag WHEN 1 THEN 1 @@ -289,7 +296,10 @@ AND sr.based_on_id = #{paramId} AND sr.bus_no LIKE CONCAT(#{prefixBusNo}, '%') + AND CAST(md.id AS CHAR) = LEFT(split_part(sr.bus_no, '-', 3), POSITION('.' IN split_part(sr.bus_no, '-', 3)) - 1) --药品ID +-- AND CAST(mr.group_id AS CHAR) = split_part(sr.bus_no, '-', 2) -- 组号ID AND sr.status_enum = 6 --服务状态是已完成 +