更新版本20200918,增加两张报表,首次护理记录排前
parent
6ca66a5941
commit
d5db1ea544
@ -0,0 +1,34 @@
|
||||
package com.emr.dao;
|
||||
|
||||
import com.emr.vo.SubmitRecord;
|
||||
import com.emr.vo.SubmitRecordStatistics;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface RecordMapper {
|
||||
//查询分组科室数量
|
||||
List<SubmitRecord> selectCountGroupDept(@Param("startDate")String startDate,
|
||||
@Param("endDate")String endDate,
|
||||
@Param("deptName")String deptName);
|
||||
//根据审核角色id和分组科室查询该科室完成份数
|
||||
List<SubmitRecord> selectCountByRoleAndDeptName(@Param("startDate")String startDate,
|
||||
@Param("endDate")String endDate,
|
||||
@Param("deptName")String deptName,
|
||||
@Param("roleId")Integer roleId,
|
||||
@Param("backRoleId")Integer backRoleId);
|
||||
//根据科室分组查询护士长审核份数
|
||||
List<SubmitRecord> selectCountWithHeadNurse(@Param("startDate")String startDate,
|
||||
@Param("endDate")String endDate,
|
||||
@Param("deptName")String deptName);
|
||||
//统计总病历数,已提交数,已归档数,已采集完整数
|
||||
SubmitRecordStatistics selectCount(@Param("startDate")String startDate,
|
||||
@Param("endDate")String endDate,
|
||||
@Param("deptName")String deptName);
|
||||
//按日期分组查询出院人数,归档情况,提交情况,资料完整情况
|
||||
List<SubmitRecordStatistics> selectCountWithDate(@Param("startDate")String startDate,
|
||||
@Param("endDate")String endDate,
|
||||
@Param("deptName")String deptName,
|
||||
@Param("dateFlag")Integer dateFlag);
|
||||
|
||||
}
|
||||
@ -0,0 +1,290 @@
|
||||
package com.emr.service.ipml;
|
||||
|
||||
import com.emr.dao.Emr_DictionaryMapper;
|
||||
import com.emr.dao.RecordMapper;
|
||||
import com.emr.entity.Emr_Dictionary;
|
||||
import com.emr.vo.SubmitRecord;
|
||||
import com.emr.vo.SubmitRecordStatistics;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.util.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class RecordService {
|
||||
@Autowired
|
||||
private RecordMapper recordMapper;
|
||||
@Autowired
|
||||
private Emr_DictionaryMapper dictionaryMapper;
|
||||
/**
|
||||
* 病案提交统计
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @param deptName
|
||||
* @return
|
||||
*/
|
||||
public List<SubmitRecord> selectCountGroupDept(String startDate,String endDate,String deptName){
|
||||
//按科室查询总出院人数
|
||||
List<SubmitRecord> submitRecords = recordMapper.selectCountGroupDept(startDate,endDate,deptName);
|
||||
if(!CollectionUtils.isEmpty(submitRecords)) {
|
||||
//获取科室集合
|
||||
String deptNames = getDepts(submitRecords);
|
||||
//查询医生该科室审核份数
|
||||
int roleId = 2;
|
||||
int backRoleId = 9;
|
||||
List<SubmitRecord> doctorSubmitList = recordMapper.selectCountByRoleAndDeptName(startDate,endDate,deptNames, roleId, backRoleId);
|
||||
//查询医生质控员该科室审核份数
|
||||
roleId = 3;
|
||||
List<SubmitRecord> doctorCheckList = recordMapper.selectCountByRoleAndDeptName(startDate,endDate,deptNames, roleId, backRoleId);
|
||||
//查询科主任该科室审核份数
|
||||
roleId = 4;
|
||||
List<SubmitRecord> directorCheckList = recordMapper.selectCountByRoleAndDeptName(startDate,endDate,deptNames, roleId, backRoleId);
|
||||
//查询护士审核份数
|
||||
roleId = 5;
|
||||
backRoleId = 10;
|
||||
List<SubmitRecord> nurseList = recordMapper.selectCountByRoleAndDeptName(startDate,endDate,deptNames, roleId, backRoleId);
|
||||
//查询护士质控员审核份数
|
||||
roleId = 6;
|
||||
List<SubmitRecord> nurseCheckList = recordMapper.selectCountByRoleAndDeptName(startDate,endDate,deptNames, roleId, backRoleId);
|
||||
//护士长
|
||||
List<SubmitRecord> headNurseList = recordMapper.selectCountWithHeadNurse(startDate,endDate,deptNames);
|
||||
//填充各个角色数据
|
||||
selectList(submitRecords,doctorSubmitList,doctorCheckList,directorCheckList,nurseList,nurseCheckList,headNurseList);
|
||||
}
|
||||
return submitRecords;
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充集合数据
|
||||
* @param submitRecords
|
||||
* @param doctorSubmitList
|
||||
* @param doctorCheckList
|
||||
* @param directorCheckList
|
||||
* @param nurseList
|
||||
* @param nurseCheckList
|
||||
* @param headNurseList
|
||||
*/
|
||||
private void selectList(List<SubmitRecord> submitRecords, List<SubmitRecord> doctorSubmitList,
|
||||
List<SubmitRecord> doctorCheckList,
|
||||
List<SubmitRecord> directorCheckList,
|
||||
List<SubmitRecord> nurseList,
|
||||
List<SubmitRecord> nurseCheckList,
|
||||
List<SubmitRecord> headNurseList) {
|
||||
for (SubmitRecord obj:submitRecords) {
|
||||
//计算医生
|
||||
//定义医生是否匹配的科室
|
||||
boolean doctorFlag = false;
|
||||
if(!CollectionUtils.isEmpty(doctorSubmitList)) {
|
||||
for (SubmitRecord objTemp : doctorSubmitList) {
|
||||
if (obj.getDeptName().equals(objTemp.getDeptName())) {
|
||||
int count = objTemp.getCount();
|
||||
int unCount = obj.getCount() - count;
|
||||
int countPercent = Math.round(count * 100 / obj.getCount());
|
||||
obj.setDoctorSubmitCount(count);
|
||||
obj.setUnDoctorSubmitCount(unCount);
|
||||
obj.setDoctorSubmitPercent(countPercent + "%");
|
||||
doctorFlag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//未匹配上科室置0
|
||||
if(!doctorFlag){
|
||||
obj.setDoctorSubmitCount(0);
|
||||
obj.setUnDoctorSubmitCount(obj.getCount());
|
||||
obj.setDoctorSubmitPercent(0 + "%");
|
||||
}
|
||||
|
||||
//计算医生质控员
|
||||
//定义医生指控员是否匹配的科室
|
||||
boolean doctorCheckFlag = false;
|
||||
for (SubmitRecord objTemp:doctorCheckList) {
|
||||
if(obj.getDeptName().equals(objTemp.getDeptName())){
|
||||
int count = objTemp.getCount();
|
||||
int unCount = obj.getCount() - count;
|
||||
int countPercent = Math.round(count * 100 / obj.getCount());
|
||||
obj.setDoctorCheckCount(count);
|
||||
obj.setUnDoctorCheckCount(unCount);
|
||||
obj.setDoctorCheckPercent(countPercent + "%");
|
||||
doctorCheckFlag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//未匹配上科室置0
|
||||
if(!doctorCheckFlag){
|
||||
obj.setDoctorCheckCount(0);
|
||||
obj.setUnDoctorCheckCount(obj.getCount());
|
||||
obj.setDoctorCheckPercent(0 + "%");
|
||||
}
|
||||
|
||||
//计算科主任
|
||||
//定义科主任是否匹配的科室
|
||||
boolean directorCheckFlag = false;
|
||||
for (SubmitRecord objTemp:directorCheckList) {
|
||||
if(obj.getDeptName().equals(objTemp.getDeptName())){
|
||||
int count = objTemp.getCount();
|
||||
int unCount = obj.getCount() - count;
|
||||
int countPercent = Math.round(count * 100 / obj.getCount());
|
||||
obj.setDirectorCheckCount(count);
|
||||
obj.setUnDirectorCheckCount(unCount);
|
||||
obj.setDirectorCheckPercent(countPercent + "%");
|
||||
directorCheckFlag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//未匹配上科室置0
|
||||
if(!directorCheckFlag){
|
||||
obj.setDirectorCheckCount(0);
|
||||
obj.setUnDirectorCheckCount(obj.getCount());
|
||||
obj.setDirectorCheckPercent(0 + "%");
|
||||
}
|
||||
|
||||
//计算护士
|
||||
//定义护士是否匹配的科室
|
||||
boolean nurseFlag = false;
|
||||
for (SubmitRecord objTemp:nurseList) {
|
||||
if(obj.getDeptName().equals(objTemp.getDeptName())){
|
||||
int count = objTemp.getCount();
|
||||
int unCount = obj.getCount() - count;
|
||||
int countPercent = Math.round(count * 100 / obj.getCount());
|
||||
obj.setNurseSubmitCount(count);
|
||||
obj.setUnNurseSubmitCount(unCount);
|
||||
obj.setNurseSubmitPercent(countPercent + "%");
|
||||
nurseFlag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//未匹配上科室置0
|
||||
if(!nurseFlag){
|
||||
obj.setNurseSubmitCount(0);
|
||||
obj.setUnNurseSubmitCount(obj.getCount());
|
||||
obj.setNurseSubmitPercent(0 + "%");
|
||||
}
|
||||
|
||||
//计算护士质控员
|
||||
//定义护士质控员是否匹配的科室
|
||||
boolean nurseCheckFlag = false;
|
||||
for (SubmitRecord objTemp:nurseCheckList) {
|
||||
if(obj.getDeptName().equals(objTemp.getDeptName())){
|
||||
int count = objTemp.getCount();
|
||||
int unCount = obj.getCount() - count;
|
||||
int countPercent = Math.round(count * 100 / obj.getCount());
|
||||
obj.setNurseCheckCount(count);
|
||||
obj.setUnNurseCheckCount(unCount);
|
||||
obj.setNurseCheckPercent(countPercent + "%");
|
||||
nurseCheckFlag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//未匹配上科室置0
|
||||
if(!nurseCheckFlag){
|
||||
obj.setNurseCheckCount(0);
|
||||
obj.setUnNurseCheckCount(obj.getCount());
|
||||
obj.setNurseCheckPercent(0 + "%");
|
||||
}
|
||||
|
||||
//定义护士长是否匹配的科室
|
||||
boolean headNurseFlag = false;
|
||||
//计算护士长
|
||||
for (SubmitRecord objTemp : headNurseList) {
|
||||
if (obj.getDeptName().equals(objTemp.getDeptName())) {
|
||||
int count = objTemp.getCount();
|
||||
int unCount = obj.getCount() - count;
|
||||
int countPercent = Math.round(count * 100 / obj.getCount());
|
||||
obj.setHeadNurseCount(count);
|
||||
obj.setUnHeadNurseCount(unCount);
|
||||
obj.setHeadNursePercent(countPercent + "%");
|
||||
headNurseFlag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//未匹配上科室置0
|
||||
if(!headNurseFlag) {
|
||||
obj.setHeadNurseCount(0);
|
||||
obj.setUnHeadNurseCount(obj.getCount());
|
||||
obj.setHeadNursePercent("0%");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 组织出院科室code以逗号隔开的字符串形式
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
private String getDepts(List<SubmitRecord> list) {
|
||||
StringBuilder depeNames = new StringBuilder();
|
||||
for (SubmitRecord obj:list) {
|
||||
if(StringUtils.isNotBlank(obj.getDeptName())) {
|
||||
if (StringUtils.isNoneBlank(depeNames)) {
|
||||
depeNames.append(",").append(obj.getDeptName());
|
||||
} else {
|
||||
depeNames.append(obj.getDeptName());
|
||||
}
|
||||
}
|
||||
}
|
||||
return depeNames.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 病案归档统计
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @param deptName
|
||||
* @return
|
||||
*/
|
||||
public SubmitRecordStatistics selectCount(String startDate,String endDate,String deptName) {
|
||||
SubmitRecordStatistics record = recordMapper.selectCount(startDate, endDate, deptName);
|
||||
//计算百分比并赋值
|
||||
SetStatisticsPercent(record);
|
||||
return record;
|
||||
}
|
||||
|
||||
/**
|
||||
* 病案室签收统计
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @param deptName
|
||||
* @return
|
||||
*/
|
||||
public List<SubmitRecordStatistics> getSignedRecordList(String startDate, String endDate, String deptName,Integer dateFlag) {
|
||||
List<SubmitRecordStatistics> list = recordMapper.selectCountWithDate(startDate, endDate, deptName,dateFlag);
|
||||
String deptNameCn = "全部";
|
||||
if(StringUtils.isNotBlank(deptName)){
|
||||
Emr_Dictionary dictionary = new Emr_Dictionary();
|
||||
dictionary.setCode(deptName);
|
||||
//转换科室
|
||||
List<Emr_Dictionary> dictionaries = dictionaryMapper.dicByClo(dictionary);
|
||||
if(!CollectionUtils.isEmpty(dictionaries)){
|
||||
deptNameCn = dictionaries.get(0).getName();
|
||||
}
|
||||
}
|
||||
if(!CollectionUtils.isEmpty(list)){
|
||||
for (SubmitRecordStatistics obj:list) {
|
||||
//计算百分比并赋值
|
||||
SetStatisticsPercent(obj);
|
||||
obj.setDeptNameCn(deptNameCn);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算百分比并赋值
|
||||
* @param record
|
||||
*/
|
||||
private void SetStatisticsPercent(SubmitRecordStatistics record) {
|
||||
Integer count = record.getAllCount();
|
||||
if (count != 0) {
|
||||
record.setCount1Percent(Math.round(record.getCount1() * 100 / count) + "%");
|
||||
record.setCount2Percent(Math.round(record.getCount2() * 100 / count) + "%");
|
||||
record.setCount3Percent(Math.round(record.getCount3() * 100 / count) + "%");
|
||||
} else {
|
||||
record.setCount1Percent("0%");
|
||||
record.setCount2Percent("0%");
|
||||
record.setCount3Percent("0%");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package com.emr.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SubmitRecord {
|
||||
private String deptName;
|
||||
private String deptNameCn;
|
||||
private Integer count;
|
||||
|
||||
private Integer doctorSubmitCount;
|
||||
private Integer unDoctorSubmitCount;
|
||||
private String doctorSubmitPercent;
|
||||
|
||||
private Integer doctorCheckCount;
|
||||
private Integer unDoctorCheckCount;
|
||||
private String doctorCheckPercent;
|
||||
|
||||
private Integer directorCheckCount;
|
||||
private Integer unDirectorCheckCount;
|
||||
private String directorCheckPercent;
|
||||
|
||||
private Integer nurseSubmitCount;
|
||||
private Integer unNurseSubmitCount;
|
||||
private String nurseSubmitPercent;
|
||||
|
||||
private Integer nurseCheckCount;
|
||||
private Integer unNurseCheckCount;
|
||||
private String nurseCheckPercent;
|
||||
|
||||
private Integer headNurseCount;
|
||||
private Integer unHeadNurseCount;
|
||||
private String headNursePercent;
|
||||
}
|
||||
@ -0,0 +1,293 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.emr.dao.RecordMapper">
|
||||
<resultMap id="BaseResultMap" type="com.emr.vo.SubmitRecord"></resultMap>
|
||||
<resultMap id="BaseResultMap1" type="com.emr.vo.SubmitRecordStatistics"></resultMap>
|
||||
<!---查询时间段-->
|
||||
<sql id="selectByDate">
|
||||
AND CONVERT(varchar(10),archive_master.discharge_date_time, 23) != '1801-02-03'
|
||||
<if test="deptName != null and deptName != ''">
|
||||
AND archive_master.dept_name in (${deptName})
|
||||
</if>
|
||||
<choose>
|
||||
<when test="startDate != null and startDate != '' and endDate != null and endDate != ''">
|
||||
and discharge_date_time between CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120) and
|
||||
#{endDate,jdbcType=NCHAR}+ ' 23:59:59'
|
||||
</when>
|
||||
<when test="startDate != null and startDate != ''">
|
||||
and discharge_date_time >= CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120)
|
||||
</when>
|
||||
<when test="endDate != null and endDate != ''">
|
||||
and discharge_date_time <= #{endDate,jdbcType=NCHAR}+ ' 23:59:59'
|
||||
</when>
|
||||
</choose>
|
||||
</sql>
|
||||
<sql id="selectByDate1">
|
||||
AND CONVERT(varchar(10),archive_master.discharge_date_time, 23) != '1801-02-03'
|
||||
<if test="deptName != null and deptName != ''">
|
||||
AND archive_master.dept_name in (${deptName})
|
||||
</if>
|
||||
<choose>
|
||||
<when test="startDate != null and startDate != '' and endDate != null and endDate != ''">
|
||||
<choose>
|
||||
<when test="dateFlag == 1">
|
||||
and discharge_date_time between CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120) and
|
||||
#{endDate,jdbcType=NCHAR}+ ' 23:59:59'
|
||||
</when>
|
||||
<when test="dateFlag == 2">
|
||||
and CONVERT(VARCHAR(7),discharge_date_time,120) between #{startDate,jdbcType=NCHAR} and
|
||||
#{endDate,jdbcType=NCHAR}
|
||||
</when>
|
||||
<when test="dateFlag == 3">
|
||||
and CONVERT(VARCHAR(4),discharge_date_time,120) between #{startDate,jdbcType=NCHAR} and
|
||||
#{endDate,jdbcType=NCHAR}
|
||||
</when>
|
||||
</choose>
|
||||
</when>
|
||||
<when test="startDate != null and startDate != ''">
|
||||
<choose>
|
||||
<when test="dateFlag == 1">
|
||||
and discharge_date_time >= CONVERT(VARCHAR(10),#{startDate,jdbcType=NCHAR},120)
|
||||
</when>
|
||||
<when test="dateFlag == 2">
|
||||
and CONVERT(VARCHAR(7),discharge_date_time,120) >= #{startDate,jdbcType=NCHAR}
|
||||
</when>
|
||||
<when test="dateFlag == 3">
|
||||
and CONVERT(VARCHAR(4),discharge_date_time,120) >= #{startDate,jdbcType=NCHAR}
|
||||
</when>
|
||||
</choose>
|
||||
</when>
|
||||
<when test="endDate != null and endDate != ''">
|
||||
<choose>
|
||||
<when test="dateFlag == 1">
|
||||
and discharge_date_time <= #{endDate,jdbcType=NCHAR}+ ' 23:59:59'
|
||||
</when>
|
||||
<when test="dateFlag == 2">
|
||||
and CONVERT(VARCHAR(7),discharge_date_time,120) <= #{endDate,jdbcType=NCHAR}
|
||||
</when>
|
||||
<when test="dateFlag == 3">
|
||||
and CONVERT(VARCHAR(4),discharge_date_time,120) <= #{endDate,jdbcType=NCHAR}
|
||||
</when>
|
||||
</choose>
|
||||
</when>
|
||||
</choose>
|
||||
</sql>
|
||||
<!---查询分组科室数量-->
|
||||
<select id="selectCountGroupDept" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
dept_name deptName,
|
||||
COUNT( archive_master.id ) count,
|
||||
emr_dictionary.NAME deptNameCn
|
||||
FROM
|
||||
archive_master
|
||||
INNER JOIN emr_dictionary ON archive_master.dept_name = emr_dictionary.CODE
|
||||
AND emr_dictionary.parent_id = 'dept_code'
|
||||
<where>
|
||||
<include refid="selectByDate"></include>
|
||||
</where>
|
||||
GROUP BY
|
||||
dept_name,
|
||||
emr_dictionary.NAME,
|
||||
emr_dictionary.CODE
|
||||
ORDER BY
|
||||
emr_dictionary.CODE
|
||||
</select>
|
||||
<!--根据审核角色id和分组科室查询该科室完成份数-->
|
||||
<select id="selectCountByRoleAndDeptName" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
archive_master.dept_name,
|
||||
sum( CASE WHEN ISNULL( t1.createtime, 0 ) > ISNULL( t2.createtime, 0 ) THEN 1 ELSE 0 END ) count
|
||||
FROM
|
||||
( SELECT master_id, MAX( createtime ) createtime FROM archive_flow_info WHERE start_step_id = ${roleId} GROUP BY master_id ) t1
|
||||
LEFT JOIN ( SELECT master_id, MAX( createtime ) createtime FROM archive_flow_info WHERE target_step_id = ${backRoleId} GROUP BY master_id ) t2 ON t1.master_id = t2.master_id
|
||||
INNER JOIN archive_master ON t1.master_id = archive_master.id
|
||||
<where>
|
||||
<include refid="selectByDate"></include>
|
||||
</where>
|
||||
GROUP BY
|
||||
dept_name
|
||||
</select>
|
||||
<!--根据科室分组查询护士长审核份数-->
|
||||
<select id="selectCountWithHeadNurse" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
dept_name deptName,
|
||||
COUNT( id ) count
|
||||
FROM
|
||||
archive_master
|
||||
WHERE
|
||||
ArchiveState = '64'
|
||||
<include refid="selectByDate"></include>
|
||||
GROUP BY
|
||||
dept_name
|
||||
</select>
|
||||
<!--统计总病历数,已提交数,已归档数,已采集完整数-->
|
||||
<select id="selectCount" resultType="com.emr.vo.SubmitRecordStatistics">
|
||||
SELECT
|
||||
( SELECT COUNT( 1 ) FROM archive_master
|
||||
<where>
|
||||
<include refid="selectByDate"></include>
|
||||
</where>
|
||||
) allCount,
|
||||
( SELECT COUNT( 1 ) FROM archive_master WHERE ArchiveState = '64' <include refid="selectByDate"></include>
|
||||
) count1,
|
||||
( SELECT COUNT( 1 ) FROM archive_master WHERE ArchiveState = '128' <include refid="selectByDate"></include>
|
||||
) count2,
|
||||
(
|
||||
SELECT
|
||||
count( 1 )
|
||||
FROM
|
||||
archive_master
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
MasterID,
|
||||
COUNT( AssortID ) count
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
archive_detail.MasterID,
|
||||
dbo.archive_detail.AssortID
|
||||
FROM
|
||||
dbo.archive_detail
|
||||
INNER JOIN dbo.zd_assort ON dbo.archive_detail.AssortID = dbo.zd_assort.assort_id
|
||||
AND dbo.zd_assort.print_flag = 0
|
||||
AND dbo.zd_assort.is_check = 1
|
||||
WHERE
|
||||
( dbo.archive_detail.flag = 0 )
|
||||
GROUP BY
|
||||
archive_detail.MasterID,
|
||||
dbo.archive_detail.AssortID
|
||||
) temp
|
||||
GROUP BY
|
||||
MasterID
|
||||
) temp ON archive_master.id = temp.MasterID
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
MID,
|
||||
COUNT( MID ) inspectionCount
|
||||
FROM
|
||||
archive_other_ext
|
||||
WHERE
|
||||
sysFlag IN ( 3, 6 )
|
||||
AND ISNULL( DID, '' )= ''
|
||||
AND ISNULL( MID, '' )!= ''
|
||||
GROUP BY
|
||||
MID
|
||||
) archive_other_ext ON archive_master.id = archive_other_ext.MID
|
||||
WHERE
|
||||
ISNULL( count, 0 ) = ( SELECT COUNT( assort_id ) FROM zd_assort WHERE print_flag = 0 AND is_check = 1 )
|
||||
AND inspectionCount IS NULL
|
||||
<include refid="selectByDate"></include>
|
||||
) count3
|
||||
</select>
|
||||
|
||||
<!--按日期分组查询出院人数,归档情况,提交情况,资料完整情况-->
|
||||
<select id="selectCountWithDate" resultMap="BaseResultMap1">
|
||||
SELECT
|
||||
isnull( t1.count, 0 ) allCount,
|
||||
t1.disDate,
|
||||
isnull( t2.count, 0 ) count1,
|
||||
isnull( t3.count, 0 ) count2,
|
||||
isnull( t4.count, 0 ) count3
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
COUNT( 1 ) count,
|
||||
<include refid="formatDate"></include> disDate
|
||||
FROM
|
||||
archive_master
|
||||
<where>
|
||||
<include refid="selectByDate1"></include>
|
||||
</where>
|
||||
GROUP BY
|
||||
<include refid="formatDate"></include>
|
||||
) t1
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
COUNT( 1 ) count,
|
||||
<include refid="formatDate"></include> disDate
|
||||
FROM
|
||||
archive_master
|
||||
WHERE
|
||||
ArchiveState = '64'
|
||||
<include refid="selectByDate1"></include>
|
||||
GROUP BY
|
||||
<include refid="formatDate"></include>
|
||||
) t2 ON t1.disDate = t2.disDate
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
COUNT( 1 ) count,
|
||||
<include refid="formatDate"></include> disDate
|
||||
FROM
|
||||
archive_master
|
||||
WHERE
|
||||
ArchiveState = '128'
|
||||
<include refid="selectByDate1"></include>
|
||||
GROUP BY
|
||||
<include refid="formatDate"></include>
|
||||
) t3 ON t1.disDate = t3.disDate
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
count( 1 ) count,
|
||||
<include refid="formatDate"></include> disDate
|
||||
FROM
|
||||
archive_master
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
MasterID,
|
||||
COUNT( AssortID ) count
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
archive_detail.MasterID,
|
||||
dbo.archive_detail.AssortID
|
||||
FROM
|
||||
dbo.archive_detail
|
||||
INNER JOIN dbo.zd_assort ON dbo.archive_detail.AssortID = dbo.zd_assort.assort_id
|
||||
AND dbo.zd_assort.print_flag = 0
|
||||
AND dbo.zd_assort.is_check = 1
|
||||
WHERE
|
||||
( dbo.archive_detail.flag = 0 )
|
||||
GROUP BY
|
||||
archive_detail.MasterID,
|
||||
dbo.archive_detail.AssortID
|
||||
) temp
|
||||
GROUP BY
|
||||
MasterID
|
||||
) temp ON archive_master.id = temp.MasterID
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
MID,
|
||||
COUNT( MID ) inspectionCount
|
||||
FROM
|
||||
archive_other_ext
|
||||
WHERE
|
||||
sysFlag IN ( 3, 6 )
|
||||
AND ISNULL( DID, '' )= ''
|
||||
AND ISNULL( MID, '' )!= ''
|
||||
GROUP BY
|
||||
MID
|
||||
) archive_other_ext ON archive_master.id = archive_other_ext.MID
|
||||
WHERE
|
||||
ISNULL( count, 0 ) = ( SELECT COUNT( assort_id ) FROM zd_assort WHERE print_flag = 0 AND is_check = 1 )
|
||||
AND inspectionCount IS NULL
|
||||
<include refid="selectByDate1"></include>
|
||||
GROUP BY
|
||||
<include refid="formatDate"></include>
|
||||
) t4 ON t1.disDate = t4.disDate
|
||||
order by t1.disDate desc
|
||||
</select>
|
||||
<!---格式化时间-->
|
||||
<sql id="formatDate">
|
||||
<choose>
|
||||
<when test="dateFlag == 1">
|
||||
CONVERT ( VARCHAR ( 10 ), archive_master.discharge_date_time, 23 )
|
||||
</when>
|
||||
<when test="dateFlag == 2">
|
||||
CONVERT ( VARCHAR ( 7 ), archive_master.discharge_date_time, 120 )
|
||||
</when>
|
||||
<when test="dateFlag == 3">
|
||||
CONVERT ( VARCHAR ( 4 ), archive_master.discharge_date_time, 120 )
|
||||
</when>
|
||||
</choose>
|
||||
</sql>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue