新增
This commit is contained in:
@@ -6,6 +6,7 @@ namespace app\adminapi\logic\tcm;
|
||||
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\tcm\Prescription;
|
||||
use app\common\model\tcm\PrescriptionOrder;
|
||||
use app\common\model\tcm\Diagnosis;
|
||||
use app\common\service\wechat\WechatWorkAppMessageService;
|
||||
use think\facade\Config;
|
||||
@@ -82,6 +83,11 @@ class PrescriptionLogic
|
||||
return true;
|
||||
}
|
||||
|
||||
$assistantId = is_array($row) ? (int) ($row['assistant_id'] ?? 0) : (int) ($row->assistant_id ?? 0);
|
||||
if ($assistantId > 0 && $assistantId === $adminId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$isShared = is_array($row) ? (int) ($row['is_shared'] ?? 0) : (int) $row->is_shared;
|
||||
if ($isShared === 1) {
|
||||
return true;
|
||||
@@ -187,6 +193,12 @@ class PrescriptionLogic
|
||||
$sn = self::generateSn();
|
||||
}
|
||||
|
||||
$assistantIdForRx = 0;
|
||||
if ($diagnosisIdRule > 0) {
|
||||
$diagAssistant = Diagnosis::where('id', $diagnosisIdRule)->value('assistant_id');
|
||||
$assistantIdForRx = (int) ($diagAssistant ?? 0);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'sn' => $sn,
|
||||
'prescription_name' => $params['prescription_name'] ?? '',
|
||||
@@ -228,11 +240,13 @@ class PrescriptionLogic
|
||||
'audit_by_name' => '',
|
||||
'audit_remark' => '',
|
||||
'creator_id' => $adminId,
|
||||
'assistant_id' => $assistantIdForRx,
|
||||
];
|
||||
|
||||
$prescription = new Prescription();
|
||||
$prescription->save($data);
|
||||
return (int)$prescription->id;
|
||||
|
||||
return (int) $prescription->id;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -247,10 +261,13 @@ class PrescriptionLogic
|
||||
return false;
|
||||
}
|
||||
|
||||
// 已通过且未作废:不可编辑(与消费者端仅「查看」一致)
|
||||
// 已通过且未作废:不可编辑;例外:业务订单「处方审核」已驳回时允许医生改方,保存后业务订单侧审核会重置为待审
|
||||
if ((int) ($prescription->audit_status ?? 1) === 1 && (int) ($prescription->void_status ?? 0) === 0) {
|
||||
self::setError('该处方已通过审核,不可编辑');
|
||||
return false;
|
||||
if (!PrescriptionOrderLogic::allowDoctorEditApprovedPrescriptionDueToBusinessReject((int) $params['id'])) {
|
||||
self::setError('该处方已通过审核,不可编辑');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 已驳回:仅当该诊单+当天+同一创建人下没有另一条「已通过且未作废」的处方时允许重新编辑(改后待审核、作废一并清除)
|
||||
@@ -300,8 +317,17 @@ class PrescriptionLogic
|
||||
|
||||
$wasVoid = (int) ($prescription->void_status ?? 0) === 1;
|
||||
|
||||
$assistantIdForRx = (int) ($prescription->assistant_id ?? 0);
|
||||
if ($newDiagnosisId > 0) {
|
||||
$diagAssistant = Diagnosis::where('id', $newDiagnosisId)->value('assistant_id');
|
||||
$assistantIdForRx = (int) ($diagAssistant ?? 0);
|
||||
} else {
|
||||
$assistantIdForRx = 0;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'diagnosis_id' => $newDiagnosisId,
|
||||
'assistant_id' => $assistantIdForRx,
|
||||
'prescription_name' => $params['prescription_name'] ?? $prescription->prescription_name,
|
||||
'prescription_type' => $params['prescription_type'] ?? $prescription->prescription_type,
|
||||
'patient_name' => $params['patient_name'] ?? $prescription->patient_name,
|
||||
@@ -344,6 +370,8 @@ class PrescriptionLogic
|
||||
}
|
||||
|
||||
$prescription->save($data);
|
||||
PrescriptionOrderLogic::onConsumerPrescriptionSaved((int) $params['id']);
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
@@ -395,6 +423,15 @@ class PrescriptionLogic
|
||||
$arr['gender_desc'] = $arr['gender'] == 1 ? '男' : '女';
|
||||
$arr['visible_role_ids'] = self::visibleRoleIdsToArray($arr['visible_role_ids'] ?? '');
|
||||
|
||||
$bizPo = PrescriptionOrder::where('prescription_id', $id)
|
||||
->where('prescription_audit_status', 2)
|
||||
->whereNull('delete_time')
|
||||
->where('fulfillment_status', '<>', 4)
|
||||
->order('id', 'desc')
|
||||
->find();
|
||||
$arr['business_prescription_audit_rejected'] = $bizPo ? 1 : 0;
|
||||
$arr['business_prescription_audit_remark'] = $bizPo ? (string) ($bizPo->prescription_audit_remark ?? '') : '';
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user