更新
This commit is contained in:
@@ -7,6 +7,7 @@ namespace app\adminapi\logic\tcm;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\service\prescriptionai\PrescriptionAiAccess as Access;
|
||||
use app\common\service\prescriptionai\PrescriptionAiCipher as Cipher;
|
||||
use app\common\service\prescriptionai\PrescriptionAiDoctorSnapshot as DoctorSnapshot;
|
||||
use app\common\service\prescriptionai\PrescriptionAiPolicy as Policy;
|
||||
use app\common\service\prescriptionai\PrescriptionAiProgress as Progress;
|
||||
use app\common\service\prescriptionai\PrescriptionAiStatistics;
|
||||
@@ -106,7 +107,13 @@ final class PrescriptionAiLogic
|
||||
self::requirePermission('detail', $actor, $info);
|
||||
$batch = self::loadBatch($batchId, $actor, $info);
|
||||
$models = self::models([$batchId], true);
|
||||
return self::formatBatch($batch, $models[$batchId] ?? [], Access::prescription((int) $batch['prescription_id'], $actor, $info));
|
||||
$detail = self::formatBatch($batch, $models[$batchId] ?? [], Access::prescription((int) $batch['prescription_id'], $actor, $info));
|
||||
// loadBatch has checked both current prescription and historical source permissions.
|
||||
// This cipher is saved at enqueue time, so it is available before models start and
|
||||
// remains the correct original when the user selects an older report revision.
|
||||
$detail['doctor_snapshot'] = empty($batch['prescription_cipher']) ? null
|
||||
: DoctorSnapshot::project((new Cipher())->decrypt($batch['prescription_cipher'], 'prescription'));
|
||||
return $detail;
|
||||
}
|
||||
|
||||
public static function regenerate(int $rxId, string $reason, int $actor, array $info): array
|
||||
@@ -244,9 +251,10 @@ final class PrescriptionAiLogic
|
||||
$models = [];
|
||||
foreach (Policy::MODELS as $model) {
|
||||
$m = $summary['models'][$model] ?? [];
|
||||
// 分布直方图与均值同源,前端据此画分箱;缺失时给空数组,不补零。
|
||||
$models[$model] = ['eligible_count' => $m['valid_count'] ?? 0, 'coverage_rate' => $m['coverage_percent'] ?? 0,
|
||||
'mean' => $m['mean'] ?? null, 'median' => $m['median'] ?? null, 'excluded_reasons' => $m['exclusion_reasons'] ?? [],
|
||||
'strata' => $m['strata'] ?? []];
|
||||
'distribution' => $m['distribution'] ?? [], 'strata' => $m['strata'] ?? []];
|
||||
}
|
||||
$doctors[] = ['doctor_id' => $doctorId, 'doctor_name' => (string) ($names[$doctorId] ?? ''),
|
||||
'total_count' => $summary['total_events'] ?? 0, 'patient_count' => $summary['patient_count'] ?? 0,
|
||||
|
||||
@@ -45,6 +45,8 @@ class PrescriptionOrderLogic
|
||||
{
|
||||
private static string $error = '';
|
||||
|
||||
private const TRACKING_AUDIT_REQUIRED = '处方审核和支付单审核均通过后,才可填写或修改快递单号';
|
||||
|
||||
public static function setError(string $msg): void
|
||||
{
|
||||
self::$error = $msg;
|
||||
@@ -55,6 +57,17 @@ class PrescriptionOrderLogic
|
||||
return self::$error;
|
||||
}
|
||||
|
||||
private static function assertTrackingAuditApproved(PrescriptionOrder $order): bool
|
||||
{
|
||||
if ((int) $order->prescription_audit_status !== 1 || (int) $order->payment_slip_audit_status !== 1) {
|
||||
self::$error = self::TRACKING_AUDIT_REQUIRED;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static function assertRemoteSnapshotMutable(PrescriptionOrder $order): bool
|
||||
{
|
||||
try {
|
||||
@@ -990,6 +1003,12 @@ class PrescriptionOrderLogic
|
||||
private static function createLocked(array $params, int $adminId, array $adminInfo)
|
||||
{
|
||||
self::$error = '';
|
||||
// 新建业务订单的两项审核均为待审核,不能在创建时预填单号。
|
||||
if (trim((string) ($params['tracking_number'] ?? '')) !== '') {
|
||||
self::$error = self::TRACKING_AUDIT_REQUIRED;
|
||||
|
||||
return false;
|
||||
}
|
||||
$rxId = (int) $params['prescription_id'];
|
||||
$diagId = (int) $params['diagnosis_id'];
|
||||
$payOrderIds = self::normalizePayOrderIds($params['pay_order_ids'] ?? []);
|
||||
@@ -1086,7 +1105,7 @@ class PrescriptionOrderLogic
|
||||
$order->prev_staff = (string) ($params['prev_staff'] ?? '');
|
||||
$order->service_channel = (string) ($params['service_channel'] ?? '');
|
||||
$order->service_package = (string) ($params['service_package'] ?? '');
|
||||
$order->tracking_number = (string) ($params['tracking_number'] ?? '');
|
||||
$order->tracking_number = '';
|
||||
$order->express_company = self::normalizeExpressCompany($params['express_company'] ?? 'auto');
|
||||
$order->ship_mode = self::canSelectShipMode($adminInfo)
|
||||
? self::normalizeShipMode((string) ($params['ship_mode'] ?? 'gancao'))
|
||||
@@ -1867,6 +1886,15 @@ class PrescriptionOrderLogic
|
||||
return false;
|
||||
}
|
||||
|
||||
// 未提交单号时保留原值;仅实际填写、修改或清空单号需要双审核通过。
|
||||
$trackingNumber = array_key_exists('tracking_number', $params)
|
||||
? (string) $params['tracking_number']
|
||||
: (string) ($order->tracking_number ?? '');
|
||||
$trackingChanged = $trackingNumber !== (string) ($order->tracking_number ?? '');
|
||||
if ($trackingChanged && !self::assertTrackingAuditApproved($order)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$medDays = $params['medication_days'] ?? null;
|
||||
$medDays = $medDays === '' || $medDays === null ? null : (int) $medDays;
|
||||
|
||||
@@ -1892,7 +1920,7 @@ class PrescriptionOrderLogic
|
||||
$order->prev_staff = (string) ($params['prev_staff'] ?? '');
|
||||
$order->service_channel = (string) ($params['service_channel'] ?? '');
|
||||
$order->service_package = (string) ($params['service_package'] ?? '');
|
||||
$order->tracking_number = (string) ($params['tracking_number'] ?? '');
|
||||
$order->tracking_number = $trackingNumber;
|
||||
if (array_key_exists('express_company', $params)) {
|
||||
$order->express_company = self::normalizeExpressCompany($params['express_company']);
|
||||
}
|
||||
@@ -1978,6 +2006,10 @@ class PrescriptionOrderLogic
|
||||
$order->payment_slip_audit_status = 0;
|
||||
$order->payment_slip_audit_remark = '';
|
||||
}
|
||||
// 同次编辑若让支付单重新进入待审核,也不能同时写入新的单号。
|
||||
if ($trackingChanged && !self::assertTrackingAuditApproved($order)) {
|
||||
return false;
|
||||
}
|
||||
self::syncFulfillmentStatus($order);
|
||||
|
||||
try {
|
||||
@@ -2001,7 +2033,7 @@ class PrescriptionOrderLogic
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅修改承运商与快递单号。物流信息不属于药房下单快照,因此允许在所有履约状态下修正。
|
||||
* 双审核通过后,仅修改承运商与快递单号。物流信息不属于药房下单快照,不另设履约状态限制。
|
||||
*
|
||||
* @return array<string,mixed>|false
|
||||
*/
|
||||
@@ -2061,6 +2093,10 @@ class PrescriptionOrderLogic
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!self::assertTrackingAuditApproved($order)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$oldTrackingNumber = trim((string) ($order->tracking_number ?? ''));
|
||||
$oldExpressCompany = self::normalizeExpressCompany((string) ($order->express_company ?? 'auto'));
|
||||
$newExpressCompany = self::normalizeExpressCompany($expressCompany);
|
||||
@@ -2148,6 +2184,9 @@ class PrescriptionOrderLogic
|
||||
|
||||
return false;
|
||||
}
|
||||
if (!self::assertTrackingAuditApproved($order)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$shipMode = self::normalizeShipMode((string) ($order->ship_mode ?? 'gancao'));
|
||||
$shipModeText = $shipMode === 'direct' ? '药房直发' : '甘草药方发';
|
||||
|
||||
Reference in New Issue
Block a user