Skip to content

Commit

Permalink
MAT-6631: combine population descriptions with spaces; remove any new…
Browse files Browse the repository at this point in the history
… lines from descriptions
  • Loading branch information
nmorasb committed Mar 5, 2024
1 parent 777f375 commit e252364
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/main/java/gov/cms/madie/util/MappingUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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;
}
}

0 comments on commit e252364

Please sign in to comment.