diff --git a/pom.xml b/pom.xml
index aa439c5..8bb560d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
4.0.0
gov.cms.madie.packaging
packaging-utility
- 0.2.5
+ 0.2.6
packaging-utility
A simple packaging-utility.
diff --git a/src/main/java/gov/cms/madie/packaging/utils/PackagingUtility.java b/src/main/java/gov/cms/madie/packaging/utils/PackagingUtility.java
index d24d4f0..c2e5dc9 100644
--- a/src/main/java/gov/cms/madie/packaging/utils/PackagingUtility.java
+++ b/src/main/java/gov/cms/madie/packaging/utils/PackagingUtility.java
@@ -1,8 +1,13 @@
package gov.cms.madie.packaging.utils;
import gov.cms.madie.packaging.exceptions.InternalServerException;
+import org.hl7.fhir.r4.model.Bundle;
public interface PackagingUtility {
byte[] getZipBundle(Object export, String exportFileName) throws InternalServerException;
+
+ String getHumanReadableWithCSS(Bundle measureBundle);
+
+ String getHumanReadableWithCSS(String measureBundleJson);
}
diff --git a/src/main/java/gov/cms/madie/packaging/utils/qicore411/PackagingUtilityImpl.java b/src/main/java/gov/cms/madie/packaging/utils/qicore411/PackagingUtilityImpl.java
index ecaa57c..8e962cb 100644
--- a/src/main/java/gov/cms/madie/packaging/utils/qicore411/PackagingUtilityImpl.java
+++ b/src/main/java/gov/cms/madie/packaging/utils/qicore411/PackagingUtilityImpl.java
@@ -8,9 +8,7 @@
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
-import org.hl7.fhir.r4.model.Attachment;
-import org.hl7.fhir.r4.model.Bundle;
-import org.hl7.fhir.r4.model.Library;
+import org.hl7.fhir.r4.model.*;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.parser.IParser;
@@ -22,7 +20,6 @@
import gov.cms.madie.packaging.utils.ZipUtility;
import gov.cms.madie.packaging.utils.qicore.ResourceUtils;
import lombok.extern.slf4j.Slf4j;
-import org.hl7.fhir.r4.model.Measure;
@Slf4j
public class PackagingUtilityImpl implements PackagingUtility {
@@ -68,11 +65,7 @@ private byte[] getZipBundle(Bundle bundle, String exportFileName) throws Interna
if (ResourceUtils.isMeasureBundle(bundle)) {
org.hl7.fhir.r4.model.DomainResource measure =
(org.hl7.fhir.r4.model.DomainResource) ResourceUtils.getResource(bundle, "Measure");
- String humanReadable = measure.getText().getDivAsString();
-
- String template = ResourceUtils.getData("/templates/HumanReadable.liquid");
- String humanReadableWithCSS =
- template.replace("human_readable_content_holder", humanReadable);
+ String humanReadableWithCSS = getHumanReadableWithCSS(measure);
return zipEntries(exportFileName, jsonParser, xmlParser, bundle, humanReadableWithCSS);
} else if (ResourceUtils.isPatientBundle(bundle)) {
@@ -82,6 +75,47 @@ private byte[] getZipBundle(Bundle bundle, String exportFileName) throws Interna
}
}
+ /**
+ * Retrieve the Measure's Narrative text (aka the Human Readable) from the provided Bundle and
+ * wrap with CSS.
+ *
+ * @param measureBundleJson String of the Measure Bundle JSON with a Measure entry containing one
+ * Narrative.
+ * @return String representation of the Human Readable with CSS.
+ */
+ public String getHumanReadableWithCSS(String measureBundleJson) {
+ IParser jsonParser = context.newJsonParser();
+ org.hl7.fhir.r4.model.Bundle bundle =
+ (org.hl7.fhir.r4.model.Bundle) jsonParser.parseResource(measureBundleJson);
+ return getHumanReadableWithCSS(bundle);
+ }
+
+ /**
+ * Retrieve the Measure's Narrative text (aka the Human Readable) from the provided Bundle and
+ * wrap with CSS.
+ *
+ * @param measureBundle Measure Bundle with a Measure entry containing one Narrative.
+ * @return String representation of the Human Readable with CSS.
+ */
+ public String getHumanReadableWithCSS(Bundle measureBundle) {
+ if (measureBundle == null) {
+ return null;
+ }
+ if (ResourceUtils.isMeasureBundle(measureBundle)) {
+ org.hl7.fhir.r4.model.DomainResource measure =
+ (org.hl7.fhir.r4.model.DomainResource)
+ ResourceUtils.getResource(measureBundle, "Measure");
+ return getHumanReadableWithCSS(measure);
+ }
+ throw new InternalServerException("Unable to parse Measure Bundle");
+ }
+
+ private String getHumanReadableWithCSS(DomainResource measure) {
+ String humanReadableNarrative = measure.getText().getDivAsString();
+ String template = ResourceUtils.getData("/templates/HumanReadable.liquid");
+ return template.replace("human_readable_content_holder", humanReadableNarrative);
+ }
+
private byte[] getTestCaseZipBundle(Map exportBundles)
throws InternalServerException {
diff --git a/src/main/java/gov/cms/madie/packaging/utils/qicore6/PackagingUtilityImpl.java b/src/main/java/gov/cms/madie/packaging/utils/qicore6/PackagingUtilityImpl.java
index 14cb9c8..68e1254 100644
--- a/src/main/java/gov/cms/madie/packaging/utils/qicore6/PackagingUtilityImpl.java
+++ b/src/main/java/gov/cms/madie/packaging/utils/qicore6/PackagingUtilityImpl.java
@@ -1,7 +1,5 @@
package gov.cms.madie.packaging.utils.qicore6;
-/**
- * QI-Core 6.0.0 matches packaging requirements of QICore v4.1.1
- */
+/** QI-Core 6.0.0 matches packaging requirements of QICore v4.1.1 */
public class PackagingUtilityImpl
extends gov.cms.madie.packaging.utils.qicore411.PackagingUtilityImpl {}
diff --git a/src/main/resources/templates/HumanReadable.liquid b/src/main/resources/templates/HumanReadable.liquid
index d2f034c..6909a1e 100644
--- a/src/main/resources/templates/HumanReadable.liquid
+++ b/src/main/resources/templates/HumanReadable.liquid
@@ -2,337 +2,420 @@
- human_readable_content_holder
+human_readable_content_holder
\ No newline at end of file