use of org.openmrs.module.coreapps.htmlformentry.CodedOrFreeTextAnswerListWidget in project openmrs-module-pihcore by PIH.
the class CauseOfDeathListTagHandler method getSubstitution.
@Override
protected String getSubstitution(FormEntrySession session, FormSubmissionController controllerActions, Map<String, String> parameters) throws BadFormDesignException {
Concept causeGroupConcept = HtmlFormEntryUtil.getConcept(CAUSES_OF_DEATH_CONCEPT);
List<Obs> existingObs = session.getContext().removeExistingObs(causeGroupConcept);
CodedOrFreeTextAnswerListWidget widget = new CodedOrFreeTextAnswerListWidget();
widget.setUiUtils((UiUtils) session.getAttribute("uiUtils"));
widget.setBetweenElementsCode("mirebalais.deathCertificate.due_to_or_following");
widget.setTitleCode("mirebalais.deathCertificate.cause_of_death");
widget.setPlaceholderCode("mirebalais.deathCertificate.cause_of_death_instructions");
widget.setContainerClasses("required");
if (parameters.get("locale") != null) {
widget.setLocale(parameters.get("locale"));
}
if (existingObs != null && existingObs.size() > 0) {
widget.setInitialValue(initialValue(existingObs));
}
session.getContext().registerWidget(widget);
ErrorWidget errorWidget = new ErrorWidget();
session.getContext().registerErrorWidget(widget, errorWidget);
session.getSubmissionController().addAction(new Action(widget, errorWidget, existingObs));
return widget.generateHtml(session.getContext());
}
Aggregations