<?php

namespace App\Http\Controllers\API\H5;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class FenzhenController extends Controller
{
  public function abandon()
  {
    // 这里放 弃检逻辑
    return \Yz::Return(true, "弃检成功");
  }
  public function check()
  {
    // 这里放 检查是否有 体检引导的数据
    $id_number =request('id_number');
    $list=DB::table('orders')->where(['id_number'=>$id_number])->whereIn('status',[2,4])->get();
    return \Yz::Return(true, "弃检成功",['list'=>$list]);
  }

  public function list()
  {
    $id =request('id');
    $info=DB::table('orders')->where(['id'=>$id])->whereIn('status',[2,4])->get();
    if(!$info)  return \Yz::echoError1("查询就诊人订单失败");
    return \Yz::Return(true, "获取成功", [
      'info' => [
        'name' => $info->name,
        'sex' => $info->sex,
        'combo_name' => $info->title,
        'check_date' => $info->appointment_date,
        'start_time' =>  $info->appointment_time,
        'end_time' => '10:25',
        'qrcode' => '',
        'code' => $info->appointment_number,  // 体检条码
      ],
      'list' => [[
        'time' => '08:25',
        'name' => '体检登记',
        'status' => 4,
        'desc' => '已完成',
        'tip' => '体检登记 2024-08-09 08:25:30',
      ], [
        'time' => '08:30',
        'name' => '体格检查',
        'status' => 4,
        'desc' => '已完成',
        'tip' => '体格检查 2024-08-09 08:30:33',
      ], [
        'time' => '08:50',
        'name' => '超声科',
        'status' => 2,
        'desc' => '第5位，预计等待 11 分钟',
        'tip' => '腹部彩超',
      ], [
        'time' => '09:20',
        'name' => '心电图',
        'status' => 1,
        'desc' => '预计 09:20 进入队列',
        'tip' => '剩余5项正在排队中，',
        'more' => 1
      ], [
        'time' => '10:03',
        'name' => '体检结束',
        'status' => -1,
        'desc' => '早餐时间 10:03'
      ], [
        'time' => '',
        'name' => '出具报告',
        'status' => -1,
        'desc' => '预计 9月23日 出具体检报告'
      ], [
        'time' => '',
        'name' => '报告解读',
        'status' => -1,
        'desc' => '预计 9月24日 可以预约报告解读'
      ]],
    ]);
  }

  public function info()
  {
    $id =request('id');
    $info=DB::table('orders')->where(['id'=>$id])->whereIn('status',[2,4])->get();
    if(!$info)  return \Yz::echoError1("查询就诊人订单失败");
    return \Yz::Return(true, "获取成功", [
      'info' => [
        'name' => $info->name,
        'sex' => $info->sex,
        'combo_name' => $info->title,
        'check_date' => $info->appointment_date,
        'start_time' =>  $info->appointment_time,
        'end_time' => '10:25',
        'qrcode' => '',
        'code' => $info->appointment_number,  // 体检条码
      ],
      'list' => [[
        'id' => '1',
        'time' => '2024.09.11 08:25',
        'name' => '超声科-颈部血管彩超',
        'status' => 4,
      ], [
        'id' => '1',
        'time' => '2024.09.11 08:25',
        'name' => '内科-内科问诊',
        'status' => 4,
      ], [
        'id' => '1',
        'time' => '2024.09.11 08:25',
        'name' => '内科-内科问诊',
        'status' => 1,
      ], [
        'id' => '1',
        'time' => '2024.09.11 08:25',
        'name' => '内科-内科问诊',
        'status' => 1,
      ], [
        'id' => '1',
        'time' => '2024.09.11 08:25',
        'name' => '内科-内科问诊',
        'status' => 1,
      ]],
    ]);
  }
}
