|
|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\API;
|
|
|
|
|
|
|
|
|
|
use App\Http\Controllers\API\His\HisController;
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
|
use Barryvdh\Snappy\Facades\SnappyPdf;
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
@ -130,6 +131,36 @@ public function GetCheckPdf()
|
|
|
|
|
->orderByRaw('FIELD(a.entrust_id, ' . implode(',', array_map('intval', $normalIds)) . ')')
|
|
|
|
|
->get();
|
|
|
|
|
|
|
|
|
|
//预查询 ROC 缓存:diagnosisName 或 medicalHistory 为空时补充数据
|
|
|
|
|
$rocDataMap = [];
|
|
|
|
|
$rocKeys = [];
|
|
|
|
|
foreach ($list as $item) {
|
|
|
|
|
if ((empty($item->diagnosisName) || empty($item->medicalHistory))
|
|
|
|
|
&& !empty($item->episodeid) && !empty($item->app_num)) {
|
|
|
|
|
$key = $item->episodeid . '|' . $item->app_num;
|
|
|
|
|
$rocKeys[$key] = [
|
|
|
|
|
'episodeid' => $item->episodeid,
|
|
|
|
|
'app_num' => $item->app_num,
|
|
|
|
|
'patient_type' => $item->patient_type,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
foreach ($rocKeys as $key => $info) {
|
|
|
|
|
$res = HisController::GetApplyDetail(
|
|
|
|
|
$info['episodeid'],
|
|
|
|
|
$info['app_num'],
|
|
|
|
|
$info['patient_type'],
|
|
|
|
|
'本地'
|
|
|
|
|
);
|
|
|
|
|
if ($res['code'] == 200 && !empty($res['data'])) {
|
|
|
|
|
$rocData = $res['data'][0];
|
|
|
|
|
$rocDataMap[$key] = [
|
|
|
|
|
'diagnosisName' => $rocData['diagnosisName'] ?? '',
|
|
|
|
|
'medicalHistory' => $rocData['medicalHistory'] ?? '',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//三层分组
|
|
|
|
|
$groups = [];
|
|
|
|
|
foreach ($list as $item) {
|
|
|
|
|
@ -171,6 +202,7 @@ public function GetCheckPdf()
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$rocKey = ($item->episodeid ?? '') . '|' . ($item->app_num ?? '');
|
|
|
|
|
$groups[$typeKey]['patients'][$patientKey]['rooms'][$roomKey]['items'][] = [
|
|
|
|
|
'id' => $item->id,
|
|
|
|
|
'entrust_id' => $item->entrust_id,
|
|
|
|
|
@ -182,6 +214,14 @@ public function GetCheckPdf()
|
|
|
|
|
'period_begin_time' => $item->period_begin_time,
|
|
|
|
|
'period_end_time' => $item->period_end_time,
|
|
|
|
|
'reservation_sources' => $item->reservation_sources,
|
|
|
|
|
'diagnosisName' => !empty($item->diagnosisName)
|
|
|
|
|
? $item->diagnosisName
|
|
|
|
|
: ($rocDataMap[$rocKey]['diagnosisName'] ?? ''),
|
|
|
|
|
'medicalHistory' => !empty($item->medicalHistory)
|
|
|
|
|
? $item->medicalHistory
|
|
|
|
|
: ($rocDataMap[$rocKey]['medicalHistory'] ?? ''),
|
|
|
|
|
'docotr' => $item->docotr ?? '',
|
|
|
|
|
'reservation_department' => $item->reservation_department ?? '',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -262,6 +302,12 @@ public function GetCheckPdf()
|
|
|
|
|
->values()
|
|
|
|
|
->toArray();
|
|
|
|
|
$room['warm_tips'] = $tips;
|
|
|
|
|
|
|
|
|
|
//申请医生、申请科室、临床诊断、病史资料:去重,中文逗号分割
|
|
|
|
|
$room['doctor'] = implode(',', array_values(array_unique(array_filter(array_column($room['items'], 'docotr')))));
|
|
|
|
|
$room['apply_department'] = implode(',', array_values(array_unique(array_filter(array_column($room['items'], 'reservation_department')))));
|
|
|
|
|
$room['diagnosis_name'] = implode(',', array_values(array_unique(array_filter(array_column($room['items'], 'diagnosisName')))));
|
|
|
|
|
$room['medical_history'] = implode(',', array_values(array_unique(array_filter(array_column($room['items'], 'medicalHistory')))));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -473,6 +519,36 @@ public function GenerateGroupedCheckPdf()
|
|
|
|
|
$type = request('Type', 'group');
|
|
|
|
|
$p_type = config('app.globals.患者类型');
|
|
|
|
|
|
|
|
|
|
//预查询 ROC 缓存:diagnosisName 或 medicalHistory 为空时补充数据
|
|
|
|
|
$rocDataMap = [];
|
|
|
|
|
$rocKeys = [];
|
|
|
|
|
foreach ($list as $item) {
|
|
|
|
|
if ((empty($item->diagnosisName) || empty($item->medicalHistory))
|
|
|
|
|
&& !empty($item->episodeid) && !empty($item->app_num)) {
|
|
|
|
|
$key = $item->episodeid . '|' . $item->app_num;
|
|
|
|
|
$rocKeys[$key] = [
|
|
|
|
|
'episodeid' => $item->episodeid,
|
|
|
|
|
'app_num' => $item->app_num,
|
|
|
|
|
'patient_type' => $item->patient_type,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
foreach ($rocKeys as $key => $info) {
|
|
|
|
|
$res = HisController::GetApplyDetail(
|
|
|
|
|
$info['episodeid'],
|
|
|
|
|
$info['app_num'],
|
|
|
|
|
$info['patient_type'],
|
|
|
|
|
'本地'
|
|
|
|
|
);
|
|
|
|
|
if ($res['code'] == 200 && !empty($res['data'])) {
|
|
|
|
|
$rocData = $res['data'][0];
|
|
|
|
|
$rocDataMap[$key] = [
|
|
|
|
|
'diagnosisName' => $rocData['diagnosisName'] ?? '',
|
|
|
|
|
'medicalHistory' => $rocData['medicalHistory'] ?? '',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//三层分组:patient_type → 患者标识 → 诊室
|
|
|
|
|
$groups = [];
|
|
|
|
|
foreach ($list as $item) {
|
|
|
|
|
@ -519,6 +595,7 @@ public function GenerateGroupedCheckPdf()
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$rocKey = ($item->episodeid ?? '') . '|' . ($item->app_num ?? '');
|
|
|
|
|
$groups[$typeKey]['patients'][$patientKey]['rooms'][$roomKey]['items'][] = [
|
|
|
|
|
'id' => $item->id,
|
|
|
|
|
'entrust' => $item->entrust,
|
|
|
|
|
@ -529,6 +606,14 @@ public function GenerateGroupedCheckPdf()
|
|
|
|
|
'period_begin_time' => $item->period_begin_time,
|
|
|
|
|
'period_end_time' => $item->period_end_time,
|
|
|
|
|
'reservation_sources' => $item->reservation_sources,
|
|
|
|
|
'diagnosisName' => !empty($item->diagnosisName)
|
|
|
|
|
? $item->diagnosisName
|
|
|
|
|
: ($rocDataMap[$rocKey]['diagnosisName'] ?? ''),
|
|
|
|
|
'medicalHistory' => !empty($item->medicalHistory)
|
|
|
|
|
? $item->medicalHistory
|
|
|
|
|
: ($rocDataMap[$rocKey]['medicalHistory'] ?? ''),
|
|
|
|
|
'docotr' => $item->docotr ?? '',
|
|
|
|
|
'reservation_department' => $item->reservation_department ?? '',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -614,6 +699,12 @@ public function GenerateGroupedCheckPdf()
|
|
|
|
|
->values()
|
|
|
|
|
->toArray();
|
|
|
|
|
$room['warm_tips'] = $tips;
|
|
|
|
|
|
|
|
|
|
//申请医生、申请科室、临床诊断、病史资料:去重,中文逗号分割
|
|
|
|
|
$room['doctor'] = implode(',', array_values(array_unique(array_filter(array_column($room['items'], 'docotr')))));
|
|
|
|
|
$room['apply_department'] = implode(',', array_values(array_unique(array_filter(array_column($room['items'], 'reservation_department')))));
|
|
|
|
|
$room['diagnosis_name'] = implode(',', array_values(array_unique(array_filter(array_column($room['items'], 'diagnosisName')))));
|
|
|
|
|
$room['medical_history'] = implode(',', array_values(array_unique(array_filter(array_column($room['items'], 'medicalHistory')))));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|