diff --git a/app/Controller/PatientPathographyController.php b/app/Controller/PatientPathographyController.php index 64e1496..100a0b0 100644 --- a/app/Controller/PatientPathographyController.php +++ b/app/Controller/PatientPathographyController.php @@ -69,4 +69,15 @@ class PatientPathographyController extends AbstractController $data = $PatientPathographyService->getFamilyPathographyGroup(); return $this->response->json($data); } + + /** + * 删除家庭成员病情记录 + * @return ResponseInterface + */ + public function deleteFamilyPathography(): ResponseInterface + { + $PatientPathographyService = new PatientPathographyService(); + $data = $PatientPathographyService->deleteFamilyPathography(); + return $this->response->json($data); + } } \ No newline at end of file diff --git a/app/Services/PatientPathographyService.php b/app/Services/PatientPathographyService.php index 3b825de..684f1ac 100644 --- a/app/Services/PatientPathographyService.php +++ b/app/Services/PatientPathographyService.php @@ -192,4 +192,40 @@ class PatientPathographyService extends BaseService return success($patient_pathographys->toArray()); } + + /** + * 删除家庭成员病情记录 + * @return array + */ + public function deleteFamilyPathography(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + $pathography_id = $this->request->route('pathography_id'); + + // 获取病情记录 + $params = array(); + $params['user_id'] = $user_info['user_id']; + $params['patient_id'] = $user_info['client_user_id']; + $params['pathography_id'] = $pathography_id; + $patient_pathography = PatientPathography::getOne($params); + if (empty($patient_pathography)){ + return fail(HttpEnumCode::HTTP_ERROR,"无该病例"); + } + + if ($patient_pathography['status'] == 2){ + return success(); + } + + $params = array(); + $params['pathography_id'] = $patient_pathography['pathography_id']; + + $data = array(); + $data['status'] = 2; + $res = PatientPathography::edit($params,$data); + if (!$res){ + return fail(); + } + + return success(); + } } \ No newline at end of file diff --git a/config/routes.php b/config/routes.php index c0dfe18..7024eac 100644 --- a/config/routes.php +++ b/config/routes.php @@ -502,6 +502,9 @@ Router::addGroup('/patient', function () { // 获取家庭成员病情记录分组 Router::get('/group', [PatientPathographyController::class, 'getFamilyPathographyGroup']); + + // 删除家庭成员病情记录 + Router::delete('/{pathography_id:\d+}', [PatientPathographyController::class, 'deleteFamilyPathography']); }); });