<ion-header [translucent]="true">
  <ion-toolbar class="searchbar">
    <ion-button color="light" slot="start">
      <ion-back-button  defaultHref="/" ></ion-back-button>
    </ion-button>
    <ion-title>AI问诊</ion-title>

  </ion-toolbar>
</ion-header>

<ion-content>
  <ion-segment [(ngModel)]="selectedSegment" (ionChange)="segmentChanged($event)" scrollable>
    <ion-segment-button *ngFor="let segment of segments" [value]="segment">
      {{segment}}
    </ion-segment-button>
  </ion-segment>
  <div>
      <ion-grid>
        <ion-row>
          <ion-col size="6" *ngFor="let doctor of doctorList">
            <ion-card class="ioncard">
              <ion-item class="ionitem" lines="none" (click)="openInquiry(doctor)">
                <ion-avatar slot="start">
                  <img [src]="doctor.get('avatar')" />
                </ion-avatar>
                <ion-label>
                  <h2>{{ doctor.get('name') }}({{ doctor.get('age') }}岁)</h2>
                  <p>{{ doctor.get('title') }},{{ doctor.get('depart')?.name }}</p>
                </ion-label>
              </ion-item>
              
              <ion-item lines="none" class="hospital-infom">
                <ion-label>
                  <!-- <p>{{doctor.hospital}}</p> -->
                  <p>智养互联网医院</p>
                  <div class="badges">
                    <!-- <ion-badge color="success">{{doctor.hospitalLevel}}</ion-badge>
                    <span>{{doctor.hospitalType}}</span> -->
                    <ion-badge color="success">三甲</ion-badge>
                    <span>百强医院</span>
                  </div>
                </ion-label>
              </ion-item>
            </ion-card>
          </ion-col>
        </ion-row>
      </ion-grid>
  </div>
  
  
  <!-- <h1>科室</h1>
  <ion-input  [value]="keshi" placeholder="请输入科室" (ionInput)="keshiInput($event)"></ion-input> -->

  <!-- 文本域：生成提示词 -->
  <!-- <h1>症状的描述</h1>
  <ion-textarea [value]="userPrompt" placeholder="请描述您的症状" (ionInput)="promptInput($event)" autoGrow="true"></ion-textarea> -->
  
  <!-- 按钮：执行消息生成函数 -->
  <!-- <ion-button (click)="sendMessage()" expand="block">初步诊断</ion-button> -->
  
  <!-- 展示：返回消息内容 -->
  <!-- 消息传输过程中，实时预览 -->
  <!-- @if(!isComplete){
    <div>{{responseMsg}}</div>
  } -->
  
  <!-- 消息传输完成后，实时预览Markdown格式 -->
  <!-- @if(isComplete){
    <fm-markdown-preview class="content-style" [content]="responseMsg"></fm-markdown-preview>
  } -->
  <!-- <ion-button (click)="doInqueryTask()">执行问诊任务集</ion-button> -->
  <ul>
    @for(step of taskList;track step.title;){
      <div>
        <!-- 待开始 -->
        @if(step.progress==0 && !step.error){
          <ion-icon name="radio-button-off-outline"></ion-icon>
        }
        <!-- 进行中 -->
        @if(step.progress!=0 && step.progress!=1){
          <ion-icon name="reload-outline"></ion-icon>
        }
        <!-- 已完成 -->
        @if(step.progress==1){
          <ion-icon name="checkmark-circle-outline"></ion-icon>
        }
        <!-- 已出错 -->
        @if(step.error){
          <ion-icon name="close-circle-outline"></ion-icon>
        }
        {{step.title}}  
        @if(step.progress){
          <span>{{step.progress * 100 | number:"2.0-0"}}%</span>
        }
  
        @if(step.error){
          <span style="color:red;">{{step.error}}</span>
        }
      </div>   
    }
    </ul>
    <!-- 问诊报告生成结果 -->
    @if(shareData.diagResult){
      <h1>{{shareData.diagResult.title}}</h1>
      <h2>{{shareData.diagResult.desc}}</h2>
      <p>{{shareData.diagResult.content}}</p>
    }
    <!-- <div>
      <ion-card>
        <ion-card-header>
          <ion-card-title>权威医生</ion-card-title>
          <ion-card-subtitle>医生简介</ion-card-subtitle>
        </ion-card-header>
        <ion-card-content>
          <ion-list>
            <ion-item (click)="openInquiry(doctor)" *ngFor="let doctor of doctorList" lines="none">
              <ion-thumbnail slot="start">
                <img [src]="doctor.get('avatar') || '../../assets/image/doctor7.png'" [alt]="doctor.get('name')" />
              </ion-thumbnail>
              <div class="doctor-info">
                <h3>{{ doctor.get('name') }}({{ doctor.get('age') }}岁)</h3>
                <p>{{ doctor.get('title') }},{{ doctor.get('depart')?.name }}</p>
                <p>飞码互联网医院</p>
              </div>
            </ion-item>
          </ion-list>
        </ion-card-content>
      </ion-card>
    </div> -->
</ion-content>

<ion-footer>
  <ion-toolbar>
    <div class="createai">
      <ion-button aria-setsize="large" expand="block" (click)="createAI()" color="primary" slot="start">创建ai医生</ion-button>
    </div>
  </ion-toolbar>
</ion-footer>