新增
This commit is contained in:
@@ -1,138 +1,138 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\controller\dept;
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\logic\dept\DeptLogic;
|
||||
use app\adminapi\validate\dept\DeptValidate;
|
||||
|
||||
/**
|
||||
* 部门管理控制器
|
||||
* Class DeptController
|
||||
* @package app\adminapi\controller\dept
|
||||
*/
|
||||
class DeptController extends BaseAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 部门列表
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2022/5/25 18:07
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$result = DeptLogic::lists($params);
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 上级部门
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/5/26 18:36
|
||||
*/
|
||||
public function leaderDept()
|
||||
{
|
||||
$result = DeptLogic::leaderDept();
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加部门
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2022/5/25 18:40
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new DeptValidate())->post()->goCheck('add');
|
||||
DeptLogic::add($params);
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑部门
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2022/5/25 18:41
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new DeptValidate())->post()->goCheck('edit');
|
||||
$result = DeptLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(DeptLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除部门
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2022/5/25 18:41
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new DeptValidate())->post()->goCheck('delete');
|
||||
DeptLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取部门详情
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2022/5/25 18:41
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new DeptValidate())->goCheck('detail');
|
||||
$result = DeptLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取部门数据
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/10/13 10:28
|
||||
*/
|
||||
public function all()
|
||||
{
|
||||
$apply = (int) ($this->request->get('apply_data_scope', 0));
|
||||
$result = $apply === 1
|
||||
? DeptLogic::getAllDataScoped($this->adminId, $this->adminInfo)
|
||||
: DeptLogic::getAllData();
|
||||
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\controller\dept;
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\logic\dept\DeptLogic;
|
||||
use app\adminapi\validate\dept\DeptValidate;
|
||||
|
||||
/**
|
||||
* 部门管理控制器
|
||||
* Class DeptController
|
||||
* @package app\adminapi\controller\dept
|
||||
*/
|
||||
class DeptController extends BaseAdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 部门列表
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2022/5/25 18:07
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$result = DeptLogic::lists($params);
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 上级部门
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/5/26 18:36
|
||||
*/
|
||||
public function leaderDept()
|
||||
{
|
||||
$result = DeptLogic::leaderDept();
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加部门
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2022/5/25 18:40
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new DeptValidate())->post()->goCheck('add');
|
||||
DeptLogic::add($params);
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑部门
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2022/5/25 18:41
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new DeptValidate())->post()->goCheck('edit');
|
||||
$result = DeptLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(DeptLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除部门
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2022/5/25 18:41
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new DeptValidate())->post()->goCheck('delete');
|
||||
DeptLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取部门详情
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2022/5/25 18:41
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new DeptValidate())->goCheck('detail');
|
||||
$result = DeptLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取部门数据
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/10/13 10:28
|
||||
*/
|
||||
public function all()
|
||||
{
|
||||
$apply = (int) ($this->request->get('apply_data_scope', 0));
|
||||
$result = $apply === 1
|
||||
? DeptLogic::getAllDataScoped($this->adminId, $this->adminInfo)
|
||||
: DeptLogic::getAllData();
|
||||
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,198 +1,198 @@
|
||||
<?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('删除成功');
|
||||
}
|
||||
}
|
||||
<?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('删除成功');
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,96 +1,96 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\controller\qywx;
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\qywx\CustomerLists;
|
||||
use app\adminapi\logic\qywx\CustomerLogic;
|
||||
use app\adminapi\validate\qywx\CustomerValidate;
|
||||
|
||||
/**
|
||||
* 企业微信客户管理控制器
|
||||
*/
|
||||
class CustomerController extends BaseAdminController
|
||||
{
|
||||
/**
|
||||
* @notes 客户列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new CustomerLists());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 同步企业微信客户
|
||||
*/
|
||||
public function sync()
|
||||
{
|
||||
$result = CustomerLogic::triggerBackgroundSync();
|
||||
if ($result === false) {
|
||||
return $this->fail(CustomerLogic::getError());
|
||||
}
|
||||
$msg = is_array($result) && isset($result['message']) ? (string) $result['message'] : '已提交同步';
|
||||
|
||||
return $this->success($msg, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取统计信息
|
||||
*/
|
||||
public function stats()
|
||||
{
|
||||
$stats = CustomerLogic::getStats();
|
||||
return $this->data($stats);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取标签维度统计(按 group 分组、按客户数倒序,供前端筛选下拉 + 标签面板共用)
|
||||
*/
|
||||
public function tagStats()
|
||||
{
|
||||
return $this->data(CustomerLogic::getTagStats());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 今日进入分布(用于页面"今日新增"卡片的迷你柱/最近进入时间/渠道 Top5)
|
||||
*/
|
||||
public function todayArrival()
|
||||
{
|
||||
return $this->data(CustomerLogic::getTodayArrivalStats());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 今日进入明细流水(每一次 add_external_contact 推送 = 一行,按时间倒序分页)
|
||||
*/
|
||||
public function todayArrivalList()
|
||||
{
|
||||
$pageNo = (int) $this->request->get('page_no', 1);
|
||||
$pageSize = (int) $this->request->get('page_size', 20);
|
||||
|
||||
return $this->data(CustomerLogic::getTodayArrivalList($pageNo, $pageSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取同步设置
|
||||
*/
|
||||
public function getSyncSettings()
|
||||
{
|
||||
$settings = CustomerLogic::getSyncSettings();
|
||||
return $this->data($settings);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 保存同步设置
|
||||
*/
|
||||
public function saveSyncSettings()
|
||||
{
|
||||
$params = (new CustomerValidate())->post()->goCheck('syncSettings');
|
||||
$result = CustomerLogic::saveSyncSettings($params);
|
||||
if ($result === false) {
|
||||
return $this->fail(CustomerLogic::getError());
|
||||
}
|
||||
return $this->success('保存成功');
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\controller\qywx;
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\qywx\CustomerLists;
|
||||
use app\adminapi\logic\qywx\CustomerLogic;
|
||||
use app\adminapi\validate\qywx\CustomerValidate;
|
||||
|
||||
/**
|
||||
* 企业微信客户管理控制器
|
||||
*/
|
||||
class CustomerController extends BaseAdminController
|
||||
{
|
||||
/**
|
||||
* @notes 客户列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new CustomerLists());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 同步企业微信客户
|
||||
*/
|
||||
public function sync()
|
||||
{
|
||||
$result = CustomerLogic::triggerBackgroundSync();
|
||||
if ($result === false) {
|
||||
return $this->fail(CustomerLogic::getError());
|
||||
}
|
||||
$msg = is_array($result) && isset($result['message']) ? (string) $result['message'] : '已提交同步';
|
||||
|
||||
return $this->success($msg, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取统计信息
|
||||
*/
|
||||
public function stats()
|
||||
{
|
||||
$stats = CustomerLogic::getStats();
|
||||
return $this->data($stats);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取标签维度统计(按 group 分组、按客户数倒序,供前端筛选下拉 + 标签面板共用)
|
||||
*/
|
||||
public function tagStats()
|
||||
{
|
||||
return $this->data(CustomerLogic::getTagStats());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 今日进入分布(用于页面"今日新增"卡片的迷你柱/最近进入时间/渠道 Top5)
|
||||
*/
|
||||
public function todayArrival()
|
||||
{
|
||||
return $this->data(CustomerLogic::getTodayArrivalStats());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 今日进入明细流水(每一次 add_external_contact 推送 = 一行,按时间倒序分页)
|
||||
*/
|
||||
public function todayArrivalList()
|
||||
{
|
||||
$pageNo = (int) $this->request->get('page_no', 1);
|
||||
$pageSize = (int) $this->request->get('page_size', 20);
|
||||
|
||||
return $this->data(CustomerLogic::getTodayArrivalList($pageNo, $pageSize));
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取同步设置
|
||||
*/
|
||||
public function getSyncSettings()
|
||||
{
|
||||
$settings = CustomerLogic::getSyncSettings();
|
||||
return $this->data($settings);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 保存同步设置
|
||||
*/
|
||||
public function saveSyncSettings()
|
||||
{
|
||||
$params = (new CustomerValidate())->post()->goCheck('syncSettings');
|
||||
$result = CustomerLogic::saveSyncSettings($params);
|
||||
if ($result === false) {
|
||||
return $this->fail(CustomerLogic::getError());
|
||||
}
|
||||
return $this->success('保存成功');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,154 +1,154 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\controller\stats;
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\logic\stats\YejiStatsLogic;
|
||||
|
||||
/**
|
||||
* 业绩看板(部门 × 时间区间)控制器
|
||||
*
|
||||
* - GET stats.yejiStats/overview 单区间
|
||||
* - GET stats.yejiStats/multi 多区间一次返回(默认 月/周/今日/昨日 四张表)
|
||||
* - GET stats.yejiStats/deptOptions 部门下拉
|
||||
* - GET stats.yejiStats/leaderboard 医助排行榜(按展示部门分表)
|
||||
* - GET stats.yejiStats/leadLines 进线数据明细(add_external_contact 逐条)
|
||||
* - GET stats.yejiStats/appointmentLines 医助排行榜「预约诊单」挂号逐条明细
|
||||
* - GET stats.yejiStats/revisitBreakdown 二中心复诊下钻:医助 × 业务订单笔数
|
||||
* - GET stats.yejiStats/assignLines 被指派数明细(医助×诊单去重,与看板同口径)
|
||||
*/
|
||||
class YejiStatsController extends BaseAdminController
|
||||
{
|
||||
public function overview()
|
||||
{
|
||||
// 业绩看板涉及多张大表 + 标签穿透计算,单 30s 上限不够;放宽到 120s 兜底
|
||||
@set_time_limit(120);
|
||||
$params = $this->request->get();
|
||||
|
||||
return $this->data(YejiStatsLogic::overview($params, $this->adminId, $this->adminInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 一次返回 4 个时间区间的数据,对应前端 4 张表。
|
||||
* 默认区间(不传 ranges 时):当月、当周(周一→今天)、今日、昨日。
|
||||
* ranges 也可由前端自定义传入:[{label:..., start_date:..., end_date:...}]
|
||||
*/
|
||||
public function multi()
|
||||
{
|
||||
// 4 个区间叠加,30s 上限对部分线上数据量来说过紧,放宽到 120s
|
||||
@set_time_limit(120);
|
||||
$params = $this->request->get();
|
||||
$rangesRaw = $params['ranges'] ?? null;
|
||||
|
||||
$today = date('Y-m-d');
|
||||
$monthStart = date('Y-m-01');
|
||||
// 周一为起点(PHP date('N') 1=周一)
|
||||
$weekStart = date('Y-m-d', strtotime('monday this week'));
|
||||
$yesterday = date('Y-m-d', strtotime('-1 day'));
|
||||
|
||||
$ranges = [];
|
||||
if (is_array($rangesRaw) && $rangesRaw !== []) {
|
||||
foreach ($rangesRaw as $r) {
|
||||
if (!is_array($r)) {
|
||||
continue;
|
||||
}
|
||||
$ranges[] = [
|
||||
'label' => (string) ($r['label'] ?? ''),
|
||||
'start_date' => (string) ($r['start_date'] ?? $today),
|
||||
'end_date' => (string) ($r['end_date'] ?? ($r['start_date'] ?? $today)),
|
||||
];
|
||||
}
|
||||
}
|
||||
if ($ranges === []) {
|
||||
$ranges = [
|
||||
['label' => '本月(' . date('n') . '月)', 'start_date' => $monthStart, 'end_date' => $today],
|
||||
['label' => '本周(' . substr($weekStart, 5) . '~' . substr($today, 5) . ')', 'start_date' => $weekStart, 'end_date' => $today],
|
||||
['label' => '今日(' . substr($today, 5) . ')', 'start_date' => $today, 'end_date' => $today],
|
||||
['label' => '昨日(' . substr($yesterday, 5) . ')', 'start_date' => $yesterday, 'end_date' => $yesterday],
|
||||
];
|
||||
}
|
||||
|
||||
$base = [];
|
||||
if (isset($params['dept_ids'])) {
|
||||
$base['dept_ids'] = $params['dept_ids'];
|
||||
}
|
||||
if (isset($params['tag_id'])) {
|
||||
$base['tag_id'] = $params['tag_id'];
|
||||
}
|
||||
if (isset($params['channel_code'])) {
|
||||
$base['channel_code'] = $params['channel_code'];
|
||||
}
|
||||
|
||||
return $this->data([
|
||||
'ranges' => $ranges,
|
||||
'tables' => YejiStatsLogic::overviewBatch($ranges, $base, $this->adminId, $this->adminInfo),
|
||||
]);
|
||||
}
|
||||
|
||||
public function deptOptions()
|
||||
{
|
||||
return $this->data(YejiStatsLogic::deptOptions($this->adminId, $this->adminInfo));
|
||||
}
|
||||
|
||||
/** 渠道(标签)下拉,按 source_group_name 分组 */
|
||||
public function channelOptions()
|
||||
{
|
||||
return $this->data(YejiStatsLogic::channelOptions());
|
||||
}
|
||||
|
||||
/** 医助排行榜:与 overview 同筛选;日期由前端传入(多表模式下前端传「今日」单区间) */
|
||||
public function leaderboard()
|
||||
{
|
||||
@set_time_limit(120);
|
||||
$params = $this->request->get();
|
||||
|
||||
return $this->data(YejiStatsLogic::assistantLeaderboards($params, $this->adminId, $this->adminInfo));
|
||||
}
|
||||
|
||||
/** 「未归属中心」行:按诊单医助拆解业绩(与表格补差、合计业绩诊单医助归属一致) */
|
||||
public function unassignedBreakdown()
|
||||
{
|
||||
@set_time_limit(120);
|
||||
$params = $this->request->get();
|
||||
|
||||
return $this->data(YejiStatsLogic::unassignedCenterBreakdown($params, $this->adminId, $this->adminInfo));
|
||||
}
|
||||
|
||||
/** 进线数据明细:与看板「进线数据」同口径 */
|
||||
public function leadLines()
|
||||
{
|
||||
@set_time_limit(120);
|
||||
$params = $this->request->get();
|
||||
|
||||
return $this->data(YejiStatsLogic::leadLineList($params, $this->adminId, $this->adminInfo));
|
||||
}
|
||||
|
||||
/** 医助排行榜「预约诊单」:挂号记录逐条列表(与计数同口径) */
|
||||
public function appointmentLines()
|
||||
{
|
||||
@set_time_limit(120);
|
||||
$params = $this->request->get();
|
||||
|
||||
return $this->data(YejiStatsLogic::leaderboardAppointmentLines($params, $this->adminId, $this->adminInfo));
|
||||
}
|
||||
|
||||
/** 二中心复诊:按部门行 + 复诊分项拆解医助与业务订单笔数 */
|
||||
public function revisitBreakdown()
|
||||
{
|
||||
@set_time_limit(120);
|
||||
$params = $this->request->get();
|
||||
|
||||
return $this->data(YejiStatsLogic::revisitDeptAssistantBreakdown($params, $this->adminId, $this->adminInfo));
|
||||
}
|
||||
|
||||
/** 被指派数明细:与看板「被指派数」同口径(区间内非继承指派,医助×诊单去重) */
|
||||
public function assignLines()
|
||||
{
|
||||
@set_time_limit(120);
|
||||
$params = $this->request->get();
|
||||
|
||||
return $this->data(YejiStatsLogic::assignLines($params, $this->adminId, $this->adminInfo));
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\controller\stats;
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\logic\stats\YejiStatsLogic;
|
||||
|
||||
/**
|
||||
* 业绩看板(部门 × 时间区间)控制器
|
||||
*
|
||||
* - GET stats.yejiStats/overview 单区间
|
||||
* - GET stats.yejiStats/multi 多区间一次返回(默认 月/周/今日/昨日 四张表)
|
||||
* - GET stats.yejiStats/deptOptions 部门下拉
|
||||
* - GET stats.yejiStats/leaderboard 医助排行榜(按展示部门分表)
|
||||
* - GET stats.yejiStats/leadLines 进线数据明细(add_external_contact 逐条)
|
||||
* - GET stats.yejiStats/appointmentLines 医助排行榜「预约诊单」挂号逐条明细
|
||||
* - GET stats.yejiStats/revisitBreakdown 二中心复诊下钻:医助 × 业务订单笔数
|
||||
* - GET stats.yejiStats/assignLines 被指派数明细(医助×诊单去重,与看板同口径)
|
||||
*/
|
||||
class YejiStatsController extends BaseAdminController
|
||||
{
|
||||
public function overview()
|
||||
{
|
||||
// 业绩看板涉及多张大表 + 标签穿透计算,单 30s 上限不够;放宽到 120s 兜底
|
||||
@set_time_limit(120);
|
||||
$params = $this->request->get();
|
||||
|
||||
return $this->data(YejiStatsLogic::overview($params, $this->adminId, $this->adminInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 一次返回 4 个时间区间的数据,对应前端 4 张表。
|
||||
* 默认区间(不传 ranges 时):当月、当周(周一→今天)、今日、昨日。
|
||||
* ranges 也可由前端自定义传入:[{label:..., start_date:..., end_date:...}]
|
||||
*/
|
||||
public function multi()
|
||||
{
|
||||
// 4 个区间叠加,30s 上限对部分线上数据量来说过紧,放宽到 120s
|
||||
@set_time_limit(120);
|
||||
$params = $this->request->get();
|
||||
$rangesRaw = $params['ranges'] ?? null;
|
||||
|
||||
$today = date('Y-m-d');
|
||||
$monthStart = date('Y-m-01');
|
||||
// 周一为起点(PHP date('N') 1=周一)
|
||||
$weekStart = date('Y-m-d', strtotime('monday this week'));
|
||||
$yesterday = date('Y-m-d', strtotime('-1 day'));
|
||||
|
||||
$ranges = [];
|
||||
if (is_array($rangesRaw) && $rangesRaw !== []) {
|
||||
foreach ($rangesRaw as $r) {
|
||||
if (!is_array($r)) {
|
||||
continue;
|
||||
}
|
||||
$ranges[] = [
|
||||
'label' => (string) ($r['label'] ?? ''),
|
||||
'start_date' => (string) ($r['start_date'] ?? $today),
|
||||
'end_date' => (string) ($r['end_date'] ?? ($r['start_date'] ?? $today)),
|
||||
];
|
||||
}
|
||||
}
|
||||
if ($ranges === []) {
|
||||
$ranges = [
|
||||
['label' => '本月(' . date('n') . '月)', 'start_date' => $monthStart, 'end_date' => $today],
|
||||
['label' => '本周(' . substr($weekStart, 5) . '~' . substr($today, 5) . ')', 'start_date' => $weekStart, 'end_date' => $today],
|
||||
['label' => '今日(' . substr($today, 5) . ')', 'start_date' => $today, 'end_date' => $today],
|
||||
['label' => '昨日(' . substr($yesterday, 5) . ')', 'start_date' => $yesterday, 'end_date' => $yesterday],
|
||||
];
|
||||
}
|
||||
|
||||
$base = [];
|
||||
if (isset($params['dept_ids'])) {
|
||||
$base['dept_ids'] = $params['dept_ids'];
|
||||
}
|
||||
if (isset($params['tag_id'])) {
|
||||
$base['tag_id'] = $params['tag_id'];
|
||||
}
|
||||
if (isset($params['channel_code'])) {
|
||||
$base['channel_code'] = $params['channel_code'];
|
||||
}
|
||||
|
||||
return $this->data([
|
||||
'ranges' => $ranges,
|
||||
'tables' => YejiStatsLogic::overviewBatch($ranges, $base, $this->adminId, $this->adminInfo),
|
||||
]);
|
||||
}
|
||||
|
||||
public function deptOptions()
|
||||
{
|
||||
return $this->data(YejiStatsLogic::deptOptions($this->adminId, $this->adminInfo));
|
||||
}
|
||||
|
||||
/** 渠道(标签)下拉,按 source_group_name 分组 */
|
||||
public function channelOptions()
|
||||
{
|
||||
return $this->data(YejiStatsLogic::channelOptions());
|
||||
}
|
||||
|
||||
/** 医助排行榜:与 overview 同筛选;日期由前端传入(多表模式下前端传「今日」单区间) */
|
||||
public function leaderboard()
|
||||
{
|
||||
@set_time_limit(120);
|
||||
$params = $this->request->get();
|
||||
|
||||
return $this->data(YejiStatsLogic::assistantLeaderboards($params, $this->adminId, $this->adminInfo));
|
||||
}
|
||||
|
||||
/** 「未归属中心」行:按诊单医助拆解业绩(与表格补差、合计业绩诊单医助归属一致) */
|
||||
public function unassignedBreakdown()
|
||||
{
|
||||
@set_time_limit(120);
|
||||
$params = $this->request->get();
|
||||
|
||||
return $this->data(YejiStatsLogic::unassignedCenterBreakdown($params, $this->adminId, $this->adminInfo));
|
||||
}
|
||||
|
||||
/** 进线数据明细:与看板「进线数据」同口径 */
|
||||
public function leadLines()
|
||||
{
|
||||
@set_time_limit(120);
|
||||
$params = $this->request->get();
|
||||
|
||||
return $this->data(YejiStatsLogic::leadLineList($params, $this->adminId, $this->adminInfo));
|
||||
}
|
||||
|
||||
/** 医助排行榜「预约诊单」:挂号记录逐条列表(与计数同口径) */
|
||||
public function appointmentLines()
|
||||
{
|
||||
@set_time_limit(120);
|
||||
$params = $this->request->get();
|
||||
|
||||
return $this->data(YejiStatsLogic::leaderboardAppointmentLines($params, $this->adminId, $this->adminInfo));
|
||||
}
|
||||
|
||||
/** 二中心复诊:按部门行 + 复诊分项拆解医助与业务订单笔数 */
|
||||
public function revisitBreakdown()
|
||||
{
|
||||
@set_time_limit(120);
|
||||
$params = $this->request->get();
|
||||
|
||||
return $this->data(YejiStatsLogic::revisitDeptAssistantBreakdown($params, $this->adminId, $this->adminInfo));
|
||||
}
|
||||
|
||||
/** 被指派数明细:与看板「被指派数」同口径(区间内非继承指派,医助×诊单去重) */
|
||||
public function assignLines()
|
||||
{
|
||||
@set_time_limit(120);
|
||||
$params = $this->request->get();
|
||||
|
||||
return $this->data(YejiStatsLogic::assignLines($params, $this->adminId, $this->adminInfo));
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,178 +1,181 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\controller\tcm;
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\logic\tcm\PrescriptionLogic;
|
||||
use app\adminapi\validate\tcm\PrescriptionValidate;
|
||||
|
||||
/**
|
||||
* 中医处方单控制器
|
||||
*/
|
||||
class PrescriptionController extends BaseAdminController
|
||||
{
|
||||
/**
|
||||
* @notes 处方列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new \app\adminapi\lists\tcm\PrescriptionLists());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 添加处方
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new PrescriptionValidate())->post()->goCheck('add');
|
||||
$params['creator_id'] = $this->adminId;
|
||||
$id = PrescriptionLogic::add($params, $this->adminId);
|
||||
if ($id === null) {
|
||||
return $this->fail(PrescriptionLogic::getError());
|
||||
}
|
||||
return $this->success('保存成功', ['id' => $id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑处方
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new PrescriptionValidate())->post()->goCheck('edit');
|
||||
$result = PrescriptionLogic::edit($params, $this->adminId);
|
||||
if (!$result) {
|
||||
return $this->fail(PrescriptionLogic::getError());
|
||||
}
|
||||
return $this->success('编辑成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 修正处方患者姓名手机性别
|
||||
*/
|
||||
public function patchPatient()
|
||||
{
|
||||
$params = (new PrescriptionValidate())->post()->goCheck('patchPatient');
|
||||
$ok = PrescriptionLogic::patchPatientContact(
|
||||
(int) $params['id'],
|
||||
(string) $params['patient_name'],
|
||||
(string) $params['phone'],
|
||||
(int) $params['gender'],
|
||||
(int) $this->adminId,
|
||||
$this->adminInfo
|
||||
);
|
||||
if (!$ok) {
|
||||
return $this->fail(PrescriptionLogic::getError());
|
||||
}
|
||||
|
||||
return $this->success('已更新');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除处方
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new PrescriptionValidate())->post()->goCheck('delete');
|
||||
$result = PrescriptionLogic::delete($params['id']);
|
||||
if (!$result) {
|
||||
return $this->fail(PrescriptionLogic::getError());
|
||||
}
|
||||
return $this->success('删除成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 处方详情
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new PrescriptionValidate())->get()->goCheck('detail');
|
||||
$detail = PrescriptionLogic::detail((int) $params['id'], (int) $this->adminId, $this->adminInfo);
|
||||
|
||||
if (!$detail) {
|
||||
$msg = PrescriptionLogic::getError();
|
||||
|
||||
return $this->fail($msg !== '' ? $msg : '处方不存在');
|
||||
}
|
||||
|
||||
return $this->data($detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 审核处方(通过 / 驳回,驳回即作废)
|
||||
*/
|
||||
public function audit()
|
||||
{
|
||||
$params = (new PrescriptionValidate())->post()->goCheck('audit');
|
||||
$ok = PrescriptionLogic::audit(
|
||||
(int) $params['id'],
|
||||
(string) $params['action'],
|
||||
(string) ($params['remark'] ?? ''),
|
||||
(int) $this->adminId,
|
||||
$this->adminInfo
|
||||
);
|
||||
if (!$ok) {
|
||||
return $this->fail(PrescriptionLogic::getError());
|
||||
}
|
||||
|
||||
$msg = $params['action'] === 'reject' ? '已驳回并作废处方' : '审核通过';
|
||||
$wecom = PrescriptionLogic::consumeLastAuditWecomNotify();
|
||||
$data = [];
|
||||
if (is_array($wecom)) {
|
||||
$data['wecom_notify_ok'] = !empty($wecom['ok']);
|
||||
if (empty($wecom['ok']) && !empty($wecom['message'])) {
|
||||
$data['wecom_notify_hint'] = (string) $wecom['message'];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->success($msg, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 根据诊单获取处方列表
|
||||
*/
|
||||
public function listByDiagnosis()
|
||||
{
|
||||
$diagnosisId = (int)($this->request->get('diagnosis_id') ?? 0);
|
||||
if (!$diagnosisId) {
|
||||
return $this->fail('诊单ID不能为空');
|
||||
}
|
||||
$list = PrescriptionLogic::listByDiagnosis($diagnosisId);
|
||||
return $this->data($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 根据预约获取处方
|
||||
*/
|
||||
public function getByAppointment()
|
||||
{
|
||||
$appointmentId = (int)($this->request->get('appointment_id') ?? 0);
|
||||
if (!$appointmentId) {
|
||||
return $this->fail('预约ID不能为空');
|
||||
}
|
||||
$prescription = PrescriptionLogic::getByAppointment($appointmentId, (int)$this->adminId, $this->adminInfo);
|
||||
if ($prescription === null) {
|
||||
//$msg = PrescriptionLogic::getError();
|
||||
return '';
|
||||
}
|
||||
return $this->data($prescription);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 作废处方
|
||||
*/
|
||||
public function void()
|
||||
{
|
||||
$id = (int)($this->request->post('id') ?? 0);
|
||||
if (!$id) {
|
||||
return $this->fail('处方ID不能为空');
|
||||
}
|
||||
$admin = $this->adminInfo;
|
||||
$ok = PrescriptionLogic::void($id, (int)$this->adminId, $admin['name'] ?? '');
|
||||
if (!$ok) {
|
||||
return $this->fail(PrescriptionLogic::getError());
|
||||
}
|
||||
return $this->success('作废成功');
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\controller\tcm;
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\logic\tcm\PrescriptionLogic;
|
||||
use app\adminapi\validate\tcm\PrescriptionValidate;
|
||||
|
||||
/**
|
||||
* 中医处方单控制器
|
||||
*/
|
||||
class PrescriptionController extends BaseAdminController
|
||||
{
|
||||
/**
|
||||
* @notes 处方列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new \app\adminapi\lists\tcm\PrescriptionLists());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 添加处方
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new PrescriptionValidate())->post()->goCheck('add');
|
||||
$params['creator_id'] = $this->adminId;
|
||||
$id = PrescriptionLogic::add($params, $this->adminId);
|
||||
if ($id === null) {
|
||||
return $this->fail(PrescriptionLogic::getError());
|
||||
}
|
||||
return $this->success('保存成功', ['id' => $id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑处方
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new PrescriptionValidate())->post()->goCheck('edit');
|
||||
$result = PrescriptionLogic::edit($params, $this->adminId);
|
||||
if (!$result) {
|
||||
return $this->fail(PrescriptionLogic::getError());
|
||||
}
|
||||
return $this->success('编辑成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 修正处方患者姓名手机性别
|
||||
*/
|
||||
public function patchPatient()
|
||||
{
|
||||
$params = (new PrescriptionValidate())->post()->goCheck('patchPatient');
|
||||
$ok = PrescriptionLogic::patchPatientContact(
|
||||
(int) $params['id'],
|
||||
(string) $params['patient_name'],
|
||||
(string) $params['phone'],
|
||||
(int) $params['gender'],
|
||||
(int) $this->adminId,
|
||||
$this->adminInfo
|
||||
);
|
||||
if (!$ok) {
|
||||
return $this->fail(PrescriptionLogic::getError());
|
||||
}
|
||||
|
||||
return $this->success('已更新');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除处方
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new PrescriptionValidate())->post()->goCheck('delete');
|
||||
$result = PrescriptionLogic::delete($params['id']);
|
||||
if (!$result) {
|
||||
return $this->fail(PrescriptionLogic::getError());
|
||||
}
|
||||
return $this->success('删除成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 处方详情
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new PrescriptionValidate())->get()->goCheck('detail');
|
||||
$detail = PrescriptionLogic::detail((int) $params['id'], (int) $this->adminId, $this->adminInfo);
|
||||
|
||||
if (!$detail) {
|
||||
$msg = PrescriptionLogic::getError();
|
||||
|
||||
return $this->fail($msg !== '' ? $msg : '处方不存在');
|
||||
}
|
||||
|
||||
return $this->data($detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 审核处方(通过 / 驳回,驳回即作废)
|
||||
*/
|
||||
public function audit()
|
||||
{
|
||||
$params = (new PrescriptionValidate())->post()->goCheck('audit');
|
||||
$ok = PrescriptionLogic::audit(
|
||||
(int) $params['id'],
|
||||
(string) $params['action'],
|
||||
(string) ($params['remark'] ?? ''),
|
||||
(int) $this->adminId,
|
||||
$this->adminInfo
|
||||
);
|
||||
if (!$ok) {
|
||||
return $this->fail(PrescriptionLogic::getError());
|
||||
}
|
||||
|
||||
$msg = $params['action'] === 'reject' ? '已驳回并作废处方' : '审核通过';
|
||||
$wecom = PrescriptionLogic::consumeLastAuditWecomNotify();
|
||||
$data = [];
|
||||
if (is_array($wecom)) {
|
||||
$data['wecom_notify_ok'] = !empty($wecom['ok']);
|
||||
if (empty($wecom['ok']) && !empty($wecom['message'])) {
|
||||
$data['wecom_notify_hint'] = (string) $wecom['message'];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->success($msg, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 根据诊单获取处方列表
|
||||
*/
|
||||
public function listByDiagnosis()
|
||||
{
|
||||
$diagnosisId = (int)($this->request->get('diagnosis_id') ?? 0);
|
||||
if (!$diagnosisId) {
|
||||
return $this->fail('诊单ID不能为空');
|
||||
}
|
||||
$list = PrescriptionLogic::listByDiagnosis($diagnosisId);
|
||||
return $this->data($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 根据预约获取处方
|
||||
*/
|
||||
public function getByAppointment()
|
||||
{
|
||||
$appointmentId = (int)($this->request->get('appointment_id') ?? 0);
|
||||
if (!$appointmentId) {
|
||||
return $this->fail('预约ID不能为空');
|
||||
}
|
||||
$prescription = PrescriptionLogic::getByAppointment($appointmentId, (int)$this->adminId, $this->adminInfo);
|
||||
if ($prescription === null) {
|
||||
$msg = PrescriptionLogic::getError();
|
||||
if ($msg !== '') {
|
||||
return $this->fail($msg);
|
||||
}
|
||||
return $this->data([]);
|
||||
}
|
||||
return $this->data($prescription);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 作废处方
|
||||
*/
|
||||
public function void()
|
||||
{
|
||||
$id = (int)($this->request->post('id') ?? 0);
|
||||
if (!$id) {
|
||||
return $this->fail('处方ID不能为空');
|
||||
}
|
||||
$admin = $this->adminInfo;
|
||||
$ok = PrescriptionLogic::void($id, (int)$this->adminId, $admin['name'] ?? '');
|
||||
if (!$ok) {
|
||||
return $this->fail(PrescriptionLogic::getError());
|
||||
}
|
||||
return $this->success('作废成功');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace app\adminapi\controller\tcm;
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\logic\tcm\PrescriptionLibraryAiLogic;
|
||||
use app\adminapi\logic\tcm\PrescriptionLibraryLogic;
|
||||
use app\adminapi\validate\tcm\PrescriptionLibraryValidate;
|
||||
|
||||
@@ -77,4 +78,74 @@ class PrescriptionLibraryController extends BaseAdminController
|
||||
}
|
||||
return $this->data($detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 读取已保存的双模型 AI 解释,不触发上游调用
|
||||
*/
|
||||
public function aiReports()
|
||||
{
|
||||
$params = (new PrescriptionLibraryValidate())->get()->goCheck('aiReports');
|
||||
$reports = PrescriptionLibraryAiLogic::getSavedReports(
|
||||
(int) $params['id'],
|
||||
$this->adminId,
|
||||
$this->adminInfo
|
||||
);
|
||||
if ($reports === null) {
|
||||
return $this->fail(PrescriptionLibraryAiLogic::getError());
|
||||
}
|
||||
return $this->data($reports);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 查询当前数据范围内完全没有 AI 报告的处方,不触发上游调用
|
||||
*/
|
||||
public function missingAiReports()
|
||||
{
|
||||
$params = (new PrescriptionLibraryValidate())->get()->goCheck('missingAiReports');
|
||||
$result = PrescriptionLibraryAiLogic::getMissingReports(
|
||||
(int) ($params['limit'] ?? 500),
|
||||
$this->adminId,
|
||||
$this->adminInfo
|
||||
);
|
||||
if ($result === null) {
|
||||
return $this->fail(PrescriptionLibraryAiLogic::getError());
|
||||
}
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 整份重新生成两个固定模型的 AI 解释并保存成功项
|
||||
*/
|
||||
public function generateAiReports()
|
||||
{
|
||||
$params = (new PrescriptionLibraryValidate())->post()->goCheck('generateAiReports');
|
||||
$reports = PrescriptionLibraryAiLogic::generateAll(
|
||||
(int) $params['id'],
|
||||
$this->adminId,
|
||||
$this->adminInfo
|
||||
);
|
||||
if ($reports === null) {
|
||||
return $this->fail(PrescriptionLibraryAiLogic::getError());
|
||||
}
|
||||
return $this->data($reports);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑一份已保存的 AI 解释
|
||||
*/
|
||||
public function editAiReport()
|
||||
{
|
||||
$params = (new PrescriptionLibraryValidate())->post()->goCheck('editAiReport');
|
||||
$report = PrescriptionLibraryAiLogic::editReport(
|
||||
(int) $params['id'],
|
||||
(int) $params['report_id'],
|
||||
$params['content'] ?? null,
|
||||
$this->adminId,
|
||||
$this->adminInfo
|
||||
);
|
||||
if ($report === null) {
|
||||
return $this->fail(PrescriptionLibraryAiLogic::getError());
|
||||
}
|
||||
return $this->data($report);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user