|
@ -89,12 +89,8 @@ public class RehabilitationManageService {
|
|
|
*/
|
|
|
public MixEnvelop<Map<String,Object>, Map<String,Object>> findRehabilitationPlan(Integer doctorType,String doctorCode, String diseaseCode, Integer planType,Integer todaybacklog, String patientCondition,Integer page, Integer pageSize) throws Exception{
|
|
|
|
|
|
// if(StringUtils.isNotEmpty(diseaseCode)){
|
|
|
// leftSql += " left join "+basedb+".wlyy_patient_disease_server s on p.patient=s.patient and s.del=1 and s.disease ='"+diseaseCode+"'" ;
|
|
|
// }
|
|
|
String leftSql = "";
|
|
|
|
|
|
String sql = " select p.*" + AesEncryptUtils.decryptMysql("p.name","patientName") + " from wlyy_specialist.wlyy_patient_rehabilitation_plan p " ;
|
|
|
String sql = " select p.* from wlyy_specialist.wlyy_patient_rehabilitation_plan p " ;
|
|
|
|
|
|
if(doctorType==2){//家医是根据签约关系过滤
|
|
|
leftSql =" join "+basedb+".wlyy_sign_family f on f.patient=p.patient and f.expenses_status='1' and f.status=1 ";
|
|
@ -113,6 +109,7 @@ public class RehabilitationManageService {
|
|
|
|
|
|
sql += " and " + AesEncryptUtils.decryptMysqlNo("p.name") + " like '%"+patientCondition+"%' ";
|
|
|
}
|
|
|
sql = TransforSqlUtl.wlyy_patient_rehabilitation_planAll2(sql);
|
|
|
String finalSql = "";
|
|
|
|
|
|
String todayStart = DateUtil.getStringDateShort()+" "+"00:00:00";
|
|
@ -124,16 +121,7 @@ public class RehabilitationManageService {
|
|
|
}
|
|
|
finalSql =" select DISTINCT b.* from (select plan_id,doctor from wlyy_specialist.wlyy_rehabilitation_plan_detail where 1=1 "+condition+") a " +
|
|
|
" JOIN ("+sql+") b on a.plan_id=b.id ";
|
|
|
// if(todaybacklog!=null&&todaybacklog==1){
|
|
|
// finalSql = " select DISTINCT b.* from (select DISTINCT plan_id from wlyy_specialist.wlyy_rehabilitation_plan_detail where execute_time>='"+todayStart+"' and execute_time<='"+todayEnd+"') a "+
|
|
|
// "LEFT JOIN ("+sql+") b on a.plan_id=b.id";
|
|
|
// }else{
|
|
|
// finalSql = " select b.* from ("+sql+") b ";
|
|
|
// }
|
|
|
if(doctorType==1){//专科医生是根据计划的创建者字段过滤
|
|
|
// sql+=" and (p.create_user in (select r.doctor assistant from " +
|
|
|
// " wlyy_specialist.wlyy_specialist_patient_relation r where r.health_assistant ='"+doctorCode+"') " +
|
|
|
// " or p.create_user='"+doctorCode+"') ";
|
|
|
finalSql += " where b.create_user = '"+doctorCode+"' or a.doctor ='"+doctorCode+"'";
|
|
|
}
|
|
|
List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(finalSql);
|
|
@ -374,6 +362,7 @@ public class RehabilitationManageService {
|
|
|
sql+= " and d.status="+status;
|
|
|
}
|
|
|
sql += " ORDER BY d.execute_time ";
|
|
|
sql = TransforSqlUtl.wlyy_rehabilitation_plan_detailAll2(sql);
|
|
|
List<Map<String,Object>> rehabilitationDetailList = jdbcTemplate.queryForList(sql);
|
|
|
// List<RehabilitationDetailDO> rehabilitationDetailList = rehabilitationDetailDao.findByPlanId(DateUtil.strToDate(executeStartTime),DateUtil.strToDate(executeEndTime),planId);
|
|
|
Map<String,Map<String,Object>> map = new LinkedHashMap<>();
|
|
@ -518,113 +507,11 @@ public class RehabilitationManageService {
|
|
|
sql+= "and d.status="+status;
|
|
|
}
|
|
|
sql +=" order by d.execute_time desc ";
|
|
|
sql = TransforSqlUtl.wlyy_rehabilitation_plan_detailAll(sql);
|
|
|
List<Map<String,Object>> rehabilitationDetailList = jdbcTemplate.queryForList(sql);
|
|
|
return ObjEnvelop.getSuccess(SpecialistMapping.api_success,rehabilitationDetailList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 多个康复计划服务项目内容列表
|
|
|
* @param planDetailIds
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
/* public ObjEnvelop serviceItemList(String planDetailIds,String doctorCode) throws Exception{
|
|
|
String[] s = planDetailIds.split(",");
|
|
|
String planDetailList = "";
|
|
|
for(String one:s){
|
|
|
planDetailList +=",'"+one+"'";
|
|
|
}
|
|
|
String planDetailResult = StringUtils.isNotEmpty(planDetailList)?planDetailList.substring(1):"";
|
|
|
String sql = "select i.title,i.content,i.type as itemType,i.reserve,d.id,d.execute_time,d.hospital_name,d.status,d.type as detailType,d.expense,d.doctor as executeDoctor," +
|
|
|
" d.doctor_name as executeDoctorName,p.patient ,p.create_user as createDoctor,p.create_user_name as createDoctorName, p.status as planStatus " +
|
|
|
" from wlyy_specialist.wlyy_rehabilitation_plan_detail d " +
|
|
|
" LEFT JOIN wlyy_specialist.wlyy_hospital_service_item h on d.hospital_service_item_id = h.id "+
|
|
|
" LEFT JOIN wlyy_specialist.wlyy_service_item i on i.id = h.service_item_id " +
|
|
|
" LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id " +
|
|
|
" where d.id in ("+planDetailResult+") order BY d.execute_time ASC ";
|
|
|
List<Map<String,Object>> serviceItemList = jdbcTemplate.queryForList(sql);
|
|
|
// if(serviceItemList.size()>0){
|
|
|
// Map<String,Object> serviceItem = serviceItemList.get(0);
|
|
|
List<Map<String,Object>> resultList = new ArrayList<>();
|
|
|
for(Map<String,Object> one:serviceItemList){
|
|
|
Map<String,Object> resultMap = new HashMap<>();
|
|
|
Integer isMyTask = 0;
|
|
|
if(StringUtils.isNotEmpty(doctorCode)&&doctorCode.equals(one.get("executeDoctor")+"")){
|
|
|
isMyTask=1;
|
|
|
}
|
|
|
resultMap.put("isMyTask",isMyTask);//0不是自己的任务,1是自己的任务
|
|
|
// if(!(one.get("specialistDoctor")+"").equals((one.get("create_user")+""))){
|
|
|
// executeDoctorList.add(one.get("create_user_name")+"");
|
|
|
// }
|
|
|
List<String> executeDoctorList = new ArrayList<>();
|
|
|
executeDoctorList.add(one.get("executeDoctorName")+"");
|
|
|
resultMap.put("executeDoctorList",executeDoctorList);//执行医生名称列表
|
|
|
resultMap.put("executeDoctorCode",one.get("executeDoctor")+"");//执行医生code
|
|
|
resultMap.put("executeDoctorName",one.get("executeDoctorName")+"");//执行医生code
|
|
|
resultMap.put("specialistDoctorCode",one.get("createDoctor")+"");//创建人(专科)医生code
|
|
|
resultMap.put("specialistDoctorName",one.get("createDoctorName")+"");//创建人(专科)医生名字
|
|
|
resultMap.put("title",one.get("title"));//项目标题
|
|
|
resultMap.put("planDetaiId",one.get("id"));//计划服务项目id
|
|
|
resultMap.put("shortExecuteTime",DateUtil.dateToStr((Date) one.get("execute_time"),DateUtil.HH_MM));//项目标题
|
|
|
resultMap.put("content",one.get("content"));//项目内容
|
|
|
resultMap.put("hospitalName",one.get("hospital_name"));//地点
|
|
|
resultMap.put("executeTime",one.get("execute_time"));//执行时间
|
|
|
DecimalFormat df = new DecimalFormat("0.00");
|
|
|
resultMap.put("expense",df.format(((Integer)one.get("expense")*1.00)/100.00));//收费
|
|
|
resultMap.put("reserve",one.get("reserve"));//是否需要预约(1预约、0不预约)
|
|
|
resultMap.put("planStatus",one.get("planStatus"));//计划的状态
|
|
|
Integer status = Integer.valueOf(one.get("status").toString());//状态(0未完成,1已完成,2已预约)
|
|
|
String statusName = "";
|
|
|
switch (status){
|
|
|
case 0:{statusName="未完成";break;}
|
|
|
case 1:{statusName="已完成";break;}
|
|
|
case 2:{statusName="已预约";break;}
|
|
|
}
|
|
|
resultMap.put("statusName",statusName);//状态
|
|
|
//指导与汇报
|
|
|
List<GuidanceMessageLogDO> messageList = guidanceMessageLogDao.findByPlanDetailId(one.get("id").toString());
|
|
|
List<Map<String,Object>> messageMapList = new ArrayList<>();
|
|
|
for(GuidanceMessageLogDO one2:messageList){
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
map.put("doctorName",one2.getDoctorName());
|
|
|
map.put("adminTeamName",one2.getAdminTeamName());
|
|
|
map.put("content",one2.getContent());
|
|
|
map.put("contentType",one2.getContentType());
|
|
|
map.put("createTime",DateUtil.dateToStr(one2.getCreateTime(),"MM-dd HH:mm"));
|
|
|
messageMapList.add(map);
|
|
|
}
|
|
|
Integer itemType = (Integer) one.get("itemType");
|
|
|
resultMap.put("messageList",messageMapList);//指导与汇报记录
|
|
|
resultMap.put("patient",one.get("patient"));
|
|
|
resultMap.put("itemType",itemType);
|
|
|
resultMap.put("detaiType",one.get("detaiType"));
|
|
|
resultMap.put("status",status);//状态
|
|
|
//是否完成任务
|
|
|
List<RehabilitationOperateRecordsDO> operateList = rehabilitationOperateRecordsDao.findByRehabilitationDetailId(one.get("id").toString());
|
|
|
Integer operate = 0;
|
|
|
if(operateList.size()>0){
|
|
|
operate =1;
|
|
|
RehabilitationOperateRecordsDO temp = operateList.get(0);
|
|
|
operate =1;
|
|
|
Date completeTime = temp.getCompleteTime();
|
|
|
String completeTimeStr = DateUtil.dateToStr(completeTime,DateUtil.YYYY_MM_DD_HH_MM);
|
|
|
resultMap.put("completeTime",completeTimeStr);//完成时间
|
|
|
resultMap.put("operatorDoctorName",temp.getDoctorName());//执行医生名称
|
|
|
resultMap.put("node",temp.getNode());
|
|
|
resultMap.put("relationRecordImg",(temp.getRelationRecordImg()!=null&&StringUtils.isNotEmpty(temp.getRelationRecordImg()))?(new JSONArray(temp.getRelationRecordImg())):null);//json格式
|
|
|
if(itemType!=1&&itemType!=0){
|
|
|
resultMap.put("relationRecordCode",temp.getRelationRecordCode());
|
|
|
resultMap.put("completeTimeShort",DateUtil.dateToStr(completeTime,"yyyy/MM/dd"));
|
|
|
}
|
|
|
}
|
|
|
resultMap.put("operate",operate);//是否完成任务(默认0:未完成,1:已完成)
|
|
|
resultList.add(resultMap);
|
|
|
}
|
|
|
return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultList);
|
|
|
// }
|
|
|
// return MixEnvelop.getError("没有该服务项详情信息!");
|
|
|
}*/
|
|
|
|
|
|
/**
|
|
|
* 多个康复计划服务项目内容列表
|
|
|
* @param planDetailIds
|
|
@ -644,6 +531,8 @@ public class RehabilitationManageService {
|
|
|
" LEFT JOIN wlyy_specialist.wlyy_rehabilitation_service_item i on i.code = d.hospital_service_item_id " +
|
|
|
" LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id " +
|
|
|
" where d.id in ("+planDetailResult+") order BY d.execute_time ASC ";
|
|
|
sql = TransforSqlUtl.wlyy_patient_rehabilitation_planCreateName(sql);
|
|
|
sql = TransforSqlUtl.wlyy_rehabilitation_plan_detailDoctorName(sql);
|
|
|
List<Map<String,Object>> serviceItemList = jdbcTemplate.queryForList(sql);
|
|
|
// if(serviceItemList.size()>0){
|
|
|
// Map<String,Object> serviceItem = serviceItemList.get(0);
|
|
@ -743,6 +632,10 @@ public class RehabilitationManageService {
|
|
|
" LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id " +
|
|
|
" LEFT JOIN wlyy_specialist.wlyy_plan_detail_appointment a on d.id=.a.rehabilitation_plan_detail_id " +
|
|
|
" where d.id = '"+planDetailId+"'";
|
|
|
sql = TransforSqlUtl.wlyy_patient_rehabilitation_planName(sql);
|
|
|
sql = TransforSqlUtl.wlyy_patient_rehabilitation_planCreateName(sql);
|
|
|
sql = TransforSqlUtl.wlyy_plan_detail_appointmentAll(sql);
|
|
|
sql = TransforSqlUtl.wlyy_rehabilitation_plan_detailDoctorName(sql);
|
|
|
List<Map<String,Object>> serviceItemList = jdbcTemplate.queryForList(sql);
|
|
|
if (serviceItemList.size()==0){
|
|
|
return ObjEnvelop.getSuccess(SpecialistMapping.api_success,new HashMap<>());
|
|
@ -912,6 +805,7 @@ public class RehabilitationManageService {
|
|
|
|
|
|
// String specialistRelationSql = "select * from wlyy_specialist.wlyy_specialist_patient_relation where patient='"+patientCode+"' and sign_status='1' and status >=0 ";
|
|
|
String specialistRelationSql = "select DISTINCT d.doctor,d.doctor_name from wlyy_specialist.wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where d.type=2 and p.patient='"+patientCode+"'";
|
|
|
specialistRelationSql = TransforSqlUtl.wlyy_rehabilitation_plan_detailDoctorName2(specialistRelationSql);
|
|
|
List<Map<String,Object>> specialistRelationList = jdbcTemplate.queryForList(specialistRelationSql);
|
|
|
for(Map<String,Object> one:specialistRelationList){
|
|
|
String doctor = one.get("doctor")+"";
|
|
@ -967,11 +861,7 @@ public class RehabilitationManageService {
|
|
|
//已完成
|
|
|
Integer allFinishCount = rehabilitationDetailDao.findByStatusAndPlanId(1,one.getId());
|
|
|
map.put("allFinishCount",allFinishCount);//已完成
|
|
|
// //未完成
|
|
|
// Integer notstartedCount = rehabilitationDetailDao.completenessCount(1,one.getId());//未开始
|
|
|
// Integer underwayCount = rehabilitationDetailDao.completenessCount(1,one.getId());//进行中
|
|
|
// Integer unfinishedCount = notstartedCount+underwayCount;
|
|
|
// map.put("unfinishedCount",unfinishedCount);//未完成
|
|
|
|
|
|
//完成度(已完成/(已完成+未完成))
|
|
|
Integer allCount = rehabilitationDetailDao.findAllByPlanId(one.getId());
|
|
|
map.put("allCount",allCount);//总数
|
|
@ -992,51 +882,6 @@ public class RehabilitationManageService {
|
|
|
//康复计划-已完成、进行中
|
|
|
resultMap.put("planUnderway",planUnderway);//进行中
|
|
|
resultMap.put("planFinish",planFinish);//已完成
|
|
|
|
|
|
// //近期康复相关记录
|
|
|
//// String currentTime = DateUtil.getStringDate();
|
|
|
// String planDetailSql = " select d.*,i.content,i.title from wlyy_specialist.wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_hospital_service_item h on d.hospital_service_item_id=h.id" +
|
|
|
// " LEFT JOIN wlyy_service_item i on i.id=h.service_item_id LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where p.patient='"+patientCode+"' and d.executeTime<='"+currentTime+"' order by executeTime desc";
|
|
|
// List<Map<String,Object>> planDetails = jdbcTemplate.queryForList(planDetailSql);
|
|
|
// List<Map<String,Object>> planDetailList = new ArrayList<>();
|
|
|
// for(Map<String,Object> one:planDetails){
|
|
|
// Date executeTimeDate = (Date)one.get("execute_time");
|
|
|
// String executeTime = DateUtil.dateToStr(executeTimeDate,"yyyy/MM/dd HH:mm");
|
|
|
// String content = one.get("content").toString();
|
|
|
// String title = one.get("title").toString();
|
|
|
// Integer status = (Integer)one.get("status");
|
|
|
// String statusName = "";
|
|
|
// switch (status){
|
|
|
// case 0:{statusName="未完成";break;}
|
|
|
// case 1:{statusName="已完成";break;}
|
|
|
// case 2:{statusName="已预约";break;}
|
|
|
// }
|
|
|
// String id = one.get("id").toString();
|
|
|
// Map<String,Object> map = new HashMap<>();
|
|
|
// map.put("id",id);//id
|
|
|
// map.put("executeTime",executeTime);//执行时间
|
|
|
// map.put("title",title);//项目标题
|
|
|
// map.put("content",content);//项目内容
|
|
|
// map.put("statusName",statusName);//状态名称
|
|
|
// planDetailList.add(map);
|
|
|
// }
|
|
|
// resultMap.put("planDetailList",planDetailList);//康复相关记录列表
|
|
|
// String planDetailCountSql = " select d.status as num from wlyy_specialist.wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_hospital_service_item h on d.hospital_service_item_id=h.id" +
|
|
|
// " LEFT JOIN wlyy_service_item i on i.id=h.service_item_id LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where p.patient='"+patientCode+"'";
|
|
|
// List<Map<String,Object>> planDetailList2 = jdbcTemplate.queryForList(planDetailCountSql);
|
|
|
// Integer planDetailFinish = 0;
|
|
|
// Integer planDetailUnfinish = 0;
|
|
|
// for(Map<String,Object> one:planDetailList2){
|
|
|
//
|
|
|
// Integer status = (Integer)one.get("status");
|
|
|
// if(status==1){
|
|
|
// planDetailFinish+=1;
|
|
|
// }else{
|
|
|
// planDetailUnfinish+=1;
|
|
|
// }
|
|
|
// }
|
|
|
// resultMap.put("planDetailFinish",planDetailFinish);//已完成
|
|
|
// resultMap.put("planDetailUnfinish",planDetailUnfinish);//未完成
|
|
|
return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultMap);
|
|
|
}
|
|
|
|
|
@ -1061,12 +906,8 @@ public class RehabilitationManageService {
|
|
|
planDetailSql += " and d.execute_time<='"+endTime+"' ";
|
|
|
}
|
|
|
|
|
|
// List<Map<String,Object>> planDetailsCount = jdbcTemplate.queryForList(planDetailSql);
|
|
|
// int count = 0;
|
|
|
// if(planDetailsCount!=null&&planDetailsCount.size()>0){
|
|
|
// count = planDetailsCount.size();
|
|
|
// }
|
|
|
planDetailSql += " ORDER BY s.complete_time DESC LIMIT "+(page-1)*pageSize+","+pageSize;
|
|
|
planDetailSql = TransforSqlUtl.wlyy_rehabilitation_plan_detailAll2(planDetailSql);
|
|
|
List<Map<String,Object>> planDetails = jdbcTemplate.queryForList(planDetailSql);
|
|
|
List<Map<String,Object>> planDetailList = new ArrayList<>();
|
|
|
for(Map<String,Object> one:planDetails){
|
|
@ -1215,6 +1056,7 @@ public class RehabilitationManageService {
|
|
|
|
|
|
// String specialistRelationSql = "select * from wlyy_specialist.wlyy_specialist_patient_relation where patient='"+patientCode+"' and sign_status='1' and status='1'";
|
|
|
String specialistRelationSql = "select DISTINCT d.doctor,d.doctor_name from wlyy_specialist.wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_specialist.wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where d.type=2 AND d.doctor IS NOT NULL and d.doctor <> '' and p.patient='"+patientCode+"'";
|
|
|
specialistRelationSql = TransforSqlUtl.wlyy_rehabilitation_plan_detailDoctorName2(specialistRelationSql);
|
|
|
List<Map<String,Object>> specialistRelationList = jdbcTemplate.queryForList(specialistRelationSql);
|
|
|
for(Map<String,Object> one:specialistRelationList){
|
|
|
String doctor = one.get("doctor")+"";
|
|
@ -1363,6 +1205,7 @@ public class RehabilitationManageService {
|
|
|
}
|
|
|
//如果整个计划的服务项都完成了,整个计划也完成了
|
|
|
String allSql ="SELECT * FROM wlyy_rehabilitation_plan_detail where plan_id = (SELECT plan_id FROM `wlyy_rehabilitation_plan_detail` WHERE id='"+planDeatilId+"')";
|
|
|
allSql = TransforSqlUtl.wlyy_rehabilitation_plan_detailAll(allSql);
|
|
|
List<RehabilitationDetailDO> rehabilitationDetailDOList = jdbcTemplate.query(allSql,new BeanPropertyRowMapper<>(RehabilitationDetailDO.class));
|
|
|
int allCount=0;
|
|
|
String planId="";
|
|
@ -1569,6 +1412,7 @@ public class RehabilitationManageService {
|
|
|
}
|
|
|
buffer.deleteCharAt(buffer.length()-1);
|
|
|
String sql = "select * from wlyy_rehabilitation_plan_detail where id in("+buffer+")";
|
|
|
sql = TransforSqlUtl.wlyy_rehabilitation_plan_detailAll(sql);
|
|
|
List<RehabilitationDetailDO> rehabilitationDetailDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(RehabilitationDetailDO.class));
|
|
|
envelop.setObj(rehabilitationDetailDOS);
|
|
|
return envelop;
|
|
@ -1578,7 +1422,7 @@ public class RehabilitationManageService {
|
|
|
Map<String,Object> reslutMap = new HashMap<>();
|
|
|
String sql ="SELECT" +
|
|
|
" p.patient," +
|
|
|
" p.`name`," +
|
|
|
" p.name," +
|
|
|
" p.title," +
|
|
|
" p.disease_name,p.abort_reason,p.abort_time,p.create_time,p.patient_img," +
|
|
|
" a.*" +
|
|
@ -1606,6 +1450,8 @@ public class RehabilitationManageService {
|
|
|
" ) a ON p.id = a.plan_id" +
|
|
|
" WHERE" +
|
|
|
" p.id = '"+planId+"'";
|
|
|
sql = TransforSqlUtl.wlyy_patient_rehabilitation_planName(sql);
|
|
|
sql = TransforSqlUtl.wlyy_rehabilitation_operate_recordsDoctorName(sql);
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
Integer allCount = rehabilitationDetailDao.findAllByPlanId(planId);//计划总服务项目数
|
|
|
Integer finishCount = list.size();//完成服务项目数
|