You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
3.3 KiB
PHP

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
namespace App\Http\Controllers\API\H5;
use App\Http\Controllers\API\AspNetZhuanController;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class DoctorController extends Controller
{
//获取体检医生列表
public function GetList()
{
$date = request('date');
$hospital = request('hospital');
$month = request('month');
$doctor_id = request('doctor_id');
$hospital_map = [
'h1' => '6',
'h4' => '2',
];
$datesArray = [];
if (isset($date)) {
$datesArray[] = $date;
}
if (isset($month) and $month == 'all') {
// 循环30次每次获取一天后的日期
for ($i = 0; $i < 31; $i++) {
// 使用strtotime函数计算$i天后的日期然后用date函数格式化日期
$datesArray[] = date('Y-m-d', strtotime("+$i days"));
}
}
if (isset($month) and (strlen($month) == 7 or strlen($month) == 6)) {
$firstDay = strtotime($month . '-01');
// 获取该月的最后一天
$lastDay = strtotime('+1 month', $firstDay) - 86400; // 减去一天的秒数86400秒得到最后一天
// 从第一天到最后一天,逐天添加到数组中
$currentDay = $firstDay;
while ($currentDay <= $lastDay) {
$datesArray[] = date('Y-m-d', $currentDay);
$currentDay = strtotime('+1 day', $currentDay);
}
}
if (empty($datesArray)) return \Yz::Return(false,"参数错误");
$dnet = new AspNetZhuanController();
$res = $dnet->GetDoctorDateList([
"yyid" => $hospital_map["h$hospital"],
"data" => $datesArray,
"action" => "1"
]);
// return \Yz::Return(true,"",$res);
$list = [];
$keshi=[
'A0030090'=>'内科',
'A0030091'=>'妇科',
'A0030102'=>'外科'
];
if ($res['code'] == '200' && count($res['yisheng']) != 0) {
foreach ($res['yisheng'] as $key => $value) {
$keshiname='';
if(isset($keshi[$value['KSID']])){
$keshiname=$keshi[$value['KSID']];
}
$list[] = [
'head_img' => 'data:image/jpeg;base64,' . $value['U_IMG'],
'name' => $value['U_NAME'],
'id' => $value['U_ID'],
'level' => $value['ZC_NAME'],
'hospital' => '',
'time' => $value['U_GDPB'],
'desc' => $value['U_JIANJIE'],
'keshiname'=>$keshiname
];
}
}
$paiban=[];
$dates=[];
if(isset($month) and (strlen($month) == 7 or strlen($month) == 6) and isset($doctor_id)){
$k=0;
foreach ($res['paiban'] as $key => $date_value) {
foreach ($date_value as $key2 => $value2) {
if($value2['YSID']==$doctor_id){
$paiban[]=$value2;
}
}
}
$firstDay = date("Y-m-d", strtotime($month . "-01"));
// 获取当月的最后一天
$lastDay = date("Y-m-t", strtotime($month));
for ($i = $firstDay; $i <= $lastDay; $i = date("Y-m-d", strtotime($i . " +1 day"))) {
foreach ($paiban as $key => $value) {
if(date('Y-m-d', strtotime($value['PBRQ']))==$i){
$dates[]=[
'date'=>$i,
'paiban'=>$value,
];
}
}
$k++;
}
}
return \Yz::Return(true, "查询完成", ['list' => $list, 'paiban' => $dates]);
}
}