diff --git a/Laravel/app/Lib/Yz.php b/Laravel/app/Lib/Yz.php
index 12ee1cd..b1e5efa 100644
--- a/Laravel/app/Lib/Yz.php
+++ b/Laravel/app/Lib/Yz.php
@@ -10,13 +10,13 @@ class Yz{
$result=array();
$result['status']='no';
$result['msg']=$msg;
- return response()->json($result)->setEncodingOptions(JSON_UNESCAPED_UNICODE);
+ return $result;
}
public static function echoError1($msg){
$result=array();
$result['status']=false;
$result['msg']=$msg;
- return response()->json($result)->setEncodingOptions(JSON_UNESCAPED_UNICODE);
+ return $result;
}
public static function Return($status,$msg,$data=[]){
@@ -38,18 +38,35 @@ class Yz{
'Body' => [
'ResultCode' => $code,
'ResultContent' => $msg,
- 'SuccessIDList' => null, // 或者使用空数组 []
+ 'SuccessIDList' => [1,2,4], // 或者使用空数组 []
],
],
];
// 将数据转换为 XML
$xml = simplexml_load_string('' . "");
- array_walk_recursive($data, function($value, $key) use ($xml) {
- $child = $xml->addChild($key, $value);
- });
+// array_walk_recursive($data, function($value, $key) use ($xml) {
+// $child = $xml->addChild($key, $value);
+// });
+
+ // 递归添加数据到 XML
+ self::addNode($xml, $data);
$xmlString = $xml->asXML();
// 设置响应头为 XML 并返回
return response($xmlString)->header('Content-Type', 'text/xml');
}
+
+ private static function addNode(SimpleXMLElement $xml, array $data)
+ {
+ foreach ($data as $key => $value) {
+ if (is_array($value)) {
+ // 如果值是一个数组,则创建一个新节点并递归调用
+ $node = $xml->addChild($key);
+ self::addNode($node, $value);
+ } else {
+ // 否则直接添加节点
+ $xml->addChild($key, $value);
+ }
+ }
+ }
}
diff --git a/Laravel/app/Services/Admin/YeWu/PlanListService.php b/Laravel/app/Services/Admin/YeWu/PlanListService.php
index e86b9f7..cf50163 100644
--- a/Laravel/app/Services/Admin/YeWu/PlanListService.php
+++ b/Laravel/app/Services/Admin/YeWu/PlanListService.php
@@ -212,7 +212,7 @@ WHERE
$enableCheckTime = $date;//到此时间后可进行预约
$plan_dateTime = $planInfo->date . ' ' . $planInfo->end_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") . "之后的时间");
+ if ($plan_dateTime < $enableCheckTime and $item->check_begin_time>0) 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();
@@ -333,6 +333,59 @@ WHERE
}
+ public function AutoYuYue($regnum,$entrustids,$episodeid,$appointment_type)
+ {
+ $dateRange=config('app.globals.可用号源查询范围');
+// $regnum = request('regnum');
+// $entrustids = request('entrustid');
+// $episodeid = request('episodeid');
+// $appointment_type = request('appointment_type'); //预约类型
+ $TodayDateTime = date("Y-m-d H:i:s");
+
+
+ $startDate = new DateTime();
+ // 设定结束日期为当前日期加7天
+ $endDate = new DateTime();
+ $endDate->modify('+' . $dateRange . ' day');
+ // 循环遍历每一天
+ $currentDate = $startDate;
+ $enable_plan=false;
+ while ($currentDate <= $endDate) {
+ $nowdate = $currentDate->format('Y-m-d');
+ $s = $this->GetEnablePlan($regnum, $entrustids, $episodeid, $appointment_type, $nowdate);
+
+ if ($s['status']) {
+ $list = $s['data']['plan_list'];
+ if (count($list) > 0) {
+ foreach ($list as $k => $v) {
+ if($v->count-$v->used_count>0 and $TodayDateTime< $v->date.' '.$v->end_reservation_time){
+ $enable_plan=$v;
+ break;
+ }
+ }
+ if(!!$enable_plan){
+ break;
+ }
+ }
+ }
+
+ // 每次循环增加一天
+ $currentDate->modify('+1 day');
+ }
+ if(!!$enable_plan){
+ $mainlistids=DB::table('s_list')->whereIn('entrust_id',$entrustids)->pluck('id')->toArray();
+ $yuyue=$this->YuYue($enable_plan->id, $appointment_type, $mainlistids, 1);
+ if($yuyue['status']==false){
+ return \Yz::echoError1($yuyue['msg']);
+ }
+ if($yuyue['status']===true){
+ return \Yz::Return(true,"预约成功",['entrust_id'=>$entrustids,'date'=>$enable_plan->date,'begin_time'=>$enable_plan->begin_time,'end_time'=>$enable_plan->end_time]);
+ }
+
+ }else{
+ return \Yz::echoError1('最近'.$dateRange.'日无可用号源');
+ }
+ }
public function CancelYuYue($MainListId, $reg_num)
{
diff --git a/Laravel/app/Services/Xml/ShenQingDanService.php b/Laravel/app/Services/Xml/ShenQingDanService.php
index f1da0d2..c3fb410 100644
--- a/Laravel/app/Services/Xml/ShenQingDanService.php
+++ b/Laravel/app/Services/Xml/ShenQingDanService.php
@@ -2,6 +2,8 @@
namespace App\Services\Xml;
+use App\Http\Controllers\API\Admin\YeWu\PlanListController;
+use App\Services\Admin\YeWu\PlanListService;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
@@ -18,6 +20,7 @@ class ShenQingDanService
$orderList = array($orderList);
}
$insert_count = 0;//成功插入数量
+ $yuyueInfo=false;//自动预约信息
DB::beginTransaction();
foreach ($orderList as $key => $order) {
$patient_type = null;
@@ -71,6 +74,17 @@ class ShenQingDanService
$insertListId = DB::table('s_list')->insertGetId($params);
if ($insertListId) {
+ if(config('app.globals.自动预约')==1){
+ $planser=new PlanListService();
+ $yuyue= $planser->AutoYuYue($params['reg_num'],[$params['entrust_id']],$params['episodeid'],1);
+ if($yuyue['status']==false){
+ DB::rollBack();
+ return \Yz::XMLReturn($Header['SourceSystem'], $Header['MessageID'], -1, '自动预约失败,'.$yuyue['msg'].',推送失败');
+ }
+ if($yuyue['status']===true){
+ $yuyueInfo[]=$yuyue['data'];
+ }
+ }
$data = [
'list_id' => $insertListId,
'reg_num' => $Body["PATPatientInfo"]["PATPatientID"],
@@ -95,7 +109,8 @@ class ShenQingDanService
}
if (count($orderList) == $insert_count) {
DB::commit();
- return \Yz::XMLReturn($Header['SourceSystem'], $Header['MessageID'], 0, '成功');
+
+ return \Yz::XMLReturn($Header['SourceSystem'], $Header['MessageID'], 0, ['SendStatus'=>true,"YuyueInfo"=>$yuyueInfo]);
} else {
DB::rollBack();
return \Yz::XMLReturn($Header['SourceSystem'], $Header['MessageID'], -1, '失败');
diff --git a/YiJi-admin/index.html b/YiJi-admin/index.html
index 117ccc1..4ce383c 100644
--- a/YiJi-admin/index.html
+++ b/YiJi-admin/index.html
@@ -4,7 +4,7 @@
-
测试医院-医技预约
+ 演示医院-医技预约
diff --git a/YiJi-admin/src/views/Index.vue b/YiJi-admin/src/views/Index.vue
index 99dda72..522fbce 100644
--- a/YiJi-admin/src/views/Index.vue
+++ b/YiJi-admin/src/views/Index.vue
@@ -6,7 +6,7 @@
-
医技预约
+
演示医院
{{configInfo.站点名称}}
@@ -54,7 +54,7 @@