|  | @ -42,6 +42,7 @@ import com.yihu.jw.hospital.doctor.dao.PatientRegisterTimeDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.doctor.dao.WlyyDoctorOnlineTimeDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.drugstore.dao.BaseDrugStoreDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.mapping.service.DoctorMappingService;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.mapping.service.PatientMappingService;
 | 
	
	
		
			
				|  | @ -75,12 +76,15 @@ import com.yihu.jw.util.common.IdCardUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.common.LatitudeUtils;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.date.DateUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
 | 
	
		
			
				|  |  | import com.yihu.jw.utils.Pkis.PKIService_PortType;
 | 
	
		
			
				|  |  | import com.yihu.jw.utils.Pkis.PKIService_ServiceLocator;
 | 
	
		
			
				|  |  | import com.yihu.jw.utils.WebserviceUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.utils.hibernate.HibenateUtils;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.dao.BasePatientWechatDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.dao.WechatDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.dao.WxPushLogDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.enterprise.EnterpriseService;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.service.BaseSensitiveFilterWordsService;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.service.WxAccessTokenService;
 | 
	
		
			
				|  |  | import com.yihu.mysql.query.BaseJpaService;
 | 
	
	
		
			
				|  | @ -111,7 +115,9 @@ import java.io.IOException;
 | 
	
		
			
				|  |  | import java.io.OutputStream;
 | 
	
		
			
				|  |  | import java.lang.Boolean;
 | 
	
		
			
				|  |  | import java.math.BigDecimal;
 | 
	
		
			
				|  |  | import java.net.URL;
 | 
	
		
			
				|  |  | import java.text.DecimalFormat;
 | 
	
		
			
				|  |  | import java.text.ParseException;
 | 
	
		
			
				|  |  | import java.util.*;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | /**
 | 
	
	
		
			
				|  | @ -246,6 +252,13 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |     private BaseBannerDoctorDao baseBannerDoctorDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private BaseDrugStoreDao baseDrugStoreDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private DoctorMappingDao doctorMappingDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PrescriptionSignDao prescriptionSignDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private EnterpriseService enterpriseService;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -266,14 +279,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<WlyyOutpatientVO> findOutpatientList(String patient, String startTime, String endTime, boolean demoFlag) throws Exception {
 | 
	
		
			
				|  |  |     public List<WlyyOutpatientVO> findOutpatientList(String patient, String startTime, String endTime, boolean demoFlag,String ksdm) throws Exception {
 | 
	
		
			
				|  |  |         logger.info("findOutpatientList patient:" + patient);
 | 
	
		
			
				|  |  |         String patNo = patientMappingService.findHisPatNoByPatient(patient);
 | 
	
		
			
				|  |  |         if (StringUtils.isBlank(patNo)) {
 | 
	
		
			
				|  |  |             return null;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         logger.info("findOutpatientList patNo " + patNo);
 | 
	
		
			
				|  |  |         return entranceService.BS30025(patNo, null, startTime, endTime, demoFlag);
 | 
	
		
			
				|  |  |         return entranceService.BS30025(patNo, null, startTime, endTime, demoFlag,ksdm);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
	
		
			
				|  | @ -290,7 +303,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             return null;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         logger.info("findOutpatientList patNo:" + patNo);
 | 
	
		
			
				|  |  |         List<WlyyOutpatientVO> list = entranceService.BS30025(patNo, conNo, null, null, demoFlag);
 | 
	
		
			
				|  |  |         List<WlyyOutpatientVO> list = entranceService.BS30025(patNo, conNo, null, null, demoFlag,null);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (list != null && list.size() > 0) {
 | 
	
		
			
				|  |  |             WlyyOutpatientVO outpatientVO = list.get(0);
 | 
	
	
		
			
				|  | @ -313,7 +326,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //BS16017(String REGISTER_SN,String realOrder,String PAT_NO,String ADM_NO,boolean demoFlag) throws Exception {
 | 
	
		
			
				|  |  |         logger.info("findOriginPrescriptionList: registerSn:" + registerSn + " patient" + patient + " patNo:" + patNo + " realOrder:" + realOrder + " admNo:" + admNo);
 | 
	
		
			
				|  |  |         return entranceService.BS16017(registerSn, realOrder, patNo, admNo, demoFlag);
 | 
	
		
			
				|  |  |         List<WlyyPrescriptionVO> prescriptionVOS = entranceService.BS16017(registerSn, realOrder, patNo, admNo, demoFlag);
 | 
	
		
			
				|  |  |         for (WlyyPrescriptionVO prescriptionVO:prescriptionVOS){
 | 
	
		
			
				|  |  |             WlyyPrescriptionEmrDO wlyyPrescriptionEmrDO = readOutPatientXml(registerSn);//电子病历
 | 
	
		
			
				|  |  |             prescriptionVO.setWlyyPrescriptionEmrDO(wlyyPrescriptionEmrDO);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return prescriptionVOS;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
	
		
			
				|  | @ -485,6 +503,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         rs.put("patientCancelValue", outpatientDO.getPatientCancelValue());
 | 
	
		
			
				|  |  |         rs.put("patientCancelRemark", outpatientDO.getPatientCancelRemark());
 | 
	
		
			
				|  |  |         rs.put("operator",outpatientDO.getOperator());
 | 
	
		
			
				|  |  |         rs.put("status",outpatientDO.getStatus());
 | 
	
		
			
				|  |  |         rs.put("createTime",DateUtil.dateToStrLong(outpatientDO.getCreateTime()));
 | 
	
		
			
				|  |  |         //居民详情
 | 
	
		
			
				|  |  |         BasePatientDO basePatientDO = basePatientDao.findById(outpatientDO.getPatient());
 | 
	
		
			
				|  |  |         rs.put("patientName", basePatientDO.getName());
 | 
	
	
		
			
				|  | @ -772,8 +792,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     @Transactional
 | 
	
		
			
				|  |  |     public WlyyOutpatientDO appointmentRevisit(String outpatientJson, String expressageJson, String registerJson, String chargeType) throws Exception {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //1.保存就诊实体
 | 
	
		
			
				|  |  |         WlyyOutpatientDO outpatientDO = objectMapper.readValue(outpatientJson, WlyyOutpatientDO.class);
 | 
	
		
			
				|  |  |         BasePatientDO patientDO = basePatientDao.findById(outpatientDO.getPatient());
 | 
	
	
		
			
				|  | @ -790,7 +810,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         if (outpatientDO.getRegisterDate() == null) {
 | 
	
		
			
				|  |  |             outpatientDO.setRegisterDate(new Date());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         WlyyPrescriptionExpressageDO previous = checkOutPatientPre(outpatientDO.getPatient());
 | 
	
		
			
				|  |  |         //2.物流信息
 | 
	
		
			
				|  |  |         WlyyPrescriptionExpressageDO expressageDO = objectMapper.readValue(expressageJson, WlyyPrescriptionExpressageDO.class);
 | 
	
		
			
				|  |  |         if (null!=previous.getId()&&previous.getOneselfPickupFlg()!=expressageDO.getOneselfPickupFlg()){
 | 
	
		
			
				|  |  |             WlyyOutpatientDO wlyyOutpatientDO = new WlyyOutpatientDO();
 | 
	
		
			
				|  |  |             wlyyOutpatientDO.setRemindCount(previous.getOneselfPickupFlg());
 | 
	
		
			
				|  |  |             return wlyyOutpatientDO;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         WlyyOutpatientDO outpatient = outpatientDao.save(outpatientDO);
 | 
	
		
			
				|  |  |         WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("WX_MONEY");
 | 
	
		
			
				|  |  |         Double price = 0.0;
 | 
	
	
		
			
				|  | @ -806,25 +833,27 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         businessOrderService.recharge(outpatient.getId(), "复诊-诊查费", "2", "复诊-诊查费", patientDO.getId(), patientDO.getName(), outpatient.getDoctor(), price);
 | 
	
		
			
				|  |  |         BusinessOrderDO businessOrderDO = businessOrderService.recharge(outpatient.getId(), "复诊-诊查费", "2", "复诊-诊查费", patientDO.getId(), patientDO.getName(), outpatient.getDoctor(), price);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         WlyyPatientRegisterTimeDO registerTimeDO = null;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         WlyyPatientRegisterTimeDO wlyyPatientRegisterTimeDO =new WlyyPatientRegisterTimeDO();
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             //如果是视频预约咨询
 | 
	
		
			
				|  |  |             if (StringUtils.isNotBlank(registerJson)) {
 | 
	
		
			
				|  |  |                 registerTimeDO = objectMapper.readValue(registerJson, WlyyPatientRegisterTimeDO.class);
 | 
	
		
			
				|  |  |                 registerTimeDO.setOutpatientId(outpatient.getId());
 | 
	
		
			
				|  |  |                 registerTimeDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |                 patientRegisterTimeDao.save(registerTimeDO);
 | 
	
		
			
				|  |  |                 wlyyPatientRegisterTimeDO = patientRegisterTimeDao.save(registerTimeDO);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } catch (Exception e) {
 | 
	
		
			
				|  |  |             throw new RuntimeException("号源已经被预约,请选择其他号源");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //2.物流信息
 | 
	
		
			
				|  |  |         WlyyPrescriptionExpressageDO expressageDO = objectMapper.readValue(expressageJson, WlyyPrescriptionExpressageDO.class);
 | 
	
		
			
				|  |  |         if (0==expressageDO.getOneselfPickupFlg()){
 | 
	
		
			
				|  |  |             if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
 | 
	
		
			
				|  |  |                 String drugCode= expressageDO.getHospitalCode()==null?"5550":expressageDO.getHospitalCode();
 | 
	
		
			
				|  |  |                 expressageDO.setHospitalCode(drugCode);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             System.out.println("进入物流信息");
 | 
	
		
			
				|  |  |             expressageDO.setDel(1);
 | 
	
		
			
				|  |  |             expressageDO.setCreateTime(new Date());
 | 
	
	
		
			
				|  | @ -854,10 +883,41 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //3.创建候诊室
 | 
	
		
			
				|  |  |         createRoom(outpatient, chargeType);
 | 
	
		
			
				|  |  |         String content = "向您发起了图文复诊,点击查看";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return outpatient;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public WlyyPrescriptionExpressageDO checkOutPatientPre(String patientId) throws ParseException {
 | 
	
		
			
				|  |  |         String sql = "select t.id as \"id\",t.adm_no as \"admNo\",t.create_time as \"createTime\" from wlyy_outpatient t where 1=1";
 | 
	
		
			
				|  |  |         String startDate = DateUtil.getStringDateShort()+" 00:00:00";
 | 
	
		
			
				|  |  |         String endDate = DateUtil.getStringDateShort()+" 23:59:59";
 | 
	
		
			
				|  |  |         if ("xm_zsyy_wx".equalsIgnoreCase(wechatId)){
 | 
	
		
			
				|  |  |             sql+=" and t.create_time >= '" +startDate+"' "+
 | 
	
		
			
				|  |  |                     " and t.create_time <= '" +endDate+"' ";
 | 
	
		
			
				|  |  |         }else if("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
 | 
	
		
			
				|  |  |             sql+=" and  t.create_time >= to_char('"+startDate+"','yyyy-mm-dd hh:mm:ss')\n" +
 | 
	
		
			
				|  |  |                     "and t.create_time < to_char('"+endDate+"','yyyy-mm-dd hh:mm:ss')";
 | 
	
		
			
				|  |  |         }else {
 | 
	
		
			
				|  |  |             sql+=" and  t.create_time >= to_char('"+startDate+"','yyyy-mm-dd hh:mm:ss')\n" +
 | 
	
		
			
				|  |  |                     "and t.create_time < to_char('"+endDate+"','yyyy-mm-dd hh:mm:ss')";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (StringUtils.isNoneBlank(patientId)){
 | 
	
		
			
				|  |  |             sql+=" and t.patient = '"+patientId+"'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         sql +=" and t.outpatient_type = 1  order by t.create_time desc";
 | 
	
		
			
				|  |  |         System.out.println(sql);
 | 
	
		
			
				|  |  |         List<Map<String,Object>> listPrescript = hibenateUtils.createSQLQuery(sql);
 | 
	
		
			
				|  |  |         WlyyPrescriptionExpressageDO wlyyPrescriptionExpressageDO = new WlyyPrescriptionExpressageDO();
 | 
	
		
			
				|  |  |         if (listPrescript!=null&&listPrescript.size()>=1){
 | 
	
		
			
				|  |  |             Map<String,Object> mapPrescript = listPrescript.get(0);
 | 
	
		
			
				|  |  |             String outPatientId = mapPrescript.get("id").toString();
 | 
	
		
			
				|  |  |             List<WlyyPrescriptionExpressageDO> list =  prescriptionExpressageDao.findByOutpatientId(outPatientId);
 | 
	
		
			
				|  |  |             if(list!=null&&list.size()!=0){
 | 
	
		
			
				|  |  |                 wlyyPrescriptionExpressageDO = list.get(0);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return wlyyPrescriptionExpressageDO;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 创建候诊室
 | 
	
	
		
			
				|  | @ -1431,7 +1491,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 " JOIN base_doctor_role r ON r.doctor_code = d.id " +
 | 
	
		
			
				|  |  |                 " WHERE  " +
 | 
	
		
			
				|  |  |                 " h.org_code = '" + orgCode + "'" +
 | 
	
		
			
				|  |  |                 " AND r.role_code ='specialist'";
 | 
	
		
			
				|  |  |                 " AND r.role_code ='specialist' and d.del=1 ";
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(chargeType)) {
 | 
	
		
			
				|  |  |             if ("all".equalsIgnoreCase(chargeType)) {
 | 
	
		
			
				|  |  |                 //不过滤号别
 | 
	
	
		
			
				|  | @ -1496,7 +1556,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 " JOIN base_doctor_role r ON r.doctor_code = d.id " +
 | 
	
		
			
				|  |  |                 " WHERE  " +
 | 
	
		
			
				|  |  |                 " h.org_code = '" + orgCode + "'" +
 | 
	
		
			
				|  |  |                 " AND r.role_code ='specialist'";
 | 
	
		
			
				|  |  |                 " AND r.role_code ='specialist' and d.del=1 ";
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(chargeType)) {
 | 
	
		
			
				|  |  |             if ("all".equalsIgnoreCase(chargeType)) {
 | 
	
		
			
				|  |  |                 //不过滤号别
 | 
	
	
		
			
				|  | @ -1592,12 +1652,17 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 outpatientDao.save(outpatientDO);
 | 
	
		
			
				|  |  |                 //调用电子病历注册
 | 
	
		
			
				|  |  |                 manageType = 2;
 | 
	
		
			
				|  |  |                 registDianziBingli(outpatientDO, basePatientDO, manageType, registerDO.getRegisterNo(), registerDO.getConNo());
 | 
	
		
			
				|  |  |                 try {
 | 
	
		
			
				|  |  |                     registDianziBingli(outpatientDO, basePatientDO, manageType, registerDO.getRegisterNo(), registerDO.getConNo());
 | 
	
		
			
				|  |  |                 }catch (Exception e){
 | 
	
		
			
				|  |  |                     e.printStackTrace();
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 return res;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //下载银医通
 | 
	
		
			
				|  |  |         net.sf.json.JSONObject object1 = entranceService.qutpatientBalance(outpatientDO.getCardNo(), demoFlag);
 | 
	
		
			
				|  |  |         logger.info("下载银医通");
 | 
	
		
			
				|  |  |         net.sf.json.JSONObject rs = entranceService.BS10111(outpatientDO.getCardNo(), doctorMappingDO.getMappingCode(), outpatientDO.getDept(), null, outpatientDO.getWinNo(), demoFlag);
 | 
	
		
			
				|  |  |         net.sf.json.JSONObject res = rs.getJSONObject("resquest");
 | 
	
		
			
				|  |  |         logger.info("挂号结果 res: " + res.toString());
 | 
	
	
		
			
				|  | @ -1714,7 +1779,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 "<CardNO>" + outpatientDO.getCardNo() + "</CardNO>\n" +
 | 
	
		
			
				|  |  |                 "<PatientName>" + basePatientDO.getName() + "</PatientName>" +
 | 
	
		
			
				|  |  |                 "<SexCode>" + basePatientDO.getSex() + "</SexCode>";
 | 
	
		
			
				|  |  |         if (1 == basePatientDO.getSex()) {
 | 
	
		
			
				|  |  |         if (basePatientDO.getSex()!=null&&1 == basePatientDO.getSex()) {
 | 
	
		
			
				|  |  |             _xmlStr = _xmlStr + "<Sex>男</Sex>";
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             _xmlStr = _xmlStr + "<Sex>女</Sex>";
 | 
	
	
		
			
				|  | @ -1995,7 +2060,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |      * @param diagnosisJson
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Map<String, Object> makeDiagnosis(String outPatientId, String advice, String type, String infoJsons, String diagnosisJson, String inspectionJson, String emrJson) throws Exception {
 | 
	
		
			
				|  |  |     public Map<String, Object> makeDiagnosis(String outPatientId,String prescriptionId, String advice, String type, String infoJsons, String diagnosisJson, String inspectionJson, String emrJson) throws Exception {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Map<String, Object> result = new HashedMap();
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -2006,26 +2071,28 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //========================处方操作=============================================================
 | 
	
		
			
				|  |  |         //创建处方记录
 | 
	
		
			
				|  |  |         List<WlyyPrescriptionDO> prescriptionDOs = prescriptionDao.findByOutpatientId(outPatientId);
 | 
	
		
			
				|  |  |         WlyyPrescriptionDO prescriptionDO = null;
 | 
	
		
			
				|  |  |         if (prescriptionDOs != null && prescriptionDOs.size() > 0) {
 | 
	
		
			
				|  |  |             prescriptionDO = prescriptionDOs.get(0);
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             prescriptionDO = new WlyyPrescriptionDO();
 | 
	
		
			
				|  |  |         WlyyPrescriptionDO  prescriptionDO= new WlyyPrescriptionDO();
 | 
	
		
			
				|  |  |         /*List<WlyyPrescriptionDO> prescriptionDOs = prescriptionDao.findByOutpatientId(outPatientId);*/
 | 
	
		
			
				|  |  |         List<WlyyPrescriptionDO> wlyyPrescriptionDO1 = new ArrayList<>();
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(prescriptionId)){
 | 
	
		
			
				|  |  |             wlyyPrescriptionDO1 = prescriptionDao.findById(prescriptionId);
 | 
	
		
			
				|  |  |             prescriptionDO =wlyyPrescriptionDO1.get(0);
 | 
	
		
			
				|  |  |         }else{
 | 
	
		
			
				|  |  |             prescriptionDO.setOutpatientId(outPatientId);
 | 
	
		
			
				|  |  |             prescriptionDO.setType(1);
 | 
	
		
			
				|  |  |             prescriptionDO.setDept(outpatientDO.getDept());
 | 
	
		
			
				|  |  |             prescriptionDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |             prescriptionDO.setStatus(10);
 | 
	
		
			
				|  |  |             prescriptionDO.setPatientCode(outpatientDO.getPatient());
 | 
	
		
			
				|  |  |             prescriptionDO.setPatientName(outpatientDO.getPatientName());
 | 
	
		
			
				|  |  |             prescriptionDO.setDoctor(outpatientDO.getDoctor());
 | 
	
		
			
				|  |  |             prescriptionDO.setDoctorName(outpatientDO.getDoctorName());
 | 
	
		
			
				|  |  |             prescriptionDO.setPayStatus(0);
 | 
	
		
			
				|  |  |             if (wechatId.equalsIgnoreCase("xm_ykyy_wx")) {
 | 
	
		
			
				|  |  |                 prescriptionDO.setAdmNo(outpatientDO.getAdmNo());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         prescriptionDO.setType(1);
 | 
	
		
			
				|  |  |         prescriptionDO.setDept(outpatientDO.getDept());
 | 
	
		
			
				|  |  |         prescriptionDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |         prescriptionDO.setStatus(10);
 | 
	
		
			
				|  |  |         prescriptionDO.setPatientCode(outpatientDO.getPatient());
 | 
	
		
			
				|  |  |         prescriptionDO.setPatientName(outpatientDO.getPatientName());
 | 
	
		
			
				|  |  |         prescriptionDO.setDoctor(outpatientDO.getDoctor());
 | 
	
		
			
				|  |  |         prescriptionDO.setDoctorName(outpatientDO.getDoctorName());
 | 
	
		
			
				|  |  |         prescriptionDO.setPayStatus(0);
 | 
	
		
			
				|  |  |         if (wechatId.equalsIgnoreCase("xm_ykyy_wx")) {
 | 
	
		
			
				|  |  |             prescriptionDO.setAdmNo(outpatientDO.getAdmNo());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         WlyyPrescriptionDO prescription = prescriptionDao.save(prescriptionDO);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //========================处方操作结束=============================================================
 | 
	
	
		
			
				|  | @ -2080,7 +2147,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             savePrescriptionCheck(prescription.getDoctor(), "开具处方", 5, prescription.getId());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (prescriptionDOs != null && prescriptionDOs.size() > 0) {
 | 
	
		
			
				|  |  |         if (wlyyPrescriptionDO1 != null && wlyyPrescriptionDO1.size() > 0) {
 | 
	
		
			
				|  |  |             savePrescriptionCheck(prescription.getDoctor(), "处方修改", 3, prescription.getId());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -2136,16 +2203,16 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             if (StringUtils.isNotBlank(inspectionJson)) {
 | 
	
		
			
				|  |  |                 List<WlyyInspectionDO> inspections = (List<WlyyInspectionDO>) com.alibaba.fastjson.JSONArray.parseArray(inspectionJson, WlyyInspectionDO.class);
 | 
	
		
			
				|  |  |                 for (WlyyInspectionDO ins : inspections) {
 | 
	
		
			
				|  |  |                     YkEmrJcsqDO ykEmrJcsqDO =new YkEmrJcsqDO();
 | 
	
		
			
				|  |  |                     ins.setDel(1);
 | 
	
		
			
				|  |  |                     ins.setCreateTime(new Date());
 | 
	
		
			
				|  |  |                     ins.setPrescriptionId(prescription.getId());
 | 
	
		
			
				|  |  |                     ins.setOutpatientId(outPatientId);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 //保存检查检验。
 | 
	
		
			
				|  |  |                 wlyyInspectionDao.save(inspections);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 //计算检查检验费用
 | 
	
		
			
				|  |  |                 prescription.setInspectFee(getInsFee(inspections));
 | 
	
		
			
				|  |  |             }
 | 
	
	
		
			
				|  | @ -2177,6 +2244,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 result.put("code", 1);
 | 
	
		
			
				|  |  |                 result.put("mes", "诊断完成");
 | 
	
		
			
				|  |  |                 result.put("prescriptionId",prescription.getId());
 | 
	
		
			
				|  |  |                 return result;
 | 
	
		
			
				|  |  |             } else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")) {
 | 
	
		
			
				|  |  |                 Double price = prescription.getDrugFee();
 | 
	
	
		
			
				|  | @ -2187,6 +2255,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 Map<String, Object> result1 = new HashedMap();
 | 
	
		
			
				|  |  |                 result1.put("code", 1);
 | 
	
		
			
				|  |  |                 result1.put("mes", "开方提交成功");
 | 
	
		
			
				|  |  |                 result1.put("prescriptionId",prescription.getId());
 | 
	
		
			
				|  |  |                 return result1;
 | 
	
		
			
				|  |  |             } else if (wechatId.equalsIgnoreCase("xm_xzzx_wx")) {
 | 
	
		
			
				|  |  |                 Double price = prescription.getDrugFee();
 | 
	
	
		
			
				|  | @ -2197,10 +2266,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 Map<String, Object> result1 = new HashedMap();
 | 
	
		
			
				|  |  |                 result1.put("code", 1);
 | 
	
		
			
				|  |  |                 result1.put("mes", "开方提交成功");
 | 
	
		
			
				|  |  |                 result1.put("prescriptionId",prescription.getId());
 | 
	
		
			
				|  |  |                 return result1;
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 result.put("code", 1);
 | 
	
		
			
				|  |  |                 result.put("mes", "诊断完成");
 | 
	
		
			
				|  |  |                 result.put("prescriptionId",prescription.getId());
 | 
	
		
			
				|  |  |                 return result;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -2210,6 +2281,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             outpatientDao.save(outpatientDO);
 | 
	
		
			
				|  |  |             result.put("code", 1);
 | 
	
		
			
				|  |  |             result.put("mes", "诊断完成");
 | 
	
		
			
				|  |  |             result.put("prescriptionId",prescription.getId());
 | 
	
		
			
				|  |  |             return result;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -3489,12 +3561,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 if ("1".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
 | 
	
		
			
				|  |  |                     data.put("type", "9");
 | 
	
		
			
				|  |  |                     msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个图文复诊已被医生取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
 | 
	
		
			
				|  |  |                     sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "9", "doctorRefuseRemind", "");
 | 
	
		
			
				|  |  |                     sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "9", "doctorRefuseRemind", cancelRemark);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 if ("2".equalsIgnoreCase(wlyyOutpatientDO.getType())) {
 | 
	
		
			
				|  |  |                     data.put("type", "16");
 | 
	
		
			
				|  |  |                     msg += wlyyOutpatientDO.getPatientName() + ",您好! 您有一个视频复诊已被医生取消,取消原因:" + cancelValue + "。取消说明:" + cancelRemark + "。";
 | 
	
		
			
				|  |  |                     sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "16", "doctorRefuseRemind", "");
 | 
	
		
			
				|  |  |                     sendWxTemplateMsg(wechatId, wlyyOutpatientDO.getId(),null, "16", "doctorRefuseRemind", cancelRemark);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 data.put("msg", msg);
 | 
	
		
			
				|  |  |                 messageDO.setData(data.toString());
 | 
	
	
		
			
				|  | @ -3585,26 +3657,31 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         String remark = "";
 | 
	
		
			
				|  |  |         if ("doctorRefuseRemind".equalsIgnoreCase(titelType)) {
 | 
	
		
			
				|  |  |             if ("9".equals(type)) {
 | 
	
		
			
				|  |  |                 contentMsg = "您的图文复诊订单已被医生取消,您可重新发起。由于订单取消将不做扣费处理";
 | 
	
		
			
				|  |  |                 contentMsg = "医生已取消您的复诊申请,取消原因:"+remindMsg;
 | 
	
		
			
				|  |  |                 first = outpatientDO.getPatientName() + ",您好!您的图文复诊已取消";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if ("16".equals(type)) {
 | 
	
		
			
				|  |  |                 contentMsg = "您的视频复诊订单已被医生取消,您可重新发起。由于订单取消将不做扣费处理";
 | 
	
		
			
				|  |  |                 contentMsg = "医生已取消您的复诊申请,取消原因:"+remindMsg;
 | 
	
		
			
				|  |  |                 first = outpatientDO.getPatientName() + ",您好!您的视频复诊已取消";
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             logger.info("doctorRefuseRemind医生拒诊入参:outpatientId="+outpatientId);
 | 
	
		
			
				|  |  |             msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
 | 
	
		
			
				|  |  |         } else if("outPatientTimeOutRemind".equalsIgnoreCase(titelType)) {
 | 
	
		
			
				|  |  |             contentMsg = "您邀请的医师暂无应答,您可以选择继续等待或者取消邀请。";
 | 
	
		
			
				|  |  |             first = outpatientDO.getPatientName() + ",您好!";
 | 
	
		
			
				|  |  |             logger.info("outPatientTimeOutRemind:outpatientId="+outpatientId+"contentMsg"+contentMsg);
 | 
	
		
			
				|  |  |             msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
 | 
	
		
			
				|  |  |         } else if ("payRemind".equalsIgnoreCase(titelType)) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if ("9".equals(type)) {
 | 
	
		
			
				|  |  |                 contentMsg = "您有一个图文复诊订单待支付,点击完成支付,如您已支付请忽略本条信息";
 | 
	
		
			
				|  |  |                 first = outpatientDO.getPatientName() + ",您好!您有一个图文复诊订单待支付,请及时支付。";
 | 
	
		
			
				|  |  |                 contentMsg = "请您先完成预交金充值发起在线问诊,点击详情进行预交金充值,如您已完成请忽略本条信息。";//您有一个图文复诊订单待支付,点击完成支付,如您已支付请忽略本条信息
 | 
	
		
			
				|  |  |                 first = outpatientDO.getPatientName() + ",您好!您有一笔未完成的在线问诊订单,请及时处理。";//您有一个图文复诊订单待支付,请及时支付。
 | 
	
		
			
				|  |  |                 msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
 | 
	
		
			
				|  |  |                 logger.info("图文复诊订单待支付微信消息模板推送开始");
 | 
	
		
			
				|  |  |             } else if ("16".equals(type)) {
 | 
	
		
			
				|  |  |                 contentMsg = "您有一个视频复诊订单待支付,点击完成支付,如您已支付请忽略本条信息";
 | 
	
		
			
				|  |  |                 first = outpatientDO.getPatientName() + ",您好!您有一个视频复诊订单待支付,请及时支付。";
 | 
	
		
			
				|  |  |                 contentMsg = "请您先完成预交金充值发起在线问诊,点击详情进行预交金充值,如您已完成请忽略本条信息。";//您有一个视频复诊订单待支付,点击完成支付,如您已支付请忽略本条信息
 | 
	
		
			
				|  |  |                 first = outpatientDO.getPatientName() + ",您好!您有一笔未完成的在线问诊订单,请及时处理。";//您有一个视频复诊订单待支付,请及时支付。
 | 
	
		
			
				|  |  |                 msgUrl="/ims-wx/index.html#/returnVisit/record?outpatientId="+outpatientId;
 | 
	
		
			
				|  |  |                 logger.info("视频复诊订单待支付微信消息模板推送开始");
 | 
	
		
			
				|  |  |             }
 | 
	
	
		
			
				|  | @ -3624,7 +3701,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             first = outpatientDO.getPatientName() + ",您好! 医生已为您开具处方,请及时支付。";
 | 
	
		
			
				|  |  |             contentMsg = "医生已为您开具处方,请及时支付。";
 | 
	
		
			
				|  |  |             remark = "点击完成支付,如您已支付请忽略本条信息";
 | 
	
		
			
				|  |  |             msgUrl="/ims-wx/index.html#/returnVisit/prescriptionDetail?outpatientId="+outpatientId;
 | 
	
		
			
				|  |  |             msgUrl="/ims-wx/index.html#/returnVisit/prescriptionDetail?outpatientId="+outpatientId+"&id="+remindMsg;
 | 
	
		
			
				|  |  |             logger.info("处方支付微信消息模板推送开始");
 | 
	
		
			
				|  |  |         } else if ("msgRemind".equalsIgnoreCase(titelType)) {
 | 
	
		
			
				|  |  |             first = outpatientDO.getPatientName() + ",您好!";
 | 
	
	
		
			
				|  | @ -3717,6 +3794,13 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 //发起微信消息模板推送
 | 
	
		
			
				|  |  |                 newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
 | 
	
		
			
				|  |  |                 logger.info("眼科微信消息模板推送 医生拒诊开始");
 | 
	
		
			
				|  |  |             }else if("outPatientTimeOutRemind".equals(titelType)){
 | 
	
		
			
				|  |  |                 //就诊等待过长提示
 | 
	
		
			
				|  |  |                 scene="jzddgcts";
 | 
	
		
			
				|  |  |                 WxTemplateConfigDO config = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, "template_outpatient_timeout_remind", scene, 1);
 | 
	
		
			
				|  |  |                 BeanUtils.copyProperties(config, newConfig);
 | 
	
		
			
				|  |  |                 newConfig.setUrl(newConfig.getUrl() + "" + outpatientDO.getId());
 | 
	
		
			
				|  |  |                 logger.info("就诊等待过长提示");
 | 
	
		
			
				|  |  |             } else if ("payRemind".equalsIgnoreCase(titelType)) {
 | 
	
		
			
				|  |  |                 scene = "zxzfts";
 | 
	
		
			
				|  |  |                 //就诊支付
 | 
	
	
		
			
				|  | @ -3893,7 +3977,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         } else if ("xm_xzzx_wx".equalsIgnoreCase(wxId)) {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String responseMsg="";
 | 
	
		
			
				|  |  |             String prefix="https://www.xmheart.com";
 | 
	
		
			
				|  |  |             //String prefix="https://www.xmheart.com";
 | 
	
		
			
				|  |  |             String prefix = "https://ih.xmheart.com";
 | 
	
		
			
				|  |  |             if(StringUtils.isNotEmpty(outpatientId)){
 | 
	
		
			
				|  |  |                 responseMsg = xzzxEntranceService.sendXCXMes(wxId,
 | 
	
		
			
				|  |  |                         patientDO.getId(),
 | 
	
	
		
			
				|  | @ -3915,16 +4000,13 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                         prefix+msgUrl,
 | 
	
		
			
				|  |  |                         "wx53f6bb4ac081d840");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             logger.info("url="+prefix+msgUrl);
 | 
	
		
			
				|  |  |             String msg="first:"+first+"contentMsg:"+contentMsg+"remark:"+remark;
 | 
	
		
			
				|  |  |             logger.info("发送的信息="+msg);
 | 
	
		
			
				|  |  |             logger.info("XZZX_Msg_" + titelType + "=" + responseMsg);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         } else if ("xm_zsyy_wx".equalsIgnoreCase(wxId)) {
 | 
	
		
			
				|  |  |             if ("prescriptionPayRemind".equalsIgnoreCase(titelType)){
 | 
	
		
			
				|  |  |                 return;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String responseMsg="";
 | 
	
		
			
				|  |  |             String prefix="https://hlwyy.xmzsh.com";
 | 
	
		
			
				|  |  |             if(StringUtils.isNotEmpty(outpatientId)){
 | 
	
	
		
			
				|  | @ -3937,6 +4019,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                         contentMsg,
 | 
	
		
			
				|  |  |                         remark
 | 
	
		
			
				|  |  |                 );
 | 
	
		
			
				|  |  |                 System.out.println("结束发送模板消息");
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (consultTeam!=null&&consPatientDO!=null){
 | 
	
		
			
				|  |  |                 responseMsg = entranceService.ehospitalNotice(
 | 
	
	
		
			
				|  | @ -4584,7 +4667,12 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 " base_doctor d " +
 | 
	
		
			
				|  |  |                 " JOIN base_doctor_hospital h ON h.doctor_code = d.id " +
 | 
	
		
			
				|  |  |                 " Left join ( select count(id) as total,doctor from wlyy_outpatient where status = 3 GROUP BY doctor ) a on a.doctor = d.id ";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Map<String, Object> params = new HashedMap();
 | 
	
		
			
				|  |  |         Date date = new Date();
 | 
	
		
			
				|  |  |         sql+="LEFT JOIN (SELECT  COUNT(t1.doctor) as workTotal, t1.doctor FROM  wlyy_doctor_work_time t1   WHERE   " +
 | 
	
		
			
				|  |  |                 "t1.start_time <=:startTime  AND t1.end_time >=:endTime GROUP BY t1.doctor) dw ON dw.doctor=d.id ";
 | 
	
		
			
				|  |  |         params.put("startTime", date);
 | 
	
		
			
				|  |  |         params.put("endTime", date);
 | 
	
		
			
				|  |  |         if ("1".equalsIgnoreCase(isAttention)) {
 | 
	
		
			
				|  |  |             sql += " join base_doctor_patient_follow follow on follow.doctor = d.id and follow.patient ='" + patientid + "' ";
 | 
	
		
			
				|  |  |         }
 | 
	
	
		
			
				|  | @ -4603,9 +4691,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             sql += " JOIN wlyy_doctor_work_time wk on wk.doctor = d.id ";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         sql += " WHERE  1=1 ";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Map<String, Object> params = new HashedMap();
 | 
	
		
			
				|  |  |         sql += " WHERE  1=1 ";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (StringUtils.isBlank(chargType)) {
 | 
	
		
			
				|  |  |             sql += " AND d.charge_type is not null ";
 | 
	
	
		
			
				|  | @ -4621,7 +4708,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(iswork) && "1".equals(iswork)) {
 | 
	
		
			
				|  |  |             logger.info("iswork:" + iswork);
 | 
	
		
			
				|  |  |             Date date = new Date();
 | 
	
		
			
				|  |  |             sql += " AND (" +
 | 
	
		
			
				|  |  |                     " EXISTS ( " +
 | 
	
		
			
				|  |  |                     " SELECT " +
 | 
	
	
		
			
				|  | @ -4697,9 +4783,32 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         sql += " and d.del='1' order by a.total " + consutlSort;
 | 
	
		
			
				|  |  |         sql += " and d.del='1' order by dw.workTotal desc,d.consult_status DESC,a.total " + consutlSort;
 | 
	
		
			
				|  |  |         String sqlCount = "select count(1) as \"total\" from ( "+sql+" ) t";
 | 
	
		
			
				|  |  |         List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql, params, page, pagesize);
 | 
	
		
			
				|  |  |         for (Map<String,Object> map:list){
 | 
	
		
			
				|  |  |             String doctor = map.get("id").toString();
 | 
	
		
			
				|  |  |             //查询医生各项评价平均分
 | 
	
		
			
				|  |  |             String sqlscore = "SELECT " +
 | 
	
		
			
				|  |  |                     "AVG(a.score) AS \"score\"," +
 | 
	
		
			
				|  |  |                     "a.score_type AS \"score_type\" " +
 | 
	
		
			
				|  |  |                     "FROM base_evaluate a,base_evaluate_score b " +
 | 
	
		
			
				|  |  |                     "WHERE " +
 | 
	
		
			
				|  |  |                     "a.relation_code=b.id " +
 | 
	
		
			
				|  |  |                     "AND b.doctor='" + doctor + "' " +
 | 
	
		
			
				|  |  |                     "GROUP BY a.score_type ORDER BY  a.score_type ASC ";
 | 
	
		
			
				|  |  |             List<Map<String, Object>> listscore = jdbcTemplate.queryForList(sqlscore);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             Double doctorScore = new Double("0");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if (listscore != null && listscore.size() > 0) {
 | 
	
		
			
				|  |  |                 for (Map<String, Object> _listscore : listscore) {
 | 
	
		
			
				|  |  |                     doctorScore += Double.parseDouble(_listscore.get("score").toString());
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             doctorScore = doctorScore / 3;
 | 
	
		
			
				|  |  |             map.put("doctorScore", doctorScore);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         List<Map<String, Object>> listCount = hibenateUtils.createSQLQuery(sqlCount, params);
 | 
	
		
			
				|  |  |         Long count = 0L;
 | 
	
		
			
				|  |  |         if(listCount!=null){
 | 
	
	
		
			
				|  | @ -5552,19 +5661,18 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |      *
 | 
	
		
			
				|  |  |      * @param admNo     门诊唯一号
 | 
	
		
			
				|  |  |      * @param realOrder 处方号
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Object getSFExpressInfo(String admNo, String realOrder, String wxId) throws Exception {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //根据门诊唯一号取就诊记录
 | 
	
		
			
				|  |  | //        List<WlyyOutpatientDO> wlyyOutpatientDOs = outpatientDao.findByAdmNo(admNo);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         WlyyPrescriptionDO wlyyPrescriptionDOS = prescriptionDao.findByAdmNoAndRealOrder(admNo, realOrder);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<WlyyPrescriptionDO> wlyyPrescriptionDOList = prescriptionDao.findByRealOrderList(realOrder);
 | 
	
		
			
				|  |  |         Object result = "";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         System.out.println("获取顺丰物流面单信息:wlyyPrescriptionDOS != null=" + wlyyPrescriptionDOS != null);
 | 
	
		
			
				|  |  |         if (wlyyPrescriptionDOS != null) {
 | 
	
		
			
				|  |  |         System.out.println("获取顺丰物流面单信息:wlyyPrescriptionDOS != null=" + wlyyPrescriptionDOList != null);
 | 
	
		
			
				|  |  |         if (wlyyPrescriptionDOList != null&&wlyyPrescriptionDOList.size()!=0) {
 | 
	
		
			
				|  |  |             WlyyPrescriptionDO wlyyPrescriptionDOS = wlyyPrescriptionDOList.get(0);
 | 
	
		
			
				|  |  |             List<WlyyPrescriptionExpressageDO> expressageDOList = sfexpressService.findByField("outpatientId", wlyyPrescriptionDOS.getOutpatientId());
 | 
	
		
			
				|  |  |             WlyyPrescriptionExpressageDO sfexpress_obj = null;
 | 
	
		
			
				|  |  |             System.out.println("获取顺丰物流面单信息:CollectionUtils.isEmpty(expressageDOList)=" + CollectionUtils.isEmpty(expressageDOList));
 | 
	
	
		
			
				|  | @ -5574,7 +5682,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                 System.out.println("获取顺丰物流面单信息:1");
 | 
	
		
			
				|  |  |                 sfexpress_obj = expressageDOList.get(0);
 | 
	
		
			
				|  |  |                 System.out.println("获取顺丰物流面单信息:2");
 | 
	
		
			
				|  |  |                 BasePatientDO basePatientDO = basePatientDao.findById(wlyyPrescriptionDOS.getPatientCode());
 | 
	
		
			
				|  |  |                 //如果该处方的快递单号已生成,则说明已经下单成功,不需要重复下单,直接返回面单信息
 | 
	
		
			
				|  |  |                 System.out.println("获取顺丰物流面单信息:3");
 | 
	
		
			
				|  |  |                 if (org.apache.commons.lang.StringUtils.isNotBlank(sfexpress_obj.getMailno())) {
 | 
	
	
		
			
				|  | @ -5603,9 +5710,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                     System.out.println("获取顺丰物流面单信息:6");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 wlyyPrescriptionDOS.setStatus(32);
 | 
	
		
			
				|  |  |                 prescriptionDao.save(wlyyPrescriptionDOS);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 for (WlyyPrescriptionDO prescriptionDO:wlyyPrescriptionDOList){
 | 
	
		
			
				|  |  |                     prescriptionDO.setStatus(32);
 | 
	
		
			
				|  |  |                     prescriptionDao.save(prescriptionDO);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 if (sfexpress_obj != null && StringUtils.isNoneBlank(sfexpress_obj.getMailno())) {
 | 
	
		
			
				|  |  |                     com.alibaba.fastjson.JSONObject object = sfexpressService.postSFOrderQueryService(sfexpress_obj);
 | 
	
		
			
				|  |  |                     System.out.println("获取顺丰物流面单信息7-1"+object.toJSONString());
 | 
	
	
		
			
				|  | @ -6754,7 +6862,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |      * @param name
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public List<Map<String, Object>> findDoctorByName(String hospital, String name, String chargeType) {
 | 
	
		
			
				|  |  |     public List<Map<String, Object>> findDoctorByName(String hospital, String name, String chargeType,String dept) {
 | 
	
		
			
				|  |  |         String sql = "SELECT " +
 | 
	
		
			
				|  |  |                 " d.id AS \"id\", " +
 | 
	
		
			
				|  |  |                 " d.name AS \"name\"" +
 | 
	
	
		
			
				|  | @ -6769,6 +6877,9 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(hospital)) {
 | 
	
		
			
				|  |  |             sql += " AND h.org_code ='" + hospital + "'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(StringUtils.isNotBlank(dept)){
 | 
	
		
			
				|  |  |             sql+= " AND h.dept_code = '"+dept+"'";
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (StringUtils.isNotBlank(chargeType)) {
 | 
	
		
			
				|  |  |             if ("all".equals(chargeType)) {
 | 
	
	
		
			
				|  | @ -7043,7 +7154,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                     List<WlyyPrescriptionInfoDO> infoDOS = prescriptionInfoDao.findByPrescriptionId(prescriptionId, 1);
 | 
	
		
			
				|  |  |                     List<WlyyInspectionDO> inspectionDOS = wlyyInspectionDao.findByPrescriptionId(prescriptionId, 1);
 | 
	
		
			
				|  |  |                     DoctorMappingDO doctorMappingDO = doctorMappingService.findMappingCode(outpatientDO.getDoctor(), outpatientDO.getHospital());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     List<WlyyPrescriptionExpressageDO> expressageDOS = prescriptionExpressageDao.findByOutpatientId(outpatientDO.getId());
 | 
	
		
			
				|  |  |                     //his处方拼接开方条件
 | 
	
		
			
				|  |  |                     com.alibaba.fastjson.JSONArray jsonData = new com.alibaba.fastjson.JSONArray();
 | 
	
		
			
				|  |  |                     for (WlyyPrescriptionInfoDO info : infoDOS) {
 | 
	
	
		
			
				|  | @ -7054,12 +7165,31 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |                         //设置his药品查询条件
 | 
	
		
			
				|  |  |                         setInspectionParam(jsonData, doctorMappingDO, outpatientDO, wlyyPrescriptionDO, ins, outpatientDO.getIcd10());
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     if (expressageDOS!=null&&expressageDOS.size()!=0){
 | 
	
		
			
				|  |  |                         WlyyPrescriptionExpressageDO prescriptionExpressageDO = expressageDOS.get(0);
 | 
	
		
			
				|  |  |                         if (prescriptionExpressageDO!=null&&prescriptionExpressageDO.getOneselfPickupFlg()==0){
 | 
	
		
			
				|  |  |                             for (int i=0;i<jsonData.size();i++){
 | 
	
		
			
				|  |  |                                 com.alibaba.fastjson.JSONObject object = jsonData.getJSONObject(i);
 | 
	
		
			
				|  |  |                                 object.put("selfDelivered",0);
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  |                         }else if (prescriptionExpressageDO!=null&&prescriptionExpressageDO.getOneselfPickupFlg()==1){
 | 
	
		
			
				|  |  |                             for (int i=0;i<jsonData.size();i++){
 | 
	
		
			
				|  |  |                                 com.alibaba.fastjson.JSONObject object = jsonData.getJSONObject(i);
 | 
	
		
			
				|  |  |                                 object.put("selfDelivered",1);
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     Map<String, Object> map = sendHisDiagnosis(jsonData, outpatientDO, wlyyPrescriptionDO);
 | 
	
		
			
				|  |  |                     //处方签名
 | 
	
		
			
				|  |  |                     logger.info("处方签名");
 | 
	
		
			
				|  |  |                     SOF_SignDataWithExtraInfo(wlyyPrescriptionDO);
 | 
	
		
			
				|  |  |                     //同步电子病历
 | 
	
		
			
				|  |  |                     WlyyPrescriptionEmrDO prescriptionEmrDO = prescriptionEmrDao.findEmrByPrescriptionId(prescriptionId);
 | 
	
		
			
				|  |  |                     if (prescriptionEmrDO != null) {
 | 
	
		
			
				|  |  |                         String doctorId = doctorMappingDO.getMappingCode();
 | 
	
		
			
				|  |  |                         String doctorName = doctorMappingDO.getDoctorName();
 | 
	
		
			
				|  |  |                         logger.info("电子病历签名");
 | 
	
		
			
				|  |  |                         SOF_SignDataWithExtraInfoEmr(prescriptionEmrDO);
 | 
	
		
			
				|  |  |                         writeOutPatient(outpatientDO.getRegisterNo(), prescriptionEmrDO.getComplaint(), prescriptionEmrDO.getMedicalHistory(), prescriptionEmrDO.getPastHistory(), prescriptionEmrDO.getPhysicalExamination(), prescriptionEmrDO.getAssistExamination(), doctorId, doctorName);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     if (map.get("code").toString().equalsIgnoreCase("1")) {
 | 
	
	
		
			
				|  | @ -7136,7 +7266,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |             if ("xm_ykyy_wx".equalsIgnoreCase(wxId)) {
 | 
	
		
			
				|  |  |                 ykyyService.pushNotificationToYktPatient(patient.getYktId(), messageDO.getTitle(), data.get("msg").toString());
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             sendWxTemplateMsg(wxId, outpatientDO.getId(), null,"", "prescriptionPayRemind", "");
 | 
	
		
			
				|  |  |             sendWxTemplateMsg(wxId, outpatientDO.getId(), null,"", "prescriptionPayRemind", wlyyPrescriptionDO.getId());
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             wlyyPrescriptionDO.setId(prescriptionId);
 | 
	
		
			
				|  |  |             wlyyPrescriptionDO.setCheckStatus(status);
 | 
	
	
		
			
				|  | @ -7538,7 +7668,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public com.alibaba.fastjson.JSONObject outpatient(String patient) throws Exception {
 | 
	
		
			
				|  |  |     public net.sf.json.JSON outpatient(String patient) throws Exception {
 | 
	
		
			
				|  |  |         PatientMappingDO mappingDO = patientMappingDao.findByPatient(patient);
 | 
	
		
			
				|  |  |         String url = "";
 | 
	
		
			
				|  |  |         WlyyHospitalSysDictDO wlyyHospitalSysDictDO = hospitalSysDictDao.findById("HAI_TAI_OUTPATIENT_URL");
 | 
	
	
		
			
				|  | @ -7562,8 +7692,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         XMLSerializer xmlSerializer = new XMLSerializer();
 | 
	
		
			
				|  |  |         net.sf.json.JSON json = xmlSerializer.read(returnValue);
 | 
	
		
			
				|  |  |         logger.info("返回json" + json);
 | 
	
		
			
				|  |  |         com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(json.toString());
 | 
	
		
			
				|  |  |         return object;
 | 
	
		
			
				|  |  |         return json;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -7573,7 +7702,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public com.alibaba.fastjson.JSONObject outpmedicaldoc(String patient) throws Exception {
 | 
	
		
			
				|  |  |     public net.sf.json.JSON outpmedicaldoc(String patient) throws Exception {
 | 
	
		
			
				|  |  |         PatientMappingDO mappingDO = patientMappingDao.findByPatient(patient);
 | 
	
		
			
				|  |  |         String url = "";
 | 
	
		
			
				|  |  |         WlyyHospitalSysDictDO wlyyHospitalSysDictDO = hospitalSysDictDao.findById("HAI_TAI_OUTPATIENT_URL");
 | 
	
	
		
			
				|  | @ -7597,12 +7726,11 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         XMLSerializer xmlSerializer = new XMLSerializer();
 | 
	
		
			
				|  |  |         net.sf.json.JSON json = xmlSerializer.read(returnValue);
 | 
	
		
			
				|  |  |         logger.info("返回json" + json);
 | 
	
		
			
				|  |  |         com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(json.toString());
 | 
	
		
			
				|  |  |         return object;
 | 
	
		
			
				|  |  |         return json;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public com.alibaba.fastjson.JSONObject getPatInfoDataXml(String opid,String recSn) throws Exception {
 | 
	
		
			
				|  |  |     public net.sf.json.JSON getPatInfoDataXml(String opid,String recSn) throws Exception {
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String url = "";
 | 
	
		
			
				|  |  |         WlyyHospitalSysDictDO wlyyHospitalSysDictDO = hospitalSysDictDao.findById("HAI_TAI_OUTPATIENT_URL");
 | 
	
	
		
			
				|  | @ -7617,19 +7745,17 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         String returnValue = "";
 | 
	
		
			
				|  |  |         Map<String, String> params = new HashedMap();
 | 
	
		
			
				|  |  |         params.put("type", "getPatInfoDataXml");
 | 
	
		
			
				|  |  |         params.put("data", data);
 | 
	
		
			
				|  |  |         returnValue = com.yihu.jw.utils.WebserviceUtil.post(url,
 | 
	
		
			
				|  |  |                 "http://business.htemr.haitaiinc.com",
 | 
	
		
			
				|  |  |                 "manageEmrDataAll",
 | 
	
		
			
				|  |  |                 "getPatInfoDataXml",
 | 
	
		
			
				|  |  |                 params);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         logger.info("门诊病历列表信息,返回值xmlstr:" + returnValue);
 | 
	
		
			
				|  |  |         XMLSerializer xmlSerializer = new XMLSerializer();
 | 
	
		
			
				|  |  |         net.sf.json.JSON json = xmlSerializer.read(returnValue);
 | 
	
		
			
				|  |  |         logger.info("返回json" + json);
 | 
	
		
			
				|  |  |         com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(json.toString());
 | 
	
		
			
				|  |  |         return object;
 | 
	
		
			
				|  |  |         return json;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public String writeOutPatient(String registerSn, String chiefComplaint, String hpi, String elapsemhis, String bodycheck, String assistanTcheck, String doctorId, String doctorName) throws Exception {
 | 
	
	
		
			
				|  | @ -8079,4 +8205,136 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
 | 
	
		
			
				|  |  |         return MixEnvelop.getSuccess(IotRequestMapping.Common.message_success_find, res);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 处方签名
 | 
	
		
			
				|  |  |      * @param prescriptionDO
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public void SOF_SignDataWithExtraInfo(WlyyPrescriptionDO prescriptionDO) throws Exception {
 | 
	
		
			
				|  |  |         DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(prescriptionDO.getDoctor());
 | 
	
		
			
				|  |  |         BaseDoctorDO doctorDO = baseDoctorDao.findById(prescriptionDO.getDoctor());
 | 
	
		
			
				|  |  |         BasePatientDO patientDO = basePatientDao.findById(prescriptionDO.getPatientCode());
 | 
	
		
			
				|  |  |         WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(prescriptionDO.getOutpatientId());
 | 
	
		
			
				|  |  |         PKIService_ServiceLocator locator = new PKIService_ServiceLocator();
 | 
	
		
			
				|  |  |         URL portAddress = new URL("http://192.0.33.91:8080/pkis/services/v1?wsdl");
 | 
	
		
			
				|  |  |         PKIService_PortType service = locator.getPKIServiceImplPort(portAddress);
 | 
	
		
			
				|  |  |         WlyyOutpatientDO outpatientDO = outpatientDao.findById(prescriptionDO.getOutpatientId());
 | 
	
		
			
				|  |  |         List<WlyyPrescriptionInfoDO> infoDOS = prescriptionInfoDao.findByPrescriptionId(prescriptionDO.getId(), 1);
 | 
	
		
			
				|  |  |         List<WlyyInspectionDO> inspectionDOS = wlyyInspectionDao.findByPrescriptionId(prescriptionDO.getId(), 1);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //his处方拼接开方条件
 | 
	
		
			
				|  |  |         com.alibaba.fastjson.JSONArray jsonData = new com.alibaba.fastjson.JSONArray();
 | 
	
		
			
				|  |  |         for (WlyyPrescriptionInfoDO info : infoDOS) {
 | 
	
		
			
				|  |  |             //设置his药品查询条件
 | 
	
		
			
				|  |  |             setInfoJsonParam(jsonData, doctorMappingDO, outpatientDO, prescriptionDO, info, outpatientDO.getIcd10());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         for (WlyyInspectionDO ins : inspectionDOS) {
 | 
	
		
			
				|  |  |             //设置his药品查询条件
 | 
	
		
			
				|  |  |             setInspectionParam(jsonData, doctorMappingDO, outpatientDO, prescriptionDO, ins, outpatientDO.getIcd10());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         // 1.1.1 服务端签名(带取证查询扩展信息)
 | 
	
		
			
				|  |  |         // inData 参数
 | 
	
		
			
				|  |  |         String inData = jsonData.toJSONString();
 | 
	
		
			
				|  |  |         inData = org.apache.commons.codec.binary.Base64.encodeBase64String(inData.getBytes("gbk"));
 | 
	
		
			
				|  |  |         // extInfo  参数
 | 
	
		
			
				|  |  |         String idCardNo = "123502004266006872;"+doctorDO.getIdcard();
 | 
	
		
			
				|  |  |         Map<String, String> extInfoMap = new HashMap<String, String>();
 | 
	
		
			
				|  |  |         extInfoMap.put("busSys", "ZhongJianXinLianHLWYY");
 | 
	
		
			
				|  |  |         extInfoMap.put("doctorNo", doctorMappingDO!=null?doctorMappingDO.getMappingCode():null);
 | 
	
		
			
				|  |  |         extInfoMap.put("doctorName", doctorMappingDO!=null?doctorMappingDO.getDoctorName():null);
 | 
	
		
			
				|  |  |         extInfoMap.put("deptName", "部门");
 | 
	
		
			
				|  |  |         extInfoMap.put("patientName", patientDO!=null?patientDO.getName():null);
 | 
	
		
			
				|  |  |         extInfoMap.put("patientSex", patientDO!=null?IdCardUtil.getSexForIdcard(patientDO.getIdcard()):null);
 | 
	
		
			
				|  |  |         extInfoMap.put("hospitalNo", wlyyOutpatientDO!=null?wlyyOutpatientDO.getOriginAdmNo():null);
 | 
	
		
			
				|  |  |         extInfoMap.put("hospitalNumber",  wlyyOutpatientDO!=null?wlyyOutpatientDO.getOriginConNo():null);
 | 
	
		
			
				|  |  |         extInfoMap.put("diagnostic", wlyyOutpatientDO!=null?wlyyOutpatientDO.getIcd10Name():null);
 | 
	
		
			
				|  |  |         String extInfo = org.apache.commons.codec.binary.Base64.encodeBase64String(JSON.toJSONString(extInfoMap).getBytes("GBK"));
 | 
	
		
			
				|  |  |         String result = service.SOF_SignDataWithExtraInfo(idCardNo, inData, extInfo);
 | 
	
		
			
				|  |  |         logger.info("请求返参"+result);
 | 
	
		
			
				|  |  |         com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(result);
 | 
	
		
			
				|  |  |         if ("1000".equalsIgnoreCase(object.getString("code"))){
 | 
	
		
			
				|  |  |             com.alibaba.fastjson.JSONArray array = com.alibaba.fastjson.JSONArray.parseArray(object.getString("data"));
 | 
	
		
			
				|  |  |             for (int i=0;i<array.size();i++){
 | 
	
		
			
				|  |  |                 com.alibaba.fastjson.JSONObject jsonObject = array.getJSONObject(i);
 | 
	
		
			
				|  |  |                 String signData = jsonObject.getString("signData");
 | 
	
		
			
				|  |  |                 String signResult = jsonObject.getString("signResult");
 | 
	
		
			
				|  |  |                 String certData = jsonObject.getString("certData");
 | 
	
		
			
				|  |  |                 WlyyPrescriptionSignDO prescriptionSignDO = new WlyyPrescriptionSignDO();
 | 
	
		
			
				|  |  |                 prescriptionSignDO.setCertData(certData);
 | 
	
		
			
				|  |  |                 prescriptionSignDO.setPrescriptionId(prescriptionDO.getId());
 | 
	
		
			
				|  |  |                 prescriptionSignDO.setSignData(signData);
 | 
	
		
			
				|  |  |                 prescriptionSignDO.setSignResult(signResult);
 | 
	
		
			
				|  |  |                 prescriptionSignDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |                 prescriptionSignDO.setUpdateTime(new Date());
 | 
	
		
			
				|  |  |                 prescriptionSignDao.save(prescriptionSignDO);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             prescriptionDO.setSignFlag(1);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 电子病历签名
 | 
	
		
			
				|  |  |      * @param prescriptionEmrDO
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public void SOF_SignDataWithExtraInfoEmr(WlyyPrescriptionEmrDO prescriptionEmrDO) throws Exception {
 | 
	
		
			
				|  |  |         WlyyPrescriptionDO prescriptionDO = prescriptionDao.findOne(prescriptionEmrDO.getPrescriptionId());
 | 
	
		
			
				|  |  |         DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(prescriptionDO.getDoctor());
 | 
	
		
			
				|  |  |         BaseDoctorDO doctorDO = baseDoctorDao.findById(prescriptionDO.getDoctor());
 | 
	
		
			
				|  |  |         BasePatientDO patientDO = basePatientDao.findById(prescriptionDO.getPatientCode());
 | 
	
		
			
				|  |  |         WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(prescriptionDO.getOutpatientId());
 | 
	
		
			
				|  |  |         PKIService_ServiceLocator locator = new PKIService_ServiceLocator();
 | 
	
		
			
				|  |  |         URL portAddress = new URL("http://192.0.33.91:8080/pkis/services/v1?wsdl");
 | 
	
		
			
				|  |  |         PKIService_PortType service = locator.getPKIServiceImplPort(portAddress);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //电子病历签名
 | 
	
		
			
				|  |  |         com.alibaba.fastjson.JSONObject jsonData = new com.alibaba.fastjson.JSONObject();
 | 
	
		
			
				|  |  |         jsonData.put("CHIEF_COMPLAINT",prescriptionEmrDO.getComplaint());
 | 
	
		
			
				|  |  |         jsonData.put("HPI",prescriptionEmrDO.getMedicalHistory());
 | 
	
		
			
				|  |  |         jsonData.put("ELAPSEMHIS",prescriptionEmrDO.getPastHistory());
 | 
	
		
			
				|  |  |         jsonData.put("BODYCHECK",prescriptionEmrDO.getPhysicalExamination());
 | 
	
		
			
				|  |  |         jsonData.put("ASSISTANTCHECK",prescriptionEmrDO.getAssistExamination());
 | 
	
		
			
				|  |  |         // 1.1.1 服务端签名(带取证查询扩展信息)
 | 
	
		
			
				|  |  |         // inData 参数
 | 
	
		
			
				|  |  |         String inData = jsonData.toJSONString();
 | 
	
		
			
				|  |  |         inData = org.apache.commons.codec.binary.Base64.encodeBase64String(inData.getBytes("gbk"));
 | 
	
		
			
				|  |  |         // extInfo  参数
 | 
	
		
			
				|  |  |         String idCardNo = "123502004266006872;"+doctorDO.getIdcard();
 | 
	
		
			
				|  |  |         Map<String, String> extInfoMap = new HashMap<String, String>();
 | 
	
		
			
				|  |  |         extInfoMap.put("busSys", "ZhongJianXinLianHLWYY");
 | 
	
		
			
				|  |  |         extInfoMap.put("doctorNo", doctorMappingDO!=null?doctorMappingDO.getMappingCode():null);
 | 
	
		
			
				|  |  |         extInfoMap.put("doctorName", doctorMappingDO!=null?doctorMappingDO.getDoctorName():null);
 | 
	
		
			
				|  |  |         extInfoMap.put("deptName", "部门");
 | 
	
		
			
				|  |  |         extInfoMap.put("patientName", patientDO!=null?patientDO.getName():null);
 | 
	
		
			
				|  |  |         extInfoMap.put("patientSex", patientDO!=null?IdCardUtil.getSexForIdcard(patientDO.getIdcard()):null);
 | 
	
		
			
				|  |  |         extInfoMap.put("hospitalNo", wlyyOutpatientDO!=null?wlyyOutpatientDO.getOriginAdmNo():null);
 | 
	
		
			
				|  |  |         extInfoMap.put("hospitalNumber",  wlyyOutpatientDO!=null?wlyyOutpatientDO.getOriginConNo():null);
 | 
	
		
			
				|  |  |         extInfoMap.put("diagnostic", wlyyOutpatientDO!=null?wlyyOutpatientDO.getIcd10Name():null);
 | 
	
		
			
				|  |  |         String extInfo = org.apache.commons.codec.binary.Base64.encodeBase64String(JSON.toJSONString(extInfoMap).getBytes("GBK"));
 | 
	
		
			
				|  |  |         String result = service.SOF_SignDataWithExtraInfo(idCardNo, inData, extInfo);
 | 
	
		
			
				|  |  |         logger.info("请求返参"+result);
 | 
	
		
			
				|  |  |         com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(result);
 | 
	
		
			
				|  |  |         if ("1000".equalsIgnoreCase(object.getString("code"))){
 | 
	
		
			
				|  |  |             com.alibaba.fastjson.JSONArray array = com.alibaba.fastjson.JSONArray.parseArray(object.getString("data"));
 | 
	
		
			
				|  |  |             for (int i=0;i<array.size();i++){
 | 
	
		
			
				|  |  |                 com.alibaba.fastjson.JSONObject jsonObject = array.getJSONObject(i);
 | 
	
		
			
				|  |  |                 String signData = jsonObject.getString("signData");
 | 
	
		
			
				|  |  |                 String signResult = jsonObject.getString("signResult");
 | 
	
		
			
				|  |  |                 String certData = jsonObject.getString("certData");
 | 
	
		
			
				|  |  |                 WlyyPrescriptionSignDO prescriptionSignDO = new WlyyPrescriptionSignDO();
 | 
	
		
			
				|  |  |                 prescriptionSignDO.setCertData(certData);
 | 
	
		
			
				|  |  |                 prescriptionSignDO.setPrescriptionId(prescriptionDO.getId());
 | 
	
		
			
				|  |  |                 prescriptionSignDO.setSignData(signData);
 | 
	
		
			
				|  |  |                 prescriptionSignDO.setSignResult(signResult);
 | 
	
		
			
				|  |  |                 prescriptionSignDO.setCreateTime(new Date());
 | 
	
		
			
				|  |  |                 prescriptionSignDO.setUpdateTime(new Date());
 | 
	
		
			
				|  |  |                 prescriptionSignDO.setRelationCode(prescriptionEmrDO.getId());
 | 
	
		
			
				|  |  |                 prescriptionSignDao.save(prescriptionSignDO);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             prescriptionDO.setSignFlag(1);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | }
 |