新增获取我的问诊、关注医生列表接口

This commit is contained in:
2023-03-04 17:08:14 +08:00
parent 80dbd4bf93
commit 707a0eb6fd
11 changed files with 280 additions and 74 deletions
+100 -43
View File
@@ -440,62 +440,60 @@ class PatientDoctorService extends BaseService
}
/**
* 获取首页服务过患者的医生
* 限制条数
* @param string $patient_id
* @return array
* 获取我的问诊、关注医生列表
* @return array|void
*/
public function getIndexPatientDoctorLimit(string $patient_id): array
{
$results = array();
public function getDoctorList(){
$user_info = $this->request->getAttribute("userInfo") ?? [];
$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;
}
$my_doctor_type = $this->request->input('my_doctor_type'); // 医生类型(1:问诊 2:关注)
$page = $this->request->input('page', 1);
$per_page = $this->request->input('per_page', 10);
if (count($results) > 5){
// 超出5个
continue;
}
if ($my_doctor_type == 1){
// 问诊
$params = array();
$params['patient_id'] = $user_info['client_user_id'];
$params['history_status'] = 1;
$result = PatientHistoryInquiryModel::getPage($params);
}else{
// 关注
$params = array();
$params['patient_id'] = $user_info['client_user_id'];
$result = PatientFollow::getPage($params);
}
// 检测是否重复,如果重复,删除最早的一个数据
foreach ($results as $key => $result){
if ($patient_history_doctor['doctor_id'] == $result['doctor_id']){
unset($results[$key]);
// 处理数据
if (!empty($result['data'])) {
foreach ($result['data'] as $item) {
$data = array();
// 医生专长
if (!empty($item['DoctorExpertise'])) {
foreach ($item['DoctorExpertise'] as &$doctor_expertise) {
if (!empty($doctor_expertise['DiseaseClassExpertise'])) {
$doctor_expertise['expertise_name'] = $doctor_expertise['DiseaseClassExpertise']['expertise_name'];
}
unset($doctor_expertise['DiseaseClassExpertise']);
}
}
$data['doctor_expertise'] = $item['DoctorExpertise'];
// 组合数据
$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'];
}
// 医生数据
$data['user_doctor'] = $item['UserDoctor'];
// 按照天来计算,当日为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);
}
// 头像
$data['user_doctor']['avatar'] = addAliyunOssWebsite($data['user_doctor']['avatar']);
$results[] = $data;
// 职称
$data['user_doctor']['doctor_title_name'] = empty($data['user_doctor']['doctor_title']) ? "" : DoctorTitleCode::getMessage($data['user_doctor']['doctor_title']);
unset($data);
$result['data'] = $data;
}
}
$results = array_merge($results);
return $results;
return success($result);
}
/**
@@ -568,4 +566,63 @@ class PatientDoctorService extends BaseService
}
return success($results);
}
/**
* 获取首页服务过患者的医生
* 限制条数
* @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::getIndexHistoryDoctorList($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;
}
}