PDF调整

dev
鹿和sa0ChunLuyu 19 hours ago
parent 400a6e6074
commit a539477a46

@ -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')))));
}
}
}

@ -68,6 +68,10 @@
<td style="border: none; width: 24%; text-align: left;"></td>
@endif
</tr>
<tr style="border: none;">
<td style="border: none; width: 25%; text-align: left;"><span style="display: inline-block; white-space: pre;">申请医生</span>{{ $room['doctor'] }}</td>
<td style="border: none; width: 75%; text-align: left;" colspan="3"><span style="display: inline-block;">申请科室</span>{{ $room['apply_department'] }}</td>
</tr>
</table>
</div>
@ -83,12 +87,17 @@
@if ($room['period_begin'] && $room['period_end'])
{{ $room['period_begin'] }}-{{ $room['period_end'] }}
@endif
{{ $room['weekday_label'] }}</td>
{{ $room['weekday_label'] }}
<span style="margin-left: 20px;"><span style="font-weight: 900;">临床诊断:</span>{{ $room['diagnosis_name'] }}</span></td>
</tr>
<tr style="border: none; vertical-align: top;">
<td style="width: 15%; border: none; font-size: 22px; font-weight: 900; text-align: left; white-space: nowrap;">检查地点:</td>
<td style="border: none; font-size: 22px; text-align: left;">{{ $room['room_addr'] }}</td>
</tr>
<tr style="border: none; vertical-align: top;">
<td style="width: 15%; border: none; font-size: 22px; font-weight: 900; text-align: left; white-space: nowrap;">病史资料:</td>
<td style="border: none; font-size: 20px; text-align: left; line-height: 1.5;">{{ $room['medical_history'] }}</td>
</tr>
</table>
</div>

Loading…
Cancel
Save