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-6307 pulled new liquid templates from latest release v0.3.0 #175

Merged
merged 3 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
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
@@ -1,6 +1,5 @@
package gov.cms.madie.madiefhirservice.services;

import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.security.Principal;

Expand Down Expand Up @@ -44,7 +43,6 @@ public byte[] createExport(Measure madieMeasure, Principal principal, String acc
throw new InternalServerException(
"Unexpected error while generating exports for measureID: " + madieMeasure.getId());
}
byte[] result = utility.getZipBundle(bundle, exportFileName);
return result;
return utility.getZipBundle(bundle, exportFileName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.springframework.web.util.HtmlUtils.htmlEscape;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
Expand Down Expand Up @@ -270,6 +271,8 @@ public String generateLibraryHumanReadable(Library library) {
var versionConvertor_40_50 = new VersionConvertor_40_50(new BaseAdvisor_40_50());
org.hl7.fhir.r5.model.Library r5Library =
(org.hl7.fhir.r5.model.Library) versionConvertor_40_50.convertResource(library);
// escape html
escapeLibrary(r5Library);
String template = getData("/templates/Library.liquid");
try {
LiquidEngine.LiquidDocument doc = liquidEngine.parse(template, "libray-hr");
Expand All @@ -281,6 +284,40 @@ public String generateLibraryHumanReadable(Library library) {
}
}

private void escapeLibrary(org.hl7.fhir.r5.model.Library r5Library) {
r5Library.setTitle(escapeStr(r5Library.getTitle()));
r5Library.setSubtitle(escapeStr(r5Library.getSubtitle()));
r5Library.setPublisher(escapeStr(r5Library.getPublisher()));
r5Library.setDescription(escapeStr(r5Library.getDescription()));
r5Library.setPurpose(escapeStr(r5Library.getPurpose()));
r5Library.setUsage(escapeStr(r5Library.getUsage()));
r5Library.setCopyright(escapeStr(r5Library.getCopyright()));

r5Library
.getRelatedArtifact()
.forEach(
relatedArtifact -> relatedArtifact.setDisplay(escapeStr(relatedArtifact.getDisplay())));
r5Library
.getDataRequirement()
.forEach(
dataRequirement ->
dataRequirement
.getCodeFilter()
.forEach(
cf ->
cf.getCode()
.forEach(
coding -> coding.setDisplay(escapeStr(coding.getDisplay())))));

r5Library.setContent(
r5Library.getContent().stream()
.filter(content -> content.getContentType().equalsIgnoreCase("text/cql"))
.map(
content ->
content.setData(escapeStr(Arrays.toString(content.getData())).getBytes()))
.collect(Collectors.toList()));
}

private Extension createEffectiveDataRequirementExtension() {
var extension = new Extension();
extension.setUrl(CqfMeasures.EFFECTIVE_DATA_REQUIREMENT_URL);
Expand Down
Loading
Loading