Skip to content

Commit

Permalink
MAT-6434: escaping additional fields on measure for human readable
Browse files Browse the repository at this point in the history
  • Loading branch information
nmorasb committed Nov 16, 2023
1 parent b88898a commit c164749
Showing 1 changed file with 45 additions and 0 deletions.
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,25 @@ 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 +99,12 @@ 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 +132,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 Down Expand Up @@ -140,7 +167,25 @@ 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()));
}
});

// population criteria stratifications
return measure;
}

Expand Down

0 comments on commit c164749

Please sign in to comment.