|  | @ -14,7 +14,6 @@ let BaseModel = require('./base.model');
 | 
	
		
			
				|  |  | let searchRepo = require('../repository/search.repo');
 | 
	
		
			
				|  |  | let modelUtil = require("../util/modelUtil");
 | 
	
		
			
				|  |  | let objectUtil = require('../util/objectUtil');
 | 
	
		
			
				|  |  | let log = require("../util/log.js");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | const GROUP_TYPE = require('../include/commons').GROUP_TYPE;
 | 
	
		
			
				|  |  | 
 | 
	
	
		
			
				|  | @ -35,28 +34,102 @@ class Search extends BaseModel{
 | 
	
		
			
				|  |  |                 return;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             var data = {patients: [], chats: []};
 | 
	
		
			
				|  |  |             var data = {patients: [],group:[], chats: []};
 | 
	
		
			
				|  |  |             for (var i = 0; i < patients.length; ++i) {
 | 
	
		
			
				|  |  |                 var patient = patients[i];
 | 
	
		
			
				|  |  |                 data.patients.push({
 | 
	
		
			
				|  |  |                 var p ={};
 | 
	
		
			
				|  |  |                 console.log(patient.code);
 | 
	
		
			
				|  |  |                 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) {
 | 
	
		
			
				|  |  |                 if (err) {
 | 
	
		
			
				|  |  |                     modelUtil.emitDbError(self.eventEmitter, "Search talk group failed", err);
 | 
	
		
			
				|  |  |                     return;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 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,
 | 
	
		
			
				|  |  |                     };
 | 
	
		
			
				|  |  |                     data.group.push(group);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 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 chat = chats[i];
 | 
	
		
			
				|  |  |                         console.log(JSON.stringify(chat));
 | 
	
		
			
				|  |  |                         lastPatient.code = chat.code;
 | 
	
		
			
				|  |  |                         lastPatient.name = chat.name;
 | 
	
		
			
				|  |  |                         lastPatient.sex = chat.sex;
 | 
	
		
			
				|  |  |                         lastPatient.birthday = objectUtil.timestampToLong(chat.birthday);
 | 
	
		
			
				|  |  |                         lastPatient.avatar = chat.photo === null ? "" : chat.photo;
 | 
	
		
			
				|  |  |                         lastPatient.amount = chat.amount;
 | 
	
		
			
				|  |  |                         lastPatient.chat = chat.chat;
 | 
	
		
			
				|  |  |                         lastPatient.content = chat.content;
 | 
	
		
			
				|  |  |                         lastPatient.type = chat.type;
 | 
	
		
			
				|  |  |                         lastPatient.msg_id =chat.msg_id;
 | 
	
		
			
				|  |  |                         data.chats.push(lastPatient);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     modelUtil.emitData(self.eventEmitter, data);
 | 
	
		
			
				|  |  |                 });
 | 
	
		
			
				|  |  |             });
 | 
	
		
			
				|  |  |         });
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 患者查询查看更多1.患者 2.内容 3.群组
 | 
	
		
			
				|  |  |      * @param userId
 | 
	
		
			
				|  |  |      * @param userRole
 | 
	
		
			
				|  |  |      * @param keyword
 | 
	
		
			
				|  |  |      * @param type
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     searchAboutPatientAll(userId, userRole, keyword,type) {
 | 
	
		
			
				|  |  |         let self = this;
 | 
	
		
			
				|  |  |         var data = [];
 | 
	
		
			
				|  |  |         if(type==1){
 | 
	
		
			
				|  |  |             searchRepo.searchPatients(userId, userRole, keyword, function (err, patients) {
 | 
	
		
			
				|  |  |                 if (err) {
 | 
	
		
			
				|  |  |                     modelUtil.emitDbError(self.eventEmitter, "Search patient on basic information failed", err);
 | 
	
		
			
				|  |  |                     return;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 for (var i = 0; i < patients.length; ++i) {
 | 
	
		
			
				|  |  |                     var patient = patients[i];
 | 
	
		
			
				|  |  |                     data.push({
 | 
	
		
			
				|  |  |                         code: patient.code,
 | 
	
		
			
				|  |  |                         name: patient.name,
 | 
	
		
			
				|  |  |                         sex: patient.sex,
 | 
	
		
			
				|  |  |                         birthday: objectUtil.timestampToLong(patient.birthday),
 | 
	
		
			
				|  |  |                         avatar: patient.photo === null ? "" : patient.photo
 | 
	
		
			
				|  |  |                     });
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 modelUtil.emitData(self.eventEmitter, data);
 | 
	
		
			
				|  |  |             });
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         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 chat = chats[i];
 | 
	
		
			
				|  |  |                     log.info(JSON.stringify(chat));
 | 
	
		
			
				|  |  |                     lastPatient.code = chat.code;
 | 
	
		
			
				|  |  |                     lastPatient.name = chat.name;
 | 
	
		
			
				|  |  |                     lastPatient.sex = chat.sex;
 | 
	
	
		
			
				|  | @ -66,11 +139,30 @@ class Search extends BaseModel{
 | 
	
		
			
				|  |  |                     lastPatient.chat = chat.chat;
 | 
	
		
			
				|  |  |                     lastPatient.content = chat.content;
 | 
	
		
			
				|  |  |                     lastPatient.type = chat.type;
 | 
	
		
			
				|  |  |                     data.chats.push(lastPatient);
 | 
	
		
			
				|  |  |                     data.push(lastPatient);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 modelUtil.emitData(self.eventEmitter, data);
 | 
	
		
			
				|  |  |             });
 | 
	
		
			
				|  |  |         });
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if(type==2){
 | 
	
		
			
				|  |  |             searchRepo.searchGroupPatients(userId, keyword, function (err, groups) {
 | 
	
		
			
				|  |  |                 if (err) {
 | 
	
		
			
				|  |  |                     modelUtil.emitDbError(self.eventEmitter, "Search talk group failed", err);
 | 
	
		
			
				|  |  |                     return;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 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,
 | 
	
		
			
				|  |  |                     };
 | 
	
		
			
				|  |  |                     data.push(group);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 modelUtil.emitData(self.eventEmitter, data);
 | 
	
		
			
				|  |  |             });
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
	
		
			
				|  | @ -86,7 +178,7 @@ class Search extends BaseModel{
 | 
	
		
			
				|  |  |         searchRepo.searchPatientPMList(userId, keyword,groupId,type, function (err, chats) {
 | 
	
		
			
				|  |  |             var data = [];
 | 
	
		
			
				|  |  |             if (err) {
 | 
	
		
			
				|  |  |                 modelUtil.emitDbError(self.eventEmitter, "Search patient on private messages failed", err);
 | 
	
		
			
				|  |  |                 modelUtil.emitDbError(self.eventEmitter, "Search searchPatientPMList on private messages failed", err);
 | 
	
		
			
				|  |  |                 return;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             for (var i = 0; i < chats.length; ++i) {
 | 
	
	
		
			
				|  | @ -99,6 +191,7 @@ class Search extends BaseModel{
 | 
	
		
			
				|  |  |                 lastPatient.avatar = chat.photo === null ? "" : chat.photo;
 | 
	
		
			
				|  |  |                 lastPatient.chat = chat.chat;
 | 
	
		
			
				|  |  |                 lastPatient.content=chat.content;
 | 
	
		
			
				|  |  |                 lastPatient.msg_id=chat.msg_id;
 | 
	
		
			
				|  |  |                 data.push(lastPatient);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             modelUtil.emitData(self.eventEmitter, data);
 | 
	
	
		
			
				|  | @ -111,117 +204,168 @@ class Search extends BaseModel{
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     searchAboutDoctor(userId, keyword) {
 | 
	
		
			
				|  |  |         let self = this;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         searchRepo.searchDoctors(userId, keyword, function (err, doctors) {
 | 
	
		
			
				|  |  |         //搜索单对单医生聊天
 | 
	
		
			
				|  |  |         searchRepo.searchP2Pdoctors(userId, keyword, function (err, doctors) {
 | 
	
		
			
				|  |  |             if (err) {
 | 
	
		
			
				|  |  |                 modelUtil.emitDbError(self.eventEmitter, "Search doctor on basic information failed", err);
 | 
	
		
			
				|  |  |                 return;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             let data = {doctors: [], groups: [], chats: {doctors: [], groups: []}};
 | 
	
		
			
				|  |  |             for (let i = 0; i < doctors.length; ++i) {
 | 
	
		
			
				|  |  |                 let doctor = doctors[i];
 | 
	
		
			
				|  |  |             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,
 | 
	
		
			
				|  |  |                     sex: doctor.sex,
 | 
	
		
			
				|  |  |                     avatar: doctor.photo === null ? "" : doctor.photo
 | 
	
		
			
				|  |  |                 });
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             // 搜索讨论组名称及成员名称
 | 
	
		
			
				|  |  |             searchRepo.searchGroups(userId, keyword, function (err, groups) {
 | 
	
		
			
				|  |  |             // 搜索讨论组名称及成员名称(讨论组)
 | 
	
		
			
				|  |  |             searchRepo.searchGroupDoctors(userId, keyword, function (err, groups) {
 | 
	
		
			
				|  |  |                 if (err) {
 | 
	
		
			
				|  |  |                     modelUtil.emitDbError(self.eventEmitter, "Search talk group failed", err);
 | 
	
		
			
				|  |  |                     return;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 let lastGroupCode = '';
 | 
	
		
			
				|  |  |                 let lastGroup = null;
 | 
	
		
			
				|  |  |                 for (let i = 0; i < groups.length; ++i) {
 | 
	
		
			
				|  |  |                     let group = groups[i];
 | 
	
		
			
				|  |  |                     if (lastGroupCode !== group.code) {
 | 
	
		
			
				|  |  |                         lastGroupCode = group.code;
 | 
	
		
			
				|  |  |                         lastGroup = {
 | 
	
		
			
				|  |  |                             code: group.code,
 | 
	
		
			
				|  |  |                             name: group.name,
 | 
	
		
			
				|  |  |                             type: GROUP_TYPE.DiscussionGroup,
 | 
	
		
			
				|  |  |                             members: []
 | 
	
		
			
				|  |  |                 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(lastGroup);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     lastGroup.members.push({
 | 
	
		
			
				|  |  |                         code: group.member_code,
 | 
	
		
			
				|  |  |                         name: group.member_name
 | 
	
		
			
				|  |  |                     });
 | 
	
		
			
				|  |  |                         data.groups.push(group);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 // 搜索医生间的私信
 | 
	
		
			
				|  |  |                 searchRepo.searchDoctorMessages(userId, keyword, function (err, messages) {
 | 
	
		
			
				|  |  |                 searchRepo.searchDoctorsContent(userId, keyword, function (err, messages) {
 | 
	
		
			
				|  |  |                     if (err) {
 | 
	
		
			
				|  |  |                         modelUtil.emitDbError(self.eventEmitter, "Search doctor private messages failed", err);
 | 
	
		
			
				|  |  |                         return;
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     var message = null;
 | 
	
		
			
				|  |  |                     for (var i = 0; i < messages.length; ++i) {
 | 
	
		
			
				|  |  |                         var t = messages[i];
 | 
	
		
			
				|  |  |                         message = {
 | 
	
		
			
				|  |  |                             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
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     let lastDoctor;
 | 
	
		
			
				|  |  |                     let lastDoctorCode = '';
 | 
	
		
			
				|  |  |                     for (let i = 0; i < messages.length; ++i) {
 | 
	
		
			
				|  |  |                         let message = messages[i];
 | 
	
		
			
				|  |  |                         if (lastDoctorCode !== message.code) {
 | 
	
		
			
				|  |  |                             lastDoctorCode = message.code;
 | 
	
		
			
				|  |  |                             lastDoctor = {
 | 
	
		
			
				|  |  |                                 code: message.code,
 | 
	
		
			
				|  |  |                                 name: message.name,
 | 
	
		
			
				|  |  |                                 photo: message.photo === null ? "" : message.photo,
 | 
	
		
			
				|  |  |                                 messages: []
 | 
	
		
			
				|  |  |                             };
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                             data.chats.doctors.push(lastDoctor);
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                         lastDoctor.messages.push({
 | 
	
		
			
				|  |  |                             id: message.msg_id,
 | 
	
		
			
				|  |  |                             content: message.content
 | 
	
		
			
				|  |  |                         });
 | 
	
		
			
				|  |  |                         };
 | 
	
		
			
				|  |  |                         data.content.push(message);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                     // 搜索医生间的讨论组消息
 | 
	
		
			
				|  |  |                     searchRepo.searchGroupMessages(userId, keyword, function (err, messages) {
 | 
	
		
			
				|  |  |                         if (err) {
 | 
	
		
			
				|  |  |                             modelUtil.emitDbError(self.eventEmitter, "Search doctor group messages failed", err);
 | 
	
		
			
				|  |  |                             return;
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                         // g.code, g.name, gm.msg_id, gm.content
 | 
	
		
			
				|  |  |                         let lastGroup;
 | 
	
		
			
				|  |  |                         let lastGroupCode = '';
 | 
	
		
			
				|  |  |                         for (let i = 0; i < messages.length; ++i) {
 | 
	
		
			
				|  |  |                             let message = messages[i];
 | 
	
		
			
				|  |  |                             if (lastGroupCode !== message.code) {
 | 
	
		
			
				|  |  |                                 lastGroupCode = message.code;
 | 
	
		
			
				|  |  |                                 lastGroup = {
 | 
	
		
			
				|  |  |                                     code: message.code,
 | 
	
		
			
				|  |  |                                     name: message.name,
 | 
	
		
			
				|  |  |                                     messages: []
 | 
	
		
			
				|  |  |                                 };
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                                 data.chats.groups.push(lastGroup);
 | 
	
		
			
				|  |  |                             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                             lastGroup.messages.push({
 | 
	
		
			
				|  |  |                                 id: message.msg_id,
 | 
	
		
			
				|  |  |                                 content: message.content
 | 
	
		
			
				|  |  |                             });
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                         modelUtil.emitData(self.eventEmitter, data);
 | 
	
		
			
				|  |  |                     modelUtil.emitData(self.eventEmitter, data);
 | 
	
		
			
				|  |  |                     });
 | 
	
		
			
				|  |  |                 });
 | 
	
		
			
				|  |  |             });
 | 
	
		
			
				|  |  |         });
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     searchDoctorMore(userId,keyword,type){
 | 
	
		
			
				|  |  |         let self = this;
 | 
	
		
			
				|  |  |         var data = [];
 | 
	
		
			
				|  |  |         if(type==1){
 | 
	
		
			
				|  |  |             searchRepo.searchP2Pdoctors(userId, keyword, 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,
 | 
	
		
			
				|  |  |                         hospitalName:doctor.name,
 | 
	
		
			
				|  |  |                         sex: doctor.sex,
 | 
	
		
			
				|  |  |                         avatar: doctor.photo === null ? "" : doctor.photo
 | 
	
		
			
				|  |  |                     });
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 modelUtil.emitData(self.eventEmitter, data);
 | 
	
		
			
				|  |  |             });
 | 
	
		
			
				|  |  |         }else if(type==2){
 | 
	
		
			
				|  |  |             searchRepo.searchGroupDoctors(userId, keyword, function (err, groups) {
 | 
	
		
			
				|  |  |                 if (err) {
 | 
	
		
			
				|  |  |                     modelUtil.emitDbError(self.eventEmitter, "Search talk group failed", err);
 | 
	
		
			
				|  |  |                     return;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 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.push(group);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 modelUtil.emitData(self.eventEmitter, data);
 | 
	
		
			
				|  |  |             });
 | 
	
		
			
				|  |  |         }else if(type==3){
 | 
	
		
			
				|  |  |             searchRepo.searchDoctorsContent(userId, keyword, function (err, messages) {
 | 
	
		
			
				|  |  |                 if (err) {
 | 
	
		
			
				|  |  |                     modelUtil.emitDbError(self.eventEmitter, "Search doctor private messages failed", err);
 | 
	
		
			
				|  |  |                     return;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 var message = null;
 | 
	
		
			
				|  |  |                 for (var i = 0; i < messages.length; ++i) {
 | 
	
		
			
				|  |  |                     var t = messages[i];
 | 
	
		
			
				|  |  |                     message = {
 | 
	
		
			
				|  |  |                         code: t.code,
 | 
	
		
			
				|  |  |                         name: t.name,
 | 
	
		
			
				|  |  |                         amount: t.amount,
 | 
	
		
			
				|  |  |                         content:t.content,
 | 
	
		
			
				|  |  |                         type:t.type,
 | 
	
		
			
				|  |  |                         msg_id:t.msg_id,
 | 
	
		
			
				|  |  |                         groupType:t.group_type
 | 
	
		
			
				|  |  |                     };
 | 
	
		
			
				|  |  |                     data.push(message);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 modelUtil.emitData(self.eventEmitter, data);
 | 
	
		
			
				|  |  |             });
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 搜索医生聊天详情
 | 
	
		
			
				|  |  |      * @param userId 当前医生ID
 | 
	
		
			
				|  |  |      * @param keyword 关键字
 | 
	
		
			
				|  |  |      * @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);
 | 
	
		
			
				|  |  |             });
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | module.exports = Search;
 |