This commit is contained in:
Your Name
2026-05-18 11:20:24 +08:00
parent 1d66f84bd3
commit 08290b329e
8 changed files with 157 additions and 43 deletions
@@ -2486,6 +2486,25 @@ class PrescriptionOrderLogic
return $m[$fs] ?? ('状态' . (string) $fs);
}
/**
* 业务订单列表/导出:「诊单医助」admin id。
* 与 {@see PrescriptionLists} 一致优先 {@see Prescription::$assistant_id}(开方时从诊单快照到处方表);
* 为 0 时再取诊单当前 {@see Diagnosis::$assistant_id}(兼容历史处方或未写入快照列的数据)。
*/
public static function resolveAssistantAdminIdForPrescriptionOrderRow(
int $prescriptionAssistantId,
int $diagnosisAssistantId
): int {
if ($prescriptionAssistantId > 0) {
return $prescriptionAssistantId;
}
if ($diagnosisAssistantId > 0) {
return $diagnosisAssistantId;
}
return 0;
}
/**
* 导出用:诊单医助在 admin_dept 中的部门路径(多部门「;」、路径内「 / 」)
*/
@@ -2656,7 +2675,7 @@ class PrescriptionOrderLogic
$rxById = [];
if ($rxIdList !== []) {
$rxRows = Prescription::whereIn('id', $rxIdList)->whereNull('delete_time')
->field(['id', 'prescription_type', 'need_decoction', 'dose_unit'])
->field(['id', 'prescription_type', 'need_decoction', 'dose_unit', 'assistant_id'])
->select()
->toArray();
foreach ($rxRows as $xr) {
@@ -2697,13 +2716,17 @@ class PrescriptionOrderLogic
$diagId = (int) ($item['diagnosis_id'] ?? 0);
$dg = $diagById[$diagId] ?? null;
$rxId = (int) ($item['prescription_id'] ?? 0);
$rx = $rxById[$rxId] ?? [];
$item['export_patient_name'] = \is_array($dg) ? (string) ($dg['patient_name'] ?? '') : '';
if (\is_array($dg)) {
$g = (int) ($dg['gender'] ?? 0);
$item['export_patient_gender'] = $g === 1 ? '男' : '女';
$item['export_patient_age'] = (string) ($dg['age'] ?? '');
$item['export_patient_phone'] = (string) ($dg['phone'] ?? '');
$astId = (int) ($dg['assistant_id'] ?? 0);
$rxAst = \is_array($rx) ? (int) ($rx['assistant_id'] ?? 0) : 0;
$diagAst = (int) ($dg['assistant_id'] ?? 0);
$astId = self::resolveAssistantAdminIdForPrescriptionOrderRow($rxAst, $diagAst);
if ($astId > 0) {
if (!isset($assistantDeptCache[$astId])) {
$assistantDeptCache[$astId] = self::formatAssistantDeptPathForExport($astId);
@@ -2719,8 +2742,6 @@ class PrescriptionOrderLogic
$item['export_assistant_dept'] = '';
}
$rxId = (int) ($item['prescription_id'] ?? 0);
$rx = $rxById[$rxId] ?? [];
$item['export_medication_form'] = self::formatMedicationFormForExport(\is_array($rx) ? $rx : []);
$item['export_channel'] = (string) ($item['service_channel'] ?? '');