| 
															
																@ -83,6 +83,7 @@ class Patient extends BaseModel { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                let patientClient = clientCache.findById(message.to); 
															 | 
															
															 | 
															
																                let patientClient = clientCache.findById(message.to); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                if (!patientClient) { 
															 | 
															
															 | 
															
																                if (!patientClient) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                    log.warn("User is not online, user id: ", message.to); 
															 | 
															
															 | 
															
																                    log.warn("User is not online, user id: ", message.to); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                    //发送微信模板消息 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                    self.sendConsultWechatReplyTempMsg(message); 
															 | 
															
															 | 
															
																                    self.sendConsultWechatReplyTempMsg(message); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                    return; 
															 | 
															
															 | 
															
																                    return; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                } 
															 | 
															
															 | 
															
																                } 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -123,23 +124,65 @@ class Patient extends BaseModel { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                        modelUtil.emitDbError(self.eventEmitter, "get doctor info failed", err); 
															 | 
															
															 | 
															
																                        modelUtil.emitDbError(self.eventEmitter, "get doctor info failed", err); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                        return; 
															 | 
															
															 | 
															
																                        return; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                    } 
															 | 
															
															 | 
															
																                    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                    if (result && result.length > 0) { 
															 | 
															
															 | 
															
																                    if (result && result.length > 0) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                        var name = result[0].name; 
															 | 
															
															 | 
															
																                        var name = result[0].name; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                        var msg = { 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                            touser: openid, 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                            template_id: config.wechatConfig.template.consultTemplate, 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                            url: config.wechatConfig.baseUrl + "/wx/html/yszx/html/consulting-doctor.html?openid=" + openid + 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                            "&consult=" + "" + "&toUser=" + message.to, 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                            data: { 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                                first: {value: "您的健康咨询有新的回复", color: "#000000"} 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                                , remark: {value: "", color: "#000000"} 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                                , keyword1: {value: "XXXX咨询", color: "#000000"} 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                                , keyword2: {value: "XXXX回复", color: "#000000"} 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                                , keyword3: {value: name, color: "#000000"} 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                        patientRepo.getPatientDoctorConsult(message.to, message.from, function (err, result) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                            if (err) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                modelUtil.emitDbError(self.eventEmitter, "get patient and doctor consult info failed", err); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                return; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                            } 
															 | 
															
															 | 
															
																                            } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                        }; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                        wechatUtil.sendWxTemplateMessage(msg); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                            var consult = result && result.length > 0 ? result[0] : ""; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                            if (consult) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                var replyContent = message.content; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                switch(message.contentType){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                    case CONTENT_TYPES.Image: 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                        replyContent = "[图片]"; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                        break; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                    case CONTENT_TYPES.Audio: 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                        replyContent = "[语音]"; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                        break; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                    case CONTENT_TYPES.Article: 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                        replyContent = "[文章]"; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                        break; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                    case CONTENT_TYPES.GoTo: 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                        replyContent = "[链接]"; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                        break; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                    case CONTENT_TYPES.SessionBegin: 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                        return; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                        break; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                    case CONTENT_TYPES.SessionEnd: 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                        return; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                        break; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                    default: 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                        return; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                        break; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                var msg = { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                    touser: openid, 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                    template_id: config.wechatConfig.template.consultTemplate, 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                    url: config.wechatConfig.baseUrl + "/wx/html/yszx/html/consulting-doctor.html?openid=" + openid + 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                    "&consult=" + consult.consult + "&toUser=" + message.to, 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                    data: { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                        first: {value: "您的健康咨询有新的回复", color: "#000000"} 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                        , remark: {value: "", color: "#000000"} 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                        , keyword1: {value: consult.symptoms, color: "#000000"} 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                        , keyword2: {value: replyContent, color: "#000000"} 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                        , keyword3: {value: name, color: "#000000"} 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                }; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                                wechatUtil.sendWxTemplateMessage(msg); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                            } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                        }); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                    } else { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                        modelUtil.emitDbError(self.eventEmitter, "can not find doctor info", err); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                    } 
															 | 
															
															 | 
															
																                    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                }); 
															 | 
															
															 | 
															
																                }); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            } else { 
															 | 
															
															 | 
															
																            } else { 
															 |