更新
This commit is contained in:
@@ -623,7 +623,42 @@ class TcmController extends BaseApiController
|
||||
];
|
||||
|
||||
if ($existing) {
|
||||
$payload['id'] = $existing['id'];
|
||||
// 分表单项更新时保留未提交字段,避免血糖/血压互相覆盖
|
||||
$keepDecimal = function ($new, string $oldKey) use ($parseDecimal, $existing) {
|
||||
if ($new !== null) {
|
||||
return $new;
|
||||
}
|
||||
return $parseDecimal($existing[$oldKey] ?? null);
|
||||
};
|
||||
$keepInt = function ($new, string $oldKey) use ($parseInt, $existing) {
|
||||
if ($new !== null) {
|
||||
return $new;
|
||||
}
|
||||
return $parseInt($existing[$oldKey] ?? null);
|
||||
};
|
||||
$fasting = $keepDecimal($fasting, 'fasting_blood_sugar');
|
||||
$postprandial = $keepDecimal($postprandial, 'postprandial_blood_sugar');
|
||||
$other = $keepDecimal($other, 'other_blood_sugar');
|
||||
$systolic = $keepInt($systolic, 'systolic_pressure');
|
||||
$diastolic = $keepInt($diastolic, 'diastolic_pressure');
|
||||
if ($remark === '') {
|
||||
$remark = trim((string) ($existing['remark'] ?? ''));
|
||||
}
|
||||
|
||||
$payload = [
|
||||
'diagnosis_id' => $diagnosisId,
|
||||
'patient_id' => (int) $diagnosis['patient_id'],
|
||||
'record_date' => $todayStart,
|
||||
'record_time' => date('H:i'),
|
||||
'fasting_blood_sugar' => $fasting,
|
||||
'postprandial_blood_sugar' => $postprandial,
|
||||
'other_blood_sugar' => $other,
|
||||
'systolic_pressure' => $systolic,
|
||||
'diastolic_pressure' => $diastolic,
|
||||
'remark' => $remark,
|
||||
'source' => 1,
|
||||
'id' => $existing['id'],
|
||||
];
|
||||
BloodRecord::update($payload);
|
||||
return $this->success('已更新今日记录', ['id' => $existing['id']]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user