encounterTypeErrorWidget = new ErrorWidget();
if (parameters.get("types") != null) {
List<EncounterType> encounterTypes = new ArrayList<EncounterType>();
String[] temp = ((String) parameters.get("types")).split(",");
for (String s : temp) {
EncounterType type = HtmlFormEntryUtil.getEncounterType(s);
if (type == null) {
throw new RuntimeException("Cannot find encounter type: " + s);
}
encounterTypes.add(type);
}
encounterTypeWidget.setOptions(encounterTypes);
}
// Set default values
EncounterType defaultEncounterType = null;
if (context.getExistingEncounter() != null) {
defaultEncounterType = context.getExistingEncounter().getEncounterType();
} else {
String defaultTypeId = (String) parameters.get("default");
if (StringUtils.hasText(defaultTypeId)) {