| 
					
				 | 
			
			
				@ -245,7 +245,7 @@ class Doctor extends BaseModel { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            let chats = {patients: [], doctors: [], groups: []}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            let chats = {patients: [], doctors: [], groups: [],systems:[]}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (let i = 0; i < patients.length; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                let patient = patients[i]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                chats.patients.push({ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -300,8 +300,107 @@ class Doctor extends BaseModel { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                timestamp: objectUtil.timestampToLong(group.timestamp) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        modelUtil.emitData(self.eventEmitter, chats); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        //系统消息 type 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        smRepo.getLastMessageByType(userId,"302,303,304,305,401,402,403,404,405",function(err,res){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                modelUtil.emitDbError(self.eventEmitter, 'Get getLastMessageByType list with doctor failed', err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            let system={lastContent:"",czrq:"",amount:"0",title:"系统消息",type:"1"}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            if(res.length>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                system.lastContent = res[0]["lastContent"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                system.czrq = res[0]["czrq"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            smRepo.getMessagesAmountByType(userId,"302,303,304,305,401,402,403,404,405",function(err,res){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    modelUtil.emitDbError(self.eventEmitter, 'Get getLastMessageByType list with doctor failed', err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                system.amount=res[0]["amount"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                chats.systems.push(system); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                //审核处理 type 2 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                smRepo.getLastMessageByType(userId,"301",function(err,res){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        modelUtil.emitDbError(self.eventEmitter, 'Get getLastMessageByType list with doctor failed', err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    let audit={lastContent:"",czrq:"",amount:"0",title:"审核处理",type:"2"}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    if(res.length>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        audit.lastContent = res[0]["lastContent"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        audit.czrq = res[0]["czrq"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    smRepo.getMessagesAmountByType(userId,"301",function(err,res){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            modelUtil.emitDbError(self.eventEmitter, 'Get getLastMessageByType list with doctor failed', err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        audit.amount=res[0]["amount"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        chats.systems.push(audit); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        //在线咨询 type 3 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        smRepo.getLastMessageByType(userId,"101",function(err,res){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                modelUtil.emitDbError(self.eventEmitter, 'Get getLastMessageByType list with doctor failed', err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            let consult={lastContent:"",czrq:"",amount:"0",title:"在线咨询",type:"3"}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            if(res.length>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                consult.lastContent = res[0]["lastContent"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                consult.czrq = res[0]["czrq"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            smRepo.getMessagesAmountByType(userId,"101",function(err,res){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                    modelUtil.emitDbError(self.eventEmitter, 'Get getLastMessageByType list with doctor failed', err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                    return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                consult.amount=res[0]["amount"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                chats.systems.push(consult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                //预约就诊 type 4 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                smRepo.getLastMessageByType(userId,"201",function(err,res){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                    if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                        modelUtil.emitDbError(self.eventEmitter, 'Get getLastMessageByType list with doctor failed', err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                        return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                    let appo={lastContent:"",czrq:"",amount:"0",title:"预约就诊",type:"4"}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                    if(res.length>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                        appo.lastContent = res[0]["lastContent"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                        appo.czrq = res[0]["czrq"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                    smRepo.getMessagesAmountByType(userId,"201",function(err,res){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                        if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                            modelUtil.emitDbError(self.eventEmitter, 'Get getLastMessageByType list with doctor failed', err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                            return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                        appo.amount=res[0]["amount"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                        chats.systems.push(appo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                        //反馈意见 type 5 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                        smRepo.getLastMessageByType(userId,"501",function(err,res){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                            if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                                modelUtil.emitDbError(self.eventEmitter, 'Get getLastMessageByType list with doctor failed', err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                                return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                            let view={lastContent:"",czrq:"",amount:"0",title:"反馈意见",type:"5"}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                            if(res.length>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                                view.lastContent = res[0]["lastContent"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                                view.czrq = res[0]["czrq"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                            smRepo.getMessagesAmountByType(userId,"501",function(err,res){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                                if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                                    modelUtil.emitDbError(self.eventEmitter, 'Get getLastMessageByType list with doctor failed', err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                                    return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                                view.amount=res[0]["amount"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                                chats.systems.push(view); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                                modelUtil.emitData(self.eventEmitter, chats); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                        }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -368,39 +467,117 @@ class Doctor extends BaseModel { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                timestamp: objectUtil.timestampToLong(group.timestamp) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        smRepo.getAppoList(userId,function(err,appo){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    getSystemMsgList(userId){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        let self = this; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        let chats = {systems:[]}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        smRepo.getLastMessageByType(userId,"302,303,304,305,401,402,403,404,405",function(err,res){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                modelUtil.emitDbError(self.eventEmitter, 'Get getLastMessageByType list with doctor failed', err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            let system={lastContent:"",czrq:"",amount:"0",title:"系统消息",type:"1"}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if(res.length>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                system.lastContent = res[0]["lastContent"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                system.czrq = objectUtil.timestampToLong(res[0]["czrq"]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            smRepo.getMessagesAmountByType(userId,"302,303,304,305,401,402,403,404,405",function(err,res){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    modelUtil.emitDbError(self.eventEmitter, 'Get getLastMessageByType list with doctor failed', err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                system.amount=res[0]["amount"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                chats.systems.push(system); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                //审核处理 type 2 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                smRepo.getLastMessageByType(userId,"301",function(err,res){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        modelUtil.emitDbError(self.eventEmitter, 'Get getLastMessageByType list with doctor failed', err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    let audit={lastContent:"",czrq:"",amount:"0",title:"审核处理",type:"2"}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if(res.length>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        audit.lastContent = res[0]["lastContent"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        audit.czrq = objectUtil.timestampToLong(res[0]["czrq"]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    smRepo.getMessagesAmountByType(userId,"301",function(err,res){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            modelUtil.emitDbError(self.eventEmitter, 'Get getLastMessageByType list with doctor failed', err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        audit.amount=res[0]["amount"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        chats.systems.push(audit); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        //在线咨询 type 3 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        smRepo.getLastMessageByType(userId,"101",function(err,res){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                modelUtil.emitDbError(self.eventEmitter, 'Get group list with doctor failed', err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                modelUtil.emitDbError(self.eventEmitter, 'Get getLastMessageByType list with doctor failed', err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            var appoArray=[]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            var appolist={}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            appolist.newMessageCount = appo.length; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            appolist.lastContent = appo[0].lastContent; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            appoArray.push(appolist); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            chats.system.appo = appoArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            smRepo.getSystemList(userId,function(err,sys){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            let consult={lastContent:"",czrq:"",amount:"0",title:"在线咨询",type:"3"}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            if(res.length>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                consult.lastContent = res[0]["lastContent"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                consult.czrq = objectUtil.timestampToLong(res[0]["czrq"]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            smRepo.getMessagesAmountByType(userId,"101",function(err,res){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    modelUtil.emitDbError(self.eventEmitter, 'Get group list with doctor failed', err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    modelUtil.emitDbError(self.eventEmitter, 'Get getLastMessageByType list with doctor failed', err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                var sysarry=[]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                var syslist={}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                syslist.newMessageCount = sys.length; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                if(sys.length>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 syslist.lastContent = sys[0].lastContent; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    syslist.lastContent=""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                sysarry.push(syslist) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                chats.system.sysInfo = sysarry; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                modelUtil.emitData(self.eventEmitter, chats); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                consult.amount=res[0]["amount"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                chats.systems.push(consult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                //预约就诊 type 4 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                smRepo.getLastMessageByType(userId,"201",function(err,res){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        modelUtil.emitDbError(self.eventEmitter, 'Get getLastMessageByType list with doctor failed', err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    let appo={lastContent:"",czrq:"",amount:"0",title:"预约就诊",type:"4"}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    if(res.length>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        appo.lastContent = res[0]["lastContent"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        appo.czrq = objectUtil.timestampToLong(res[0]["czrq"]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    smRepo.getMessagesAmountByType(userId,"201",function(err,res){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            modelUtil.emitDbError(self.eventEmitter, 'Get getLastMessageByType list with doctor failed', err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        appo.amount=res[0]["amount"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        chats.systems.push(appo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        //反馈意见 type 5 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        smRepo.getLastMessageByType(userId,"501",function(err,res){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                modelUtil.emitDbError(self.eventEmitter, 'Get getLastMessageByType list with doctor failed', err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            let view={lastContent:"",czrq:"",amount:"0",title:"反馈意见",type:"5"}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            if(res.length>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                view.lastContent = res[0]["lastContent"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                view.czrq = objectUtil.timestampToLong(res[0]["czrq"]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            smRepo.getMessagesAmountByType(userId,"501",function(err,res){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                    modelUtil.emitDbError(self.eventEmitter, 'Get getLastMessageByType list with doctor failed', err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                    return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                view.amount=res[0]["amount"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                chats.systems.push(view); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                modelUtil.emitData(self.eventEmitter, chats); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                        }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 获取与患者的聊天列表。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -413,7 +590,7 @@ class Doctor extends BaseModel { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            let chats = {patients: [], groups: []}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            let chats = {patients: []}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (let i = 0; i < patients.length; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                let patient = patients[i]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                chats.patients.push({ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -428,32 +605,7 @@ class Doctor extends BaseModel { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    timestamp: objectUtil.timestampToLong(patient.timestamp) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            gmRepo.findAllGroupsWithPatient(userId, function (err, groups) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    modelUtil.emitDbError(self.eventEmitter, 'Get group list with patient failed', err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (let i = 0; i < groups.length; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    let group = groups[i]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    // 过滤掉医生间的求助团队 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    if (group.group_type === 2) continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    chats.groups.push({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        code: group.code, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        name: group.name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        groupType: group.msg_type, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        newMessageCount: group.new_msg_count, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        lastContentType: group.last_content_type, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        lastContent: group.last_content, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        timestamp: objectUtil.timestampToLong(group.timestamp) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                modelUtil.emitData(self.eventEmitter, chats); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            modelUtil.emitData(self.eventEmitter, chats); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -562,22 +714,14 @@ class Doctor extends BaseModel { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    chats.patient  = patientAmount; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    smRepo.getAppoList(userId,function(err, res){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    smRepo.getMessagesAmountByType(userId,"101,201,301,302,303,304,401,402,403,404,405,501",function(err, res){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            modelUtil.emitDbError(self.eventEmitter, 'Get chat list with patient failed', err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            chats.appo  = res.length; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        smRepo.getSystemList(userId,function(err,res){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                modelUtil.emitDbError(self.eventEmitter, 'Get chat list with patient failed', err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                chats.sysInfo  = res.length; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            chats.sysInfo = res[0]['amount']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            modelUtil.emitData(self.eventEmitter, chats); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }); 
			 |