|
@ -42,11 +42,13 @@ import java.text.SimpleDateFormat;
|
|
|
import java.time.*;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.time.format.TextStyle;
|
|
|
import java.time.temporal.WeekFields;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* Created by wangzhinan on 2019/12/3.
|
|
@ -8578,23 +8580,28 @@ public class StatisticsEsService {
|
|
|
* @param startDate
|
|
|
* @param endDate
|
|
|
* @param flag
|
|
|
* @param area
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONObject getFollowUpHeaderTotal(String startDate,String endDate,Integer flag) {
|
|
|
public JSONObject getFollowUpHeaderTotal(String startDate,String endDate,Integer flag,String deptCode) {
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
if (flag == 1) {
|
|
|
startDate = DateUtil.getFirstMonthDay() + " 00:00:00";
|
|
|
endDate = DateUtil.getLastMonthDay() + " 23:59:59";
|
|
|
} else if (flag == 2) {
|
|
|
startDate = DateUtil.getMonthDate(new Date(), -6) + " 00:00:00";
|
|
|
endDate = DateUtil.getStringDateShort() + " 23:59:59";
|
|
|
} else if (flag == 3) {
|
|
|
startDate = DateUtil.getCurrentYearStartTime() + " 00:00:00";
|
|
|
endDate = DateUtil.getCurrentYearEndTime() + " 23:59:59";
|
|
|
}
|
|
|
if(StringUtils.isBlank(startDate)){
|
|
|
if (flag == 1) {
|
|
|
startDate = DateUtil.getFirstMonthDay();
|
|
|
endDate = DateUtil.getLastMonthDay();
|
|
|
} else if (flag == 2) {
|
|
|
startDate = DateUtil.getMonthDate(new Date(), -6) ;
|
|
|
endDate = DateUtil.getStringDateShort();
|
|
|
} else if (flag == 3) {
|
|
|
startDate = DateUtil.getCurrentYearStartTime() ;
|
|
|
endDate = DateUtil.getCurrentYearEndTime();
|
|
|
}
|
|
|
}
|
|
|
endDate = endDate +" 23:59:59";
|
|
|
//开通详情
|
|
|
String sql = "select dept_name,diagnosis_name from base_disease_hospital where status=1 and create_time>='"+startDate+"' and create_time <='"+endDate+"'";
|
|
|
if(StringUtils.isNotBlank(deptCode)){
|
|
|
sql += " and dept like '%"+deptCode+"%'";
|
|
|
}
|
|
|
List<Map<String,Object>> diseaseList = jdbcTemplate.queryForList(sql);
|
|
|
Set<String> deptSet = new HashSet<>();
|
|
|
Set<String> diagnosisSet = new HashSet<>();
|
|
@ -8614,28 +8621,25 @@ public class StatisticsEsService {
|
|
|
jsonObject.put("diagnosisName",diagnosisSet);//开通的疾病
|
|
|
//下转次数:
|
|
|
String turnSql = "select count(1) as total from wlyy_rehabilitation_patient_info where create_time>='"+startDate+"' and create_time <='"+endDate+"' ";
|
|
|
if(StringUtils.isNotBlank(deptCode)){
|
|
|
turnSql += " and dept = '"+deptCode+"' ";
|
|
|
}
|
|
|
String turnTotal = "0";
|
|
|
String shoudongTurnTotal = "0";
|
|
|
String zidongTurnTotal = "0";
|
|
|
Map<String,Object> turnMap = jdbcTemplate.queryForMap(turnSql);
|
|
|
if (turnMap!=null){
|
|
|
if (turnMap.get("total")!=null){
|
|
|
turnTotal = turnMap.get("total").toString();
|
|
|
}
|
|
|
if (turnMap.get("total")!=null){
|
|
|
turnTotal = turnMap.get("total").toString();
|
|
|
}
|
|
|
String zidongTurnSql = turnSql+" and from_source =2 ";
|
|
|
Map<String,Object> zidongTurnMap = jdbcTemplate.queryForMap(zidongTurnSql);
|
|
|
if (zidongTurnMap!=null){
|
|
|
if (zidongTurnMap.get("total")!=null){
|
|
|
zidongTurnTotal = zidongTurnMap.get("total").toString();
|
|
|
}
|
|
|
if (zidongTurnMap.get("total")!=null){
|
|
|
zidongTurnTotal = zidongTurnMap.get("total").toString();
|
|
|
}
|
|
|
String shoudongTurnSql = turnSql+ " and from_source=1 ";
|
|
|
Map<String,Object> shoudongTurnMap = jdbcTemplate.queryForMap(shoudongTurnSql);
|
|
|
if (shoudongTurnMap!=null){
|
|
|
if (shoudongTurnMap.get("total")!=null){
|
|
|
shoudongTurnTotal = shoudongTurnMap.get("total").toString();
|
|
|
}
|
|
|
if (shoudongTurnMap.get("total")!=null){
|
|
|
shoudongTurnTotal = shoudongTurnMap.get("total").toString();
|
|
|
}
|
|
|
jsonObject.put("zidongTurnTotal",zidongTurnTotal);//自动下转
|
|
|
jsonObject.put("shoudongTurnTotal",shoudongTurnTotal);//手动下转
|
|
@ -8644,57 +8648,450 @@ public class StatisticsEsService {
|
|
|
//下转人数
|
|
|
String turnPersonTotal = "0";
|
|
|
String turnPersonSql = "select count(DISTINCT patient) as total from wlyy_rehabilitation_patient_info where create_time>='"+startDate+"' and create_time <='"+endDate+"' ";
|
|
|
if(StringUtils.isNotBlank(deptCode)){
|
|
|
turnPersonSql += " and dept = '"+deptCode+"' ";
|
|
|
}
|
|
|
Map<String,Object> turnPersonMap = jdbcTemplate.queryForMap(turnPersonSql);
|
|
|
if (turnPersonMap!=null){
|
|
|
if (turnPersonMap.get("total")!=null){
|
|
|
turnPersonTotal = turnPersonMap.get("total").toString();
|
|
|
}
|
|
|
if (turnPersonMap.get("total")!=null){
|
|
|
turnPersonTotal = turnPersonMap.get("total").toString();
|
|
|
}
|
|
|
//下转人数性别
|
|
|
String turnSexSql = "SELECT\n" +
|
|
|
"\tcount(DISTINCT patient) AS total,\n" +
|
|
|
"\tsex\n" +
|
|
|
"FROM\n" +
|
|
|
"\twlyy_rehabilitation_patient_info\n" +
|
|
|
"WHERE\n" +
|
|
|
"\tcreate_time >= '"+startDate+"'\n" +
|
|
|
"AND create_time <= '"+endDate+"'\n" +
|
|
|
"GROUP BY\n" +
|
|
|
"\tsex";
|
|
|
String turnSexSql = "SELECT count(DISTINCT patient) AS total, sex " +
|
|
|
" FROM wlyy_rehabilitation_patient_info " +
|
|
|
" WHERE create_time >= '"+startDate+"' " +
|
|
|
"AND create_time <= '"+endDate+"' ";
|
|
|
if(StringUtils.isNotBlank(deptCode)){
|
|
|
turnSexSql += " and dept = '"+deptCode+"' ";
|
|
|
}
|
|
|
turnSexSql += " GROUP BY sex";
|
|
|
List<Map<String,Object>> sexMapList = jdbcTemplate.queryForList(turnSexSql);
|
|
|
for (Map<String,Object> map:sexMapList){
|
|
|
if (map.get("sex")!=null){
|
|
|
if (map.get("sex").toString().equalsIgnoreCase("1")){
|
|
|
map.put("sexName","男");
|
|
|
}else if (map.get("sex").toString().equalsIgnoreCase("2")){
|
|
|
map.put("sexName","女");
|
|
|
}else {
|
|
|
map.put("sexName","未知");
|
|
|
}
|
|
|
String sex = map.get("sex")+"";
|
|
|
if("1".equals(sex)){
|
|
|
map.put("sexName","男");
|
|
|
}else if("2".equals(sex)){
|
|
|
map.put("sexName","女");
|
|
|
}else {
|
|
|
map.put("sexName","未知");
|
|
|
}
|
|
|
}
|
|
|
jsonObject.put("turnPersonTotal",turnPersonTotal);//下转人数
|
|
|
jsonObject.put("sexMapList",sexMapList);//性别分布
|
|
|
//随访次数
|
|
|
String followUpTotal = "0";//随访总次数
|
|
|
String followupSql = "select COUNT(1) total from wlyy_followup where followup_date >='"+startDate+"' and followup_date <='"+endDate+"'";
|
|
|
Map<String,Object> followupMap = jdbcTemplate.queryForMap(followupSql);
|
|
|
if (followupMap!=null){
|
|
|
if (followupMap.get("total")!=null){
|
|
|
followUpTotal = followupMap.get("total").toString();
|
|
|
}
|
|
|
}
|
|
|
String followupCompleteTotal = "0";
|
|
|
String followupCompleteSql = followupSql + " and status = 1 ";
|
|
|
Map<String,Object> followupCompleteMap = jdbcTemplate.queryForMap(followupCompleteSql);
|
|
|
if (followupCompleteMap!=null){
|
|
|
if (followupCompleteMap.get("total")!=null){
|
|
|
followupCompleteTotal = followupCompleteMap.get("total").toString();
|
|
|
}
|
|
|
String followupSql = "SELECT COUNT(f.id) planNum,COUNT(if(f.`status`=1,1,null)) finishNum from wlyy_followup f" +
|
|
|
" where f.followup_date >='"+startDate+"' and f.followup_date <='"+endDate+"' ";
|
|
|
if(StringUtils.isNotBlank(deptCode)){
|
|
|
followupSql += "SELECT COUNT(f.id) planNum,COUNT(if(f.`status`=1,1,null)) finishNum from wlyy_followup f,base_doctor_hospital h " +
|
|
|
" where f.doctor_code=h.doctor_code and h.del=1 and h.dept_code='"+deptCode+"' " +
|
|
|
" and f.followup_date >='"+startDate+"' and f.followup_date <='"+endDate+"' ";
|
|
|
}
|
|
|
Map<String,Object> followupMap = jdbcTemplate.queryForMap(followupSql);
|
|
|
followUpTotal = followupMap.get("planNum").toString();
|
|
|
followupCompleteTotal = followupMap.get("finishNum").toString();
|
|
|
|
|
|
String rate = getTwoRange(Integer.parseInt(followupCompleteTotal),Integer.parseInt(followUpTotal),0);
|
|
|
jsonObject.put("followupCompleteRate",rate);
|
|
|
jsonObject.put("followupTotal",followUpTotal);
|
|
|
return jsonObject;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 诊后康复服务分析
|
|
|
*
|
|
|
* @param startDate
|
|
|
* @param endDate
|
|
|
* @param flag 1本月 2半年 3年
|
|
|
* @param timeType 1日 2周 3月
|
|
|
*/
|
|
|
public List<Map<String,Object>> rehabilitationAnalysis(String startDate,String endDate,Integer flag,String timeType,String dept){
|
|
|
List<Map<String,Object>> result = new ArrayList<>();
|
|
|
if(StringUtils.isBlank(startDate)){
|
|
|
if (flag == 1) {
|
|
|
startDate = DateUtil.getFirstMonthDay();
|
|
|
endDate = DateUtil.getLastMonthDay();
|
|
|
} else if (flag == 2) {
|
|
|
startDate = DateUtil.getMonthDate(new Date(), -6) ;
|
|
|
endDate = DateUtil.getStringDateShort();
|
|
|
} else if (flag == 3) {
|
|
|
startDate = DateUtil.getCurrentYearStartTime() ;
|
|
|
endDate = DateUtil.getCurrentYearEndTime();
|
|
|
}
|
|
|
}
|
|
|
String endDateTmp = endDate;
|
|
|
endDate = endDate +" 23:59:59";
|
|
|
String dateColumn = "DATE_FORMAT(p.complete_time,'%Y-%m-%d')";
|
|
|
String dateColumn2 = "DATE_FORMAT(i.czrq,'%Y-%m-%d')";
|
|
|
if("2".equals(timeType)){
|
|
|
dateColumn = "DATE_FORMAT(p.complete_time,'%Y-%u')";
|
|
|
dateColumn2 = "DATE_FORMAT(i.czrq,'%Y-%u')";
|
|
|
}else if("3".equals(timeType)){
|
|
|
dateColumn = "DATE_FORMAT(p.complete_time,'%Y-%m')";
|
|
|
dateColumn2 = "DATE_FORMAT(i.czrq,'%Y-%m')";
|
|
|
}
|
|
|
String sql = "select "+dateColumn+" date,COUNT(if(p.relation_type=1,1,null)) callNum " +
|
|
|
",COUNT(if(p.relation_type=2,1,null)) consultNum " +
|
|
|
",COUNT(if(p.relation_type=4,1,null)) doorNum ,COUNT(if(p.relation_type=5,1,null)) guidanceNum " +
|
|
|
",COUNT(if(p.relation_type=6,1,null)) followupNum ,COUNT(if(p.relation_type=7,1,null)) visitNum " +
|
|
|
" from base_service_item_plan p where p.status=1 "+
|
|
|
" and p.complete_time>='"+startDate+"' and p.complete_time<='"+endDate+"' GROUP BY date";
|
|
|
if(StringUtils.isNotBlank(dept)){
|
|
|
sql = "select "+dateColumn+" date,COUNT(if(p.relation_type=1,1,null)) callNum " +
|
|
|
",COUNT(if(p.relation_type=2,1,null)) consultNum " +
|
|
|
",COUNT(if(p.relation_type=4,1,null)) doorNum ,COUNT(if(p.relation_type=5,1,null)) guidanceNum " +
|
|
|
",COUNT(if(p.relation_type=6,1,null)) followupNum ,COUNT(if(p.relation_type=7,1,null)) visitNum " +
|
|
|
" from base_service_item_plan p,base_doctor_hospital h where p.status=1 and p.doctor=h.doctor_code and h.del=1 and h.dept_code='"+dept+"' "+
|
|
|
" and p.complete_time>='"+startDate+"' and p.complete_time<='"+endDate+"' GROUP BY date";
|
|
|
}
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
Map<String,Map<String,Object>> dateMap = list.stream().collect(Collectors.toMap(e -> e.get("date").toString(), v -> v, (p1, p2) -> p1));
|
|
|
|
|
|
String sql2 = "SELECT COUNT(DISTINCT i.id) num,"+dateColumn2+" date " +
|
|
|
" from wlyy_patient_health_index i,wlyy_patient_rehabilitation_plan p " +
|
|
|
"WHERE i.`user`=p.patient and i.czrq>='"+startDate+"' and i.czrq<='"+endDate+"' " +
|
|
|
"GROUP BY date";
|
|
|
if(StringUtils.isNotBlank(dept)){
|
|
|
sql2 = "SELECT COUNT(DISTINCT i.id) num,"+dateColumn2+" date " +
|
|
|
" from wlyy_patient_health_index i,wlyy_patient_rehabilitation_plan p,base_doctor_hospital h " +
|
|
|
"WHERE i.`user`=p.patient and p.plan_doctor=h.doctor_code and h.del=1 and h.dept_code='"+dept+"' " +
|
|
|
" and i.czrq>='"+startDate+"' and i.czrq<='"+endDate+"' GROUP BY date";
|
|
|
}
|
|
|
List<Map<String,Object>> list2 = jdbcTemplate.queryForList(sql2);
|
|
|
Map<String, String> healthMap = list2.stream().collect(Collectors.toMap(e -> e.get("date").toString(), e -> e.get("num").toString()));
|
|
|
|
|
|
if("1".equals(timeType)){
|
|
|
LocalDate startLocal = LocalDate.parse(startDate);
|
|
|
LocalDate endLocal = LocalDate.parse(endDateTmp);
|
|
|
while (!startLocal.isAfter(endLocal)) {
|
|
|
String month = startLocal.toString();
|
|
|
Map<String,Object> map = dateMap.get(month);
|
|
|
String healthNum = healthMap.get(month);
|
|
|
if(map == null){
|
|
|
map = new HashMap<>();
|
|
|
map.put("date",month);
|
|
|
map.put("callNum","0");
|
|
|
map.put("consultNum","0");
|
|
|
map.put("doorNum","0");
|
|
|
map.put("guidanceNum","0");
|
|
|
map.put("followupNum","0");
|
|
|
map.put("visitNum","0");
|
|
|
}
|
|
|
if(StringUtils.isBlank(healthNum)){
|
|
|
healthNum = "0";
|
|
|
}
|
|
|
map.put("healthNum",healthNum);
|
|
|
result.add(map);
|
|
|
startLocal = startLocal.plusDays(1);
|
|
|
}
|
|
|
}else if("2".equals(timeType)){
|
|
|
String startWeek = getWeek(startDate,0);
|
|
|
String endWeek = getWeek(endDateTmp,0);
|
|
|
String currentWeek = getWeek(startDate,0);
|
|
|
int i = 1;
|
|
|
while (currentWeek.compareTo(endWeek)<=0) {
|
|
|
Map<String,Object> map = dateMap.get(currentWeek);
|
|
|
String healthNum = healthMap.get(currentWeek);
|
|
|
if(map == null){
|
|
|
map = new HashMap<>();
|
|
|
map.put("date",currentWeek);
|
|
|
map.put("callNum","0");
|
|
|
map.put("consultNum","0");
|
|
|
map.put("doorNum","0");
|
|
|
map.put("guidanceNum","0");
|
|
|
map.put("followupNum","0");
|
|
|
map.put("visitNum","0");
|
|
|
}
|
|
|
if(StringUtils.isBlank(healthNum)){
|
|
|
healthNum = "0";
|
|
|
}
|
|
|
map.put("healthNum",healthNum);
|
|
|
result.add(map);
|
|
|
currentWeek = getWeek(startDate,i);
|
|
|
i++;
|
|
|
}
|
|
|
|
|
|
}else {
|
|
|
YearMonth startYearMonth = YearMonth.from(LocalDate.parse(startDate));
|
|
|
YearMonth endYearMonth = YearMonth.from(LocalDate.parse(endDateTmp));
|
|
|
YearMonth currentYearMonth = startYearMonth;
|
|
|
|
|
|
while (!currentYearMonth.isAfter(endYearMonth)) {
|
|
|
String month = currentYearMonth.toString();
|
|
|
Map<String,Object> map = dateMap.get(month);
|
|
|
String healthNum = healthMap.get(month);
|
|
|
if(map == null){
|
|
|
map = new HashMap<>();
|
|
|
map.put("date",month);
|
|
|
map.put("callNum","0");
|
|
|
map.put("consultNum","0");
|
|
|
map.put("doorNum","0");
|
|
|
map.put("guidanceNum","0");
|
|
|
map.put("followupNum","0");
|
|
|
map.put("visitNum","0");
|
|
|
}
|
|
|
if(StringUtils.isBlank(healthNum)){
|
|
|
healthNum = "0";
|
|
|
}
|
|
|
map.put("healthNum",healthNum);
|
|
|
result.add(map);
|
|
|
currentYearMonth = currentYearMonth.plusMonths(1);
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public static String getWeek(String date,int addWeek) {
|
|
|
LocalDate now = LocalDate.parse(date);
|
|
|
if(addWeek>0){
|
|
|
now = now.plusWeeks(addWeek);
|
|
|
}
|
|
|
String week = Integer.toString(now.get(WeekFields.ISO.weekOfYear()));
|
|
|
if (week.length() == 1){
|
|
|
week = "0" + week;
|
|
|
}
|
|
|
String year = Integer.toString(now.getYear());
|
|
|
return year + week;
|
|
|
}
|
|
|
|
|
|
//诊后随访明细
|
|
|
public List<Map<String,Object>> followupDetail(String startDate,String endDate,Integer flag,String sort){
|
|
|
if(StringUtils.isBlank(sort)){
|
|
|
sort = "complete";
|
|
|
}
|
|
|
if(StringUtils.isBlank(startDate)){
|
|
|
if (flag == 1) {
|
|
|
startDate = DateUtil.getFirstMonthDay();
|
|
|
endDate = DateUtil.getLastMonthDay();
|
|
|
} else if (flag == 2) {
|
|
|
startDate = DateUtil.getMonthDate(new Date(), -6) ;
|
|
|
endDate = DateUtil.getStringDateShort();
|
|
|
} else if (flag == 3) {
|
|
|
startDate = DateUtil.getCurrentYearStartTime() ;
|
|
|
endDate = DateUtil.getCurrentYearEndTime();
|
|
|
}
|
|
|
}
|
|
|
endDate = endDate +" 23:59:59";
|
|
|
String sql = "SELECT COUNT(f.id) planNum,COUNT(if(f.`status`=1,1,null)) finishNum, " +
|
|
|
"COUNT(if(f.`status`=1,if(f.followup_date<f.followup_plan_date,1,null ),null)) ontimeNum, " +
|
|
|
"if(f.followup_date>=f.followup_plan_date,1,null ) overTimeNum,count(DISTINCT f.patient_code) patientNum " +
|
|
|
",f.doctor_name doctorName,h.dept_name deptName" +
|
|
|
" from wlyy_followup f,base_doctor_hospital h " +
|
|
|
"WHERE f.doctor_code=h.doctor_code and h.del=1 " +
|
|
|
" and f.followup_date>='"+startDate+"' and f.followup_date<='"+endDate+"' " +
|
|
|
"GROUP BY f.doctor_name,h.dept_name ";
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
final String sortTmp = sort;
|
|
|
Map<String, List<Map<String, Object>>> resList = list.stream().collect(Collectors.groupingBy(e -> e.get("deptName").toString()));
|
|
|
List<Map<String,Object>> result = new ArrayList<>();
|
|
|
for (Map.Entry<String, List<Map<String,Object>>> entry:resList.entrySet()){
|
|
|
String key = entry.getKey();
|
|
|
int planNumDept = 0;
|
|
|
int finishNumDept = 0;
|
|
|
int ontimeNumDept = 0;
|
|
|
int overTimeNumDept = 0;
|
|
|
int patientNumDept = 0;
|
|
|
Map<String,Object> deptTmp = new HashMap<>();
|
|
|
List<Map<String,Object>> value = entry.getValue();
|
|
|
String dept = "";
|
|
|
for (Map<String,Object> map:value){
|
|
|
dept = map.get("dept")+"";
|
|
|
int planNum = Integer.parseInt(map.get("planNum")+"");
|
|
|
int finishNum = Integer.parseInt(map.get("finishNum")+"");
|
|
|
int ontimeNum = Integer.parseInt(map.get("ontimeNum")+"");
|
|
|
int overTimeNum = Integer.parseInt(map.get("overTimeNum")+"");
|
|
|
int patientNum = Integer.parseInt(map.get("patientNum")+"");
|
|
|
map.put("completeRate",getRange(finishNum, planNum,0));
|
|
|
map.put("complete",getDoubleRange((double) finishNum, (double) planNum,0));
|
|
|
planNumDept += planNum;
|
|
|
finishNumDept += finishNum;
|
|
|
ontimeNumDept += ontimeNum;
|
|
|
overTimeNumDept += overTimeNum;
|
|
|
patientNumDept += patientNum;
|
|
|
}
|
|
|
deptTmp.put("doctorName","-");
|
|
|
deptTmp.put("deptName",key);
|
|
|
deptTmp.put("planNum",planNumDept);
|
|
|
deptTmp.put("finishNum",finishNumDept);
|
|
|
deptTmp.put("ontimeNum",ontimeNumDept);
|
|
|
deptTmp.put("overTimeNum",overTimeNumDept);
|
|
|
deptTmp.put("patientNum",patientNumDept);
|
|
|
deptTmp.put("completeRate",getRange(finishNumDept, planNumDept,0));
|
|
|
deptTmp.put("complete",getDoubleRange((double) finishNumDept, (double) planNumDept,0));
|
|
|
value.sort(Comparator.comparingDouble(a->Double.parseDouble(a.get(sortTmp)+"")));
|
|
|
deptTmp.put("list",value);
|
|
|
deptTmp.put("hasChildren",false);
|
|
|
if(value.size()>0){
|
|
|
deptTmp.put("hasChildren",true);
|
|
|
}
|
|
|
result.add(deptTmp);
|
|
|
}
|
|
|
result.sort(Comparator.comparingDouble(a->Double.parseDouble(a.get(sortTmp)+"")));
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public List<Map<String,Object>> exportFollowupDetail(String startDate,String endDate,Integer flag,String sort){
|
|
|
if(StringUtils.isBlank(sort)){
|
|
|
sort = "complete";
|
|
|
}
|
|
|
if(StringUtils.isBlank(startDate)){
|
|
|
if (flag == 1) {
|
|
|
startDate = DateUtil.getFirstMonthDay();
|
|
|
endDate = DateUtil.getLastMonthDay();
|
|
|
} else if (flag == 2) {
|
|
|
startDate = DateUtil.getMonthDate(new Date(), -6) ;
|
|
|
endDate = DateUtil.getStringDateShort();
|
|
|
} else if (flag == 3) {
|
|
|
startDate = DateUtil.getCurrentYearStartTime() ;
|
|
|
endDate = DateUtil.getCurrentYearEndTime();
|
|
|
}
|
|
|
}
|
|
|
endDate = endDate +" 23:59:59";
|
|
|
String sql = "SELECT COUNT(f.id) planNum,COUNT(if(f.`status`=1,1,null)) finishNum, " +
|
|
|
"COUNT(if(f.`status`=1,if(f.followup_date<f.followup_plan_date,1,null ),null)) ontimeNum, " +
|
|
|
"if(f.followup_date>=f.followup_plan_date,1,null ) overTimeNum,count(DISTINCT f.patient_code) patientNum " +
|
|
|
",f.doctor_name doctorName,h.dept_name deptName" +
|
|
|
" from wlyy_followup f,base_doctor_hospital h " +
|
|
|
"WHERE f.doctor_code=h.doctor_code and h.del=1 " +
|
|
|
" and f.followup_date>='"+startDate+"' and f.followup_date<='"+endDate+"' " +
|
|
|
"GROUP BY f.doctor_name,h.dept_name ";
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
final String sortTmp = sort;
|
|
|
Map<String, List<Map<String, Object>>> resList = list.stream().collect(Collectors.groupingBy(e -> e.get("deptName").toString()));
|
|
|
List<Map<String,Object>> tmpList = new ArrayList<>();
|
|
|
List<Map<String,Object>> result = new ArrayList<>();
|
|
|
for (Map.Entry<String, List<Map<String,Object>>> entry:resList.entrySet()){
|
|
|
String key = entry.getKey();
|
|
|
int planNumDept = 0;
|
|
|
int finishNumDept = 0;
|
|
|
int ontimeNumDept = 0;
|
|
|
int overTimeNumDept = 0;
|
|
|
int patientNumDept = 0;
|
|
|
Map<String,Object> deptTmp = new HashMap<>();
|
|
|
List<Map<String,Object>> value = entry.getValue();
|
|
|
for (Map<String,Object> map:value){
|
|
|
int planNum = Integer.parseInt(map.get("planNum")+"");
|
|
|
int finishNum = Integer.parseInt(map.get("finishNum")+"");
|
|
|
int ontimeNum = Integer.parseInt(map.get("ontimeNum")+"");
|
|
|
int overTimeNum = Integer.parseInt(map.get("overTimeNum")+"");
|
|
|
int patientNum = Integer.parseInt(map.get("patientNum")+"");
|
|
|
map.put("completeRate",getRange(finishNum, planNum,0));
|
|
|
map.put("complete",getDoubleRange((double) finishNum, (double) planNum,0));
|
|
|
planNumDept += planNum;
|
|
|
finishNumDept += finishNum;
|
|
|
ontimeNumDept += ontimeNum;
|
|
|
overTimeNumDept += overTimeNum;
|
|
|
patientNumDept += patientNum;
|
|
|
}
|
|
|
deptTmp.put("doctorName","-");
|
|
|
deptTmp.put("deptName",key);
|
|
|
deptTmp.put("planNum",planNumDept);
|
|
|
deptTmp.put("finishNum",finishNumDept);
|
|
|
deptTmp.put("ontimeNum",ontimeNumDept);
|
|
|
deptTmp.put("overTimeNum",overTimeNumDept);
|
|
|
deptTmp.put("patientNum",patientNumDept);
|
|
|
deptTmp.put("completeRate",getRange(finishNumDept, planNumDept,0));
|
|
|
deptTmp.put("complete",getDoubleRange((double) finishNumDept, (double) planNumDept,0));
|
|
|
value.sort(Comparator.comparingDouble(a->Double.parseDouble(a.get(sortTmp)+"")));
|
|
|
tmpList.add(deptTmp);
|
|
|
}
|
|
|
tmpList.sort(Comparator.comparingDouble(a->Double.parseDouble(a.get(sortTmp)+"")));
|
|
|
for (Map<String,Object> map:tmpList){
|
|
|
result.add(map);
|
|
|
String key = map.get("deptName")+"";
|
|
|
List<Map<String,Object>> value = resList.get(key);
|
|
|
if(value!=null){
|
|
|
result.addAll(value);
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 科室下转排行、诊断下转排行
|
|
|
* @param startDate
|
|
|
* @param endDate
|
|
|
* @param flag
|
|
|
* @param type 1科室 2诊断
|
|
|
*/
|
|
|
public List<Map<String,Object>> tuanDownRanking(String startDate,String endDate,Integer flag,String type,String dept){
|
|
|
if(StringUtils.isBlank(startDate)){
|
|
|
if (flag == 1) {
|
|
|
startDate = DateUtil.getFirstMonthDay();
|
|
|
endDate = DateUtil.getLastMonthDay();
|
|
|
} else if (flag == 2) {
|
|
|
startDate = DateUtil.getMonthDate(new Date(), -6) ;
|
|
|
endDate = DateUtil.getStringDateShort();
|
|
|
} else if (flag == 3) {
|
|
|
startDate = DateUtil.getCurrentYearStartTime() ;
|
|
|
endDate = DateUtil.getCurrentYearEndTime();
|
|
|
}
|
|
|
}
|
|
|
endDate = endDate +" 23:59:59";
|
|
|
String column1 = "dept code,dept_name name";
|
|
|
String column2 = "dept";
|
|
|
if("2".equals(type)){
|
|
|
column1 = "diagnosis code,diagnosis_name name";
|
|
|
column2 = "diagnosis";
|
|
|
}
|
|
|
String sql = "SELECT "+column1+",COUNT(*) num from wlyy_rehabilitation_patient_info " +
|
|
|
"WHERE `status` in (1,7) and create_time>='"+startDate+"' and create_time<='"+endDate+"' ";
|
|
|
if(StringUtils.isNotBlank(dept)){
|
|
|
sql += " and dept = '"+ dept +"'";
|
|
|
}
|
|
|
sql += " GROUP BY "+column2+" ORDER BY num ";
|
|
|
return jdbcTemplate.queryForList(sql);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 科室随访排行、医生随访排行
|
|
|
* @param startDate
|
|
|
* @param endDate
|
|
|
* @param flag
|
|
|
* @param type 1科室 2医生
|
|
|
*/
|
|
|
public List<Map<String,Object>> followupRanking(String startDate,String endDate,Integer flag,String type,String dept){
|
|
|
if(StringUtils.isBlank(startDate)){
|
|
|
if (flag == 1) {
|
|
|
startDate = DateUtil.getFirstMonthDay();
|
|
|
endDate = DateUtil.getLastMonthDay();
|
|
|
} else if (flag == 2) {
|
|
|
startDate = DateUtil.getMonthDate(new Date(), -6) ;
|
|
|
endDate = DateUtil.getStringDateShort();
|
|
|
} else if (flag == 3) {
|
|
|
startDate = DateUtil.getCurrentYearStartTime() ;
|
|
|
endDate = DateUtil.getCurrentYearEndTime();
|
|
|
}
|
|
|
}
|
|
|
endDate = endDate +" 23:59:59";
|
|
|
|
|
|
String sql = "SELECT COUNT(f.id) planNum,COUNT(if(f.`status`=1,1,null)) finishNum,h.dept_name name " +
|
|
|
" from wlyy_followup f,base_doctor_hospital h " +
|
|
|
"WHERE f.doctor_code=h.doctor_code and h.del=1 and f.followup_date>='"+startDate+"' and f.followup_date<='"+endDate+"' ";
|
|
|
if(StringUtils.isNotBlank(dept)){
|
|
|
sql += " and h.dept_code = '"+ dept +"'";
|
|
|
}
|
|
|
sql += " GROUP BY h.dept_name ";
|
|
|
if("2".equals(type)){
|
|
|
sql = "SELECT COUNT(f.id) planNum,COUNT(if(f.`status`=1,1,null)) finishNum,f.doctor_name name " +
|
|
|
" from wlyy_followup f WHERE 1=1 and f.followup_date>='"+startDate+"' and f.followup_date<='"+endDate+"'" +
|
|
|
" GROUP BY f.doctor_name";
|
|
|
if(StringUtils.isNotBlank(dept)){
|
|
|
sql = "SELECT COUNT(f.id) planNum,COUNT(if(f.`status`=1,1,null)) finishNum,f.doctor_name name " +
|
|
|
" from wlyy_followup f,base_doctor_hospital h " +
|
|
|
"WHERE f.doctor_code=h.doctor_code and h.del=1 and f.followup_date>='"+startDate+"' and f.followup_date<='"+endDate+"' "+
|
|
|
" and h.dept_code = '"+ dept +"' GROUP BY f.doctor_name";
|
|
|
}
|
|
|
}
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String,Object> map:list){
|
|
|
int planNum = Integer.parseInt(map.get("planNum")+"");
|
|
|
int finishNum = Integer.parseInt(map.get("finishNum")+"");
|
|
|
map.put("completeRate",getRange(finishNum, planNum,0));
|
|
|
map.put("complete",getDoubleRange((double) finishNum, (double) planNum,0));
|
|
|
}
|
|
|
list.sort(Comparator.comparingDouble(a->Double.parseDouble(a.get("complete")+"")));
|
|
|
return list;
|
|
|
}
|
|
|
}
|