更新
This commit is contained in:
@@ -437,9 +437,9 @@ class PrescriptionLogic
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅修正处方笺展示用患者姓名与手机号(zyt_tcm_prescription),不改变审核状态与其它字段
|
||||
* 仅修正处方笺展示用患者姓名、手机号与性别(zyt_tcm_prescription),不改变审核状态与其它字段
|
||||
*/
|
||||
public static function patchPatientContact(int $rxId, string $patientName, string $phone, int $adminId, array $adminInfo): bool
|
||||
public static function patchPatientContact(int $rxId, string $patientName, string $phone, int $gender, int $adminId, array $adminInfo): bool
|
||||
{
|
||||
self::$error = '';
|
||||
$prescription = Prescription::find($rxId);
|
||||
@@ -476,20 +476,38 @@ class PrescriptionLogic
|
||||
|
||||
return false;
|
||||
}
|
||||
if (!in_array($gender, [0, 1], true)) {
|
||||
self::setError('性别无效');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$oldName = trim((string) ($prescription->patient_name ?? ''));
|
||||
$oldPhone = trim((string) ($prescription->phone ?? ''));
|
||||
$oldGender = (int) ($prescription->gender ?? 0);
|
||||
|
||||
if ($oldName === $patientName && $oldPhone === $phone) {
|
||||
if ($oldName === $patientName && $oldPhone === $phone && $oldGender === $gender) {
|
||||
self::setError('信息未变更');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$genderText = static function (int $g): string {
|
||||
if ($g === 1) {
|
||||
return '男';
|
||||
}
|
||||
if ($g === 0) {
|
||||
return '女';
|
||||
}
|
||||
|
||||
return '未知';
|
||||
};
|
||||
|
||||
try {
|
||||
$prescription->save([
|
||||
'patient_name' => $patientName,
|
||||
'phone' => $phone,
|
||||
'gender' => $gender,
|
||||
]);
|
||||
|
||||
$latestPo = PrescriptionOrder::where('prescription_id', $rxId)
|
||||
@@ -500,13 +518,17 @@ class PrescriptionLogic
|
||||
|
||||
$nameFrom = $oldName === '' ? '—' : $oldName;
|
||||
$phoneFrom = $oldPhone === '' ? '—' : $oldPhone;
|
||||
$genderFrom = $genderText($oldGender);
|
||||
$genderTo = $genderText($gender);
|
||||
$summary = sprintf(
|
||||
'处方 #%d:患者姓名「%s」→「%s」,手机「%s」→「%s」',
|
||||
'处方 #%d:患者姓名「%s」→「%s」,手机「%s」→「%s」,性别「%s」→「%s」',
|
||||
$rxId,
|
||||
$nameFrom,
|
||||
$patientName,
|
||||
$phoneFrom,
|
||||
$phone
|
||||
$phone,
|
||||
$genderFrom,
|
||||
$genderTo
|
||||
);
|
||||
PrescriptionOrderLogic::appendRxPatientPatchLog($logOrderId, $adminId, $adminInfo, $summary);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user