Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAT-6434: escaping additional fields on measure for human readable #178

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems to be done on line 59?

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
Loading