更新
This commit is contained in:
@@ -298,7 +298,7 @@ class DiagnosisLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
if ($diagnosisIds !== []) {
|
||||
$rxAll = Prescription::whereIn('diagnosis_id', $diagnosisIds)
|
||||
->whereNull('delete_time')
|
||||
->field(['id', 'diagnosis_id', 'doctor_name', 'creator_id', 'prescription_date', 'create_time', 'void_status'])
|
||||
->field(['id', 'diagnosis_id', 'doctor_name', 'creator_id', 'prescription_date', 'create_time', 'void_status', 'audit_status'])
|
||||
->order('id', 'desc')
|
||||
->select()
|
||||
->toArray();
|
||||
@@ -339,6 +339,8 @@ class DiagnosisLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
'time_text' => $this->formatPrescriptionFollowupTime($rx),
|
||||
'doctor_name' => $doctorName !== '' ? $doctorName : '—',
|
||||
'voided' => (int) ($rx['void_status'] ?? 0) !== 0,
|
||||
'void_status' => (int) ($rx['void_status'] ?? 0),
|
||||
'audit_status' => (int) ($rx['audit_status'] ?? -1),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -348,6 +350,8 @@ class DiagnosisLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
$item['followup_time_text'] = ($item['has_prescription'] && $fu) ? ($fu['time_text'] ?? '') : '';
|
||||
$item['followup_doctor_name'] = ($item['has_prescription'] && $fu) ? ($fu['doctor_name'] ?? '—') : '';
|
||||
$item['followup_rx_voided'] = ($item['has_prescription'] && $fu && !empty($fu['voided'])) ? 1 : 0;
|
||||
$item['prescription_audit_status'] = ($item['has_prescription'] && $fu) ? (int) ($fu['audit_status'] ?? -1) : -1;
|
||||
$item['prescription_void_status'] = ($item['has_prescription'] && $fu) ? (int) ($fu['void_status'] ?? 0) : 0;
|
||||
// 开方次数即复诊次数:1 张处方 = 第 1 次复诊,以此类推
|
||||
$item['followup_prescription_count'] = (int) ($rxCountByDiag[$did] ?? 0);
|
||||
}
|
||||
|
||||
@@ -809,8 +809,8 @@ class PrescriptionLogic
|
||||
'dose_unit' => '剂',
|
||||
'usage_days' => 7,
|
||||
'times_per_day' => 2,
|
||||
'usage_instruction' => '水煎服,一日二次',
|
||||
'usage_time' => '饭前',
|
||||
'usage_instruction' => '',
|
||||
'usage_time' => '饭后',
|
||||
'usage_way' => '温水送服',
|
||||
'dietary_taboo' => '',
|
||||
'usage_notes' => '',
|
||||
|
||||
@@ -13,11 +13,10 @@ use app\common\model\tcm\PrescriptionOrder;
|
||||
use app\common\model\tcm\PrescriptionOrderLog;
|
||||
use app\common\model\tcm\PrescriptionOrderPayOrder;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\auth\AdminDept;
|
||||
use app\common\model\dept\Dept;
|
||||
use app\common\service\ExpressTrackService;
|
||||
use app\common\service\gancao\GancaoScmRecipelService;
|
||||
use think\facade\Config;
|
||||
use think\facade\Db;
|
||||
use think\facade\Log;
|
||||
|
||||
class PrescriptionOrderLogic
|
||||
@@ -36,6 +35,7 @@ class PrescriptionOrderLogic
|
||||
|
||||
/**
|
||||
* 部门自底向上链式名称,含父级(如:总部 / 华东 / 上海门诊)
|
||||
* 使用 Db 直查 zyt_dept:避免 Dept 软删除全局作用域导致有 dept_id 仍拼不出路径
|
||||
*/
|
||||
private static function buildDeptPath(int $deptId): string
|
||||
{
|
||||
@@ -45,13 +45,13 @@ class PrescriptionOrderLogic
|
||||
$names = [];
|
||||
$id = $deptId;
|
||||
for ($i = 0; $i < 50; $i++) {
|
||||
$row = Dept::where('id', $id)->whereNull('delete_time')->field(['id', 'name', 'pid'])->find();
|
||||
if ($row === null) {
|
||||
$row = Db::name('dept')->where('id', $id)->field(['id', 'name', 'pid'])->find();
|
||||
if (empty($row)) {
|
||||
break;
|
||||
}
|
||||
$data = $row->toArray();
|
||||
array_unshift($names, (string) ($data['name'] ?? ''));
|
||||
$pid = (int) ($data['pid'] ?? 0);
|
||||
$r = is_array($row) ? $row : $row->toArray();
|
||||
array_unshift($names, (string) ($r['name'] ?? ''));
|
||||
$pid = (int) ($r['pid'] ?? 0);
|
||||
if ($pid <= 0) {
|
||||
break;
|
||||
}
|
||||
@@ -66,6 +66,27 @@ class PrescriptionOrderLogic
|
||||
return implode(' / ', $names);
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员在 zyt_admin_dept 中的部门路径(多部门用「;」、含父级「 / 」)
|
||||
*/
|
||||
private static function buildAdminDeptPathJoined(int $adminId): string
|
||||
{
|
||||
if ($adminId <= 0) {
|
||||
return '';
|
||||
}
|
||||
$deptIds = Db::name('admin_dept')->where('admin_id', $adminId)->column('dept_id');
|
||||
$pathSegmentsC = [];
|
||||
foreach ($deptIds as $didC) {
|
||||
$pc = self::buildDeptPath((int) $didC);
|
||||
if ($pc !== '') {
|
||||
$pathSegmentsC[] = $pc;
|
||||
}
|
||||
}
|
||||
$pathSegmentsC = array_values(array_unique($pathSegmentsC));
|
||||
|
||||
return $pathSegmentsC === [] ? '' : implode(';', $pathSegmentsC);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int[] $allowRoleIds
|
||||
*/
|
||||
@@ -641,7 +662,7 @@ class PrescriptionOrderLogic
|
||||
unset($arr['prescription']['herbs']);
|
||||
}
|
||||
|
||||
// 诊单医助 / 诊单创建人 及部门(多部门、含父级路径用「;」与「 / 」分隔);创建人为 tcm_diagnosis.admin_id
|
||||
// 诊单医助 / 诊单创建人姓名(tcm_diagnosis.admin_id);部门见下方:优先业务订单 creator_id
|
||||
$arr['assistant_id'] = 0;
|
||||
$arr['assistant_name'] = '';
|
||||
$arr['assistant_dept_path'] = '';
|
||||
@@ -659,7 +680,7 @@ class PrescriptionOrderLogic
|
||||
if ($astId > 0) {
|
||||
$an = Admin::where('id', $astId)->whereNull('delete_time')->value('name');
|
||||
$arr['assistant_name'] = $an !== null && (string) $an !== '' ? (string) $an : '';
|
||||
$deptIds = AdminDept::where('admin_id', $astId)->column('dept_id');
|
||||
$deptIds = Db::name('admin_dept')->where('admin_id', $astId)->column('dept_id');
|
||||
$pathSegments = [];
|
||||
foreach ($deptIds as $did) {
|
||||
$p = self::buildDeptPath((int) $did);
|
||||
@@ -675,19 +696,18 @@ class PrescriptionOrderLogic
|
||||
if ($creId > 0) {
|
||||
$cn = Admin::where('id', $creId)->whereNull('delete_time')->value('name');
|
||||
$arr['diagnosis_creator_name'] = $cn !== null && (string) $cn !== '' ? (string) $cn : '';
|
||||
$deptIdsC = AdminDept::where('admin_id', $creId)->column('dept_id');
|
||||
$pathSegmentsC = [];
|
||||
foreach ($deptIdsC as $didC) {
|
||||
$pc = self::buildDeptPath((int) $didC);
|
||||
if ($pc !== '') {
|
||||
$pathSegmentsC[] = $pc;
|
||||
}
|
||||
}
|
||||
$pathSegmentsC = array_values(array_unique($pathSegmentsC));
|
||||
$arr['diagnosis_creator_dept_path'] = $pathSegmentsC === [] ? '' : implode(';', $pathSegmentsC);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 「创建人所属部门」:优先 zyt_tcm_prescription_order.creator_id;无部门时再试诊单 admin_id(非处方开方人)
|
||||
$deptPath = self::buildAdminDeptPathJoined((int) ($arr['creator_id'] ?? 0));
|
||||
if ($deptPath === '') {
|
||||
$dgAdmin = (int) ($arr['diagnosis_creator_id'] ?? 0);
|
||||
if ($dgAdmin > 0) {
|
||||
$deptPath = self::buildAdminDeptPathJoined($dgAdmin);
|
||||
}
|
||||
}
|
||||
$arr['diagnosis_creator_dept_path'] = $deptPath;
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user