diff --git a/src/main/java/gov/cms/madie/util/MappingUtil.java b/src/main/java/gov/cms/madie/util/MappingUtil.java index 322cfee..cfd5195 100644 --- a/src/main/java/gov/cms/madie/util/MappingUtil.java +++ b/src/main/java/gov/cms/madie/util/MappingUtil.java @@ -3,9 +3,7 @@ import com.nimbusds.oauth2.sdk.util.CollectionUtils; import gov.cms.madie.models.measure.BaseConfigurationTypes; import gov.cms.madie.models.measure.Measure; -import gov.cms.madie.models.measure.MeasureObservation; import gov.cms.madie.models.measure.MeasureScoring; -import gov.cms.madie.models.measure.Population; import gov.cms.madie.models.measure.PopulationType; import org.apache.commons.lang3.StringUtils; @@ -46,6 +44,14 @@ public static boolean isPopulationObservation(PopulationType populationType) { || populationType == PopulationType.MEASURE_POPULATION_OBSERVATION; } + /** + * Fetch all descriptions for the given population type (observations are a valid possible input) + * Combine all descriptions for that population type with a space (not a newline) + * + * @param measure + * @param populationType + * @return + */ public static String getPopulationDescription(Measure measure, PopulationType populationType) { if (CollectionUtils.isEmpty(measure.getGroups())) { return null; @@ -64,8 +70,8 @@ public static String getPopulationDescription(Measure measure, PopulationType po .name() .equalsIgnoreCase(population.getName().name()) && StringUtils.isNotBlank(population.getDescription())) - .map(Population::getDescription) - .collect(Collectors.joining("\n")); + .map(p -> p.getDefinition().replaceAll("[\\t\\n\\r]+", " ")) + .collect(Collectors.joining(" ")); } else if (CollectionUtils.isNotEmpty(group.getMeasureObservations()) && isPopulationObservation(populationType)) { // there is only one observation description field, so grab all available @@ -75,13 +81,13 @@ && isPopulationObservation(populationType)) { observation -> StringUtils.isNotBlank(observation.getDefinition()) && StringUtils.isNotBlank(observation.getDescription())) - .map(MeasureObservation::getDescription) - .collect(Collectors.joining("\n")); + .map(mo -> mo.getDefinition().replaceAll("[\\t\\n\\r]+", " ")) + .collect(Collectors.joining(" ")); } return null; }) .filter(StringUtils::isNotBlank) - .collect(Collectors.joining("\n")); + .collect(Collectors.joining(" ")); return StringUtils.isBlank(description) ? null : description; } }