优化科主任审核页面拆成单表查询

master
linjj 2 years ago
parent 95c8d3fe7e
commit affb802536

@ -2,14 +2,13 @@ package com.emr.dao;
import com.emr.dto.Archive_MasterDto;
import com.emr.entity.Archive_Master;
import com.emr.entity.Archive_Master_Following;
import com.emr.entity.Archive_Master_Vo;
import com.emr.entity.CommomVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface Archive_MasterMapper {
public interface Archive_MasterMapper {
/**
*
* @param id
@ -257,4 +256,21 @@ public interface Archive_MasterMapper {
Integer selectTime1(Archive_Master_Vo archiveMasterVo);
List<Archive_MasterDto> selectChildMasterId(String time);
/**
* @description:
* @params: id
* @return: Archive_Master_Vo
* @author linjj
* @date: 2023/6/29 17:17
*/
List<Archive_Master_Vo> getDoctorDefectNum(@Param(value = "ids")String ids);
/**
* @description:
* @params: id
* @return: Archive_Master_Vo
* @author linjj
* @date: 2023/6/29 17:17
*/
List<Archive_Master_Vo> getNurseDefectNum(@Param(value = "ids")String ids);
}

@ -279,6 +279,8 @@ public class Archive_Master_Vo {
private Integer countNum;
private String archiveDetailId;
public Integer getFlag() {
return flag;
}

@ -10,8 +10,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.emr.dao.*;
import com.emr.service.Emr_DictionaryService;
import com.emr.util.HttpClientTool;
import com.emr.util.IDHelper;
import com.emr.util.*;
import com.emr.vo.GetTime;
import com.emr.vo.Power_User_Dto;
import com.emr.entity.*;
@ -34,6 +33,7 @@ import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Service
@ -1140,7 +1140,6 @@ public class Archive_MasterServiceImpl implements Archive_MasterService {
log.error(errorStr);
}
}
@Override
public List<Archive_Master_Vo> selectByCmtByColumn(Archive_Master_Vo archiveMasterVo, Integer offset, Integer limit) {
//判断并设置查询是否打印权限
@ -1149,7 +1148,57 @@ public class Archive_MasterServiceImpl implements Archive_MasterService {
if(null != offset && null != limit) {
PageHelper.offsetPage(offset, limit);
}
//转换科室
List<Archive_Master_Vo> list = archiveMasterMapper.selectByCmtCol(archiveMasterVo);
//masterIds集合
List<String> masterIds = ListUtils.distinctSelect(list, Archive_Master_Vo::getId);
//转成逗号拼接
String ids = String.join(",", masterIds);
//获取医生缺陷数量
List<Archive_Master_Vo> doctorDefectNum = archiveMasterMapper.getDoctorDefectNum(ids);
//医生是否有缺陷
Map<String, Archive_Master_Vo> doctorMap = ListUtils.toMap(doctorDefectNum, Archive_Master_Vo::getArchiveDetailId);
Setters.<Archive_Master_Vo>instance().list(list).cycleSetProperties(p -> {
String doctorId = p.getId();
if (doctorMap.containsKey(doctorId)){
String faultDoctorNum = doctorMap.get(doctorId).getFaultDoctorNum();
p.setFaultDoctorNum(faultDoctorNum);
p.setNumb(1);
}
});
//获取护士缺陷数量
List<Archive_Master_Vo> nurseDefectNum = archiveMasterMapper.getNurseDefectNum(ids);
//护士是否有缺陷
Map<String, Archive_Master_Vo> nurseMap = ListUtils.toMap(nurseDefectNum, Archive_Master_Vo::getArchiveDetailId);
//判断是否有缺陷就填入
Setters.<Archive_Master_Vo>instance().list(list).cycleSetProperties(p -> {
String nurseId = p.getId();
if (nurseMap.containsKey(nurseId)){
String faultNurseNum = nurseMap.get(nurseId).getFaultNurseNum();
p.setFaultNurseNum(faultNurseNum);
p.setNumb(1);
}
});
//获取科室列表
Emr_Dictionary dic = new Emr_Dictionary();
dic.setEffective(1);
dic.setTypecode("dept_code");
List<Emr_Dictionary> dicList = emrDictionaryService.dicByTypeCode(dic);
//转换科室
Map<String, Emr_Dictionary> codeMap = ListUtils.toMap(dicList, Emr_Dictionary::getCode);
Setters.<Archive_Master_Vo>instance().list(list).cycleSetProperties(p -> {
String deptCode = p.getDeptName();
String deptAdmissionCode = p.getDeptAdmissionTo();
if(StringUtils.isNotBlank(deptCode) && codeMap.containsKey(deptCode)){
String deptName = codeMap.get(deptCode).getName();
p.setDeptName(deptName);
}
if(StringUtils.isNotBlank(deptAdmissionCode) && codeMap.containsKey(deptAdmissionCode)){
String deptAdmissionTo = codeMap.get(deptAdmissionCode).getName();
p.setDeptAdmissionTo(deptAdmissionTo);
}
});
//设置医生、护士名称和打印标识
setNameAndPrintFlag(archiveMasterVo, list);
return list;

@ -0,0 +1,12 @@
package com.emr.util;
/**
* @InterfaceName FieldSelector
* @Description
* @Author linjj
* @Date 2023/6/29 16:41
* @Version 1.0
*/
public interface FieldSelector<Type, FieldType> {
FieldType select(Type type);
}

@ -0,0 +1,22 @@
package com.emr.util;
import java.util.List;
public class ListPropertySetter<T> {
private final List<T> values;
public ListPropertySetter(List<T> values) {
this.values = values;
}
public List<T> cycleSetProperties(PropertySetter<T> setter) {
if (null == values) return values;
for (T value : values) {
setter.apply(value);
}
return values;
}
}

@ -0,0 +1,79 @@
package com.emr.util;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
public final class ListUtils {
public static <T, K> Map<K, T> toMap(List<T> list, FieldSelector<T, K> selector) {
if (CollectionUtils.isEmpty(list)) return Collections.emptyMap();
Map<K, T> map = new HashMap<>(list.size());
for (T t : list) {
K key = selector.select(t);
if (key != null) map.put(key, t);
}
return map;
}
public static <T, K> Map<K, List<T>> groupBy(List<T> list, FieldSelector<T, K> selector) {
if (CollectionUtils.isEmpty(list)) return Collections.emptyMap();
Map<K, List<T>> map = new HashMap<>();
for (T t : list) {
K key = selector.select(t);
if (key == null) continue;
if (!map.containsKey(key)) {
map.put(key, new ArrayList<T>());
}
map.get(key).add(t);
}
return map;
}
public static <T, K> List<K> select(List<T> list, FieldSelector<T, K> selector) {
if (CollectionUtils.isEmpty(list)) return Collections.emptyList();
List<K> filedList = new ArrayList<>(list.size());
for (T t : list) {
K key = selector.select(t);
if (key != null) filedList.add(key);
}
return filedList;
}
public static <T, K> List<K> distinctSelect(List<T> list, FieldSelector<T, K> selector) {
if (CollectionUtils.isEmpty(list)) return Collections.emptyList();
Set<K> filedSet = new HashSet<>();
for (T t : list) {
K key = selector.select(t);
if (key != null) filedSet.add(key);
}
return new ArrayList<>(filedSet);
}
@SafeVarargs
public static <T> List<T> unionWithoutDuplicate(List<T>... values) {
if (null == values || values.length <= 0) return Collections.emptyList();
Set<T> unionFiledSet = new HashSet<>();
for (List<T> value : values) {
if (!CollectionUtils.isEmpty(value)) {
unionFiledSet.addAll(value);
}
}
return new ArrayList<>(unionFiledSet);
}
public static <T, K> List<T> skipDuplicateKey(List<T> list, FieldSelector<T, K> selector) {
if (CollectionUtils.isEmpty(list)) return Collections.emptyList();
List<T> filedList = new ArrayList<>(list.size());
Map<K, T> map = toMap(list, selector);
for (K key : map.keySet()) {
filedList.add(map.get(key));
}
return filedList;
}
}

@ -0,0 +1,7 @@
package com.emr.util;
public interface PropertySetter<T> {
void apply(T t);
}

@ -0,0 +1,14 @@
package com.emr.util;
import java.util.List;
public class Setters<T> {
public static <T> Setters<T> instance() {
return new Setters<>();
}
public ListPropertySetter<T> list(List<T> values) {
return new ListPropertySetter<>(values);
}
}

@ -974,35 +974,16 @@
</select>
<select id="selectByCmtCol" parameterType="com.emr.entity.Archive_Master_Vo" resultMap="BaseResultMap2">
select m.id,m.patient_id,m.inp_no,m.visit_id,m.name,m.sex,ISNULL(f.name,m.dept_name) dept_name
,CONVERT(varchar(10),m.discharge_date_time, 120) discharge_date_time,m.ArchiveState,CONVERT(varchar(10),m.admission_date_time, 120) admission_date_time,ISNULL(d.name,m.dept_admission_to) dept_admission_to
select m.id,m.patient_id,m.inp_no,m.visit_id,m.name,m.sex,m.dept_name
,CONVERT(varchar(10),m.discharge_date_time, 120) discharge_date_time,m.ArchiveState,CONVERT(varchar(10),m.admission_date_time, 120) admission_date_time,m.dept_admission_to
,m.check_doctor,m.checked_datetime,m.checked_doctor,m.LockInfo,m.DOCTOR_IN_CHARGE,m.ID_NO,m.DISCHARGE_DISPOSITION,m.dept_code_lend,m.isscaned,m.is_scanning,
m.cmt_doctor,m.cmt_nurse,m.doctor_name,m.nurse_name,m.cmt_doctor_date,m.cmt_nurse_date,m.emr_doctor_cmt,m.emr_nure_cmt,m.death_flag,m.bed_number,ISNULL(s.numb, 0) numb
,ISNULL(sDoctor.numb, 0) faultDoctorNum,ISNULL(sNurse.numb, 0) faultNurseNum,ISNULL(printTable.num, 0) printNum
m.cmt_doctor,m.cmt_nurse,m.doctor_name,m.nurse_name,m.cmt_doctor_date,m.cmt_nurse_date,m.emr_doctor_cmt,m.emr_nure_cmt,m.death_flag,m.bed_number,
ISNULL(m.print_flag, 0) printNum
from archive_master m
LEFT JOIN (select code,name from emr_dictionary where parent_id=(select id from emr_dictionary where
typeCode='dept_code' )) d
on m.dept_admission_to=d.code
LEFT JOIN(select archive_detail_id,count(*) numb from emr_fault_detail where 1=1 and back_flag in ('1','5') GROUP BY archive_detail_id) sDoctor
on m.id=sDoctor.archive_detail_id
LEFT JOIN(select archive_detail_id,count(*) numb from emr_fault_detail where 1=1 and back_flag in ('2','6') GROUP BY archive_detail_id) sNurse
on m.id=sNurse.archive_detail_id
LEFT JOIN (select code,name from emr_dictionary where parent_id=(select id from emr_dictionary where
typeCode='dept_code' )) f
on m.dept_name=f.code
LEFT JOIN(select archive_detail_id,count(*) numb from emr_fault_detail where 1=1 and back_flag is not null GROUP BY archive_detail_id) s
on m.id=s.archive_detail_id
LEFT JOIN (select MasterID,COUNT(*) num from archive_printInfo group by MasterID) printTable
on m.id=printTable.MasterID
where 1=1 and ArchiveState in('提交','主任退回','归档中','复审退回')
and patindex('%B%',m.inp_no) = 0 and inp_no not like 'LG%' and m.Is_Valid!=1
<if test="printNum != null and printNum != ''">
<choose>
<when test="printNum == 1">
and printTable.MasterID is not null
</when>
<otherwise>and printTable.MasterID is null</otherwise>
</choose>
<if test="printNum !=null and printNum !=''">
AND m.print_flag=#{printNum}
</if>
<if test="inpNo != null and inpNo != ''">
and m.inp_no like '%'+#{inpNo,jdbcType=NCHAR}+'%'
@ -2610,4 +2591,34 @@
<select id="selectChildMasterId" resultType="com.emr.dto.Archive_MasterDto">
select id,inp_no from Archive_Master where admission_date_time = #{time}
</select>
<select id="getDoctorDefectNum" resultType="com.emr.entity.Archive_Master_Vo">
SELECT
archive_detail_id,
count(*) faultDoctorNum
FROM
emr_fault_detail
WHERE
back_flag IN ( '1', '5' )
and archive_detail_id in
<foreach item="item" collection="ids.split(',')" open="(" separator="," close=")">
#{item}
</foreach>
GROUP BY
archive_detail_id
</select>
<select id="getNurseDefectNum" resultType="com.emr.entity.Archive_Master_Vo">
SELECT
archive_detail_id,
count(*) faultNurseNum
FROM
emr_fault_detail
WHERE
back_flag IN ( '2', '6' )
and archive_detail_id in
<foreach item="item" collection="ids.split(',')" open="(" separator="," close=")">
#{item}
</foreach>
GROUP BY
archive_detail_id
</select>
</mapper>

@ -1643,7 +1643,7 @@
$(function () {
//initTableLg();
getFaultType();
// getFaultType();
var objUrl;
var img_html;
var MasterID;

@ -3623,11 +3623,11 @@
var redFlag = row.numb;
if (redFlag != 0) {
//有退回给医生的缺陷
if(row.faultDoctorNum!= 0){
if(row.faultDoctorNum!= 0 && row.faultDoctorNum!=null) {
html = html + '<button type="button" class="btn btn-sm btn-info getQXDoctorInfo">医生查看缺陷</button>';
}
//有退回给护士的缺陷
if(row.faultNurseNum!= 0){
if(row.faultNurseNum!= 0 && row.faultNurseNum!=null){
html = html + '<button type="button" class="btn btn-sm btn-info getQXNurseInfo">护士查看缺陷</button>';
}
}

Loading…
Cancel
Save