321 lines
9.0 KiB
PHP
321 lines
9.0 KiB
PHP
<?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\tcm;
|
|
|
|
use app\adminapi\controller\BaseAdminController;
|
|
use app\adminapi\lists\tcm\DiagnosisLists;
|
|
use app\adminapi\logic\tcm\DiagnosisLogic;
|
|
use app\adminapi\validate\tcm\DiagnosisValidate;
|
|
|
|
/**
|
|
* 中医辨房病因诊单控制器
|
|
* Class DiagnosisController
|
|
* @package app\adminapi\controller\tcm
|
|
*/
|
|
class DiagnosisController extends BaseAdminController
|
|
{
|
|
/**
|
|
* @notes 测试接口
|
|
* @return \think\response\Json
|
|
*/
|
|
public function test()
|
|
{
|
|
return $this->success('中医诊单控制器可以访问', [
|
|
'controller' => 'TcmDiagnosisController',
|
|
'namespace' => __NAMESPACE__,
|
|
'class' => __CLASS__,
|
|
'method' => __METHOD__
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* @notes 诊单列表
|
|
* @return \think\response\Json
|
|
*/
|
|
public function lists()
|
|
{
|
|
return $this->dataLists(new DiagnosisLists());
|
|
}
|
|
|
|
/**
|
|
* @notes 添加诊单
|
|
* @return \think\response\Json
|
|
*/
|
|
public function add()
|
|
{
|
|
$params = (new DiagnosisValidate())->post()->goCheck('add');
|
|
$result = DiagnosisLogic::add($params);
|
|
if ($result) {
|
|
return $this->success('添加成功', ['id' => $result], 1, 1);
|
|
}
|
|
return $this->fail(DiagnosisLogic::getError());
|
|
}
|
|
|
|
/**
|
|
* @notes 编辑诊单
|
|
* @return \think\response\Json
|
|
*/
|
|
public function edit()
|
|
{
|
|
$params = (new DiagnosisValidate())->post()->goCheck('edit');
|
|
$result = DiagnosisLogic::edit($params);
|
|
if ($result) {
|
|
return $this->success('编辑成功', [], 1, 1);
|
|
}
|
|
return $this->fail(DiagnosisLogic::getError());
|
|
}
|
|
|
|
/**
|
|
* @notes 删除诊单
|
|
* @return \think\response\Json
|
|
*/
|
|
public function delete()
|
|
{
|
|
$params = (new DiagnosisValidate())->post()->goCheck('id');
|
|
$result = DiagnosisLogic::delete($params);
|
|
if ($result) {
|
|
return $this->success('删除成功', [], 1, 1);
|
|
}
|
|
return $this->fail(DiagnosisLogic::getError());
|
|
}
|
|
|
|
/**
|
|
* @notes 诊单详情
|
|
* @return \think\response\Json
|
|
*/
|
|
public function detail()
|
|
{
|
|
$params = (new DiagnosisValidate())->goCheck('id');
|
|
$result = DiagnosisLogic::detail($params);
|
|
return $this->data($result);
|
|
}
|
|
|
|
/**
|
|
* @notes 检查手机号是否重复
|
|
* @return \think\response\Json
|
|
*/
|
|
public function checkPhone()
|
|
{
|
|
$params = $this->request->post();
|
|
$result = DiagnosisLogic::checkPhone($params);
|
|
return $this->data($result);
|
|
}
|
|
|
|
/**
|
|
* @notes 检查身份证号是否重复
|
|
* @return \think\response\Json
|
|
*/
|
|
public function checkIdCard()
|
|
{
|
|
$params = $this->request->post();
|
|
$result = DiagnosisLogic::checkIdCard($params);
|
|
return $this->data($result);
|
|
}
|
|
|
|
/**
|
|
* @notes 指派医助
|
|
* @return \think\response\Json
|
|
*/
|
|
public function assign()
|
|
{
|
|
$params = $this->request->post();
|
|
|
|
// 验证参数
|
|
if (empty($params['id'])) {
|
|
return $this->fail('诊单ID不能为空');
|
|
}
|
|
|
|
if (!isset($params['assistant_id'])) {
|
|
return $this->fail('请选择医助');
|
|
}
|
|
|
|
$result = DiagnosisLogic::assign($params);
|
|
if ($result) {
|
|
return $this->success('指派成功', [], 1, 1);
|
|
}
|
|
return $this->fail(DiagnosisLogic::getError());
|
|
}
|
|
|
|
/**
|
|
* @notes 获取通话签名
|
|
* @return \think\response\Json
|
|
*/
|
|
public function getCallSignature()
|
|
{
|
|
$params = $this->request->post();
|
|
|
|
if (empty($params['diagnosis_id'])) {
|
|
return $this->fail('诊单ID不能为空');
|
|
}
|
|
|
|
if (empty($params['patient_id'])) {
|
|
return $this->fail('患者ID不能为空');
|
|
}
|
|
|
|
// 传递当前管理员ID
|
|
$params['admin_id'] = $this->adminId;
|
|
|
|
$result = DiagnosisLogic::getCallSignature($params);
|
|
if ($result) {
|
|
return $this->data($result);
|
|
}
|
|
return $this->fail(DiagnosisLogic::getError());
|
|
}
|
|
|
|
/**
|
|
* @notes 发起通话
|
|
* @return \think\response\Json
|
|
*/
|
|
public function startCall()
|
|
{
|
|
$params = $this->request->post();
|
|
|
|
if (empty($params['diagnosis_id'])) {
|
|
return $this->fail('诊单ID不能为空');
|
|
}
|
|
|
|
// 传递当前管理员ID
|
|
$params['admin_id'] = $this->adminId;
|
|
|
|
$result = DiagnosisLogic::startCall($params);
|
|
if ($result) {
|
|
return $this->success('发起通话成功', [], 1, 1);
|
|
}
|
|
return $this->fail(DiagnosisLogic::getError());
|
|
}
|
|
|
|
/**
|
|
* @notes 结束通话
|
|
* @return \think\response\Json
|
|
*/
|
|
public function endCall()
|
|
{
|
|
$params = $this->request->post();
|
|
|
|
if (empty($params['diagnosis_id'])) {
|
|
return $this->fail('诊单ID不能为空');
|
|
}
|
|
|
|
// 传递当前管理员ID
|
|
$params['admin_id'] = $this->adminId;
|
|
|
|
$result = DiagnosisLogic::endCall($params);
|
|
if ($result) {
|
|
return $this->success('结束通话成功', [], 1, 1);
|
|
}
|
|
return $this->fail(DiagnosisLogic::getError());
|
|
}
|
|
|
|
/**
|
|
* @notes 获取通话记录
|
|
* @return \think\response\Json
|
|
*/
|
|
public function getCallRecords()
|
|
{
|
|
$params = $this->request->get();
|
|
|
|
if (empty($params['diagnosis_id'])) {
|
|
return $this->fail('诊单ID不能为空');
|
|
}
|
|
|
|
$result = DiagnosisLogic::getCallRecords($params);
|
|
return $this->data($result);
|
|
}
|
|
|
|
/**
|
|
* @notes 获取患者通话签名(用于测试)
|
|
* @return \think\response\Json
|
|
*/
|
|
public function getPatientSignature()
|
|
{
|
|
$params = $this->request->get();
|
|
|
|
if (empty($params['patient_id'])) {
|
|
return $this->fail('患者ID不能为空');
|
|
}
|
|
|
|
$result = DiagnosisLogic::getPatientSignature((int)$params['patient_id']);
|
|
if ($result) {
|
|
return $this->data($result);
|
|
}
|
|
return $this->fail(DiagnosisLogic::getError());
|
|
}
|
|
|
|
/**
|
|
* @notes 获取医助列表
|
|
* @return \think\response\Json
|
|
*/
|
|
public function getAssistants()
|
|
{
|
|
$result = DiagnosisLogic::getAssistants();
|
|
return $this->data($result);
|
|
}
|
|
|
|
/**
|
|
* @notes 获取医生列表
|
|
* @return \think\response\Json
|
|
*/
|
|
public function getDoctors()
|
|
{
|
|
$result = DiagnosisLogic::getDoctors();
|
|
return $this->data($result);
|
|
}
|
|
|
|
/**
|
|
* @notes 生成小程序码
|
|
* @return \think\response\Json
|
|
*/
|
|
public function generateMiniProgramQrcode()
|
|
{
|
|
$params = (new DiagnosisValidate())->post()->goCheck('generateQrcode');
|
|
$result = DiagnosisLogic::generateMiniProgramQrcode($params);
|
|
return $this->data($result);
|
|
}
|
|
|
|
/**
|
|
* @notes 搜索患者(用于创建订单等场景)
|
|
* @return \think\response\Json
|
|
*/
|
|
public function searchPatient()
|
|
{
|
|
$keyword = $this->request->get('keyword', '');
|
|
$page_no = $this->request->get('page_no', 1);
|
|
$page_size = $this->request->get('page_size', 10);
|
|
|
|
if (empty($keyword)) {
|
|
return $this->success('', ['lists' => [], 'count' => 0]);
|
|
}
|
|
|
|
$offset = ($page_no - 1) * $page_size;
|
|
|
|
$lists = \app\common\model\tcm\Diagnosis::where('patient_name|patient_phone|patient_id_card', 'like', '%' . $keyword . '%')
|
|
->field(['id', 'patient_name', 'patient_phone', 'patient_id_card', 'gender', 'age'])
|
|
->limit($offset, $page_size)
|
|
->order('id desc')
|
|
->select()
|
|
->toArray();
|
|
|
|
$count = \app\common\model\tcm\Diagnosis::where('patient_name|patient_phone|patient_id_card', 'like', '%' . $keyword . '%')
|
|
->count();
|
|
|
|
return $this->success('', [
|
|
'lists' => $lists,
|
|
'count' => $count,
|
|
'page_no' => $page_no,
|
|
'page_size' => $page_size
|
|
]);
|
|
}
|
|
}
|