|
@ -670,12 +670,22 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
if (StringUtils.isNotBlank(patient)){
|
|
if (StringUtils.isNotBlank(patient)){
|
|
sql.append( " and (ord.patient='"+patient+"' or ord.proxy_patient='"+patient+"' ) group by ord.status ");
|
|
sql.append( " and (ord.patient='"+patient+"' or ord.proxy_patient='"+patient+"' ) group by ord.status ");
|
|
}
|
|
}
|
|
else if (StringUtils.isNotBlank(doctor)) {
|
|
|
|
sql.append(" AND EXISTS (" +
|
|
|
|
"SELECT sr.patient from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," +
|
|
|
|
"base_team_member m " +
|
|
|
|
"where ord.patient = CONVERT(sr.patient USING utf8) and sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and m.team_code = r.team_code " +
|
|
|
|
" and i.del = 1 and sr.`status`=1 and i.code='emergencyAssistance' and m.doctor_code = '"+doctor+"' and m.del = '1') group by ord.status");
|
|
|
|
|
|
else if (StringUtils.isNotBlank(doctor)){
|
|
|
|
BaseDoctorDO doctorDO = doctorDao.findById(doctor);
|
|
|
|
if (null!=doctorDO){
|
|
|
|
if (2==doctorDO.getLevel()){//社工
|
|
|
|
sql.append(" AND EXISTS (" +
|
|
|
|
"SELECT sr.patient from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," +
|
|
|
|
"base_team_member m " +
|
|
|
|
"where ord.patient = CONVERT(sr.patient USING utf8) and sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and m.team_code = r.team_code " +
|
|
|
|
" and i.del = 1 and sr.`status`=1 and i.code='emergencyAssistance' and m.doctor_code = '"+doctor+"' and m.del = '1') group by ord.status");
|
|
|
|
}
|
|
|
|
if (4==doctorDO.getLevel()){//助老员
|
|
|
|
sql.append(" and EXISTS (" +
|
|
|
|
"SELECT 1 from base_patient_helper ph INNER JOIN base_patient p on ph.patient = p.id and p.del=1 " +
|
|
|
|
" where ord.patient = ph.patient and ph.doctor='"+doctor+"' and ph.del=1) group by ord.status ");
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql.toString());
|
|
List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql.toString());
|
|
for (Map<String,Object> map:sqlResult){
|
|
for (Map<String,Object> map:sqlResult){
|
|
@ -721,11 +731,21 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
public List<EmergencyAssistanceDO> getOrderList(String patient,String patientName,String doctor,String status,Integer page,Integer pageSize,String sort){
|
|
public List<EmergencyAssistanceDO> getOrderList(String patient,String patientName,String doctor,String status,Integer page,Integer pageSize,String sort){
|
|
StringBuilder sql = new StringBuilder(" select ord.* from base_emergency_assistance_order ord inner join base_patient pa on pa.id = ord.patient and pa.del=1 where 1=1 ");
|
|
StringBuilder sql = new StringBuilder(" select ord.* from base_emergency_assistance_order ord inner join base_patient pa on pa.id = ord.patient and pa.del=1 where 1=1 ");
|
|
if (StringUtils.isNotBlank(doctor)){
|
|
if (StringUtils.isNotBlank(doctor)){
|
|
sql.append(" AND EXISTS (" +
|
|
|
|
"SELECT sr.patient from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," +
|
|
|
|
"base_team_member m " +
|
|
|
|
"where ord.patient = CONVERT(sr.patient USING utf8) and sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and m.team_code = r.team_code " +
|
|
|
|
" and i.del = 1 and sr.`status`=1 and i.code='emergencyAssistance' and m.doctor_code = '"+doctor+"' and m.del = '1') ");
|
|
|
|
|
|
BaseDoctorDO doctorDO = doctorDao.findById(doctor);
|
|
|
|
if (null!=doctorDO){
|
|
|
|
if (2==doctorDO.getLevel()){//社工
|
|
|
|
sql.append(" AND EXISTS (" +
|
|
|
|
"SELECT sr.patient from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," +
|
|
|
|
"base_team_member m " +
|
|
|
|
"where ord.patient = CONVERT(sr.patient USING utf8) and sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and m.team_code = r.team_code " +
|
|
|
|
" and i.del = 1 and sr.`status`=1 and i.code='emergencyAssistance' and m.doctor_code = '"+doctor+"' and m.del = '1') ");
|
|
|
|
}
|
|
|
|
if (4==doctorDO.getLevel()){//助老员
|
|
|
|
sql.append(" and EXISTS (" +
|
|
|
|
"SELECT 1 from base_patient_helper ph INNER JOIN base_patient p on ph.patient = p.id and p.del=1 " +
|
|
|
|
" where ord.patient = ph.patient and ph.doctor='"+doctor+"' and ph.del=1) ");
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
if (StringUtils.isNotBlank(patient)){
|
|
if (StringUtils.isNotBlank(patient)){
|
|
sql.append(" and ( ord.patient = '"+patient+"' or ord.proxy_patient='"+patient+"' )");
|
|
sql.append(" and ( ord.patient = '"+patient+"' or ord.proxy_patient='"+patient+"' )");
|
|
@ -1206,4 +1226,143 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
|
|
return logDO;
|
|
return logDO;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/****************************************助老员部分*************************************************************************/
|
|
|
|
/**
|
|
|
|
* 查看居民救助历史记录
|
|
|
|
* @param patient
|
|
|
|
* @param doctor
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public List<Map<String,Object>> getEmeAndSecuOrderList(String orderType,String patient,String patientName,String doctor,String status,Integer page,Integer pageSize,String svrDesc){
|
|
|
|
page = page>0?page-1:0;
|
|
|
|
List<Map<String,Object>> result = new ArrayList<>();
|
|
|
|
String filter = " ";
|
|
|
|
if (StringUtils.isNotBlank(patient)){
|
|
|
|
filter += " and ord.patient ='"+patient+"' ";
|
|
|
|
}
|
|
|
|
if (StringUtils.isNotBlank(patientName)){
|
|
|
|
filter += " and ord.patient_name like'%"+patientName+"%' ";
|
|
|
|
|
|
|
|
}
|
|
|
|
if (StringUtils.isNotBlank(doctor)){
|
|
|
|
filter += " and EXISTS ( SELECT 1 from base_patient_helper ph INNER JOIN base_patient p on ph.patient = p.id " +
|
|
|
|
" and p.del=1 where ord.patient = ph.patient and ph.doctor='"+doctor+"' and ph.del=1) ";
|
|
|
|
}
|
|
|
|
if (StringUtils.isNotBlank(status)){
|
|
|
|
filter += " and ord.status ='"+status+"' ";
|
|
|
|
}
|
|
|
|
String sql = " ";
|
|
|
|
if (StringUtils.isNotBlank(orderType)){
|
|
|
|
List<String> orderTypes = Arrays.asList(orderType.split(",").clone());
|
|
|
|
if (orderTypes.contains("20")){
|
|
|
|
sql += "select '20' as OrderType,ord.id,ord.patient,ord.patient_name,ord.doctor,ord.status,ord.doctor_name," +
|
|
|
|
"'紧急呼叫' as serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time ,case p.sex when 1 then '男' when 2 then '女' else p.sex end as sex," +
|
|
|
|
" TIMESTAMPDIFF(YEAR,p.birthday,now()) as age " +
|
|
|
|
"from base_emergency_assistance_order ord INNER JOIN base_patient p on ord.patient = p.id where 1=1 " +filter;
|
|
|
|
}
|
|
|
|
if (orderTypes.contains("20")&&orderTypes.contains("22")){
|
|
|
|
sql += " UNION ";
|
|
|
|
}
|
|
|
|
if (orderTypes.contains("22")){
|
|
|
|
sql += " select '22' as 'OrderType',ord.id,ord.patient,ord.patient_name,ord.doctor,ord.status,ord.doctor_name," +
|
|
|
|
"ord.serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time ,case p.sex when 1 then '男' when 2 then '女' else p.sex end as sex, " +
|
|
|
|
"TIMESTAMPDIFF(YEAR,p.birthday,now()) as age from base_security_monitoring_order ord " +
|
|
|
|
" INNER JOIN base_patient p on ord.patient = p.id where 1=1 "+filter;
|
|
|
|
if(StringUtils.isNotBlank(svrDesc)){
|
|
|
|
sql += " and ord.service = '"+svrDesc+"' ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sql += "order by create_time desc limit "+page*pageSize+","+pageSize;
|
|
|
|
result = jdbcTemplate.queryForList(sql);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public JSONObject getEmeAndSecuOrderTab(String orderType,String doctor){
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
if ("20".equals(orderType)){
|
|
|
|
JSONObject tmpObj = new JSONObject();
|
|
|
|
tmpObj.put("status_-2",0);//误报警
|
|
|
|
tmpObj.put("status_-1",0);//已取消
|
|
|
|
tmpObj.put("status_0",0);//已完成
|
|
|
|
tmpObj.put("status_1",0);//预警中
|
|
|
|
String sql = " select ord.status,count(ord.id) count from base_emergency_assistance_order ord where 1=1" ;
|
|
|
|
if (StringUtils.isNotBlank(doctor)){
|
|
|
|
sql+= " and EXISTS (" +
|
|
|
|
"SELECT 1 from base_patient_helper ph INNER JOIN base_patient p on ph.patient = p.id and p.del=1 " +
|
|
|
|
" where ord.patient = ph.patient and ph.doctor='"+doctor+"' and ph.del=1) ";
|
|
|
|
}
|
|
|
|
List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql.toString());
|
|
|
|
for (Map<String,Object> map:sqlResult){
|
|
|
|
tmpObj.put("status_"+map.get("status"),map.get("count"));
|
|
|
|
}
|
|
|
|
Integer All = 0;
|
|
|
|
Set<String> keySet = tmpObj.keySet();
|
|
|
|
for (String key : keySet){
|
|
|
|
All+=tmpObj.getInteger(key);
|
|
|
|
}
|
|
|
|
tmpObj.put("all",All);
|
|
|
|
result.put(ResponseContant.resultFlag, ResponseContant.success);
|
|
|
|
result.put(ResponseContant.resultMsg,tmpObj);
|
|
|
|
}
|
|
|
|
else if("22".equals(orderType)){
|
|
|
|
result.put("status_-2", 0);//误报警
|
|
|
|
result.put("status_-1", 0);//已取消
|
|
|
|
result.put("status_0", 0);//已完成
|
|
|
|
result.put("status_1", 0);//预警中
|
|
|
|
result.put("status_all", 0);//
|
|
|
|
result.put("svr_all", 0);//
|
|
|
|
|
|
|
|
Map<String, String> serverTmp = new HashMap<>();
|
|
|
|
|
|
|
|
String sql = " select py_code,dict_value from wlyy_hospital_sys_dict where dict_name='security_server_dict' ";
|
|
|
|
List<Map<String, Object>> servers = jdbcTemplate.queryForList(sql);
|
|
|
|
for (Map<String, Object> server : servers) {
|
|
|
|
result.put("svr_" + server.get("py_code").toString(), 0);
|
|
|
|
serverTmp.put(server.get("dict_value").toString(), server.get("py_code").toString());
|
|
|
|
}
|
|
|
|
sql = "select ord.status,ord.serve_desc,count(ord.id) count from base_security_monitoring_order ord INNER JOIN base_patient p on p.id = ord.patient " +
|
|
|
|
"where 1=1 ";
|
|
|
|
String fliter = " ";
|
|
|
|
if (StringUtils.isNotBlank(doctor)) {
|
|
|
|
fliter+= " and EXISTS (" +
|
|
|
|
"SELECT 1 from base_patient_helper ph INNER JOIN base_patient p on ph.patient = p.id and p.del=1 " +
|
|
|
|
" where ord.patient = ph.patient and ph.doctor='"+doctor+"' and ph.del=1) ";
|
|
|
|
}
|
|
|
|
fliter += " group by ord.status,ord.serve_desc ";
|
|
|
|
List<Map<String, Object>> sqlResult = jdbcTemplate.queryForList(sql + fliter);
|
|
|
|
String pyCode = "";
|
|
|
|
for (Map<String, Object> map : sqlResult) {
|
|
|
|
result.put("status_" + map.get("status"), result.getInteger("status_" + map.get("status")) + Integer.parseInt(map.get("count").toString()));
|
|
|
|
pyCode = serverTmp.get(map.get("serve_desc")) == null ? null : serverTmp.get(map.get("serve_desc")).toString();
|
|
|
|
if (StringUtils.isNotBlank(pyCode)) {
|
|
|
|
result.put("svr_" + pyCode, result.getInteger("svr_" + pyCode) + Integer.parseInt(map.get("count").toString()));
|
|
|
|
result.put("status_all", result.getInteger("status_all") + Integer.parseInt(map.get("count").toString()));
|
|
|
|
result.put("svr_all", result.getInteger("svr_all") + Integer.parseInt(map.get("count").toString()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}else {
|
|
|
|
String sql = " select count(ord.id) from base_emergency_assistance_order ord where 1=1" ;
|
|
|
|
if (StringUtils.isNotBlank(doctor)){
|
|
|
|
sql+= " and EXISTS (" +
|
|
|
|
"SELECT 1 from base_patient_helper ph INNER JOIN base_patient p on ph.patient = p.id and p.del=1 " +
|
|
|
|
" where ord.patient = ph.patient and ph.doctor='"+doctor+"' and ph.del=1) ";
|
|
|
|
}
|
|
|
|
Long emeCount = jdbcTemplate.queryForObject(sql,Long.class);
|
|
|
|
result.put("emeAll",emeCount);
|
|
|
|
sql = "select count(ord.id) count from base_security_monitoring_order ord INNER JOIN base_patient p on p.id = ord.patient " +
|
|
|
|
"where 1=1 ";
|
|
|
|
String fliter = " ";
|
|
|
|
if (StringUtils.isNotBlank(doctor)) {
|
|
|
|
sql += " and EXISTS (" +
|
|
|
|
"SELECT 1 from base_patient_helper ph INNER JOIN base_patient p on ph.patient = p.id and p.del=1 " +
|
|
|
|
" where ord.patient = ph.patient and ph.doctor='"+doctor+"' and ph.del=1) ";
|
|
|
|
}
|
|
|
|
Long secuCount = jdbcTemplate.queryForObject(sql,Long.class);
|
|
|
|
result.put("secuAll",secuCount);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|