// If the "order" attribute is passed in, limit to the specified locations in order
else if (parameters.get("order") != null) {
String[] temp = ((String) parameters.get("order")).split(",");
for (String s : temp) {
Location loc = HtmlFormEntryUtil.getLocation(s, context);
if (loc == null) {
throw new RuntimeException("Cannot find location: " + loc);
}
locations.add(loc);
}
}
// if no locations have been specified by the order attribute, use all non-retired locations
if (locations.isEmpty()) {
locations = Context.getLocationService().getAllLocations(false);
}
// Set default values
Location defaultLocation = null;
if (context.getExistingEncounter() != null) {
defaultLocation = context.getExistingEncounter().getLocation();
} else {
String defaultLocId = (String) parameters.get("default");
if (StringUtils.hasText(defaultLocId)) {