From f4794bf08d837ca7bd80af256dad4f48b0457575 Mon Sep 17 00:00:00 2001 From: Mirna Gama Date: Wed, 10 Jan 2024 16:56:53 -0300 Subject: [PATCH] [R8] Delete patient in patient controller --- .../controllers/PatientController.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/com/mirna/hospitalmanagementapi/application/controllers/PatientController.java b/src/main/java/com/mirna/hospitalmanagementapi/application/controllers/PatientController.java index 30fdfdc..914e310 100644 --- a/src/main/java/com/mirna/hospitalmanagementapi/application/controllers/PatientController.java +++ b/src/main/java/com/mirna/hospitalmanagementapi/application/controllers/PatientController.java @@ -7,6 +7,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.web.PageableDefault; import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -108,4 +109,18 @@ public class PatientController { return ResponseEntity.ok(patient); } + + /** + * Delete method to deactivate an existing patient record by provided ID + * + * @param id Path variable that represents the patient's unique identifier + * + * @return A response entity containing the deactivated patient if successful + */ + @DeleteMapping("/{id}") + public ResponseEntity deletePatient(@PathVariable Long id) { + Patient patient = patientService.deactivatePatient(id); + + return ResponseEntity.ok(patient); + } }