346 lines
14 KiB
PHP
346 lines
14 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', 'getCardList', 'getOrderByNo'];
|
|
|
|
/**
|
|
* @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->userId,
|
|
'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());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @notes 获取就诊卡列表(供小程序调用)
|
|
* @return \think\response\Json
|
|
*/
|
|
public function getCardList()
|
|
{
|
|
$user_id =$this->userId;
|
|
|
|
if (!$user_id) {
|
|
return $this->fail('患者ID不能为空');
|
|
}
|
|
|
|
try {
|
|
$result = DiagnosisLogic::getCardList($user_id);
|
|
|
|
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 addCard()
|
|
{
|
|
$params = [
|
|
'user_id' => $this->userId,
|
|
'patient_id' => $this->request->post('patient_id'),
|
|
'patient_name' => $this->request->post('patient_name'),
|
|
'gender' => $this->request->post('gender'),
|
|
'age' => $this->request->post('age'),
|
|
'id_card' => $this->request->post('id_card'),
|
|
'height' => $this->request->post('height'),
|
|
'weight' => $this->request->post('weight'),
|
|
'systolic_pressure' => $this->request->post('systolic_pressure'),
|
|
'diastolic_pressure' => $this->request->post('diastolic_pressure'),
|
|
'fasting_blood_sugar' => $this->request->post('fasting_blood_sugar'),
|
|
'diabetes_discovery_year' => $this->request->post('diabetes_discovery_year'),
|
|
'local_hospital_diagnosis' => $this->request->post('local_hospital_diagnosis'),
|
|
'local_hospital_name' => $this->request->post('local_hospital_name'),
|
|
'local_hospital_visit_date' => $this->request->post('local_hospital_visit_date'),
|
|
'diagnosis_date' => $this->request->post('diagnosis_date'),
|
|
'diagnosis_type' => $this->request->post('diagnosis_type'),
|
|
'syndrome_type' => $this->request->post('syndrome_type'),
|
|
'diabetes_type' => $this->request->post('diabetes_type'),
|
|
'appetite' => $this->request->post('appetite'),
|
|
'water_intake' => $this->request->post('water_intake'),
|
|
'diet_condition' => $this->request->post('diet_condition'),
|
|
'weight_change' => $this->request->post('weight_change'),
|
|
'body_feeling' => $this->request->post('body_feeling'),
|
|
'sleep_condition' => $this->request->post('sleep_condition'),
|
|
'eye_condition' => $this->request->post('eye_condition'),
|
|
'head_feeling' => $this->request->post('head_feeling'),
|
|
'sweat_condition' => $this->request->post('sweat_condition'),
|
|
'skin_condition' => $this->request->post('skin_condition'),
|
|
'urine_condition' => $this->request->post('urine_condition'),
|
|
'stool_condition' => $this->request->post('stool_condition'),
|
|
'kidney_condition' => $this->request->post('kidney_condition'),
|
|
'fatty_liver_degree' => $this->request->post('fatty_liver_degree'),
|
|
'past_history' => $this->request->post('past_history'),
|
|
'trauma_history' => $this->request->post('trauma_history'),
|
|
'surgery_history' => $this->request->post('surgery_history'),
|
|
'allergy_history' => $this->request->post('allergy_history'),
|
|
'family_history' => $this->request->post('family_history'),
|
|
'pregnancy_history' => $this->request->post('pregnancy_history'),
|
|
'symptoms' => $this->request->post('symptoms'),
|
|
'tongue_coating' => $this->request->post('tongue_coating'),
|
|
'tongue_images' => $this->request->post('tongue_images'),
|
|
'report_files' => $this->request->post('report_files'),
|
|
'pulse' => $this->request->post('pulse'),
|
|
'treatment_principle' => $this->request->post('treatment_principle'),
|
|
'prescription' => $this->request->post('prescription'),
|
|
'doctor_advice' => $this->request->post('doctor_advice'),
|
|
'remark' => $this->request->post('remark')
|
|
];
|
|
// patient_id 可选:不传则创建时自动生成(新患者首张就诊卡)
|
|
try {
|
|
$result = DiagnosisLogic::addCard($params);
|
|
if ($result === false) {
|
|
return $this->fail(DiagnosisLogic::getError());
|
|
}
|
|
return $this->success('创建成功', $result);
|
|
} catch (\Exception $e) {
|
|
return $this->fail($e->getMessage());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @notes 更新就诊卡(供小程序调用)
|
|
* @return \think\response\Json
|
|
*/
|
|
public function updateCard()
|
|
{
|
|
$params = [
|
|
'id' => $this->request->post('id'),
|
|
'patient_id' => $this->request->post('patient_id'),
|
|
'patient_name' => $this->request->post('patient_name'),
|
|
'gender' => $this->request->post('gender'),
|
|
'age' => $this->request->post('age'),
|
|
'id_card' => $this->request->post('id_card'),
|
|
// 生命体征
|
|
'height' => $this->request->post('height'),
|
|
'weight' => $this->request->post('weight'),
|
|
'systolic_pressure' => $this->request->post('systolic_pressure'),
|
|
'diastolic_pressure' => $this->request->post('diastolic_pressure'),
|
|
'fasting_blood_sugar' => $this->request->post('fasting_blood_sugar'),
|
|
// 主诉
|
|
'diabetes_discovery_year' => $this->request->post('diabetes_discovery_year'),
|
|
'local_hospital_diagnosis' => $this->request->post('local_hospital_diagnosis'),
|
|
'local_hospital_name' => $this->request->post('local_hospital_name'),
|
|
'local_hospital_visit_date' => $this->request->post('local_hospital_visit_date'),
|
|
// 诊断信息
|
|
'diagnosis_date' => $this->request->post('diagnosis_date'),
|
|
'diagnosis_type' => $this->request->post('diagnosis_type'),
|
|
'syndrome_type' => $this->request->post('syndrome_type'),
|
|
'diabetes_type' => $this->request->post('diabetes_type'),
|
|
// 现病史字段
|
|
'appetite' => $this->request->post('appetite'),
|
|
'water_intake' => $this->request->post('water_intake'),
|
|
'diet_condition' => $this->request->post('diet_condition'),
|
|
'weight_change' => $this->request->post('weight_change'),
|
|
'body_feeling' => $this->request->post('body_feeling'),
|
|
'sleep_condition' => $this->request->post('sleep_condition'),
|
|
'eye_condition' => $this->request->post('eye_condition'),
|
|
'head_feeling' => $this->request->post('head_feeling'),
|
|
'sweat_condition' => $this->request->post('sweat_condition'),
|
|
'skin_condition' => $this->request->post('skin_condition'),
|
|
'urine_condition' => $this->request->post('urine_condition'),
|
|
'stool_condition' => $this->request->post('stool_condition'),
|
|
'kidney_condition' => $this->request->post('kidney_condition'),
|
|
'fatty_liver_degree' => $this->request->post('fatty_liver_degree'),
|
|
// 既往史字段
|
|
'past_history' => $this->request->post('past_history'),
|
|
'trauma_history' => $this->request->post('trauma_history'),
|
|
'surgery_history' => $this->request->post('surgery_history'),
|
|
'allergy_history' => $this->request->post('allergy_history'),
|
|
'family_history' => $this->request->post('family_history'),
|
|
'pregnancy_history' => $this->request->post('pregnancy_history'),
|
|
// 临床信息
|
|
'symptoms' => $this->request->post('symptoms'),
|
|
'tongue_coating' => $this->request->post('tongue_coating'),
|
|
'tongue_images' => $this->request->post('tongue_images'),
|
|
'report_files' => $this->request->post('report_files'),
|
|
'pulse' => $this->request->post('pulse'),
|
|
'treatment_principle' => $this->request->post('treatment_principle'),
|
|
'prescription' => $this->request->post('prescription'),
|
|
'doctor_advice' => $this->request->post('doctor_advice'),
|
|
'remark' => $this->request->post('remark')
|
|
];
|
|
|
|
if (!$params['id']) {
|
|
return $this->fail('诊单ID不能为空');
|
|
}
|
|
|
|
if (!$params['patient_id']) {
|
|
return $this->fail('患者ID不能为空');
|
|
}
|
|
|
|
try {
|
|
$result = DiagnosisLogic::updateCard($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 getOrderByNo()
|
|
{
|
|
$orderNo = $this->request->get('order_no', '');
|
|
if (empty($orderNo)) {
|
|
return $this->fail('订单号不能为空');
|
|
}
|
|
|
|
try {
|
|
$order = \app\common\model\Order::where('order_no', $orderNo)->find();
|
|
if (!$order) {
|
|
return $this->fail('订单不存在');
|
|
}
|
|
|
|
$typeMap = [1 => '挂号费', 2 => '问诊费', 3 => '药品费用'];
|
|
$statusMap = [1 => '待支付', 2 => '已支付', 3 => '已取消', 4 => '已退款'];
|
|
|
|
return $this->data([
|
|
'id' => $order['id'],
|
|
'order_no' => $order['order_no'],
|
|
'order_type' => $order['order_type'],
|
|
'order_type_desc' => $typeMap[$order['order_type']] ?? '未知',
|
|
'amount' => $order['amount'],
|
|
'status' => $order['status'],
|
|
'status_desc' => $statusMap[$order['status']] ?? '未知',
|
|
'remark' => $order['remark'] ?? '',
|
|
'create_time' => $order['create_time'],
|
|
]);
|
|
} catch (\Exception $e) {
|
|
return $this->fail($e->getMessage());
|
|
}
|
|
}
|
|
}
|