133 lines
3.9 KiB
PHP
133 lines
3.9 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\api\controller;
|
|
|
|
use app\adminapi\logic\tcm\DiagnosisLogic;
|
|
use app\adminapi\logic\ConfigLogic;
|
|
|
|
/**
|
|
* 中医诊断控制器(供小程序调用)
|
|
* Class TcmController
|
|
* @package app\api\controller
|
|
*/
|
|
class TcmController extends BaseApiController
|
|
{
|
|
/**
|
|
* @notes 不需要登录的方法
|
|
* @var array
|
|
*/
|
|
public array $notNeedLogin = ['getPatientSignature', 'diagnosisDetail', 'getDict', 'confirmDiagnosis'];
|
|
|
|
/**
|
|
* @notes 获取患者签名(供小程序调用)
|
|
* @return \think\response\Json
|
|
*/
|
|
public function getPatientSignature()
|
|
{
|
|
$patientId = $this->request->get('patient_id');
|
|
|
|
if (!$patientId) {
|
|
return $this->fail('患者ID不能为空');
|
|
}
|
|
|
|
// 调用逻辑层
|
|
$result = DiagnosisLogic::getPatientSignature($patientId);
|
|
|
|
if ($result === false) {
|
|
return $this->fail(DiagnosisLogic::getError());
|
|
}
|
|
|
|
return $this->data($result);
|
|
}
|
|
|
|
/**
|
|
* @notes 获取诊单详情(供小程序调用)
|
|
* @return \think\response\Json
|
|
*/
|
|
public function diagnosisDetail()
|
|
{
|
|
$params = [
|
|
'id' => $this->request->get('id'),
|
|
'user_id' => $this->request->get('user_id', 0),
|
|
'share_user_id' => $this->request->get('share_user_id', 0)
|
|
];
|
|
|
|
if (!$params['id']) {
|
|
return $this->fail('诊单ID不能为空');
|
|
}
|
|
|
|
try {
|
|
$result = DiagnosisLogic::diagnosisDetailWithRecord($params);
|
|
|
|
if ($result === false) {
|
|
return $this->fail(DiagnosisLogic::getError());
|
|
}
|
|
|
|
return $this->data($result);
|
|
} catch (\Exception $e) {
|
|
return $this->fail($e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @notes 确认诊单(供小程序调用)
|
|
* @return \think\response\Json
|
|
*/
|
|
public function confirmDiagnosis()
|
|
{
|
|
$params = [
|
|
'id' => $this->request->post('id'),
|
|
'user_id' => $this->userId,
|
|
'share_user_id' => $this->request->post('share_user', 0)
|
|
];
|
|
|
|
if (!$params['id']) {
|
|
return $this->fail('诊单ID不能为空');
|
|
}
|
|
|
|
try {
|
|
$result = DiagnosisLogic::confirmDiagnosisRecord($params);
|
|
|
|
if ($result === false) {
|
|
return $this->fail(DiagnosisLogic::getError());
|
|
}
|
|
|
|
return $this->success('确认成功');
|
|
} catch (\Exception $e) {
|
|
return $this->fail($e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @notes 获取字典数据(供小程序调用)
|
|
* @return \think\response\Json
|
|
*/
|
|
public function getDict()
|
|
{
|
|
$type = $this->request->get('type', '');
|
|
|
|
if (!$type) {
|
|
return $this->fail('字典类型不能为空');
|
|
}
|
|
|
|
try {
|
|
$data = ConfigLogic::getDictByType($type);
|
|
return $this->data($data);
|
|
} catch (\Exception $e) {
|
|
return $this->fail($e->getMessage());
|
|
}
|
|
}
|
|
}
|