门诊输液 up
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.openhis.web.outpatientmanage.appservice.impl;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -124,7 +126,21 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR
|
||||
IPage<OutpatientInfusionRecordDto> OutpatientInfusionRecordPage =
|
||||
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;
|
||||
}
|
||||
|
||||
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(record.getServiceId(), prefixBusNo, null, true);
|
||||
@@ -189,7 +206,7 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR
|
||||
.setActivityId(record.getActivityId()).setPatientId(record.getPatientId())
|
||||
.setEncounterId(record.getEncounterId()).setPerformerId(practitioner.getId())
|
||||
.setPerformerTypeCode(practitionerRole.getRoleCode())
|
||||
.setOccurrenceStartTime(DateUtils.getNowDate())
|
||||
.setOccurrenceStartTime(DateUtils.getNowDate()).setRequesterId(practitioner.getId())
|
||||
.setOccurrenceEndTime(DateUtils.addDateMinute(DateUtils.getNowDate(), 30));
|
||||
|
||||
serviceRequests.add(serviceRequest);
|
||||
@@ -202,8 +219,12 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR
|
||||
return false; // 如果批量插入失败,返回 false
|
||||
}
|
||||
// 批量更新执行状态
|
||||
if (!checkServiceRequestIsCompleted(serviceRecords)) {
|
||||
return false; // 如果批量耿欣失败,返回 false
|
||||
List<Long> serviceIds = checkServiceRequestIsCompleted(serviceRecords);
|
||||
int updateRes = batchUpdateRecordStatus(serviceIds);
|
||||
|
||||
// 如果更新失败,返回 false
|
||||
if (updateRes == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -214,9 +235,9 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR
|
||||
* 检查该条服务申请的所有输液信息都完成
|
||||
*
|
||||
* @param serviceRecords 同一个服务请求的输液信息列表
|
||||
* @return 更新成功/失败
|
||||
* @return 更新的ID集合
|
||||
*/
|
||||
public boolean checkServiceRequestIsCompleted(Map<Long, List<OutpatientInfusionRecordDto>> serviceRecords) {
|
||||
public List<Long> checkServiceRequestIsCompleted(Map<Long, List<OutpatientInfusionRecordDto>> serviceRecords) {
|
||||
|
||||
// 存储更新的serviceId
|
||||
List<Long> serviceIds = new ArrayList<>();
|
||||
@@ -233,7 +254,8 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR
|
||||
int index = 0; // 用于记录当前索引
|
||||
|
||||
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);
|
||||
|
||||
@@ -255,11 +277,12 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR
|
||||
// 如果最终结果为 1,表示所有记录都满足条件,即当前服务请求的数据全部被执行
|
||||
if (result == 1) {
|
||||
serviceIds.add(serviceId);
|
||||
return serviceIds;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return batchUpdateRecordStatus(serviceIds);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,9 +291,10 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR
|
||||
* @param serviceIds 服务请求ID列表
|
||||
* @return 修改成功/失败
|
||||
*/
|
||||
public boolean batchUpdateRecordStatus(List<Long> serviceIds) {
|
||||
public int batchUpdateRecordStatus(List<Long> serviceIds) {
|
||||
if (serviceIds == null || serviceIds.isEmpty()) {
|
||||
return false; // 如果传入的列表为空,直接返回失败
|
||||
// 返回-1,表示不更新
|
||||
return -1;
|
||||
}
|
||||
|
||||
LambdaUpdateWrapper<ServiceRequest> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
@@ -279,8 +303,8 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR
|
||||
EventStatus.COMPLETED.getValue());
|
||||
|
||||
int countUpdate = serviceRequestMapper.update(null, updateWrapper);
|
||||
// 如果更新的记录数大于 0,返回 true
|
||||
return countUpdate > 0;
|
||||
// 如果更新的记录数大于 0
|
||||
return countUpdate;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -323,14 +347,63 @@ public class OutpatientInfusionRecordServiceImpl implements IOutpatientInfusionR
|
||||
// 状态是已完成
|
||||
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 {
|
||||
// based_on_id 为空,此条件筛选控制不显示执行履历
|
||||
queryWrapper.isNull(CommonConstants.FieldName.BasedOnId);
|
||||
// 状态是进行中
|
||||
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条
|
||||
IPage<OutpatientInfusionRecordDto> OutpatientInfusionRecordPage =
|
||||
outpatientManageMapper.getOutpatientInfusionRecord(new Page<>(1, 100), queryWrapper);
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.openhis.web.outpatientmanage.dto;
|
||||
|
||||
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.ser.std.ToStringSerializer;
|
||||
import com.openhis.common.annotation.Dict;
|
||||
@@ -65,6 +63,9 @@ public class OutpatientInfusionRecordDto {
|
||||
/** 住院执行次数 */
|
||||
private Integer executeNum;
|
||||
|
||||
/** 已经行次数 */
|
||||
private Integer doneNum;
|
||||
|
||||
/** 分组id */
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long groupId;
|
||||
@@ -84,8 +85,8 @@ public class OutpatientInfusionRecordDto {
|
||||
/** 发放科室 */
|
||||
@Dict(dictCode = "id", dictTable = "adm_organization", dictText = "name")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long orgId;
|
||||
private String orgId_dictText;
|
||||
private Long performOrg;
|
||||
private String performOrg_dictText;
|
||||
|
||||
/** 预计执行时间 */
|
||||
private String occurrenceStartTime;
|
||||
@@ -94,6 +95,7 @@ public class OutpatientInfusionRecordDto {
|
||||
private String occurrenceEndTime;
|
||||
|
||||
/** 药品ID */
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long medicationId;
|
||||
|
||||
/** 药品信息 */
|
||||
|
||||
@@ -133,34 +133,34 @@
|
||||
<select id="getOutpatientInfusionPatient"
|
||||
resultType="com.openhis.web.outpatientmanage.dto.OutpatientInfusionPatientDto">
|
||||
SELECT
|
||||
T1.tenant_id,
|
||||
T1.service_id,
|
||||
T1.prescription_no,
|
||||
T1.encounter_bus_no,
|
||||
T1.birth_date,
|
||||
T1.patient_bus_no,
|
||||
T1.patient_id,
|
||||
T1.patient_name,
|
||||
T1.id_card,
|
||||
T1.gender_enum,
|
||||
T1.create_time
|
||||
T1.tenant_id,
|
||||
T1.service_id,
|
||||
T1.prescription_no,
|
||||
T1.encounter_bus_no,
|
||||
T1.birth_date,
|
||||
T1.patient_bus_no,
|
||||
T1.patient_id,
|
||||
T1.patient_name,
|
||||
T1.id_card,
|
||||
T1.gender_enum,
|
||||
T1.create_time
|
||||
FROM
|
||||
(
|
||||
SELECT DISTINCT
|
||||
sr.id AS service_id, --服务申请管理ID
|
||||
sr.prescription_no, --处方号
|
||||
sr.encounter_id,
|
||||
e.bus_no as encounter_bus_no, --就诊号
|
||||
TO_CHAR(pt.birth_date, 'YYYY-MM-DD') AS birth_date, --病人生日
|
||||
pt.bus_no AS patient_bus_no, --病人ID(前台显示用)
|
||||
sr.patient_id, --病人ID
|
||||
pt.name AS patient_name, --病人姓名
|
||||
pt.id_card AS id_card, --病人身份证号
|
||||
sr.tenant_id,
|
||||
pt.gender_enum, --病人性别
|
||||
to_char(mr.create_time, 'YYYY-MM-DD HH24:MI:SS') AS create_time--开单时间
|
||||
sr.id AS service_id, --服务申请管理ID
|
||||
sr.prescription_no, --处方号
|
||||
sr.encounter_id,
|
||||
e.bus_no as encounter_bus_no, --就诊号
|
||||
TO_CHAR(pt.birth_date, 'YYYY-MM-DD') AS birth_date, --病人生日
|
||||
pt.bus_no AS patient_bus_no, --病人ID(前台显示用)
|
||||
sr.patient_id, --病人ID
|
||||
pt.name AS patient_name, --病人姓名
|
||||
pt.id_card AS id_card, --病人身份证号
|
||||
sr.tenant_id,
|
||||
pt.gender_enum, --病人性别
|
||||
to_char(mr.create_time, 'YYYY-MM-DD HH24:MI:SS') AS create_time--开单时间
|
||||
FROM
|
||||
wor_service_request sr
|
||||
wor_service_request sr
|
||||
LEFT JOIN adm_encounter e ON e.id = sr.encounter_id
|
||||
LEFT JOIN adm_patient pt ON pt.id = sr.patient_id
|
||||
LEFT JOIN wor_activity_definition ad ON ad.id = sr.activity_id
|
||||
@@ -185,17 +185,21 @@
|
||||
T1.request_status,
|
||||
T1.bus_no,
|
||||
T1.execute_num,
|
||||
T1.done_num,
|
||||
T1.based_on_id,
|
||||
T1.activity_id,
|
||||
T1.prescription_no,
|
||||
T1.encounter_id,
|
||||
T1.encounter_bus_no,
|
||||
T1.patient_name,
|
||||
T1.gender_enum,
|
||||
T1.patient_bus_no,
|
||||
T1.patient_id,
|
||||
T1.medication_information,
|
||||
T1.medication_id,
|
||||
T1.medication_quantity,
|
||||
T1.medication_status_Enum,
|
||||
T1.medication_status_enum,
|
||||
T1.rate_code,
|
||||
T1.group_id,
|
||||
T1.skin_test_flag,
|
||||
T1.speed,
|
||||
@@ -210,54 +214,57 @@
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
sr.tenant_id,
|
||||
sr.id AS service_id, --服务申请管理ID
|
||||
sr.bus_no, -- 服务请求编码
|
||||
sr.based_on_id, -- 请求基于什么的ID
|
||||
sr.activity_id,--请求code,输液
|
||||
sr.prescription_no, --处方号
|
||||
sr.encounter_id , --就诊ID
|
||||
sr.status_enum AS request_status, --服务请求状态
|
||||
e.bus_no AS encounter_bus_no, --就诊ID(前台显示用)
|
||||
pt.name AS patient_name, --病人姓名
|
||||
pt.bus_no AS patient_bus_no, --病人ID(前台显示用)
|
||||
sr.patient_id, --病人ID
|
||||
md.id AS medication_id, --药品ID
|
||||
md.name AS medication_information, --药品信息
|
||||
mr.quantity AS medication_quantity,--药品数量
|
||||
mr.status_enum AS medication_status_Enum, --药品状态
|
||||
mr.execute_num, -- 药品执行次数
|
||||
mr.group_id, --注射药品组号
|
||||
mr.perform_org,--执行科室
|
||||
CASE mr.skin_test_flag
|
||||
WHEN 1 THEN 1
|
||||
ELSE 0
|
||||
END AS skin_test_flag ,--皮试标志
|
||||
mr.speed, --输液速度
|
||||
mr.method_code,--用法
|
||||
mr.dose || ' '|| mr.dose_unit_code AS dose,--单次剂量,剂量单位
|
||||
mr.practitioner_id as doctor_id, --开单医生
|
||||
mr.org_id,--开单科室
|
||||
sr.performer_id, --执行护士
|
||||
to_char(sr.occurrence_start_time, 'YYYY-MM-DD HH24:MI:SS') AS occurrence_start_time, --预计执行时间
|
||||
to_char(sr.occurrence_end_time, 'YYYY-MM-DD HH24:MI:SS') AS occurrence_end_time, --预计结束时间
|
||||
to_char(mr.create_time, 'YYYY-MM-DD HH24:MI:SS') AS create_time--开单时间
|
||||
FROM
|
||||
wor_service_request sr
|
||||
LEFT JOIN adm_encounter e ON e.id = sr.encounter_id
|
||||
LEFT JOIN adm_patient pt ON pt.id = sr.patient_id
|
||||
LEFT JOIN wor_activity_definition ad ON ad.id = sr.activity_id
|
||||
LEFT JOIN med_medication_request mr ON mr.prescription_no = sr.prescription_no
|
||||
LEFT JOIN med_medication m ON m.id = mr.medication_id
|
||||
LEFT JOIN med_medication_definition md ON md.id = m.medication_def_id
|
||||
LEFT JOIN cli_allergy_intolerance ai ON ai.request_id = sr.id
|
||||
<where>
|
||||
ad.bus_no = 'sy001' -- 输液检查的编号,todo:编号未定,后期修改
|
||||
AND mr.infusion_flag = 1
|
||||
sr.tenant_id,
|
||||
sr.id AS service_id, --服务申请管理ID
|
||||
sr.bus_no, -- 服务请求编码
|
||||
sr.based_on_id, -- 请求基于什么的ID
|
||||
sr.activity_id,--请求code,输液
|
||||
sr.prescription_no, --处方号
|
||||
sr.encounter_id , --就诊ID
|
||||
sr.status_enum AS request_status, --服务请求状态
|
||||
e.bus_no AS encounter_bus_no, --就诊ID(前台显示用)
|
||||
pt.name AS patient_name, --病人姓名
|
||||
pt.gender_enum, --病人性别
|
||||
pt.bus_no AS patient_bus_no, --病人ID(前台显示用)
|
||||
sr.patient_id, --病人ID
|
||||
md.id AS medication_id, --药品ID
|
||||
md.name AS medication_information, --药品信息
|
||||
mr.quantity AS medication_quantity,--药品数量
|
||||
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, --注射药品组号
|
||||
mr.perform_org,--执行科室
|
||||
CASE mr.skin_test_flag
|
||||
WHEN 1 THEN 1
|
||||
ELSE 0
|
||||
END AS skin_test_flag ,--皮试标志
|
||||
mr.speed, --输液速度
|
||||
mr.method_code,--用法
|
||||
mr.dose || ' '|| mr.dose_unit_code AS dose,--单次剂量,剂量单位
|
||||
mr.practitioner_id as doctor_id, --开单医生
|
||||
mr.org_id,--开单科室
|
||||
sr.performer_id, --执行护士
|
||||
to_char(sr.occurrence_start_time, 'YYYY-MM-DD HH24:MI:SS') AS occurrence_start_time, --预计执行时间
|
||||
to_char(sr.occurrence_end_time, 'YYYY-MM-DD HH24:MI:SS') AS occurrence_end_time, --预计结束时间
|
||||
to_char(mr.create_time, 'YYYY-MM-DD HH24:MI:SS') AS create_time--开单时间
|
||||
FROM
|
||||
wor_service_request sr
|
||||
LEFT JOIN adm_encounter e ON e.id = sr.encounter_id
|
||||
LEFT JOIN adm_patient pt ON pt.id = sr.patient_id
|
||||
LEFT JOIN wor_activity_definition ad ON ad.id = sr.activity_id
|
||||
LEFT JOIN med_medication_request mr ON mr.prescription_no = sr.prescription_no
|
||||
LEFT JOIN med_medication m ON m.id = mr.medication_id
|
||||
LEFT JOIN med_medication_definition md ON md.id = m.medication_def_id
|
||||
LEFT JOIN cli_allergy_intolerance ai ON ai.request_id = sr.id
|
||||
<where>
|
||||
ad.bus_no = 'sy001' -- 输液检查的编号,todo:编号未定,后期修改
|
||||
AND mr.infusion_flag = 1
|
||||
|
||||
</where>
|
||||
ORDER BY
|
||||
create_time desc,e.bus_no,pt.bus_no
|
||||
</where>
|
||||
ORDER BY
|
||||
create_time desc,e.bus_no,pt.bus_no
|
||||
) AS T1
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
@@ -40,6 +40,11 @@ public class CommonConstants {
|
||||
* 3(用于字符串截位)
|
||||
*/
|
||||
Integer THREE = 3;
|
||||
|
||||
/**
|
||||
* 中杠
|
||||
*/
|
||||
String DASH = "-";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,7 +123,6 @@ public class CommonConstants {
|
||||
*/
|
||||
String PatientId = "patient_id";
|
||||
|
||||
|
||||
/**
|
||||
* 就诊号
|
||||
*/
|
||||
@@ -157,6 +161,11 @@ public class CommonConstants {
|
||||
* 请求基于什么的ID
|
||||
*/
|
||||
String BasedOnId = "based_on_id";
|
||||
|
||||
/**
|
||||
* 药品id
|
||||
*/
|
||||
String MedicationId = "medication_id";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user