|
@ -2,34 +2,38 @@ package com.yihu.rehabilitation.service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
import com.yihu.fastdfs.FastDFSUtil;
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorRoleDao;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.door.SignFamily;
|
|
|
import com.yihu.jw.entity.hospital.doctor.Frequency;
|
|
|
import com.yihu.jw.entity.patient.Message;
|
|
|
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
|
|
|
import com.yihu.jw.entity.patient.Patient;
|
|
|
import com.yihu.jw.entity.specialist.DoctorPatientRelationDO;
|
|
|
import com.yihu.jw.entity.specialist.SpecialistPatientRelationDO;
|
|
|
import com.yihu.jw.entity.specialist.rehabilitation.*;
|
|
|
import com.yihu.jw.entity.util.TransforSqlUtl;
|
|
|
import com.yihu.jw.im.util.ImUtil;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.rehabilitation.GuidanceMessageLogDao;
|
|
|
import com.yihu.jw.rehabilitation.RehabilitationDetailAppointmentDao;
|
|
|
import com.yihu.jw.rehabilitation.RehabilitationOperateRecordsDao;
|
|
|
import com.yihu.jw.rehabilitation.SpecialistPatientRelationDao;
|
|
|
import com.yihu.jw.rehabilitation.*;
|
|
|
import com.yihu.jw.restmodel.web.Envelop;
|
|
|
import com.yihu.jw.restmodel.web.MixEnvelop;
|
|
|
import com.yihu.jw.restmodel.web.ObjEnvelop;
|
|
|
import com.yihu.jw.rm.base.BaseRequestMapping;
|
|
|
import com.yihu.jw.rm.specialist.SpecialistMapping;
|
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
|
import com.yihu.jw.util.common.QrcodeUtil;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.rehabilitation.dao.FrequencyDao;
|
|
|
import com.yihu.rehabilitation.dao.PatientRehabilitationPlanDao;
|
|
|
import com.yihu.rehabilitation.dao.RehabilitationDetailDao;
|
|
|
import com.yihu.rehabilitation.dao.SignFamilyDao;
|
|
|
import com.yihu.jw.utils.hibernate.HibenateUtils;
|
|
|
import com.yihu.rehabilitation.dao.*;
|
|
|
import com.yihu.rehabilitation.util.HtmlUtil;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.json.JSONArray;
|
|
@ -38,8 +42,11 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.io.InputStream;
|
|
|
import java.sql.Timestamp;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
@ -51,8 +58,6 @@ import java.util.*;
|
|
|
@Transactional
|
|
|
public class RehabilitationManageService {
|
|
|
|
|
|
@Value("${basedb.name}")
|
|
|
private String basedb;
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
@Autowired
|
|
@ -79,7 +84,34 @@ public class RehabilitationManageService {
|
|
|
private SpecialistEvaluateSevice specialistEvaluateSevice;
|
|
|
@Autowired
|
|
|
private FrequencyDao frequencyDao;
|
|
|
|
|
|
@Autowired
|
|
|
private ImUtil imUtil;
|
|
|
@Autowired
|
|
|
private PatientMedicalRecordsRehabilitationDao medicalRecordsRehabilitationDao;
|
|
|
@Autowired
|
|
|
private BaseDoctorHospitalDao baseDoctorHospitalDao;
|
|
|
@Autowired
|
|
|
private HibenateUtils hibenateUtils;
|
|
|
@Autowired
|
|
|
private DoctorPatientRelationDao doctorPatientRelationDao;
|
|
|
@Autowired
|
|
|
private FastDFSUtil fastDFSUtil;
|
|
|
@Autowired
|
|
|
private PatientMedicalRecordsRehabilitationDao patientMedicalRecordsDao;
|
|
|
@Value("${im.data_base_name}")
|
|
|
private String imDBName;
|
|
|
@Value("${neiwang.enable}")
|
|
|
private Boolean isneiwang; //如果不是内网项目要转到到内网wlyy在上传
|
|
|
@Autowired
|
|
|
private ZsRehabilitationInfoService zsRehabilitationInfoService;
|
|
|
@Autowired
|
|
|
private PatientRecordService patientRecordService;
|
|
|
@Autowired
|
|
|
private RehabilitationInfoService rehabilitationInfoService;
|
|
|
@Autowired
|
|
|
private ObjectMapper objectMapper;
|
|
|
@Value("${demo.flag}")
|
|
|
private Boolean demoFlag;
|
|
|
/**
|
|
|
* 预约协诊
|
|
|
* @param doctor
|
|
@ -163,6 +195,7 @@ public class RehabilitationManageService {
|
|
|
count = rstotal.size();
|
|
|
}
|
|
|
sql += " ORDER BY p.create_time DESC LIMIT "+(page-1)*pageSize+","+pageSize;
|
|
|
System.out.println("sql==="+sql);
|
|
|
List<Map<String,Object>> patientRehabilitationPlanDOList = jdbcTemplate.queryForList(sql);
|
|
|
List<Map<String,Object>> resultList = new ArrayList<>();
|
|
|
BasePatientDO patient =null;
|
|
@ -194,7 +227,7 @@ public class RehabilitationManageService {
|
|
|
resultMap.put("id",one.get("id"));
|
|
|
resultMap.put("status",one.get("status"));//康复计划状态
|
|
|
//健康情况
|
|
|
String healthyConditionSql =" select label_name,label from "+basedb+".wlyy_sign_patient_label_info where status=1 and patient='"+one.get("patient")+"' and label_type=8";
|
|
|
String healthyConditionSql =" select label_name,label from wlyy_sign_patient_label_info where status=1 and patient='"+one.get("patient")+"' and label_type=8";
|
|
|
List<Map<String,Object>> healthyConditionList = jdbcTemplate.queryForList(healthyConditionSql);
|
|
|
String healthyCondition = healthyConditionList.size()>0?healthyConditionList.get(0).get("label_name")+"":"";
|
|
|
String healthyConditionType = healthyConditionList.size()>0?healthyConditionList.get(0).get("label")+"":"";
|
|
@ -248,8 +281,8 @@ public class RehabilitationManageService {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public ObjEnvelop findRehabilitationPlanDetailList(String currentDoctorCode,String patientCode) throws Exception{
|
|
|
String sql = " select DISTINCT r.* from wlyy_specialist_patient_relation r join wlyy_patient_rehabilitation_plan p on r.patient=p.patient where r.sign_status ='1' and r.status in('0','1') and r.patient='"+patientCode+"' ";
|
|
|
sql = TransforSqlUtl.specialistPatientRelationAll2(sql);
|
|
|
String sql = " select DISTINCT r.* from wlyy_doctor_patient_relation r join wlyy_patient_rehabilitation_plan p on r.patient=p.patient where r.status in('0','1') and r.patient='"+patientCode+"' ";
|
|
|
//sql = TransforSqlUtl.specialistPatientRelationAll2(sql);
|
|
|
List<Map<String,Object>> specialistPatientRelationList = jdbcTemplate.queryForList(sql);
|
|
|
List<Map<String,Object>> resultList = new ArrayList<>();
|
|
|
for(Map<String,Object> temp: specialistPatientRelationList){
|
|
@ -257,14 +290,14 @@ public class RehabilitationManageService {
|
|
|
Map<String,Object> resultMap = new HashMap<>();
|
|
|
Integer isOperator = 0;
|
|
|
resultMap.put("patientCode",patientCode);//居民code
|
|
|
String healthyConditionSql =" select label_name,label from "+basedb+".wlyy_sign_patient_label_info where status=1 and patient='"+patientCode+"' and label_type=8";
|
|
|
String healthyConditionSql =" select label_name,label from wlyy_sign_patient_label_info where status=1 and patient='"+patientCode+"' and label_type=8";
|
|
|
List<Map<String,Object>> healthyConditionList = jdbcTemplate.queryForList(healthyConditionSql);
|
|
|
String healthyCondition = healthyConditionList.size()>0?healthyConditionList.get(0).get("label_name")+"":"";
|
|
|
String healthyConditionType = healthyConditionList.size()>0?healthyConditionList.get(0).get("label")+"":"";
|
|
|
resultMap.put("healthyCondition",healthyCondition);
|
|
|
resultMap.put("healthyConditionType",healthyConditionType);
|
|
|
//专科医生
|
|
|
String specialistRelationSql = "select r.*,t.name as teamName,h.name as specialistHospitalName from wlyy_specialist_patient_relation r left join "+basedb+".wlyy_admin_team t on r.team_code=t.id left join "+basedb+".dm_hospital h on t.org_code=h.code where r.sign_status ='1' and r.status in('0','1') and r.patient='"+patientCode+"' and r.doctor='"+doctorCode+"'";
|
|
|
String specialistRelationSql = "select r.*,t.name as teamName,h.name as specialistHospitalName from wlyy_doctor_patient_relation r left join base_team t on r.team_code=t.id left join base_org h on t.org_code=h.code where r.status in('0','1') and r.patient='"+patientCode+"' and r.doctor='"+doctorCode+"'";
|
|
|
specialistRelationSql = TransforSqlUtl.specialistPatientRelationAll2(specialistRelationSql);
|
|
|
List<Map<String,Object>> specialistRelationList = jdbcTemplate.queryForList(specialistRelationSql);
|
|
|
Map<String,Object> specialistMap = specialistRelationList.get(0);
|
|
@ -275,14 +308,14 @@ public class RehabilitationManageService {
|
|
|
Integer specialistFinishCount1 = rehabilitationDetailDao.findItemByDoctor(doctorCode,patientCode);
|
|
|
Integer specialistServiceCount1 = rehabilitationDetailDao.completeServiceByDoctor(doctorCode,patientCode,1);
|
|
|
|
|
|
Integer specialistUnfinishCount2 = rehabilitationDetailDao.unfinishItemByDoctor(specialistMap.get("health_assistant")+"",patientCode,1);
|
|
|
/*Integer specialistUnfinishCount2 = rehabilitationDetailDao.unfinishItemByDoctor(specialistMap.get("health_assistant")+"",patientCode,1);
|
|
|
Integer specialistFinishCount2 = rehabilitationDetailDao.findItemByDoctor(specialistMap.get("health_assistant")+"",patientCode);
|
|
|
Integer specialistServiceCount2 = rehabilitationDetailDao.completeServiceByDoctor(specialistMap.get("health_assistant")+"",patientCode,1);
|
|
|
Integer specialistServiceCount2 = rehabilitationDetailDao.completeServiceByDoctor(specialistMap.get("health_assistant")+"",patientCode,1);*/
|
|
|
|
|
|
resultMap.put("specialistFinishItemCount",specialistFinishCount1-specialistUnfinishCount1+specialistFinishCount2-specialistUnfinishCount2);//完成项目
|
|
|
resultMap.put("specialistServiceRecordCount",specialistServiceCount1+specialistServiceCount2);//服务次数
|
|
|
resultMap.put("specialistFinishItemCount",specialistFinishCount1-specialistUnfinishCount1);//完成项目
|
|
|
resultMap.put("specialistServiceRecordCount",specialistServiceCount1);//服务次数
|
|
|
//家庭医生(包括全科医生、健管师)
|
|
|
String signFamilySql = "SELECT f.*,t.name as teamName FROM "+basedb+".wlyy_sign_family f LEFT JOIN "+basedb+".wlyy_admin_team t on f.admin_team_code=t.id where f.status =1 and f.expenses_status='1' and f.patient='"+patientCode+"'";
|
|
|
String signFamilySql = "SELECT f.*,t.name as teamName FROM wlyy_sign_family f LEFT JOIN wlyy_admin_team t on f.admin_team_code=t.id where f.status =1 and f.expenses_status='1' and f.patient='"+patientCode+"'";
|
|
|
List<Map<String,Object>> signFamilyList = jdbcTemplate.queryForList(signFamilySql);
|
|
|
if(signFamilyList != null && signFamilyList.size() >0 ) {
|
|
|
Map<String, Object> signFamilyMap = signFamilyList.get(0);
|
|
@ -312,14 +345,14 @@ public class RehabilitationManageService {
|
|
|
resultMap.put("sex", "1".equals(sex) ? "男" : ("2".equals(sex) ? "女" : "未知"));
|
|
|
resultMap.put("patientName", signFamilyMap.get("patientName"));
|
|
|
}
|
|
|
//疾病类型
|
|
|
String diseaseSql = " select s.* from "+basedb+".wlyy_patient_disease_server s where s.del=1 and s.patient='"+patientCode+"' and s.specialist_relation_code='"+specialistMap.get("id")+"' ";
|
|
|
/* //疾病类型
|
|
|
String diseaseSql = " select s.* from wlyy_patient_disease_server s where s.del=1 and s.patient='"+patientCode+"' and s.specialist_relation_code='"+specialistMap.get("id")+"' ";
|
|
|
List<Map<String,Object>> diseaseList = jdbcTemplate.queryForList(diseaseSql);
|
|
|
List<String> disease = new ArrayList<>();
|
|
|
for(Map<String,Object> one2:diseaseList){
|
|
|
disease.add(one2.get("disease_name")+"");
|
|
|
}
|
|
|
resultMap.put("diseaseList",disease);
|
|
|
resultMap.put("diseaseList",disease);*/
|
|
|
|
|
|
//计划列表
|
|
|
List<PatientRehabilitationPlanDO> list = patientRehabilitationPlanDao.findByPatientAndCreateUser(patientCode,doctorCode);
|
|
@ -373,7 +406,149 @@ public class RehabilitationManageService {
|
|
|
return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 日历
|
|
|
* @param searchTask 快速查找任务(1、我的任务,2、随访,3、复诊,4、健康教育)
|
|
|
* @param status 任务状态(0未完成,1已完成,2已预约)
|
|
|
* @param doctorCode 登陆医生
|
|
|
* @param taskExecutor 任务执行者 0全部;1我的任务 2他人任务
|
|
|
*/
|
|
|
public ObjEnvelop calendarPlanDetailByPatient(String executeStartTime,String executeEndTime,String patient,Integer searchTask,Integer status,String doctorCode,String taskExecutor) throws Exception{
|
|
|
List<Map<String,Object>> planList = getPatientAllRehabilitationPlan(patient);
|
|
|
StringBuilder planCondition = new StringBuilder();
|
|
|
planCondition .append("'"+planList.get(0).get("id").toString()+"'");
|
|
|
for (int i=1;i<planList.size();i++){
|
|
|
planCondition .append(",'"+planList.get(0).get("id").toString()+"'");
|
|
|
}
|
|
|
String sql = " select d.* from wlyy_rehabilitation_plan_detail d " +
|
|
|
" LEFT JOIN wlyy_rehabilitation_service_item i on i.code = d.hospital_service_item_id " +
|
|
|
" where d.plan_id in ("+planCondition+") " +
|
|
|
"" ;
|
|
|
if(StringUtils.isNotBlank(executeStartTime)){
|
|
|
sql += " and d.execute_time>='"+executeStartTime+"' ";
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(executeEndTime)){
|
|
|
sql += " and d.execute_time<='"+executeEndTime+"' ";
|
|
|
}
|
|
|
if(searchTask!=null){
|
|
|
if(searchTask==8){
|
|
|
sql+=" and d.doctor='"+doctorCode+"' " ;
|
|
|
}else {
|
|
|
sql+=" and i.code="+searchTask+" " ;
|
|
|
}
|
|
|
}
|
|
|
if(taskExecutor.equals("1")){ //我的任务
|
|
|
sql+="and d.doctor='"+doctorCode+"' ";
|
|
|
}
|
|
|
if(taskExecutor.equals("2")){//他人任务
|
|
|
sql+="and d.doctor <>'"+doctorCode+"' ";
|
|
|
}
|
|
|
if(status!=null){
|
|
|
sql+= " and d.status="+status;
|
|
|
}
|
|
|
sql += " ORDER BY d.execute_time ";
|
|
|
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<>();
|
|
|
for(Map<String,Object> one:rehabilitationDetailList){
|
|
|
String executeTime = DateUtil.dateToStr((Date) one.get("execute_time"),DateUtil.YYYY_MM_DD);
|
|
|
Map<String,Object> m = null;
|
|
|
if(map.containsKey(executeTime)){
|
|
|
m = map.get(executeTime);
|
|
|
Map<String,Integer> family = null;
|
|
|
Map<String,Integer> specialist = null;
|
|
|
if(one.get("type")!=null){
|
|
|
if((Integer)one.get("type")==1){//家庭医生
|
|
|
if(m.containsKey("family")){
|
|
|
family = (Map<String,Integer>)m.get("family");
|
|
|
}else{
|
|
|
family = new HashMap<>();
|
|
|
family.put("all",0);
|
|
|
family.put("finish",0);
|
|
|
}
|
|
|
if((Integer)one.get("status")==1){
|
|
|
family.put("finish",family.get("finish")+1);
|
|
|
}
|
|
|
family.put("all",family.get("all")+1);
|
|
|
m.put("family",family);
|
|
|
}else if((Integer)one.get("type")==2){//专科医生
|
|
|
|
|
|
if(m.containsKey("specialist")){
|
|
|
|
|
|
specialist = (Map<String,Integer>)m.get("specialist");
|
|
|
}else{
|
|
|
specialist = new HashMap<>();
|
|
|
specialist.put("all",0);
|
|
|
specialist.put("finish",0);
|
|
|
}
|
|
|
if((Integer)one.get("status")==1){
|
|
|
specialist.put("finish",(specialist.get("finish"))+1);
|
|
|
}
|
|
|
specialist.put("all",(specialist.get("all"))+1);
|
|
|
m.put("specialist",specialist);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
m = new HashMap<>();
|
|
|
// m.put("specialist",new HashMap<String,Object>());
|
|
|
if(one.get("type")!=null){
|
|
|
if((Integer)one.get("type")==1){//家庭医生
|
|
|
Map<String,Integer> family = new HashMap<>();
|
|
|
family.put("all",0);
|
|
|
family.put("finish",0);
|
|
|
if((Integer)one.get("status")==1){
|
|
|
family.put("finish",family.get("finish")+1);
|
|
|
}
|
|
|
family.put("all",family.get("all")+1);
|
|
|
m.put("family",family);
|
|
|
}else if((Integer)one.get("type")==2){//专科医生
|
|
|
Map<String,Integer> specialist = new HashMap<>();
|
|
|
specialist.put("all",0);
|
|
|
specialist.put("finish",0);
|
|
|
if((Integer)one.get("status")==1){
|
|
|
specialist.put("finish",specialist.get("finish")+1);
|
|
|
}
|
|
|
specialist.put("all",specialist.get("all")+1);
|
|
|
m.put("specialist",specialist);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
//myTaskFlag,1:有自己任务,0:没有自己任务
|
|
|
if(StringUtils.isNotEmpty(doctorCode)){
|
|
|
|
|
|
if(m.containsKey("myTaskFlag")){
|
|
|
if((Integer)m.get("myTaskFlag")==0){
|
|
|
if(doctorCode.equals(one.get("doctor").toString())){
|
|
|
m.put("myTaskFlag",1);
|
|
|
}else{
|
|
|
m.put("myTaskFlag",0);
|
|
|
}
|
|
|
}
|
|
|
}else{
|
|
|
if(doctorCode.equals(one.get("doctor").toString())){
|
|
|
m.put("myTaskFlag",1);
|
|
|
}else{
|
|
|
m.put("myTaskFlag",0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if(m.containsKey("planDetailIds")){
|
|
|
m.put("planDetailIds",m.get("planDetailIds")+","+one.get("id"));
|
|
|
}else{
|
|
|
m.put("planDetailIds",one.get("id")+"");
|
|
|
}
|
|
|
map.put(executeTime,m);
|
|
|
}
|
|
|
/*List list = new ArrayList();
|
|
|
for(String key : map.keySet()){
|
|
|
Map<String,Object> result = map.get(key);
|
|
|
result.put("executeTime", key);
|
|
|
list.add(result);
|
|
|
}*/
|
|
|
return ObjEnvelop.getSuccess(SpecialistMapping.api_success,map);
|
|
|
}
|
|
|
/**
|
|
|
* 日历
|
|
|
* @param planId 计划id
|
|
@ -390,8 +565,9 @@ public class RehabilitationManageService {
|
|
|
planCondition .append(",'"+planIdlist[i]+"'");
|
|
|
}
|
|
|
String sql = " select d.* from wlyy_rehabilitation_plan_detail d " +
|
|
|
" LEFT JOIN base_service_package_item i on i.id = d.hospital_service_item_id " +
|
|
|
" where d.plan_id in ("+planCondition+") and i.service_package_id='system' " ;
|
|
|
" LEFT JOIN wlyy_rehabilitation_service_item i on i.code = d.hospital_service_item_id " +
|
|
|
" where d.plan_id in ("+planCondition+") " +
|
|
|
" " ;
|
|
|
if(StringUtils.isNotBlank(executeStartTime)){
|
|
|
sql += " and d.execute_time>='"+executeStartTime+"' ";
|
|
|
}
|
|
@ -415,7 +591,6 @@ 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<>();
|
|
@ -536,8 +711,52 @@ public class RehabilitationManageService {
|
|
|
planCondition .append(",'"+planIdlist[i]+"'");
|
|
|
}
|
|
|
String sql = " select d.*,DATE_FORMAT(d.execute_time,'%Y/%m/%d %H:%i') as executeTime ,i.code,i.name from wlyy_rehabilitation_plan_detail d " +
|
|
|
" LEFT JOIN base_service_package_item i on i.id = d.hospital_service_item_id " +
|
|
|
" where d.plan_id in ("+planCondition+" )AND d.execute_time IS NOT NULL and i.service_package_id ='system' and d.execute_time <>'' " ;
|
|
|
" LEFT JOIN wlyy_rehabilitation_service_item i on i.code = d.hospital_service_item_id " +
|
|
|
" where d.plan_id in ("+planCondition+" )AND d.execute_time IS NOT NULL " +
|
|
|
" and d.execute_time <>'' " ;
|
|
|
if(searchTask!=null){
|
|
|
if(searchTask==8){//
|
|
|
sql+="and d.doctor='"+doctorCode+"' ";
|
|
|
}else {
|
|
|
sql+=" and i.code="+searchTask+" " ;
|
|
|
}/*else if(searchTask==5){
|
|
|
sql+=" and i.reserve=1 " ;
|
|
|
}*/
|
|
|
}
|
|
|
if("1".equals(taskExecutor)){ //我的任务
|
|
|
sql+="and d.doctor='"+doctorCode+"' ";
|
|
|
}
|
|
|
if("2".equals(taskExecutor)){//他人任务
|
|
|
sql+="and d.doctor <>'"+doctorCode+"' ";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(executeEndTime)&&StringUtils.isNoneBlank(executeStartTime)){
|
|
|
sql+="and d.execute_time>='"+executeStartTime+"' and d.execute_time<='"+executeEndTime+"' ";
|
|
|
}
|
|
|
if(status!=null){
|
|
|
sql+= "and d.status="+status;
|
|
|
}
|
|
|
sql +=" order by d.execute_time desc ";
|
|
|
sql = TransforSqlUtl.wlyy_rehabilitation_plan_detailAll2(sql);
|
|
|
List<Map<String,Object>> rehabilitationDetailList = jdbcTemplate.queryForList(sql);
|
|
|
return ObjEnvelop.getSuccess(SpecialistMapping.api_success,rehabilitationDetailList);
|
|
|
}
|
|
|
/**
|
|
|
* 日历列表
|
|
|
* @param searchTask 快速查找任务(1、我的任务,2、随访,3、复诊,4、健康教育)
|
|
|
* @param status 任务状态(0未完成,1已完成,2已预约)
|
|
|
* @param doctorCode 登陆医生
|
|
|
* @param taskExecutor 任务执行者 0全部;1我的任务 2他人任务
|
|
|
*/
|
|
|
public ObjEnvelop calendarPlanDetailListByPatient(String executeStartTime,String executeEndTime,String patient,Integer searchTask,Integer status,String doctorCode,String taskExecutor){
|
|
|
List<Map<String,Object>> planList = getPatientAllRehabilitationPlan(patient);
|
|
|
StringBuilder planCondition = new StringBuilder();
|
|
|
planCondition .append("'"+planList.get(0).get("id").toString()+"'");
|
|
|
for (int i=1;i<planList.size();i++){
|
|
|
planCondition .append(",'"+planList.get(0).get("id").toString()+"'");
|
|
|
}
|
|
|
String sql = " select d.*,DATE_FORMAT(d.execute_time,'%Y/%m/%d %H:%i') as executeTime ,i.code,i.name from wlyy_rehabilitation_plan_detail d " +
|
|
|
" LEFT JOIN wlyy_rehabilitation_service_item i on i.code = d.hospital_service_item_id " +
|
|
|
" where d.plan_id in ("+planCondition+" )AND d.execute_time IS NOT NULL and d.execute_time <>'' " ;
|
|
|
if(searchTask!=null){
|
|
|
if(searchTask==8){//
|
|
|
sql+="and d.doctor='"+doctorCode+"' ";
|
|
@ -564,7 +783,6 @@ public class RehabilitationManageService {
|
|
|
List<Map<String,Object>> rehabilitationDetailList = jdbcTemplate.queryForList(sql);
|
|
|
return ObjEnvelop.getSuccess(SpecialistMapping.api_success,rehabilitationDetailList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 多个康复计划服务项目内容列表
|
|
|
* @param planDetailIds
|
|
@ -581,9 +799,9 @@ public class RehabilitationManageService {
|
|
|
String sql = "select i.name,i.code,i.introduce,d.execute_time,d.hospital_name,d.id,d.status,d.type as detailType,d.expense,d.doctor as executeDoctor," +
|
|
|
" d.doctor_name as executeDoctorName,p.patient ,p.id AS planId,p.create_user as createDoctor,p.create_user_name as createDoctorName, p.status as planStatus " +
|
|
|
" from wlyy_rehabilitation_plan_detail d " +
|
|
|
" LEFT JOIN base_service_package_item i on i.id = d.hospital_service_item_id " +
|
|
|
" LEFT JOIN wlyy_rehabilitation_service_item i on i.code = d.hospital_service_item_id " +
|
|
|
" LEFT JOIN wlyy_patient_rehabilitation_plan p on d.plan_id=p.id " +
|
|
|
" where d.id in ("+planDetailResult+") and i.service_package_id='system' order BY d.execute_time ASC";
|
|
|
" 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);
|
|
@ -684,19 +902,20 @@ public class RehabilitationManageService {
|
|
|
*
|
|
|
*/
|
|
|
public ObjEnvelop serviceItem(String planDetailId,String doctorCode,String recordId) throws Exception{
|
|
|
String sql = "select h.name as title,h.introduce as content,h.code as itemType,d.id,d.execute_time,d.hospital_name,d.status,d.type,d.expense,d.doctor as executeDoctor, " +
|
|
|
String sql = "select h.name as title,h.content as content,h.code as itemType,d.id,d.execute_time,d.hospital_name,d.status,d.type,d.expense,d.doctor as executeDoctor, " +
|
|
|
" d.doctor_name as executeDoctorName,p.patient ,p.name as patientName,p.create_user as createDoctor,p.create_user_name as createDoctorName, p.status as planStatus," +
|
|
|
" p.disease,p.disease_name as diseaseName,p.title as planTitle,d.plan_id as planId,d.relation_code as relationCode,d.frequency_code as frequencyCode,d.remark "+
|
|
|
" ,a.appointment_time appointmentTime,a.appointment_doctor appointmentDoctor,a.appointment_doctor_name appointmentDoctorName,d.reservation_type reservationType" +
|
|
|
" from wlyy_rehabilitation_plan_detail d " +
|
|
|
" LEFT JOIN base_service_package_item h on d.hospital_service_item_id = h.id "+
|
|
|
" LEFT JOIN wlyy_rehabilitation_service_item h on d.hospital_service_item_id = h.code "+
|
|
|
" LEFT JOIN wlyy_patient_rehabilitation_plan p on d.plan_id=p.id " +
|
|
|
" LEFT JOIN wlyy_plan_detail_appointment a on d.id=.a.rehabilitation_plan_detail_id " +
|
|
|
" where d.id = '"+planDetailId+"' and h.service_package_id='system'";
|
|
|
" where d.id = '"+planDetailId+"'";
|
|
|
sql = TransforSqlUtl.wlyy_patient_rehabilitation_planName2(sql);
|
|
|
sql = TransforSqlUtl.wlyy_patient_rehabilitation_planCreateName(sql);
|
|
|
sql = TransforSqlUtl.wlyy_plan_detail_appointmentAppDoctorName(sql);
|
|
|
sql = TransforSqlUtl.wlyy_rehabilitation_plan_detailDoctorName(sql);
|
|
|
System.out.println("sql===="+sql);
|
|
|
List<Map<String,Object>> serviceItemList = jdbcTemplate.queryForList(sql);
|
|
|
if (serviceItemList.size()==0){
|
|
|
return ObjEnvelop.getSuccess(SpecialistMapping.api_success,new HashMap<>());
|
|
@ -720,6 +939,12 @@ public class RehabilitationManageService {
|
|
|
// if(!(one.get("specialistDoctor")+"").equals((one.get("create_user")+""))){
|
|
|
// executeDoctorList.add(one.get("create_user_name")+"");
|
|
|
// }
|
|
|
List<BaseDoctorHospitalDO> baseDoctorHospitalDO = baseDoctorHospitalDao.findByDoctorCode(one.get("executeDoctor").toString());
|
|
|
if (baseDoctorHospitalDO!=null&&baseDoctorHospitalDO.size()>0){
|
|
|
resultMap.put("executeDoctorDept",baseDoctorHospitalDO.get(0).getDeptCode());
|
|
|
resultMap.put("executeDoctorDeptName",baseDoctorHospitalDO.get(0).getDeptName());
|
|
|
}
|
|
|
|
|
|
executeDoctorList.add(one.get("executeDoctorName")+"");//
|
|
|
resultMap.put("remark",one.get("remark"));//备注
|
|
|
resultMap.put("executeDoctorList",executeDoctorList);//执行医生名称列表
|
|
@ -1005,10 +1230,10 @@ public class RehabilitationManageService {
|
|
|
Map<String,Object> resultMap = new HashMap<>();
|
|
|
//近期康复相关记录
|
|
|
// String currentTime = DateUtil.getStringDate();
|
|
|
String planDetailSql = " select d.*,h.name,h.code,s.complete_time from wlyy_rehabilitation_plan_detail d LEFT JOIN base_service_package_item h on d.hospital_service_item_id=h.id " +
|
|
|
String planDetailSql = " select d.*,h.name,h.code,s.complete_time from wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_rehabilitation_service_item h on d.hospital_service_item_id=h.code " +
|
|
|
" LEFT JOIN wlyy_patient_rehabilitation_plan p on d.plan_id=p.id" +
|
|
|
" left join wlyy_rehabilitation_operate_records s on s.rehabilitation_detail_id=d.id " +
|
|
|
" where d.status=1 and p.patient='"+patientCode+"' and d.frequency_code IS NOT NULL and h.service_package_id='system' AND d.frequency_code <>'' ";
|
|
|
" where d.status=1 and p.patient='"+patientCode+"' and d.frequency_code IS NOT NULL AND d.frequency_code <>'' ";
|
|
|
if(StringUtils.isNotEmpty(startTime)){
|
|
|
planDetailSql += " and d.execute_Time>='"+startTime+"' ";
|
|
|
}
|
|
@ -1045,8 +1270,8 @@ public class RehabilitationManageService {
|
|
|
planDetailList.add(map);
|
|
|
}
|
|
|
resultMap.put("planDetailList",planDetailList);//康复相关记录列表
|
|
|
String planDetailCountSql = " select d.status as num from wlyy_rehabilitation_plan_detail d LEFT JOIN base_service_package_item h on d.hospital_service_item_id=h.id" +
|
|
|
" LEFT JOIN wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where p.patient='"+patientCode+"' and h.service_package_id='system' ";
|
|
|
String planDetailCountSql = " select d.status as num from wlyy_rehabilitation_plan_detail d LEFT JOIN wlyy_rehabilitation_service_item h on d.hospital_service_item_id=h.code" +
|
|
|
" LEFT JOIN 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;
|
|
@ -1103,12 +1328,12 @@ public class RehabilitationManageService {
|
|
|
adminTeamCode = specialistPatientRelationDO.getTeamCode();
|
|
|
doctorName = specialistPatientRelationDO.getDoctorName();
|
|
|
}else if(doctorType==2){
|
|
|
String signFamilySql = " select f.* from "+basedb+".wlyy_sign_family f where f.status=1 and f.expenses_status='1' and f.patient='"+patient+"'";
|
|
|
String signFamilySql = " select f.* from wlyy_sign_family f where f.status=1 and f.expenses_status='1' and f.patient='"+patient+"'";
|
|
|
List<Map<String,Object>> signFamily = jdbcTemplate.queryForList(signFamilySql);
|
|
|
adminTeamCode = (Integer)signFamily.get(0).get("admin_team_code");
|
|
|
doctorName = signFamily.get(0).get("doctor_name").toString();
|
|
|
}
|
|
|
String adminTeamSql = " select t.* from "+basedb+".wlyy_admin_team t where t.available=1 and t.id="+adminTeamCode;
|
|
|
String adminTeamSql = " select t.* from base_team t where t.del='1' and t.id="+adminTeamCode;
|
|
|
List<Map<String,Object>> adminTeam = jdbcTemplate.queryForList(adminTeamSql);
|
|
|
String adminTeamName = adminTeam.get(0).get("name").toString();
|
|
|
guidanceMessageLogDO.setAdminTeamCode(adminTeamCode);
|
|
@ -1233,7 +1458,7 @@ public class RehabilitationManageService {
|
|
|
* @param endTime
|
|
|
* @return
|
|
|
*/
|
|
|
public ObjEnvelop dailyJob(String startTime,String endTime){
|
|
|
public JSONArray dailyJob(String startTime,String endTime){
|
|
|
String sql = "select d.doctor,p.patient,count(1) as num from wlyy_rehabilitation_plan_detail d left join wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where d.status!=1 and p.status=1 and d.execute_time>='"+startTime+"' and d.execute_time<='"+endTime+"' GROUP BY d.doctor,p.patient";
|
|
|
// List<Object> list = rehabilitationDetailDao.dailyJob(startTime,endTime);
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
@ -1250,7 +1475,7 @@ public class RehabilitationManageService {
|
|
|
}
|
|
|
one.put("planDetailIds",StringUtils.isNotEmpty(ids)?ids.substring(1):"");
|
|
|
}
|
|
|
return ObjEnvelop.getSuccess(SpecialistMapping.api_success,list);
|
|
|
return new JSONArray(list);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@ -1260,7 +1485,7 @@ public class RehabilitationManageService {
|
|
|
* @param endTime
|
|
|
* @return
|
|
|
*/
|
|
|
public ObjEnvelop tomorrowJob(String startTime,String endTime){
|
|
|
public JSONArray tomorrowJob(String startTime,String endTime){
|
|
|
String sql = "select d.doctor,p.patient,count(1) as num,p.id from wlyy_rehabilitation_plan_detail d left join wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where d.status!=1 and p.status=1 and d.execute_time>='"+startTime+"' and d.execute_time<='"+endTime+"' GROUP BY d.doctor,p.patient";
|
|
|
// List<Object> list = rehabilitationDetailDao.dailyJob(startTime,endTime);
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
@ -1277,7 +1502,7 @@ public class RehabilitationManageService {
|
|
|
}
|
|
|
one.put("planDetailIds",StringUtils.isNotEmpty(ids)?ids.substring(1):"");
|
|
|
}
|
|
|
return ObjEnvelop.getSuccess(SpecialistMapping.api_success,list);
|
|
|
return new JSONArray(list);
|
|
|
}
|
|
|
|
|
|
|
|
@ -1288,7 +1513,7 @@ public class RehabilitationManageService {
|
|
|
* @param endTime
|
|
|
* @return
|
|
|
*/
|
|
|
public ObjEnvelop dailyByJob(String startTime,String endTime){
|
|
|
public JSONArray dailyByJob(String startTime,String endTime){
|
|
|
String sql = "select d.doctor,p.patient,h.service_item_name AS serviceItemName,d.time_type AS timeType from wlyy_rehabilitation_plan_detail d left join wlyy_patient_rehabilitation_plan p on d.plan_id=p.id left join wlyy_hospital_service_item h ON h.id=d.hospital_service_item_id where d.status!=1 and p.status=1 and d.execute_time>='"+startTime+"' and d.execute_time<='"+endTime+"' GROUP BY d.doctor,p.patient,d.execute_time";
|
|
|
// List<Object> list = rehabilitationDetailDao.dailyJob(startTime,endTime);
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
@ -1305,7 +1530,7 @@ public class RehabilitationManageService {
|
|
|
}
|
|
|
one.put("planDetailIds",StringUtils.isNotEmpty(ids)?ids.substring(1):"");
|
|
|
}
|
|
|
return ObjEnvelop.getSuccess(SpecialistMapping.api_success,list);
|
|
|
return new JSONArray(list);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@ -1360,13 +1585,13 @@ public class RehabilitationManageService {
|
|
|
}
|
|
|
//更新返回数据提供发送消息使用
|
|
|
String sql ="SELECT" +
|
|
|
" i.service_item_id," +
|
|
|
" i.id as \"id\"," +
|
|
|
" r.doctor_code," +
|
|
|
" r.patient_code," +
|
|
|
" pd.hospital" +
|
|
|
" FROM" +
|
|
|
" wlyy_rehabilitation_plan_detail pd" +
|
|
|
" LEFT JOIN wlyy_hospital_service_item i ON pd.hospital_service_item_id = i.id" +
|
|
|
" LEFT JOIN wlyy_rehabilitation_service_item i ON pd.hospital_service_item_id = i.id" +
|
|
|
" LEFT JOIN wlyy_rehabilitation_operate_records r ON pd.id = r.rehabilitation_detail_id" +
|
|
|
" WHERE" +
|
|
|
" pd.id = '"+planDeatilId+"'";
|
|
@ -1374,18 +1599,22 @@ public class RehabilitationManageService {
|
|
|
if (list!=null && list.size()>0){
|
|
|
resultMap = list.get(0);
|
|
|
}
|
|
|
String itemSql ="SELECT evaluation,title FROM `wlyy_service_item` WHERE id='"+String.valueOf(resultMap.get("service_item_id"))+"'";
|
|
|
String itemSql ="SELECT evaluation,title FROM `wlyy_service_item` WHERE id='"+String.valueOf(resultMap.get("id"))+"'";
|
|
|
List<Map<String,Object>> itemList = jdbcTemplate.queryForList(itemSql);
|
|
|
if (itemList!=null && itemList.size()>0){
|
|
|
resultMap.put("evaluation",itemList.get(0).get("evaluation"));
|
|
|
resultMap.put("title",itemList.get(0).get("title"));
|
|
|
}
|
|
|
//保存wlyy_message
|
|
|
String hospotal = resultMap.get("hospital").toString();
|
|
|
List<BaseDoctorHospitalDO> depts= baseDoctorHospitalDao.findByDoctorCode(resultMap.get("doctor_code").toString());
|
|
|
String hospotal = "";
|
|
|
String patient = resultMap.get("patient_code").toString();
|
|
|
String doctor = resultMap.get("doctor_code").toString();
|
|
|
Message message = new Message();
|
|
|
message.setType(21);
|
|
|
if (depts!=null&&depts.size()>0){
|
|
|
hospotal=depts.get(0).getOrgCode();
|
|
|
}
|
|
|
SystemMessageDO message = new SystemMessageDO();
|
|
|
message.setType("21");
|
|
|
message.setSender(patient);
|
|
|
message.setReceiver(doctor);
|
|
|
message.setRelationCode(planDeatilId);
|
|
@ -1462,7 +1691,7 @@ public class RehabilitationManageService {
|
|
|
rehabilitationOperateRecordsDO.setPatientCode(patientRehabilitationPlanDO.getPatient());
|
|
|
rehabilitationOperateRecordsDO.setPatientName(patientRehabilitationPlanDO.getName());
|
|
|
rehabilitationOperateRecordsDO.setDoctorCode(jsonObject.getString("doctorCode"));
|
|
|
rehabilitationOperateRecordsDO.setDoctorName(jsonObject.getString("doctorName"));
|
|
|
rehabilitationOperateRecordsDO.setDoctorName(rehabilitationDetailDO.getDoctorName());
|
|
|
rehabilitationOperateRecordsDO.setRelationRecordType(5);
|
|
|
rehabilitationOperateRecordsDO.setCompleteTime(new Date());
|
|
|
rehabilitationOperateRecordsDO.setCreateTime(new Date());
|
|
@ -1502,7 +1731,6 @@ public class RehabilitationManageService {
|
|
|
|
|
|
/**
|
|
|
* 计划总进度
|
|
|
* @param planId
|
|
|
* @return
|
|
|
*/
|
|
|
public ObjEnvelop planSchedule(String planId,String patientCode){
|
|
@ -1510,28 +1738,44 @@ public class RehabilitationManageService {
|
|
|
Integer allCount = rehabilitationDetailDao.findAllByPlanId(planId);//计划总服务项目数
|
|
|
Integer finishedCount = rehabilitationDetailDao.findByStatusAndPlanId(1,planId);
|
|
|
PatientRehabilitationPlanDO p =patientRehabilitationPlanDao.findById(planId);
|
|
|
SpecialistPatientRelationDO specialistPatientRelationDO;
|
|
|
if (p.getTeamCode()!= null) {
|
|
|
specialistPatientRelationDO = specialistPatientRelationDao.findByTeamCodeAndPatient(p.getTeamCode(),p.getPatient());
|
|
|
}
|
|
|
else {
|
|
|
specialistPatientRelationDO = specialistPatientRelationDao.findByDoctorAndPatient(p.getCreateUser(),p.getPatient());
|
|
|
List<DoctorPatientRelationDO> doctorPatientRelationDO= doctorPatientRelationDao.findByDoctorAndPatient(p.getCreateUser(),p.getPatient());
|
|
|
List<RehabilitationDetailDO> details=rehabilitationDetailDao.findByPlanId(planId);
|
|
|
String doctor="";
|
|
|
String doctorName="";
|
|
|
if (details!=null&&details.size()>0){
|
|
|
doctor=details.get(0).getDoctor();
|
|
|
doctorName=details.get(0).getDoctorName();
|
|
|
}
|
|
|
resultMap.put("allCount",allCount);
|
|
|
resultMap.put("finishedCount",finishedCount);
|
|
|
resultMap.put("specialistPatientRelationDO",specialistPatientRelationDO);
|
|
|
resultMap.put("specialistPatientRelationDO",doctorPatientRelationDO);
|
|
|
if (p!=null){
|
|
|
resultMap.put("disease",p.getDisease());
|
|
|
resultMap.put("diseaseName",p.getDiseaseName());
|
|
|
resultMap.put("createUser",p.getCreateUser());
|
|
|
resultMap.put("planTitle",p.getTitle());
|
|
|
resultMap.put("status", p.getStatus());
|
|
|
resultMap.put("isVerify", p.getIsVerify());
|
|
|
resultMap.put("patientImg", p.getPatientImg());
|
|
|
resultMap.put("adviceContent",p.getAdviceContent());
|
|
|
resultMap.put("createTimeDate",DateUtil.dateToStr(p.getCreateTime(),"yyyy-MM-dd"));
|
|
|
resultMap.put("createTime", DateUtil.dateToStr(p.getCreateTime(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
resultMap.put("medicalRecordsCode",p.getMedicalRecordsCode());
|
|
|
|
|
|
List<BaseDoctorHospitalDO> baseDoctorHospitalDO = baseDoctorHospitalDao.findByDoctorCode(p.getCreateUser());
|
|
|
if (baseDoctorHospitalDO!=null&&baseDoctorHospitalDO.size()>0){
|
|
|
resultMap.put("createUserName",p.getCreateUserName());
|
|
|
resultMap.put("createUserDept",baseDoctorHospitalDO.get(0).getDeptCode());
|
|
|
resultMap.put("createUserDeptName",baseDoctorHospitalDO.get(0).getDeptName());
|
|
|
}
|
|
|
List<BaseDoctorHospitalDO> baseDoctorHospitalDOTo = baseDoctorHospitalDao.findByDoctorCode(doctor);
|
|
|
if (baseDoctorHospitalDOTo!=null&&baseDoctorHospitalDOTo.size()>0){
|
|
|
resultMap.put("doctorName",doctorName);
|
|
|
resultMap.put("doctor",doctor);
|
|
|
resultMap.put("doctorDept",baseDoctorHospitalDOTo.get(0).getDeptCode());
|
|
|
resultMap.put("doctorDeptName",baseDoctorHospitalDOTo.get(0).getDeptName());
|
|
|
}
|
|
|
PatientMedicalRecordsDO patientMedicalRecordsDO = patientMedicalRecordsDao.findByCode(p.getMedicalRecordsCode());
|
|
|
resultMap.put("patientMedicalRecordsDO",patientMedicalRecordsDO);
|
|
|
}
|
|
|
BasePatientDO basePatientDO = basePatientDao.findById(patientCode);
|
|
|
Integer age = IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard());
|
|
@ -1541,12 +1785,6 @@ public class RehabilitationManageService {
|
|
|
resultMap.put("patientPhoto",basePatientDO.getPhoto());
|
|
|
resultMap.put("patientName",basePatientDO.getName());
|
|
|
resultMap.put("patientCode",basePatientDO.getId());
|
|
|
String healthyConditionSql =" select label_name,label from wlyy_sign_patient_label_info where status=1 and patient='"+basePatientDO.getId()+"' and label_type=8";
|
|
|
List<Map<String,Object>> healthyConditionList = jdbcTemplate.queryForList(healthyConditionSql);
|
|
|
String healthyCondition = healthyConditionList.size()>0?healthyConditionList.get(0).get("label_name")+"":"";
|
|
|
String healthyConditionType = healthyConditionList.size()>0?healthyConditionList.get(0).get("label")+"":"";
|
|
|
resultMap.put("healthyCondition",healthyCondition);
|
|
|
resultMap.put("healthyConditionType",healthyConditionType);
|
|
|
resultMap.put("idcard",basePatientDO.getIdcard());
|
|
|
// resultMap.put("healthyCondition",healthyCondition);
|
|
|
return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultMap);
|
|
@ -1576,9 +1814,9 @@ public class RehabilitationManageService {
|
|
|
return ObjEnvelop.getSuccess(SpecialistMapping.api_success,map);
|
|
|
}
|
|
|
|
|
|
public ObjEnvelop dailyJobReserve(String startTime,String endTime){
|
|
|
public JSONArray dailyJobReserve1(String startTime, String endTime){
|
|
|
String sql = "select DISTINCT d.doctor,p.patient,d.hospital from wlyy_rehabilitation_plan_detail d left join wlyy_patient_rehabilitation_plan p on d.plan_id=p.id " +
|
|
|
" left join wlyy_hospital_service_item h on d.hospital_service_item_id=h.id " +
|
|
|
" 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 "+
|
|
|
" where d.status!=1 and d.execute_time>='"+startTime+"' and d.execute_time<='"+endTime+"' and i.reserve=1 and p.status!=0 and d.status=0 ";
|
|
|
// List<Object> list = rehabilitationDetailDao.dailyJob(startTime,endTime);
|
|
@ -1601,7 +1839,7 @@ public class RehabilitationManageService {
|
|
|
}
|
|
|
one.put("planDetailIds",StringUtils.isNotEmpty(ids)?ids.substring(1):"");
|
|
|
}
|
|
|
return ObjEnvelop.getSuccess(SpecialistMapping.api_success,list);
|
|
|
return new JSONArray(JSON.toJSONString(list));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@ -1658,11 +1896,11 @@ public class RehabilitationManageService {
|
|
|
" i.code as item_type " +
|
|
|
" FROM" +
|
|
|
" wlyy_rehabilitation_plan_detail d" +
|
|
|
" LEFT JOIN base_service_package_item i ON d.hospital_service_item_id = i.id "+
|
|
|
" LEFT JOIN wlyy_rehabilitation_service_item i ON d.hospital_service_item_id = i.code "+
|
|
|
" LEFT JOIN wlyy_rehabilitation_operate_records r ON d.id = r.rehabilitation_detail_id" +
|
|
|
" WHERE" +
|
|
|
" r.`status` = 1" +
|
|
|
" and i.service_package_id='system') a ON p.id = a.plan_id" +
|
|
|
" ) a ON p.id = a.plan_id" +
|
|
|
" WHERE" +
|
|
|
" p.id = '"+planId+"'";
|
|
|
sql = TransforSqlUtl.wlyy_patient_rehabilitation_planName(sql);
|
|
@ -1724,4 +1962,1332 @@ public class RehabilitationManageService {
|
|
|
public String getCode() {
|
|
|
return UUID.randomUUID().toString().replaceAll("-", "");
|
|
|
}
|
|
|
|
|
|
public List<Map<String,Object>> getPatientAllRehabilitationPlan(String patient){
|
|
|
String sql = "select p.team_code as teamCode,d.id as doctor,p.create_time as createTime,p.id,d.photo,p.title,d.idcard,YEAR (now()) - YEAR (substring(d.idcard, 7, 8)) AS age, d.sex,p.name,p.patient,p.disease_name,d.name as doctorName,p.advice_content as adviceContent,p.medical_records_code as medicalRecordsCode,p.create_time as create_time " +
|
|
|
" FROM wlyy_patient_rehabilitation_plan p " +
|
|
|
" LEFT JOIN base_doctor d ON d.id = p.create_user " +
|
|
|
"WHERE p.patient='"+patient+"'";
|
|
|
sql = sql +" union "+
|
|
|
"SELECT p.team_code as teamCode,d.id AS doctor," +
|
|
|
"p.create_time AS createTime," +
|
|
|
"p.id," +
|
|
|
"d.photo," +
|
|
|
"p.title," +
|
|
|
"d.idcard,YEAR (now())-YEAR (substring(d.idcard,7,8)) AS age," +
|
|
|
"d.sex,p.name," +
|
|
|
"p.patient," +
|
|
|
"p.disease_name,"+
|
|
|
"d.NAME AS doctorName," +
|
|
|
"p.advice_content AS adviceContent," +
|
|
|
"p.medical_records_code AS medicalRecordsCode," +
|
|
|
"p.create_time AS create_time " +
|
|
|
"FROM " +
|
|
|
"wlyy_patient_rehabilitation_plan p " +
|
|
|
"LEFT JOIN base_doctor d ON d.id=p.create_user" +
|
|
|
" LEFT JOIN (" +
|
|
|
"SELECT sr.patient AS patient,sr.team_code AS team_code " +
|
|
|
"FROM wlyy_doctor_patient_relation sr " +
|
|
|
"JOIN wlyy_doctor_special_share se ON se.special_code=sr.id " +
|
|
|
"WHERE sr.patient='"+patient+"') d " +
|
|
|
"ON d.patient=p.patient WHERE " +
|
|
|
"p.patient='"+patient+"' " +
|
|
|
" "+
|
|
|
"ORDER BY create_time DESC";
|
|
|
sql = TransforSqlUtl.wlyy_patient_rehabilitation_planName(sql);
|
|
|
List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
|
|
|
List<Map<String,Object>> result = new ArrayList<>();
|
|
|
List<Map<String,Object>> hadManage = new ArrayList<>();
|
|
|
for (Map<String,Object> mp:mapList){//获下转状态
|
|
|
Date createTimeDate = DateUtil.strToDateLong(mp.get("createTime").toString());
|
|
|
mp.put("createTimeDate",DateUtil.dateToStrShort(createTimeDate));
|
|
|
String mpDoctor = mp.get("doctor").toString();
|
|
|
String manageStatus;
|
|
|
//获取最近完成服务
|
|
|
sql = "select si.`code`,si.name,opr.complete_time update_time \n" +
|
|
|
"from wlyy_rehabilitation_plan_detail pd \n" +
|
|
|
"INNER JOIN wlyy_rehabilitation_service_item si on si.`code` = pd.hospital_service_item_id \n" +
|
|
|
"INNER JOIN wlyy_rehabilitation_operate_records opr on opr.rehabilitation_detail_id = pd.id\n" +
|
|
|
"where plan_id='"+mp.get("id").toString()+"' and opr.`status` =1 ORDER BY opr.complete_time DESC ";
|
|
|
List<Map<String,Object>> serverItems = jdbcTemplate.queryForList(sql);
|
|
|
if(serverItems!=null&&serverItems.size()!=0){
|
|
|
mp.put("completeServer",serverItems.get(0));
|
|
|
}
|
|
|
else{
|
|
|
mp.put("completeServer","");
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
manageStatus = jdbcTemplate.queryForObject(sql,String.class);
|
|
|
}catch (Exception e){
|
|
|
manageStatus="0";
|
|
|
}
|
|
|
if (StringUtils.isBlank(manageStatus)||manageStatus.equals("0")){//已下转,即未接收
|
|
|
mp.put("turnDownState",1);
|
|
|
result.add(mp);
|
|
|
}
|
|
|
else{//已接受
|
|
|
mp.put("turnDownState",2);
|
|
|
hadManage.add(mp);
|
|
|
}
|
|
|
}
|
|
|
result.addAll(hadManage);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public List<Map<String,Object>> selectByGuidance(String planId,String itemCode){
|
|
|
String sql ="SELECT gm.* FROM wlyy_guidance_message_log gm LEFT JOIN wlyy_rehabilitation_plan_detail pd ON pd.id = gm.plan_detail_id " +
|
|
|
"WHERE pd.plan_id = '"+planId+"' AND pd.hospital_service_item_id = '"+itemCode+"' ORDER BY gm.create_time DESC ";
|
|
|
List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
|
|
|
return mapList;
|
|
|
}
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
public String manageAllPlanByPatient(String patient,String doctor){
|
|
|
String sql = "SELECT re.id,re.doctor,re.doctor_name as doctor_name,pl.id planId,pl.name as patientName,pl.create_user,pl.create_user_name specialDoctorName \n" +
|
|
|
"from wlyy_patient_rehabilitation_plan pl \n" +
|
|
|
"INNER JOIN wlyy_doctor_patient_relation re\n" +
|
|
|
"on pl.patient = re.patient \n" +
|
|
|
"where re.`status`>=0 \n" +
|
|
|
"and pl.patient ='"+patient+"' and (re.is_manage<>1 or re.is_manage is NULL) ";
|
|
|
|
|
|
sql = TransforSqlUtl.wlyy_patient_rehabilitation_planCreateName(sql);
|
|
|
List<Map<String,Object>> planIds = jdbcTemplate.queryForList(sql);
|
|
|
List<Map<String,Object>> planByCreate = jdbcTemplate.queryForList(sql+" GROUP BY pl.create_user");
|
|
|
for (Map<String,Object> tmp:planIds){
|
|
|
sql ="update wlyy_doctor_patient_relation set is_manage=1,manage_user ='"+doctor+"', manage_time ='"+DateUtil.getStringDate()+"' where id='"+tmp.get("id").toString()+"' ";
|
|
|
jdbcTemplate.execute(sql);
|
|
|
}
|
|
|
BaseDoctorDO doctorObject = baseDoctorDao.findById(doctor);//家庭医生
|
|
|
//接收患者时,给服务医生群组发送消息
|
|
|
List<String> patientRelationDoctor = new ArrayList<>();
|
|
|
for (Map<String,Object> tmp:planByCreate){
|
|
|
try {
|
|
|
if(!patientRelationDoctor.contains(tmp.get("doctor").toString())){
|
|
|
//guidanceService.sendSpecialistWeixinMessage(patient,tmp.get("doctor").toString(),2,null,null,null);
|
|
|
patientRelationDoctor.add(tmp.get("doctor").toString());
|
|
|
}
|
|
|
//患者服务医生群组发送Im消息
|
|
|
com.alibaba.fastjson.JSONArray serverDoctorList =selectPlanServerDoctor(tmp.get("planId").toString(),doctor);
|
|
|
int length = serverDoctorList.size();
|
|
|
for (int i=0;i<length;i++){
|
|
|
JSONObject serverJson = serverDoctorList.getJSONObject(i);
|
|
|
if (serverJson.getString("type").equals("4")){
|
|
|
String sessionId = serverJson.getString("sessionId");
|
|
|
String message= tmp.get("specialDoctorName").toString()+"医生您好,我已确认接收管理患者"+tmp.get("patientName").toString()+",谢谢。";
|
|
|
imUtil.sendImMsg(doctor,doctorObject.getName(),sessionId,"1",message,"1","");
|
|
|
}
|
|
|
}
|
|
|
//发送模板消息
|
|
|
/*if(messageService.getMessageNoticeSettingByMessageType(tmp.get("create_user").toString(),"1", MessageNoticeSetting.MessageTypeEnum.systemSwitch.getValue())) {
|
|
|
Doctor specialistDoctor = doctorDao.findByCode(tmp.get("create_user").toString());
|
|
|
if(StringUtils.isNoneBlank(specialistDoctor.getOpenid())){
|
|
|
Doctor SignDoctor = doctorDao.findByCode(doctor);
|
|
|
Patient p = patientDao.findByCode(patient);
|
|
|
//[医生姓名]医生您好,[医生姓名]医生已确认接收您的康复下转患者[患者姓名],请访问厦门i健康APP康复管理查看。
|
|
|
String first = specialistDoctor.getName() + "医生您好,"+SignDoctor.getName()+"医生已确认接收您的康复下转患者"
|
|
|
+ p.getName() +",请访问厦门i健康APP康复管理查看。";
|
|
|
if (StringUtils.isNoneBlank(specialistDoctor.getOpenid())){
|
|
|
doctorAssistantUtil.sendWXTemplate(2,specialistDoctor.getOpenid(),first,"请及时处理","康复管理","已接收");
|
|
|
}
|
|
|
}
|
|
|
}*/
|
|
|
|
|
|
}catch(Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
@Transactional(propagation= Propagation.NOT_SUPPORTED)
|
|
|
public com.alibaba.fastjson.JSONArray selectPlanServerDoctor(String planId,String doctorCode) throws Exception{
|
|
|
String sql ="SELECT t.patient,t.create_user FROM wlyy_patient_rehabilitation_plan t where t.id='"+planId+"'";//专科
|
|
|
List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
|
|
|
com.alibaba.fastjson.JSONArray jsonArray = new com.alibaba.fastjson.JSONArray();
|
|
|
String patient = "";
|
|
|
for (Map<String,Object> map:mapList){
|
|
|
String doctor =map.get("create_user").toString();
|
|
|
patient = map.get("patient").toString();
|
|
|
JSONObject object = new JSONObject();
|
|
|
BaseDoctorDO doctor1 = baseDoctorDao.findById(doctor);
|
|
|
object.put("code",doctor1.getId());
|
|
|
object.put("name",doctor1.getName());
|
|
|
object.put("level",doctor1.getLevel());
|
|
|
/*object.put("hospital",doctor1.getHospital());
|
|
|
object.put("hospitalName",doctor1.getHospitalName());*/
|
|
|
if (doctor1.getLevel()==1){
|
|
|
object.put("levelName","专科医生");
|
|
|
}else if (doctor1.getLevel()==2){
|
|
|
object.put("levelName","全科医生");
|
|
|
}
|
|
|
|
|
|
object.put("photo",doctor1.getPhoto());
|
|
|
object.put("idcard",doctor1.getIdcard());
|
|
|
jsonArray.add(object);
|
|
|
}
|
|
|
/*SignFamily signFamily = signFamilyDao.findByPatient(patient);
|
|
|
if (signFamily!=null){
|
|
|
org.json.JSONObject object = new org.json.JSONObject();
|
|
|
BaseDoctorDO doctor1 = baseDoctorDao.findById(signFamily.getDoctor());
|
|
|
object.put("code",doctor1.getId());
|
|
|
object.put("name",doctor1.getName());
|
|
|
if (doctor.getLevel()==1){
|
|
|
object.put("levelName","专科医生");
|
|
|
}else if (doctor.getLevel()==2){
|
|
|
object.put("levelName","全科医生");
|
|
|
}
|
|
|
object.put("photo",doctor.getPhoto());
|
|
|
object.put("idcard",doctor.getIdcard());
|
|
|
object.put("hospital",doctor.getHospital());
|
|
|
object.put("hospitalName",doctor.getHospitalName());
|
|
|
array.put(object);
|
|
|
org.json.JSONObject object1 = new org.json.JSONObject();
|
|
|
if (StringUtils.isNoneBlank(signFamily.getDoctorHealth())){
|
|
|
BaseDoctorDO doctor1 = baseDoctorDao.findById(signFamily.getDoctorHealth());
|
|
|
object1.put("code",doctor1.getId());
|
|
|
object1.put("name",doctor1.getName());
|
|
|
object1.put("level",3);
|
|
|
object1.put("levelName","健管师");
|
|
|
object1.put("photo",doctor1.getPhoto());
|
|
|
object1.put("idcard",doctor1.getIdcard());
|
|
|
object.put("hospital",doctor1.getHospital());
|
|
|
object.put("hospitalName",doctor1.getHospitalName());
|
|
|
array.put(object1);
|
|
|
}
|
|
|
}*/
|
|
|
StringBuilder serverGroupSessionId =new StringBuilder();//群聊session_id
|
|
|
StringBuilder serverGroupSessionName =new StringBuilder();//群聊名称
|
|
|
JSONObject participants = new JSONObject();//群聊成员
|
|
|
if (jsonArray!=null){
|
|
|
for(int i=0;i<jsonArray.size();i++){//获取服务医生P2P 未读消息以及session_id。
|
|
|
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
|
serverGroupSessionId.append(jsonObject.getString("code")+"_");
|
|
|
serverGroupSessionName.append(jsonObject.getString("name")+"、");
|
|
|
participants.put(jsonObject.getString("code"),0);
|
|
|
if(jsonObject.getString("code").equals(doctorCode)){//
|
|
|
jsonObject.put("unRead",0);
|
|
|
jsonObject.put("sessionId","");
|
|
|
jsonObject.put("type","");
|
|
|
jsonObject.put("business_type","");
|
|
|
continue;
|
|
|
}
|
|
|
//服务医生间的消息获取
|
|
|
JSONObject participantsP2P = new JSONObject();
|
|
|
participantsP2P.put(doctorCode,0);
|
|
|
participantsP2P.put(jsonObject.getString("code"),0);
|
|
|
//获取登录医生与其他服务医生的session_id
|
|
|
//{"data":{"business_type":1,"name":"余研","id":"3438fdc6c1082c7b3c3e93dc27da244b59b694dc","type":"2","create_date":1603436112458},"status":200}
|
|
|
JSONObject result = imUtil.createSession(participantsP2P,"2",jsonObject.getString("name"),null);
|
|
|
jsonObject.put("sessionId",result.getJSONObject("data").getString("id"));
|
|
|
jsonObject.put("type",result.getJSONObject("data").getString("type"));
|
|
|
jsonObject.put("business_type",result.getJSONObject("data").getInteger("business_type"));
|
|
|
//获取未读消息
|
|
|
result = imUtil.getSessionUnreadMessageCount(jsonObject.getString("sessionId"),doctorCode);
|
|
|
jsonObject.put("unRead",result.getInteger("count"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//服务医生群聊数据获取
|
|
|
JSONObject groupObject = new JSONObject();
|
|
|
if(StringUtils.isNoneBlank(serverGroupSessionId)&&StringUtils.isNoneBlank(serverGroupSessionName)){
|
|
|
serverGroupSessionId.append("server_group");
|
|
|
serverGroupSessionName=serverGroupSessionName.deleteCharAt(serverGroupSessionName.length()-1);
|
|
|
if(imUtil.sessionIsExist(serverGroupSessionId+"")){//会话存在
|
|
|
JSONObject result = imUtil.getSessionUnreadMessageCount(serverGroupSessionId+"",doctorCode);
|
|
|
groupObject.put("unRead",result.getInteger("count"));
|
|
|
}
|
|
|
else{
|
|
|
JSONObject result = imUtil.createSession(participants,"4",serverGroupSessionName+"",serverGroupSessionId+"");
|
|
|
groupObject.put("unRead",0);
|
|
|
}
|
|
|
groupObject.put("name",serverGroupSessionName);
|
|
|
groupObject.put("sessionId",serverGroupSessionId.toString());
|
|
|
groupObject.put("business_type",1);
|
|
|
groupObject.put("type","4");
|
|
|
}
|
|
|
jsonArray.add(groupObject);
|
|
|
return jsonArray;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 每天8点,16点的job
|
|
|
* @param startTime
|
|
|
* @param endTime
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public void dailyJobSendMessage(String startTime,String endTime,Integer type) throws Exception{
|
|
|
JSONArray jsonArray = dailyJob(startTime,endTime);
|
|
|
org.json.JSONObject jsonObject = null;
|
|
|
String doctor = "";
|
|
|
String patient ="";
|
|
|
Integer num = null;
|
|
|
String planDetailIds = null;
|
|
|
for(int i=0;i<jsonArray.length();i++){
|
|
|
jsonObject = jsonArray.getJSONObject(i);
|
|
|
doctor = jsonObject.get("doctor")+"";//执行的医生(接收的医生)
|
|
|
patient = jsonObject.get("patient")+"";//执行的居民
|
|
|
num = (Integer)jsonObject.get("num");//需要今日需要执行的项目数
|
|
|
planDetailIds = jsonObject.get("planDetailIds")+"";
|
|
|
SystemMessageDO message1 = new SystemMessageDO();
|
|
|
// message1.setSender(patient);
|
|
|
message1.setType(type.toString());
|
|
|
message1.setReceiver(doctor);
|
|
|
message1.setRelationCode(planDetailIds);
|
|
|
// specialistEvaluateSevice.sendMessage(message1,null,patient,num,null);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 每天15点的job
|
|
|
* @param startTime
|
|
|
* @param endTime
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public void tomorrowJobSendMessage(String startTime,String endTime,Integer type) throws Exception{
|
|
|
JSONArray jsonArray =tomorrowJob(startTime,endTime);
|
|
|
org.json.JSONObject jsonObject = null;
|
|
|
String doctor = "";
|
|
|
String patient ="";
|
|
|
Integer num = null;
|
|
|
String planDetailIds = null;
|
|
|
for(int i=0;i<jsonArray.length();i++){
|
|
|
jsonObject = jsonArray.getJSONObject(i);
|
|
|
doctor = jsonObject.get("doctor")+"";//执行的医生(接收的医生)
|
|
|
patient = jsonObject.get("patient")+"";//执行的居民
|
|
|
num = (Integer)jsonObject.get("num");//需要今日需要执行的项目数
|
|
|
planDetailIds = jsonObject.get("planDetailIds")+"";
|
|
|
String planId = jsonObject.get("id")+"";
|
|
|
SystemMessageDO message1 = new SystemMessageDO();
|
|
|
// message1.setSender(patient);
|
|
|
message1.setType(type.toString());
|
|
|
message1.setReceiver(doctor);
|
|
|
message1.setRelationCode(planDetailIds);
|
|
|
message1.setReason(planId);
|
|
|
// specialistEvaluateSevice.sendMessage(message1,null,patient,num,null);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 每15分钟的job
|
|
|
*
|
|
|
* @param startTime
|
|
|
* @param endTime
|
|
|
* @param type
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public void dailyByJobSendMessage(String startTime,String endTime,Integer type) throws Exception{
|
|
|
JSONArray jsonArray = dailyByJob(startTime,endTime);
|
|
|
org.json.JSONObject jsonObject = null;
|
|
|
String doctor = "";
|
|
|
String patient ="";
|
|
|
Integer num = null;
|
|
|
String serviceItemName = null;
|
|
|
String planDetailIds = null;
|
|
|
Long timeType = null;
|
|
|
String nowDate = DateUtil.getStringDate();
|
|
|
String date9 = DateUtil.getStringDateShort()+" 09:00:00";//白天
|
|
|
String date21 = DateUtil.getStringDateShort()+" 21:00:00";//白天
|
|
|
String date9s = DateUtil.getNextDay(DateUtil.getNowDate(),1)+" 09:00:00";//晚上
|
|
|
for(int i=0;i<jsonArray.length();i++){
|
|
|
jsonObject = jsonArray.getJSONObject(i);
|
|
|
doctor = jsonObject.get("doctor")+"";//执行的医生(接收的医生)
|
|
|
patient = jsonObject.get("patient")+"";//执行的居民
|
|
|
/*num = (Integer)jsonObject.get("num");//需要今日需要执行的项目数*/
|
|
|
planDetailIds = jsonObject.get("planDetailIds")+"";
|
|
|
|
|
|
serviceItemName = jsonObject.getString("serviceItemName");
|
|
|
timeType = jsonObject.getLong("timeType");
|
|
|
if (timeType!=null){
|
|
|
if (timeType==1 && nowDate.compareTo(date9)==1&&nowDate.compareTo(date21)==-1){
|
|
|
SystemMessageDO message1 = new SystemMessageDO();
|
|
|
// message1.setSender(patient);
|
|
|
message1.setType(type.toString());
|
|
|
message1.setReceiver(doctor);
|
|
|
message1.setRelationCode(planDetailIds);
|
|
|
message1.setData(serviceItemName);
|
|
|
// specialistEvaluateSevice.sendMessage(message1,null,patient,num,null);
|
|
|
}else if (timeType==2 && nowDate.compareTo(date21)==1&&nowDate.compareTo(date9s)==-1){
|
|
|
SystemMessageDO message1 = new SystemMessageDO();
|
|
|
// message1.setSender(patient);
|
|
|
message1.setType(type.toString());
|
|
|
message1.setReceiver(doctor);
|
|
|
message1.setRelationCode(planDetailIds);
|
|
|
message1.setData(serviceItemName);
|
|
|
// specialistEvaluateSevice.sendMessage(message1,null,patient,num,null);
|
|
|
}else if (timeType==0){
|
|
|
SystemMessageDO message1 = new SystemMessageDO();
|
|
|
// message1.setSender(patient);
|
|
|
message1.setType(type.toString());
|
|
|
message1.setReceiver(doctor);
|
|
|
message1.setRelationCode(planDetailIds);
|
|
|
message1.setData(serviceItemName);
|
|
|
// specialistEvaluateSevice.sendMessage(message1,null,patient,num,null);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
public void dailyJobReserve(Integer num,Integer type) throws Exception{
|
|
|
Long time = num*24*60*60*1000L;
|
|
|
String startTime = DateUtil.dateToStrShort(new Date(new Date().getTime()+time))+" "+"00:00:00";
|
|
|
String endTime = DateUtil.dateToStrShort(new Date(new Date().getTime()+time))+" "+"23:59:59";
|
|
|
JSONArray jsonArray=dailyJobReserve1(startTime,endTime);
|
|
|
org.json.JSONObject jsonObject = null;
|
|
|
String doctor = "";
|
|
|
String patient ="";
|
|
|
String hospital ="";
|
|
|
String planDetailIds = null;
|
|
|
for(int i=0;i<jsonArray.length();i++){
|
|
|
jsonObject = jsonArray.getJSONObject(i);
|
|
|
doctor = jsonObject.get("doctor")+"";//执行的医生(接收的医生)
|
|
|
patient = jsonObject.get("patient")+"";//执行的居民
|
|
|
hospital = jsonObject.get("hospital")+"";//医院
|
|
|
planDetailIds = jsonObject.get("planDetailIds")+"";
|
|
|
SystemMessageDO message1 = new SystemMessageDO();
|
|
|
// message1.setSender(patient);
|
|
|
message1.setType(type.toString());
|
|
|
message1.setReceiver(doctor);
|
|
|
message1.setRelationCode(planDetailIds);
|
|
|
// specialistEvaluateSevice.sendMessage(message1,hospital,patient,num,null);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public List<PatientMedicalRecordsDO> selectByMedicalCode(String code){
|
|
|
String str[] = code.split(",");
|
|
|
List<PatientMedicalRecordsDO> medicalRecordsDOS= new ArrayList<>();
|
|
|
for (int i=0;i<str.length;i++){
|
|
|
PatientMedicalRecordsDO medicalRecordsDO = medicalRecordsRehabilitationDao.findByCode(str[i]);
|
|
|
medicalRecordsDOS.add(medicalRecordsDO);
|
|
|
}
|
|
|
|
|
|
return medicalRecordsDOS;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
public List<Map<String,Object>> selectAllCompleteServiceItemsByPatient(String patient){
|
|
|
List<Map<String,Object>> resutList = new ArrayList<>();
|
|
|
String sql ="select A.id 'planId',pdl.id,pdl.frequency_code,A.patient,A.`name`,si.id 'code',si.`name` 'serviceName',opr.complete_time 'czrq' from \n" +
|
|
|
"(select p.team_code as teamCode,d.code as doctor,p.create_time as createTime,p.id,p.patient,p.name " +
|
|
|
"from wlyy_patient_rehabilitation_plan p\n" +
|
|
|
"LEFT JOIN base_doctor d ON d.id = p.create_user\n" +
|
|
|
"WHERE p.patient='"+patient+"'\n" +
|
|
|
"union\n" +
|
|
|
"SELECT p.team_code as teamCode,d.CODE AS doctor,p.create_time AS createTime,p.id,p.patient,p.name " +
|
|
|
"from \n" +
|
|
|
" wlyy_patient_rehabilitation_plan p\n" +
|
|
|
"LEFT JOIN base_doctor d ON d.id=p.create_user\n" +
|
|
|
"LEFT JOIN (\n" +
|
|
|
"SELECT sr.patient AS patient,sr.team_code AS team_code \n" +
|
|
|
"FROM wlyy_doctor_patient_relation sr \n" +
|
|
|
"JOIN wlyy_doctor_special_share se ON se.special_code=sr.id \n" +
|
|
|
"WHERE sr.patient='"+patient+"') d \n" +
|
|
|
"ON d.patient=p.patient WHERE \n" +
|
|
|
"p.patient='"+patient+"' \n" +
|
|
|
"\n" +
|
|
|
"ORDER BY createTime DESC)A \n" +
|
|
|
"INNER JOIN wlyy_rehabilitation_plan_detail pdl ON A.id = pdl.plan_id\n" +
|
|
|
"INNER JOIN wlyy_rehabilitation_service_item si on pdl.hospital_service_item_id = si.id\n" +
|
|
|
"INNER JOIN wlyy_rehabilitation_operate_records opr on opr.rehabilitation_detail_id = pdl.id\n" +
|
|
|
"where pdl.hospital_service_item_id <>2 and opr.`status`=1 order by opr.complete_time desc ";
|
|
|
sql = TransforSqlUtl.wlyy_patient_rehabilitation_planName(sql);
|
|
|
List<Map<String,Object>> planDetailList = jdbcTemplate.queryForList(sql);
|
|
|
resutList.addAll(planDetailList);
|
|
|
//康复咨询
|
|
|
sql= "select ct.consult,ct.type,ct.patient,ct.name,ct.czrq,ct.symptoms,top.`status`,top.end_time,top.evaluate,top.evaluate_time,top.reply,top.reply_time, '2' as 'serviceId','康复咨询' as 'serviceName'\n" +
|
|
|
"from wlyy_consult_team ct\n" +
|
|
|
"INNER JOIN im_internet_hospital.topics top on top.id = ct.consult \n" +
|
|
|
"where ct.patient='"+patient+"' and ct.type=18 and ct.del=1";
|
|
|
List<Map<String,Object>> kangFuList = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String,Object> map:kangFuList){
|
|
|
if (map.get("status").toString().equals("0")&&map.get("reply").toString().equals("0")){
|
|
|
map.put("serviceStatus","未回复");
|
|
|
}
|
|
|
if (map.get("status").toString().equals("0")&&map.get("reply").toString().equals("1")){
|
|
|
map.put("serviceStatus","未结束");
|
|
|
}
|
|
|
if (map.get("status").toString().equals("10")){//&&map.get("evaluate").toString().equals("0")
|
|
|
map.put("serviceStatus","已结束");
|
|
|
}
|
|
|
// if (map.get("status").toString().equals("10")&&map.get("evaluate").toString().equals("1")){
|
|
|
// map.put("serviceStatus","已结束");
|
|
|
// }
|
|
|
}
|
|
|
resutList.addAll(kangFuList);
|
|
|
Collections.sort(resutList, new Comparator<Map<String, Object>>() {
|
|
|
public int compare(Map<String, Object> o1, Map<String, Object> o2) {
|
|
|
Timestamp map1value = (Timestamp) o1.get("czrq");
|
|
|
Timestamp map2value = (Timestamp) o2.get("czrq");
|
|
|
int sort = 1;
|
|
|
if (map1value.getTime() - map2value.getTime() > 0) {
|
|
|
return sort == 1 ? -1 : 1;
|
|
|
} else if (map1value.getTime() - map2value.getTime() < 0) {
|
|
|
return sort == 1 ? 1 : -1;
|
|
|
} else {
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
return resutList;
|
|
|
}
|
|
|
|
|
|
|
|
|
public JSONArray getPlanDetailForModifing(String planId,String templateId){
|
|
|
String sql;
|
|
|
JSONArray result = new JSONArray();
|
|
|
if(StringUtils.isBlank(templateId)){
|
|
|
sql ="select id from wlyy_rehabilitation_plan_template where title='系统模板'";
|
|
|
templateId = jdbcTemplate.queryForObject(sql,String.class);
|
|
|
}
|
|
|
sql = "select d.hospital_service_item_id as code,i.`name`\n" +
|
|
|
"from wlyy_rehabilitation_template_detail d LEFT JOIN wlyy_rehabilitation_service_item i\n" +
|
|
|
"ON i.`code` = d.hospital_service_item_id\n" +
|
|
|
"where d.template_id = '"+templateId+"'";
|
|
|
List<Map<String,Object>> templateDetailList = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String,Object> map:templateDetailList){
|
|
|
sql ="select d.*,DATE_FORMAT(d.execute_time,'%Y/%m/%d %H:%i') as executeTime ,i.code,i.name \n" +
|
|
|
"from wlyy_rehabilitation_plan_detail d \n" +
|
|
|
"LEFT JOIN wlyy_rehabilitation_service_item i on i.code = d.hospital_service_item_id \n" +
|
|
|
"where d.plan_id ='"+planId+"' AND d.execute_time IS NOT NULL and d.execute_time <>''\n" +
|
|
|
"AND d.`status`<> 1\n" +
|
|
|
"and d.hospital_service_item_id ='"+map.get("code").toString()+"'\n" +
|
|
|
"ORDER BY hospital_service_item_id ASC,execute_time ASC;";
|
|
|
sql = TransforSqlUtl.wlyy_rehabilitation_plan_detailAll2(sql);
|
|
|
List<Map<String,Object>> planDetailList = jdbcTemplate.queryForList(sql);
|
|
|
org.json.JSONObject temp = new org.json.JSONObject();
|
|
|
temp.put("counts",planDetailList.size());
|
|
|
temp.put("code",map.get("code").toString());
|
|
|
temp.put("name",map.get("name").toString());
|
|
|
temp.put("list",planDetailList);
|
|
|
result.put(temp);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
public org.json.JSONObject selectBySpecialistDoctor(String level, String area, String doctor, String disease, Integer page, Integer pageSize, String doctorType, String patientInfo, String filterPlan, String turnDownState){
|
|
|
Integer turnDownStateTotal_0=0;//全部
|
|
|
Integer turnDownStateTotal_1=0;//已下转
|
|
|
Integer turnDownStateTotal_2=0;//已接受
|
|
|
Integer turnDownStateTotal_3=0;//未下转
|
|
|
org.json.JSONObject resultObj = new org.json.JSONObject();
|
|
|
BaseDoctorDO doctorObj = baseDoctorDao.findById(doctor);
|
|
|
List<Map<String, Object>> result = new ArrayList<>();
|
|
|
String sql = "SELECT DISTINCT pr.id,p.`name`,plan.id as planId, p.`id` as code, p.idcard,p.photo, plan.disease,plan.disease_name,YEAR (now()) - YEAR (substring(p.idcard, 7, 8)) as age," +
|
|
|
"p.sex,pr.doctor AS specialist,pr.doctor_name AS specialistName,pr.disease_code,pr.doctor_name ," +
|
|
|
"pr.doctor, pr.health_doctor, pr.health_doctor_name, pr.is_manage,pr.manage_user,pr.manage_time FROM" +
|
|
|
" base_doctor doc,`wlyy_doctor_patient_relation` pr" +
|
|
|
" LEFT JOIN base_patient p ON p.`id` = pr.patient ";
|
|
|
//关联居民计划表
|
|
|
if("1".equals(filterPlan)){
|
|
|
sql = sql + " INNER JOIN `wlyy_patient_rehabilitation_plan` plan on plan.patient = pr.patient ";
|
|
|
}
|
|
|
sql =sql+ " WHERE doc.`id` = pr.doctor ";
|
|
|
String sqlCondition = "";
|
|
|
if (doctorType.equalsIgnoreCase("1")){
|
|
|
sqlCondition +=" AND pr.doctor = '"+doctor+"'";
|
|
|
}else {
|
|
|
sqlCondition +=" AND (pr.doctor = '"+doctor+"' or pr.health_doctor = '"+doctor+"') ";
|
|
|
|
|
|
}
|
|
|
|
|
|
if(StringUtils.isNoneBlank(patientInfo)){
|
|
|
sqlCondition +=" AND (p.idcard like '%"+patientInfo+"%' OR p.`name`like '%"+patientInfo+"%') ";
|
|
|
}
|
|
|
/* if (level.equalsIgnoreCase("1")){
|
|
|
sqlCondition +=" and sf.hospital IN ( SELECT dh.`code` FROM `dm_hospital` dh where dh.city='"+area+"' and dh.del=1 )";
|
|
|
}else if (level.equalsIgnoreCase("2")){
|
|
|
sqlCondition +=" and sf.hospital IN ( SELECT dh.`code` FROM `dm_hospital` dh where dh.town='"+area+"' and dh.del=1 )";
|
|
|
}else if (level.equalsIgnoreCase("3")){
|
|
|
sqlCondition +=" and sf.hospital = '"+area+"' ";
|
|
|
}*/
|
|
|
/*if (StringUtils.isNoneBlank(disease)){
|
|
|
sqlCondition +=" and pr.id IN (SELECT pds.specialist_relation_code FROM wlyy_patient_disease_server pds WHERE pds.del=1 and pds.disease ='"+disease+"')";
|
|
|
}*/
|
|
|
//LIMIT+(page-1)*pageSize+","+pageSize
|
|
|
sqlCondition += " ORDER BY pr.create_time DESC ";
|
|
|
sql += sqlCondition;
|
|
|
List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
|
|
|
System.out.println("mapList"+sql);
|
|
|
for (Map<String,Object> map:mapList){
|
|
|
BasePatientDO patientDo = basePatientDao.findById(map.get("code").toString());
|
|
|
List<BaseDoctorHospitalDO> depts= baseDoctorHospitalDao.findByDoctorCode(doctor);
|
|
|
if (depts!=null&&depts.size()>0){
|
|
|
map.put("dept_code",depts.get(0).getDeptCode());
|
|
|
map.put("dept_name",depts.get(0).getDeptName());
|
|
|
}
|
|
|
Integer age = IdCardUtil.getAgeByIdcardOrBirthday(patientDo.getIdcard(),patientDo.getBirthday());
|
|
|
map.put("age",age);
|
|
|
String specialistRelationCode = map.get("id").toString();
|
|
|
String relationManageState = map.get("is_manage")==null?"0":map.get("is_manage").toString();//管理状态
|
|
|
/*List<PatientDiseaseServer> diseaseServers = patientDiseaseServerDao.findBySpecialistRelationCodeAndDel(specialistRelationCode,"1");
|
|
|
StringBuffer diseaseName = new StringBuffer();
|
|
|
for (int i=0;i<diseaseServers.size();i++){
|
|
|
diseaseName.append(diseaseServers.get(i).getDiseaseName()+",");
|
|
|
}
|
|
|
if(StringUtils.isNoneBlank(diseaseName)){
|
|
|
diseaseName.deleteCharAt(diseaseName.length()-1);
|
|
|
}
|
|
|
map.put("disease_name",diseaseName);*/
|
|
|
if(StringUtils.isBlank(relationManageState)||!relationManageState.equals("1")){//未进行管理
|
|
|
map.put("turnDownState", 1);//已下转
|
|
|
turnDownStateTotal_1+=1;
|
|
|
turnDownStateTotal_0+=1;
|
|
|
if(turnDownState.equals("1")||turnDownState.equals("0")){
|
|
|
result.add(map);
|
|
|
}
|
|
|
}
|
|
|
else{
|
|
|
map.put("turnDownState", 2);//已管理
|
|
|
turnDownStateTotal_2+=1;
|
|
|
turnDownStateTotal_0+=1;
|
|
|
if(turnDownState.equals("2")||turnDownState.equals("0")){
|
|
|
result.add(map);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//家医端未下转(签约居民,但是还未下转的居民) 专科医生端未下转(与未下转列表同-去除未家签)
|
|
|
if (doctorType.equalsIgnoreCase("1")){//专科
|
|
|
sql = "select null as id,p.`name`,p.`id` as code,p.idcard,p.photo,YEAR (now()) - YEAR (substring(p.idcard, 7, 8)) AS age, p.sex,d.create_user AS specialist,d.create_user_name AS specialistName,\n" +
|
|
|
" d.doctor_name,d.doctor,d.health_doctor,d.health_doctor_name,null as is_manage,null as manage_user,null as manage_time \n" +
|
|
|
"from wlyy_doctor_patient_relation d,base_patient p ,base_doctor doc where doc.`id` = d.create_user AND d.create_user='"+doctor+"' ";
|
|
|
}
|
|
|
sqlCondition="";
|
|
|
if(StringUtils.isNoneBlank(patientInfo)){
|
|
|
sqlCondition +=" AND (p.idcard like '%"+patientInfo+"%' OR p.`name`like '%"+patientInfo+"%') ";
|
|
|
}
|
|
|
/* if (level.equalsIgnoreCase("1")){
|
|
|
sqlCondition +=" and s.hospital IN ( SELECT dh.`code` FROM `dm_hospital` dh where dh.city='"+area+"' and dh.del=1 )";
|
|
|
}else if (level.equalsIgnoreCase("2")){
|
|
|
sqlCondition +=" and s.hospital IN ( SELECT dh.`code` FROM `dm_hospital` dh where dh.town='"+area+"' and dh.del=1 )";
|
|
|
}else if (level.equalsIgnoreCase("3")){
|
|
|
sqlCondition +=" and s.hospital = '"+area+"' ";
|
|
|
}*/
|
|
|
if (StringUtils.isNoneBlank(disease)){
|
|
|
sqlCondition +=" AND d.patient in (select patient from wlyy_patient_disease_server pds where pds.del=1 and pds.disease ='"+disease+"') ";
|
|
|
}
|
|
|
|
|
|
sql = sql + sqlCondition ;
|
|
|
if (doctorType.equalsIgnoreCase("1")){//专科
|
|
|
sql = sql+ " \n" +
|
|
|
" AND d.patient = p.id \n" +
|
|
|
"AND d.patient NOT IN ( SELECT i.patient FROM wlyy_patient_rehabilitation_plan i, base_patient p \n" +
|
|
|
"WHERE i.create_user='"+doctor+"' AND i. STATUS != 0 AND p. id = i.patient \n" +
|
|
|
"GROUP BY i.patient ORDER BY i.create_time DESC) GROUP BY d.patient ORDER BY d.create_time DESC ";
|
|
|
}
|
|
|
List<Map<String, Object>> mapList12 = jdbcTemplate.queryForList(sql);
|
|
|
System.out.println("mapList2"+sql);
|
|
|
for (Map<String, Object> map : mapList12) {
|
|
|
List<BaseDoctorHospitalDO> depts= baseDoctorHospitalDao.findByDoctorCode(doctor);
|
|
|
if (depts!=null&&depts.size()>0){
|
|
|
map.put("dept_code",depts.get(0).getDeptCode());
|
|
|
map.put("dept_name",depts.get(0).getDeptName());
|
|
|
}
|
|
|
BasePatientDO patientDo = basePatientDao.findById(map.get("code").toString());
|
|
|
Integer age = IdCardUtil.getAgeByIdcardOrBirthday(patientDo.getIdcard(),patientDo.getBirthday());
|
|
|
map.put("age",age);
|
|
|
map.put("disease_name", "暂无");
|
|
|
map.put("turnDownState",3);//未下
|
|
|
turnDownStateTotal_3+=1;
|
|
|
turnDownStateTotal_0+=1;
|
|
|
if(turnDownState.equals("3")||turnDownState.equals("0")){
|
|
|
result.add(map);
|
|
|
}
|
|
|
}
|
|
|
org.json.JSONObject turnDownStateObj = new org.json.JSONObject();
|
|
|
turnDownStateObj.put("stateAll",turnDownStateTotal_0);//全部
|
|
|
turnDownStateObj.put("stateDown",turnDownStateTotal_1);//已下转
|
|
|
turnDownStateObj.put("stateReceive",turnDownStateTotal_2);//已接受
|
|
|
turnDownStateObj.put("stateNotDown",turnDownStateTotal_3);//未下转
|
|
|
resultObj.put("showList",result);
|
|
|
resultObj.put("turnDownState",turnDownStateObj);
|
|
|
return resultObj;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 康复管理-生成康复下转专科医生二维码
|
|
|
* @param doctorCode
|
|
|
* @param teamCode
|
|
|
* @param teamName
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public String createSpecialDoctorQrCode(String doctorCode,String teamCode,String teamName) throws Exception{
|
|
|
Map<String, Object> param = new HashedMap();
|
|
|
String fileUrl = "";
|
|
|
String appId="";
|
|
|
//生成二维码图片
|
|
|
String contentJsonStr="https://open.weixin.qq.com/connect/oauth2/authorize?appid="+appId+"&redirect_uri="+""+"%2fwx%2fhtml%2fkfgl%2fhtml%2frecover_manage.html%3FdoctorCode%3D"+doctorCode+"%26teamCode%3D"+teamCode+"%26teamName%3D"+teamName+"&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
|
|
|
InputStream ipt = QrcodeUtil.createQrcode(contentJsonStr, 300, "png");
|
|
|
if (isneiwang) {
|
|
|
// 圖片列表
|
|
|
List<String> tempPaths = new ArrayList<String>();
|
|
|
try {
|
|
|
ObjectNode imgNode = fastDFSUtil.upload(ipt, "png", "plan_service_qrcode" + System.currentTimeMillis());
|
|
|
com.alibaba.fastjson.JSONObject json = com.alibaba.fastjson.JSONObject.parseObject(imgNode.toString());
|
|
|
tempPaths.add(json.getString("fid"));
|
|
|
String urls = "";
|
|
|
for (String image : tempPaths) {
|
|
|
if (urls.length() == 0) {
|
|
|
urls = image;
|
|
|
} else {
|
|
|
urls += "," + image;
|
|
|
}
|
|
|
}
|
|
|
fileUrl = "" + urls;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
} else {
|
|
|
try {
|
|
|
//fileUrl = "" + CommonUtil.PrescriptionQRCodetoNeiWang(ipt);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
System.out.println("服务码-----------1"+fileUrl);
|
|
|
param.put("doctorCode", doctorCode);
|
|
|
param.put("imageUrl",fileUrl);
|
|
|
return fileUrl;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public org.json.JSONObject selectBySpecialistDoctor1(String level, String area, String doctor, String disease, Integer page, Integer pageSize, String doctorType, String patientInfo, String filterPlan, String turnDownState){
|
|
|
Integer turnDownStateTotal_0=0;//全部
|
|
|
Integer turnDownStateTotal_1=0;//已下转
|
|
|
Integer turnDownStateTotal_2=0;//已接受
|
|
|
Integer turnDownStateTotal_3=0;//未下转
|
|
|
org.json.JSONObject resultObj = new org.json.JSONObject();
|
|
|
List<Map<String, Object>> result = new ArrayList<>();
|
|
|
String sql = "select DISTINCT t.id as \"id\"," +
|
|
|
" p.name as \"name\"," +
|
|
|
" p.id as \"code\"," +
|
|
|
" p.idcard as \"idcard\"," +
|
|
|
" p.photo as \"photo\"," +
|
|
|
" p.sex as \"sex\"," +
|
|
|
" t.disease as \"disease\"," +
|
|
|
" t.disease_name as \"disease_name\"," +
|
|
|
" YEAR (now()) - YEAR (substring(p.idcard, 7, 8)) as age," +
|
|
|
" d.doctor as \"doctor\"," +
|
|
|
" d.doctor_name as \"doctor_name\"," +
|
|
|
" t.create_user as \"create_user\"," +
|
|
|
" t.create_user_name as \"create_user_name\"," +
|
|
|
" t.create_time as \"create_time\"," +
|
|
|
" t.is_verify as \"is_verify\"" +
|
|
|
" from wlyy_patient_rehabilitation_plan t left join wlyy_rehabilitation_plan_detail d on t.id =d.plan_id" +
|
|
|
" left join base_doctor doc on d.doctor=doc.id LEFT JOIN base_patient p ON p.`id` = t.patient" +
|
|
|
" where 1=1 " ;
|
|
|
|
|
|
if(StringUtils.isNoneBlank(patientInfo)){
|
|
|
sql +=" AND (p.idcard like '%"+patientInfo+"%' OR p.`name`like '%"+patientInfo+"%') ";
|
|
|
}
|
|
|
if (doctorType.equalsIgnoreCase("1")){
|
|
|
sql +=" AND d.doctor = '"+doctor+"'";
|
|
|
}else {
|
|
|
sql +=" AND (d.doctor = '"+doctor+"' or t.create_user = '"+doctor+"') ";
|
|
|
|
|
|
}
|
|
|
/* if (level.equalsIgnoreCase("1")){
|
|
|
sqlCondition +=" and sf.hospital IN ( SELECT dh.`code` FROM `dm_hospital` dh where dh.city='"+area+"' and dh.del=1 )";
|
|
|
}else if (level.equalsIgnoreCase("2")){
|
|
|
sqlCondition +=" and sf.hospital IN ( SELECT dh.`code` FROM `dm_hospital` dh where dh.town='"+area+"' and dh.del=1 )";
|
|
|
}else if (level.equalsIgnoreCase("3")){
|
|
|
sqlCondition +=" and sf.hospital = '"+area+"' ";
|
|
|
}*/
|
|
|
/*if (StringUtils.isNoneBlank(disease)){
|
|
|
sqlCondition +=" and pr.id IN (SELECT pds.specialist_relation_code FROM wlyy_patient_disease_server pds WHERE pds.del=1 and pds.disease ='"+disease+"')";
|
|
|
}*/
|
|
|
//LIMIT+(page-1)*pageSize+","+pageSize
|
|
|
sql += " ORDER BY p.create_time DESC ";
|
|
|
List<Map<String,Object>> mapList = hibenateUtils.createSQLQuery(sql,page,pageSize);
|
|
|
System.out.println("mapList"+sql);
|
|
|
for (Map<String,Object> map:mapList){
|
|
|
BasePatientDO patientDo = basePatientDao.findById(map.get("code").toString());
|
|
|
List<BaseDoctorHospitalDO> depts= baseDoctorHospitalDao.findByDoctorCode(doctor);
|
|
|
if (depts!=null&&depts.size()>0){
|
|
|
map.put("dept_code",depts.get(0).getDeptCode());
|
|
|
map.put("dept_name",depts.get(0).getDeptName());
|
|
|
}
|
|
|
Integer age = IdCardUtil.getAgeByIdcardOrBirthday(patientDo.getIdcard(),patientDo.getBirthday());
|
|
|
map.put("age",age);
|
|
|
String specialistRelationCode = map.get("id").toString();
|
|
|
String relationManageState = map.get("is_verify")==null?"0":map.get("is_verify").toString();//管理状态
|
|
|
/*List<PatientDiseaseServer> diseaseServers = patientDiseaseServerDao.findBySpecialistRelationCodeAndDel(specialistRelationCode,"1");
|
|
|
StringBuffer diseaseName = new StringBuffer();
|
|
|
for (int i=0;i<diseaseServers.size();i++){
|
|
|
diseaseName.append(diseaseServers.get(i).getDiseaseName()+",");
|
|
|
}
|
|
|
if(StringUtils.isNoneBlank(diseaseName)){
|
|
|
diseaseName.deleteCharAt(diseaseName.length()-1);
|
|
|
}
|
|
|
map.put("disease_name",diseaseName);*/
|
|
|
if(StringUtils.isBlank(relationManageState)||!relationManageState.equals("1")){
|
|
|
map.put("turnDownState", 1);//已确认
|
|
|
turnDownStateTotal_1+=1;
|
|
|
turnDownStateTotal_0+=1;
|
|
|
if(turnDownState.equals("1")||turnDownState.equals("0")){
|
|
|
result.add(map);
|
|
|
}
|
|
|
}
|
|
|
else{
|
|
|
map.put("turnDownState", 2);//未确认
|
|
|
turnDownStateTotal_2+=1;
|
|
|
turnDownStateTotal_0+=1;
|
|
|
result.add(map);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
org.json.JSONObject turnDownStateObj = new org.json.JSONObject();
|
|
|
turnDownStateObj.put("stateAll",turnDownStateTotal_0);//全部
|
|
|
turnDownStateObj.put("stateDown",turnDownStateTotal_1);//已下转
|
|
|
turnDownStateObj.put("stateReceive",turnDownStateTotal_2);//已接受
|
|
|
turnDownStateObj.put("stateNotDown",turnDownStateTotal_3);//未下转
|
|
|
resultObj.put("showList",result);
|
|
|
resultObj.put("turnDownState",turnDownStateObj);
|
|
|
return resultObj;
|
|
|
}
|
|
|
|
|
|
|
|
|
public List<Map<String,Object>> calendarPlanDetailItems(String executeStartTime, String executeEndTime, String planId, Integer searchTask, Integer status, String doctorCode) throws Exception{
|
|
|
String sqlCondition = "";
|
|
|
if (searchTask!=null){
|
|
|
if(searchTask==8){
|
|
|
sqlCondition+="and d.doctor='"+doctorCode+"' ";
|
|
|
}else {
|
|
|
sqlCondition+=" and i.code="+searchTask+" " ;
|
|
|
}
|
|
|
}
|
|
|
if(status!=null){
|
|
|
sqlCondition += "and d.status="+status;
|
|
|
}//服务项目
|
|
|
String sql = " select d.id,d.plan_id as planId,i.code,i.name,p.patient,d.frequency_code,DATE_FORMAT(d.create_time,'%Y-%m-%d %H:%i:%s') as createTime from wlyy_rehabilitation_plan_detail d " +
|
|
|
" LEFT JOIN wlyy_patient_rehabilitation_plan p ON p.id=d.plan_id " +
|
|
|
" LEFT JOIN wlyy_rehabilitation_service_item i on i.code = d.hospital_service_item_id " +
|
|
|
" where d.plan_id='"+planId+"' "+sqlCondition+" group by i.code";
|
|
|
|
|
|
List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
|
|
|
|
|
|
for (Map<String,Object> map:mapList){
|
|
|
String sql1 = "SELECT d.frequency_code,d.plan_id as planId ,d.id,DATE_FORMAT(d.create_time,'%Y-%m-%d %H:%i:%s') AS createTime " +
|
|
|
"FROM wlyy_rehabilitation_plan_detail d " +
|
|
|
"WHERE d.plan_id = '"+planId+"' and d.hospital_service_item_id='"+map.get("code")+"'ORDER BY d.create_time DESC";
|
|
|
List<Map<String,Object>> mapList1 = jdbcTemplate.queryForList(sql1);
|
|
|
if (mapList1!=null&&mapList1.size()!=0){
|
|
|
Map<String,Object> map1 = mapList1.get(0);
|
|
|
map.put("frequency_code",map1.get("frequency_code"));
|
|
|
map.put("planId",map1.get("planId"));
|
|
|
map.put("id",map1.get("id"));
|
|
|
map.put("createTime",map1.get("createTime"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for (Map<String,Object> map:mapList){
|
|
|
if (!StringUtils.isNoneBlank(map.get("frequency_code").toString())){//
|
|
|
String sqlCount = "SELECT ror.id,MAX(ror.complete_time) as date,count(*) as total FROM `wlyy_rehabilitation_operate_records` ror, " +
|
|
|
"wlyy_rehabilitation_plan_detail pd WHERE pd.id = ror.rehabilitation_detail_id " +
|
|
|
"AND pd.plan_id = '"+planId+"' AND pd.hospital_service_item_id='"+map.get("code")+"' AND ror.`status`=1 ";
|
|
|
List<Map<String,Object>> mapList1 = jdbcTemplate.queryForList(sqlCount);
|
|
|
int count = 0;
|
|
|
/* if (map.get("code").toString().equalsIgnoreCase("6")){
|
|
|
String allPlanSql = "select wf.id as id,wf.followup_no as followupNo,wf.followup_date as followupDate,wf.followup_plan_date as followupPlanDate,wf.followup_next_date as followupNextDate,\n" +
|
|
|
"wf.followup_type as followupType,wf.followup_class as followupClass,wf.followup_manager_status as followupManagerStatus,wf.doctor_code as doctorCode,wf.doctor_name as doctorName,\n" +
|
|
|
"wf.jwdoctor_code as jwdoctorCode,wf.org_code as orgCode,wf.org_name as orgName,wf.jworg_code as jworgCode,wf.patient_code as patientCode,wf.patient_name as patientName,wf.idcard,\n" +
|
|
|
"wf.data_from as dataFrom,wf.status,wf.followup_content_phone as followupContentPhone,wf.creater,wf.sign_type as signType,wf.admin_team_code as adminTeamCode,wf.sign_code as signCode,\n" +
|
|
|
"wf.prescription_code as prescriptionCode,wf.type from wlyy_followup wf where 1=1 and wf.status !=0\n" +
|
|
|
"and wf.patient_code = '"+map.get("patient")+"' order by wf.followup_plan_date desc";
|
|
|
List<Map<String , Object>> allPlanList = jdbcTemplate.queryForList(allPlanSql);
|
|
|
count = allPlanList.size();
|
|
|
}*/
|
|
|
|
|
|
/*if (map.get("code").toString().equalsIgnoreCase("7")){
|
|
|
String allPrescrSql = "SELECT p.`name`, TIMESTAMPDIFF(YEAR,p.birthday,SYSDATE()) age, p.sex, p.photo, pr.`status`, pr.`code`, \n" +
|
|
|
"LEFT(pr.create_time,19) AS createTime, pr.doctor, pr.min_drug_day AS minDrugDay, LEFT(pr.pres_create_time,19) AS presCreateTime \n" +
|
|
|
"FROM wlyy_prescription pr LEFT JOIN wlyy_patient p ON pr.patient = p.`code` WHERE 1=1 AND pr.patient = '"+map.get("patient")+"' AND pr.status = 100 GROUP BY pr.`code`;";
|
|
|
List<Map<String , Object>> allPrescrList = jdbcTemplate.queryForList(allPrescrSql);
|
|
|
count = allPrescrList.size();
|
|
|
}
|
|
|
|
|
|
if (mapList1!=null && mapList1.size()!=0){
|
|
|
Map<String,Object> map1 = mapList1.get(0);
|
|
|
map.put("compeletTotal",new Integer(map1.get("total").toString()) + count );
|
|
|
map.put("firstDate",map1.get("date"));
|
|
|
}*/
|
|
|
|
|
|
}else {
|
|
|
int codeCount = 0 ;
|
|
|
|
|
|
/* if (map.get("code").toString().equalsIgnoreCase("6")){ //康复随访
|
|
|
//该居民的所有随访计划,需要同步展示到康复计划-康复随访内
|
|
|
String allPlanSql = "select wf.id as id,wf.followup_no as followupNo,wf.followup_date as followupDate,wf.followup_plan_date as followupPlanDate,wf.followup_next_date as followupNextDate,\n" +
|
|
|
"wf.followup_type as followupType,wf.followup_class as followupClass,wf.followup_manager_status as followupManagerStatus,wf.doctor_code as doctorCode,wf.doctor_name as doctorName,\n" +
|
|
|
"wf.jwdoctor_code as jwdoctorCode,wf.org_code as orgCode,wf.org_name as orgName,wf.jworg_code as jworgCode,wf.patient_code as patientCode,wf.patient_name as patientName,wf.idcard,\n" +
|
|
|
"wf.data_from as dataFrom,wf.status,wf.followup_content_phone as followupContentPhone,wf.creater,wf.sign_type as signType,wf.admin_team_code as adminTeamCode,wf.sign_code as signCode,\n" +
|
|
|
"wf.prescription_code as prescriptionCode,wf.type from wlyy_followup wf where 1=1 and wf.status !=0\n" +
|
|
|
"and wf.patient_code = '"+map.get("patient")+"' order by wf.followup_plan_date desc";
|
|
|
List<Map<String , Object>> allPlanList = jdbcTemplate.queryForList(allPlanSql);
|
|
|
codeCount = allPlanList.size();
|
|
|
map.put("allPlanList",allPlanList);
|
|
|
}
|
|
|
|
|
|
if (map.get("code").toString().equalsIgnoreCase("7")){ //康复复诊
|
|
|
//居民的处方续方,需要同步展示到康复计划-康复复诊内
|
|
|
String allPrescrSql = "SELECT p.`name`, TIMESTAMPDIFF(YEAR,p.birthday,SYSDATE()) age, p.sex, p.photo, pr.`status`, pr.`code`, \n" +
|
|
|
"LEFT(pr.create_time,19) AS createTime, pr.doctor, pr.min_drug_day AS minDrugDay, LEFT(pr.pres_create_time,19) AS presCreateTime \n" +
|
|
|
"FROM wlyy_prescription pr LEFT JOIN wlyy_patient p ON pr.patient = p.`code` WHERE 1=1 AND pr.patient = '"+map.get("patient")+"' AND pr.status = 100 GROUP BY pr.`code`;";
|
|
|
List<Map<String , Object>> allPrescrList = jdbcTemplate.queryForList(allPrescrSql);
|
|
|
codeCount = allPrescrList.size();
|
|
|
map.put("allPrescrList",allPrescrList);
|
|
|
}*/
|
|
|
|
|
|
String sqlCount="SELECT\n" +
|
|
|
"\tCOUNT(pd.id) AS total ,\n" +
|
|
|
"\tCOUNT(CASE WHEN pd.`status`=1 THEN 1 ELSE NULL END) AS compeletTotal\n" +
|
|
|
"FROM\n" +
|
|
|
"\t wlyy_rehabilitation_plan_detail pd\n" +
|
|
|
"WHERE\n" +
|
|
|
"\t pd.plan_id = '"+planId+"' " +
|
|
|
"AND pd.hospital_service_item_id='"+map.get("code")+"' and (pd.frequency_code IS NOT NULL AND pd.frequency_code<>'')\n";
|
|
|
|
|
|
List<Map<String,Object>> mapList1 = jdbcTemplate.queryForList(sqlCount);
|
|
|
if (mapList1!=null && mapList1.size()!=0){
|
|
|
Map<String,Object> map1 = mapList1.get(0);
|
|
|
map.put("total",new Integer(map1.get("total").toString()) + codeCount);
|
|
|
map.put("compeletTotal",new Integer(map1.get("compeletTotal").toString()) + codeCount);
|
|
|
}
|
|
|
String dateSql = "SELECT MAX(CASE WHEN pd.`status`=1 THEN pd.execute_time ELSE NULL END) AS firstDate FROM wlyy_rehabilitation_plan_detail pd " +
|
|
|
"WHERE pd.plan_id = '"+planId+"' AND pd.hospital_service_item_id='"+map.get("code")+"'";
|
|
|
List<Map<String,Object>> mapList2 = jdbcTemplate.queryForList(dateSql);
|
|
|
if (mapList2!=null && mapList2.size()!=0){
|
|
|
Map<String,Object> map1 = mapList2.get(0);
|
|
|
map.put("firstDate",map1.get("firstDate"));
|
|
|
String condition = "";
|
|
|
if (map1.get("firstDate")!=null&&StringUtils.isNoneBlank(map1.get("firstDate").toString())){
|
|
|
condition = "and pd.execute_time >='"+map1.get("firstDate").toString()+"'";
|
|
|
}
|
|
|
String dateSql1 = "SELECT pd.execute_time as lastDate FROM wlyy_rehabilitation_plan_detail pd " +
|
|
|
"WHERE pd.plan_id = '"+planId+"' AND pd.hospital_service_item_id='"+map.get("code")+"' and pd.status=0 "+condition+" order by pd.execute_time ASC ";
|
|
|
List<Map<String,Object>> mapList3 = jdbcTemplate.queryForList(dateSql1);
|
|
|
if (mapList3!=null&&mapList3.size()!=0){
|
|
|
Map<String,Object> map2 = mapList3.get(0);
|
|
|
map.put("lastDate",map2.get("lastDate"));
|
|
|
}else {
|
|
|
map.put("lastDate",null);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
if (map.get("code").toString().equalsIgnoreCase("2"))
|
|
|
{//康复咨询
|
|
|
//总康复咨询数量
|
|
|
String sqlTotal = "select count(*)\n" +
|
|
|
"from wlyy_consult a,wlyy_consult_team b where a.id = b.consult and a.patient = '"+map.get("patient")+"' and a.del = '1' and a.type=18";
|
|
|
Integer consultTotal = jdbcTemplate.queryForObject(sqlTotal,Integer.class);
|
|
|
/* String healthCount = "SELECT * FROM wlyy_patient_reservation WHERE incidental_msg_type = 0 AND source = 4 AND patient = '"+map.get("patient")+"' ORDER BY start_time DESC";
|
|
|
List<Map<String , Object>> healthList = jdbcTemplate.queryForList(healthCount);
|
|
|
map.put("healthList",healthList);
|
|
|
map.put("total",consultTotal + healthList.size());*/
|
|
|
//完成康复咨询数量
|
|
|
/* sqlTotal = "select count(*)\n" +
|
|
|
"from wlyy_consult a,wlyy_consult_team b where a.code = b.consult and a.patient = '"+map.get("patient")+"' and a.del = '1' and a.type=18 and b.`status`=1";
|
|
|
consultTotal = jdbcTemplate.queryForObject(sqlTotal,Integer.class);
|
|
|
map.put("compeletTotal",consultTotal + healthList.size());*/
|
|
|
//上次发起时间
|
|
|
String sqlTemp ="select a.czrq\n" +
|
|
|
"from wlyy_consult a,wlyy_consult_team b where a.id = b.consult and a.patient = '"+map.get("patient")+"' and a.del = '1' and a.type=18 order by a.czrq desc limit 1";
|
|
|
List<Map<String,Object>> czrqMap = jdbcTemplate.queryForList(sqlTemp);
|
|
|
if(czrqMap.size()!=0){
|
|
|
if(czrqMap.get(0).get("czrq")!=null){
|
|
|
map.put("lastDate",czrqMap.get(0).get("czrq").toString());
|
|
|
}
|
|
|
}
|
|
|
else{
|
|
|
map.put("lastDate",null);
|
|
|
}
|
|
|
/* //未回复康复咨询数量
|
|
|
sqlTotal="SELECT count(*) FROM wlyy.wlyy_consult_team a WHERE a.type = 18\n" +
|
|
|
"AND EXISTS ( SELECT DISTINCT t.id consultId FROM "+imDBName+".topics t, "+imDBName+".participants p, "+imDBName+".doctors d, "+imDBName+".sessions s \n" +
|
|
|
"WHERE p.participant_id = d.id AND t.session_id = p.session_id AND t.session_id = s.id\n" +
|
|
|
"AND s.type =18 AND t.`reply` = 0 AND a.consult = t.id\n" +
|
|
|
"and a.id in( select b.id from wlyy_consult a,wlyy_consult_team b \n" +
|
|
|
"where a.code = b.consult and a.patient = '"+map.get("patient")+"' and a.del = '1' and a.type=18 )\n" +
|
|
|
")";
|
|
|
Integer noReplay = jdbcTemplate.queryForObject(sqlTotal,Integer.class);
|
|
|
map.put("noReplay",noReplay);*/
|
|
|
}
|
|
|
|
|
|
}
|
|
|
return mapList;
|
|
|
}
|
|
|
|
|
|
|
|
|
public PatientRehabilitationPlanDO confirmManage(String patient,String signDoctor,String specialist,String relationId,String planId) throws Exception {
|
|
|
String sqlCondition;
|
|
|
if (StringUtils.isNoneBlank(relationId)){
|
|
|
sqlCondition=" and pr.id='"+relationId+"' ";
|
|
|
}
|
|
|
else{
|
|
|
sqlCondition=" and pr.doctor = '"+specialist+ "'";
|
|
|
}
|
|
|
PatientRehabilitationPlanDO patientRehabilitationPlanDO = patientRehabilitationPlanDao.findById(planId);
|
|
|
if (patientRehabilitationPlanDO!=null){
|
|
|
patientRehabilitationPlanDO.setIsVerify("1");
|
|
|
patientRehabilitationPlanDao.save(patientRehabilitationPlanDO);
|
|
|
String specialistSql = "select pr.doctor,pr.patient from wlyy_doctor_patient_relation pr where pr.patient='"+patient+"' "+sqlCondition;
|
|
|
List<Map<String,Object>> mapList = jdbcTemplate.queryForList(specialistSql);
|
|
|
if (mapList!=null&&mapList.size()!=0){
|
|
|
Map<String,Object> map = mapList.get(0);
|
|
|
String doctor = (String)map.get("doctor");
|
|
|
String patient1 = (String)map.get("patient");
|
|
|
//guidanceService.sendSpecialistWeixinMessage(patient1,doctor,2,null,null,null);
|
|
|
}
|
|
|
|
|
|
//下转患者被家庭医生确认管理时,专科医生收到推送
|
|
|
/*if(messageService.getMessageNoticeSettingByMessageType(specialist,"1", MessageNoticeSetting.MessageTypeEnum.systemSwitch.getValue())) {
|
|
|
Doctor specialistDoctor = doctorDao.findByCode(specialist);
|
|
|
if(StringUtils.isNoneBlank(specialistDoctor.getOpenid())){
|
|
|
Doctor doctor = doctorDao.findByCode(signDoctor);
|
|
|
Patient p = patientDao.findByCode(patient);
|
|
|
//[医生姓名]医生您好,[医生姓名]医生已确认接收您的康复下转患者[患者姓名],请访问厦门i健康APP康复管理查看。
|
|
|
String first = specialistDoctor.getName() + "医生您好,"+doctor.getName()+"医生已确认接收您的康复下转患者"
|
|
|
+ p.getName() +",请访问厦门i健康APP康复管理查看。";
|
|
|
doctorAssistantUtil.sendWXTemplate(2,specialistDoctor.getOpenid(),first,"请及时处理","康复管理","已接收");
|
|
|
}
|
|
|
}*/
|
|
|
|
|
|
//确认管理给管理医生群组发送消息
|
|
|
/* if (StringUtils.isNoneBlank(planId)){
|
|
|
try {
|
|
|
JSONArray serverDoctorList =selectPlanServerDoctor(planId,signDoctor);
|
|
|
int length = serverDoctorList.length();
|
|
|
BaseDoctorDO doctor = baseDoctorDao.findById(signDoctor);
|
|
|
Patient p = patientDao.findByCode(patient);
|
|
|
Doctor specialistDoctor = doctorDao.findByCode(specialist);
|
|
|
for (int i=0;i<length;i++){
|
|
|
org.json.JSONObject serverJson = serverDoctorList.getJSONObject(i);
|
|
|
if (serverJson.getString("type").equals("4")){
|
|
|
String sessionId = serverJson.getString("sessionId");
|
|
|
String message= specialistDoctor.getName()+"医生您好,我已确认接收管理患者"+p.getName()+",谢谢。";
|
|
|
ImUtill.sendImMsg(signDoctor,doctor.getName(),sessionId,"1",message,"1");
|
|
|
}
|
|
|
}
|
|
|
}catch(Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}*/
|
|
|
}
|
|
|
|
|
|
|
|
|
return patientRehabilitationPlanDO;
|
|
|
}
|
|
|
|
|
|
|
|
|
public org.json.JSONObject selectByPlanDetaiId(String patient, String planId, String code, Integer page, Integer pagesize){
|
|
|
org.json.JSONObject object = new org.json.JSONObject();
|
|
|
String sql ="SELECT\n" +
|
|
|
" DATE_FORMAT(r.complete_time,'%Y-%m-%d %H:%i:%s') AS completeTime," +
|
|
|
" r.doctor_code AS doctorCode," +
|
|
|
" r.doctor_name AS doctorName," +
|
|
|
" r.`status`," +
|
|
|
" r.id as recordId," +
|
|
|
" si.`name`," +
|
|
|
" si.`code`," +
|
|
|
" pd.plan_id," +
|
|
|
" pd.id," +
|
|
|
" r.relation_code as relationCode," +
|
|
|
" r.flag " +
|
|
|
"FROM " +
|
|
|
" wlyy_rehabilitation_operate_records r " +
|
|
|
"LEFT JOIN wlyy_rehabilitation_plan_detail pd ON r.rehabilitation_detail_id = pd.id " +
|
|
|
"LEFT JOIN wlyy_rehabilitation_service_item si ON si.code= pd.hospital_service_item_id " +
|
|
|
"LEFT JOIN base_doctor d ON d.id = r.doctor_code " +
|
|
|
"WHERE " +
|
|
|
" pd.plan_id = '"+planId+"' " +
|
|
|
" AND pd.hospital_service_item_id = '"+code+"' " +
|
|
|
"ORDER BY " +
|
|
|
" r.complete_time DESC " ;
|
|
|
sql = TransforSqlUtl.wlyy_rehabilitation_operate_recordsDoctorName(sql);
|
|
|
List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
|
|
|
String sqlCount ="SELECT\n" +
|
|
|
"\tCOUNT(*) as total\n" +
|
|
|
"FROM\n" +
|
|
|
"\t wlyy_rehabilitation_operate_records r\n" +
|
|
|
"LEFT JOIN wlyy_rehabilitation_plan_detail pd ON r.rehabilitation_detail_id = pd.id\n" +
|
|
|
"LEFT JOIN wlyy_rehabilitation_service_item si ON si.code= pd.hospital_service_item_id\n" +
|
|
|
"LEFT JOIN base_doctor d ON d.id = r.doctor_code\n" +
|
|
|
"WHERE\n" +
|
|
|
"\t pd.plan_id = '"+planId+"'\n" +
|
|
|
"\t\tAND pd.hospital_service_item_id = '"+code+"'\n";
|
|
|
List<Map<String,Object>> maps = jdbcTemplate.queryForList(sqlCount);
|
|
|
|
|
|
/*String followupSql = "select wf.id as id,wf.followup_no as followupNo,wf.followup_date as completeTime,wf.followup_plan_date as followupPlanDate,wf.followup_next_date as followupNextDate,\n" +
|
|
|
"wf.followup_type as followupType,wf.followup_class as followupClass,wf.followup_manager_status as followupManagerStatus,wf.doctor_code as doctorCode,wf.doctor_name as doctorName,\n" +
|
|
|
"wf.jwdoctor_code as jwdoctorCode,wf.org_code as orgCode,wf.org_name as orgName,wf.jworg_code as jworgCode,wf.patient_code as patientCode,wf.patient_name as patientName,wf.idcard,\n" +
|
|
|
"wf.data_from as dataFrom,wf.status,wf.followup_content_phone as followupContentPhone,wf.creater,wf.sign_type as signType,wf.admin_team_code as adminTeamCode,wf.sign_code as signCode,\n" +
|
|
|
"wf.prescription_code as prescriptionCode,wf.type from wlyy_followup wf where 1=1 and wf.status !=0\n" +
|
|
|
"and wf.patient_code = '"+patient+"' ";
|
|
|
List<Map<String,Object>> followupList = jdbcTemplate.queryForList(followupSql);
|
|
|
mapList.addAll(followupList);*/
|
|
|
|
|
|
Collections.sort(mapList, new Comparator<Map<String, Object>>() {
|
|
|
public int compare(Map<String, Object> o1, Map<String, Object> o2) {
|
|
|
Timestamp map1value = (Timestamp) o1.get("completeTime");
|
|
|
Timestamp map2value = (Timestamp) o2.get("completeTime");
|
|
|
int sort = 1;
|
|
|
if (map1value.getTime() - map2value.getTime() > 0) {
|
|
|
return sort == 1 ? -1 : 1;
|
|
|
} else if (map1value.getTime() - map2value.getTime() < 0) {
|
|
|
return sort == 1 ? 1 : -1;
|
|
|
} else {
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
object.put("list",startPage(mapList,page,pagesize));
|
|
|
object.put("total",new Integer(maps.get(0).get("total").toString()) );
|
|
|
object.put("page",page);
|
|
|
object.put("pagesize",pagesize);
|
|
|
return object;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 开始分页
|
|
|
* @param list
|
|
|
* @param pageNum 页码
|
|
|
* @param pageSize 每页多少条数据
|
|
|
* @return
|
|
|
*/
|
|
|
public static List startPage(List list, Integer pageNum,
|
|
|
Integer pageSize) {
|
|
|
if (pageNum == null){
|
|
|
pageNum = 1;
|
|
|
}
|
|
|
if (pageSize == null){
|
|
|
pageSize = 10;
|
|
|
}
|
|
|
if (list == null) {
|
|
|
return null;
|
|
|
}
|
|
|
if (list.size() == 0) {
|
|
|
return null;
|
|
|
}
|
|
|
Integer count = list.size(); // 记录总数
|
|
|
Integer pageCount = 0; // 页数
|
|
|
if (count % pageSize == 0) {
|
|
|
pageCount = count / pageSize;
|
|
|
} else {
|
|
|
pageCount = count / pageSize + 1;
|
|
|
}
|
|
|
int fromIndex = 0; // 开始索引
|
|
|
int toIndex = 0; // 结束索引
|
|
|
if (pageNum != pageCount) {
|
|
|
fromIndex = (pageNum - 1) * pageSize;
|
|
|
toIndex = fromIndex + pageSize;
|
|
|
} else {
|
|
|
fromIndex = (pageNum - 1) * pageSize;
|
|
|
toIndex = count;
|
|
|
}
|
|
|
List pageList = list.subList(fromIndex, toIndex);
|
|
|
return pageList;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取康复服务项目列表
|
|
|
* @return
|
|
|
* @param name
|
|
|
*/
|
|
|
public List<Map<String, Object>> getServiceItemList(String name) {
|
|
|
String sql = "SELECT code,`name` FROM `wlyy_rehabilitation_service_item` ";
|
|
|
if(StringUtils.isNotBlank(name)){
|
|
|
sql += "where name like '%" + name + "%' ";
|
|
|
}
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
|
|
|
@Transactional(propagation= Propagation.NOT_SUPPORTED)
|
|
|
public List<PatientMedicalRecordsDO> getNewRehabilitation(String patient,String doctorCode) throws Exception {
|
|
|
//智业中山同步病历
|
|
|
String result = "";
|
|
|
List<PatientMedicalRecordsDO> query = new ArrayList<>();
|
|
|
BasePatientDO patient1 = basePatientDao.findById(patient);
|
|
|
BaseDoctorDO doctor = baseDoctorDao.findById(doctorCode);
|
|
|
String orgCode="";
|
|
|
List<BaseDoctorHospitalDO> baseDoctorHospitalDO = baseDoctorHospitalDao.findByDoctorCode(doctorCode);
|
|
|
if(baseDoctorHospitalDO!=null&&baseDoctorHospitalDO.size()>0){
|
|
|
orgCode=baseDoctorHospitalDO.get(0).getOrgCode();
|
|
|
}
|
|
|
if (demoFlag) {//demoFlag
|
|
|
result = patientRecordService.getJosnFileResullt("event" + "2");
|
|
|
} else {
|
|
|
org.json.JSONObject jsonEvent = new org.json.JSONObject();
|
|
|
List<Map<String, String>> resultMap = patientRecordService.getAllEvent_new(patient, "2", "1", "1", "2010-10-10 00:00:00",orgCode);
|
|
|
jsonEvent.put("data", JSON.parseArray(JSON.toJSONString(resultMap)));
|
|
|
result = jsonEvent.toString();
|
|
|
}
|
|
|
com.alibaba.fastjson.JSONObject rejson = com.alibaba.fastjson.JSONObject.parseObject(result);
|
|
|
com.alibaba.fastjson.JSONArray temlist = rejson.getJSONArray("data");
|
|
|
if (temlist.size() != 0) {//存在病历信息
|
|
|
com.alibaba.fastjson.JSONObject tem = temlist.getJSONObject(0);
|
|
|
/**
|
|
|
* {
|
|
|
"orgName": "厦门大学附属心血管病医院",
|
|
|
"createTime": "2013-09-26 10:13:38",
|
|
|
"patient": "386a35b8d17a47cbab6174ae7952b9b6",
|
|
|
"orgCode": "182",
|
|
|
"dataFrom": "1",
|
|
|
"id": "9f35ff1f-f683-4f3c-a0a5-7ff8ef3df89e",
|
|
|
"eventType": "2",
|
|
|
"dianosis": "高血压2级",
|
|
|
"eventDate": "2013-09-26 10:13:38"
|
|
|
}
|
|
|
*/
|
|
|
PatientMedicalRecordsDO pmr = new PatientMedicalRecordsDO();
|
|
|
pmr.setHospitalName(tem.getString("orgName"));
|
|
|
pmr.setHospital(tem.getString("orgCode"));
|
|
|
if (demoFlag) {//测试获取为病历模板 hospitalcode获取为自己的code
|
|
|
pmr.setHospital("ac02a9b87a3611e69f7c005056850d66");//
|
|
|
}
|
|
|
// pmr.setDischargeDiagnosis(re.getDiagnosis());
|
|
|
pmr.setDischargeDiagnosisName(tem.getString("dianosis"));
|
|
|
// pmr.setAdmittingDiagnosis(re.getDiagnosis());
|
|
|
pmr.setJwpatient(tem.getString("patient"));
|
|
|
pmr.setAdmittingDiagnosisName(tem.getString("dianosis"));
|
|
|
pmr.setEvent(tem.getString("id"));
|
|
|
pmr.setDataFrom(tem.getString("dataFrom"));
|
|
|
pmr.setAdvice("出院继续观察");
|
|
|
if (tem.getString("dataFrom").equals("4"))//3中山 4智业
|
|
|
{
|
|
|
try {
|
|
|
String html = rehabilitationInfoService.getEmrContentByRID(tem.getString("patient"),tem.getString("id"),tem.getString("orgCode"));
|
|
|
if (StringUtils.isNoneBlank(html)){
|
|
|
List<String> tmp = HtmlUtil.getTagContent(html,"xid=\"diagnosis.in\" diagpop=\"1\">" + "(.*?)</TD>");
|
|
|
String diagnosisIn =tmp.size()>0?tmp.get(0):"";
|
|
|
tmp = HtmlUtil.getTagContent(html,"xid=\"diagnosis.out\" diagpop=\"1\">" + "(.*?)</TD>");
|
|
|
String diagnosisOut =tmp.size()>0?tmp.get(0):"";
|
|
|
if (StringUtils.isNoneBlank(diagnosisIn)){//入院诊断
|
|
|
pmr.setAdmittingDiagnosisName(diagnosisIn);
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(diagnosisOut)){//出院诊断
|
|
|
pmr.setDischargeDiagnosisName(diagnosisOut);
|
|
|
}
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
if (tem.getString("dataFrom").equals("3"))//3中山 4智业
|
|
|
{
|
|
|
try {
|
|
|
com.alibaba.fastjson.JSONObject zsResult = zsRehabilitationInfoService.zsHospitalRecordDetail(tem.getString("patient"),tem.getString("id"));
|
|
|
com.alibaba.fastjson.JSONObject zsResultData = zsResult.getJSONObject("data");
|
|
|
if (zsResult.getInteger("status")==200&&zsResultData!=null){
|
|
|
if(zsResultData.containsKey("入院诊断")&&StringUtils.isNoneBlank(zsResultData.getString("入院诊断"))){
|
|
|
pmr.setDischargeDiagnosisName(zsResultData.getString("入院诊断"));
|
|
|
}
|
|
|
if (zsResultData.containsKey("出院诊断")&&StringUtils.isNoneBlank(zsResultData.getString("出院诊断"))){
|
|
|
pmr.setAdmittingDiagnosisName(zsResultData.getString("出院诊断"));
|
|
|
}
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
// pmr.setDiseaseCode(diseaseObj.getString("disease"));//疾病code
|
|
|
// pmr.setDiseaseName(diseaseObj.getString("diseaseName"));//疾病名称
|
|
|
String jsonData = JSON.toJSONString(pmr);
|
|
|
//创建居民住院病历
|
|
|
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
|
|
|
PatientMedicalRecordsDO patientMedicalRecordsDO = objectMapper.readValue(jsonData, PatientMedicalRecordsDO.class);
|
|
|
PatientMedicalRecordsDO patientMedicalRecordsDO1 = rehabilitationInfoService.createMedicalRecords(doctorCode, patient, patient1.getName(), patientMedicalRecordsDO, null);
|
|
|
if (patientMedicalRecordsDO1 != null) { //创建病历成功
|
|
|
query.add(patientMedicalRecordsDO1);
|
|
|
return query;
|
|
|
}
|
|
|
}
|
|
|
String sql = "SELECT pmrr.* FROM wlyy_patient_medical_records_rehabilitation pmrr WHERE pmrr.patient = '"+patient+"' and (data_from=3 or data_from=4) GROUP BY id DESC LIMIT 0,1";//find_in_set('"+diseaseCode+"',disease)
|
|
|
query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(PatientMedicalRecordsDO.class));
|
|
|
return query;
|
|
|
}
|
|
|
|
|
|
|
|
|
public List<Map<String,Object>> selectPlanByPatient(String patient, Integer status, String planId,String doctor){
|
|
|
if (StringUtils.isNoneBlank(planId)){
|
|
|
String planSql = "select p.patient " +
|
|
|
" FROM wlyy_patient_rehabilitation_plan p where p.id='"+planId+"' ";
|
|
|
List<Map<String,Object>> maps = jdbcTemplate.queryForList(planSql);
|
|
|
if (maps!=null&&maps.size()!=0){
|
|
|
Map<String,Object> map = maps.get(0);
|
|
|
patient = map.get("patient").toString();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
String sql = "select d.id as doctor,p.create_time as createTime,p.id,d.photo,p.title,d.idcard,YEAR (now()) - YEAR (substring(d.idcard, 7, 8)) AS age, d.sex,p.name,p.patient,d.name as doctorName,p.advice_content as adviceContent,p.medical_records_code as medicalRecordsCode,p.create_time as create_time " +
|
|
|
" FROM wlyy_patient_rehabilitation_plan p " +
|
|
|
" LEFT JOIN base_doctor d ON d.id = p.create_user " +
|
|
|
"WHERE p.patient='"+patient+"'";
|
|
|
if (status!=null){
|
|
|
sql +=" and p.status ="+status;
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(doctor)){
|
|
|
BaseDoctorDO doctor1 = baseDoctorDao.findById(doctor);
|
|
|
if (doctor1!=null&&doctor1.getLevel()==1){
|
|
|
sql +=" and p.create_user ='"+doctor+"'";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/*sql+=" union ";
|
|
|
|
|
|
sql+=" SELECT d.CODE AS doctor," +
|
|
|
"p.create_time AS createTime," +
|
|
|
"p.id," +
|
|
|
"d.photo," +
|
|
|
"p.title," +
|
|
|
"d.idcard,YEAR (now())-YEAR (substring(d.idcard,7,8)) AS age," +
|
|
|
"d.sex,p.name," +
|
|
|
"p.patient," +
|
|
|
"d.NAME AS doctorName," +
|
|
|
"d.dept_name AS deptName," +
|
|
|
"hospital_name AS hospitalName," +
|
|
|
"p.advice_content AS adviceContent," +
|
|
|
"p.medical_records_code AS medicalRecordsCode," +
|
|
|
"p.create_time AS create_time " +
|
|
|
"FROM " +
|
|
|
"wlyy_patient_rehabilitation_plan p " +
|
|
|
"LEFT JOIN base_doctor d ON d.id=p.create_user" +
|
|
|
" LEFT JOIN (" +
|
|
|
"SELECT sr.patient AS patient,sr.team_code AS team_code " +
|
|
|
"FROM wlyy_doctor_patient_relation sr " +
|
|
|
"JOIN wlyy_doctor_special_share se ON se.special_code=sr.id " +
|
|
|
"WHERE se.doctor='"+doctor+"' " +
|
|
|
"AND sr.patient='"+patient+"') d " +
|
|
|
"ON d.patient=p.patient WHERE " +
|
|
|
"p.patient='"+patient+"' " +
|
|
|
"AND d.team_code=p.team_code ";
|
|
|
*/
|
|
|
sql+=" ORDER BY create_time DESC ";
|
|
|
//sql = TransforSqlUtl.wlyy_patient_rehabilitation_planName(sql);
|
|
|
List<Map<String,Object>> mapList = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String,Object> map:mapList){
|
|
|
List<BaseDoctorHospitalDO> depts=baseDoctorHospitalDao.findByDoctorCode(map.get("doctor").toString());
|
|
|
if(depts!=null&&depts.size()>0){
|
|
|
map.put("deptCode",depts.get(0).getDeptCode());
|
|
|
map.put("deptName",depts.get(0).getDeptName());
|
|
|
map.put("orgCode",depts.get(0).getOrgCode());
|
|
|
map.put("orgName",depts.get(0).getOrgName());
|
|
|
}
|
|
|
String sqlSpecilist = "select * from wlyy_doctor_patient_relation where doctor = '"+map.get("doctor")+"' and patient ='"+patient+"' and status=1";
|
|
|
List<Map<String,Object>> maps = jdbcTemplate.queryForList(sqlSpecilist);
|
|
|
map.put("specialist",maps);
|
|
|
}
|
|
|
return mapList;
|
|
|
}
|
|
|
|
|
|
}
|