|  | @ -0,0 +1,131 @@
 | 
	
		
			
				|  |  | package com.yihu.jw.wlyy.service;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | import com.yihu.jw.doctor.dao.BaseDoctorDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.base.patient.BasePatientDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.patient.dao.BasePatientDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.common.IdCardUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.date.DateUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.wlyy.wlyyhttp.WlyyHttpService;
 | 
	
		
			
				|  |  | import org.apache.commons.collections.map.HashedMap;
 | 
	
		
			
				|  |  | import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  | import org.slf4j.Logger;
 | 
	
		
			
				|  |  | import org.slf4j.LoggerFactory;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import java.util.Map;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | /**
 | 
	
		
			
				|  |  |  * Created by Trick on 2019/8/21.
 | 
	
		
			
				|  |  |  */
 | 
	
		
			
				|  |  | @Service
 | 
	
		
			
				|  |  | @Transactional
 | 
	
		
			
				|  |  | public class WlyyBusinessService {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private static final Logger logger = LoggerFactory.getLogger(WlyyBusinessService.class);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private WlyyHttpService wlyyHttpService;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BaseDoctorDao baseDoctorDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private OutpatientDao outpatientDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BasePatientDao basePatientDao;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 推送系统门诊wlyy系统消息
 | 
	
		
			
				|  |  |      * @param doctor
 | 
	
		
			
				|  |  |      * @param outPatientId
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Boolean sendWlyyOutpatientMes(String doctor,String outPatientId){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         BaseDoctorDO doctorDO = baseDoctorDao.findOne(doctor);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if(doctorDO!=null&& StringUtils.isNotBlank(doctorDO.getIdcard())){
 | 
	
		
			
				|  |  |             WlyyOutpatientDO outpatientDO =outpatientDao.findOne(outPatientId);
 | 
	
		
			
				|  |  |             BasePatientDO basePatientDO = basePatientDao.findOne(outpatientDO.getPatient());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             JSONObject param = new JSONObject();
 | 
	
		
			
				|  |  |             param.put("idCard",doctorDO.getIdcard());
 | 
	
		
			
				|  |  |             param.put("sender","hlwyy");
 | 
	
		
			
				|  |  |             param.put("senderName","互联网医院");
 | 
	
		
			
				|  |  |             param.put("relationCode",outPatientId);
 | 
	
		
			
				|  |  |             String sex = "";
 | 
	
		
			
				|  |  |             try {
 | 
	
		
			
				|  |  |                 String sx = IdCardUtil.getSexForIdcard_new(basePatientDO.getIdcard());
 | 
	
		
			
				|  |  |                 if("1".equals(sx)){
 | 
	
		
			
				|  |  |                     sex = "男";
 | 
	
		
			
				|  |  |                 }else if("2".equals(sx)){
 | 
	
		
			
				|  |  |                     sex = "女";
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }catch (Exception e){
 | 
	
		
			
				|  |  |                 logger.error("推送wlyy系统消息 身份证转换性别失败!:"+e.toString());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String age = IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard())==-1?"未知":IdCardUtil.getAgeForIdcard(basePatientDO.getIdcard())+"";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String content = "您已向"+outpatientDO.getHospitalName()+outpatientDO.getDeptName()+
 | 
	
		
			
				|  |  |                     "医师"+doctorDO.getName()+"发起了协同门诊请求。协同门诊患者:"+outpatientDO.getPatientName()+
 | 
	
		
			
				|  |  |                     "("+sex+" "+age+"岁),协同门诊时间:"+ DateUtil.dateToStr(outpatientDO.getRegisterDate(),"yyyy-MM-dd HH:mm");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             param.put("content",content);
 | 
	
		
			
				|  |  |             param.put("title","协同门诊消息");
 | 
	
		
			
				|  |  |             param.put("type",500);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             JSONObject rs = wlyyHttpService.sendWlyyMes("wlyySendMes",param);
 | 
	
		
			
				|  |  |             if(rs!=null){
 | 
	
		
			
				|  |  |                 return true;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return false;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public Boolean readWlyyOutpatientMes(String outPatientId){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Map<String,Object> res = new HashedMap();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         WlyyOutpatientDO outpatientDO =outpatientDao.findOne(outPatientId);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if(outpatientDO!=null){
 | 
	
		
			
				|  |  |             BaseDoctorDO doctorDO = baseDoctorDao.findOne(outpatientDO.getDoctor());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             JSONObject param = new JSONObject();
 | 
	
		
			
				|  |  |             param.put("idCard",doctorDO.getIdcard());
 | 
	
		
			
				|  |  |             param.put("type",500);
 | 
	
		
			
				|  |  |             param.put("relationCode",outPatientId);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             JSONObject rs = wlyyHttpService.sendWlyyMes("wlyyReadMes",param);
 | 
	
		
			
				|  |  |             if(rs!=null){
 | 
	
		
			
				|  |  |                 return true;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return false;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 验证居民是否签约
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param idCard
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Boolean checkSignFamily(String idCard){
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         JSONObject param = new JSONObject();
 | 
	
		
			
				|  |  |         param.put("idCard",idCard);
 | 
	
		
			
				|  |  |         JSONObject rs = wlyyHttpService.sendWlyyMes("wlyyCheckSignFamily",param);
 | 
	
		
			
				|  |  |         if(rs!=null){
 | 
	
		
			
				|  |  |             return true;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return false;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 |