|
|
<?php
|
|
|
|
|
|
namespace App\Http\Controllers\API\Third;
|
|
|
|
|
|
use App\Http\Controllers\API\His\HisController;
|
|
|
use App\Http\Controllers\Controller;
|
|
|
use Illuminate\Http\Request;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
class YiJiController extends Controller
|
|
|
{
|
|
|
//查询是否跳转医技
|
|
|
public function CheckAppointment(){
|
|
|
|
|
|
$patientId = request('patientId');//病人id
|
|
|
$orderIdList = request('orderIdList');//医嘱号(数组)
|
|
|
$episodeid = request('episodeid');//住院号或门诊号
|
|
|
$patientType = request('patientType');// 01:门诊 02:急诊 03:住院 04:体检 05:互联网 09:其他
|
|
|
$is_redirect = false;
|
|
|
$url="";
|
|
|
if(empty($orderIdList)) return \Yz::JsonError("医嘱号列表不能为空");
|
|
|
|
|
|
//1.根据过来的参数 查询本地库是否有相关记录
|
|
|
foreach($orderIdList as $orderId){
|
|
|
$db_entrust=DB::table('s_list')->where([
|
|
|
'reg_num'=>$patientId,
|
|
|
'entrust_id'=>$orderId,
|
|
|
'episodeid'=>$episodeid,
|
|
|
])->first();
|
|
|
if(!$db_entrust){
|
|
|
//调用his接口,入库
|
|
|
$His=New HisController();
|
|
|
$His::Post("查询检查申请单",[]);
|
|
|
}else{
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//2.本地库无记录则查询his获取数据后进行更新 ,如果有,则进行跳转
|
|
|
|
|
|
if(true){
|
|
|
$is_redirect=true;
|
|
|
$url=$this->build_yiji_url($patientId,$orderIdList,$episodeid);
|
|
|
}else{
|
|
|
$is_redirect=false;
|
|
|
}
|
|
|
return \Yz::JsonReturn(true,'查询成功',['is_redirect'=>$is_redirect,'url'=>$url]);
|
|
|
}
|
|
|
|
|
|
function QueryHisShenQingDan()
|
|
|
{
|
|
|
|
|
|
}
|
|
|
function build_yiji_url($regnum, $entrustid, $episodeid) {
|
|
|
// 固定参数
|
|
|
$dotype = 1;
|
|
|
$appointment_type = 1;
|
|
|
|
|
|
// 判断 entrustid 是否为数组,如果是,则用逗号 , 拼接并分别进行 rawurlencode 编码
|
|
|
if (is_array($entrustid)) {
|
|
|
// 对数组中的每个元素进行 rawurlencode 编码后再拼接
|
|
|
$entrustid_str = implode(',', array_map('rawurlencode', $entrustid));
|
|
|
}
|
|
|
|
|
|
// 构造查询参数,并对 regnum 和 episodeid 使用 rawurlencode 编码
|
|
|
$params = [
|
|
|
'regnum' => rawurlencode($regnum),
|
|
|
'entrustid' => $entrustid_str,
|
|
|
'episodeid' => rawurlencode($episodeid),
|
|
|
'dotype' => $dotype,
|
|
|
'appointment_type' => $appointment_type,
|
|
|
];
|
|
|
|
|
|
// 使用 http_build_query 构建查询字符串,注意设置第四个参数为 PHP_QUERY_RFC3986
|
|
|
// 以确保生成的 URL 符合 RFC 3986 标准
|
|
|
$query = http_build_query($params, '', '&', PHP_QUERY_RFC3986);
|
|
|
|
|
|
// 返回完整 URL
|
|
|
return "http://192.168.80.76/yiji?$query";
|
|
|
}
|
|
|
}
|