|
@ -118,6 +118,9 @@ public class StatisticsService {
|
|
|
// 39 老人-生活照料-服务工单数
|
|
|
// 44 老人-生活照料-代预约
|
|
|
// 54 新生儿-上门辅导-工单发起数
|
|
|
// 64 活动浏览数
|
|
|
// 65 课程播放数
|
|
|
// 66 活动报名数
|
|
|
|
|
|
String index = "28,31,35,37,39,44,54";
|
|
|
String[] indexes = index.split(",");
|
|
@ -126,6 +129,17 @@ public class StatisticsService {
|
|
|
SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, defalutArea, defalutLevel, ind, SaveModel.timeLevel_DDL);
|
|
|
res.put("index_" + ind, saveModel.getResult2().longValue());
|
|
|
}
|
|
|
// activity-1 活动浏览次数64
|
|
|
// activity-2 公艺课程播放65
|
|
|
// activity-3 公艺课程播放65
|
|
|
SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, defalutArea, defalutLevel, "64", SaveModel.timeLevel_DDL);
|
|
|
res.put("activity_1", saveModel.getResult2().longValue());
|
|
|
saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, defalutArea, defalutLevel, "65", SaveModel.timeLevel_DDL);
|
|
|
res.put("activity_2", saveModel.getResult2().longValue());
|
|
|
saveModel = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, defalutArea, defalutLevel, "66", SaveModel.timeLevel_DDL);
|
|
|
res.put("activity_3", saveModel.getResult2().longValue());
|
|
|
|
|
|
|
|
|
//41紧急预警43安防要与实时一样,查sql
|
|
|
String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org' ";
|
|
|
List<Map<String, Object>> listtmp = jdbcTemplate.queryForList(sqltmp);
|
|
@ -159,21 +173,6 @@ public class StatisticsService {
|
|
|
//居民健康标签纬度
|
|
|
res.put("patientLabelStatistic", statisticsOrderServer("47", endDate, 2, "2"));
|
|
|
|
|
|
// activity-1 活动浏览次数
|
|
|
// activity-2 公艺课程播放
|
|
|
res.put("activity_1", 0);
|
|
|
res.put("activity_2", 0);
|
|
|
String sql = " SELECT activity_type, COUNT(id) total FROM base_activity_click WHERE activity_type IN (1, 2) GROUP BY activity_type";
|
|
|
List<Map<String, Object>> lists = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String, Object> tmp : lists) {
|
|
|
Integer num = Integer.parseInt(tmp.get("total").toString());
|
|
|
res.put("activity_" + tmp.get("activity_type").toString(), num);
|
|
|
}
|
|
|
|
|
|
//activity-3 幼儿活动报名-总数
|
|
|
sql = " select count(id) as total from base_child_activity_registration and org.code not in (SELECT dict_code from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org') ";
|
|
|
Integer count = jdbcTemplate.queryForObject(sql, Integer.class);
|
|
|
res.put("activity_3", count);
|
|
|
return res;
|
|
|
}
|
|
|
|
|
@ -639,8 +638,11 @@ public class StatisticsService {
|
|
|
|
|
|
/**
|
|
|
* 平台人员实时统计
|
|
|
* @param area 查询区域 目前仅支持查询老人、社工、家属
|
|
|
* @param level 区域等级 2市3区4机构5团队6医生
|
|
|
*/
|
|
|
public JSONObject platformPeople() {
|
|
|
public JSONObject platformPeople(String area,Integer level) {
|
|
|
String areaFilter = " ";
|
|
|
JSONObject result = new JSONObject();
|
|
|
Integer olderTotal = 0;
|
|
|
Integer childTotal = 0;
|
|
@ -692,9 +694,14 @@ public class StatisticsService {
|
|
|
oldFilter = " and a.id not in ('" + orgCodes + "')";
|
|
|
}
|
|
|
|
|
|
|
|
|
String sql1 = "SELECT COUNT(*) c,case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online from base_patient a WHERE archive_type = 1" +
|
|
|
" and del='1' " + oldFilter + " GROUP BY online";
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(area)&&5==level){
|
|
|
areaFilter = " and EXISTS ( select 1 from " +
|
|
|
"base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack " +
|
|
|
" where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id " +
|
|
|
" and i.del = 1 and sr.`status`=1 and CONVERT(sr.patient USING utf8) = a.id and r.team_code='"+area+"') ";
|
|
|
}
|
|
|
String sql1 = "SELECT COUNT(*) c,case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online from base_patient a WHERE archive_type = 1 " +
|
|
|
" and del='1' "+areaFilter+" " + oldFilter + " GROUP BY online";
|
|
|
List<Map<String, Object>> list1 = jdbcTemplate.queryForList(sql1);
|
|
|
for (Map<String, Object> map : list1) {
|
|
|
Integer num = Integer.valueOf(map.get("c").toString());
|
|
@ -709,7 +716,12 @@ public class StatisticsService {
|
|
|
childTotal = childOff + childOn;
|
|
|
|
|
|
//社工和教师注册人数
|
|
|
String sql2 = "SELECT COUNT(a.id) c,a.doctor_level,IFNULL(a.on_line,0) online from base_doctor a,base_doctor_hospital h where a.id=h.doctor_code and a.del = '1' and h.del = '1' " +
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(area)&&5==level){
|
|
|
areaFilter = " and EXISTS ( select 1 from base_team_member mem where mem.doctor_code = a.id " +
|
|
|
" and mem.team_code='"+area+"' and mem.del=1 ) ";
|
|
|
}
|
|
|
String sql2 = "SELECT COUNT(a.id) c,a.doctor_level,IFNULL(a.on_line,0) online " +
|
|
|
"from base_doctor a,base_doctor_hospital h where a.id=h.doctor_code and a.del = '1' and h.del = '1' " +areaFilter+
|
|
|
"and a.doctor_level is not null and h.org_code not in ( " +
|
|
|
"SELECT dict_code from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org' " +
|
|
|
") GROUP BY a.doctor_level,on_line";
|
|
@ -746,7 +758,21 @@ public class StatisticsService {
|
|
|
orgCodes = orgCodes.replaceAll(",", "','");
|
|
|
olderRelativeFilter = " and t2.id not in ('" + orgCodes + "') ";
|
|
|
}
|
|
|
sql2 = " select count(id) count,if(openid is null,0,1) online from base_patient t2 where archive_type=3 and del=1 "+olderRelativeFilter+" GROUP BY online; ";
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(area)&&5==level){
|
|
|
//有社区只查询该社区老人的家属列表
|
|
|
areaFilter = " and EXISTS ( select 1 from " +
|
|
|
"base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack " +
|
|
|
" where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id " +
|
|
|
" and i.del = 1 and sr.`status`=1 and CONVERT(sr.patient USING utf8) = t3.id and r.team_code='"+area+"' ) ";
|
|
|
|
|
|
sql2 = " select count(distinct t2.id) count,if(t2.openid is null,0,1) online " +
|
|
|
"from base_patient t2 left JOIN base_patient_family_member t1 on t1.family_member = t2.id " +
|
|
|
"left join base_patient t3 on t3.id = t1.patient " +
|
|
|
"where t2.archive_type=3 and t2.del=1 and t3.archive_type=1 and t3.del=1 "+olderRelativeFilter+areaFilter + "GROUP BY online ";
|
|
|
|
|
|
}else {
|
|
|
sql2 = " select count(id) count,if(openid is null,0,1) online from base_patient t2 where archive_type=3 and del=1 "+olderRelativeFilter+" GROUP BY online; ";
|
|
|
}
|
|
|
List<Map<String, Object>> oldFamilyList2 = jdbcTemplate.queryForList(sql2);
|
|
|
for(Map<String,Object>tmp:oldFamilyList2){
|
|
|
Integer num = Integer.valueOf(tmp.get("count").toString());
|
|
@ -760,9 +786,15 @@ public class StatisticsService {
|
|
|
}
|
|
|
olderFamilyTotal = olderFamilyOff+olderFamilyOn;
|
|
|
//家属绑定老人数量
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(area)&&5==level){
|
|
|
areaFilter = " and EXISTS ( select 1 from " +
|
|
|
"base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack " +
|
|
|
" where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id " +
|
|
|
" and i.del = 1 and sr.`status`=1 and CONVERT(sr.patient USING utf8) = t3.id and r.team_code='"+area+"' ) ";
|
|
|
}
|
|
|
sql2 = " select count(distinct t3.id) total from base_patient t2 left JOIN base_patient_family_member t1 on t1.family_member = t2.id " +
|
|
|
" Inner join base_patient t3 on t3.id = t1.patient " +
|
|
|
" where t2.archive_type=3 and t2.del=1 and t3.archive_type=1 and t3.del=1 ";
|
|
|
" where t2.archive_type=3 and t2.del=1 and t3.archive_type=1 and t3.del=1 "+areaFilter ;
|
|
|
|
|
|
olderFamilyBinding = jdbcTemplate.queryForObject(sql2,Integer.class);
|
|
|
|
|
@ -1072,9 +1104,9 @@ public class StatisticsService {
|
|
|
*/
|
|
|
public JSONObject lifeCareAnalysis(String endDate, String area, int level) throws Exception {
|
|
|
JSONObject res = new JSONObject();
|
|
|
String totalIndex = "38";
|
|
|
String noReplyIndex = "39";
|
|
|
String inTimeIndex = "40";
|
|
|
String totalIndex = "38";//已服务人数
|
|
|
String noReplyIndex = "39"; //工单数 (除了已取消与未支付)
|
|
|
String inTimeIndex = "48"; //工单项目数 (除了已取消与未支付)
|
|
|
//老人数
|
|
|
SaveModel saveModel1 = elasticsearchUtil.findOneDateQuotaLevel0(endDate, endDate, area, level, totalIndex, SaveModel.timeLevel_DDL);
|
|
|
//工单数
|
|
@ -1300,7 +1332,7 @@ public class StatisticsService {
|
|
|
if (ind.equals("46")){
|
|
|
list = elasticsearchUtil.findDateQuotaLevel2ByKeyGroup(DateUtil.getStringDateShort(), DateUtil.getStringDateShort(), defalutArea, 2, "46", SaveModel.timeLevel_DDL, null, "-2,0,1", null, null, "4", "1");
|
|
|
}else {
|
|
|
elasticsearchUtil.findDateAllQuotaLevel1(endDate, endDate, defalutArea, level, ind, SaveModel.timeLevel_DDL, null, null, areaLevel);
|
|
|
list = elasticsearchUtil.findDateAllQuotaLevel1(endDate, endDate, defalutArea, level, ind, SaveModel.timeLevel_DDL, null, null, areaLevel);
|
|
|
}
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
SaveModel saveModel = list.get(i);
|
|
@ -1962,7 +1994,6 @@ public class StatisticsService {
|
|
|
}
|
|
|
|
|
|
//老人整体概况
|
|
|
|
|
|
public Map<String,Object> getOlderOverview(String currentUserRole,String currentUserRoleLevel){
|
|
|
String year = DateUtil.getNowYear()+"";
|
|
|
String sql = " select * from base_older_num where type='"+currentUserRoleLevel+"' and code='"+currentUserRole+"' and year='"+year+"' ";
|
|
@ -1987,12 +2018,6 @@ public class StatisticsService {
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
SaveModel saveModel = list.get(i);
|
|
|
JSONObject json = new JSONObject();
|
|
|
if (saveModel.getResult2().longValue() == 0 && StringUtils.isBlank(saveModel.getSlaveKey1())) {
|
|
|
continue;
|
|
|
}
|
|
|
if ("0".equals(saveModel.getSlaveKey1())) {
|
|
|
continue;
|
|
|
}
|
|
|
json.put("num", saveModel.getResult2().longValue());
|
|
|
json.put("code", saveModel.getSlaveKey1());
|
|
|
json.put("name", saveModel.getSlaveKey1Name());
|
|
@ -2074,4 +2099,240 @@ public class StatisticsService {
|
|
|
res.put("wishesPeople", saveModel.getResult2().longValue());
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* @param area
|
|
|
* @param level 2 市 3区 4医院 5、团队 6医生
|
|
|
*获取老人服务情况(助老服务、紧急救助、医生服务、监测设备)
|
|
|
*/
|
|
|
public JSONObject getServerSituation(String area,int level) throws Exception {
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
Long finishCount = 0l;
|
|
|
Long unfinishCount = 0l;
|
|
|
//助老服务 生活照料
|
|
|
JSONObject olderServiceInfo = new JSONObject();
|
|
|
olderServiceInfo.put("finish",0);
|
|
|
olderServiceInfo.put("unfinish",0);
|
|
|
olderServiceInfo.put("law",0);
|
|
|
//紧急救助 呼叫+安防 指标67
|
|
|
JSONObject emeAssistance = new JSONObject();
|
|
|
emeAssistance.put("finish",0);
|
|
|
emeAssistance.put("unfinish",0);
|
|
|
emeAssistance.put("law",0);
|
|
|
//医生服务 老人健康咨询咨询+续方
|
|
|
JSONObject doctorServiceInfo = new JSONObject();
|
|
|
doctorServiceInfo.put("finish",0);
|
|
|
doctorServiceInfo.put("unfinish",0);
|
|
|
doctorServiceInfo.put("law",0);
|
|
|
//监测设备
|
|
|
JSONObject monitorDevice = new JSONObject();
|
|
|
monitorDevice.put("healthDevice",0);
|
|
|
monitorDevice.put("securityDevice",0);
|
|
|
monitorDevice.put("offlineDevice",0);
|
|
|
String areaFilter = "";
|
|
|
|
|
|
if (StringUtils.isNotBlank(area)&&2!=level){
|
|
|
if (4==level){
|
|
|
areaFilter = " and pack.org_code='"+area+"' ";
|
|
|
}
|
|
|
if (5==level){//团队
|
|
|
areaFilter = " and r.team_code='"+area+"' ";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
String olderFilter = " and EXISTS ( select 1 from " +
|
|
|
" base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack " +
|
|
|
" where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id and i.del = 1 " +
|
|
|
" and sr.`status`=1 and CONVERT(sr.patient USING utf8) = {patient} " +
|
|
|
" and CONVERT(sr.patient USING utf8) not in (SELECT dict_code FROM `base`.`wlyy_hospital_sys_dict` WHERE `dict_name` = 'jkzl_older' or dict_name='jkzl_child') "+areaFilter+" ) ";
|
|
|
//助老服务 生活照料 已完成
|
|
|
String sql = " select count(life.id) from base_life_care_order life where life.`status`=2 "+olderFilter.replace("{patient}","life.patient") +"" ;
|
|
|
finishCount = jdbcTemplate.queryForObject(sql,Long.class);
|
|
|
olderServiceInfo.put("finish",finishCount);
|
|
|
sql = " select count(life.id) from base_life_care_order life where life.status in (1,3) "+olderFilter.replace("{patient}","life.patient")+" " ;
|
|
|
unfinishCount = jdbcTemplate.queryForObject(sql,Long.class);
|
|
|
olderServiceInfo.put("unfinish",unfinishCount);
|
|
|
olderServiceInfo.put("law",commonUtil.getRangeDouble(finishCount.intValue(),(finishCount.intValue()+unfinishCount.intValue())));
|
|
|
result.put("olderServiceInfo",olderServiceInfo);
|
|
|
|
|
|
//紧急救助 呼叫+安防
|
|
|
//紧急救助 已响应
|
|
|
SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel1(DateUtil.getStringDateShort(), area, level, "67", SaveModel.timeLevel_DDL,"-2,0");
|
|
|
SaveModel saveModel2 = elasticsearchUtil.findOneDateQuotaLevel1(DateUtil.getStringDateShort(), area, level, "67", SaveModel.timeLevel_DDL,"1");
|
|
|
finishCount = saveModel.getResult2().longValue();
|
|
|
unfinishCount = saveModel2.getResult2().longValue();
|
|
|
emeAssistance.put("finish",finishCount);
|
|
|
emeAssistance.put("unfinish",unfinishCount);
|
|
|
emeAssistance.put("law",commonUtil.getRangeDouble(finishCount.intValue(),(finishCount.intValue()+unfinishCount.intValue())));
|
|
|
result.put("emeAssistance",emeAssistance);
|
|
|
|
|
|
//医生服务 老人健康咨询咨询+续方
|
|
|
sql = " SELECT count(p.id) FROM base_care_prescription p where p.status=2 "+olderFilter.replace("{patient}","p.patient")+" ";
|
|
|
finishCount = jdbcTemplate.queryForObject(sql,Long.class);
|
|
|
sql = " SELECT count(p.id) FROM base_care_prescription p where p.status=1 "+olderFilter.replace("{patient}","p.patient")+" ";
|
|
|
unfinishCount = jdbcTemplate.queryForObject(sql,Long.class);
|
|
|
//老人健康咨询咨询
|
|
|
sql = " SELECT count(o.consult) FROM wlyy_consult_team o INNER JOIN base_doctor d on o.doctor = d.id " +
|
|
|
" where o.status=1 and o.type = 25 AND d.del = 1 "+olderFilter.replace("{patient}","o.patient")+" ";
|
|
|
finishCount += jdbcTemplate.queryForObject(sql,Long.class);
|
|
|
sql = " SELECT count(o.consult) FROM wlyy_consult_team o INNER JOIN base_doctor d on o.doctor = d.id " +
|
|
|
" where o.status=0 and o.type = 25 AND d.del = 1 "+olderFilter.replace("{patient}","o.patient")+" ";
|
|
|
unfinishCount += jdbcTemplate.queryForObject(sql,Long.class);
|
|
|
doctorServiceInfo.put("finish",finishCount);
|
|
|
doctorServiceInfo.put("unfinish",unfinishCount);
|
|
|
doctorServiceInfo.put("law",commonUtil.getRangeDouble(finishCount.intValue(),(finishCount.intValue()+unfinishCount.intValue())));
|
|
|
|
|
|
//监测设备
|
|
|
sql = " select count(distinct pd.device_sn) from wlyy_patient_device pd INNER JOIN base_patient p on pd.user = p.id and pd.del=0 and p.del=1 " +
|
|
|
"where pd.device_type=0 "+olderFilter.replace("{patient}","pd.user");
|
|
|
Long count = jdbcTemplate.queryForObject(sql,Long.class);//健康设备
|
|
|
monitorDevice.put("healthDevice",count);
|
|
|
sql = " select count(distinct pd.device_sn) from wlyy_patient_device pd INNER JOIN base_patient p on pd.user = p.id and pd.del=0 and p.del=1 " +
|
|
|
"where pd.device_type=1 "+olderFilter.replace("{patient}","pd.user");
|
|
|
count = jdbcTemplate.queryForObject(sql,Long.class);//安防设备
|
|
|
monitorDevice.put("securityDevice",count);
|
|
|
sql = " select count(distinct pd.device_sn) from wlyy_patient_device pd INNER JOIN wlyy_devices dev on pd.device_sn = dev.device_code " +
|
|
|
" INNER JOIN base_patient p on pd.user = p.id and pd.del=0 and p.del=1 " +
|
|
|
"where (dev.contact_status=0 or dev.contact_status is null ) "+olderFilter.replace("{patient}","pd.user");
|
|
|
count = jdbcTemplate.queryForObject(sql,Long.class);//离线设备
|
|
|
monitorDevice.put("offlineDevice",count);
|
|
|
|
|
|
result.put("olderServiceInfo",olderServiceInfo);
|
|
|
result.put("emeAssistance",emeAssistance);
|
|
|
result.put("doctorServiceInfo",doctorServiceInfo);
|
|
|
result.put("monitorDevice",monitorDevice);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
*获取老人服务情况(助老服务、紧急救助、医生服务 项目数量)
|
|
|
*/
|
|
|
public JSONObject getServerSituationItem(String endDate,String area,int level) throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
|
//助老服务 生活照料 (出去已取消和未支付)
|
|
|
JSONArray olderServiceInfo = new JSONArray();
|
|
|
List<SaveModel> list = statisticsUtilService.findDateAllQuotaLevel1Sort(endDate, endDate, area, level, "48", SaveModel.timeLevel_DDL, null, null);
|
|
|
for (int i = 0; (i < list.size() && i < 5); i++) {
|
|
|
SaveModel saveModel = list.get(i);
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("num", saveModel.getResult2().longValue());
|
|
|
json.put("code", saveModel.getSlaveKey1());
|
|
|
json.put("name", saveModel.getSlaveKey1Name());
|
|
|
olderServiceInfo.add(json);
|
|
|
}
|
|
|
//紧急救助 呼叫68+安防46 已取消不算
|
|
|
JSONArray emeAssistance = new JSONArray();
|
|
|
list = elasticsearchUtil.findDateQuotaLevel2ByKeyGroup(endDate, endDate, area, level, "46", SaveModel.timeLevel_DDL, null, "-2,0,1", null, null, "4", "1");
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
SaveModel saveModel = list.get(i);
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("num", saveModel.getResult2().longValue());
|
|
|
json.put("code", saveModel.getSlaveKey1());
|
|
|
json.put("name", saveModel.getSlaveKey1Name());
|
|
|
emeAssistance.add(json);
|
|
|
}
|
|
|
//紧急呼叫
|
|
|
SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel1(endDate, endDate, area, level, "68", SaveModel.timeLevel_DDL, "-2,0,1");
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("num", saveModel.getResult2().longValue());
|
|
|
json.put("code", "jjhj");
|
|
|
json.put("name", "紧急呼叫");
|
|
|
emeAssistance.add(json);
|
|
|
emeAssistance.sort(Comparator.comparing(obj -> ((JSONObject) obj).getLongValue("num")).reversed());
|
|
|
|
|
|
//医生服务 老人健康咨询咨询+续方
|
|
|
String areaFilter = "";
|
|
|
|
|
|
if (StringUtils.isNotBlank(area)&&2!=level){
|
|
|
if (4==level){
|
|
|
areaFilter = " and pack.org_code='"+area+"' ";
|
|
|
}
|
|
|
if (5==level){//团队
|
|
|
areaFilter = " and r.team_code='"+area+"' ";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
String olderFilter = " and EXISTS ( select 1 from " +
|
|
|
" base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack " +
|
|
|
" where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id and i.del = 1 " +
|
|
|
" and sr.`status`=1 and CONVERT(sr.patient USING utf8) = {patient} " +
|
|
|
" and CONVERT(sr.patient USING utf8) not in (SELECT dict_code FROM `base`.`wlyy_hospital_sys_dict` WHERE `dict_name` = 'jkzl_older' or dict_name='jkzl_child') "+areaFilter+" ) ";
|
|
|
|
|
|
JSONArray doctorServiceInfo = new JSONArray();
|
|
|
String sql = " SELECT count(p.id) FROM base_care_prescription p where 1=1 "+olderFilter.replace("{patient}","p.patient")+" ";
|
|
|
Long count = jdbcTemplate.queryForObject(sql,Long.class);
|
|
|
json = new JSONObject();
|
|
|
json.put("num", count);
|
|
|
json.put("code", "cfxf");
|
|
|
json.put("name", "处方续方");
|
|
|
doctorServiceInfo.add(json);
|
|
|
sql = " SELECT count(o.consult) FROM wlyy_consult_team o INNER JOIN base_doctor d on o.doctor = d.id " +
|
|
|
" where o.type = 25 AND d.del = 1 "+olderFilter.replace("{patient}","o.patient")+" ";
|
|
|
count = jdbcTemplate.queryForObject(sql,Long.class);
|
|
|
json = new JSONObject();
|
|
|
json.put("num", count);
|
|
|
json.put("code", "jkzx");
|
|
|
json.put("name", "健康咨询");
|
|
|
doctorServiceInfo.add(json);
|
|
|
|
|
|
result.put("olderServiceItemInfo",olderServiceInfo);
|
|
|
result.put("emeAssistanceItem",emeAssistance);
|
|
|
result.put("doctorServiceItemInfo",doctorServiceInfo);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取养老服务社区团队列表
|
|
|
*/
|
|
|
public List<Map<String,Object>> getOlderTeamList() throws Exception {
|
|
|
List<Map<String,Object>> teamList = new ArrayList<>();
|
|
|
String sql = " select distinct org.code as orgCode,org.name as orgName,te.id as teamId,te.name as teamName from " +
|
|
|
" base_service_package pack INNER JOIN base_org org on pack.org_code = org.code " +
|
|
|
"INNER JOIN base_team te on te.org_code = org.`code` " +
|
|
|
" where org.del=1 and org.type=3 and te.del=1 and org.code not in " +
|
|
|
" (select dict_code from wlyy_hospital_sys_dict where dict_name='jkzl_org') ";
|
|
|
teamList = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String,Object> map:teamList){
|
|
|
//1 获取社工人数(该团队人数) 2.预警数(紧急呼叫+安防监护 已取消的不算)
|
|
|
//3助老服务(该社区所有老人的生活照料总数 已取消的不算) 4物联设备(健康设备绑定量+安防设备绑定量)
|
|
|
String teamName = map.get("teamName").toString();
|
|
|
String teamId = map.get("teamId").toString();
|
|
|
teamName = teamName.replace("团队","社区");
|
|
|
if(!teamName.contains("社区")){
|
|
|
teamName = teamName+"社区";
|
|
|
}
|
|
|
map.put("teamName",teamName);
|
|
|
sql = " select count(doc.id) from base_team_member mem ,base_doctor doc where mem.team_code='"+teamId+"' " +
|
|
|
" and mem.doctor_code = doc.id and mem.del=1 and doc.del=1 ";
|
|
|
Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
map.put("doctorCount",count);
|
|
|
SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel1(DateUtil.getStringDateShort(), teamId, 5, "67", SaveModel.timeLevel_DDL,"-2,0,1");
|
|
|
map.put("emeAssistanceCount",saveModel.getResult2().longValue());
|
|
|
sql = " SELECT count(o.id) FROM base_life_care_order o WHERE o.status<>0 and o.status<>-1 and EXISTS ( " +
|
|
|
" select 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i," +
|
|
|
" base_service_package pack " +
|
|
|
" where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id " +
|
|
|
" and i.del = 1 and sr.`status`=1 and CONVERT(sr.patient USING utf8) = o.patient " +
|
|
|
" and CONVERT(sr.patient USING utf8) not in (SELECT dict_code FROM `base`.`wlyy_hospital_sys_dict` " +
|
|
|
" WHERE `dict_name` = 'jkzl_older' or dict_name='jkzl_child') and r.team_code='"+teamId+"' ) ";
|
|
|
count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
map.put("olderServiceCount",count);
|
|
|
sql = " select count(distinct pd.device_sn) from wlyy_patient_device pd INNER JOIN wlyy_devices dev on pd.device_sn = dev.device_code " +
|
|
|
" INNER JOIN base_patient p on pd.user = p.id and pd.del=0 and p.del=1 " +
|
|
|
" where 1=1 and EXISTS ( " +
|
|
|
" select 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i," +
|
|
|
" base_service_package pack " +
|
|
|
" where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id " +
|
|
|
" and i.del = 1 and sr.`status`=1 and CONVERT(sr.patient USING utf8) = p.id " +
|
|
|
" and CONVERT(sr.patient USING utf8) not in (SELECT dict_code FROM `base`.`wlyy_hospital_sys_dict` " +
|
|
|
" WHERE `dict_name` = 'jkzl_older' or dict_name='jkzl_child') and r.team_code='"+teamId+"' ) ";
|
|
|
count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
map.put("bindingDeviceCount",count);
|
|
|
}
|
|
|
return teamList;
|
|
|
}
|
|
|
}
|