@Override public void handleSubmission(FormEntrySession session, HttpServletRequest submission) { Date date = null; Concept exitReasonConcept = null; Concept causeOfDeathConcept = null; String otherReason = null; if (dateWidget != null) { date = dateWidget.getValue(session.getContext(), submission); } if (reasonForExitWidget != null) { Object value = reasonForExitWidget.getValue(session.getContext(), submission); exitReasonConcept = (Concept) HtmlFormEntryUtil.convertToType(value.toString().trim(), Concept.class); } if (causeOfDeathWidget != null) { Object value = causeOfDeathWidget.getValue(session.getContext(), submission); causeOfDeathConcept = (Concept) HtmlFormEntryUtil.convertToType(value.toString().trim(), Concept.class); } if (otherReasonWidget != null) { otherReason = otherReasonWidget.getValue(session.getContext(), submission); } // only if user submits both date and reason we allow to exit from care, and this is done // to make sure a user is able to submit a form with <exitfromcare> tag, without filling that // section, however if it is filled initially, user can't resubmit after changing the date and // reason fields to null back if (date != null && exitReasonConcept != null) { session.getSubmissionActions().exitFromCare(date, exitReasonConcept, causeOfDeathConcept, otherReason); } }