Merge branch 'long-consultation-desk'
This commit is contained in:
@@ -19,6 +19,8 @@ use app\common\model\tcm\Diagnosis;
|
||||
use app\common\model\tcm\DiagnosisAssignLog;
|
||||
use app\common\model\tcm\ImChatMessage;
|
||||
use app\common\model\DiagnosisViewRecord;
|
||||
use app\adminapi\logic\doctor\DoctorNoteLogic;
|
||||
use app\common\service\FileService;
|
||||
use think\facade\Db;
|
||||
/**
|
||||
* 中医辨房病因诊单逻辑
|
||||
@@ -192,14 +194,37 @@ class DiagnosisLogic extends BaseLogic
|
||||
$params['diagnosis_date'] = strtotime($params['diagnosis_date']);
|
||||
}
|
||||
|
||||
// 保存前记录旧的检查报告,用于对比新增
|
||||
$oldReportFiles = [];
|
||||
if (isset($params['report_files'])) {
|
||||
$old = Diagnosis::where('id', $params['id'])->value('report_files');
|
||||
if ($old) {
|
||||
$oldReportFiles = is_string($old) ? (json_decode($old, true) ?: []) : (array) $old;
|
||||
}
|
||||
}
|
||||
|
||||
Diagnosis::update($params);
|
||||
|
||||
|
||||
// 检查报告有新增时同步到医生备注
|
||||
if (isset($params['report_files'])) {
|
||||
$newReportFiles = is_string($params['report_files'])
|
||||
? (json_decode($params['report_files'], true) ?: [])
|
||||
: (array) $params['report_files'];
|
||||
$added = array_values(array_diff($newReportFiles, $oldReportFiles));
|
||||
if (!empty($added)) {
|
||||
DoctorNoteLogic::addOrAppend([
|
||||
'diagnosis_id' => (int) $params['id'],
|
||||
'report_files' => $added,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果是编辑,也确保患者有 TRTC 账号
|
||||
$diagnosis = Diagnosis::find($params['id']);
|
||||
if ($diagnosis) {
|
||||
self::createPatientTrtcAccount($diagnosis->patient_id);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
@@ -256,57 +281,30 @@ class DiagnosisLogic extends BaseLogic
|
||||
|
||||
|
||||
if (!empty($diagnosis['tongue_images'])) {
|
||||
// 先尝试 JSON 解析(兼容旧数据)
|
||||
$files = json_decode($diagnosis['tongue_images'], true);
|
||||
if (is_array($files)) {
|
||||
$diagnosis['tongue_images'] = $files;
|
||||
} else {
|
||||
// JSON 解析失败则按逗号分割
|
||||
$diagnosis['tongue_images'] = array_filter(explode(',', $diagnosis['tongue_images'])) ?: [];
|
||||
}
|
||||
|
||||
// 为没有 http 前缀的图片添加域名
|
||||
$domain = request()->domain();
|
||||
$diagnosis['tongue_images'] = array_map(function($url) use ($domain) {
|
||||
if (empty($url)) {
|
||||
return $url;
|
||||
$files = json_decode($diagnosis['tongue_images'], true);
|
||||
if (is_array($files)) {
|
||||
$diagnosis['tongue_images'] = $files;
|
||||
} else {
|
||||
$diagnosis['tongue_images'] = array_filter(explode(',', $diagnosis['tongue_images'])) ?: [];
|
||||
}
|
||||
$diagnosis['tongue_images'] = array_map(function($url) {
|
||||
return empty($url) ? $url : FileService::getFileUrl($url);
|
||||
}, $diagnosis['tongue_images']);
|
||||
} else {
|
||||
$diagnosis['tongue_images'] = [];
|
||||
}
|
||||
// 如果已经包含 http:// 或 https://,则跳过
|
||||
if (stripos($url, 'http://') === 0 || stripos($url, 'https://') === 0) {
|
||||
return $url;
|
||||
}
|
||||
// 添加域名前缀
|
||||
return $domain .'/'. $url;
|
||||
}, $diagnosis['tongue_images']);
|
||||
} else {
|
||||
$diagnosis['tongue_images'] = [];
|
||||
}
|
||||
|
||||
// 处理检查报告(JSON转数组)
|
||||
if (!empty($diagnosis['report_files'])) {
|
||||
// 先尝试 JSON 解析(兼容旧数据)
|
||||
$files = json_decode($diagnosis['report_files'], true);
|
||||
if (is_array($files)) {
|
||||
$diagnosis['report_files'] = $files;
|
||||
} else {
|
||||
// JSON 解析失败则按逗号分割
|
||||
$diagnosis['report_files'] = array_filter(explode(',', $diagnosis['report_files'])) ?: [];
|
||||
}
|
||||
|
||||
// 为没有 http 前缀的文件添加域名
|
||||
$domain = request()->domain();
|
||||
$diagnosis['report_files'] = array_map(function($url) use ($domain) {
|
||||
if (empty($url)) {
|
||||
return $url;
|
||||
}
|
||||
// 如果已经包含 http:// 或 https://,则跳过
|
||||
if (stripos($url, 'http://') === 0 || stripos($url, 'https://') === 0) {
|
||||
return $url;
|
||||
}
|
||||
// 添加域名前缀
|
||||
return $domain . $url;
|
||||
}, $diagnosis['report_files']);
|
||||
} else {
|
||||
if (!empty($diagnosis['report_files'])) {
|
||||
$files = json_decode($diagnosis['report_files'], true);
|
||||
if (is_array($files)) {
|
||||
$diagnosis['report_files'] = $files;
|
||||
} else {
|
||||
$diagnosis['report_files'] = array_filter(explode(',', $diagnosis['report_files'])) ?: [];
|
||||
}
|
||||
$diagnosis['report_files'] = array_map(function($url) {
|
||||
return empty($url) ? $url : FileService::getFileUrl($url);
|
||||
}, $diagnosis['report_files']);
|
||||
} else {
|
||||
$diagnosis['report_files'] = [];
|
||||
}
|
||||
// 处理诊断日期格式
|
||||
|
||||
Reference in New Issue
Block a user