huangwenjie 5 年 前
コミット
a9598e2dda

+ 43 - 12
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -82,8 +82,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    @Autowired
    @Autowired
    private PrescriptionInfoDao prescriptionInfoDao;
    private PrescriptionInfoDao prescriptionInfoDao;
    @Autowired
    @Autowired
    private DoctorClinicRoomConsultDao doctorClinicRoomConsultDao;
    @Autowired
    private HospitalWaitingRoomDao hospitalWaitingRoomDao;
    private HospitalWaitingRoomDao hospitalWaitingRoomDao;
    @Autowired
    @Autowired
    private DictHospitalDeptDao dictHospitalDeptDao;
    private DictHospitalDeptDao dictHospitalDeptDao;
@ -1594,16 +1592,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        }
        }
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
    
    
//        if(list!=null&&list.size()>0&&StringUtils.isNotBlank(doctorCode)){
//            //排序
//            for(int i=0;i<list.size();i++){
//                String id = (String)list.get(i).get("id");
//                if(doctorCode.equals(id)){
//                    Collections.swap(list,0,i);
//                }
//            }
//        }
    
        return list;
        return list;
    }
    }
    
    
@ -1619,4 +1607,47 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        
        
        return  list;
        return  list;
    }
    }
    
    /**
     * 医生可接单列表
     * @param doctor
     * @param type
     * @return
     */
    public List<Map<String,Object>> findWaitingRoomOutpatientByDoctor(String doctor, Integer type) {
    
        String sql ="SELECT " +
                "room.outpatient_id AS id," +
                "room.patient_id AS patient_id," +
                "room.patient_name AS name," +
                "patient.sex AS sex," +
                "patient.idcard AS idcard," +
                "patient.photo AS photo," +
                "patient.birthday AS birthday," +
                "room.consult_type AS consult_type," +
                "room.reservation_time AS time," +
                "outpatient.disease_img AS disease_img," +
                "outpatient.description AS description," +
                "outpatient.origin_con_no AS origin_con_no " +
                "FROM " +
                "wlyy_hospital_waiting_room room," +
                "base_patient patient," +
                "wlyy_outpatient outpatient " +
                "WHERE " +
                "room.patient_id=patient.id " +
                "AND room.outpatient_id=outpatient.id " +
                "AND room.doctor IS NULL " +
                "AND room.consult_type="+type;
    
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if(list!=null&&list.size()>0){
            //根据身份证计算年龄
            for(Map<String,Object> outpatient :list){
                String idcard = (String)outpatient.get("idcard");
                outpatient.put("age",DateUtil.getAgeForIdcard(idcard));
            }
        }
        
        return list;
    }
}
}

+ 34 - 5
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -797,7 +797,7 @@ public class ImService {
	 * @param reason
	 * @param reason
	 * @return
	 * @return
	 */
	 */
	public Integer addPrescriptionConsult(String outpatientCode, String patient, String agent, String doctorCode, ConsultTeamDo ct, String reason, Integer type) throws Exception {
	public JSONObject addPrescriptionConsult(String outpatientCode, String patient,String doctorCode, ConsultTeamDo ct, String reason, Integer type) throws Exception {
		
		
		synchronized (outpatientCode.intern()) {
		synchronized (outpatientCode.intern()) {
			/**
			/**
@ -868,7 +868,7 @@ public class ImService {
			ct.setConsult(consult.getId());
			ct.setConsult(consult.getId());
			
			
			//推送给IM去创建议题,取得成员消息
			//推送给IM去创建议题,取得成员消息
			JSONObject messages = imUtil.getCreateTopicMessage(patient, p.getName(), consult.getTitle(), content, consult.getImages(), agent);
			JSONObject messages = imUtil.getCreateTopicMessage(doctorCode, doctor.getName(), consult.getTitle(), content, consult.getImages(), patient);
			
			
			//5、(im创建咨询) 续方咨询的sessionid为居民code+就诊code+咨询类型(图文,视频,图文+视频)
			//5、(im创建咨询) 续方咨询的sessionid为居民code+就诊code+咨询类型(图文,视频,图文+视频)
			String sessionId = patient + "_" + outpatientCode + "_" + ct.getType();
			String sessionId = patient + "_" + outpatientCode + "_" + ct.getType();
@ -903,7 +903,9 @@ public class ImService {
			// 添加医生咨询日志
			// 添加医生咨询日志
			addLogs(ct);
			addLogs(ct);
			
			
			return 1;
			JSONObject result = imUtil.getSingleSessionInfo(sessionId,doctorCode);
			
			return result;
		}
		}
	}
	}
	
	
@ -927,23 +929,26 @@ public class ImService {
		
		
		String endName = "";
		String endName = "";
		String endId = "";
		String endId = "";
		JSONObject obj = new JSONObject();
		//结束咨询才发送推送给IM文字消息
		//结束咨询才发送推送给IM文字消息
		if (endType == 1) {
		if (endType == 1) {
			BasePatientDO p = basePatientDao.findById(endOperator);
			BasePatientDO p = basePatientDao.findById(endOperator);
			endName = p.getName();
			endName = p.getName();
			endId = p.getId();
			endId = p.getId();
			obj = imUtil.endTopics(consultTeam.getPatient(), endId, endName, consultTeam.getConsult());
		} else {
		} else {
			BaseDoctorDO d = baseDoctorDao.findById(endOperator);
			if (endOperator.equals("admin")) {
			if (endOperator.equals("admin")) {
				endId = "system";
				endId = "system";
				endName = "咨询超时未回复,系统自动";
				endName = "咨询超时未回复,系统自动";
			} else {
			} else {
				BaseDoctorDO d = baseDoctorDao.findById(endOperator);
				endId = d.getId();
				endId = d.getId();
				endName = d.getName();
				endName = d.getName();
			}
			}
			obj = imUtil.endTopics(consultTeam.getDoctor(), endId, d.getName(), consultTeam.getConsult());
		}
		}
		
		
		JSONObject obj = imUtil.endTopics(consultTeam.getPatient(), endId, endName, consultTeam.getConsult());
		
		if (obj == null) {
		if (obj == null) {
			throw new RuntimeException("IM消息结束异常!");
			throw new RuntimeException("IM消息结束异常!");
		}
		}
@ -1003,4 +1008,28 @@ public class ImService {
		
		
		return imUtil.getTopic(consult);
		return imUtil.getTopic(consult);
	}
	}
	
	
	/**
	 * 获取咨询问题,图片,居民信息
	 * @param consult
	 * @param patientCode
	 * @return
	 */
	public JSONObject getConsultInfoAndPatientInfo(String consult,String patientCode) {
		BasePatientDO basePatientDO = basePatientDao.findById(patientCode);
		ConsultDo consultDo = consultDao.findOne(consult);
		JSONObject result = new JSONObject();
		
		JSONObject patientinfoObj = new JSONObject();
		patientinfoObj.put("name",basePatientDO.getName());
		patientinfoObj.put("sex",basePatientDO.getSex());
		patientinfoObj.put("mobile",basePatientDO.getMobile());
		patientinfoObj.put("address",basePatientDO.getAddress());
		Integer age = DateUtil.getAgeForIdcard(basePatientDO.getIdcard());
		patientinfoObj.put("age",age);
		result.put("patientInfo",patientinfoObj);
		result.put("consultDo",consultDo);
		return result;
	}
}
}

+ 16 - 0
business/im-service/src/main/java/com/yihu/jw/im/util/ImUtil.java

@ -630,6 +630,22 @@ public class ImUtil {
		}
		}
	}
	}
	
	
	/**
	 * 根据session和userid获取单个会话
	 * @param sessionId
	 * @param userId
	 * @return
	 */
	public JSONObject getSingleSessionInfo(String sessionId,String userId){
		String url = im_host + "api/v2/sessions/" + sessionId + "/session?user_id=" + userId;
		try {
			String ret = HttpClientUtil.get(url,"utf-8");
			return JSON.parseObject(ret);
		} catch (Exception e) {
			throw new RuntimeException("操作失败!");
		}
	}
	
	/**
	/**
	 * 发送消息给IM
	 * 发送消息给IM
	 *
	 *

+ 5 - 1
common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java

@ -278,6 +278,7 @@ public class BaseHospitalRequestMapping {
    
    
        //根据咨询CODE获取session_id
        //根据咨询CODE获取session_id
        public static final String getTopic = "/getTopic";
        public static final String getTopic = "/getTopic";
        
        
    }
    }
    
    
@ -291,7 +292,7 @@ public class BaseHospitalRequestMapping {
        public static final String addPrescriptionConsult ="/addPrescriptionConsult";
        public static final String addPrescriptionConsult ="/addPrescriptionConsult";
        
        
        //医生可接单列表
        //医生可接单列表
        public static final String findPrescriptionConsultByDoctor = "findPrescriptionConsultByDoctor";
        public static final String findWaitingRoomOutpatientByDoctor = "findWaitingRoomOutpatientByDoctor";
    
    
        //导诊台居民列表
        //导诊台居民列表
        public static final String findWaitingRoomPatient = "findWaitingRoomPatient";
        public static final String findWaitingRoomPatient = "findWaitingRoomPatient";
@ -307,6 +308,9 @@ public class BaseHospitalRequestMapping {
    
    
        //结束咨询id
        //结束咨询id
        public static final String finish = "/finish";
        public static final String finish = "/finish";
    
        //获取咨询问题,图片,居民信息
        public static final String getConsultInfoAndPatientInfo = "/getConsultInfoAndPatientInfo";
        
        
    }
    }

+ 39 - 0
common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java

@ -1063,5 +1063,44 @@ public class DateUtil {
        System.out.println(dateStart );
        System.out.println(dateStart );
        System.out.println(dateEnd);
        System.out.println(dateEnd);
    }
    }
    
    /**
     * 根据身份证的号码算出当前身份证持有者的年龄
     *
     * @param
     * @throws Exception
     */
    public static int getAgeForIdcard(String idcard) {
        try {
            int age = 0;
            
            if (org.apache.commons.lang3.StringUtils.isEmpty(idcard)) {
                return age;
            }
            
            String birth = "";
            
            if (idcard.length() == 18) {
                birth = idcard.substring(6, 14);
            } else if (idcard.length() == 15) {
                birth = "19" + idcard.substring(6, 12);
            }
            
            int year = Integer.valueOf(birth.substring(0, 4));
            int month = Integer.valueOf(birth.substring(4, 6));
            int day = Integer.valueOf(birth.substring(6));
            Calendar cal = Calendar.getInstance();
            age = cal.get(Calendar.YEAR) - year;
            //周岁计算
            if (cal.get(Calendar.MONTH) < (month - 1) || (cal.get(Calendar.MONTH) == (month - 1) && cal.get(Calendar.DATE) < day)) {
                age--;
            }
            
            return age;
        } catch (Exception e) {
        
        }
        return -1;
    }
}
}

+ 34 - 19
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
@ -34,17 +35,18 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
	@Autowired
	@Autowired
	private ImService imService;
	private ImService imService;
	
	
	@Autowired
	private PrescriptionService prescriptionService;
	
	
	
	@GetMapping (value = BaseHospitalRequestMapping.DodtorIM.findPrescriptionConsultByDoctor)
	@GetMapping (value = BaseHospitalRequestMapping.DodtorIM.findWaitingRoomOutpatientByDoctor)
	@ApiOperation(value = "医生可接单列表", notes = "医生可接单列表")
	@ApiOperation(value = "医生可接单列表", notes = "医生可接单列表")
	public ListEnvelop findPrescriptionConsultByDoctor(
	public ListEnvelop findPrescriptionConsultByDoctor(
			@ApiParam(name = "doctor", value = "医生CODE")
			@ApiParam(name = "doctor", value = "医生CODE",defaultValue = "1cd15ffe6b3a11e69f7c005056850d66")
			@RequestParam(value = "doctor",required = true) String doctor,
			@RequestParam(value = "doctor",required = true) String doctor,
			@ApiParam(name = "type", value = "图文复诊:1视频复诊:2")
			@ApiParam(name = "type", value = "图文复诊:1视频复诊:2")
			@RequestParam(value = "type",required = false) Integer type){
		String result = "[{\"id\":\"000000006777d2c80167bf4d93680100\",\"day\":\"2019-06-20\",\"patientlist\":{\"id\":\"XDF1231231LLL\",\"name\":\"张三\",\"sex\":1,\"age\":68,\"photo\":\"/group/3d45/111.jpg\",\"type\":1,\"consult_type\":1,\"time\":\"12:12\"}},{\"id\":\"000000006777d2c80167bf4d93680101\",\"day\":\"2019-06-21\",\"patientlist\":{\"id\":\"XDF1231231LL12\",\"name\":\"李四\",\"sex\":2,\"age\":66,\"photo\":\"/group/3d45/111.jpg\",\"type\":2,\"consult_type\":12,\"time\":\"12:12\"}}]";
		JSONArray messageArray = JSON.parseArray(result);
		return success(messageArray);
			@RequestParam(value = "type",required = true) Integer type){
		return success("请求成功",prescriptionService.findWaitingRoomOutpatientByDoctor(doctor,type));
	}
	}
	
	
	@GetMapping(value = BaseHospitalRequestMapping.DodtorIM.findWaitingRoomPatient)
	@GetMapping(value = BaseHospitalRequestMapping.DodtorIM.findWaitingRoomPatient)
@ -92,11 +94,11 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
	
	
	@PostMapping(value = BaseHospitalRequestMapping.DodtorIM.addPrescriptionConsult)
	@PostMapping(value = BaseHospitalRequestMapping.DodtorIM.addPrescriptionConsult)
	@ApiOperation(value = "添加复诊咨询", notes = "添加复诊咨询")
	@ApiOperation(value = "添加复诊咨询", notes = "添加复诊咨询")
	public Envelop addPrescriptionConsult(@ApiParam(name = "outpatientCode", value = "HIS就诊记录CODE", defaultValue = "10")
	public Envelop addPrescriptionConsult(@ApiParam(name = "outpatientCode", value = "HIS就诊记录CODE", defaultValue = "1")
			@RequestParam(value = "outpatientCode", required = true) String outpatientCode,
			@RequestParam(value = "outpatientCode", required = true) String outpatientCode,
			@ApiParam(name = "patientCode", value = "复诊居民", defaultValue = "86225d1365e711e69f7c005056850d66")
			@ApiParam(name = "patientCode", value = "复诊居民", defaultValue = "9638fa184ad14a71ba7e4bf931670778")
			@RequestParam(value = "patientCode", required = true) String patientCode,
			@RequestParam(value = "patientCode", required = true) String patientCode,
            @ApiParam(name = "doctorCode", value = "当前医生", defaultValue = "131231312312")
            @ApiParam(name = "doctorCode", value = "当前医生", defaultValue = "1cd15ffe6b3a11e69f7c005056850d66")
	        @RequestParam(value = "doctorCode", required = true) String doctorCode,
	        @RequestParam(value = "doctorCode", required = true) String doctorCode,
			@ApiParam(name = "type", value = "咨询类型(1、图文;2、视频,3、图文+视频)", defaultValue = "1")
			@ApiParam(name = "type", value = "咨询类型(1、图文;2、视频,3、图文+视频)", defaultValue = "1")
			@RequestParam(value = "type", required = true) Integer type,
			@RequestParam(value = "type", required = true) Integer type,
@ -107,17 +109,19 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
			
			
			//咨询类型(1、图文;2、视频,3、图文+视频)
			//咨询类型(1、图文;2、视频,3、图文+视频)
			consult.setHealthindexType(type);
			consult.setHealthindexType(type);
			int res = 0;
//			int res = 0;
		
			JSONObject result = new JSONObject();
			synchronized (outpatientCode.intern()){
			synchronized (outpatientCode.intern()){
				res = imService.addPrescriptionConsult(outpatientCode, patientCode,patientCode,doctorCode,consult,reason,type);
			}
			if (res == -1) {
				failed("该处方存在未审核的处方,无法进行复诊咨询!");
//				return error(-1, "该处方存在未审核的续方,无法进行续方咨询!");
			} if (res == -3) {
				failed("您当天有未完成的处方,不能发起复诊!");
//				return error(-1, "您当天有未完成的续方,不能发起续方咨询!");
				result = imService.addPrescriptionConsult(outpatientCode, patientCode,doctorCode,consult,reason,type);
			}
			}
//			if (res == -1) {
//				failed("该处方存在未审核的处方,无法进行复诊咨询!");
////				return error(-1, "该处方存在未审核的续方,无法进行续方咨询!");
//			} if (res == -3) {
//				failed("您当天有未完成的处方,不能发起复诊!");
////				return error(-1, "您当天有未完成的续方,不能发起续方咨询!");
//			}
//            Doctor doctor = doctorService.findDoctorByCode(consult.getDoctor());
//            Doctor doctor = doctorService.findDoctorByCode(consult.getDoctor());
//            // 添加到统计队列
//            // 添加到统计队列
@ -152,7 +156,7 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
//				}
//				}
//			}
//			}
//			BusinessLogs.info(BusinessLogs.BusinessType.consult, getRepUID(), getUID(), new org.json.JSONObject(consult));
//			BusinessLogs.info(BusinessLogs.BusinessType.consult, getRepUID(), getUID(), new org.json.JSONObject(consult));
			return success(consult);
			return success("操作成功",result);
	}
	}
	
	
	@PostMapping(value = BaseHospitalRequestMapping.PatientIM.finish)
	@PostMapping(value = BaseHospitalRequestMapping.PatientIM.finish)
@ -166,4 +170,15 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
		int resutl = imService.finish(consult,doctorCode,2);
		int resutl = imService.finish(consult,doctorCode,2);
		return success(resutl);
		return success(resutl);
	}
	}
	
	
	@GetMapping(value = BaseHospitalRequestMapping.DodtorIM.getConsultInfoAndPatientInfo)
	@ApiOperation(value = "获取咨询问题,图片,居民信息", notes = "获取咨询问题,图片,居民信息")
	public Envelop getConsultInfoAndPatientInfo(
			@ApiParam(name = "consult", value = "咨询CODE")
			@RequestParam(value = "consult",required = false) String consult,
			@ApiParam(name = "patientCode", value = "居民COEE")
			@RequestParam(value = "patientCode",required = false) String patientCode)throws Exception {
		return success("请求成功",imService.getConsultInfoAndPatientInfo(consult,patientCode));
	}
}
}

+ 1 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/PatientConsultEndpoint.java

@ -268,4 +268,5 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
			@RequestParam(value = "consult",required = false) String consult)throws Exception {
			@RequestParam(value = "consult",required = false) String consult)throws Exception {
		return success("请求成功",imService.getTopic(consult));
		return success("请求成功",imService.getTopic(consult));
	}
	}
}
}