| 
					
				 | 
			
			
				@ -1745,6 +1745,24 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else if (StringUtils.isNoneBlank(phone)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            buffer.append(" AND o.`proxy_patient_phone` like '%"+phone+"%'"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String applicationSql = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String patientTypeTemp = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if("1".equals(isApplication)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            applicationSql +=                 " JOIN ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "         select a.patient, group_concat(v.type) as type " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "         from wlyy_door_service_voucher v " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "                  JOIN (select t.id, t.patient, max(t.create_time) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "                        from wlyy_door_service_application t " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "                        where t.status in (2, 3) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "                        group by t.patient) as a " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "                       on a.id = v.service_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "         where v.status = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "         group by a.patient " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "        ) as t1 on o.patient = t1.patient" ; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            patientTypeTemp = " ,t1.`type` as patientType "; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        String sql = "SELECT " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  p.name AS patientName, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  p.photo AS photo, " + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1764,23 +1782,12 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  o.serve_lat as lat, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  o.`status` as status, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  o.`dispatcher_name` as dispatcherName, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  concat( o.patient,'_' ,c.id, '_',o.`number`,'_11' ) as sessionId, " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   t1.`type` as patientType " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  concat( o.patient,'_' ,c.id, '_',o.`number`,'_11' ) as sessionId " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                patientTypeTemp + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ( wlyy_door_service_order o " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " LEFT JOIN base_patient p ON o.patient = p.id ) LEFT JOIN wlyy_consult c on o.id = c.relation_code" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " JOIN ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "         select a.patient, group_concat(v.type) as type " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "         from wlyy_door_service_voucher v " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "                  JOIN (select t.id, t.patient, max(t.create_time) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "                        from wlyy_door_service_application t " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "                        where t.status in (2, 3) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "                        group by t.patient) as a " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "                       on a.id = v.service_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "         where v.status = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "         group by a.patient " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        ) as t1 on o.patient = t1.patient" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " LEFT JOIN base_patient p ON o.patient = p.id ) LEFT JOIN wlyy_consult c on o.id = c.relation_code"+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                applicationSql+" WHERE " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  o.hospital = '{hospital}' and o.type != 3 " +buffer+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND ( o.`status` = {status} OR -100 = {status} ) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " ORDER BY o.create_time desc " + 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1797,17 +1804,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " FROM  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "   wlyy_door_service_order o  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " LEFT JOIN base_patient p ON o.patient = p.id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " JOIN  ( " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "         select a.patient, group_concat(v.type) as type " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "         from wlyy_door_service_voucher v " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "                  JOIN (select t.id, t.patient, max(t.create_time) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "                        from wlyy_door_service_application t " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "                        where t.status in (2, 3) " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "                        group by t.patient) as a " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "                       on a.id = v.service_id " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "         where v.status = 1 " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "         group by a.patient " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "        ) as t1 on o.patient = t1.patient" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                applicationSql + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " WHERE  " + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                "  o.hospital = '{hospital}' " +buffer+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                " AND (o.`status` = {status} or -100 = {status})"; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -1852,7 +1849,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    JSONArray parArray = imUtill.getParticipants(sessionId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    parArray.forEach( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            oneParObj -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                org.json.JSONObject oneParJson = (org.json.JSONObject)oneParObj; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                JSONObject oneParJson = (com.alibaba.fastjson.JSONObject)oneParObj; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                if(StringUtils.equalsIgnoreCase(oneParJson.getString("id"),dispatcher)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    oneMap.put("isInSession",true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -2533,6 +2530,26 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        return res; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 互联网医院开方后 关联上门工单 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param orderId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param prescriptionCode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public void savePrescription(String orderId,String prescriptionCode){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        WlyyDoorServiceOrderDO orderDO = wlyyDoorServiceOrderDao.findOne(orderId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        orderDO.setPrescriptionCode(prescriptionCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        orderDO.setPrescriptionTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        orderDO.setPrescriptionStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        wlyyDoorServiceOrderDao.save(orderDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        //非代预约才发送im消息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(orderDO.getType() != null && orderDO.getType() != 3) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            //发送 预约卡片信息(2101类型) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            JSONObject orderInfoContent = this.queryOrderCardInfo(orderDO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            orderInfoContent.put("re_msg_type", 2);//开方完成消息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            this.qucikSendIM(orderDO.getId(), orderDO.getDispatcher(), "智能助手", "2101", orderInfoContent.toJSONString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     *  更新医生地理位置状态 
			 |