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.

87 lines
3.5 KiB
PHP

<?php
namespace App\Http\Controllers\API\Admin\YeWu;
use App\Http\Controllers\Controller;
use DateTime;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Tools;
class WorkMainController extends Controller
{
//获取主工作列表详情
public function getMainDetail()
{
date_default_timezone_set('PRC');
$regnum = request('regnum');
$entrustid = request('entrustid');
$episodeid = request('episodeid');
$info = DB::table('s_list')->where(['reg_num' => $regnum,'entrust_id'=>$entrustid,'episodeid'=>$episodeid])->first();
if (!$info) return \Yz::echoError1('没有找到对应医嘱信息');
$itemInfo = DB::table('s_check_item')->where(['item_name' => $info->entrust,'status'=>1,"is_del"=>0])->get();
if (count($itemInfo) == 0) return \Yz::echoError1('没有找到可用的检查项目信息');
$itemInfo=$itemInfo[0];
return \Yz::Return(true,'查询完成',['today_date'=>date("Y-m-d"),'mainInfo'=>$info,'itemInfo'=>$itemInfo]);
}
public function GetList(Request $request)
{
$searchInfo = request('searchInfo');
$page = request('page');
$pageSize = request('pageSize');
$userid = $request->get('userid');//中间件产生的参数
$userInfo = DB::table('users')->where(['id' => $userid])->get();
$department_id = $userInfo[0]->department_id;
$department = DB::table('s_department')->where(['id' => $department_id,'is_del'=>0])->first();
if(!$department) return \Yz::echoError1('科室信息不存在');
$list=DB::table('s_list')
->leftJoin('s_period','s_list.reservation_time','=','s_period.id')
->leftJoin('s_department_resources','s_list.reservation_sources','=','s_department_resources.id')
->select('s_list.*','s_period.period_begin_time','s_period.period_end_time','s_department_resources.department_resources_name')
->where(['RISRAcceptDeptCode'=>$department->department_number]);
if ($searchInfo['dateRange']!=null and count($searchInfo['dateRange']) == 2) {
$list = $list->whereBetween('s_list.entrust_date', $searchInfo['dateRange']);
}
if (isset($searchInfo['list_status'])) {
$list = $list->where('s_list.list_status', $searchInfo['list_status']);
}
if (isset($searchInfo['patient_type'])) {
$list = $list->where('s_list.patient_type', $searchInfo['patient_type']);
}
if (isset($searchInfo['reg_num'])) {
$list = $list->where('s_list.reg_num', $searchInfo['reg_num']);
}
if (isset($searchInfo['user_name'])) {
$list = $list->where('s_list.user_name', 'like','%'.$searchInfo['user_name'].'%');
}
$count = $list;
$count = $count->count();
$list=$list->orderBy('id', 'desc')->limit($pageSize)->skip(($page - 1) * $pageSize) // 跳过前9999条记录
->take($pageSize)->get();
//匹配设备(服务组)
$devices = DB::table('s_devices')->get();
foreach ($list as $key => $value) {
$list[$key]->age = Tools::calculateAgeText($value->user_brithday);
$list[$key]->devices = [];
$array_device_id = explode(",", $value->services_group);
foreach ($devices as $k => $v) {
if (in_array($v->id, $array_device_id)) {
$list[$key]->devices[] = $v;
}
}
}
return \Yz::Return(true,'查询完成',['list'=>$list,'count'=>$count]);
}
//计算年龄
}