迁移我的医生服务类,新增获取问诊医生列表
This commit is contained in:
@@ -14,6 +14,7 @@ use App\Model\PatientHistoryInquiry as PatientHistoryInquiryModel;
|
||||
use App\Model\SystemInquiryConfig;
|
||||
use App\Model\SystemInquiryTime;
|
||||
use App\Model\UserDoctor;
|
||||
use App\Model\UserDoctor as UserDoctorModel;
|
||||
|
||||
class PatientDoctorService extends BaseService
|
||||
{
|
||||
@@ -437,4 +438,134 @@ class PatientDoctorService extends BaseService
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取首页服务过患者的医生
|
||||
* 限制条数
|
||||
* @param string $patient_id
|
||||
* @return array
|
||||
*/
|
||||
public function getIndexPatientDoctorLimit(string $patient_id): array
|
||||
{
|
||||
$results = array();
|
||||
|
||||
$params = array();
|
||||
$params['patient_id'] = $patient_id;
|
||||
$params['history_status'] = 1;
|
||||
$patient_history_doctors = PatientHistoryInquiryModel::getIndexHistoryDoctorLimit($params);
|
||||
if (!empty($patient_history_doctors)) {
|
||||
foreach ($patient_history_doctors as $patient_history_doctor) {
|
||||
if (empty($patient_history_doctor['userDoctor'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (count($results) > 5){
|
||||
// 超出5个
|
||||
continue;
|
||||
}
|
||||
|
||||
// 检测是否重复,如果重复,删除最早的一个数据
|
||||
foreach ($results as $key => $result){
|
||||
if ($patient_history_doctor['doctor_id'] == $result['doctor_id']){
|
||||
unset($results[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
// 组合数据
|
||||
$data = array();
|
||||
$data['doctor_id'] = $patient_history_doctor['userDoctor']['doctor_id'];
|
||||
$data['user_name'] = $patient_history_doctor['userDoctor']['user_name'];
|
||||
$data['avatar'] = addAliyunOssWebsite($patient_history_doctor['userDoctor']['avatar']);
|
||||
$data['hospital_name'] = "";
|
||||
if (!empty($patient_history_doctor['userDoctor']['Hospital'])) {
|
||||
$data['hospital_name'] = $patient_history_doctor['userDoctor']['Hospital']['hospital_name'];
|
||||
}
|
||||
|
||||
// 按照天来计算,当日为1,前一天为2 未服务过为0
|
||||
if (empty($patient_history_doctor['created_at'])) {
|
||||
$data['days'] = 0;
|
||||
} else {
|
||||
$data['days'] = ceil((strtotime(date('Y-m-d', strtotime('+1 day'))) - strtotime($patient_history_doctor['created_at'])) / 86400);
|
||||
}
|
||||
|
||||
$results[] = $data;
|
||||
|
||||
unset($data);
|
||||
}
|
||||
}
|
||||
|
||||
$results = array_merge($results);
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取首页推荐医生
|
||||
* 限制条数
|
||||
* @return array
|
||||
*/
|
||||
public function getIndexRecommendDoctorLimit(): array
|
||||
{
|
||||
$results = array();
|
||||
|
||||
// 推荐医生
|
||||
$fields = [
|
||||
"doctor_id",
|
||||
"user_id",
|
||||
"user_name",
|
||||
"status",
|
||||
"multi_point_status",
|
||||
"avatar",
|
||||
"doctor_title",
|
||||
"department_custom_name",
|
||||
"hospital_id",
|
||||
"is_online",
|
||||
"is_img_expert_reception",
|
||||
"is_img_welfare_reception",
|
||||
"be_good_at",
|
||||
];
|
||||
|
||||
$recommend_doctors = UserDoctorModel::getIndexRecommendDoctorLimit(5, $fields);
|
||||
if (empty($recommend_doctors)) {
|
||||
return success();
|
||||
}
|
||||
|
||||
foreach ($recommend_doctors as $recommend_doctor) {
|
||||
$data = array();
|
||||
$data['doctor_id'] = $recommend_doctor['doctor_id'];
|
||||
$data['user_id'] = $recommend_doctor['user_id'];
|
||||
$data['user_name'] = $recommend_doctor['user_name'];
|
||||
$data['status'] = $recommend_doctor['status'];
|
||||
$data['multi_point_status'] = $recommend_doctor['multi_point_status']; // 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败)
|
||||
$data['avatar'] = addAliyunOssWebsite($recommend_doctor['avatar']);
|
||||
$data['doctor_title'] = empty($recommend_doctor['doctor_title']) ? "" : DoctorTitleCode::getMessage($recommend_doctor['doctor_title']);
|
||||
$data['department_custom_name'] = $recommend_doctor['department_custom_name'];
|
||||
$data['is_online'] = $recommend_doctor['is_online'];
|
||||
$data['is_img_welfare_reception'] = $recommend_doctor['is_img_welfare_reception'];
|
||||
$data['be_good_at'] = $recommend_doctor['be_good_at'];
|
||||
$data['hospital_name'] = $recommend_doctor['Hospital']['hospital_name'];
|
||||
$data['hospital_level_name'] = $recommend_doctor['Hospital']['hospital_level_name'];
|
||||
|
||||
// 处理接诊价格
|
||||
$data['price'] = 0;
|
||||
$data['free_clinic_price'] = 0;
|
||||
foreach ($recommend_doctor['DoctorInquiryConfig'] as $doctor_inquiry_config) {
|
||||
if ($doctor_inquiry_config['inquiry_mode'] == 1){
|
||||
if ($doctor_inquiry_config['inquiry_type'] == 1) {
|
||||
// 专家问诊
|
||||
$data['price'] = $doctor_inquiry_config['inquiry_price'];
|
||||
}
|
||||
|
||||
if ($doctor_inquiry_config['inquiry_type'] == 3) {
|
||||
// 公益
|
||||
$data['free_clinic_price'] = $doctor_inquiry_config['inquiry_price'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$results[] = $data;
|
||||
|
||||
unset($data);
|
||||
}
|
||||
return success($results);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user