修改 接收 检查申请的接口

main
yanzai 1 year ago
parent 7ced139ed2
commit e8df67dcd0

Binary file not shown.

@ -80,14 +80,18 @@ class WorkMainController extends Controller
$userInfo = DB::table('users')->where(['id' => $userid])->get();
$department_id = $userInfo[0]->department_id;
$department = DB::table('s_department')->where(['id' => $department_id,'is_del'=>0])->first();
if(!$department) return \Yz::echoError1('科室信息不存在');
// if(!$department) return \Yz::echoError1('科室信息不存在');
$list=DB::table('s_list')
->leftJoin('s_period','s_list.reservation_time','=','s_period.id')
->leftJoin('s_department_resources','s_list.reservation_sources','=','s_department_resources.id')
->select('s_list.*','s_period.period_begin_time','s_period.period_end_time','s_department_resources.department_resources_name')
->where(['RISRAcceptDeptCode'=>$department->department_number]);
->select('s_list.*','s_period.period_begin_time','s_period.period_end_time','s_department_resources.department_resources_name');
if($userInfo[0]->group==2){
$list=$list->whereIn('warddesc', explode(",", $userInfo[0]->ward));
}else{
$list=$list->where(['RISRAcceptDeptCode'=>$department->department_number]);
}
if ($searchInfo['dateRange']!=null and count($searchInfo['dateRange']) == 2) {
$list = $list->where(function ($q) use($searchInfo) {
$q->whereBetween('s_list.entrust_date', $searchInfo['dateRange'])

@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Log;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Services\Xml\ShenQingDanService;
class EntrustController extends Controller
{
@ -76,30 +77,18 @@ class EntrustController extends Controller
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, // 或者使用空数组 []
],
],
];
$res = explode('<soap:Body>', $xmlString)[1];
$res = explode('</soap:Body>', $res)[0];
$xmlData = simplexml_load_string($res);
$jsonData = json_encode($xmlData,JSON_UNESCAPED_UNICODE);
$result = json_decode($jsonData, true);
//如果是推送的检查申请单
if($result['action']=='T0002'){
$service = new ShenQingDanService();
return $service->Save($result,$jsonData);
}
// 将数据转换为 XML
$xml = simplexml_load_string('<?xml version="1.0" encoding="UTF-8"?>' . "\n<root/>");
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');
}
}

@ -67,5 +67,6 @@ class Kernel extends HttpKernel
'log' => \App\Http\Middleware\Log::class,
'check.sign' => \App\Http\Middleware\CheckSign::class,
'check.sign.xml' => \App\Http\Middleware\CheckSignXMl::class,
'xmllog' => \App\Http\Middleware\XmlLog::class,
];
}

@ -0,0 +1,82 @@
<?php
namespace App\Http\Middleware;
use App\Services\LogService;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class XmlLog
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next)
{
// dd($request->getContent());
$routers=[
"接收申请单"=>'/api/v1/T/CreateEntrustRecordXml',
];
$insertid=0;
$data=[
'mark'=>array_search($request->getPathInfo(), $routers),
'ip'=>Log::getTrustedProxiesIp(),
'request_header'=>$request->header(),
'post_data'=>$request->getContent(),
'get_data'=>[],
'request_url'=>$request->getPathInfo()
];
$insertid= self::RequestLog($data,$insertid);
$response= $next($request);
self::RequestLog(['response_data'=>self::JsonEncode($response->getContent())],$insertid);
return $response;
}
public function RequestLog($arr,$id)
{ //记录请求日志
LogService::CheckTableName();
$table_name = 'zz_request_log_' . date('ym');
$response_data = isset($arr['response_data']) ? self::JsonEncode($arr['response_data']) : '';
$header_data = isset($arr['request_header']) ?self::JsonEncode($arr['request_header']):'';
$post_data = isset($arr['post_data'])?self::JsonEncode($arr['post_data']):'';
$get_data = isset($arr['get_data'])?self::JsonEncode($arr['get_data'], JSON_UNESCAPED_UNICODE):'';
$milliseconds = round(microtime(true) * 1000);
$date = date("Y-m-d H:i:s", $milliseconds / 1000);
$formatted_date = sprintf("%s.%03d", $date, $milliseconds % 1000);
// $i=DB::insert("insert into ".$table_name." (request_ip, response_data,header_data,post_data,get_data,request_url,create_time,update_time)
// values (?,?,?,?,?,?,?,?)",[$arr['ip'],$response_data,$header_data,$post_data,$get_data,$arr['request_url'],$formatted_date,$formatted_date]);
// var_dump($i);
if ($id > 0) {
return DB::table($table_name)->where('id', $id)->update([
'response_data' => $response_data,
]);
} else {
return DB::table($table_name)->insertGetId([
'mark'=>$arr['mark'],
'request_ip' => $arr['ip'],
'response_data' => $response_data,
'header_data' => $header_data,
'post_data' => $post_data,
'get_data' => $get_data,
'request_url' => $arr['request_url'],
'create_time' => $formatted_date,
'update_time' => $formatted_date
]);
}
}
public static function JsonEncode($data){ //格式化数据转json
$post_data =$data;
$post_data = json_encode($post_data, JSON_UNESCAPED_UNICODE);
$str_len = mb_strlen($post_data);
$str_size = $str_len / 1024;
if ($str_size > 40) $post_data = '{"data":"Row size too large"}';
return $post_data;
}
}

@ -26,5 +26,30 @@ class Yz{
$result['data']=$data;
return $result;
}
public static function XMLReturn($SourceSystem,$MessageID,$code,$msg)
{
// 准备数据
$data = [
'Response' => [
'Header'=>[
'SourceSystem'=>$SourceSystem,
'MessageID'=>$MessageID,
],
'Body' => [
'ResultCode' => $code,
'ResultContent' => $msg,
'SuccessIDList' => null, // 或者使用空数组 []
],
],
];
// 将数据转换为 XML
$xml = simplexml_load_string('<?xml version="1.0" encoding="UTF-8"?>' . "\n<root/>");
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');
}
}

@ -0,0 +1,33 @@
<?php
namespace App\Providers;
use App\Services\SoapService;
use Illuminate\Support\ServiceProvider;
class SoapServiceProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
$this->app->singleton(SoapService::class, function () {
// 这里替换为你的SOAP服务的WSDL地址
$wsdlUrl = 'http://yijiyuyue//aa.wsdl';
return new SoapService($wsdlUrl);
});
}
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
//
}
}

@ -7,7 +7,7 @@ class UserService
{
public function GetInfoList($arr){
$list=DB::table('users as a')
->select( 'a.id', 'a.cn_name as cname','a.username as uname','a.status','a.created_at','b.group_name','c.department_name')
->select( 'a.id', 'a.cn_name as cname','a.username as uname','a.status','a.created_at','b.group_name','c.department_name','a.ward')
->leftJoin('group as b','a.group','=','b.id')
->leftJoin('s_department as c','a.department_id','=','c.id');
if(isset($arr['status'])){

@ -49,6 +49,7 @@ class LogService
}else{
Schema::create($table_name, function (Blueprint $table) {
$table->id();
$table->string('mark', 100)->nullable();
$table->string('request_ip', 15);
$table->text('post_data');
$table->text('get_data');

@ -0,0 +1,28 @@
<?php
namespace App\Services;
class SoapService
{
protected $client;
public function __construct($wsdlUrl)
{
$options = [
'trace' => 1,
'exceptions' => true,
];
$this->client = new SoapClient($wsdlUrl, $options);
}
public function callSoapMethod($methodName, array $params = [])
{
try {
return $this->client->__soapCall($methodName, $params);
} catch (\SoapFault $e) {
// 处理错误
\Log::error('SOAP Fault: ' . $e->getMessage());
throw $e;
}
}
}

@ -0,0 +1,99 @@
<?php
namespace App\Services\Xml;
use Illuminate\Support\Facades\DB;
class ShenQingDanService
{
public function Save($result,$jsonData)
{
$Body= $result['message']['Request']["Body"];
$Header=$result['message']['Request']["Header"];
$orderList=isset($Body['AddRisAppBillRt']['OrderList'])?$Body['AddRisAppBillRt']['OrderList']:[];
if (!empty($orderList) && !isset($orderList[0])) {
// 如果OrderList当前不是数组的数组则将其转换为单元素数组
$orderList = array($orderList);
}
$insert_count=0;//成功插入数量
DB::beginTransaction();
foreach ($orderList as $key => $order){
$patient_type=null;
if(isset($Body["PATAdmInfo"]["PAADMTypeCode"])){
$p=$Body["PATAdmInfo"]["PAADMTypeCode"];
if($p=='O') $patient_type=1;
if($p=='H') $patient_type=3;
if($p=='E') $patient_type=2;
if($p=='I') $patient_type=0;
}
$params = [
'list_status' => 0,
'reg_num' => $Body["PATPatientInfo"]["PATPatientID"] ?$Body["PATPatientInfo"]["PATPatientID"]: null,
'user_name' => $Body["PATPatientInfo"]["PATName"] ?$Body["PATPatientInfo"]["PATName"]: null,
'user_sex' => $Body["PATPatientInfo"]["PATName"]=='男'?1: 2,
'entrust_code' => $order["RISRCode"] ?$order["RISRCode"]: null,
'entrust' => $order["RISRDesc"] ?$order["RISRDesc"]: null,
'is_pay' => $order["OrdBillStatus"]=='已收费' ? 1: 0,
'reservation_department' => $order["AppDeptDesc"] ?$order["AppDeptDesc"]: null,
'entrust_date' =>$order["RISRSubmitTime"] ?substr($order["RISRSubmitTime"], 0, 10): null,
'entrust_time' => $order["RISRSubmitTime"] ?substr($order["RISRSubmitTime"], 11, 8): null,
'user_brithday' =>$Body["PATPatientInfo"]["PATDob"] ?$Body["PATPatientInfo"]["PATDob"]: null,
'docotr' => $Body["PATAdmInfo"]["PAADMDocDesc"] ?$Body["PATAdmInfo"]["PAADMDocDesc"]: null,
'patient_type' =>$patient_type,
'user_phone' => $Body["PATPatientInfo"]["PATTelephone"] ? $Body["PATPatientInfo"]["PATTelephone"]: null,
'implement_department' => $order["RISRAcceptDeptDesc"] ?$order["RISRAcceptDeptDesc"]: null,
'entrust_id' => $order["OEORIOrderItemID"] ?$order["OEORIOrderItemID"]: null,//his传过来的本地医嘱id
'episodeid' => $Body["PATAdmInfo"]["PAADMVisitNumber"] ?$Body["PATAdmInfo"]["PAADMVisitNumber"]: null, //就诊号
'RISRExamID' =>$order["RISRExamID"] ?$order["RISRExamID"]: null, //检查号
'RISRAcceptDeptCode' => $order["RISRAcceptDeptCode"] ?$order["RISRAcceptDeptCode"]: null, //接收科室代码
'warddesc' => $Body["PATAdmInfo"]["PAADMAdmWardDesc"]? $Body["PATAdmInfo"]["PAADMAdmWardDesc"] :null, //病区
'beddesc' => $Body["PATAdmInfo"]["PAADMCurBedNo"]? $Body["PATAdmInfo"]["PAADMCurBedNo"] :null, //病床号
];
$requiredFields = [
'reg_num', 'user_name', 'user_sex', 'entrust', 'is_pay',
'reservation_department', 'entrust_date', 'entrust_time',
'user_brithday', 'docotr', 'patient_type', 'user_phone',
'implement_department', 'entrust_id', 'episodeid',
'RISRExamID', 'RISRAcceptDeptCode'
];
// 判断是否为空
foreach ($requiredFields as $field) {
if (!isset($params[$field]) || $params[$field] === null) {
return \Yz::echoError1('参数' . $field . '不能为空');
}
}
$insertListId = DB::table('s_list')->insertGetId($params);
if ($insertListId) {
$data = [
'list_id' => $insertListId,
'reg_num' => $Body["PATPatientInfo"]["PATPatientID"],
'new_status' => 0,
'create_user' => '接口',
'note' => '创建记录',
'data' => $jsonData,//原始数据
];
$insertLog = DB::table('s_list_log')->insert($data);
if ($insertLog) {
$insert_count++;
} else {
DB::rollBack();
return \Yz::XMLReturn($Header['SourceSystem'],$Header['MessageID'],-1,'失败');
}
}else {
DB::rollBack();
return \Yz::XMLReturn($Header['SourceSystem'],$Header['MessageID'],-1,'失败');
}
}
if(count($orderList)==$insert_count){
DB::commit();
return \Yz::XMLReturn($Header['SourceSystem'],$Header['MessageID'],0,'成功');
}else{
DB::rollBack();
return \Yz::XMLReturn($Header['SourceSystem'],$Header['MessageID'],-1,'失败');
}
}
}

@ -188,7 +188,7 @@ return [
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
App\Providers\SoapServiceProvider::class,
],
/*

@ -20,6 +20,7 @@
let today_date=''
let tomorrowDate=''
let MainInfo_ids=[];//选中的检查项目对应的mainid
let PrintInfo=null;//打印信息
//获取url参数
function getParameterByName(name, url) {
if (!url) url = decodeURIComponent(window.location.href)
@ -361,13 +362,57 @@
}
$('#dayin_button').on('click',function(){
PrintInfo=null
$("#shenqingdan").html('')
if($(".lanse_bg").length==0){
MsgAlert('请选择要打印的申请单');
return false;
}
$("#shenqingdan").show();
$("#shenqingdan").jqprint();
$("#shenqingdan").hide();
let enids=''
$('.lanse_bg').each(function(){
enids=enids+$(this).data('entrustid')+','
})
//调用接口查询项目详情
$('#loadingModal').modal('show');
$.post(BaseUrl+'/api/admin/getMainDetail', {
regnum: getParameterByName('regnum'),
entrustid: enids,
episodeid: getParameterByName('episodeid'),
appointment_type:getParameterByName('appointment_type')
}, function(data) {
$('#loadingModal').modal('hide');
if (data.status) {
let info=data.data.info
let enable=true
info.forEach(function(v,i){
if(v.maininfo.list_status!=1){
MsgAlert(v.maininfo.entrust+" 不可打印,请重新选择");
enable=false
}
})
if(enable){
PrintInfo=data.data.info
PrintInfo.forEach(function(v,i){
console.log(i)
$("#shenqingdan").append(
'<div style="height:100vh;">' +
'<div style="width: 100%;text-align: center;font-size: 14px;">深圳市南山区妇幼保健院</div>'+
'<div style="width: 100%;text-align: center;font-size: 18px;font-weight: bold;">检查申请单</div>'+
'<div style="width: 100%; border: 1px solid #ccc;padding: 20px;">'+
'<div>检查项目:'+v.maininfo.entrust+'</div>'+
'</div>'+
'</div>'
)
})
$("#shenqingdan").show();
$("#shenqingdan").jqprint();
$("#shenqingdan").hide();
}
}
})
})
$('#shuaxin_button').on('click',function(){
window.location.reload()
@ -557,8 +602,15 @@
</div>
<div>
<div id="shenqingdan">
fds
</div>
<!-- <div>
<div style="width: 100%;text-align: center;font-size: 14px;">深圳市南山区妇幼保健院</div>
<div style="width: 100%;text-align: center;font-size: 18px;font-weight: bold;">检查申请单</div>
<div style="width: 100%; border: 1px solid #ccc;padding: 20px;">
<div>检查项目:腹部彩超</div>
</div>
</div> -->
</div>
</div>
@ -625,6 +677,10 @@
.lanse_bg{
background-color: #31b0d5;
}
#yizhulist{
height:100vh;
overflow-y: auto;
}
</style>

@ -121,8 +121,8 @@ Route::group(['middleware'=>['check.sign','log'],'prefix'=>'v1'],function () {
});
//对外接口
Route::group(['middleware'=>['check.sign.xml' ],'prefix'=>'v1'],function () {
Route::post('T/CreateEntrustRecordXml','App\Http\Controllers\API\Third\EntrustController@CreateRecordXml');//获取个人医嘱列表
Route::group(['middleware'=>['xmllog'],'prefix'=>'v1'],function () {
Route::post('T/CreateRecordXml','App\Http\Controllers\API\Third\EntrustController@CreateRecordXml');//获取个人医嘱列表
});

Binary file not shown.

@ -5,7 +5,11 @@
<el-row>
<el-col :span="4" class="logo">
<div><img :src="configInfo.站点图片"/></div>
<div>{{configInfo.站点名称}}</div>
<div>
<div style="font-size: 16px;">深圳市南山区妇幼保健院</div>
<div>{{configInfo.站点名称}}</div>
</div>
</el-col>
<el-col :span="3">
<el-icon size="30" color="#5f5f5f" class="offOn" v-if="isCollapse==true"

@ -24,6 +24,7 @@
<el-table-column prop="uname" label="用户名" />
<el-table-column prop="group_name" label="分组" />
<el-table-column prop="department_name" label="科室" />
<el-table-column prop="ward" label="病区" />
<el-table-column prop="status" label="状态">
<template #default="scope">
<el-tag v-if="scope.row.status==1" class="ml-2" type="success"></el-tag>

@ -20,29 +20,32 @@
<el-option label="已结束" value="3" />
</el-select>
</el-form-item>
<el-form-item>
<el-select :filterable="true" clearable v-model="searchInfo.patient_type" placeholder="患者类型"
style="margin-left: 8px;width: 150px;">
<el-option label="住院" value="0" />
<el-option label="门诊" value="1" />
<el-option label="急诊" value="2" />
<el-option label="体检" value="3" />
</el-select>
</el-form-item>
<el-form-item>
<el-select multiple :filterable="true" clearable v-model="searchInfo.resources" placeholder="资源"
style="margin-left: 8px;width: 250px;">
<el-option v-for="(item,index) in enableResourceList" :key="index"
:label="item.department_resources_name" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item>
<el-select :filterable="true" clearable v-model="searchInfo.services_group" placeholder="服务组"
style="margin-left: 8px;width: 150px;">
<el-option v-for="(item,index) in EnableDeviceList" :key="index" :label="item.device_name"
:value="item.id" />
</el-select>
</el-form-item>
<el-form-item v-if="loginUserinfo.group!=2">
<el-select :filterable="true" clearable v-model="searchInfo.patient_type" placeholder="患者类型"
style="margin-left: 8px;width: 150px;">
<el-option label="住院" value="0" />
<el-option label="门诊" value="1" />
<el-option label="急诊" value="2" />
<el-option label="体检" value="3" />
</el-select>
</el-form-item>
<el-form-item v-if="loginUserinfo.group!=2">
<el-select multiple :filterable="true" clearable v-model="searchInfo.resources" placeholder="资源"
style="margin-left: 8px;width: 250px;">
<el-option v-for="(item,index) in enableResourceList" :key="index"
:label="item.department_resources_name" :value="item.id" />
</el-select>
</el-form-item >
<el-form-item v-if="loginUserinfo.group!=2">
<el-select :filterable="true" clearable v-model="searchInfo.services_group" placeholder="服务组"
style="margin-left: 8px;width: 150px;">
<el-option v-for="(item,index) in EnableDeviceList" :key="index" :label="item.device_name"
:value="item.id" />
</el-select>
</el-form-item>
<el-form-item>
<el-input v-model="searchInfo.reg_num" placeholder="登记号" style="width: 200px;margin-left: 8px;" />
</el-form-item>
@ -485,11 +488,19 @@
LogDataShow.value = true
LogDataJson.value = data
}
let loginUserinfo=ref(null);
if(sessionStorage.getItem("LoginUserInfo")){
loginUserinfo.value=JSON.parse(sessionStorage.getItem("LoginUserInfo"))
}
onMounted(() => {
getEnableResource()
if(loginUserinfo.value.group!=2){
getEnableResource()
}
GetEnableDeviceListFunc()
GetServiceDate()
})
</script>

Loading…
Cancel
Save