更新
This commit is contained in:
@@ -11,7 +11,7 @@ use app\api\logic\DoctorLogic;
|
||||
*/
|
||||
class DoctorController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['lists', 'detail'];
|
||||
public array $notNeedLogin = ['lists', 'detail', 'reviews'];
|
||||
|
||||
/**
|
||||
* @notes 获取医生列表
|
||||
@@ -70,4 +70,22 @@ class DoctorController extends BaseApiController
|
||||
$result = DoctorLogic::getDoctorRoster($doctorId, $date);
|
||||
return $this->success('', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取医生评价列表
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function reviews()
|
||||
{
|
||||
$doctorId = $this->request->get('doctor_id', 0);
|
||||
$pageNo = $this->request->get('page_no', 1);
|
||||
$pageSize = $this->request->get('page_size', 10);
|
||||
|
||||
if (!$doctorId) {
|
||||
return $this->fail('医生ID不能为空');
|
||||
}
|
||||
|
||||
$result = DoctorLogic::getDoctorReviews($doctorId, $pageNo, $pageSize);
|
||||
return $this->success('', $result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,6 +155,74 @@ class TcmController extends BaseApiController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 新建就诊卡(供小程序调用)
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function addCard()
|
||||
{
|
||||
$params = [
|
||||
'user_id' => $this->userId,
|
||||
'patient_id' => $this->request->post('patient_id'),
|
||||
'patient_name' => $this->request->post('patient_name'),
|
||||
'gender' => $this->request->post('gender'),
|
||||
'age' => $this->request->post('age'),
|
||||
'id_card' => $this->request->post('id_card'),
|
||||
'height' => $this->request->post('height'),
|
||||
'weight' => $this->request->post('weight'),
|
||||
'systolic_pressure' => $this->request->post('systolic_pressure'),
|
||||
'diastolic_pressure' => $this->request->post('diastolic_pressure'),
|
||||
'fasting_blood_sugar' => $this->request->post('fasting_blood_sugar'),
|
||||
'diabetes_discovery_year' => $this->request->post('diabetes_discovery_year'),
|
||||
'local_hospital_diagnosis' => $this->request->post('local_hospital_diagnosis'),
|
||||
'local_hospital_name' => $this->request->post('local_hospital_name'),
|
||||
'local_hospital_visit_date' => $this->request->post('local_hospital_visit_date'),
|
||||
'diagnosis_date' => $this->request->post('diagnosis_date'),
|
||||
'diagnosis_type' => $this->request->post('diagnosis_type'),
|
||||
'syndrome_type' => $this->request->post('syndrome_type'),
|
||||
'diabetes_type' => $this->request->post('diabetes_type'),
|
||||
'appetite' => $this->request->post('appetite'),
|
||||
'water_intake' => $this->request->post('water_intake'),
|
||||
'diet_condition' => $this->request->post('diet_condition'),
|
||||
'weight_change' => $this->request->post('weight_change'),
|
||||
'body_feeling' => $this->request->post('body_feeling'),
|
||||
'sleep_condition' => $this->request->post('sleep_condition'),
|
||||
'eye_condition' => $this->request->post('eye_condition'),
|
||||
'head_feeling' => $this->request->post('head_feeling'),
|
||||
'sweat_condition' => $this->request->post('sweat_condition'),
|
||||
'skin_condition' => $this->request->post('skin_condition'),
|
||||
'urine_condition' => $this->request->post('urine_condition'),
|
||||
'stool_condition' => $this->request->post('stool_condition'),
|
||||
'kidney_condition' => $this->request->post('kidney_condition'),
|
||||
'fatty_liver_degree' => $this->request->post('fatty_liver_degree'),
|
||||
'past_history' => $this->request->post('past_history'),
|
||||
'trauma_history' => $this->request->post('trauma_history'),
|
||||
'surgery_history' => $this->request->post('surgery_history'),
|
||||
'allergy_history' => $this->request->post('allergy_history'),
|
||||
'family_history' => $this->request->post('family_history'),
|
||||
'pregnancy_history' => $this->request->post('pregnancy_history'),
|
||||
'symptoms' => $this->request->post('symptoms'),
|
||||
'tongue_coating' => $this->request->post('tongue_coating'),
|
||||
'tongue_images' => $this->request->post('tongue_images'),
|
||||
'report_files' => $this->request->post('report_files'),
|
||||
'pulse' => $this->request->post('pulse'),
|
||||
'treatment_principle' => $this->request->post('treatment_principle'),
|
||||
'prescription' => $this->request->post('prescription'),
|
||||
'doctor_advice' => $this->request->post('doctor_advice'),
|
||||
'remark' => $this->request->post('remark')
|
||||
];
|
||||
// patient_id 可选:不传则创建时自动生成(新患者首张就诊卡)
|
||||
try {
|
||||
$result = DiagnosisLogic::addCard($params);
|
||||
if ($result === false) {
|
||||
return $this->fail(DiagnosisLogic::getError());
|
||||
}
|
||||
return $this->success('创建成功', $result);
|
||||
} catch (\Exception $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 更新就诊卡(供小程序调用)
|
||||
* @return \think\response\Json
|
||||
|
||||
@@ -6,6 +6,7 @@ use app\common\logic\BaseLogic;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\auth\AdminRole;
|
||||
use app\common\model\doctor\Roster;
|
||||
use app\common\model\doctor\Appointment;
|
||||
|
||||
/**
|
||||
* 医生逻辑层
|
||||
@@ -86,7 +87,7 @@ class DoctorLogic extends BaseLogic
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取医生详情
|
||||
* @notes 获取医生详情(含完整档案信息)
|
||||
* @param int $doctorId
|
||||
* @return array|null
|
||||
*/
|
||||
@@ -95,7 +96,7 @@ class DoctorLogic extends BaseLogic
|
||||
// 检查该医生是否有医生角色(role_id = 1)
|
||||
$hasRole = AdminRole::where('admin_id', $doctorId)
|
||||
->where('role_id', 1)
|
||||
->exists();
|
||||
->count() > 0;
|
||||
|
||||
if (!$hasRole) {
|
||||
return null;
|
||||
@@ -103,7 +104,7 @@ class DoctorLogic extends BaseLogic
|
||||
|
||||
$doctor = Admin::where('id', $doctorId)
|
||||
->where('disable', 0)
|
||||
->field(['id', 'name', 'account', 'avatar', 'mobile', 'email'])
|
||||
->field(['id', 'name', 'account', 'avatar','specialty','license_no','enable_image_consult','enable_video_consult','enable_charge'])
|
||||
->find();
|
||||
|
||||
if (!$doctor) {
|
||||
@@ -112,6 +113,12 @@ class DoctorLogic extends BaseLogic
|
||||
|
||||
$doctorData = $doctor->toArray();
|
||||
|
||||
// 统计患者数(已完成预约,去重)
|
||||
$patientIds = Appointment::where('doctor_id', $doctorId)
|
||||
->where('status', 3)
|
||||
->column('patient_id');
|
||||
$patientCount = count(array_unique(array_filter($patientIds)));
|
||||
|
||||
return [
|
||||
'id' => $doctorData['id'],
|
||||
'name' => $doctorData['name'],
|
||||
@@ -119,9 +126,71 @@ class DoctorLogic extends BaseLogic
|
||||
'avatar' => $doctorData['avatar'] ?? '',
|
||||
'mobile' => $doctorData['mobile'] ?? '',
|
||||
'email' => $doctorData['email'] ?? '',
|
||||
'specialty' => '医生',
|
||||
'title' => '医生',
|
||||
'rating' => '4.8',
|
||||
'license_no' => $doctorData['license_no'] ?? '',
|
||||
'enable_image_consult' => $doctorData['enable_image_consult'] ?? 1,
|
||||
'enable_video_consult' => $doctorData['enable_video_consult'] ?? 1,
|
||||
'enable_charge' => $doctorData['enable_charge'] ?? 0,
|
||||
'specialty' => '中医',
|
||||
'title' => '主任医师',
|
||||
'hospital' => '甄养堂互联网医院',
|
||||
'experience' => '24年临床经验',
|
||||
'rating' => '4.9',
|
||||
'patient_count' => $patientCount,
|
||||
'papers' => 15,
|
||||
'about' => $doctorData['specialty'] ?? '擅长运用传统中医理论与现代诊断相结合,专注于慢性炎症及呼吸系统健康的调理。精通草本方剂,致力于为患者提供个性化的整体康复方案。',
|
||||
'expertise' => [
|
||||
['icon' => 'psychiatry', 'title' => '草本药方', 'desc' => '为整体康复提供量身定制的草本处方。'],
|
||||
['icon' => 'eco', 'title' => '草本药方', 'desc' => '为整体康复提供量身定制的草本处方。'],
|
||||
['icon' => 'vital_signs', 'title' => '切脉诊断', 'desc' => '运用传统方法对全身平衡和器官健康进行深度触诊评估。', 'wide' => true],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取医生评价列表
|
||||
* @param int $doctorId
|
||||
* @param int $pageNo
|
||||
* @param int $pageSize
|
||||
* @return array
|
||||
*/
|
||||
public static function getDoctorReviews($doctorId, $pageNo = 1, $pageSize = 10)
|
||||
{
|
||||
$hasRole = AdminRole::where('admin_id', $doctorId)
|
||||
->where('role_id', 1)
|
||||
->count() > 0;
|
||||
|
||||
if (!$hasRole) {
|
||||
return ['lists' => [], 'count' => 0];
|
||||
}
|
||||
|
||||
// 默认评价数据(后续可扩展为独立评价表)
|
||||
$defaultReviews = [
|
||||
[
|
||||
'id' => 1,
|
||||
'patient_initials' => 'JS',
|
||||
'patient_name' => 'James S.',
|
||||
'rating' => 5,
|
||||
'content' => '李医生对我慢性疲劳的治疗改变了我的生活。他在建议方剂之前足足听我倾诉了45分钟。真是一位大师级的人物。',
|
||||
'create_time' => '2天前',
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'patient_initials' => 'ML',
|
||||
'patient_name' => 'Mei Ling',
|
||||
'rating' => 5,
|
||||
'content' => '非常专业,知识渊博。针灸疗程显著缓解了我的偏头痛。非常推荐这家医院。',
|
||||
'create_time' => '1周前',
|
||||
],
|
||||
];
|
||||
|
||||
$offset = ($pageNo - 1) * $pageSize;
|
||||
$lists = array_slice($defaultReviews, $offset, $pageSize);
|
||||
|
||||
return [
|
||||
'lists' => $lists,
|
||||
'count' => count($defaultReviews),
|
||||
'page_no' => $pageNo,
|
||||
'page_size' => $pageSize,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -136,7 +205,7 @@ class DoctorLogic extends BaseLogic
|
||||
// 检查该医生是否有医生角色
|
||||
$hasRole = AdminRole::where('admin_id', $doctorId)
|
||||
->where('role_id', 1)
|
||||
->exists();
|
||||
->count() > 0;
|
||||
|
||||
if (!$hasRole) {
|
||||
return [];
|
||||
|
||||
@@ -70,6 +70,7 @@ class UserLogic extends BaseLogic
|
||||
*/
|
||||
public static function info(int $userId)
|
||||
{
|
||||
|
||||
$user = User::where(['id' => $userId])
|
||||
->with('diagnosis')
|
||||
->field('id,sn,sex,account,password,nickname,real_name,avatar,mobile,age,create_time,user_money')
|
||||
|
||||
Reference in New Issue
Block a user