|
|
<?php
|
|
|
|
|
|
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;
|
|
|
|
|
|
class EntrustController extends Controller
|
|
|
{
|
|
|
//创建医嘱记录进入 s_list表
|
|
|
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, //接收科室代码
|
|
|
];
|
|
|
$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 . '不能为空');
|
|
|
}
|
|
|
}
|
|
|
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),//原始数据
|
|
|
];
|
|
|
$insertLog = DB::table('s_list_log')->insert($data);
|
|
|
if ($insertLog) {
|
|
|
DB::commit();
|
|
|
return \Yz::Return(true, '保存成功', []);
|
|
|
} else {
|
|
|
DB::rollBack();
|
|
|
return \Yz::echoError1('保存失败');
|
|
|
}
|
|
|
} 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('<?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');
|
|
|
|
|
|
}
|
|
|
}
|