patient_logic = new PatientLogic(); } /** * 获取列表 * @return JsonResponse */ public function lists(): JsonResponse { $response = $this->patient_logic->getAllPatientLists(); return jsonResponse(Response::HTTP_OK, 'success', PatientListsResource::make($response)->toArray()); } /** * 获取详情 * @param Request $request * @param string $patient_id * @return JsonResponse * @throws GeneralException */ public function details(Request $request, string $patient_id): JsonResponse { $response = $this->patient_logic->getPatientDetails($patient_id); return jsonResponse(Response::HTTP_OK, 'success', PatientDetailsResource::make($response)->toArray()); } /** * 创建档案 * @param CreatePatientRequest $request * @return JsonResponse * @throws GeneralException */ public function create(CreatePatientRequest $request): JsonResponse { $patient_id = $this->patient_logic->createPatient($request->safe()->all()); return jsonResponse(Response::HTTP_CREATED, 'success', ['patient_id' => $patient_id]); } /** * 绑定档案 * @param BindPatientRequest $request * @return JsonResponse * @throws GeneralException */ public function bind(BindPatientRequest $request): JsonResponse { $patient_id = $this->patient_logic->bindPatient($request->safe()->all()); return jsonResponse(Response::HTTP_CREATED, 'success', ['patient_id' => $patient_id]); } /** * 设置默认状态 * @param Request $request * @param string $patient_id * @return JsonResponse * @throws GeneralException */ public function setDefault(Request $request, string $patient_id): JsonResponse { $this->patient_logic->setDefaultPatient($patient_id); return jsonResponse(Response::HTTP_OK, 'update success.'); } /** * 删除 * @param Request $request * @param string $patient_id * @return JsonResponse * @throws GeneralException */ public function delete(Request $request, string $patient_id): JsonResponse { $this->patient_logic->cancelBindPatient($patient_id); return jsonResponse(Response::HTTP_OK, 'delete success.'); } }