diff --git a/Laravel.zip b/Laravel.zip index 308764b..4867bc7 100644 Binary files a/Laravel.zip and b/Laravel.zip differ diff --git a/Laravel/app/Http/Controllers/API/Admin/UserController.php b/Laravel/app/Http/Controllers/API/Admin/UserController.php index 0758f4c..6b941f0 100644 --- a/Laravel/app/Http/Controllers/API/Admin/UserController.php +++ b/Laravel/app/Http/Controllers/API/Admin/UserController.php @@ -12,10 +12,11 @@ class UserController extends Controller $status =request('status'); $cname =request('cname'); $departmentid =request('departmentid'); + $ward =request('ward'); $page =request('page'); $pagesize =request('pageSize'); $s=app()->make(UserService::class); - return $s->GetInfoList(['cname'=>$cname,'status'=>$status,'departmentid'=>$departmentid,'page'=>$page,'pagesize'=>$pagesize]); + return $s->GetInfoList(['cname'=>$cname,'status'=>$status,'departmentid'=>$departmentid,'ward'=>$ward,'page'=>$page,'pagesize'=>$pagesize]); } public function Save(){ $userInfo =request('userInfo'); diff --git a/Laravel/app/Http/Controllers/API/Admin/YeWu/CheckItemController.php b/Laravel/app/Http/Controllers/API/Admin/YeWu/CheckItemController.php index af80f08..c74ce3a 100644 --- a/Laravel/app/Http/Controllers/API/Admin/YeWu/CheckItemController.php +++ b/Laravel/app/Http/Controllers/API/Admin/YeWu/CheckItemController.php @@ -48,33 +48,48 @@ class CheckItemController extends Controller public function SetHuChi(Request $request) { $userid = $request->get('userid');//中间件产生的参数 + $id = request('id'); $code1 = request('code1'); $code2 = request('code2'); $time = request('time'); if(!isset($time)) return \Yz::echoError1("时间不能为空"); + $i=null; + $u=null; + if($id==0){ + $q = DB::table('s_huchi') + ->where('is_del', 0) + ->where(function ($query) use ($code1, $code2) { + $query->where('code1', $code1)->where('code2', $code2); + }) + ->orWhere(function ($query) use ($code1, $code2) { + $query->where('code1', $code2)->where('code2', $code1); + }) + ->get(); + + if (count($q) > 0) return \Yz::echoError1("此条互斥已存在,请删除后再添加!"); + $i = DB::table('s_huchi')->insertGetId([ + 'code1' => $code1, + 'code2' => $code2, + 'time' => $time, + 'is_del' => 0, + 'add_user' => $userid, + ]); + }else{ + + $u=DB::table('s_huchi')->where(['id'=>$id,'is_del'=>0])->update([ + 'time'=>$time + ]); + if($u){ + $i= $id; + } + } + + - $q = DB::table('s_huchi') - ->where('is_del', 0) - ->where(function ($query) use ($code1, $code2) { - $query->where('code1', $code1)->where('code2', $code2); - }) - ->orWhere(function ($query) use ($code1, $code2) { - $query->where('code1', $code2)->where('code2', $code1); - }) - ->get(); - - if (count($q) > 0) return \Yz::echoError1("此条互斥已存在,请删除后再添加!"); - $i = DB::table('s_huchi')->insert([ - 'code1' => $code1, - 'code2' => $code2, - 'time' => $time, - 'is_del' => 0, - 'add_user' => $userid, - ]); if ($i) { - return \Yz::Return(true, '设置成功', []); + return \Yz::Return(true, '设置成功', ['code2'=>$code2,'id'=>$i]); } else { - return \Yz::echoError1("添加失败"); + return \Yz::echoError1("操作失败"); } } @@ -117,7 +132,22 @@ ON WHERE s_huchi.is_del = 0 AND (s_huchi.code1 = ? OR s_huchi.code2 = ?)",[$code,$code]); + foreach ($q as $key=> $row) { + $r=[]; + if ($row->code1 == $code) { + $r=$row; + } else if ($row->code2 == $code) { + $jsonString = json_encode($row); + $array = json_decode($jsonString, true); + $r=$array; + $r['code1_item_name'] = $array['code2_item_name']; + $r['code2_item_name'] = $array['code1_item_name']; + $r['code1'] = $array['code2']; + $r['code2'] = $array['code1']; + } + $q[$key]=$r; + } return \Yz::Return(true, '操作成功', $q); } diff --git a/Laravel/app/Http/Controllers/API/Admin/YeWu/InpatientWardController.php b/Laravel/app/Http/Controllers/API/Admin/YeWu/InpatientWardController.php new file mode 100644 index 0000000..db38b60 --- /dev/null +++ b/Laravel/app/Http/Controllers/API/Admin/YeWu/InpatientWardController.php @@ -0,0 +1,62 @@ +where(['is_del'=>0]); + if(!empty($searchInfo['name'])){ + $list=$list->where(['name','like','%'.$searchInfo['name'].'%']); + } + $count= $list->count(); + $list= $list->skip(($page-1)*$pageSize) // 跳过前9999条记录 + ->take($pageSize)->get(); + foreach ($list as $k=>$v){ + $list[$k]->user_list=DB::table('users') + ->whereRaw("FIND_IN_SET(?, ward)", [$v->name]) + ->where(['status'=>1])->get(); + } + return \Yz::Return(true,"查询完成",['list'=>$list,'count'=>$count]); + } + public function Save(Request $request) + { + $userid = $request->get('userid');//中间件产生的参数 + $data = request('Info'); + if(empty($data['id'])){ + $id=DB::table('s_inpatient_ward')->insertGetId($data); + if($id){ + return \Yz::Return(true, '添加成功', $id); + }else{ + return \Yz::Return(false, '添加失败'); + } + }else{ + $res=DB::table('s_inpatient_ward')->where('id',$data['id'])->update($data); + if($res){ + return \Yz::Return(true, '修改成功'); + }else{ + return \Yz::Return(false, '修改失败'); + } + } + } + + public function Del() + { + $id = request('id'); + $res=DB::table('s_inpatient_ward')->where('id',$id)->update(['is_del'=>1]); + if($res){ + return \Yz::Return(true, '删除成功'); + }else{ + return \Yz::Return(false, '删除失败'); + } + } +} diff --git a/Laravel/app/Http/Controllers/API/Admin/YeWu/WorkMainController.php b/Laravel/app/Http/Controllers/API/Admin/YeWu/WorkMainController.php index 46bff29..39df7f1 100644 --- a/Laravel/app/Http/Controllers/API/Admin/YeWu/WorkMainController.php +++ b/Laravel/app/Http/Controllers/API/Admin/YeWu/WorkMainController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\API\Admin\YeWu; use App\Http\Controllers\Controller; +use App\Services\Admin\YeWu\PlanListService; use DateTime; use Illuminate\Http\Request; use Illuminate\Support\Carbon; @@ -47,20 +48,21 @@ class WorkMainController extends Controller if (!in_array($appointment_type, $qudaos)){ $msg=$msg.',该项目不支持在此渠道预约'; } - if(isset($ii[0]->check_begin_time)){ //判断开医嘱后多久能预约 - $entrust_time = $value->entrust_date . ' ' . $value->entrust_time; //医嘱时间 - $date = new DateTime($entrust_time); - $date->modify("+" . $ii[0]->check_begin_time . " minutes"); - $enableCheckTime = $date;//到此时间后可进行预约 - $current_time = new DateTime(); - if ($current_time < $enableCheckTime){ - $msg=$msg.",请于" . $enableCheckTime->format("Y-m-d H:i:s") . "后进行预约"; - } - } +// if(isset($ii[0]->check_begin_time)){ //判断开医嘱后多久能预约 +// $entrust_time = $value->entrust_date . ' ' . $value->entrust_time; //医嘱时间 +// $date = new DateTime($entrust_time); +// $date->modify("+" . $ii[0]->check_begin_time . " minutes"); +// $enableCheckTime = $date;//到此时间后可进行预约 +// $current_time = new DateTime(); +// if ($current_time < $enableCheckTime){ +// $msg=$msg.",请于" . $enableCheckTime->format("Y-m-d H:i:s") . "后进行预约"; +// } +// } } $itemInfo[]=[ 'maininfo'=>$value, + 'iteminfo'=>$ii, 'msg'=>$msg ]; } @@ -164,18 +166,21 @@ class WorkMainController extends Controller ->where(['a.item_name'=>$val['name'],'a.is_del'=>0,'a.status'=>1]) ->whereNotNull('b.device_id') ->pluck('b.device_id')->toArray(); + $FirstItem= DB::table('s_check_item as a') + ->where(['a.item_name'=>$val['name'],'a.is_del'=>0,'a.status'=>1])->first(); + if(!$FirstItem) return \Yz::echoError1('此医嘱项目无效,请检查项目设置'); } $itemNames[]=$val['name']; } - //获取所有传过来的检查项目关联的设备 + //获取所有传过来的检查项目关联的设备,并且只有设置相同的医嘱后等待时间才能同时勾选 $ItemsDevices= DB::table('s_check_item as a') ->leftJoin('s_check_item_device as b','a.id','=','b.item_id') ->leftJoin('s_devices as c','b.device_id','=','c.id') - ->whereIn('a.item_name',$itemNames)->where(['a.is_del'=>0,'a.status'=>1])->get(); + ->whereIn('a.item_name',$itemNames)->where(['a.is_del'=>0,'a.status'=>1,'check_begin_time'=>$FirstItem->check_begin_time])->get(); //按照第一个勾选的检查项目关联的设备进行分组,能在一个设备上进行检查的分在一组 if(!empty($FirstItemDevices)){ $group=[]; - foreach ($FirstItemDevices as $value){ + foreach ($FirstItemDevices as $f_key=> $value){ $lg=[]; foreach ($ItemsDevices as $v){ if($v->device_id==$value){ @@ -189,11 +194,15 @@ class WorkMainController extends Controller $lg[]=$v; } } - $group[]=$lg; + if(count($lg)>1 or count($group)==0){ + $group[]=$lg; + } + + } return \Yz::Return(true,'查询完成',['group'=>$group]); }else{ - return \Yz::echoError1('当前勾选检查项目不可用'); + return \Yz::echoError1('当前勾选检查项目不可进行此操作'); } }else{ return \Yz::echoError1('检查项目不能为空'); @@ -272,4 +281,12 @@ class WorkMainController extends Controller } } + //医生取消预约 + public function DoctorCancelYuYue() + { + $MainListId = request('MainListId'); + $reg_num = request('reg_num'); + $service = new PlanListService(); + return $service->CancelYuYue($MainListId,$reg_num); + } } diff --git a/Laravel/app/Http/Kernel.php b/Laravel/app/Http/Kernel.php index 528aa34..fd328c5 100644 --- a/Laravel/app/Http/Kernel.php +++ b/Laravel/app/Http/Kernel.php @@ -41,7 +41,7 @@ class Kernel extends HttpKernel 'api' => [ // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, - 'throttle:api', + 'throttle:120,1', \Illuminate\Routing\Middleware\SubstituteBindings::class, ], ]; diff --git a/Laravel/app/Services/Admin/UserService.php b/Laravel/app/Services/Admin/UserService.php index 98dbad0..5dba97d 100644 --- a/Laravel/app/Services/Admin/UserService.php +++ b/Laravel/app/Services/Admin/UserService.php @@ -19,6 +19,9 @@ class UserService if(isset($arr['departmentid'])){ $list=$list->where('a.department_id', $arr['departmentid']); } + if(isset($arr['ward'])){ + $list=$list->whereRaw("FIND_IN_SET(?, a.ward)", [$arr['ward']]); + } $count=$list->count(); $list=$list ->skip(($arr['page']-1)*$arr['pagesize']) // 跳过前9999条记录 @@ -35,7 +38,8 @@ class UserService 'cn_name' => $arr['info']['cname'], 'username' => $arr['info']['uname'], 'status'=>$arr['info']['status'], - 'department_id'=> isset($arr['info']['department_id']) ?$arr['info']['department_id']: 0 + 'department_id'=> isset($arr['info']['department_id']) ?$arr['info']['department_id']: 0, + 'ward'=> isset($arr['info']['ward']) ?$arr['info']['ward']: null ]); if($query){ $result['status']='ok'; @@ -60,7 +64,8 @@ class UserService 'username' => $arr['info']['uname'], 'pwd' => $hash, 'status'=>1, - 'department_id'=> isset($arr['info']['department_id']) ?$arr['info']['department_id']: 0 + 'department_id'=> isset($arr['info']['department_id']) ?$arr['info']['department_id']: 0, + 'ward'=> isset($arr['info']['ward']) ?$arr['info']['ward']: null ]); DB::commit(); // 手动提交事务 diff --git a/Laravel/app/Services/Admin/YeWu/PlanListService.php b/Laravel/app/Services/Admin/YeWu/PlanListService.php index 936d795..9c63c5c 100644 --- a/Laravel/app/Services/Admin/YeWu/PlanListService.php +++ b/Laravel/app/Services/Admin/YeWu/PlanListService.php @@ -18,9 +18,12 @@ class PlanListService // $episodeid = request('episodeid'); // $appointment_type = request('appointment_type'); //预约类型 // $appointment_date = request('date'); //预约日期 - $allDevice=[]; - foreach ($entrustids as $key=>$entrustid){ - $info = DB::table('s_list')->where(['reg_num' => $regnum, 'entrust_id' => $entrustid, 'episodeid' => $episodeid,'is_nullify'=>0])->first(); + + + $allDevice = [];//所有医嘱检查项目绑定的设备id + $commPatientType = [];//所有医嘱共同的病人类型 + foreach ($entrustids as $key => $entrustid) { + $info = DB::table('s_list')->where(['reg_num' => $regnum, 'entrust_id' => $entrustid, 'episodeid' => $episodeid, 'is_nullify' => 0])->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('没有找到可用的检查项目信息'); @@ -29,24 +32,29 @@ class PlanListService $qudaos = explode(',', $itemInfo->reservation_method); if (!in_array($appointment_type, $qudaos)) return \Yz::echoError1('此检查项目不支持在当前渠道预约'); - $entrust_time = $info->entrust_date . ' ' . $info->entrust_time; //医嘱时间 - $date = new DateTime($entrust_time); - $date->modify("+" . $itemInfo->check_begin_time . " minutes"); - $enableCheckTime = $date;//到此时间后可进行预约 - $current_time = new DateTime(); - if ($current_time < $enableCheckTime) return \Yz::echoError1("请于" . $enableCheckTime->format("Y-m-d H:i:s") . "后进行预约"); +// $entrust_time = $info->entrust_date . ' ' . $info->entrust_time; //医嘱时间 +// $date = new DateTime($entrust_time); +// $date->modify("+" . $itemInfo->check_begin_time . " minutes"); +// $enableCheckTime = $date;//到此时间后可进行预约 +// $current_time = new DateTime(); +// if ($current_time < $enableCheckTime) return \Yz::echoError1("请于" . $enableCheckTime->format("Y-m-d H:i:s") . "后进行预约"); //获取检查项目绑定的服务组(设备),判断状态正常的 $devices = DB::table('s_check_item_device') ->leftJoin("s_devices", "s_check_item_device.device_id", "=", "s_devices.id") ->where(['s_check_item_device.item_id' => $itemInfo->id]) ->where(['s_devices.status' => 1, 'is_del' => 0])->pluck('s_devices.id')->toArray(); - $allDevice[]=$devices; + $allDevice[] = $devices; + + if (!in_array($info->patient_type, $commPatientType)) { + // 如果不在数组中,则添加它 + array_push($commPatientType, $info->patient_type); + } } - $commonDevice=[]; //多个检查项目共同的设备id - foreach($allDevice as $set) { - if(count($commonDevice) == 0) { + $commonDevice = []; //多个检查项目共同的设备id + foreach ($allDevice as $set) { + if (count($commonDevice) == 0) { // 如果$intersection为空,直接将第一个子数组的元素放入 $commonDevice = $set; } else { @@ -54,7 +62,7 @@ class PlanListService $commonDevice = array_intersect($commonDevice, $set); } } - // dd($commonDevice); + // dd($commonDevice); //获取主表检查项目绑定的科室id $department_id = DB::table('s_department')->where(['department_number' => $info->RISRAcceptDeptCode])->first(); @@ -87,8 +95,8 @@ class PlanListService // ->get(); $placeholders = implode(',', array_fill(0, count($commonDevice), '?')); - $canshu=array_merge($commonDevice,[$department_id->id,$appointment_date,$appointment_type]); - $plan=DB::select("SELECT + $canshu = array_merge($commonDevice, [$department_id->id, $appointment_date, $appointment_type]); + $plan = DB::select("SELECT a.*, dd.devices, b.department_resources_name, @@ -117,11 +125,29 @@ WHERE AND a.STATUS = 1 AND a.is_del = 0 AND b.is_del = 0 - AND c.appointment_type_id =?",$canshu); - - + AND c.appointment_type_id =?", $canshu); + //遍历列表 把超过当前时间的放在后面 + $pl1 = []; + $pl2 = []; + $pp = []; + $nowtime = date('Y-m-d H:i:s'); + foreach ($plan as $key => $p) { +// //病人类型不符合的过滤掉 + $planPatientType = explode(",", $p->patient_type); + if (!empty(array_diff($commPatientType, $planPatientType))) { + continue; + } + //过期的排在后面 + $time = $p->date . ' ' . $p->end_time; + if ($time > $nowtime) { + $pl1[] = $p; + } else { + $pl2[] = $p; + } + } + $pp = array_merge($pl1, $pl2); - return \Yz::Return(true, '查询完成', ['today_date' => date("Y-m-d"), 'appointment_date' => $appointment_date, 'weekname' => Tools::GetWeekName($appointment_date), 'mainInfo' => $info, 'plan_list' => $plan]); + return \Yz::Return(true, '查询完成', ['today_date' => date("Y-m-d"), 'appointment_date' => $appointment_date, 'weekname' => Tools::GetWeekName($appointment_date), 'mainInfo' => $info, 'plan_list' => $pp]); } //开始预约占用名额 @@ -141,39 +167,55 @@ WHERE if ($nowdatetime > $planInfo->date . ' ' . $planInfo->end_reservation_time) return \Yz::echoError1('已经超过预约截止时间'); $planCount = DB::table('s_source_roster_detail_count')->where(['roster_detail_id' => $planid, 'appointment_type_id' => $appointment_type])->first(); - if ($planCount->count <= ($planCount->used_count+count($mainlistids))) return \Yz::echoError1('当前预约时间名额不足'); + if ($planCount->count <= ($planCount->used_count + count($mainlistids))) return \Yz::echoError1('当前预约时间名额不足'); - $oldMainInfos=[];//临时存储原来的主表信息,用于改约 + $oldMainInfos = [];//临时存储原来的主表信息,用于改约 //遍历多个s_list表id,前端多选,一次预约多个检查项目 - foreach ($mainlistids as $key_m=>$mainlistid ){ + foreach ($mainlistids as $key_m => $mainlistid) { $mainInfo = DB::table('s_list as a') - ->select('a.*','b.period_begin_time','b.period_end_time') - ->leftJoin('s_period as b','a.reservation_time','=','b.id') + ->select('a.*', 'b.period_begin_time', 'b.period_end_time') + ->leftJoin('s_period as b', 'a.reservation_time', '=', 'b.id') ->where(['a.id' => $mainlistid])->first(); - $oldMainInfos[]=$mainInfo; + $oldMainInfos[] = $mainInfo; if (!$mainInfo) return \Yz::echoError1('医嘱不存在'); //判断状态 - $msg_t=""; - if($mainInfo->list_status==0){ - $msg_t="当前状态为待预约"; + $msg_t = ""; + if ($mainInfo->list_status == 0) { + $msg_t = "当前状态为待预约"; } - if($mainInfo->list_status==1){ - $msg_t="已经在".$mainInfo->reservation_date.'的'.$mainInfo->period_begin_time.'-'.$mainInfo->period_end_time.'预约成功,不能再次预约'; + if ($mainInfo->list_status == 1) { + $msg_t = "已经在" . $mainInfo->reservation_date . '的' . $mainInfo->period_begin_time . '-' . $mainInfo->period_end_time . '预约成功,不能再次预约'; } - if($mainInfo->list_status==2){ - $msg_t="当前状态为已登记"; + if ($mainInfo->list_status == 2) { + $msg_t = "当前状态为已登记"; } - if($mainInfo->list_status==3){ - $msg_t="当前状态为已完成"; + if ($mainInfo->list_status == 3) { + $msg_t = "当前状态为已完成"; } - if ($do_type == 1 && $mainInfo->list_status <> 0) return \Yz::echoError1($mainInfo->entrust.' '.$msg_t.',禁止预约'); - if ($do_type == 2 && $mainInfo->list_status <> 1) return \Yz::echoError1($mainInfo->entrust.' '.$msg_t.',不允许改约操作'); + if ($do_type == 1 && $mainInfo->list_status <> 0) return \Yz::echoError1($mainInfo->entrust . ' ' . $msg_t . ',禁止预约'); + if ($do_type == 2 && $mainInfo->list_status <> 1) return \Yz::echoError1($mainInfo->entrust . ' ' . $msg_t . ',不允许改约操作'); + //判断病人类型 + $plan_patient_type=explode(",", $planInfo->patient_type); + if(!in_array($mainInfo->patient_type, $plan_patient_type)) return \Yz::echoError1('当前计划不支持此病人类型'); //判断互斥(暂时根据reg_num判断身份) //查询想要预约的项目 其自身code $item = DB::table('s_check_item')->where(['item_name' => $mainInfo->entrust, 'status' => 1, 'is_del' => 0])->first(); if (!$item) return \Yz::echoError1('此检查项目不可用'); + + //医嘱开具后,预约时间需在设定的等待期之后,单位分钟 + $entrust_time = $mainInfo->entrust_date . ' ' . $mainInfo->entrust_time; //医嘱时间 + $date = new DateTime($entrust_time); + $date->modify("+" . $item->check_begin_time . " minutes"); + $enableCheckTime = $date;//到此时间后可进行预约 + $plan_dateTime = $planInfo->date . ' ' . $planInfo->begin_time; + $plan_dateTime = new DateTime($plan_dateTime); + if ($plan_dateTime < $enableCheckTime) return \Yz::echoError1($item->item_name . " 已设置只能预约医嘱开具后" . $item->check_begin_time . "分钟后的时间,请预约" . $enableCheckTime->format("Y-m-d H:i:s") . "之后的时间"); + + //检测是否空腹 + $configs = DB::table('configs')->where('label', '开启空腹')->first(); + if ($item->limosis == 1 and $planInfo->end_reservation_time > '12:00:00' and $configs->value == 1) return \Yz::echoError1($item->item_name . ' 项目必须空腹,只能预约上午,请重新选择时间'); //查询当前检查项目是否存在互斥 $cha_hc = DB::table('s_huchi')->where('is_del', 0) ->where(function ($q) use ($item) { @@ -184,7 +226,10 @@ WHERE $status_1 = DB::table('s_list') ->select('s_check_item.item_code', 's_list.entrust', 's_list.reservation_date', 's_list.reservation_time') ->leftJoin('s_check_item', 's_list.entrust', '=', 's_check_item.item_name') - ->where(['s_list.reg_num' => $mainInfo->reg_num, 's_list.list_status' => 1, 's_list.is_del' => 0, 's_list.is_nullify' => 0])->get(); + ->where(['s_list.reg_num' => $mainInfo->reg_num, 's_list.list_status' => 1, 's_list.is_del' => 0, 's_list.is_nullify' => 0]) + //排除自身,自己不能互斥自己 + ->whereNotIn('item_name', [$mainInfo->entrust]) + ->get(); if (count($status_1) > 0) { foreach ($status_1 as $key => $value) { foreach ($cha_hc as $k => $v) { @@ -221,50 +266,50 @@ WHERE DB::beginTransaction(); try { //更新计划明细表使用数量 - $u = DB::table('s_source_roster_detail_count')->where(['id' => $planCount->id]) ->whereRaw('count > (used_count + ?)', [count($mainlistids)]) - ->increment('used_count',count($mainlistids)); + $u = DB::table('s_source_roster_detail_count')->where(['id' => $planCount->id])->whereRaw('count > (used_count + ?)', [count($mainlistids)]) + ->increment('used_count', count($mainlistids)); if ($u) { $cha = DB::table('s_source_roster_detail_count')->where(['id' => $planCount->id])->first(); - if ($cha->count >= ($cha->used_count+count($mainlistids))) { + if ($cha->count >= ($cha->used_count + count($mainlistids))) { //更新主表信息 - $u_data=[ + $u_data = [ 'list_status' => 1, 'reservation_date' => $planInfo->date, 'reservation_time' => $planInfo->period_id, 'reservation_sources' => $planInfo->resources_id, 'services_group' => $planInfo->device_id, 'roster_id' => $planInfo->id, - 'department_id'=>$planInfo->department_id, + 'department_id' => $planInfo->department_id, 'xuhao' => 0, 'appointment_type_id' => $appointment_type, ]; - $u_mainList = DB::table('s_list')->whereIn('id' , $mainlistids)->update($u_data); - $note="预约"; + $u_mainList = DB::table('s_list')->whereIn('id', $mainlistids)->update($u_data); + $note = "预约"; - foreach ($oldMainInfos as $key =>$oldMainInfo){ + foreach ($oldMainInfos as $key => $oldMainInfo) { if ($do_type == 2) { - // if(count($mainlistids)>1) return \Yz::echoError1('请选择1条医嘱改约,暂不支持批量'); - $note="改约"; + // if(count($mainlistids)>1) return \Yz::echoError1('请选择1条医嘱改约,暂不支持批量'); + $note = "改约"; //如果是改约,则恢复原来的数量 - $u_old = DB::table('s_source_roster_detail_count')->where(['roster_detail_id' => $oldMainInfo->roster_id, 'appointment_type_id' => $oldMainInfo->appointment_type_id,['used_count','>',0]])->decrement('used_count'); + $u_old = DB::table('s_source_roster_detail_count')->where(['roster_detail_id' => $oldMainInfo->roster_id, 'appointment_type_id' => $oldMainInfo->appointment_type_id, ['used_count', '>', 0]])->decrement('used_count'); } - $i_log=DB::table('s_list_log')->insert([ - 'list_id'=>$oldMainInfo->id, - 'reg_num'=>$oldMainInfo->reg_num, - 'old_status'=>$oldMainInfo->list_status, - 'new_status'=>1, - 'create_user'=>null, - 'note'=>$note, - 'data'=>json_encode($u_data) + $i_log = DB::table('s_list_log')->insert([ + 'list_id' => $oldMainInfo->id, + 'reg_num' => $oldMainInfo->reg_num, + 'old_status' => $oldMainInfo->list_status, + 'new_status' => 1, + 'create_user' => null, + 'note' => $note, + 'data' => json_encode($u_data) ]); } if ($u_mainList) { DB::commit(); - return \Yz::Return(true, '预约成功', []); + return \Yz::Return(true, '预约成功', ['planid' => $planid, 'mainlistids' => $mainlistids]); } else { DB::rollBack(); return \Yz::echoError1('预约失败'); @@ -281,7 +326,7 @@ WHERE } catch (\Exception $e) { DB::rollBack(); - return \Yz::echoError1('预约异常'.$e->getMessage()); + return \Yz::echoError1('预约异常' . $e->getMessage()); } @@ -292,13 +337,13 @@ WHERE date_default_timezone_set('PRC'); $nowdatetime = date("Y-m-d H:i:s"); - $mainInfo = DB::table('s_list')->where(['id' => $MainListId,'reg_num'=>$reg_num])->first(); + $mainInfo = DB::table('s_list')->where(['id' => $MainListId, 'reg_num' => $reg_num])->first(); if (!$mainInfo) return \Yz::echoError1('医嘱不存在'); //判断状态 if ($mainInfo->list_status <> 1) return \Yz::echoError1('该记录无法取消,当前状态:' . $mainInfo->list_status); DB::beginTransaction(); try { - $u_data=[ + $u_data = [ 'list_status' => 0, 'reservation_date' => null, 'reservation_time' => null, @@ -306,19 +351,19 @@ WHERE 'services_group' => null, 'roster_id' => null, 'xuhao' => null, - 'department_id'=>null, + 'department_id' => null, 'appointment_type_id' => null, 'canel_time' => $nowdatetime, ]; $u_mainList = DB::table('s_list')->where(['id' => $MainListId])->update($u_data); - $i_log=DB::table('s_list_log')->insert([ - 'list_id'=>$mainInfo->id, - 'reg_num'=>$mainInfo->reg_num, - 'old_status'=>$mainInfo->list_status, - 'new_status'=>0, - 'create_user'=>null, - 'note'=>'取消预约', - 'data'=>json_encode($u_data) + $i_log = DB::table('s_list_log')->insert([ + 'list_id' => $mainInfo->id, + 'reg_num' => $mainInfo->reg_num, + 'old_status' => $mainInfo->list_status, + 'new_status' => 0, + 'create_user' => null, + 'note' => '取消预约', + 'data' => json_encode($u_data) ]); $u_count = DB::table('s_source_roster_detail_count')->where(['roster_detail_id' => $mainInfo->roster_id, 'appointment_type_id' => $mainInfo->appointment_type_id])->decrement('used_count'); if ($u_mainList && $u_count) { diff --git a/Laravel/public/jq_page/appointment.html b/Laravel/public/jq_page/appointment.html index a51e0cd..c43f80b 100644 --- a/Laravel/public/jq_page/appointment.html +++ b/Laravel/public/jq_page/appointment.html @@ -21,6 +21,8 @@ let tomorrowDate='' let MainInfo_ids=[];//选中的检查项目对应的mainid let PrintInfo=null;//打印信息 + let YuYueSuccessInfo='';//预约成功后返回的信息 + let MainInfo_period_ids=[];//选中的检查项目对应的reservation_time //获取url参数 function getParameterByName(name, url) { if (!url) url = decodeURIComponent(window.location.href) @@ -56,10 +58,10 @@ case 3: return "结束" break; - + } } - + //获取基本信息 function GetMainInfo() { $('#yizhulist').html(''); @@ -76,18 +78,24 @@ MainInfoList=data.data.info MainInfoList.forEach(function(item,key){ let zhuangtai =GetStatus(item.maininfo.list_status) - let msg=item.msg==''?"":'
不可预约:'+item.msg+'
' + let msg=item.msg==''?"":'
不可预约:'+item.msg+'
' let yuyueshijian=item.maininfo.list_status==1?'
预约时间:'+item.maininfo.reservation_date+' '+item.maininfo.period_begin_time.substring(0,5) +'-'+ item.maininfo.period_end_time.substring(0,5) +'
' :'' let bj_color=item.msg==''?"":"hongse_bg" + let kongfu=(item.iteminfo[0] && item.iteminfo[0].limosis==1)?'是':'否' + if(YuYueSuccessInfo && YuYueSuccessInfo.mainlistids.includes(item.maininfo.id+'')){ + console.log(666666666); + bj_color="lanse_bg" + } $('#yizhulist').append( - '
' + + '
' + '
医嘱项:'+item.maininfo.entrust +'
' + '
当前状态:'+zhuangtai+'
' +msg+ + '
医生:'+ item.maininfo.docotr+' 是否空腹:'+ kongfu+'
' + yuyueshijian+ '
' ); }) - + $('.b_name').html(MainInfoList[0].maininfo.user_name); $('.b_id').html(MainInfoList[0].maininfo.reg_num); $('.b_sex').html(function(){ @@ -99,16 +107,27 @@ } }); $('.b_tel').html(MainInfoList[0].maininfo.user_phone); - $('.b_yun').html(MainInfoList[0].maininfo.RISRPatDiag); + // $('.b_yun').html(MainInfoList[0].maininfo.RISRPatDiag); today_date=data.data.today_date + let add=1; + if(getParameterByName('dotype')==2 && YuYueSuccessInfo==''){//如果是改约,默认定位到预约的日期 + console.log(data.data.info[0].maininfo.reservation_date); + today_date=data.data.info[0].maininfo.reservation_date + add=0; + } var currentDate = new Date(data.data.today_date) - currentDate.setDate(currentDate.getDate() + 1) + + currentDate.setDate(currentDate.getDate() + add) tomorrowDate = currentDate.toISOString().split('T')[0] - $('.yiyuInfo:first').trigger('click'); + if(YuYueSuccessInfo==''){ + $('.yiyuInfo:first').trigger('click'); + } + + } else { - MsgAlert(data.msg) + MsgAlert(data.msg) } }, 'json') } @@ -131,40 +150,71 @@ $('#xingqi1').html(data.data.weekname); $('#table1 tbody').html('') if(data.data.plan_list.length>0){ + //判断是否是预约成功后重新加载计划列表,自动选中成功后的日期 + let zhuangtai="class='table_row '"; + data.data.plan_list.forEach(function(v, i) { - $('#table1 tbody').append('\n' + + if(YuYueSuccessInfo && YuYueSuccessInfo.planid==v.id){ + zhuangtai="class='table_row row_selected'" + }else{ + zhuangtai="class='table_row '" + } + if(getParameterByName('dotype')==2 && YuYueSuccessInfo=='') {//如果是改约,默认定位到预约的日期 + if(MainInfo_period_ids[0]==v.period_id){ + zhuangtai="class='table_row row_selected'" + }else{ + zhuangtai="class='table_row '" + } + } + $('#table1 tbody').append('\n' + ' ' + v.date + '\n' + ' ' + v.weekname + '\n' + ' ' + v.department_resources_name + '\n' + ' ' + v.devices + '\n' + - ' ' + v.begin_time + '-' + v.end_time + '\n' + + ' ' + v.begin_time.substring(0,5) + '-' + v.end_time.substring(0,5) + '\n' + ' ' + v.used_count + '/' + v.count + '\n' + ' ') }) + if(getParameterByName('dotype')==2 && YuYueSuccessInfo=='') {//如果是改约,默认定位到预约的日期 + console.log($('.row_selected').position()) + $('.table_k').animate({ + scrollTop: $('.row_selected').position().top-200 + }, 200); // 动画持续时间为1000毫秒 + } + + + }else{ $('#table1 tbody').append('暂无可用计划') } - + } if (data.data.appointment_date == $('#datetimepicker2 input').val()) { $('#xingqi2').html(data.data.weekname); $('#table2 tbody').html('') if(data.data.plan_list.length>0){ + //判断是否是预约成功后重新加载计划列表,自动选中成功后的日期 + let zhuangtai="class='table_row '"; data.data.plan_list.forEach(function(v, i) { - $('#table2 tbody').append('\n' + + if(YuYueSuccessInfo && YuYueSuccessInfo.planid==v.id){ + zhuangtai="class='table_row row_selected'" + }else{ + zhuangtai="class='table_row '" + } + $('#table2 tbody').append('\n' + ' ' + v.date + '\n' + ' ' + v.weekname + '\n' + ' ' + v.department_resources_name + '\n' + ' ' + v.devices + '\n' + - ' ' + v.begin_time + '-' + v.end_time + '\n' + + ' ' + v.begin_time.substring(0,5) + '-' + v.end_time.substring(0,5) + '\n' + ' ' + v.used_count + '/' + v.count + '\n' + ' ') }) }else{ $('#table2 tbody').append('暂无可用计划') } - + } //选中某一行 @@ -187,10 +237,11 @@ } }) + } else { - MsgAlert(data.msg) + MsgAlert(data.msg) } - // $("#table2").freezeHeader({ 'height': '100px' }); + }, 'json') @@ -204,9 +255,9 @@ }, function(data) { $('#loadingModal').modal('hide'); if (data.status) { - + }else{ - MsgAlert(data.msg) + MsgAlert(data.msg) } }) } @@ -225,7 +276,8 @@ }, function(data) { $('#loadingModal').modal('hide'); if (data.status) { - MsgAlert("操作成功") + YuYueSuccessInfo=data.data + MsgAlert("操作成功") if($('#enable_print').is(':checked')){ PrintFunc(); } @@ -233,7 +285,7 @@ getPlanList($('#datetimepicker2 input').val()) GetMainInfo() }else{ - MsgAlert(data.msg) + MsgAlert(data.msg) } }) } @@ -296,6 +348,12 @@ //点击左侧的检查项目,调用接口查询可同时预约的项目 $("#yizhulist").on('click','.yiyuInfo:not(.yiyuInfo.hongse_bg)',function(){ + //如果有预约状态的被选中则启用取消按钮,否则取消按钮关闭 + if($(this).data('status')==1){ + $('#quxiao_button').prop('disabled', false); + }else{ + $('#quxiao_button').prop('disabled', true); + } //如果点击的项目本身已经被选中,再次点击则取消 if( $(this).hasClass('lanse_bg')){ $(this).removeClass('lanse_bg'); @@ -305,9 +363,11 @@ //如果点击的项目还没被选中,则清空所有已经选中的 if(!$(this).hasClass('lanse_bg')){ $(".lanse_bg").removeClass('lanse_bg'); - insertInto_appointmenText() + $(this).addClass('lanse_bg'); + insertInto_appointmenText() } - + + let first=$(this).data('id') let items=[] $('.yiyuInfo:not(.yiyuInfo.hongse_bg)').each(function(){ @@ -315,33 +375,39 @@ if($(this).data('id')==first){ isfirst=1 } - items.push({name:$(this).data('name'),rowid:$(this).data('id'),first:isfirst}) + if($(this).data('status')==0){ + items.push({name:$(this).data('name'),rowid:$(this).data('id'),first:isfirst}) + } + }) - - $('#loadingModal').modal('show'); - $.post(BaseUrl+'/api/admin/CheckEntrstItemGroup', { - items:items - }, function(data) { - $('#loadingModal').modal('hide'); - if (data.status) { - data.data.group[0].forEach(function(v,i){ - //遍历所有 不是红色的检查项目。匹配接口返回的可同时预约的项目 ,勾选 - $('.yiyuInfo:not(.yiyuInfo.hongse_bg)').each(function(){ - if($(this).data('id')==v.rowid){ - $(this).addClass('lanse_bg'); - } + + if(items.length>1){ + $('#loadingModal').modal('show'); + $.post(BaseUrl+'/api/admin/CheckEntrstItemGroup', { + items:items + }, function(data) { + $('#loadingModal').modal('hide'); + if (data.status) { + data.data.group[0].forEach(function(v,i){ + //遍历所有 不是红色的检查项目。匹配接口返回的可同时预约的项目 ,勾选 + $('.yiyuInfo:not(.yiyuInfo.hongse_bg)').each(function(){ + if($(this).data('id')==v.rowid){ + $(this).addClass('lanse_bg'); + } + }) + }) - - }) - insertInto_appointmenText() - - - }else{ - MsgAlert(data.msg) - } - }) - + insertInto_appointmenText() + + + }else{ + MsgAlert(data.msg) + } + }) + } + + }) function insertInto_appointmenText(){ //向检查项目输入框 填写内容 MainInfo_ids=[] @@ -351,6 +417,7 @@ input_itemname=input_itemname+" "+$(this).data('name') entrust_ids.push($(this).data('entrustid')) MainInfo_ids.push($(this).data('mainid')) + MainInfo_period_ids.push($(this).data('periodid')) }) $('#input_appointment_item').val(input_itemname); console.log(entrust_ids); @@ -367,12 +434,12 @@ $('#table1 tbody').html('请先选择检查项目') $('#table2 tbody').html('请先选择检查项目') } - + } $('#dayin_button').on('click',function(){ PrintFunc(); }) - + $('#shuaxin_button').on('click',function(){ window.location.reload() }) @@ -406,6 +473,35 @@ getPlanList(t2) } }) + //点击取消 + $('#quxiao_button').on('click',function(){ + if (MainInfo_ids.length !== 1) { + MsgAlert("请勾选1条 预约中 的医嘱,进行取消") + return false + } + let result = confirm("你确定要取消此预约吗?"); + + if (result !== true) { + return false; + } + + $('#loadingModal').modal('show'); + $.post(BaseUrl+'/api/admin/DoctorCancelYuYue', { + MainListId:MainInfo_ids[0], + reg_num: getParameterByName('regnum'), + }, function(data) { + $('#loadingModal').modal('hide'); + if (data.status) { + MsgAlert("操作成功") + getPlanList($('#datetimepicker1 input').val()) + getPlanList($('#datetimepicker2 input').val()) + GetMainInfo() + }else{ + MsgAlert(data.msg) + } + }) + }) + $('#tablelist').load("tablelist.html"); }) @@ -457,19 +553,19 @@ '
' ) }) - + $("#shenqingdan").show(); $("#shenqingdan").jqprint(); $("#shenqingdan").hide(); } } - + }) - + } - + - +