Files
zyt/server/app/adminapi/controller/doctor/AppointmentController.php

199 lines
6.2 KiB
PHP
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace app\adminapi\controller\doctor;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\doctor\AppointmentLists;
use app\adminapi\logic\doctor\AppointmentLogic;
use app\adminapi\logic\doctor\DoctorNoteLogic;
use app\adminapi\validate\doctor\AppointmentValidate;
/**
* 医生预约控制器
* Class AppointmentController
* @package app\adminapi\controller\doctor
*/
class AppointmentController extends BaseAdminController
{
/**
* @notes 获取可用时间段
* @return \think\response\Json
*/
public function availableSlots()
{
$params = (new AppointmentValidate())->goCheck('availableSlots');
$result = AppointmentLogic::getAvailableSlots($params);
return $this->data($result);
}
/**
* @notes 创建预约
* @return \think\response\Json
*/
public function create()
{
$params = (new AppointmentValidate())->post()->goCheck('create');
$params['assistant_id'] = $this->adminId;
$result = AppointmentLogic::create($params, $this->adminId, $this->adminInfo);
if ($result === false) {
return $this->fail(AppointmentLogic::getError());
}
return $this->success('预约成功', $result);
}
/**
* @notes 取消预约
* @return \think\response\Json
*/
public function cancel()
{
$params = (new AppointmentValidate())->post()->goCheck('cancel');
$result = AppointmentLogic::cancel($params, $this->adminId, $this->adminInfo);
if ($result === false) {
return $this->fail(AppointmentLogic::getError());
}
return $this->success('取消成功');
}
/**
* @notes 预约列表
* @return \think\response\Json
*/
public function lists()
{
return $this->dataLists(new AppointmentLists());
}
/**
* 后台编辑挂号记录(消费者处方-挂号列表等,perms: doctor.appointment/edit
*/
public function edit()
{
$params = (new AppointmentValidate())->post()->goCheck('adminEdit');
$post = $this->request->post();
if (array_key_exists('assistant_id', $post)) {
$params['assistant_id'] = $post['assistant_id'];
}
$result = AppointmentLogic::adminEdit($params, $this->adminId, $this->adminInfo);
if ($result === false) {
return $this->fail(AppointmentLogic::getError());
}
return $this->success('保存成功');
}
/** 批量修改挂号渠道来源(消费者处方-挂号列表) */
public function batchEditChannel()
{
$params = (new AppointmentValidate())->post()->goCheck('batchEditChannel');
$post = $this->request->post();
if (\array_key_exists('channel_source_detail', $post)) {
$params['channel_source_detail'] = $post['channel_source_detail'];
}
$result = AppointmentLogic::adminBatchEditChannel($params, $this->adminId, $this->adminInfo);
if ($result === false) {
return $this->fail(AppointmentLogic::getError());
}
return $this->success((string) ($result['msg'] ?? '操作成功'), $result);
}
/**
* @notes 预约详情
* @return \think\response\Json
*/
public function detail()
{
$params = (new AppointmentValidate())->goCheck('detail');
$result = AppointmentLogic::detail($params);
return $this->data($result);
}
/**
* @notes 获取医生可用号源数
* @return \think\response\Json
*/
public function doctorAvailability()
{
$doctorId = $this->request->get('doctor_id');
$date = $this->request->get('date');
if (!$doctorId || !$date) {
return $this->fail('参数错误');
}
$availableCount = AppointmentLogic::getDoctorAvailability($doctorId, $date);
return $this->data(['available_count' => $availableCount]);
}
/**
* @notes 完成预约
* @return \think\response\Json
*/
public function complete()
{
$params = (new AppointmentValidate())->post()->goCheck('complete');
$result = AppointmentLogic::complete($params);
if ($result === false) {
return $this->fail(AppointmentLogic::getError());
}
return $this->success('操作成功');
}
/**
* @notes 接诊台聚合详情(患者信息 + 诊单病例 + 血糖血压记录)
* @return \think\response\Json
*/
public function reception()
{
$params = (new AppointmentValidate())->goCheck('reception');
$result = AppointmentLogic::reception($params);
return $this->data($result);
}
/**
* @notes 通知接诊医助(发企业微信)
* @return \think\response\Json
*/
public function notifyAssistant()
{
$params = (new AppointmentValidate())->post()->goCheck('notifyAssistant');
$result = AppointmentLogic::notifyAssistant((int) $params['id']);
if (empty($result['ok'])) {
return $this->fail($result['message'] ?? '通知失败');
}
return $this->success('通知已发送');
}
public function addDoctorNote()
{
$params = (new AppointmentValidate())->post()->goCheck('addDoctorNote');
$params['doctor_id'] = $this->adminId;
$result = DoctorNoteLogic::addOrAppend($params);
if ($result === false) {
return $this->fail(DoctorNoteLogic::getError());
}
return $this->success('保存成功');
}
public function doctorNotes()
{
$params = (new AppointmentValidate())->goCheck('doctorNotes');
return $this->data(DoctorNoteLogic::getByDiagnosis((int) $params['diagnosis_id']));
}
public function deleteDoctorNoteImage()
{
$params = (new AppointmentValidate())->post()->goCheck('deleteDoctorNoteImage');
$result = DoctorNoteLogic::deleteImage(
(int) $params['note_id'],
$params['image_type'],
$params['image_path']
);
if ($result === false) {
return $this->fail(DoctorNoteLogic::getError());
}
return $this->success('删除成功');
}
}