Commit fa09b3f7 by 赵增煜

本地

parent 7c00f2ef
......@@ -18,6 +18,8 @@ public function test()
public function drugList(Request $request)
{
// $code = $request->input('code');
# TODO 通过药店编号筛选药品列表
# pharmacy_id = $request->input('code');
$data = DrugModel::query()->paginate(10);
// $total = DrugModel::query()->count();
......
<?php
namespace App\Api\Controllers;
use App\Common\Util;
use App\Http\Controllers\BaseApiController;
use App\Models\InquiryModel;
use App\Models\DrugRelatedTagModel;
use App\Models\DrugTagRelatedInquiryModel;
use Illuminate\Http\Request;
// 问诊问题控制器
class InquiryController extends BaseApiController
{
public function InquirytList(Request $request)
{
$inquiry_list = [];
# 获取通用问题
$inquiry_list_1 = InquiryModel::query()->get()->toArray();
# 通过药品id获取标签
$inquiry_list_2 = [];
$drug_ids = $request->input('drug_ids');
if ($drug_ids) {
$tag_ids = DrugRelatedTagModel::whereIn('drug_id', explode(',', $drug_ids))->pluck('tag_id')->toArray();
# 获取标签关联的问题
if($tag_ids){
$inquiry_ids = DrugTagRelatedInquiryModel::whereIn('tag_id',$tag_ids)->pluck('inquiry_id')->toArray();
# 获取非通用问题
if( $inquiry_ids ){
$inquiry_list_2 = InquiryModel::whereIn('id', array_column($inquiry_ids, 'inquiry_id'))->get()->toArray();
}
}
}
# 合并问题列表
$inquiry_list = array_merge($inquiry_list_1, $inquiry_list_2);
return $this->success($inquiry_list);
}
}
\ No newline at end of file
......@@ -18,9 +18,15 @@ public function test()
// 获取问诊人列表
public function patientList(Request $request)
{
$search_input = $request->input('search_input');
$login_type = $request->input('login_type');
$id = $request->input('id');
$query = PatientModel::query();
if( $login_type == 0 ){ # 用户
$query = $query->where('user_id', $id);
}else if( $login_type == 2 ){ # 药店
$query = $query->where('pharmacy_id', $id);
}
$search_input = $request->input('search_input');
if ($search_input) {
$query->where('mobile', 'like', "%{$search_input}%");
// ->orWhere('mobile', 'like', "%{$search_input}%");
......@@ -75,7 +81,6 @@ public function delete(Request $request)
return $this->error(401, '该问诊人不存在');
}
$data->delete();
return $this->success($data);
}
......@@ -84,16 +89,21 @@ public function setDefault(Request $request)
{
// 通过id找到是否存在默认问诊人,如果存在比对id是否相同,如果不同则修改默认问诊人状态
// TODO 验证条件待调整
$id = $request->input('id');
$data = PatientModel::where('is_default', 1)->where('id', $id)->first();
$login_type = $request->input('login_type');
$uid = $request->input('uid');
# 把该账号下的默认问诊人状态改为0
$query = PatientModel::where('id', $uid)->where('is_default', 1);
if( $login_type == 0 ){
$query = $query->where('user_id', $uid);
}else if( $login_type == 2 ){
$query = $query->where('pharmacy_id', $uid);
}
$data = $query->first();
if ($data) {
if ($data['id'] == $id) {
return $this->success(['msg' => '该问诊人已经是默认问诊人']);
} else {
$data->is_default = 0;
$data->save();
}
}
# 把当前问诊人设为默认
$id = $request->input('id');
$data = PatientModel::find($id);
if (! $data) {
......@@ -101,19 +111,26 @@ public function setDefault(Request $request)
}
$data->is_default = 1;
$data->save();
return $this->success($data);
}
// 获取默认问诊人
public function getDefault(Request $request)
{
$login_type = $request->input('login_type');
$id = $request->input('id');
$data = PatientModel::where('id', $id)->where('is_default', 1)->first();
$query = PatientModel::where('is_default', 1);
if( $login_type == 0 ){
$query = $query->where('user_id', $id);
}else if( $login_type == 2 ){
$query = $query->where('pharmacy_id', $id);
}
$data = $query->first();
if ($data) {
return $this->success($data);
} else {
return $this->error(401, '暂无默认问诊人');
}
}
}
<?php
namespace App\Api\Controllers;
use App\Common\Util;
use App\Http\Controllers\BaseApiController;
use App\Models\PrescriptionModel;
use App\Models\PatientModel;
use Illuminate\Http\Request;
// 问诊人控制器
class PrescriptionController extends BaseApiController
{
# 开方
public function create(Request $request)
{
# $userId = auth('api')->user()->id;
# 生成处方单号
$patient_id = $request->input('patient_id');
# 获取问诊人信息
$patient = PatientModel::query()->where('id', $patient_id)->first();
$data = [];
$data['prescription_umber'] = ""; # TODO 处方单编号生成逻辑待定
$data['status'] = 0; # TODO Model中增加枚举
$data['user_id'] = ""; # TODO 获取当前用户ID
$data['patient_id'] = $patient_id; # 问诊人编号
$data['patient_name'] = $patient->name; # 问诊人姓名
$data['patient_age'] = $patient->age; # 问诊人年龄
$data['patient_gender'] = $patient->gender; # 问诊人性别
# 分派医师 医师当日开方未达到上限以及是否在时间段的搜索出来
# 给医师发送短信
# 判断是否为医师自动开方
# 生成医师开方日志
# 分派药师
# 判断是否药师自动审方
# 生成药师审方日志
# 给药师发送短信
# 生成处方单信息
}
}
\ No newline at end of file
......@@ -22,7 +22,7 @@ public function up()
$table->string('license_no', 30)->comment('执照编号');
$table->string('license_no_pic')->comment('执行证书');
$table->string('license_no_period')->comment('执行证书有效期');
$table->string('physician_license', 30)->comment('执业资格证书');
$table->string('physician_license')->comment('执业资格证书');
$table->string('id_card_front_pic')->comment('身份证正面照');
$table->string('id_card_back_pic')->comment('身份证反面照');
$table->string('online_hospital_name', 128)->comment('互联网医院名称');
......@@ -32,6 +32,7 @@ public function up()
$table->text('introduction')->nullable()->comment('简介');
$table->boolean('status')->default(0)->comment('是否启用[0=未启用,1=启用]');
$table->text('signed_pic')->nullable()->comment('签名照');
$table->bigInteger('user_id')->nullable()->unique('uk_userid')->comment('用户表ID');
$table->timestamps();
$table->softDeletes();
});
......
......@@ -25,6 +25,7 @@ public function up()
$table->string('physician_license')->comment('执业资格证书');
$table->string('signed_pic')->comment('签名照');
$table->boolean('status')->default(0)->comment('启用[0=未启用,1=启用]');
$table->bigInteger('user_id')->nullable()->unique('uk_userid')->comment('用户表ID');
$table->timestamps();
$table->softDeletes();
});
......
......@@ -41,12 +41,17 @@
Route::post('/patients-setDefault', 'App\Api\Controllers\PatientController@setDefault');
# 获取默认问诊人
Route::post('/patients-getDefault', 'App\Api\Controllers\PatientController@getDefault');
# 获取问诊问题列表
Route::get('/inquirys', 'App\Api\Controllers\InquiryController@InquirytList');
# 开方
Route::post('/prescription-create', 'App\Api\Controllers\PrescriptionController@create');
// 需要验证是否登录的路由组
Route::middleware(['jwt.auth'])->group(function () {
// 获取用户信息
Route::get('/users', 'App\Api\Controllers\UserController@userInfo');
// 获取药品列表
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment