门诊输液 up
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
package com.openhis.web.outpatientmanage.appservice.impl;
|
package com.openhis.web.outpatientmanage.appservice.impl;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@@ -124,7 +126,21 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR
|
|||||||
IPage<OutpatientInfusionRecordDto> OutpatientInfusionRecordPage =
|
IPage<OutpatientInfusionRecordDto> OutpatientInfusionRecordPage =
|
||||||
outpatientManageMapper.getOutpatientInfusionRecord(new Page<>(1, 100), queryWrapper);
|
outpatientManageMapper.getOutpatientInfusionRecord(new Page<>(1, 100), queryWrapper);
|
||||||
|
|
||||||
return OutpatientInfusionRecordPage.getRecords();
|
List<OutpatientInfusionRecordDto> infusionPerformList = OutpatientInfusionRecordPage.getRecords();
|
||||||
|
|
||||||
|
// 遍历列表并处理每个记录
|
||||||
|
infusionPerformList.forEach(e -> {
|
||||||
|
// 性别
|
||||||
|
e.setGenderEnum_enumText(EnumUtils.getInfoByValue(AdministrativeGender.class, e.getGenderEnum()));
|
||||||
|
// 药品状态
|
||||||
|
e.setMedicationStatusEnum_enumText(
|
||||||
|
EnumUtils.getInfoByValue(EventStatus.class, e.getMedicationStatusEnum()));
|
||||||
|
// 皮试标志
|
||||||
|
e.setSkinTestFlag_enumText(EnumUtils.getInfoByValue(Whether.class, e.getSkinTestFlag()));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
return infusionPerformList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -176,7 +192,8 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
String prefixBusNo = record.getBusNo() + "." + record.getGroupId() + "." + record.getMedicationId();
|
String prefixBusNo = record.getBusNo() + CommonConstants.Common.DASH + record.getGroupId()
|
||||||
|
+ CommonConstants.Common.DASH + record.getMedicationId();
|
||||||
// 获取执行次数
|
// 获取执行次数
|
||||||
Long exeCount =
|
Long exeCount =
|
||||||
outpatientManageMapper.countExecuteNumOrGroupNum(record.getServiceId(), prefixBusNo, null, true);
|
outpatientManageMapper.countExecuteNumOrGroupNum(record.getServiceId(), prefixBusNo, null, true);
|
||||||
@@ -189,7 +206,7 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR
|
|||||||
.setActivityId(record.getActivityId()).setPatientId(record.getPatientId())
|
.setActivityId(record.getActivityId()).setPatientId(record.getPatientId())
|
||||||
.setEncounterId(record.getEncounterId()).setPerformerId(practitioner.getId())
|
.setEncounterId(record.getEncounterId()).setPerformerId(practitioner.getId())
|
||||||
.setPerformerTypeCode(practitionerRole.getRoleCode())
|
.setPerformerTypeCode(practitionerRole.getRoleCode())
|
||||||
.setOccurrenceStartTime(DateUtils.getNowDate())
|
.setOccurrenceStartTime(DateUtils.getNowDate()).setRequesterId(practitioner.getId())
|
||||||
.setOccurrenceEndTime(DateUtils.addDateMinute(DateUtils.getNowDate(), 30));
|
.setOccurrenceEndTime(DateUtils.addDateMinute(DateUtils.getNowDate(), 30));
|
||||||
|
|
||||||
serviceRequests.add(serviceRequest);
|
serviceRequests.add(serviceRequest);
|
||||||
@@ -202,8 +219,12 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR
|
|||||||
return false; // 如果批量插入失败,返回 false
|
return false; // 如果批量插入失败,返回 false
|
||||||
}
|
}
|
||||||
// 批量更新执行状态
|
// 批量更新执行状态
|
||||||
if (!checkServiceRequestIsCompleted(serviceRecords)) {
|
List<Long> serviceIds = checkServiceRequestIsCompleted(serviceRecords);
|
||||||
return false; // 如果批量耿欣失败,返回 false
|
int updateRes = batchUpdateRecordStatus(serviceIds);
|
||||||
|
|
||||||
|
// 如果更新失败,返回 false
|
||||||
|
if (updateRes == 0) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -214,9 +235,9 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR
|
|||||||
* 检查该条服务申请的所有输液信息都完成
|
* 检查该条服务申请的所有输液信息都完成
|
||||||
*
|
*
|
||||||
* @param serviceRecords 同一个服务请求的输液信息列表
|
* @param serviceRecords 同一个服务请求的输液信息列表
|
||||||
* @return 更新成功/失败
|
* @return 更新的ID集合
|
||||||
*/
|
*/
|
||||||
public boolean checkServiceRequestIsCompleted(Map<Long, List<OutpatientInfusionRecordDto>> serviceRecords) {
|
public List<Long> checkServiceRequestIsCompleted(Map<Long, List<OutpatientInfusionRecordDto>> serviceRecords) {
|
||||||
|
|
||||||
// 存储更新的serviceId
|
// 存储更新的serviceId
|
||||||
List<Long> serviceIds = new ArrayList<>();
|
List<Long> serviceIds = new ArrayList<>();
|
||||||
@@ -233,7 +254,8 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR
|
|||||||
int index = 0; // 用于记录当前索引
|
int index = 0; // 用于记录当前索引
|
||||||
|
|
||||||
for (OutpatientInfusionRecordDto record : groupRecords) {
|
for (OutpatientInfusionRecordDto record : groupRecords) {
|
||||||
String prefixBusNo = record.getBusNo() + "." + record.getGroupId() + "." + record.getMedicationId();
|
String prefixBusNo = record.getBusNo() + CommonConstants.Common.DASH + record.getGroupId()
|
||||||
|
+ CommonConstants.Common.DASH + record.getMedicationId();
|
||||||
// 获取执行次数
|
// 获取执行次数
|
||||||
Long exeCount = outpatientManageMapper.countExecuteNumOrGroupNum(serviceId, prefixBusNo, null, true);
|
Long exeCount = outpatientManageMapper.countExecuteNumOrGroupNum(serviceId, prefixBusNo, null, true);
|
||||||
|
|
||||||
@@ -255,11 +277,12 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR
|
|||||||
// 如果最终结果为 1,表示所有记录都满足条件,即当前服务请求的数据全部被执行
|
// 如果最终结果为 1,表示所有记录都满足条件,即当前服务请求的数据全部被执行
|
||||||
if (result == 1) {
|
if (result == 1) {
|
||||||
serviceIds.add(serviceId);
|
serviceIds.add(serviceId);
|
||||||
|
return serviceIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return batchUpdateRecordStatus(serviceIds);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -268,9 +291,10 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR
|
|||||||
* @param serviceIds 服务请求ID列表
|
* @param serviceIds 服务请求ID列表
|
||||||
* @return 修改成功/失败
|
* @return 修改成功/失败
|
||||||
*/
|
*/
|
||||||
public boolean batchUpdateRecordStatus(List<Long> serviceIds) {
|
public int batchUpdateRecordStatus(List<Long> serviceIds) {
|
||||||
if (serviceIds == null || serviceIds.isEmpty()) {
|
if (serviceIds == null || serviceIds.isEmpty()) {
|
||||||
return false; // 如果传入的列表为空,直接返回失败
|
// 返回-1,表示不更新
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
LambdaUpdateWrapper<ServiceRequest> updateWrapper = new LambdaUpdateWrapper<>();
|
LambdaUpdateWrapper<ServiceRequest> updateWrapper = new LambdaUpdateWrapper<>();
|
||||||
@@ -279,8 +303,8 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR
|
|||||||
EventStatus.COMPLETED.getValue());
|
EventStatus.COMPLETED.getValue());
|
||||||
|
|
||||||
int countUpdate = serviceRequestMapper.update(null, updateWrapper);
|
int countUpdate = serviceRequestMapper.update(null, updateWrapper);
|
||||||
// 如果更新的记录数大于 0,返回 true
|
// 如果更新的记录数大于 0
|
||||||
return countUpdate > 0;
|
return countUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -323,14 +347,63 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR
|
|||||||
// 状态是已完成
|
// 状态是已完成
|
||||||
queryWrapper.eq(CommonConstants.FieldName.RequestStatus, EventStatus.COMPLETED.getValue());
|
queryWrapper.eq(CommonConstants.FieldName.RequestStatus, EventStatus.COMPLETED.getValue());
|
||||||
|
|
||||||
|
List<OutpatientInfusionRecordDto> infusionPerformList = editRecords(queryWrapper);
|
||||||
|
List<Long> medicationIds = checkServiceRequestIsCompleted(infusionPerformList);
|
||||||
|
// 未产生执行历史
|
||||||
|
if (medicationIds == null || medicationIds.isEmpty()) {
|
||||||
|
return infusionPerformList;
|
||||||
|
}
|
||||||
|
// 筛选一下执行的药品
|
||||||
|
queryWrapper.in(CommonConstants.FieldName.MedicationId, medicationIds);
|
||||||
|
|
||||||
|
return editRecords(queryWrapper);
|
||||||
|
|
||||||
// 门诊输液待执行记录查询
|
// 门诊输液待执行记录查询
|
||||||
} else {
|
} else {
|
||||||
// based_on_id 为空,此条件筛选控制不显示执行履历
|
// based_on_id 为空,此条件筛选控制不显示执行履历
|
||||||
queryWrapper.isNull(CommonConstants.FieldName.BasedOnId);
|
queryWrapper.isNull(CommonConstants.FieldName.BasedOnId);
|
||||||
// 状态是进行中
|
// 状态是进行中
|
||||||
queryWrapper.eq(CommonConstants.FieldName.RequestStatus, EventStatus.IN_PROGRESS.getValue());
|
queryWrapper.eq(CommonConstants.FieldName.RequestStatus, EventStatus.IN_PROGRESS.getValue());
|
||||||
|
|
||||||
|
return editRecords(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行完成后,显示执行历史
|
||||||
|
*
|
||||||
|
* @param infusionPerformList 执行历史输液列表
|
||||||
|
* @return medicationIds 返回药品id集合
|
||||||
|
*/
|
||||||
|
public List<Long> checkServiceRequestIsCompleted(List<OutpatientInfusionRecordDto> infusionPerformList) {
|
||||||
|
|
||||||
|
List<Long> medicationIds = new ArrayList<>();
|
||||||
|
infusionPerformList.forEach(e -> {
|
||||||
|
|
||||||
|
// 使用正则表达式匹配 . 前面的第一个数字
|
||||||
|
String regex = "(\\d+)\\.";
|
||||||
|
Pattern pattern = Pattern.compile(regex);
|
||||||
|
Matcher matcher = pattern.matcher(e.getBusNo());
|
||||||
|
|
||||||
|
if (matcher.find()) {
|
||||||
|
// 获取匹配的第一个数字
|
||||||
|
medicationIds.add(Long.valueOf(matcher.group(1))); // 添加到 List 中
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return medicationIds;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 显示门诊输液执行记录查询
|
||||||
|
*
|
||||||
|
* @param queryWrapper 查询条件
|
||||||
|
* @return 返回门诊输液执行记录查询
|
||||||
|
*/
|
||||||
|
public List<OutpatientInfusionRecordDto> editRecords(QueryWrapper<OutpatientInfusionRecordDto> queryWrapper) {
|
||||||
|
|
||||||
// 默认显示100条
|
// 默认显示100条
|
||||||
IPage<OutpatientInfusionRecordDto> OutpatientInfusionRecordPage =
|
IPage<OutpatientInfusionRecordDto> OutpatientInfusionRecordPage =
|
||||||
outpatientManageMapper.getOutpatientInfusionRecord(new Page<>(1, 100), queryWrapper);
|
outpatientManageMapper.getOutpatientInfusionRecord(new Page<>(1, 100), queryWrapper);
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
package com.openhis.web.outpatientmanage.dto;
|
package com.openhis.web.outpatientmanage.dto;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||||
import com.openhis.common.annotation.Dict;
|
import com.openhis.common.annotation.Dict;
|
||||||
@@ -65,6 +63,9 @@ public class OutpatientInfusionRecordDto {
|
|||||||
/** 住院执行次数 */
|
/** 住院执行次数 */
|
||||||
private Integer executeNum;
|
private Integer executeNum;
|
||||||
|
|
||||||
|
/** 已经行次数 */
|
||||||
|
private Integer doneNum;
|
||||||
|
|
||||||
/** 分组id */
|
/** 分组id */
|
||||||
@JsonSerialize(using = ToStringSerializer.class)
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
private Long groupId;
|
private Long groupId;
|
||||||
@@ -84,8 +85,8 @@ public class OutpatientInfusionRecordDto {
|
|||||||
/** 发放科室 */
|
/** 发放科室 */
|
||||||
@Dict(dictCode = "id", dictTable = "adm_organization", dictText = "name")
|
@Dict(dictCode = "id", dictTable = "adm_organization", dictText = "name")
|
||||||
@JsonSerialize(using = ToStringSerializer.class)
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
private Long orgId;
|
private Long performOrg;
|
||||||
private String orgId_dictText;
|
private String performOrg_dictText;
|
||||||
|
|
||||||
/** 预计执行时间 */
|
/** 预计执行时间 */
|
||||||
private String occurrenceStartTime;
|
private String occurrenceStartTime;
|
||||||
@@ -94,6 +95,7 @@ public class OutpatientInfusionRecordDto {
|
|||||||
private String occurrenceEndTime;
|
private String occurrenceEndTime;
|
||||||
|
|
||||||
/** 药品ID */
|
/** 药品ID */
|
||||||
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
private Long medicationId;
|
private Long medicationId;
|
||||||
|
|
||||||
/** 药品信息 */
|
/** 药品信息 */
|
||||||
|
|||||||
@@ -185,17 +185,21 @@
|
|||||||
T1.request_status,
|
T1.request_status,
|
||||||
T1.bus_no,
|
T1.bus_no,
|
||||||
T1.execute_num,
|
T1.execute_num,
|
||||||
|
T1.done_num,
|
||||||
T1.based_on_id,
|
T1.based_on_id,
|
||||||
T1.activity_id,
|
T1.activity_id,
|
||||||
T1.prescription_no,
|
T1.prescription_no,
|
||||||
T1.encounter_id,
|
T1.encounter_id,
|
||||||
T1.encounter_bus_no,
|
T1.encounter_bus_no,
|
||||||
T1.patient_name,
|
T1.patient_name,
|
||||||
|
T1.gender_enum,
|
||||||
T1.patient_bus_no,
|
T1.patient_bus_no,
|
||||||
T1.patient_id,
|
T1.patient_id,
|
||||||
T1.medication_information,
|
T1.medication_information,
|
||||||
|
T1.medication_id,
|
||||||
T1.medication_quantity,
|
T1.medication_quantity,
|
||||||
T1.medication_status_Enum,
|
T1.medication_status_enum,
|
||||||
|
T1.rate_code,
|
||||||
T1.group_id,
|
T1.group_id,
|
||||||
T1.skin_test_flag,
|
T1.skin_test_flag,
|
||||||
T1.speed,
|
T1.speed,
|
||||||
@@ -220,13 +224,16 @@
|
|||||||
sr.status_enum AS request_status, --服务请求状态
|
sr.status_enum AS request_status, --服务请求状态
|
||||||
e.bus_no AS encounter_bus_no, --就诊ID(前台显示用)
|
e.bus_no AS encounter_bus_no, --就诊ID(前台显示用)
|
||||||
pt.name AS patient_name, --病人姓名
|
pt.name AS patient_name, --病人姓名
|
||||||
|
pt.gender_enum, --病人性别
|
||||||
pt.bus_no AS patient_bus_no, --病人ID(前台显示用)
|
pt.bus_no AS patient_bus_no, --病人ID(前台显示用)
|
||||||
sr.patient_id, --病人ID
|
sr.patient_id, --病人ID
|
||||||
md.id AS medication_id, --药品ID
|
md.id AS medication_id, --药品ID
|
||||||
md.name AS medication_information, --药品信息
|
md.name AS medication_information, --药品信息
|
||||||
mr.quantity AS medication_quantity,--药品数量
|
mr.quantity AS medication_quantity,--药品数量
|
||||||
mr.status_enum AS medication_status_Enum, --药品状态
|
mr.status_enum AS medication_status_enum, --药品状态
|
||||||
mr.execute_num, -- 药品执行次数
|
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, --注射药品组号
|
mr.group_id, --注射药品组号
|
||||||
mr.perform_org,--执行科室
|
mr.perform_org,--执行科室
|
||||||
CASE mr.skin_test_flag
|
CASE mr.skin_test_flag
|
||||||
|
|||||||
@@ -40,6 +40,11 @@ public class CommonConstants {
|
|||||||
* 3(用于字符串截位)
|
* 3(用于字符串截位)
|
||||||
*/
|
*/
|
||||||
Integer THREE = 3;
|
Integer THREE = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 中杠
|
||||||
|
*/
|
||||||
|
String DASH = "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -118,7 +123,6 @@ public class CommonConstants {
|
|||||||
*/
|
*/
|
||||||
String PatientId = "patient_id";
|
String PatientId = "patient_id";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 就诊号
|
* 就诊号
|
||||||
*/
|
*/
|
||||||
@@ -157,6 +161,11 @@ public class CommonConstants {
|
|||||||
* 请求基于什么的ID
|
* 请求基于什么的ID
|
||||||
*/
|
*/
|
||||||
String BasedOnId = "based_on_id";
|
String BasedOnId = "based_on_id";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 药品id
|
||||||
|
*/
|
||||||
|
String MedicationId = "medication_id";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user