Skip to content

Commit

Permalink
Merge pull request #178 from MeasureAuthoringTool/feature/MAT-6434-es…
Browse files Browse the repository at this point in the history
…cape-hr-fields

MAT-6434: escaping additional fields on measure for human readable
  • Loading branch information
nmorasb authored Nov 16, 2023
2 parents b88898a + 0865a9d commit ece5044
Showing 1 changed file with 63 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.model.Bundle;
import org.hl7.fhir.r4.model.Library;
import org.hl7.fhir.r5.model.Reference;
import org.hl7.fhir.r4.model.Resource;
import org.hl7.fhir.r5.model.Enumerations.FHIRTypes;
import org.hl7.fhir.r5.model.Expression;
Expand Down Expand Up @@ -57,6 +58,29 @@ private void escapeTopLevelProperties(org.hl7.fhir.r5.model.Measure measure) {
measure.setGuidance(escapeStr(measure.getGuidance()));
measure.setClinicalRecommendationStatement(
escapeStr(measure.getClinicalRecommendationStatement()));
measure.setRationale(escapeStr(measure.getRationale()));
measure.setSubtitle(escapeStr(measure.getSubtitle()));
measure.setRiskAdjustment(escapeStr(measure.getRiskAdjustment()));
measure.setRateAggregation(escapeStr(measure.getRateAggregation()));
measure.setClinicalRecommendationStatement(
escapeStr(measure.getClinicalRecommendationStatement()));
}

private void escapeIdentifiers(org.hl7.fhir.r5.model.Measure measure) {
if (CollectionUtils.isNotEmpty(measure.getIdentifier())) {
measure.setIdentifier(
measure.getIdentifier().stream()
.map(
identifier -> {
if (identifier.hasAssigner()) {
Reference ref = identifier.getAssigner();
ref.setDisplay(escapeStr(ref.getDisplay()));
identifier.setAssigner(ref);
}
return identifier;
})
.collect(Collectors.toList()));
}
}

private void escapeSupplementalProperties(org.hl7.fhir.r5.model.Measure measure) {
Expand All @@ -79,6 +103,15 @@ public void escapeContainedProperties(org.hl7.fhir.r5.model.Measure measure) {
contained -> {
org.hl7.fhir.r5.model.Library lib = (org.hl7.fhir.r5.model.Library) contained;
List<RelatedArtifact> relatedArtifacts = lib.getRelatedArtifact();
if (lib.hasParameter()) {
lib.setParameter(
lib.getParameter().stream()
.map(
parameterDefinition ->
parameterDefinition.setName(
escapeStr(parameterDefinition.getName())))
.collect(Collectors.toList()));
}
lib.getExtension()
.forEach(
extension -> {
Expand Down Expand Up @@ -106,6 +139,7 @@ public org.hl7.fhir.r5.model.Measure escapeMeasure(org.hl7.fhir.r5.model.Measure
escapeTopLevelProperties(measure);
escapeSupplementalProperties(measure);
escapeContainedProperties(measure);
escapeIdentifiers(measure);
// logic definitions, effective data requirements
// risk factors and supplemental data guidance
measure
Expand All @@ -125,6 +159,13 @@ public org.hl7.fhir.r5.model.Measure escapeMeasure(org.hl7.fhir.r5.model.Measure
});

// population criteria descriptions
escapePopulationCriteria(measure);

// population criteria stratifications
return measure;
}

private void escapePopulationCriteria(org.hl7.fhir.r5.model.Measure measure) {
measure
.getGroup()
.forEach(
Expand All @@ -140,8 +181,29 @@ public org.hl7.fhir.r5.model.Measure escapeMeasure(org.hl7.fhir.r5.model.Measure
Expression criteria = population.getCriteria();
criteria.setExpression(escapeStr(criteria.getExpression()));
});
if (group.hasStratifier()) {
group.setStratifier(
group.getStratifier().stream()
.map(
measureGroupStratifierComponent -> {
measureGroupStratifierComponent.setDescription(
escapeStr(measureGroupStratifierComponent.getDescription()));
log.info("escaping stratifier: {}", measureGroupStratifierComponent);
if (measureGroupStratifierComponent.hasCriteria()) {
measureGroupStratifierComponent.setCriteria(
measureGroupStratifierComponent
.getCriteria()
.setExpression(
escapeStr(
measureGroupStratifierComponent
.getCriteria()
.getExpression())));
}
return measureGroupStratifierComponent;
})
.collect(Collectors.toList()));
}
});
return measure;
}

public String generateMeasureHumanReadable(
Expand Down

0 comments on commit ece5044

Please sign in to comment.