| 
					
				 | 
			
			
				@ -15,9 +15,7 @@ let searchRepo = require('../repository/search.repo'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				let modelUtil = require("../util/modelUtil"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				let objectUtil = require('../util/objectUtil'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				const GROUP_TYPE = require('../include/commons').GROUP_TYPE; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				class Search extends BaseModel{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				class Search extends BaseModel { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    constructor() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        super(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -34,18 +32,18 @@ class Search extends BaseModel{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            var data = {patients: [],group:[], chats: []}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            var data = {patients: [], group: [], chats: []}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (var i = 0; i < patients.length; ++i) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                var patient = patients[i]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                var p ={}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                var p = {}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                console.log(patient.code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                p= { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                p = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    code: patient.code, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    name: patient.name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sex: patient.sex, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    birthday: objectUtil.timestampToLong(patient.birthday), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    avatar: patient.photo === null ? "" : patient.photo 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                data.patients.push(p); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            searchRepo.searchGroupPatients(userId, keyword, function (err, groups) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -71,7 +69,16 @@ class Search extends BaseModel{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    for (var i = 0; i < chats.length; ++i) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        var lastPatient = {code: '', name: '', sex: '', avatar: '',amount:'',content:'',chat:'',type:''}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        var lastPatient = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            code: '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            name: '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            sex: '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            avatar: '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            amount: '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            content: '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            chat: '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            type: '' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        var chat = chats[i]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        console.log(JSON.stringify(chat)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        lastPatient.code = chat.code; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -83,7 +90,7 @@ class Search extends BaseModel{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        lastPatient.chat = chat.chat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        lastPatient.content = chat.content; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        lastPatient.type = chat.type; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        lastPatient.msg_id =chat.msg_id; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        lastPatient.msg_id = chat.msg_id; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        data.chats.push(lastPatient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    modelUtil.emitData(self.eventEmitter, data); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -99,10 +106,10 @@ class Search extends BaseModel{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param keyword 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param type 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    searchAboutPatientAll(userId, userRole, keyword,type) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    searchAboutPatientAll(userId, userRole, keyword, type) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        let self = this; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        var data = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(type==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (type == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            searchRepo.searchPatients(userId, userRole, keyword, function (err, patients) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    modelUtil.emitDbError(self.eventEmitter, "Search patient on basic information failed", err); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -121,14 +128,23 @@ class Search extends BaseModel{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                modelUtil.emitData(self.eventEmitter, data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(type==3){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (type == 3) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            searchRepo.searchPatientPM(userId, keyword, function (err, chats) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    modelUtil.emitDbError(self.eventEmitter, "Search patient on private messages failed", err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (var i = 0; i < chats.length; ++i) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    var lastPatient = {code: '', name: '', sex: '', avatar: '',amount:'',content:'',chat:'',type:''}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    var lastPatient = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        code: '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        name: '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        sex: '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        avatar: '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        amount: '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        content: '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        chat: '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        type: '' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    var chat = chats[i]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    lastPatient.code = chat.code; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    lastPatient.name = chat.name; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -144,7 +160,7 @@ class Search extends BaseModel{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                modelUtil.emitData(self.eventEmitter, data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(type==2){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (type == 2) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            searchRepo.searchGroupPatients(userId, keyword, function (err, groups) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    modelUtil.emitDbError(self.eventEmitter, "Search talk group failed", err); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -172,17 +188,17 @@ class Search extends BaseModel{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param groupId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param type 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    searchAboutPatientList(userId, keyword,groupId,type){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    searchAboutPatientList(userId, keyword, groupId, type) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        let self = this; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        searchRepo.searchPatientPMList(userId, keyword,groupId,type, function (err, chats) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        searchRepo.searchPatientPMList(userId, keyword, groupId, type, function (err, chats) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            var data = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                modelUtil.emitDbError(self.eventEmitter, "Search searchPatientPMList on private messages failed", err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (var i = 0; i < chats.length; ++i) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                var lastPatient = {code: '', name: '', sex: '', avatar: '',chat:'',content:''}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                var lastPatient = {code: '', name: '', sex: '', avatar: '', chat: '', content: ''}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                var chat = chats[i]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                lastPatient.code = chat.code; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                lastPatient.name = chat.name; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -190,8 +206,8 @@ class Search extends BaseModel{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                lastPatient.birthday = objectUtil.timestampToLong(chat.birthday); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                lastPatient.avatar = chat.photo === null ? "" : chat.photo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                lastPatient.chat = chat.chat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                lastPatient.content=chat.content; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                lastPatient.msg_id=chat.msg_id; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                lastPatient.content = chat.content; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                lastPatient.msg_id = chat.msg_id; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                data.push(lastPatient); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            modelUtil.emitData(self.eventEmitter, data); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -211,13 +227,13 @@ class Search extends BaseModel{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            var data = {doctors: [], groups: [],content:[]}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            var data = {doctors: [], groups: [], content: []}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (var i = 0; i < doctors.length; ++i) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                var doctor = doctors[i]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                data.doctors.push({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    code: doctor.code, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    name: doctor.name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    hospitalName:doctor.hospital_name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    hospitalName: doctor.hospital_name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    sex: doctor.sex, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    avatar: doctor.photo === null ? "" : doctor.photo 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -232,14 +248,14 @@ class Search extends BaseModel{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                var group = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (var i = 0; i < groups.length; ++i) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        var t = groups[i]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        group = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            code: t.code, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            name: t.name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            members: t.con, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            groupType:t.group_type 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        data.groups.push(group); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    var t = groups[i]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    group = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        code: t.code, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        name: t.name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        members: t.con, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        groupType: t.group_type 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    data.groups.push(group); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                // 搜索医生间的私信 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                searchRepo.searchDoctorsContent(userId, keyword, function (err, messages) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -254,25 +270,25 @@ class Search extends BaseModel{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            code: t.code, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            name: t.name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            amount: t.amount, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            content:t.content, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            type:t.type, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            msg_id:t.msg_id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            groupType:t.group_type, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            avatar:t.photo 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            content: t.content, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            type: t.type, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            msg_id: t.msg_id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            groupType: t.group_type, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                            avatar: t.photo 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        data.content.push(message); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    modelUtil.emitData(self.eventEmitter, data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    searchDoctorMore(userId,keyword,type){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    searchDoctorMore(userId, keyword, type) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        let self = this; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        var data = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if(type==1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        if (type == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            searchRepo.searchP2Pdoctors(userId, keyword, function (err, doctors) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    modelUtil.emitDbError(self.eventEmitter, "Search doctor on basic information failed", err); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -283,14 +299,14 @@ class Search extends BaseModel{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    data.push({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        code: doctor.code, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        name: doctor.name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        hospitalName:doctor.name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        hospitalName: doctor.name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        sex: doctor.sex, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        avatar: doctor.photo === null ? "" : doctor.photo 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                modelUtil.emitData(self.eventEmitter, data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else if(type==2){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } else if (type == 2) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            searchRepo.searchGroupDoctors(userId, keyword, function (err, groups) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    modelUtil.emitDbError(self.eventEmitter, "Search talk group failed", err); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -303,13 +319,13 @@ class Search extends BaseModel{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        code: t.code, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        name: t.name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        members: t.con, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        groupType:t.group_type 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        groupType: t.group_type 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    data.push(group); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                modelUtil.emitData(self.eventEmitter, data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }else if(type==3){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } else if (type == 3) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            searchRepo.searchDoctorsContent(userId, keyword, function (err, messages) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    modelUtil.emitDbError(self.eventEmitter, "Search doctor private messages failed", err); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -322,10 +338,10 @@ class Search extends BaseModel{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        code: t.code, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        name: t.name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        amount: t.amount, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        content:t.content, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        type:t.type, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        msg_id:t.msg_id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        groupType:t.group_type 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        content: t.content, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        type: t.type, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        msg_id: t.msg_id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        groupType: t.group_type 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    data.push(message); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -341,31 +357,30 @@ class Search extends BaseModel{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param groupcode 群组code 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param type type =1 p2p type = 2群组 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    searchDoctorContentDetail(userId,keyword,groupcode,type){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            let self = this; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            var data = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            searchRepo.searchDoctorsContentDetail(userId, keyword,groupcode,type, function (err, doctors) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    modelUtil.emitDbError(self.eventEmitter, "Search doctor on basic information failed", err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                for (var i = 0; i < doctors.length; ++i) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    var doctor = doctors[i]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    data.push({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        code: doctor.code, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        name: doctor.name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        content:doctor.content, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        msg_id:doctor.msg_id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        avatar:doctor.photo, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                        groupType:doctor.group_type 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                modelUtil.emitData(self.eventEmitter, data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    searchDoctorContentDetail(userId, keyword, groupcode, type) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        let self = this; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        var data = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        searchRepo.searchDoctorsContentDetail(userId, keyword, groupcode, type, function (err, doctors) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                modelUtil.emitDbError(self.eventEmitter, "Search doctor on basic information failed", err); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            for (var i = 0; i < doctors.length; ++i) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                var doctor = doctors[i]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                data.push({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    code: doctor.code, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    name: doctor.name, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    content: doctor.content, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    msg_id: doctor.msg_id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    avatar: doctor.photo, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    groupType: doctor.group_type 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            modelUtil.emitData(self.eventEmitter, data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				module.exports = Search; 
			 |