更新
This commit is contained in:
@@ -338,7 +338,7 @@ class DiagnosisLogic extends BaseLogic
|
||||
try {
|
||||
// 获取配置
|
||||
$config = self::getTrtcConfig();
|
||||
|
||||
|
||||
if (!$config) {
|
||||
self::setError('请先配置腾讯云TRTC参数');
|
||||
return false;
|
||||
@@ -1197,4 +1197,158 @@ class DiagnosisLogic extends BaseLogic
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取就诊卡列表(供小程序调用)
|
||||
* @param int $patientId
|
||||
* @return array|false
|
||||
*/
|
||||
public static function getCardList(int $patientId)
|
||||
{
|
||||
try {
|
||||
if (!$patientId) {
|
||||
self::setError('患者ID不能为空');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 查询该患者的所有诊单
|
||||
$cardList = Diagnosis::where('patient_id', $patientId)
|
||||
->where('delete_time', null)
|
||||
->field([
|
||||
'id', 'patient_id', 'patient_name', 'gender', 'age',
|
||||
'diagnosis_date', 'diagnosis_type', 'syndrome_type',
|
||||
'status', 'create_time', 'update_time'
|
||||
])
|
||||
->order('create_time', 'desc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
// 处理数据格式
|
||||
foreach ($cardList as &$card) {
|
||||
// 转换诊断日期为时间戳和格式化文本
|
||||
if ($card['diagnosis_date']) {
|
||||
$card['diagnosis_date_text'] = date('Y-m-d', $card['diagnosis_date']);
|
||||
} else {
|
||||
$card['diagnosis_date_text'] = '-';
|
||||
}
|
||||
|
||||
// 添加性别描述
|
||||
$card['gender_desc'] = $card['gender'] == 1 ? '男' : '女';
|
||||
|
||||
// 添加状态描述
|
||||
$card['status_desc'] = $card['status'] == 1 ? '启用' : '禁用';
|
||||
|
||||
// 格式化创建时间
|
||||
if ($card['create_time']) {
|
||||
$card['create_time'] = date('Y-m-d H:i:s', $card['create_time']);
|
||||
}
|
||||
|
||||
// 格式化更新时间
|
||||
if ($card['update_time']) {
|
||||
$card['update_time'] = date('Y-m-d H:i:s', $card['update_time']);
|
||||
}
|
||||
}
|
||||
|
||||
return $cardList;
|
||||
} catch (\Exception $e) {
|
||||
\think\facade\Log::error('获取就诊卡列表失败 - patient_id: ' . $patientId . ', error: ' . $e->getMessage());
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 更新就诊卡(供小程序调用)
|
||||
* @param array $params
|
||||
* @return bool
|
||||
*/
|
||||
public static function updateCard(array $params)
|
||||
{
|
||||
try {
|
||||
$diagnosisId = $params['id'] ?? 0;
|
||||
$patientId = $params['patient_id'] ?? 0;
|
||||
|
||||
if (!$diagnosisId) {
|
||||
self::setError('诊单ID不能为空');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$patientId) {
|
||||
self::setError('患者ID不能为空');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获取诊单信息
|
||||
$diagnosis = Diagnosis::find($diagnosisId);
|
||||
|
||||
if (!$diagnosis) {
|
||||
self::setError('诊单不存在');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 权限验证:只能修改自己的诊单
|
||||
if ($diagnosis->patient_id != $patientId) {
|
||||
\think\facade\Log::warning('非法修改诊单 - diagnosis_id: ' . $diagnosisId . ', patient_id: ' . $patientId . ', actual_patient_id: ' . $diagnosis->patient_id);
|
||||
self::setError('无权限修改此诊单');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 准备更新数据
|
||||
$updateData = [
|
||||
'patient_name' => $params['patient_name'] ?? '',
|
||||
'gender' => $params['gender'] ?? 1,
|
||||
'age' => $params['age'] ?? 0,
|
||||
'diagnosis_type' => $params['diagnosis_type'] ?? '',
|
||||
'syndrome_type' => $params['syndrome_type'] ?? '',
|
||||
'diabetes_type' => $params['diabetes_type'] ?? '',
|
||||
// 现病史字段
|
||||
'appetite' => $params['appetite'] ?? '',
|
||||
'water_intake' => $params['water_intake'] ?? '',
|
||||
'diet_condition' => $params['diet_condition'] ?? '',
|
||||
'weight_change' => $params['weight_change'] ?? '',
|
||||
'body_feeling' => $params['body_feeling'] ?? '',
|
||||
'sleep_condition' => $params['sleep_condition'] ?? '',
|
||||
'eye_condition' => $params['eye_condition'] ?? '',
|
||||
'head_feeling' => $params['head_feeling'] ?? '',
|
||||
'sweat_condition' => $params['sweat_condition'] ?? '',
|
||||
'skin_condition' => $params['skin_condition'] ?? '',
|
||||
'urine_condition' => $params['urine_condition'] ?? '',
|
||||
'stool_condition' => $params['stool_condition'] ?? '',
|
||||
'kidney_condition' => $params['kidney_condition'] ?? '',
|
||||
'fatty_liver_degree' => $params['fatty_liver_degree'] ?? '',
|
||||
// 既往史字段
|
||||
'past_history' => $params['past_history'] ?? '',
|
||||
'trauma_history' => $params['trauma_history'] ?? 0,
|
||||
'surgery_history' => $params['surgery_history'] ?? 0,
|
||||
'allergy_history' => $params['allergy_history'] ?? 0,
|
||||
'family_history' => $params['family_history'] ?? 0,
|
||||
'pregnancy_history' => $params['pregnancy_history'] ?? 0,
|
||||
// 临床信息
|
||||
'symptoms' => $params['symptoms'] ?? '',
|
||||
'tongue_coating' => $params['tongue_coating'] ?? '',
|
||||
'pulse' => $params['pulse'] ?? '',
|
||||
'treatment_principle' => $params['treatment_principle'] ?? '',
|
||||
'prescription' => $params['prescription'] ?? '',
|
||||
'doctor_advice' => $params['doctor_advice'] ?? '',
|
||||
'remark' => $params['remark'] ?? '',
|
||||
'update_time' => time()
|
||||
];
|
||||
|
||||
// 处理诊断日期
|
||||
if (!empty($params['diagnosis_date'])) {
|
||||
$updateData['diagnosis_date'] = strtotime($params['diagnosis_date']);
|
||||
}
|
||||
|
||||
// 执行更新
|
||||
$diagnosis->save($updateData);
|
||||
|
||||
\think\facade\Log::info('诊单更新成功 - diagnosis_id: ' . $diagnosisId . ', patient_id: ' . $patientId);
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
\think\facade\Log::error('更新诊单失败 - error: ' . $e->getMessage());
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user