更新bug

This commit is contained in:
Your Name
2026-08-20 17:47:14 +08:00
parent 35f91ee37a
commit 5794f60c5d
67 changed files with 9257 additions and 1287 deletions
@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace app\adminapi\logic\tcm;
use app\adminapi\logic\firstvisit\MyPatientLogic;
use app\common\model\auth\Admin;
use app\common\model\doctor\Appointment;
use app\common\model\doctor\Medicine as DoctorMedicine;
@@ -938,8 +937,8 @@ class PrescriptionLogic
public static function listByDiagnosis(int $diagnosisId, int $viewerAdminId, array $viewerAdminInfo): array
{
self::$error = '';
if (!MyPatientLogic::canAccessDiagnosis($diagnosisId, $viewerAdminId, $viewerAdminInfo)) {
self::setError('诊单不存在或无权访问');
if (!DiagnosisLogic::canViewReadonlyDiagnosis($diagnosisId, $viewerAdminId, $viewerAdminInfo)) {
self::setError(DiagnosisLogic::getError() ?: '诊单不存在或无权访问');
return [];
}
@@ -968,16 +967,29 @@ class PrescriptionLogic
/**
* 根据预约ID获取处方(带权限检查)
*/
public static function getByAppointment(int $appointmentId, int $viewerAdminId, array $viewerAdminInfo): ?array
{
public static function getByAppointment(int $appointmentId, int $viewerAdminId, array $viewerAdminInfo): ?array
{
self::$error = '';
$row = Prescription::where('appointment_id', $appointmentId)
$rows = Prescription::where('appointment_id', $appointmentId)
->whereNull('delete_time')
->order('id', 'desc')
->find();
if (!$row) {
return null;
->select();
$row = null;
$fallback = null;
foreach ($rows as $candidate) {
if ($fallback === null) {
$fallback = $candidate;
}
if ((int) ($candidate->void_status ?? 0) === 0) {
$row = $candidate;
break;
}
}
$row = $row ?? $fallback;
if (!$row) {
return null;
}
// 权限检查:只返回当前用户有权限查看的处方