diff --git a/Laravel/app/Http/Controllers/API/Admin/YeWu/PlanListController.php b/Laravel/app/Http/Controllers/API/Admin/YeWu/PlanListController.php
index b111253..dc9baab 100644
--- a/Laravel/app/Http/Controllers/API/Admin/YeWu/PlanListController.php
+++ b/Laravel/app/Http/Controllers/API/Admin/YeWu/PlanListController.php
@@ -125,13 +125,30 @@ class PlanListController extends Controller
]);
if (!$i_c) {
DB::rollBack();
- return \Yz::echoError1('创建失败');
+ return \Yz::echoError1('渠道数量创建失败');
}
}
} else {
DB::rollBack();
return \Yz::echoError1('模板数量信息异常,请重新选择!异常模板Id:' . $model->id);
}
+ if(isset($model->device_id)){
+ $device_ids =explode(",", $model->device_id);
+ foreach ($device_ids as $dv_key=>$dv_value){
+ $i_dev = DB::table('s_source_roster_detail_device')->insert([
+ 'roster_detail_id' => $plan_id,
+ 'device_id' => $dv_value,
+ ]);
+ if (!$i_dev) {
+ DB::rollBack();
+ return \Yz::echoError1('设备关联创建失败');
+ }
+ }
+
+ }else{
+ DB::rollBack();
+ return \Yz::echoError1('模板未关联设备,请重新选择!异常模板Id:' . $model->id);
+ }
}
}
@@ -297,10 +314,19 @@ class PlanListController extends Controller
$episodeid = request('episodeid');
$appointment_type = request('appointment_type'); //预约类型
$appointment_date = request('date'); //预约日期
-
$service = new PlanListService();
return $service->GetEnablePlan($regnum,$entrustid,$episodeid,$appointment_type,$appointment_date);
}
+ //获取最近可用的,计划 日期
+ public function EnablePlanDate()
+ {
+ $regnum = request('regnum');
+ $entrustid = request('entrustid');
+ $episodeid = request('episodeid');
+ $appointment_type = request('appointment_type'); //预约类型
+ $appointment_date = request('date'); //预约日期
+
+ }
//开始预约占用名额
public function YuYue()
diff --git a/Laravel/app/Http/Controllers/API/Admin/YeWu/WorkMainController.php b/Laravel/app/Http/Controllers/API/Admin/YeWu/WorkMainController.php
index 46bf0b1..ed3168f 100644
--- a/Laravel/app/Http/Controllers/API/Admin/YeWu/WorkMainController.php
+++ b/Laravel/app/Http/Controllers/API/Admin/YeWu/WorkMainController.php
@@ -16,15 +16,59 @@ class WorkMainController extends Controller
{
date_default_timezone_set('PRC');
$regnum = request('regnum');
- $entrustid = request('entrustid');
+ $entrustids = request('entrustid');
$episodeid = request('episodeid');
- $info = DB::table('s_list')->where(['reg_num' => $regnum,'entrust_id'=>$entrustid,'episodeid'=>$episodeid])->first();
+ $appointment_type=request('appointment_type');
+
+ $arrayEntrustids = explode(",", $entrustids);
+ $info = DB::table('s_list as a')->where(['a.reg_num' => $regnum, 'a.episodeid'=>$episodeid,'a.is_nullify'=>0])
+ ->select('a.*','c.period_begin_time','c.period_end_time')
+ ->leftJoin('s_period as c','a.reservation_time','=','c.id')
+ ->whereIn('a.entrust_id',$arrayEntrustids)
+ ->get();
if (!$info) return \Yz::echoError1('没有找到对应医嘱信息');
+ $itemInfo=[];
+ foreach ($info as $value){
+ $ii = DB::table('s_check_item as a')
+ ->leftJoin('s_check_item_device as b','a.id','=','b.item_id')
+ ->where(['a.item_name' => $value->entrust,'a.status'=>1,"a.is_del"=>0])->get();
+
+ $msg='';
+ if(count($ii)==0){
+ $msg="检查项目不可用";
+ }
+ if(count($ii)>0 ){
+ if(empty($ii[0]->device_id)){
+ $msg="检查项目未关联服务组";
+ }
+
+ $qudaos = explode(',', $ii[0]->reservation_method);
+ 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") . "后进行预约";
+ }
+ }
- $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]);
+ }
+ $itemInfo[]=[
+ 'maininfo'=>$value,
+ 'msg'=>$msg
+ ];
+ }
+// $itemInfo = DB::table('s_check_item')
+// ->whereIn('item_name',)
+// ->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"),'info'=>$itemInfo]);
}
public function GetList(Request $request)
{
@@ -98,5 +142,79 @@ class WorkMainController extends Controller
return \Yz::Return(true,'查询完成',$List);
}
+ //批量检查医嘱检查项目是否可以同时预约(如果关联的是同一个服务组则可以同时预约)返回可同时预约的row_id
+ public function CheckEntrstItemGroup()
+ {
+ $list=[];
+ $itemNames=[];
+ $items= request('items');
+ if(!empty($items)){
+ $FirstItemDevices=[];
+ foreach ($items as $key=>$val){
+ if($val['first']==1){
+ //获取点击的检查项目关联的设备id
+ $FirstItemDevices= DB::table('s_check_item as a')
+ ->leftJoin('s_check_item_device as b','a.id','=','b.item_id')
+ ->select('b.device_id')
+ ->where(['a.item_name'=>$val['name'],'a.is_del'=>0,'a.status'=>1])
+ ->whereNotNull('b.device_id')
+ ->pluck('b.device_id')->toArray();
+ }
+ $itemNames[]=$val['name'];
+ }
+ //获取所有传过来的检查项目关联的设备
+ $ItemsDevices= DB::table('s_check_item as a')
+ ->leftJoin('s_check_item_device as b','a.id','=','b.item_id')
+ ->whereIn('a.item_name',$itemNames)->where(['a.is_del'=>0,'a.status'=>1])->get();
+ //按照第一个勾选的检查项目关联的设备进行分组,能在一个设备上进行检查的分在一组
+ if(!empty($FirstItemDevices)){
+ $group=[];
+ foreach ($FirstItemDevices as $value){
+ $lg=[];
+ foreach ($ItemsDevices as $v){
+ if($v->device_id==$value){
+
+ foreach ($items as $item){
+ if($item['name']==$v->item_name){
+ $v->rowid=$item['rowid'];
+ }
+ }
+ $lg[]=$v;
+ }
+ }
+ $group[]=$lg;
+ }
+ return \Yz::Return(true,'查询完成',['group'=>$group]);
+ }else{
+ return \Yz::echoError1('当前勾选检查项目不可用');
+ }
+ }else{
+ return \Yz::echoError1('检查项目不能为空');
+ }
+
+
+
+ }
+ //检查当前时段是否有存在已经预约的待检查项目
+ public function CheckIsDaiJian()
+ {
+ $reg_num= request('reg_num');
+ $planid=request('planid');
+ $query=DB::table('s_list')->where(['reg_num'=>$reg_num,'list_status'=>1,'is_nullify'=>0])
+ ->select('s_list.*','s_period.period_begin_time','s_period.period_end_time')
+ ->leftJoin('s_period','s_list.reservation_time','=','s_period.id')
+ ->get();
+ if(count($query)>0){
+ $plan=DB::table('s_source_roster_detail')->where(['id'=>$planid])->first();
+ foreach ($query as $key=>$value){
+ $entrustTime=[$value->reservation_date.' '.$value->period_begin_time,$value->reservation_date.' '.$value->period_end_time];
+ $planTime=[$plan->date.' '.$plan->begin_time,$plan->date.' '.$plan->end_time];
+ if ($entrustTime[0] <= $planTime[1] && $planTime[0] <= $entrustTime[1]) {
+ return \Yz::echoError1('当前时段存在待检项目:'.$value->entrust.'时间:'.$value->reservation_date.' '.substr($value->period_begin_time, 0, 5).'-'.substr($value->period_end_time, 0, 5).' 请确认是否继续预约');
+ }
+ }
+ }
+ return \Yz::Return(true,'可以预约',[]);
+ }
}
diff --git a/Laravel/app/Http/Controllers/API/Third/EntrustController.php b/Laravel/app/Http/Controllers/API/Third/EntrustController.php
index 0c59484..eeb9e08 100644
--- a/Laravel/app/Http/Controllers/API/Third/EntrustController.php
+++ b/Laravel/app/Http/Controllers/API/Third/EntrustController.php
@@ -3,6 +3,7 @@
namespace App\Http\Controllers\API\Third;
use App\Http\Controllers\Controller;
+use Illuminate\Support\Facades\Log;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
@@ -12,26 +13,25 @@ class EntrustController extends Controller
public function CreateRecord()
{
$Info = request('info');
-
- $params=[
- 'list_status'=>0,
- 'reg_num'=>$Info['reg_num'] ?? null,
- 'user_name'=>$Info['user_name'] ?? null,
- 'user_sex'=>$Info['user_sex'] ?? null,
- 'entrust'=>$Info['entrust'] ?? null,
- 'is_pay'=>$Info['is_pay'] ?? null,
- 'reservation_department'=>$Info['reservation_department'] ?? null,
- 'entrust_date'=>$Info['entrust_date'] ?? null,
- 'entrust_time'=>$Info['entrust_time'] ?? null,
- 'user_brithday'=>$Info['user_brithday'] ?? null,
- 'docotr'=>$Info['docotr'] ?? null,
- 'patient_type'=>$Info['patient_type'] ?? null,
- 'user_phone'=>$Info['user_phone'] ?? null,
- 'implement_department'=>$Info['implement_department'] ?? null,
- 'entrust_id'=>$Info['entrust_id'] ?? null,//his传过来的本地医嘱id
- 'episodeid'=>$Info['episodeid'] ?? null, //就诊号
- 'RISRExamID'=>$Info['RISRExamID'] ?? null, //检查号
- 'RISRAcceptDeptCode'=>$Info['RISRAcceptDeptCode'] ?? null, //接收科室代码
+ $params = [
+ 'list_status' => 0,
+ 'reg_num' => $Info['reg_num'] ?? null,
+ 'user_name' => $Info['user_name'] ?? null,
+ 'user_sex' => $Info['user_sex'] ?? null,
+ 'entrust' => $Info['entrust'] ?? null,
+ 'is_pay' => $Info['is_pay'] ?? null,
+ 'reservation_department' => $Info['reservation_department'] ?? null,
+ 'entrust_date' => $Info['entrust_date'] ?? null,
+ 'entrust_time' => $Info['entrust_time'] ?? null,
+ 'user_brithday' => $Info['user_brithday'] ?? null,
+ 'docotr' => $Info['docotr'] ?? null,
+ 'patient_type' => $Info['patient_type'] ?? null,
+ 'user_phone' => $Info['user_phone'] ?? null,
+ 'implement_department' => $Info['implement_department'] ?? null,
+ 'entrust_id' => $Info['entrust_id'] ?? null,//his传过来的本地医嘱id
+ 'episodeid' => $Info['episodeid'] ?? null, //就诊号
+ 'RISRExamID' => $Info['RISRExamID'] ?? null, //检查号
+ 'RISRAcceptDeptCode' => $Info['RISRAcceptDeptCode'] ?? null, //接收科室代码
];
$requiredFields = [
'reg_num', 'user_name', 'user_sex', 'entrust', 'is_pay',
@@ -44,32 +44,62 @@ class EntrustController extends Controller
// 判断是否为空
foreach ($requiredFields as $field) {
if (!isset($params[$field]) || $params[$field] === null) {
- return \Yz::echoError1('参数'.$field.'不能为空');
+ return \Yz::echoError1('参数' . $field . '不能为空');
}
}
DB::beginTransaction();
- $insertListId=DB::table('s_list')->insertGetId($params);
- if($insertListId){
- $data=[
- 'list_id'=>$insertListId,
- 'reg_num'=>$Info['reg_num'],
- 'new_status'=>0,
- 'create_user'=>'接口',
- 'note'=>'创建记录',
- 'data'=>json_encode($Info,JSON_UNESCAPED_UNICODE),//原始数据
+ $insertListId = DB::table('s_list')->insertGetId($params);
+ if ($insertListId) {
+ $data = [
+ 'list_id' => $insertListId,
+ 'reg_num' => $Info['reg_num'],
+ 'new_status' => 0,
+ 'create_user' => '接口',
+ 'note' => '创建记录',
+ 'data' => json_encode($Info, JSON_UNESCAPED_UNICODE),//原始数据
];
- $insertLog=DB::table('s_list_log')->insert($data);
- if($insertLog){
+ $insertLog = DB::table('s_list_log')->insert($data);
+ if ($insertLog) {
DB::commit();
- return \Yz::Return(true,'保存成功',[]);
- }else{
+ return \Yz::Return(true, '保存成功', []);
+ } else {
DB::rollBack();
return \Yz::echoError1('保存失败');
}
- }else{
+ } else {
DB::rollBack();
return \Yz::echoError1('保存失败');
}
}
+
+ public function CreateRecordXml(Request $request)
+ {
+ $xmlString = $request->getContent(); // 获取请求的原始内容(XML)
+ $xmlData = simplexml_load_string($xmlString);
+ $jsonData = json_encode($xmlData);
+ Log::info($jsonData);
+
+ // 准备数据
+ $data = [
+ 'Response' => [
+ 'Body' => [
+ 'ResultCode' => '0',
+ 'ResultContent' => '成功',
+ 'SuccessIDList' => null, // 或者使用空数组 []
+ ],
+ ],
+ ];
+
+ // 将数据转换为 XML
+ $xml = simplexml_load_string('' . "\n");
+ array_walk_recursive($data, function($value, $key) use ($xml) {
+ $child = $xml->addChild($key, $value);
+ });
+ $xmlString = $xml->asXML();
+
+ // 设置响应头为 XML 并返回
+ return response($xmlString)->header('Content-Type', 'text/xml');
+
+ }
}
diff --git a/Laravel/app/Http/Kernel.php b/Laravel/app/Http/Kernel.php
index 999ddf9..36c175a 100644
--- a/Laravel/app/Http/Kernel.php
+++ b/Laravel/app/Http/Kernel.php
@@ -66,5 +66,6 @@ class Kernel extends HttpKernel
'checktoken' => \App\Http\Middleware\CheckToken::class,
'log' => \App\Http\Middleware\Log::class,
'check.sign' => \App\Http\Middleware\CheckSign::class,
+ 'check.sign.xml' => \App\Http\Middleware\CheckSignXMl::class,
];
}
diff --git a/Laravel/app/Http/Middleware/CheckSignXMl.php b/Laravel/app/Http/Middleware/CheckSignXMl.php
new file mode 100644
index 0000000..6f9cc0e
--- /dev/null
+++ b/Laravel/app/Http/Middleware/CheckSignXMl.php
@@ -0,0 +1,27 @@
+'-1','msg'=>"验证token失败"]);
+ }
+
+ }
+}
diff --git a/Laravel/app/Services/Admin/YeWu/PlanListService.php b/Laravel/app/Services/Admin/YeWu/PlanListService.php
index 9105fcd..46fd1e3 100644
--- a/Laravel/app/Services/Admin/YeWu/PlanListService.php
+++ b/Laravel/app/Services/Admin/YeWu/PlanListService.php
@@ -2,6 +2,7 @@
namespace App\Services\Admin\YeWu;
+use DateInterval;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use DateTime;
@@ -9,7 +10,7 @@ use Tools;
class PlanListService
{
- public function GetEnablePlan($regnum, $entrustid, $episodeid, $appointment_type, $appointment_date)
+ public function GetEnablePlan($regnum, $entrustids, $episodeid, $appointment_type, $appointment_date)
{
date_default_timezone_set('PRC');
// $regnum = request('regnum');
@@ -17,68 +18,114 @@ 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();
+ 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('没有找到可用的检查项目信息');
- $info = DB::table('s_list')->where(['reg_num' => $regnum, 'entrust_id' => $entrustid, 'episodeid' => $episodeid])->first();
- if (!$info) return \Yz::echoError1('没有找到对应医嘱信息');
+ $itemInfo = $itemInfo[0];
+ $qudaos = explode(',', $itemInfo->reservation_method);
+ if (!in_array($appointment_type, $qudaos)) 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('没有找到可用的检查项目信息');
+ $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") . "后进行预约");
- $itemInfo = $itemInfo[0];
- $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") . "后进行预约");
+ //获取检查项目绑定的服务组(设备),判断状态正常的
+ $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;
+ }
- //获取检查项目绑定的服务组(设备),判断状态正常的
- $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();
+ $commonDevice=[]; //多个检查项目共同的设备id
+ foreach($allDevice as $set) {
+ if(count($commonDevice) == 0) {
+ // 如果$intersection为空,直接将第一个子数组的元素放入
+ $commonDevice = $set;
+ } else {
+ // 使用array_intersect()函数求当前子数组与已有交集的交集
+ $commonDevice = array_intersect($commonDevice, $set);
+ }
+ }
+ // dd($commonDevice);
//获取主表检查项目绑定的科室id
$department_id = DB::table('s_department')->where(['department_number' => $info->RISRAcceptDeptCode])->first();
if (!$department_id) return \Yz::echoError1('获取医嘱检查项目科室信息失败');
-
+// // 获取当前日期
+// $startDate = date('Y-m-d');
+// // 创建一个空数组来存储日期
+// $datesArray = [];
+// // 循环获取今天及之后7天的日期
+// for ($i = 0; $i <7; $i++) {
+// // 使用DateTime对象方便地进行日期操作
+// $dateObject = new DateTime($startDate);
+// $dateObject->add(new DateInterval('P'.$i.'D')); // P1D表示增加一天
+// // 将日期格式化后存入数组
+// $datesArray[] = $dateObject->format('Y-m-d');
+// }
//获取对应日期的计划明细
- $plan = DB::table('s_source_roster_detail as a')
- ->select('a.*', 'b.department_resources_name', 'c.roster_detail_id', 'c.count', 'c.used_count')
- ->leftJoin('s_department_resources as b', 'a.resources_id', '=', 'b.id')
- ->leftJoin('s_source_roster_detail_count as c', 'a.id', '=', 'c.roster_detail_id')
- ->where(['a.department_id' => $department_id->id, 'a.date' => $appointment_date, 'a.status' => 1, 'a.is_del' => 0, 'b.is_del' => 0, 'c.appointment_type_id' => $appointment_type])->get();
- $plan_enable = [];
- foreach ($plan as $key => $value) {
- if (array_intersect($devices, array_map('intval', explode(',', $value->device_id)))) {
- $plan_enable[] = $value;
- }
- }
+// $plan = DB::table('s_source_roster_detail as a')
+// ->select('a.*', 'b.department_resources_name', 'c.roster_detail_id', 'c.count', 'c.used_count','e.device_name as devices')
+// ->leftJoin('s_department_resources as b', 'a.resources_id', '=', 'b.id')
+// ->leftJoin('s_source_roster_detail_count as c', 'a.id', '=', 'c.roster_detail_id')
+// ->leftJoin('s_source_roster_detail_device as d','a.id','=','d.roster_detail_id')
+// ->leftJoin('s_devices as e','d.device_id','=','e.id')
+// ->where(['a.department_id' => $department_id->id])
+// ->where('a.date',$appointment_date)
+// ->where(['a.status' => 1, 'a.is_del' => 0, 'b.is_del' => 0, 'c.appointment_type_id' => $appointment_type])
+// ->whereIn('d.device_id',$commonDevice)
+// ->orderBy('a.date')
+// ->get();
+
+ $placeholders = implode(',', array_fill(0, count($commonDevice), '?'));
+ $canshu=array_merge($commonDevice,[$department_id->id,$appointment_date,$appointment_type]);
+ $plan=DB::select("SELECT
+ a.*,
+ dd.devices,
+ b.department_resources_name,
+ c.roster_detail_id,
+ c.count,
+ c.used_count
+FROM
+ s_source_roster_detail AS a
+ LEFT JOIN s_department_resources AS b ON a.resources_id = b.id
+ LEFT JOIN s_source_roster_detail_count AS c ON a.id = c.roster_detail_id
+ JOIN (
+ SELECT
+ roster_detail_id,
+ GROUP_CONCAT( e.device_name SEPARATOR ', ' ) AS devices
+ FROM
+ s_source_roster_detail_device AS d
+ LEFT JOIN s_devices AS e ON d.device_id = e.id
+ WHERE
+ d.device_id IN ($placeholders)
+ GROUP BY
+ d.roster_detail_id
+ ) AS dd ON a.id = dd.roster_detail_id
+WHERE
+ a.department_id = ?
+ AND a.date = ?
+ AND a.STATUS = 1
+ AND a.is_del = 0
+ AND b.is_del = 0
+ AND c.appointment_type_id =?",$canshu);
- //匹配设备(服务组)
- $devices = DB::table('s_devices')->get();
- foreach ($plan_enable as $key => $value){
- // dd($value);
- $plan_enable[$key]->devices = [];
- $array_device_id = explode(",", $value->device_id);
- $names='';
- foreach ($devices as $k => $v) {
- if (in_array($v->id, $array_device_id)) {
- $names=$names. $v->device_name.' ';
- }
- }
- $plan_enable[$key]->devices =$names;
- }
- return \Yz::Return(true, '查询完成', ['today_date' => date("Y-m-d"), 'appointment_date' => $appointment_date, 'weekname' => Tools::GetWeekName($appointment_date), 'mainInfo' => $info, 'plan_list' => $plan_enable]);
+
+ return \Yz::Return(true, '查询完成', ['today_date' => date("Y-m-d"), 'appointment_date' => $appointment_date, 'weekname' => Tools::GetWeekName($appointment_date), 'mainInfo' => $info, 'plan_list' => $plan]);
}
//开始预约占用名额
- public function YuYue($planid, $appointment_type, $mainlistid, $do_type)
+ public function YuYue($planid, $appointment_type, $mainlistids, $do_type)
{
date_default_timezone_set('PRC');
$nowdatetime = date("Y-m-d H:i:s");
@@ -88,71 +135,83 @@ class PlanListService
// $do_type = request('dotype');//操作类型,1预约,2改约
// if (!isset($do_type)) return \Yz::echoError1('参数:操作类型 不能为空');
- $mainInfo = DB::table('s_list')->where(['id' => $mainlistid])->first();
- if (!$mainInfo) return \Yz::echoError1('医嘱不存在');
- //判断状态
- if ($do_type == 1 && $mainInfo->list_status <> 0) return \Yz::echoError1('该信息状态不允许预约,当前状态:' . $mainInfo->list_status);
- if ($do_type == 2 && $mainInfo->list_status <> 1) return \Yz::echoError1('该信息状态不允许改约操作,当前状态:' . $mainInfo->list_status);
+
$planInfo = DB::table('s_source_roster_detail')->where(['id' => $planid, 'status' => 1, 'is_del' => 0])->first();
if (!$planInfo) return \Yz::echoError1('当前时段不可用');
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) 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('此检查项目不可用');
- //查询当前检查项目是否存在互斥
- $cha_hc = DB::table('s_huchi')->where('is_del', 0)
- ->where(function ($q) use ($item) {
- $q->where(['code1' => $item->item_code])->orWhere('code2', $item->item_code);
- })->get();
- if (count($cha_hc) > 0) {
- //查询用户预约中的医嘱
- $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();
- if (count($status_1) > 0) {
- foreach ($status_1 as $key => $value) {
- foreach ($cha_hc as $k => $v) {
- if ($v->code1 == $value->item_code or $v->code2 == $value->item_code) {
- if ($v->time == 0) {
- //如果是永久互斥,直接拒绝
- return \Yz::Return(false, '当前预约项目与' . $value->entrust . '互斥,暂不可预约', ['name' => $value->entrust]);
- }
- if ($v->time > 0) {
- //如果设置互斥时间,则判断预约时间是否超过 正在预约的最后时间段+互斥时间
- $period = DB::table('s_period')->where(['id' => $value->reservation_time])->first();
- $endTime = $period->period_end_time;
- $periodEndDateTime = $value->reservation_date . ' ' . $endTime;
- $date = new DateTime($periodEndDateTime);
- // 添加互斥时间/小时
- $date->add(new \DateInterval('PT' . $v->time . 'H')); // PTXH 表示X小时的时间间隔
- $HuChi_EndDateTime = $date->format('Y-m-d H:i:s');//已经预约的项目结束互斥时间
- $YuYueDateTime = substr($planInfo->date, 0, 10) . ' ' . $planInfo->begin_time;
- if ($HuChi_EndDateTime > $YuYueDateTime) {
- return \Yz::Return(false, '当前预约项目与' . $value->entrust . '互斥,暂不可预约,请预约' . $HuChi_EndDateTime . '后的日期', ['name' => $value->entrust]);
+ if ($planCount->count <= ($planCount->used_count+count($mainlistids))) return \Yz::echoError1('当前预约时间名额不足');
+
+ $oldMainInfos=[];//临时存储原来的主表信息,用于改约
+ //遍历多个s_list表id,前端多选,一次预约多个检查项目
+ foreach ($mainlistids as $key_m=>$mainlistid ){
+ $mainInfo = DB::table('s_list')->where(['id' => $mainlistid])->first();
+ $oldMainInfos[]=$mainInfo;
+ if (!$mainInfo) return \Yz::echoError1('医嘱不存在');
+ //判断状态
+ if ($do_type == 1 && $mainInfo->list_status <> 0) return \Yz::echoError1($mainInfo->entrust.' 该医嘱状态不允许预约,当前状态:' . $mainInfo->list_status);
+ if ($do_type == 2 && $mainInfo->list_status <> 1) return \Yz::echoError1($mainInfo->entrust.' 该医嘱状态不允许改约操作,当前状态:' . $mainInfo->list_status);
+
+
+ //判断互斥(暂时根据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('此检查项目不可用');
+ //查询当前检查项目是否存在互斥
+ $cha_hc = DB::table('s_huchi')->where('is_del', 0)
+ ->where(function ($q) use ($item) {
+ $q->where(['code1' => $item->item_code])->orWhere('code2', $item->item_code);
+ })->get();
+ if (count($cha_hc) > 0) {
+ //查询用户预约中的医嘱
+ $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();
+ if (count($status_1) > 0) {
+ foreach ($status_1 as $key => $value) {
+ foreach ($cha_hc as $k => $v) {
+ if ($v->code1 == $value->item_code or $v->code2 == $value->item_code) {
+ if ($v->time == 0) {
+ //如果是永久互斥,直接拒绝
+ return \Yz::Return(false, '当前预约项目与' . $value->entrust . '互斥,暂不可预约', ['name' => $value->entrust]);
}
+ if ($v->time > 0) {
+ //如果设置互斥时间,则判断预约时间是否超过 正在预约的最后时间段+互斥时间
+ $period = DB::table('s_period')->where(['id' => $value->reservation_time])->first();
+ $endTime = $period->period_end_time;
+ $periodEndDateTime = $value->reservation_date . ' ' . $endTime;
+ $date = new DateTime($periodEndDateTime);
+ // 添加互斥时间/小时
+ $date->add(new \DateInterval('PT' . $v->time . 'H')); // PTXH 表示X小时的时间间隔
+ $HuChi_EndDateTime = $date->format('Y-m-d H:i:s');//已经预约的项目结束互斥时间
+ $YuYueDateTime = substr($planInfo->date, 0, 10) . ' ' . $planInfo->begin_time;
+ if ($HuChi_EndDateTime > $YuYueDateTime) {
+ return \Yz::Return(false, '当前预约项目与' . $value->entrust . '互斥,暂不可预约,请预约' . $HuChi_EndDateTime . '后的日期', ['name' => $value->entrust]);
+ }
- }
+ }
+ }
}
}
}
}
+
}
DB::beginTransaction();
try {
//更新计划明细表使用数量
- $u = DB::table('s_source_roster_detail_count')->where(['id' => $planCount->id])->where('count', '>', 'used_count')->increment('used_count');
+ $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) {
+ if ($cha->count >= ($cha->used_count+count($mainlistids))) {
//更新主表信息
$u_data=[
'list_status' => 1,
@@ -165,22 +224,28 @@ class PlanListService
'xuhao' => 0,
'appointment_type_id' => $appointment_type,
];
- $u_mainList = DB::table('s_list')->where(['id' => $mainlistid])->update($u_data);
+ $u_mainList = DB::table('s_list')->whereIn('id' , $mainlistids)->update($u_data);
$note="预约";
- if ($do_type == 2) {
- $note="改约";
- //如果是改约,则恢复原来的数量
- $u_old = DB::table('s_source_roster_detail_count')->where(['roster_detail_id' => $mainInfo->roster_id, 'appointment_type_id' => $mainInfo->appointment_type_id])->decrement('used_count');
+
+ foreach ($oldMainInfos as $key =>$oldMainInfo){
+
+ if ($do_type == 2) {
+ // 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');
+ }
+ $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'=>$mainlistid,
- 'reg_num'=>$mainInfo->reg_num,
- 'old_status'=>$mainInfo->list_status,
- 'new_status'=>1,
- 'create_user'=>null,
- 'note'=>$note,
- 'data'=>json_encode($u_data)
- ]);
+
if ($u_mainList) {
DB::commit();
return \Yz::Return(true, '预约成功', []);
@@ -191,7 +256,7 @@ class PlanListService
} else {
DB::rollBack();
- return \Yz::echoError1('当前预约时间已无名额');
+ return \Yz::echoError1('当前预约时间名额不足');
}
} else {
@@ -200,7 +265,7 @@ class PlanListService
} catch (\Exception $e) {
DB::rollBack();
- return \Yz::echoError1('预约异常');
+ return \Yz::echoError1('预约异常'.$e);
}
diff --git a/Laravel/public/jq_page/appointment.html b/Laravel/public/jq_page/appointment.html
index 29c3863..d0853d6 100644
--- a/Laravel/public/jq_page/appointment.html
+++ b/Laravel/public/jq_page/appointment.html
@@ -7,12 +7,19 @@
+
+
+
-
+ function MsgAlert(msg){
+ $('#tishi .tishineirong').html(msg);
+ $('#tishi').modal('show');
+ }
+
+
@@ -291,15 +410,19 @@
-
-
+
+
姓名:
患者id:
性别:
@@ -337,106 +460,111 @@
-
-
-
-
-