post()->goCheck('add'); $params['creator_id'] = $this->adminId; $id = PrescriptionLogic::add($params, $this->adminId); if ($id === null) { return $this->fail(PrescriptionLogic::getError()); } return $this->success('保存成功', ['id' => $id]); } /** * @notes 处方详情 */ public function detail() { $params = (new PrescriptionValidate())->get()->goCheck('detail'); $detail = PrescriptionLogic::detail((int)$params['id']); if (!$detail) { return $this->fail('处方不存在'); } return $this->data($detail); } /** * @notes 根据诊单获取处方列表 */ public function listByDiagnosis() { $diagnosisId = (int)($this->request->get('diagnosis_id') ?? 0); if (!$diagnosisId) { return $this->fail('诊单ID不能为空'); } $list = PrescriptionLogic::listByDiagnosis($diagnosisId); return $this->data($list); } /** * @notes 根据预约获取处方 */ public function getByAppointment() { $appointmentId = (int)($this->request->get('appointment_id') ?? 0); if (!$appointmentId) { return $this->fail('预约ID不能为空'); } $prescription = PrescriptionLogic::getByAppointment($appointmentId); return $this->data($prescription ?? []); } }