[R8] Delete patient in patient controller

This commit is contained in:
Mirna Gama 2024-01-10 16:56:53 -03:00 committed by Mirna Gama
parent d8704c1fcf
commit f4794bf08d

View File

@ -7,6 +7,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault; import org.springframework.data.web.PageableDefault;
import org.springframework.http.ResponseEntity; 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.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -108,4 +109,18 @@ public class PatientController {
return ResponseEntity.ok(patient); 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<Object> deletePatient(@PathVariable Long id) {
Patient patient = patientService.deactivatePatient(id);
return ResponseEntity.ok(patient);
}
} }