Merge branch 'master' of https://gitee.com/v_cms/zyt
This commit is contained in:
@@ -28,12 +28,9 @@ abstract class BaseAdminDataLists extends BaseDataLists
|
||||
protected array $adminInfo;
|
||||
protected int $adminId;
|
||||
|
||||
public function __construct()
|
||||
protected function initAdminIdentity(): void
|
||||
{
|
||||
parent::__construct();
|
||||
$this->adminInfo = $this->request->adminInfo;
|
||||
$this->adminId = $this->request->adminId;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -7,6 +7,7 @@ use app\common\model\DiagnosisViewRecord;
|
||||
use app\common\model\doctor\Appointment;
|
||||
use app\common\model\tcm\Prescription;
|
||||
use app\common\model\auth\AdminRole;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\lists\ListsExtendInterface;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\lists\Traits\HasDataScopeFilter;
|
||||
@@ -122,7 +123,7 @@ class AppointmentLists extends BaseAdminDataLists implements ListsSearchInterfac
|
||||
->leftJoin('tcm_diagnosis u', 'a.patient_id = u.id')
|
||||
->leftJoin('admin ad', 'a.doctor_id = ad.id')
|
||||
->leftJoin('admin asst', 'u.assistant_id = asst.id')
|
||||
->field('a.*, u.patient_name as patient_name, u.phone as patient_phone, u.gender as gender, u.age as age, u.weight as weight, u.height as height, u.assistant_id as assistant_id, ad.name as doctor_name, asst.name as assistant_name, u.id as diagnosis_id');
|
||||
->field('a.*, u.patient_name as patient_name, u.phone as patient_phone, u.gender as gender, u.age as age, u.weight as weight, u.height as height, u.assistant_id as assistant_id, ad.name as doctor_name, asst.name as assistant_name, u.id as diagnosis_id, a.assistant_id as appointment_assistant_id');
|
||||
if ($this->searchWhere !== []) {
|
||||
$query->where($this->searchWhere);
|
||||
}
|
||||
@@ -212,6 +213,9 @@ class AppointmentLists extends BaseAdminDataLists implements ListsSearchInterfac
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$channelNameByValue = DictData::where('type_value', 'channels')->column('name', 'value');
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
$statusMap = [
|
||||
1 => '已预约',
|
||||
@@ -228,6 +232,24 @@ class AppointmentLists extends BaseAdminDataLists implements ListsSearchInterfac
|
||||
];
|
||||
$item['appointment_type_desc'] = $typeMap[$item['appointment_type']] ?? '未知';
|
||||
|
||||
$periodRaw = (string) ($item['period'] ?? ($item['type'] ?? ''));
|
||||
$periodMap = [
|
||||
'morning' => '上午',
|
||||
'afternoon' => '下午',
|
||||
'all' => '全天',
|
||||
];
|
||||
$item['period_desc'] = $periodMap[$periodRaw] ?? ($periodRaw !== '' ? $periodRaw : '—');
|
||||
|
||||
$srcKey = trim((string) ($item['channel_source'] ?? ''));
|
||||
if ($srcKey === '' && isset($item['channels']) && $item['channels'] !== '' && $item['channels'] !== null) {
|
||||
$srcKey = trim((string) $item['channels']);
|
||||
}
|
||||
if ($srcKey !== '') {
|
||||
$item['channel_source_desc'] = (string) ($channelNameByValue[$srcKey] ?? $channelNameByValue[(string) (int) $srcKey] ?? $srcKey);
|
||||
} else {
|
||||
$item['channel_source_desc'] = '—';
|
||||
}
|
||||
|
||||
$item['diagnosis_confirmed'] = isset($confirmedMap[$item['diagnosis_id'] ?? 0]) ? 1 : 0;
|
||||
$item['has_prescription'] = isset($prescribedDiagnosisIds[$item['diagnosis_id'] ?? 0]) ? 1 : 0;
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\adminapi\logic\dept\DeptLogic;
|
||||
use app\adminapi\logic\stats\YejiStatsLogic;
|
||||
use app\adminapi\logic\tcm\PrescriptionOrderLogic;
|
||||
use app\common\enum\ExportEnum;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
use app\common\lists\ListsExtendInterface;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\lists\Traits\HasDataScopeFilter;
|
||||
@@ -23,7 +25,7 @@ use think\facade\Config;
|
||||
use think\facade\Db;
|
||||
use think\db\Query;
|
||||
|
||||
class PrescriptionOrderLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExtendInterface
|
||||
class PrescriptionOrderLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExtendInterface, ListsExcelInterface
|
||||
{
|
||||
use HasDataScopeFilter;
|
||||
|
||||
@@ -552,10 +554,16 @@ class PrescriptionOrderLists extends BaseAdminDataLists implements ListsSearchIn
|
||||
}
|
||||
unset($item);
|
||||
|
||||
$this->appendPrescriptionOrderAssignSnapshotErCenterFlags($lists);
|
||||
|
||||
if ((int) ($this->params['yeji_order_drawer'] ?? 0) === 1) {
|
||||
PrescriptionOrderLogic::appendLinkedAppointmentsToListRows($lists, $this->params);
|
||||
}
|
||||
|
||||
if ((int) $this->export === ExportEnum::EXPORT) {
|
||||
PrescriptionOrderLogic::appendPrescriptionOrderListExportRows($lists, $this->adminInfo);
|
||||
}
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
@@ -599,6 +607,39 @@ class PrescriptionOrderLists extends BaseAdminDataLists implements ListsSearchIn
|
||||
return $base;
|
||||
}
|
||||
|
||||
public function setFileName(): string
|
||||
{
|
||||
return '处方业务订单';
|
||||
}
|
||||
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
return [
|
||||
'export_fulfillment_status_text' => '履约状态',
|
||||
'export_order_time' => '创建时间',
|
||||
'doctor_name' => '医生姓名',
|
||||
'export_patient_name' => '患者姓名',
|
||||
'export_patient_gender' => '性别',
|
||||
'export_patient_age' => '年龄',
|
||||
'export_patient_phone' => '手机号',
|
||||
'assistant_name' => '医助名字',
|
||||
'export_center_label' => '一中心还是二中心',
|
||||
'export_assistant_dept' => '医助部门',
|
||||
'export_channel' => '渠道',
|
||||
'export_medication_form' => '药品形态',
|
||||
'export_medication_days' => '天数',
|
||||
'export_amount' => '总金额',
|
||||
'export_paid_amount' => '已付金额',
|
||||
'export_agency_collect' => '代收金额',
|
||||
'export_tracking_number' => '快递单号',
|
||||
'export_supply_mode' => '甘草还是自营',
|
||||
'export_gancao_prescription_cost' => '处方成本',
|
||||
'export_first_visit_assistant' => '初诊医助',
|
||||
'export_rx_audit_time' => '审核时间',
|
||||
'export_rx_auditor' => '审核人',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 业绩看板侧栏专用:约诊/接诊条数,与 YejiStatsLogic::applyConsultFiltersAlignedWithAppointmentLists 同口径
|
||||
* (doctor_appointment.status=3,appointment_date 落入区间,有效医助 COALESCE(挂号.assistant_id,诊单.assistant_id))。
|
||||
@@ -1069,4 +1110,118 @@ class PrescriptionOrderLists extends BaseAdminDataLists implements ListsSearchIn
|
||||
. ")"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表行标注:指派日志快照(related_po_creator_id + related_po_create_time)是否指向本业务单,
|
||||
* 以及该次操作的新医助(to_assistant_id)是否归属「二中心」部门子树(与 DeptLogic / 业绩看板一致)。
|
||||
*
|
||||
* @param array<int, array<string, mixed>> $lists
|
||||
*/
|
||||
private function appendPrescriptionOrderAssignSnapshotErCenterFlags(array &$lists): void
|
||||
{
|
||||
if ($lists === []) {
|
||||
return;
|
||||
}
|
||||
|
||||
$diagIds = [];
|
||||
foreach ($lists as $row) {
|
||||
$d = (int) ($row['diagnosis_id'] ?? 0);
|
||||
if ($d > 0) {
|
||||
$diagIds[$d] = true;
|
||||
}
|
||||
}
|
||||
$diagIdList = array_keys($diagIds);
|
||||
$latestSnapLogByTriple = [];
|
||||
if ($diagIdList !== []) {
|
||||
$logRows = Db::name('tcm_diagnosis_assign_log')
|
||||
->whereIn('diagnosis_id', $diagIdList)
|
||||
->field(['id', 'diagnosis_id', 'to_assistant_id', 'related_po_creator_id', 'related_po_create_time'])
|
||||
->order('id', 'desc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
foreach ($logRows as $log) {
|
||||
$d = (int) ($log['diagnosis_id'] ?? 0);
|
||||
$rcp = (int) ($log['related_po_creator_id'] ?? 0);
|
||||
$rpct = (int) ($log['related_po_create_time'] ?? 0);
|
||||
if ($d <= 0 || $rcp <= 0 || $rpct <= 0) {
|
||||
continue;
|
||||
}
|
||||
$tripleKey = $d . ':' . $rcp . ':' . $rpct;
|
||||
if (!isset($latestSnapLogByTriple[$tripleKey])) {
|
||||
$latestSnapLogByTriple[$tripleKey] = $log;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$toAssistantIdsHit = [];
|
||||
foreach ($lists as $item) {
|
||||
$diagId = (int) ($item['diagnosis_id'] ?? 0);
|
||||
$creatorId = (int) ($item['creator_id'] ?? 0);
|
||||
$poCt = (int) ($item['create_time'] ?? 0);
|
||||
$tripleKey = $diagId . ':' . $creatorId . ':' . $poCt;
|
||||
$log = $latestSnapLogByTriple[$tripleKey] ?? null;
|
||||
if (\is_array($log)) {
|
||||
$tid = (int) ($log['to_assistant_id'] ?? 0);
|
||||
if ($tid > 0) {
|
||||
$toAssistantIdsHit[$tid] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
$toAssistantIdList = array_keys($toAssistantIdsHit);
|
||||
|
||||
$erDeptSet = DeptLogic::getErCenterSubtreeDeptIdSet();
|
||||
$adminErCenter = [];
|
||||
if ($toAssistantIdList !== [] && $erDeptSet !== []) {
|
||||
$adRows = AdminDept::whereIn('admin_id', $toAssistantIdList)
|
||||
->field(['admin_id', 'dept_id'])
|
||||
->select()
|
||||
->toArray();
|
||||
foreach ($adRows as $ad) {
|
||||
$aid = (int) ($ad['admin_id'] ?? 0);
|
||||
$did = (int) ($ad['dept_id'] ?? 0);
|
||||
if ($aid > 0 && $did > 0 && isset($erDeptSet[$did])) {
|
||||
$adminErCenter[$aid] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$nameMap = [];
|
||||
if ($toAssistantIdList !== []) {
|
||||
$nameMap = \app\common\model\auth\Admin::whereIn('id', $toAssistantIdList)->column('name', 'id');
|
||||
}
|
||||
|
||||
foreach ($lists as &$item) {
|
||||
$diagId = (int) ($item['diagnosis_id'] ?? 0);
|
||||
$creatorId = (int) ($item['creator_id'] ?? 0);
|
||||
$poCt = (int) ($item['create_time'] ?? 0);
|
||||
|
||||
$item['po_assign_snapshot_hit'] = 0;
|
||||
$item['po_assign_to_assistant_id'] = 0;
|
||||
$item['po_assign_to_assistant_name'] = '';
|
||||
$item['po_assign_to_er_center'] = 0;
|
||||
$item['po_assign_is_release'] = 0;
|
||||
|
||||
if ($diagId <= 0 || $creatorId <= 0 || $poCt <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$tripleKey = $diagId . ':' . $creatorId . ':' . $poCt;
|
||||
$log = $latestSnapLogByTriple[$tripleKey] ?? null;
|
||||
if (!\is_array($log)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$item['po_assign_snapshot_hit'] = 1;
|
||||
$toId = (int) ($log['to_assistant_id'] ?? 0);
|
||||
$item['po_assign_to_assistant_id'] = $toId;
|
||||
if ($toId <= 0) {
|
||||
$item['po_assign_is_release'] = 1;
|
||||
continue;
|
||||
}
|
||||
$item['po_assign_to_assistant_name'] = (string) ($nameMap[$toId] ?? '');
|
||||
$item['po_assign_to_er_center'] = isset($adminErCenter[$toId]) ? 1 : 0;
|
||||
}
|
||||
unset($item);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user