use of org.openmrs.module.addresshierarchy.AddressField in project openmrs-module-pihcore by PIH.
the class BaseEncounterDataSetManager method addAddressColumns.
/**
* Add columns based on the configured person address, except for country
*/
protected void addAddressColumns(EncounterDataSetDefinition dsd) {
Map<String, String> nameMappings = AddressSupport.getInstance().getDefaultLayoutTemplate().getNameMappings();
List<AddressHierarchyLevel> levels = Context.getService(AddressHierarchyService.class).getAddressHierarchyLevels();
for (AddressHierarchyLevel level : levels) {
if (level == null)
continue;
AddressField addressField = level.getAddressField();
if (addressField == null)
continue;
String addressProperty = addressField.getName();
if (!"country".equals(addressProperty)) {
String addressPropertyTranslated = MessageUtil.translate(nameMappings.get(addressProperty), Locale.ENGLISH);
String columnName = addressPropertyTranslated != null ? addressPropertyTranslated.toLowerCase().replace(" ", "_") : addressProperty.toLowerCase().replace(" ", "_");
addColumn(dsd, columnName, pihPersonData.getPreferredAddress(), converters.getAddressComponent(addressProperty));
}
}
}
Aggregations