| 
					
				 | 
			
			
				@@ -1,16 +1,18 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import { FmodeChat, FmodeChatMessage, openChatPanelModal, ChatPanelOptions } from 'fmode-ng'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { Component } from '@angular/core'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import { IonCardHeader, IonHeader, IonToolbar, IonTitle, IonContent, IonTabButton, IonSearchbar, IonLabel, IonItem, IonList, NavController, IonCard, IonCardTitle, IonCardSubtitle, IonCardContent, IonThumbnail } from '@ionic/angular/standalone'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import { IonCardHeader, IonHeader, IonToolbar, IonTitle, IonContent, IonTabButton, IonSearchbar, IonLabel, IonItem, IonList, NavController, IonCard, IonCardTitle, IonCardSubtitle, IonCardContent, IonThumbnail, IonFab, IonFabButton } from '@ionic/angular/standalone'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { ExploreContainerComponent } from '../explore-container/explore-container.component'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { IonButton } from '@ionic/angular/standalone'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { IonIcon } from '@ionic/angular/standalone'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { Router } from '@angular/router'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { CommonModule } from '@angular/common'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import { ModalController } from '@ionic/angular'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import { ModalController } from '@ionic/angular/standalone'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { HttpClient } from '@angular/common/http'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { addIcons } from 'ionicons'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import { add } from 'ionicons/icons'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { documentText, chatbubbles, person, calendar, newspaper, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    medkit,clipboard, podium, videocam, people } from 'ionicons/icons'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import { CloudObject, CloudQuery } from 'src/lib/ncloud'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import { CloudObject, CloudQuery } from '../lib/ncloud'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 addIcons({ documentText, chatbubbles, person, calendar, newspaper, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    medkit,clipboard, podium, videocam, people 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  }); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -22,94 +24,28 @@ addIcons({ documentText, chatbubbles, person, calendar, newspaper, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   imports: [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     IonHeader, IonToolbar, IonTitle, IonContent, ExploreContainerComponent, IonTabButton, IonButton, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     IonIcon,IonSearchbar,IonLabel,IonItem,IonList,CommonModule,IonCard,IonCardHeader,IonCardTitle,IonCardSubtitle, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    IonCardContent, IonThumbnail,  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    IonCardContent, IonThumbnail, IonFab,IonFabButton,IonIcon 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   ], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 export class Tab1Page { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   constructor( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private router: Router, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // private modalController: ModalController, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     private modalCtrl: ModalController, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // private navCtrl: NavController, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private http: HttpClient // 注入 HttpClient 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  ) {} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   * Go to the ai page 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  goToPage1(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    console.log(['route']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    this.router.navigate(['/tabs/inquiry/ai']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private http: HttpClient// 注入 HttpClient 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  ) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    addIcons({ add }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  navigateToPage() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    this.router.navigate(['/atest']); // 替换为目标页面的路由 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-   * Go to the human page 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   * Go to the ai page 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  goToPage2(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    this.router.navigate(['/tabs/inquiry/human']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  goToPicture(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    console.log(['route']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    this.router.navigate(['/tabs/picture']) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  searchContent:string = ''; //搜索内容 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  handleInput(ev:any) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    console.log("ev.detail.value: ",ev.detail.value) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    this.searchContent = ev.detail.value; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  search(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    if (this.searchContent == ''){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      console.log("请输入搜索内容") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      console.log("搜索内容: ",this.searchContent) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      this.searchContent = ''; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  // 功能按钮数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  functionItems1 = [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    { label: '我的健康', icon: 'document-text', route: '/tabs/my-health' }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    { label: '健康档案', icon: 'person', route: '/tabs/health-records' }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    { label: '电话问诊', icon: 'calendar', route: '/tabs/tab1' }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    { label: '购买药品', icon: 'medkit', route: '/tabs/tab1' }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  ]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  functionItems2 = [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    { label: '专业男科', icon: 'clipboard', route: '/tabs/tab1' }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    { label: '权威专家', icon: 'podium', route: '/tabs/tab1' }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    { label: '健康资讯', icon: 'newspaper', route: '/tabs/tab1' }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    { label: '智慧社区', icon: 'people', route: '/tabs/smart-community' } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  ]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  doctors = [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      name: '余海涛', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      age: 20, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      position: '主任医师', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      department: '中医草药科', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      hospital: '南昌市江西师范医院', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      image: '../../assets/image/doctor5.png', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      name: '聂翼伏', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      age: 25, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      position: '副主任医师', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      department: '骨科', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      hospital: 'YY市人民医院', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      image: '../../assets/image/doctor7.png', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      name: '徐君豪', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      age: 28, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      position: '主治医师', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      department: '心血管内科', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      hospital: 'XX市第一医院', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      image: '../../assets/image/doctor6.png', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-  ]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   // 导航到指定路由 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   navigateTo(route: string) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -126,4 +62,71 @@ export class Tab1Page { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let query = new CloudQuery("NovelCharacter"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     this.doctorList = await query.find() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   /** 示例:问诊根据doctor拼接提示词 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+   openInquiry(doctor:CloudObject){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    localStorage.setItem("company","E4KpGvTEto") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let consult = new CloudObject("Consultation") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let now = new Date(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let dateStr = `${now.getFullYear()}-${now.getMonth()+1}-${now.getDate()}` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    consult.set({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      title:`${doctor.get('depart')?.name || ""}门诊记录${dateStr}-${doctor?.get("name")}`, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      doctor:doctor.toPointer(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      depart:doctor.get("depart") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let options:ChatPanelOptions = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      roleId:"2DXJkRsjXK", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      onChatInit:(chat:FmodeChat)=>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        console.log("onChatInit"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              console.log("预设角色",chat.role); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              chat.role.set("name",doctor?.get("name")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              chat.role.set("title",doctor?.get("title")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              chat.role.set("desc",doctor?.get("desc")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              chat.role.set("tags",doctor?.get("qualifications")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              chat.role.set("avatar",doctor?.get("avatar") || "../../assets/image/doctor5.png") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              chat.role.set("prompt",` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# 角色设定 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+您是${doctor?.get("desc")},${doctor?.get("name")},年龄${doctor?.get("age")}岁,需要完成一次完整的门诊服务。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# 对话环节 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+0.导诊(根据用户基本情况,引导挂号合适的科室) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+1.预设的问询方式(根据不同症状来问询具体的情况) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+- 打招呼,以用户自述为主 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+- 当信息充足时候,确认用户症状对应的科室,并进入下一个环节 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+2.拓展的问询细节 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+例如:用户反映呼吸不畅,拓展出:是否咳嗽;是否感觉痛或者痒等其他需要的问题。 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+- 当问询细节补充完成后进入下一个环节 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+3.初步的诊断结果,并且同时列出检查检验项目 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+初步诊断:确定需要有哪些进一步检查 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+检查检验:获取医学客观数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+- 等待用户提交客观数据,进入下一阶段 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+4.给出诊断方案并给出处方 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+- 完成处方时,请在消息结尾附带: [处方完成] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+# 开始话语 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+当您准备好了,可以以一个医生的身份,向来访的用户打招呼。`); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      onMessage:(chat:FmodeChat,message:FmodeChatMessage)=>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        console.log("onMessage",message) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        let content:any = message?.content 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(typeof content == "string"){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          if(content?.indexOf("[处方完成]")>-1){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            console.log("门诊已完成") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            consult.set({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+              content:content // 处方内容 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            consult.save(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      onChatSaved:(chat:FmodeChat)=>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // chat?.chatSession?.id 本次会话的 chatId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        console.log("onChatSaved",chat,chat?.chatSession,chat?.chatSession?.id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    openChatPanelModal(this.modalCtrl,options) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |