Search in sources :

Example 1 with AddressField

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));
        }
    }
}
Also used : AddressField(org.openmrs.module.addresshierarchy.AddressField) AddressHierarchyLevel(org.openmrs.module.addresshierarchy.AddressHierarchyLevel) AddressHierarchyService(org.openmrs.module.addresshierarchy.service.AddressHierarchyService)

Aggregations

AddressField (org.openmrs.module.addresshierarchy.AddressField)1 AddressHierarchyLevel (org.openmrs.module.addresshierarchy.AddressHierarchyLevel)1 AddressHierarchyService (org.openmrs.module.addresshierarchy.service.AddressHierarchyService)1