class ClientMedicationsController {

    @DeleteMapping("/clients/{uid}/medications/{id}")
    public ResponseEntity deleteMedication(
            @PathVariable int uid,
            @PathVariable int id,
            @RequestHeader(value = "X-Auth-Token", required = false) String authToken)
            throws AuthenticationException {

        Optional<Client> client = State.getClientManager().getClientByID(uid);

        if (!client.isPresent()) {
            return new ResponseEntity<>(HttpStatus.NOT_FOUND);
        }

        // Check authentication
        State.getAuthenticationManager().verifyClinicianOrAdmin(authToken);

        MedicationRecord record = client.get().getMedicationRecord(id);

        if (record == null) {
            return new ResponseEntity<>(HttpStatus.NOT_FOUND);

        } else {
            DeleteMedicationRecordAction action = new DeleteMedicationRecordAction(client.get(), record, State
                    .getClientManager());
            State.getActionInvoker(authToken).execute(action);

            Client client1 = State.getClientManager()
                    .getClientByID(client.get().getUid())
                    .orElseThrow(IllegalStateException::new);

            HttpHeaders httpHeaders = new HttpHeaders();

            return new ResponseEntity<>(httpHeaders, HttpStatus.OK);
        }
    }

}