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
2f33618e
authored
Dec 03, 2024
by
赵增煜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增药品筛选条件
parent
857cf186
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
6 deletions
+71
-6
app/Api/Controllers/DrugController.php
+4
-3
app/Api/Controllers/PrescriptionController.php
+67
-3
No files found.
app/Api/Controllers/DrugController.php
View file @
2f33618e
...
...
@@ -65,6 +65,7 @@ public function drugList(Request $request)
$pharmacy_id
=
$pharmacy
->
id
;
}
$search_input
=
$request
->
input
(
'search_input'
);
$drug_type
=
$request
->
input
(
'drug_type'
,
0
);
// $data = PharmacyDrugModel::where('pharmacy_id', $pharmacy_id)
// ->whereNotNull('dosage_id')
// ->whereHas('drug', function ($query) use ($search_input) {
...
...
@@ -77,9 +78,9 @@ public function drugList(Request $request)
// ->paginate(10);
$data
=
PharmacyDrugModel
::
where
(
'pharmacy_id'
,
$pharmacy_id
)
// ->whereNotNull('dosage_id')
->
whereHas
(
'drug'
,
function
(
$query
)
use
(
$search_input
)
{
->
whereHas
(
'drug'
,
function
(
$query
)
use
(
$search_input
,
$drug_type
)
{
//$query->where('is_rx', DrugModel::RX_TRUE)
$query
->
where
(
function
(
$subQuery
)
use
(
$search_input
)
{
$query
->
where
(
'drug_type'
,
$drug_type
)
->
where
(
function
(
$subQuery
)
use
(
$search_input
)
{
if
(
$search_input
)
{
$subQuery
->
where
(
'name'
,
'LIKE'
,
"%
{
$search_input
}
%"
)
->
orWhere
(
'code'
,
'LIKE'
,
"%
{
$search_input
}
%"
);
...
...
@@ -158,7 +159,7 @@ public function drugLimit(Request $request)
if
(
$drugModel
->
limit_buy_7
>
0
)
{
$drug
[
'limit_num'
]
=
$drugModel
->
limit_buy_7
;
}
$buyedCount
=
$drugCounts
[
$drug
_id
]
??
0
;
// 历史已购买数量
$buyedCount
=
$drugCounts
[
$drug
[
'drug_id'
]
]
??
0
;
// 历史已购买数量
$canBuyCount
=
$drug
[
'limit_num'
]
-
$buyedCount
;
// 普通药品剩余可购买数量
if
(
$canBuyCount
<=
0
)
{
$errMsg
=
'药品['
.
$drugModel
->
name
.
']剩余购买数量不足~'
;
...
...
app/Api/Controllers/PrescriptionController.php
View file @
2f33618e
...
...
@@ -106,8 +106,9 @@ public function create(Request $request)
$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]]
$inquirys
=
$request
->
input
(
'inquirys'
);
// [['inquiry_id'=>1, 'answer'=>1]]
$drugs
=
$request
->
input
(
'drugs'
);
// [['pharmacy_drug_id'=>2, 'num'=>1]]
$prescription_type
=
$request
->
input
(
'prescription_type'
,
0
);
$pharmacy
=
null
;
$open_source
=
0
;
// 获取当前用户信息,如果是药店则无需传pharmacy_id参数
...
...
@@ -127,6 +128,7 @@ public function create(Request $request)
// 生成处方
$prescription
=
new
PrescriptionModel
;
$prescription
->
prescription_type
=
$prescription_type
;
// 处方类型
$prescription
->
status
=
PrescriptionModel
::
PRESCRIPTION_STATUS_PENDING
;
$prescription
->
user_id
=
$authInfo
->
id
;
// 获取当前用户ID
// 问诊人信息
...
...
@@ -172,7 +174,7 @@ public function create(Request $request)
'unit'
=>
$pharmacyDrugQueryInfo
->
unit
,
'dosage_id'
=>
0
,
// $pharmacyDrugQueryInfo->dosage_id,
'dosage_desc'
=>
'等待药师录入'
,
// $pharmacyDrugQueryInfo->dosage->dosage_desc,
'num'
=>
$drug
[
'num'
],
'num'
=>
$drug
[
'num'
]
??
0
,
];
}
$prescription
->
drug_info
=
$drug_info
;
...
...
@@ -425,4 +427,66 @@ public function reject(Request $request)
return
$this
->
failed
(
'处方作废失败'
);
}
# 处方单录入
public
function
enter
(
Request
$request
)
{
$authInfo
=
auth
(
'api'
)
->
user
();
$prescription_id
=
$request
->
input
(
'prescription_id'
);
$prescription
=
PrescriptionModel
::
where
(
'id'
,
$prescription_id
)
->
first
();
if
(
!
$prescription
)
{
return
$this
->
failed
(
'处方单不存在,请传递正确的处方单编号!'
);
}
# $prescription_type = $request->input('prescription_type');
#
$drugs
=
$request
->
input
(
'drugs'
);
# 中药
if
(
$prescription
->
prescription_type
==
PrescriptionModel
::
PRESCRIPTION_TYPE_TCM
)
{
// 用药信息 中药:[['pharmacy_drug_id'=>2,'unit'=>'盒','num'=>1]]
$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
,
'spec'
=>
$pharmacyDrugQueryInfo
->
drug
->
spec
,
'unit'
=>
$pharmacyDrugQueryInfo
->
unit
,
# 'dosage_id' => 0, // $pharmacyDrugQueryInfo->dosage_id,
# 'dosage_desc' => '等待药师录入', // $pharmacyDrugQueryInfo->dosage->dosage_desc,
'num'
=>
$drug
[
'num'
],
# 中药为药师录入数量
];
}
$prescription
->
doses
=
$request
->
input
(
'doses'
);
// 剂量
$prescription
->
drug_info
=
$drug_info
;
}
else
if
(
intval
(
$prescription
->
prescription_type
)
==
PrescriptionModel
::
PRESCRIPTION_TYPE_WM
)
# 西药
{
// 用药信息 西药:[['pharmacy_drug_id'=>2,'dosage_id'=>1,'dosage_desc'=>'500ml tid po','num'=>1]]
$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
,
'spec'
=>
$pharmacyDrugQueryInfo
->
drug
->
spec
,
'unit'
=>
$pharmacyDrugQueryInfo
->
unit
,
'dosage_id'
=>
$drug
[
'dosage_id'
]
??
0
,
// $pharmacyDrugQueryInfo->dosage_id,
'dosage_desc'
=>
$drug
[
'dosage_desc'
]
??
'等待药师录入'
,
// $pharmacyDrugQueryInfo->dosage->dosage_desc,
'num'
=>
$drug
[
'num'
],
# 中药为药师录入数量
];
}
$prescription
->
doses
=
$request
->
input
(
'doses'
);
// 剂量
$prescription
->
drug_info
=
$drug_info
;
}
else
{
return
$this
->
failed
(
'暂不支持该类型处方单录入'
);
}
}
}
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