@ -8,10 +8,7 @@ package com.emr.service.ipml;
import com.alibaba.fastjson.JSONArray ;
import com.alibaba.fastjson.JSONObject ;
import com.emr.dao.ArchivePrintinfoMapper ;
import com.emr.dao.Archive_MasterMapper ;
import com.emr.dao.DocusRequestInfoMapper ;
import com.emr.dao.MedicalRecordHomepageCacheMapper ;
import com.emr.dao.* ;
import com.emr.util.HttpClientTool ;
import com.emr.util.IDHelper ;
import com.emr.vo.Power_User_Dto ;
@ -60,6 +57,15 @@ public class Archive_MasterServiceImpl implements Archive_MasterService {
@Autowired
private DocusRequestInfoMapper docusRequestInfoMapper ;
@Autowired
private Emr_DictionaryMapper dictionaryMapper ;
@Autowired
private Emr_Fault_DetailMapper emrFaultDetailMapper ;
@Autowired
private Archive_Master_FollowingMapper archiveMasterFollowingMapper ;
@Override
public Archive_Master selectById ( String id ) {
return archiveMasterMapper . selectById ( id ) ;
@ -180,13 +186,75 @@ public class Archive_MasterServiceImpl implements Archive_MasterService {
PageHelper . offsetPage ( offset , limit ) ;
}
List < Archive_Master_Vo > list = archiveMasterMapper . selectByColumn ( archiveMasterVo ) ;
//设置医生、护士名称和打印标识
//设置医生、护士名称和打印标识 、科室、是否退回医生、是否退回护士
setNameAndPrintFlag ( archiveMasterVo , list ) ;
return list ;
}
//设置科室名称
private void setDeptName ( Archive_Master_Vo archiveMasterVo , List < Emr_Dictionary > dictionaryList ) {
if ( ! CollectionUtils . isEmpty ( dictionaryList ) ) {
String deptAdmissionTo = archiveMasterVo . getDeptAdmissionTo ( ) ;
String deptName = archiveMasterVo . getDeptName ( ) ;
for ( Emr_Dictionary dictionary : dictionaryList ) {
if ( StringUtils . isNotBlank ( deptAdmissionTo ) & & dictionary . getCode ( ) . equals ( deptAdmissionTo ) ) {
archiveMasterVo . setDeptAdmissionTo ( dictionary . getName ( ) ) ;
}
if ( StringUtils . isNotBlank ( deptName ) & & dictionary . getCode ( ) . equals ( deptName ) ) {
archiveMasterVo . setDeptName ( dictionary . getName ( ) ) ;
}
}
}
}
//设置退回医生数量
private void setDoctorFaultNum ( String masterIds , List < Archive_Master_Vo > list ) {
String backFlags = "1" + "," + "5" ;
List < Emr_Fault_Detail > emrFaultDetails = emrFaultDetailMapper . faultBackMasterIdListByBackFlag ( backFlags , masterIds ) ;
if ( ! CollectionUtils . isEmpty ( emrFaultDetails ) ) {
for ( Archive_Master_Vo archiveMasterVo : list ) {
for ( Emr_Fault_Detail detail : emrFaultDetails ) {
if ( detail . getArchiveDetailId ( ) . equals ( archiveMasterVo . getId ( ) ) ) {
archiveMasterVo . setDoctorNum ( detail . getId ( ) . toString ( ) ) ;
break ;
}
}
}
}
}
//设置退回护士数量
private void setNurseFaultNum ( String masterIds , List < Archive_Master_Vo > list ) {
String backFlags = "2" + "," + "6" ;
List < Emr_Fault_Detail > emrFaultDetails = emrFaultDetailMapper . faultBackMasterIdListByBackFlag ( backFlags , masterIds ) ;
if ( ! CollectionUtils . isEmpty ( emrFaultDetails ) ) {
for ( Archive_Master_Vo archiveMasterVo : list ) {
for ( Emr_Fault_Detail detail : emrFaultDetails ) {
if ( detail . getArchiveDetailId ( ) . equals ( archiveMasterVo . getId ( ) ) ) {
archiveMasterVo . setNurseNum ( detail . getId ( ) . toString ( ) ) ;
break ;
}
}
}
}
}
//设置followingType=9
private void setFollowingType ( String masterIds , List < Archive_Master_Vo > list ) {
List < Archive_Master_Following > archiveMasterFollowings = archiveMasterFollowingMapper . selectFollowingByFollowingType ( "9" , masterIds ) ;
if ( ! CollectionUtils . isEmpty ( archiveMasterFollowings ) ) {
for ( Archive_Master_Vo archiveMasterVo : list ) {
for ( Archive_Master_Following following : archiveMasterFollowings ) {
if ( following . getMasterId ( ) . equals ( archiveMasterVo . getId ( ) ) ) {
archiveMasterVo . setFollowingType ( "9" ) ;
break ;
}
}
}
}
}
/ * *
* 设 置 医 生 、 护 士 名 称 和 打 印 标 识
* 设 置 医 生 、 护 士 名 称 和 打 印 标 识 、 科 室 名 称 、 是 否 退 回 医 生 、 是 否 退 回 护 士 , 是 否 followType = 9
* @param archiveMasterVo
* @param list
* /
@ -199,6 +267,10 @@ public class Archive_MasterServiceImpl implements Archive_MasterService {
//转换对象
powerUserList = JSONArray . parseArray ( powerUsers . toJSONString ( ) , Power_User_Dto . class ) ;
}
//查询科室字典
Emr_Dictionary dictionary = new Emr_Dictionary ( ) ;
dictionary . setTypecode ( "dept_code" ) ;
List < Emr_Dictionary > dictionaryList = dictionaryMapper . dicByTypeCode ( dictionary ) ;
//定义查询的masterId集合
StringBuilder masterIds = new StringBuilder ( ) ;
//遍历赋值
@ -237,30 +309,22 @@ public class Archive_MasterServiceImpl implements Archive_MasterService {
printFlag = "已打印" ;
}
archiveMaster . setPrintNum ( printFlag ) ;
} else {
if ( StringUtils . isNotBlank ( masterIds ) ) {
masterIds . append ( "," ) ;
}
masterIds . append ( archiveMaster . getId ( ) ) ;
}
}
//查询打印情况
/ * if ( StringUtils . isNotBlank ( masterIds ) ) {
List < ArchivePrintinfo > archivePrintinfos = archivePrintinfoMapper . selectPrintCountByMasterId ( masterIds . toString ( ) ) ;
//定义初始化打印状态
String printFlag = "未打印" ;
for ( Archive_Master_Vo archiveMaster : list ) {
if ( ! CollectionUtils . isEmpty ( archivePrintinfos ) ) {
for ( ArchivePrintinfo archivePrintinfo : archivePrintinfos ) {
if ( archivePrintinfo . getMasterid ( ) . equals ( archiveMaster . getId ( ) ) ) {
printFlag = "已打印" ;
break ;
}
}
}
archiveMaster . setPrintNum ( printFlag ) ;
if ( StringUtils . isNotBlank ( masterIds ) ) {
masterIds . append ( "," ) ;
}
} * /
masterIds . append ( "'" ) . append ( archiveMaster . getId ( ) ) . append ( "'" ) ;
//设置科室名称
setDeptName ( archiveMaster , dictionaryList ) ;
archiveMaster . setDoctorNum ( "0" ) ;
archiveMaster . setNurseNum ( "0" ) ;
}
//设置退回医生数量
setDoctorFaultNum ( masterIds . toString ( ) , list ) ;
//设置退回护士数量
setNurseFaultNum ( masterIds . toString ( ) , list ) ;
//设置followingType=9
setFollowingType ( masterIds . toString ( ) , list ) ;
}
}
@ -538,7 +602,6 @@ public class Archive_MasterServiceImpl implements Archive_MasterService {
public OffsetLimitPage selectByFollowinglog ( Archive_Master_Vo record , Integer offset , Integer limit ) {
PageHelper . offsetPage ( offset , limit ) ;
List < Archive_Master_Vo > list = archiveMasterMapper . selectByFollowinglog ( record ) ;
return new OffsetLimitPage ( ( Page ) list ) ;
}
@ -636,7 +699,7 @@ public class Archive_MasterServiceImpl implements Archive_MasterService {
map . put ( "userid" , user . getUserId ( ) . toString ( ) ) ;
map . put ( "username" , user . getUserName ( ) ) ;
map . put ( "code" , archiveMaster . getDeptName ( ) ) ;
map . put ( "REASON" , returnContent. toString ( ) ) ;
map . put ( "REASON" , emrFaultDetail. getDealPerson ( ) ) ;
//定义请求信息记录表
DocusRequestInfo docusRequestInfo = new DocusRequestInfo ( ) ;
docusRequestInfo . setCode ( "return" ) ;