@ -1,9 +1,9 @@
package com.emr.service.ipml ;
import com.emr.dao.EmrHolidaySetMapper ;
import com.emr.dao.Emr_DictionaryMapper ;
import com.emr.dao.RecordMapper ;
import com.emr.entity.Archive_Master_Vo ;
import com.emr.entity.Emr_Dictionary ;
import com.emr.entity.* ;
import com.emr.service.Archive_MasterService ;
import com.emr.util.Msg ;
import com.emr.vo.* ;
@ -12,7 +12,9 @@ import org.apache.shiro.util.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.stereotype.Service ;
import java.util.List ;
import javax.servlet.http.HttpServletRequest ;
import java.text.SimpleDateFormat ;
import java.util.* ;
@Service
public class RecordService {
@ -24,11 +26,171 @@ public class RecordService {
private CommomService commomService ;
@Autowired
private Archive_MasterService archiveMasterService ;
@Autowired
private EmrOvertimeSetService overtimeSetService ;
@Autowired
private EmrHolidaySetMapper holidaySetMapper ;
@Autowired
private ZdAssortService assortService ;
@Autowired
private ArchiveOtherExtService otherExtService ;
/ * *
* 病 案 提 交 统 计
* @return
* /
public List < SubmitRecord > selectUnCountGroupDept ( RecordSearch recordSearch ) {
public List < SubmitRecord > selectUnCountGroupDept ( RecordSearch recordSearch , HttpServletRequest request ) throws Exception {
/ * Integer infoId = recordSearch . getInfoId ( ) ;
if ( null ! = infoId ) {
//有按审核角色查询
if ( infoId < 5 ) {
//医生支线
recordSearch . setOperRole ( 1 ) ;
} else if ( infoId = = 5 | | infoId = = 6 ) {
//护士支线
recordSearch . setOperRole ( 2 ) ;
} else if ( infoId = = 8 ) {
recordSearch . setOperRole ( 4 ) ;
}
} * /
//按科室查询总出院人数
List < SubmitRecord > unSubmitRecords = recordMapper . selectUnCountGroupDept ( recordSearch ) ;
if ( ! CollectionUtils . isEmpty ( unSubmitRecords ) ) {
if ( null ! = recordSearch . getFlag ( ) & & recordSearch . getFlag ( ) = = 2 ) {
//过滤超期
unSubmitRecords = selectOvertimeRecord ( unSubmitRecords ) ;
}
//按科室填充数据
unSubmitRecords = selectUnSubmitCountGroupDept ( unSubmitRecords ) ;
//填充各个角色数据、主要填充已提交的
selectList ( unSubmitRecords ) ;
}
request . getSession ( ) . setAttribute ( "unSubmitRecords" , unSubmitRecords ) ;
return unSubmitRecords ;
}
/ * *
* 过 滤 未 过 期 的
* @param unSubmitRecords
* @return
* /
private List < SubmitRecord > selectOvertimeRecord ( List < SubmitRecord > unSubmitRecords ) throws Exception {
//查询超期参数
EmrOvertimeSet overtimeSet = overtimeSetService . selectByPrimaryKey ( 1 ) ;
//获取未超期列表
List < EmrHolidaySet > unHolidays = holidaySetMapper . selectNotHolidayList ( ) ;
Iterator < SubmitRecord > iterator = unSubmitRecords . iterator ( ) ;
//获取非死亡工作日
String date = unHolidays . get ( overtimeSet . getDays ( ) ) . getDate ( ) ;
//获取非死亡工作日
String deadDate = unHolidays . get ( overtimeSet . getDeadDays ( ) ) . getDate ( ) ;
//定义格式化日期
SimpleDateFormat fmt = new SimpleDateFormat ( "yyyy-MM-dd" ) ;
while ( iterator . hasNext ( ) ) {
SubmitRecord record = ( SubmitRecord ) iterator . next ( ) ;
//获取是否死亡
String dischargeDisposition = record . getDischargeDisposition ( ) ;
String dischargeDateTime = record . getDischargeDateTime ( ) ;
long time = fmt . parse ( dischargeDateTime ) . getTime ( ) ;
if ( StringUtils . isNotBlank ( dischargeDisposition ) & & "5" . equals ( dischargeDisposition ) ) {
//死亡
if ( time > = fmt . parse ( deadDate ) . getTime ( ) ) {
iterator . remove ( ) ;
}
} else {
//非死亡
if ( time > = fmt . parse ( date ) . getTime ( ) ) {
iterator . remove ( ) ;
}
}
}
return unSubmitRecords ;
}
/ * *
* 按 科 室 查 询 总 出 院 人 数
* @param unSubmitRecords 出 院 列 表
* @return
* /
private List < SubmitRecord > selectUnSubmitCountGroupDept ( List < SubmitRecord > unSubmitRecords ) {
//查询科室集合
List < Emr_Dictionary > depts = dictionaryMapper . selectAllByParentId ( "dept_code" , "CODE" ) ;
//医生未提交状态码集合
String [ ] unDoctorSubmitArr = { "1" , "16" , "48" , "512" , "256" , "272" , "304" , "768" } ;
List < String > unDoctorSubmitStr = Arrays . asList ( unDoctorSubmitArr ) ;
//医生质控员未提交状态码集合
String [ ] unDoctorCheckArr = { "2" , "18" , "50" , "514" } ;
List < String > unDoctorCheckStr = Arrays . asList ( unDoctorCheckArr ) ;
//科主任未提交状态码集合
String [ ] unDirectorCheckArr = { "6" , "22" , "54" , "518" } ;
List < String > unDirectorCheckStr = Arrays . asList ( unDirectorCheckArr ) ;
//护士未提交状态码集合
String [ ] unNurseSubmitArr = { "1" , "2" , "6" , "14" , "256" , "512" , "514" , "518" , "526" , "768" } ;
List < String > unNurseSubmitStr = Arrays . asList ( unNurseSubmitArr ) ;
//护士质控员未提交状态码集合
String [ ] unNurseCheckArr = { "16" , "18" , "22" , "30" , "272" } ;
List < String > unNurseCheckStr = Arrays . asList ( unNurseCheckArr ) ;
//护士长未提交状态码集合
String [ ] unHeadNurseArr = { "62" } ;
List < String > unHeadNurseStr = Arrays . asList ( unHeadNurseArr ) ;
//病案室未提交状态码集合
String [ ] unRecordRoomArr = { "64" , "1024" } ;
List < String > unRecordRoomStr = Arrays . asList ( unRecordRoomArr ) ;
List < SubmitRecord > list = new ArrayList < > ( ) ;
for ( Emr_Dictionary dept : depts ) {
int allCount = 0 ;
//定义医生未提交数量
int unDoctorSubmitCount = 0 ;
int unDoctorCheckCount = 0 ;
int unDirectorCheckCount = 0 ;
int unNurseSubmitCount = 0 ;
int unNurseCheckCount = 0 ;
int unHeadNurseCount = 0 ;
int unRecordRoomCount = 0 ;
for ( SubmitRecord obj : unSubmitRecords ) {
if ( dept . getCode ( ) . equals ( obj . getDeptName ( ) ) ) {
allCount + + ;
//判断属于哪个审核角色未提交状态
if ( unDoctorSubmitStr . contains ( obj . getArchivestate ( ) ) ) {
unDoctorSubmitCount + + ;
}
if ( unDoctorCheckStr . contains ( obj . getArchivestate ( ) ) ) {
unDoctorCheckCount + + ;
}
if ( unDirectorCheckStr . contains ( obj . getArchivestate ( ) ) ) {
unDirectorCheckCount + + ;
}
if ( unNurseSubmitStr . contains ( obj . getArchivestate ( ) ) ) {
unNurseSubmitCount + + ;
}
if ( unNurseCheckStr . contains ( obj . getArchivestate ( ) ) ) {
unNurseCheckCount + + ;
}
if ( unHeadNurseStr . contains ( obj . getArchivestate ( ) ) ) {
unHeadNurseCount + + ;
}
if ( unRecordRoomStr . contains ( obj . getArchivestate ( ) ) ) {
unRecordRoomCount + + ;
}
}
}
if ( allCount ! = 0 ) {
SubmitRecord record = new SubmitRecord ( ) ;
record . setCount ( allCount ) ;
record . setUnDoctorSubmitCount ( unDoctorSubmitCount ) ;
record . setUnDoctorCheckCount ( unDoctorCheckCount ) ;
record . setUnDirectorCheckCount ( unDirectorCheckCount ) ;
record . setUnNurseSubmitCount ( unNurseSubmitCount ) ;
record . setUnNurseCheckCount ( unNurseCheckCount ) ;
record . setUnHeadNurseCount ( unHeadNurseCount ) ;
record . setUnRecordRoomCount ( unRecordRoomCount ) ;
record . setDeptNameCn ( dept . getName ( ) ) ;
record . setDeptName ( dept . getCode ( ) ) ;
list . add ( record ) ;
}
}
return list ;
}
/ * public List < SubmitRecord > selectUnCountGroupDept ( RecordSearch recordSearch ) {
Integer infoId = recordSearch . getInfoId ( ) ;
if ( null ! = infoId ) {
//有按审核角色查询
@ -47,13 +209,13 @@ public class RecordService {
//填充各个角色数据
selectList ( unSubmitRecords ) ;
return unSubmitRecords ;
}
} * /
/ * *
* 填 充 集 合 数 据
* @param unSubmitRecords
* /
private void selectList ( List < SubmitRecord > unSubmitRecords ) {
private void selectList ( List < SubmitRecord > unSubmitRecords ) {
if ( ! CollectionUtils . isEmpty ( unSubmitRecords ) ) {
for ( SubmitRecord obj : unSubmitRecords ) {
int count = obj . getCount ( ) ;
@ -63,7 +225,6 @@ public class RecordService {
obj . setDoctorSubmitCount ( doctorSubmitCount ) ;
obj . setDoctorSubmitPercent ( Math . round ( doctorSubmitCount * 100 / count ) + "%" ) ;
//医生质控员提交= 医生提交 - 医生质控员未提交
int doctorCheckCount = doctorSubmitCount - obj . getUnDoctorCheckCount ( ) ;
obj . setDoctorCheckCount ( doctorCheckCount ) ;
@ -109,11 +270,103 @@ public class RecordService {
}
/ * *
* 病 案 室 签 收 统 计
* 病 案 提 交 明 细 , 按 时 间 统 计
* @return
* /
public List < SubmitRecordStatistics > getSignedRecordList ( RecordSearch recordSearch ) {
//按日期查询
List < SubmitRecordStatistics > dateList = recordMapper . selectGroupDate ( recordSearch ) ;
if ( ! CollectionUtils . isEmpty ( dateList ) ) {
//查询属于需要校验完整的带分类的集合
//设置查询的前后日期
recordSearch . setEndDate ( dateList . get ( 0 ) . getDisDate ( ) ) ;
recordSearch . setStartDate ( dateList . get ( dateList . size ( ) - 1 ) . getDisDate ( ) ) ;
List < Archive_Master_Vo > masterVoList = recordMapper . selectAllWithCompleteAssort ( recordSearch ) ;
//组织masterId分组数据
List < Archive_Master_Vo > masterIdVoList = selectGroupDataByMasterId ( masterVoList ) ;
//按日期分组和masterId分组组织已提交和已归档的数量
selectGroupDateByMasterIdList ( dateList , masterIdVoList ) ;
//转换百分比并有按科室查询时转换科室名称
setDeptNameAndPercent ( recordSearch , dateList ) ;
}
return dateList ;
}
/ * *
* 按 日 期 分 组 和 masterId 分 组 组 织 已 提 交 和 已 归 档 的 数 量
* @param dateSet 日 期 分 组
* @param masterIdVoList masterId 分 组 数 据
* @return
* /
private void selectGroupDateByMasterIdList ( List < SubmitRecordStatistics > dateSet , List < Archive_Master_Vo > masterIdVoList ) {
for ( SubmitRecordStatistics submitRecordStatistics : dateSet ) {
//定义该日期总数量
int allCount = 0 ;
//定义已提交份数
int count1 = 0 ;
//定义已归档份数
int count2 = 0 ;
//定义完整份数
int count3 = 0 ;
for ( Archive_Master_Vo obj : masterIdVoList ) {
if ( obj . getDischargeDateTime ( ) . equals ( submitRecordStatistics . getDisDate ( ) ) ) {
allCount + + ;
//获取状态码
String archivestate = obj . getArchivestate ( ) ;
if ( "64" . equals ( archivestate ) | | "128" . equals ( archivestate ) | | "1024" . equals ( archivestate ) ) {
count1 + + ;
}
if ( "128" . equals ( archivestate ) ) {
count2 + + ;
}
if ( "1" . equals ( obj . getIsSuccess ( ) ) ) {
count3 + + ;
}
}
}
submitRecordStatistics . setAllCount ( allCount ) ;
submitRecordStatistics . setCount1 ( count1 ) ;
submitRecordStatistics . setCount2 ( count2 ) ;
submitRecordStatistics . setCount3 ( count3 ) ;
}
}
/ * *
* 组 织 masterId 分 组 数 据 , 带 状 态 码 , 日 期 , 是 否 完 整
* @param masterVoList
* @return
* /
public List < SubmitRecordStatistics > getSignedRecordList ( RecordSearch recordSearch ) {
List < SubmitRecordStatistics > list = recordMapper . selectCountWithDate ( recordSearch ) ;
private List < Archive_Master_Vo > selectGroupDataByMasterId ( List < Archive_Master_Vo > masterVoList ) {
//查询需要校验的分类集合
List < Zd_Assort > assortList = assortService . selectAllByIsCheck ( ) ;
//查询ext表的不完整的集合
List < ArchiveOtherExt > archiveOtherExts = otherExtService . selectNotCompleteMidList ( ) ;
//组织masterId分组数据,带状态码,日期,是否完整
for ( Archive_Master_Vo obj : masterVoList ) {
//定义ext表中不存在
boolean exist = false ;
if ( ! CollectionUtils . isEmpty ( archiveOtherExts ) ) {
for ( ArchiveOtherExt archiveOtherExt : archiveOtherExts ) {
if ( obj . getId ( ) . equals ( archiveOtherExt . getId ( ) ) ) {
exist = true ;
break ;
}
}
}
//如果数量相等, 且在ext表中不存在则isSuccess置为1
if ( obj . getCount ( ) = = assortList . size ( ) & & ! exist ) {
obj . setIsSuccess ( "1" ) ;
}
}
return masterVoList ;
}
/ * *
* 转 换 百 分 比 并 有 按 科 室 查 询 时 转 换 科 室 名 称
* @param recordSearch
* @param list
* /
private void setDeptNameAndPercent ( RecordSearch recordSearch , List < SubmitRecordStatistics > list ) {
String deptNameCn = "全部" ;
String deptName = recordSearch . getDeptName ( ) ;
if ( StringUtils . isNotBlank ( deptName ) ) {
@ -132,7 +385,6 @@ public class RecordService {
obj . setDeptNameCn ( deptNameCn ) ;
}
}
return list ;
}
/ * *
@ -157,9 +409,9 @@ public class RecordService {
* @param recordSearch
* @return
* /
public SubmitRecordStatistics selectOvertimeCount ( RecordSearch recordSearch ) {
public SubmitRecordStatistics selectOvertimeCount ( RecordSearch recordSearch ,HttpServletRequest request ) throws Exception {
//查询超期记录数
List < SubmitRecord > submitRecords = selectUnCountGroupDept ( recordSearch );
List < SubmitRecord > submitRecords = selectUnCountGroupDept ( recordSearch ,request );
//定义接收返回对象
SubmitRecordStatistics recordStatistics = new SubmitRecordStatistics ( ) ;
if ( ! CollectionUtils . isEmpty ( submitRecords ) ) {