Merge branch 'chufan-2026-5-16'
This commit is contained in:
@@ -48,6 +48,26 @@ class PrescriptionController extends BaseAdminController
|
||||
return $this->success('编辑成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 修正处方患者姓名手机号
|
||||
*/
|
||||
public function patchPatient()
|
||||
{
|
||||
$params = (new PrescriptionValidate())->post()->goCheck('patchPatient');
|
||||
$ok = PrescriptionLogic::patchPatientContact(
|
||||
(int) $params['id'],
|
||||
(string) $params['patient_name'],
|
||||
(string) $params['phone'],
|
||||
(int) $this->adminId,
|
||||
$this->adminInfo
|
||||
);
|
||||
if (!$ok) {
|
||||
return $this->fail(PrescriptionLogic::getError());
|
||||
}
|
||||
|
||||
return $this->success('已更新');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除处方
|
||||
*/
|
||||
|
||||
@@ -436,6 +436,88 @@ class PrescriptionLogic
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅修正处方笺展示用患者姓名与手机号(zyt_tcm_prescription),不改变审核状态与其它字段
|
||||
*/
|
||||
public static function patchPatientContact(int $rxId, string $patientName, string $phone, int $adminId, array $adminInfo): bool
|
||||
{
|
||||
self::$error = '';
|
||||
$prescription = Prescription::find($rxId);
|
||||
if (!$prescription) {
|
||||
self::setError('处方不存在');
|
||||
|
||||
return false;
|
||||
}
|
||||
if (!self::canViewPrescription($prescription, $adminId, $adminInfo)) {
|
||||
self::setError('无权限修改此处方');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$patientName = trim($patientName);
|
||||
$phone = trim($phone);
|
||||
if ($patientName === '') {
|
||||
self::setError('患者姓名不能为空');
|
||||
|
||||
return false;
|
||||
}
|
||||
if (mb_strlen($patientName) > 50) {
|
||||
self::setError('患者姓名过长');
|
||||
|
||||
return false;
|
||||
}
|
||||
if ($phone === '') {
|
||||
self::setError('手机号不能为空');
|
||||
|
||||
return false;
|
||||
}
|
||||
if (strlen($phone) > 20) {
|
||||
self::setError('手机号过长');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$oldName = trim((string) ($prescription->patient_name ?? ''));
|
||||
$oldPhone = trim((string) ($prescription->phone ?? ''));
|
||||
|
||||
if ($oldName === $patientName && $oldPhone === $phone) {
|
||||
self::setError('信息未变更');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$prescription->save([
|
||||
'patient_name' => $patientName,
|
||||
'phone' => $phone,
|
||||
]);
|
||||
|
||||
$latestPo = PrescriptionOrder::where('prescription_id', $rxId)
|
||||
->whereNull('delete_time')
|
||||
->order('id', 'desc')
|
||||
->find();
|
||||
$logOrderId = $latestPo ? (int) $latestPo->id : 0;
|
||||
|
||||
$nameFrom = $oldName === '' ? '—' : $oldName;
|
||||
$phoneFrom = $oldPhone === '' ? '—' : $oldPhone;
|
||||
$summary = sprintf(
|
||||
'处方 #%d:患者姓名「%s」→「%s」,手机「%s」→「%s」',
|
||||
$rxId,
|
||||
$nameFrom,
|
||||
$patientName,
|
||||
$phoneFrom,
|
||||
$phone
|
||||
);
|
||||
PrescriptionOrderLogic::appendRxPatientPatchLog($logOrderId, $adminId, $adminInfo, $summary);
|
||||
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
self::setError($e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除处方
|
||||
*/
|
||||
|
||||
@@ -1097,7 +1097,7 @@ class PrescriptionOrderLogic
|
||||
$phoneFrom,
|
||||
$phone
|
||||
);
|
||||
self::writeLog($prescriptionOrderId, $adminId, $adminInfo, 'patch_rx_patient', $summary);
|
||||
self::appendRxPatientPatchLog($prescriptionOrderId, $adminId, $adminInfo, $summary);
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
@@ -3248,4 +3248,14 @@ class PrescriptionOrderLogic
|
||||
// 忽略日志写入错误
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处方患者姓名/手机号修正日志(写入 zyt_tcm_prescription_order_log,与 patchPrescriptionPatient 同源)
|
||||
*
|
||||
* @param int $prescriptionOrderId 无关联订单时可传 0(若库表禁止则可能静默失败)
|
||||
*/
|
||||
public static function appendRxPatientPatchLog(int $prescriptionOrderId, int $adminId, array $adminInfo, string $summary): void
|
||||
{
|
||||
self::writeLog($prescriptionOrderId, $adminId, $adminInfo, 'patch_rx_patient', $summary);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ class PrescriptionValidate extends BaseValidate
|
||||
'appointment_id' => 'number',
|
||||
'dosage_bag_count' => 'integer|between:1,5',
|
||||
'patient_name' => 'require',
|
||||
'phone' => 'require|max:20',
|
||||
'clinical_diagnosis' => 'require',
|
||||
'herbs' => 'require|array',
|
||||
'action' => 'require|in:approve,reject',
|
||||
@@ -24,6 +25,8 @@ class PrescriptionValidate extends BaseValidate
|
||||
'dosage_bag_count.integer' => '用量袋数必须为整数',
|
||||
'dosage_bag_count.between' => '用量袋数必须在1到5袋之间',
|
||||
'patient_name.require' => '患者姓名不能为空',
|
||||
'phone.require' => '手机号不能为空',
|
||||
'phone.max' => '手机号过长',
|
||||
'clinical_diagnosis.require' => '临床诊断不能为空',
|
||||
'herbs.require' => '请添加中药',
|
||||
];
|
||||
@@ -63,6 +66,11 @@ class PrescriptionValidate extends BaseValidate
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function scenePatchPatient()
|
||||
{
|
||||
return $this->only(['id', 'patient_name', 'phone']);
|
||||
}
|
||||
|
||||
public function sceneAudit()
|
||||
{
|
||||
return $this->only(['id', 'action', 'remark']);
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
-- 消费者处方列表:修正处方笺姓名 / 手机号(接口 tcm.prescription/patchPatient)
|
||||
-- 执行前确认表前缀为 zyt_;若已有相同 perms 则跳过。
|
||||
|
||||
SET @cf_rx_menu_id := (
|
||||
SELECT id FROM zyt_system_menu
|
||||
WHERE type = 'C'
|
||||
AND (
|
||||
component = 'consumer/prescription/index'
|
||||
OR component LIKE '%consumer/prescription/index%'
|
||||
)
|
||||
LIMIT 1
|
||||
);
|
||||
|
||||
INSERT INTO zyt_system_menu (
|
||||
pid, type, name, icon, sort, perms, paths, component,
|
||||
selected, params, is_cache, is_show, is_disable, create_time, update_time
|
||||
)
|
||||
SELECT
|
||||
@cf_rx_menu_id, 'A', '修正处方患者姓名手机', '', 53,
|
||||
'tcm.prescription/patchPatient', '', '',
|
||||
'', '', 0, 1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()
|
||||
FROM DUAL
|
||||
WHERE @cf_rx_menu_id IS NOT NULL
|
||||
AND NOT EXISTS (SELECT 1 FROM zyt_system_menu WHERE perms = 'tcm.prescription/patchPatient');
|
||||
Reference in New Issue
Block a user