|
|
|
|
@ -361,6 +361,155 @@ function QueryHisShenQingDan()
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 测试 HIS 回写接口入参收集
|
|
|
|
|
* 根据 s_list ID 查询 HIS 申请单,组装回写所需参数并返回,不实际调用回写接口
|
|
|
|
|
*/
|
|
|
|
|
public function TestHisCallbackParams()
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$id = request('id');
|
|
|
|
|
if (empty($id)) {
|
|
|
|
|
return \Yz::JsonReturn(false, '参数 id 不能为空', []);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$sList = DB::table('s_list')->where('id', $id)->first();
|
|
|
|
|
if (!$sList) {
|
|
|
|
|
return \Yz::JsonReturn(false, '未找到该记录', []);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$result = [
|
|
|
|
|
's_list_info' => [
|
|
|
|
|
'id' => $sList->id,
|
|
|
|
|
'entrust_id' => $sList->entrust_id,
|
|
|
|
|
'entrust_code' => $sList->entrust_code,
|
|
|
|
|
'entrust' => $sList->entrust,
|
|
|
|
|
'reg_num' => $sList->reg_num,
|
|
|
|
|
'episodeid' => $sList->episodeid,
|
|
|
|
|
'app_num' => $sList->app_num,
|
|
|
|
|
'patient_type' => $sList->patient_type,
|
|
|
|
|
'reservation_sources' => $sList->reservation_sources,
|
|
|
|
|
'RISRAcceptDeptCode' => $sList->RISRAcceptDeptCode,
|
|
|
|
|
'implement_department' => $sList->implement_department,
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// 1. 获取 execDeptCode / execDeptName(通过排班→诊室资源→执行科室链路)
|
|
|
|
|
$execDeptCode = '';
|
|
|
|
|
$execDeptName = '';
|
|
|
|
|
$execDeptInfo = [];
|
|
|
|
|
|
|
|
|
|
if (!empty($sList->reservation_sources)) {
|
|
|
|
|
$resource = DB::table('s_department_resources')
|
|
|
|
|
->where('id', $sList->reservation_sources)
|
|
|
|
|
->first();
|
|
|
|
|
if ($resource) {
|
|
|
|
|
$deptId = $resource->execute_department_id ?: $resource->department_id;
|
|
|
|
|
if ($deptId) {
|
|
|
|
|
$dept = DB::table('s_department')
|
|
|
|
|
->where('id', $deptId)
|
|
|
|
|
->first();
|
|
|
|
|
if ($dept) {
|
|
|
|
|
$execDeptCode = $dept->department_number;
|
|
|
|
|
$execDeptName = $dept->department_name;
|
|
|
|
|
$execDeptInfo = [
|
|
|
|
|
'resources_id' => $sList->reservation_sources,
|
|
|
|
|
'execute_department_id' => $resource->execute_department_id,
|
|
|
|
|
'department_id' => $resource->department_id,
|
|
|
|
|
'dept_id_used' => $deptId,
|
|
|
|
|
'department_number' => $dept->department_number,
|
|
|
|
|
'department_name' => $dept->department_name,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$result['exec_dept_info'] = $execDeptInfo;
|
|
|
|
|
|
|
|
|
|
// 2. 调 HIS 查询申请单接口
|
|
|
|
|
$patientHisTypeMap = [
|
|
|
|
|
0 => '03', // 住院
|
|
|
|
|
1 => '01', // 门诊
|
|
|
|
|
2 => '02', // 急诊
|
|
|
|
|
3 => '04', // 体检
|
|
|
|
|
];
|
|
|
|
|
$visitTypeCode = $patientHisTypeMap[$sList->patient_type] ?? '09';
|
|
|
|
|
|
|
|
|
|
$hisQueryData = [
|
|
|
|
|
'visitSqNo' => $sList->episodeid,
|
|
|
|
|
'requestNo' => $sList->app_num,
|
|
|
|
|
'visitTypeCode' => $visitTypeCode,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$result['his_query'] = [
|
|
|
|
|
'params' => $hisQueryData,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$hisRes = HisController::Get('查询检查申请单', $hisQueryData);
|
|
|
|
|
$result['his_query']['response'] = $hisRes;
|
|
|
|
|
$result['his_query']['success'] = ($hisRes['code'] == 200);
|
|
|
|
|
|
|
|
|
|
if ($hisRes['code'] == 200 && !empty($hisRes['data'])) {
|
|
|
|
|
$hisData = $hisRes['data'][0] ?? null;
|
|
|
|
|
|
|
|
|
|
if ($hisData) {
|
|
|
|
|
// 3. 提取申请单级数据
|
|
|
|
|
$comboNo = $hisData['requestNo'] ?? '';
|
|
|
|
|
// 住院取 episodeid,门诊取 reg_num
|
|
|
|
|
$inpatientNo = $sList->patient_type == 0 ? $sList->episodeid : $sList->reg_num;
|
|
|
|
|
|
|
|
|
|
// 4. 匹配项目级数据
|
|
|
|
|
$moOrder = '';
|
|
|
|
|
$hisOrderNo = '';
|
|
|
|
|
$matchedItem = [];
|
|
|
|
|
|
|
|
|
|
if (!empty($hisData['itemList']) && is_array($hisData['itemList'])) {
|
|
|
|
|
foreach ($hisData['itemList'] as $item) {
|
|
|
|
|
if (($item['termCode'] ?? '') == $sList->entrust_code) {
|
|
|
|
|
$moOrder = $item['orderNo'] ?? '';
|
|
|
|
|
$hisOrderNo = $item['chargeList'][0]['hisOrderNo'] ?? '';
|
|
|
|
|
$matchedItem = [
|
|
|
|
|
'termCode' => $item['termCode'] ?? '',
|
|
|
|
|
'termName' => $item['termName'] ?? '',
|
|
|
|
|
'orderNo' => $item['orderNo'] ?? '',
|
|
|
|
|
'hisOrderNo' => $hisOrderNo,
|
|
|
|
|
];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$result['matched_item'] = $matchedItem;
|
|
|
|
|
|
|
|
|
|
// 5. 组装回写参数
|
|
|
|
|
$result['callback_params'] = [
|
|
|
|
|
'moOrder' => $moOrder,
|
|
|
|
|
'execDeptCode' => $execDeptCode,
|
|
|
|
|
'execDeptName' => $execDeptName,
|
|
|
|
|
'inpatientNo' => $inpatientNo,
|
|
|
|
|
'hisOrderNo' => $hisOrderNo,
|
|
|
|
|
'comboNo' => $comboNo,
|
|
|
|
|
'itemCode' => $sList->entrust_code,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
$result['his_query']['response'] = null;
|
|
|
|
|
$result['his_query']['success'] = false;
|
|
|
|
|
$result['his_query']['error'] = $e->getMessage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return \Yz::JsonReturn(true, '查询完成', $result);
|
|
|
|
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
return \Yz::JsonReturn(false, '接口异常:' . $e->getMessage(), [
|
|
|
|
|
'error_file' => $e->getFile(),
|
|
|
|
|
'error_line' => $e->getLine()
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function build_yiji_url($regnum, $entrustid, $episodeid)
|
|
|
|
|
{
|
|
|
|
|
// 固定参数
|
|
|
|
|
|