Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵增煜
/
tzt-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8987056c
authored
Nov 18, 2024
by
lujunyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
处方生成修改
parent
9e36284f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
33 deletions
+59
-33
app/Admin/Controllers/PrescriptionController.php
+3
-3
app/Api/Controllers/PrescriptionController.php
+56
-30
No files found.
app/Admin/Controllers/PrescriptionController.php
View file @
8987056c
...
...
@@ -145,12 +145,12 @@ protected function form()
$form
->
hidden
(
'pharmacist_signed_pic'
);
$form
->
table
(
'inquiry_info'
,
function
(
$table
)
{
$table
->
select
(
'inquiry
'
,
'问题项
'
)
->
options
(
InquiryModel
::
all
()
->
pluck
(
'question'
,
'id'
));
$table
->
radio
(
'
selected'
,
'选择项
'
)
->
options
([
1
=>
'是'
,
0
=>
'否'
]);
$table
->
select
(
'inquiry
_id'
,
'问题
'
)
->
options
(
InquiryModel
::
all
()
->
pluck
(
'question'
,
'id'
));
$table
->
radio
(
'
answer'
,
'回答
'
)
->
options
([
1
=>
'是'
,
0
=>
'否'
]);
})
->
saveAsJson
();
$form
->
table
(
'drug_info'
,
function
(
$table
)
{
$table
->
select
(
'pharmacy_drug'
,
'药品'
)
->
options
(
PharmacyDrugModel
::
with
(
'drug'
)
->
get
()
->
pluck
(
'drug.name'
,
'id'
))
->
width
(
3
);
$table
->
select
(
'pharmacy_drug
_id
'
,
'药品'
)
->
options
(
PharmacyDrugModel
::
with
(
'drug'
)
->
get
()
->
pluck
(
'drug.name'
,
'id'
))
->
width
(
3
);
$table
->
number
(
'num'
,
'数量'
)
->
min
(
1
)
->
default
(
1
)
->
width
(
4
);
})
->
saveAsJson
();
$form
->
switch
(
'is_voided'
)
->
width
(
4
);
...
...
app/Api/Controllers/PrescriptionController.php
View file @
8987056c
...
...
@@ -3,7 +3,9 @@
namespace
App\Api\Controllers
;
use
App\Http\Controllers\BaseApiController
;
use
App\Models\DiagnosiModel
;
use
App\Models\DoctorModel
;
use
App\Models\InquiryModel
;
use
App\Models\PatientModel
;
use
App\Models\PharmacistModel
;
use
App\Models\PharmacyDrugModel
;
...
...
@@ -50,12 +52,11 @@ public function prescriptionList(Request $request)
// 时间段
$start_time
=
$request
->
input
(
'start_time'
);
$end_time
=
$request
->
input
(
'end_time'
);
if
(
$start_time
&&
$end_time
)
{
$query
->
whereBetween
(
'created_at'
,
[
$start_time
,
$end_time
]);
}
elseif
(
$start_time
)
{
if
(
$start_time
)
{
$query
->
where
(
'created_at'
,
'>='
,
$start_time
);
}
elseif
(
$end_time
)
{
}
$end_time
=
$request
->
input
(
'end_time'
);
if
(
$end_time
)
{
$query
->
where
(
'created_at'
,
'<='
,
$end_time
);
}
...
...
@@ -87,47 +88,67 @@ public function detail(Request $request)
public
function
create
(
Request
$request
)
{
$authInfo
=
auth
(
'api'
)
->
user
();
$pharmacy_id
=
0
;
$pharmacy_id
=
$request
->
input
(
'pharmacy_id'
,
0
);
$patient_id
=
$request
->
input
(
'patient_id'
);
$diagnosis_id
=
$request
->
input
(
'diagnosis_id'
);
$inquirys
=
$request
->
input
(
'inquirys'
);
// [['inquiry_id'=>1,'answer'=>1]]
$drugs
=
$request
->
input
(
'drugs'
);
// [['pharmacy_drug_id'=>2,'num'=>1]]
$pharmacy
=
null
;
// 获取当前用户信息,如果是药店则无需传pharmacy_id参数
if
(
$authInfo
->
last_login_type
==
User
::
LOGIN_TYPE_PHARMACY
)
{
$pharmacy
=
PharmacyModel
::
query
()
->
where
(
'user_id'
,
$pharmacy_
id
)
->
first
();
$pharmacy
=
PharmacyModel
::
where
(
'user_id'
,
$authInfo
->
id
)
->
first
();
$pharmacy_id
=
$pharmacy
->
id
;
}
elseif
(
$authInfo
->
last_login_type
==
User
::
LOGIN_TYPE_DOCTOR
)
{
$pharmacy_id
=
$request
->
input
(
'pharmacy_id'
);
$pharmacy
=
PharmacyModel
::
query
()
->
where
(
'id'
,
$pharmacy_id
)
->
first
();
$pharmacy
=
PharmacyModel
::
find
(
$pharmacy_id
);
if
(
!
$pharmacy
)
{
return
$this
->
failed
(
'药店信息不存在'
);
}
}
else
{
return
$this
->
failed
(
'pharmacy_id不能为空'
);
}
// 生成处方单号
$patient_id
=
$request
->
input
(
'patient_id'
);
// 获取问诊人信息
$patient
=
PatientModel
::
query
()
->
where
(
'id'
,
$patient_id
)
->
first
();
$patient_age
=
getAgeByIdCard
(
$patient
->
id_card
);
$prescription
=
new
PrescriptionModel
;
$prescription
->
status
=
PrescriptionModel
::
PRESCRIPTION_STATUS_PENDING
;
$prescription
->
user_id
=
$authInfo
->
id
;
// 获取当前用户ID
// 问诊人信息
$patient
=
PatientModel
::
find
(
$patient_id
);
$prescription
->
patient_id
=
$patient_id
;
// 问诊人编号
$prescription
->
patient_name
=
$patient
->
name
;
// 问诊人姓名
$prescription
->
patient_age
=
$patient_age
;
// 问诊人年龄
$prescription
->
patient_age
=
getAgeByIdCard
(
$patient
->
id_card
)
;
// 问诊人年龄
$prescription
->
patient_gender
=
$patient
->
gender
;
// 问诊人性别
// 诊断信息
$prescription
->
diagnosis_id
=
$
request
->
input
(
'diagnosis_id'
)
;
$prescription
->
diagnosis_name
=
$request
->
input
(
'diagnosis_
name'
);
$prescription
->
diagnosis_id
=
$
diagnosis_id
;
$prescription
->
diagnosis_name
=
DiagnosiModel
::
find
(
$diagnosis_id
)
->
value
(
'
name'
);
// 问诊问题
$prescription
->
inquiry_info
=
''
;
// TODO 问诊问题
$inquiry_info
=
[];
foreach
(
$inquirys
as
$inquiry
)
{
$inquiry_info
[]
=
[
'inquiry_id'
=>
$inquiry
[
'inquiry_id'
],
'question'
=>
InquiryModel
::
find
(
$inquiry
[
'inquiry_id'
])
->
value
(
'question'
),
'answer'
=>
$inquiry
[
'answer'
]
==
1
?
1
:
0
,
// [1 => '是', 0 => '否']
];
}
$prescription
->
inquiry_info
=
json_encode
(
$inquiry_info
);
// 用药信息
$prescription
->
drug_info
=
''
;
// TODO 用药信息
$drug_info
=
[];
foreach
(
$drugs
as
$drug
)
{
$pharmacyDrugQueryInfo
=
PharmacyDrugModel
::
with
([
'drug'
,
'dosage'
])
->
find
(
$drug
[
'pharmacy_drug_id'
]);
$drug_info
[]
=
[
'pharmacy_drug_id'
=>
$drug
[
'pharmacy_drug_id'
],
'drug_id'
=>
$pharmacyDrugQueryInfo
->
drug_id
,
'drug_name'
=>
$pharmacyDrugQueryInfo
->
drug
->
name
,
'unit'
=>
$pharmacyDrugQueryInfo
->
unit
,
'dosage_id'
=>
$pharmacyDrugQueryInfo
->
dosage_id
,
'dosage_desc'
=>
$pharmacyDrugQueryInfo
->
dosage
->
dosage_desc
,
'num'
=>
$drug
[
'num'
],
];
}
$prescription
->
drug_info
=
json_encode
(
$drug_info
);
// TODO 用药信息
// 分派医师 TODO 医师当日开方未达到上限以及是否在时间段的搜索出来
// 判断是否开启时间段
// foreach ($doctors as $key => $doctor) {
// }
$doctors
=
DoctorModel
::
query
()
->
where
(
'status'
,
1
)
->
get
();
$randomDoctor
=
$doctors
->
random
();
$randomDoctor
=
DoctorModel
::
inRandomOrder
()
->
where
(
'status'
,
1
)
->
first
();
$prescription
->
doctor_id
=
$randomDoctor
->
id
;
$prescription
->
doctor_name
=
$randomDoctor
->
mame
;
$prescription
->
doctor_online_hospital_name
=
$randomDoctor
->
online_hospital_name
;
...
...
@@ -141,18 +162,19 @@ public function create(Request $request)
$prescription
->
pharmacy_name
=
$pharmacy
->
name
;
// 分派药师,先搜索是否存在默认药师,如果不存在则随机抽取一个
$pharmacist
=
PharmacistModel
::
query
()
->
where
(
'status'
,
1
)
->
where
(
'is_default'
,
1
)
->
where
(
'pharmacy_id'
,
$pharmacy_id
)
->
first
();
if
(
!
$pharmacist
)
{
$pharmacists
=
PharmacistModel
::
query
()
->
where
(
'status'
,
1
)
->
where
(
'pharmacy_id'
,
$pharmacy_id
)
->
get
();
$pharmacist
=
$pharmacists
->
random
();
}
$pharmacist
=
PharmacistModel
::
where
(
'status'
,
1
)
->
where
(
'pharmacy_id'
,
$pharmacy_id
)
->
where
(
function
(
$query
)
{
$query
->
where
(
'is_default'
,
1
)
->
orWhereNull
(
'is_default'
);
})
->
inRandomOrder
()
->
first
();
$prescription
->
pharmacist_id
=
$pharmacist
->
id
;
$prescription
->
pharmacist_name
=
$pharmacist
->
name
;
$prescription
->
pharmacist_license_number
=
$pharmacist
->
license_number
;
$prescription
->
pharmacist_signed_pic
=
$pharmacist
->
signed_pic
;
// 处方单 默认状态
$prescription
->
status
=
PrescriptionModel
::
PRESCRIPTION_STATUS_PENDING
;
// 生成处方单信息
$prescription_number
=
0
;
if
(
$prescription
->
save
())
{
...
...
@@ -161,9 +183,13 @@ public function create(Request $request)
return
$this
->
failed
(
'生成处方单失败'
);
}
$site_config
=
DB
::
table
(
'admin_settings'
)
->
where
(
'slug'
,
'site_config'
)
->
value
(
'value'
);
$site_config
=
json_decode
(
$site_config
,
true
);
// 获取全局开方配置
$site_config
=
admin_setting_array
(
'site_config'
);
$prescription_limit
=
$site_config
[
'prescription_limit'
];
$prescription_period_status
=
$site_config
[
'prescription_period_status'
];
$prescription_period_start
=
$site_config
[
'prescription_period_start'
];
$prescription_period_end
=
$site_config
[
'prescription_period_end'
];
$prescription_limit_buy_7
=
$site_config
[
'prescription_limit_buy_7'
];
// 判断是否为医师自动开方
$prescription_auto
=
$site_config
[
'prescription_auto'
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment