|
|
|
@ -36,7 +36,11 @@ public function getMainDetail()
|
|
|
|
$itemInfo=[];
|
|
|
|
$itemInfo=[];
|
|
|
|
$noDeptInfo=[];
|
|
|
|
$noDeptInfo=[];
|
|
|
|
$noScheduleInfo=[];
|
|
|
|
$noScheduleInfo=[];
|
|
|
|
|
|
|
|
$checkItemService = new \App\Services\Admin\YeWu\CheckItemService();
|
|
|
|
foreach ($info as $value){
|
|
|
|
foreach ($info as $value){
|
|
|
|
|
|
|
|
$theItem = $checkItemService->getCheckItemByEntrust($value->entrust_code, $value->entrust, $deptId);
|
|
|
|
|
|
|
|
$ii = collect();
|
|
|
|
|
|
|
|
if ($theItem) {
|
|
|
|
$ii = DB::table('s_check_item as a')
|
|
|
|
$ii = DB::table('s_check_item as a')
|
|
|
|
->leftJoin('s_check_item_device as b','a.id','=','b.item_id')
|
|
|
|
->leftJoin('s_check_item_device as b','a.id','=','b.item_id')
|
|
|
|
->leftJoin('s_department_resources_device as c','b.device_id','=','c.device_id')
|
|
|
|
->leftJoin('s_department_resources_device as c','b.device_id','=','c.device_id')
|
|
|
|
@ -47,7 +51,8 @@ public function getMainDetail()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
->select('a.*', 'b.device_id', 'c.department_id as dept_device_dept_id', 'd.department_name',
|
|
|
|
->select('a.*', 'b.device_id', 'c.department_id as dept_device_dept_id', 'd.department_name',
|
|
|
|
DB::raw('COALESCE(s_dept_check_item.reservation_method, a.reservation_method) as reservation_method'))
|
|
|
|
DB::raw('COALESCE(s_dept_check_item.reservation_method, a.reservation_method) as reservation_method'))
|
|
|
|
->where(['a.item_name' => $value->entrust,'a.status'=>1,"a.is_del"=>0])->get();
|
|
|
|
->where('a.id', $theItem->id)->where('a.status',1)->where('a.is_del',0)->get();
|
|
|
|
|
|
|
|
}
|
|
|
|
$source=null;
|
|
|
|
$source=null;
|
|
|
|
if(!empty($value->reservation_sources)){
|
|
|
|
if(!empty($value->reservation_sources)){
|
|
|
|
$source=DB::table('s_department_resources')->where(['id'=>$value->reservation_sources])->first();
|
|
|
|
$source=DB::table('s_department_resources')->where(['id'=>$value->reservation_sources])->first();
|
|
|
|
@ -453,37 +458,34 @@ public function CheckEntrstItemGroup()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$list=[];
|
|
|
|
$list=[];
|
|
|
|
$rowids=[];
|
|
|
|
$rowids=[];
|
|
|
|
$itemNames=[];
|
|
|
|
$itemIds=[];
|
|
|
|
$items= request('items');
|
|
|
|
$items= request('items');
|
|
|
|
if(!empty($items)){
|
|
|
|
if(!empty($items)){
|
|
|
|
$FirstItemDevices=[];
|
|
|
|
$FirstItemDevices=[];
|
|
|
|
|
|
|
|
$FirstItem=null;
|
|
|
|
$userid = request()->get('userid');
|
|
|
|
$userid = request()->get('userid');
|
|
|
|
$deptId = \App\Services\Admin\YeWu\DeptCheckItemService::getDeptIdByUserid($userid);
|
|
|
|
$deptId = \App\Services\Admin\YeWu\DeptCheckItemService::getDeptIdByUserid($userid);
|
|
|
|
|
|
|
|
$checkItemService = new \App\Services\Admin\YeWu\CheckItemService();
|
|
|
|
foreach ($items as $key=>$val){
|
|
|
|
foreach ($items as $key=>$val){
|
|
|
|
|
|
|
|
//精确匹配检查项目:主用 item_code,查不到回退 item_name(取最新),避免同名歧义
|
|
|
|
|
|
|
|
$theItem = $checkItemService->getCheckItemByEntrust($val['item_code'] ?? null, $val['name'], $deptId);
|
|
|
|
|
|
|
|
if(!$theItem) return \Yz::echoError1('此医嘱项目无效,请检查项目设置');
|
|
|
|
|
|
|
|
$itemIds[]=$theItem->id;
|
|
|
|
if($val['first']==1){
|
|
|
|
if($val['first']==1){
|
|
|
|
//获取点击的检查项目关联的设备id
|
|
|
|
//获取点击的检查项目关联的设备id
|
|
|
|
$FirstItemDevices= DB::table('s_check_item as a')
|
|
|
|
$FirstItemDevices=DB::table('s_check_item_device')
|
|
|
|
->leftJoin('s_check_item_device as b','a.id','=','b.item_id')
|
|
|
|
->where('item_id',$theItem->id)
|
|
|
|
->select('b.device_id')
|
|
|
|
->whereNotNull('device_id')
|
|
|
|
->where(['a.item_name'=>$val['name'],'a.is_del'=>0,'a.status'=>1])
|
|
|
|
->pluck('device_id')->toArray();
|
|
|
|
->whereNotNull('b.device_id')
|
|
|
|
$FirstItem=$theItem;
|
|
|
|
->pluck('b.device_id')->toArray();
|
|
|
|
|
|
|
|
$FirstItem= DB::table('s_check_item as a')
|
|
|
|
|
|
|
|
->leftJoin('s_dept_check_item', function($j) use ($deptId) {
|
|
|
|
|
|
|
|
$j->on('s_dept_check_item.check_item_id', '=', 'a.id')
|
|
|
|
|
|
|
|
->where('s_dept_check_item.department_id', '=', $deptId);
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
->select('a.*', DB::raw('COALESCE(s_dept_check_item.check_begin_time, a.check_begin_time, 0) as check_begin_time'))
|
|
|
|
|
|
|
|
->where(['a.item_name'=>$val['name'],'a.is_del'=>0,'a.status'=>1])->first();
|
|
|
|
|
|
|
|
if(!$FirstItem) return \Yz::echoError1('此医嘱项目无效,请检查项目设置');
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$itemNames[]=$val['name'];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!$FirstItem) return \Yz::echoError1('此医嘱项目无效,请检查项目设置');
|
|
|
|
//获取所有传过来的检查项目关联的设备,并且只有设置相同的医嘱后等待时间才能同时勾选
|
|
|
|
//获取所有传过来的检查项目关联的设备,并且只有设置相同的医嘱后等待时间才能同时勾选
|
|
|
|
$ItemsDevices= DB::table('s_check_item as a')
|
|
|
|
$ItemsDevices= DB::table('s_check_item as a')
|
|
|
|
->leftJoin('s_check_item_device as b','a.id','=','b.item_id')
|
|
|
|
->leftJoin('s_check_item_device as b','a.id','=','b.item_id')
|
|
|
|
->leftJoin('s_devices as c','b.device_id','=','c.id')
|
|
|
|
->leftJoin('s_devices as c','b.device_id','=','c.id')
|
|
|
|
->whereIn('a.item_name',$itemNames)->where(['a.is_del'=>0,'a.status'=>1,'check_begin_time'=>$FirstItem->check_begin_time])->get();
|
|
|
|
->whereIn('a.id',$itemIds)->where(['a.is_del'=>0,'a.status'=>1,'check_begin_time'=>$FirstItem->check_begin_time])->get();
|
|
|
|
//按照第一个勾选的检查项目关联的设备进行分组,能在一个设备上进行检查的分在一组
|
|
|
|
//按照第一个勾选的检查项目关联的设备进行分组,能在一个设备上进行检查的分在一组
|
|
|
|
|
|
|
|
|
|
|
|
if(!empty($FirstItemDevices)){
|
|
|
|
if(!empty($FirstItemDevices)){
|
|
|
|
|