diff --git a/pom.xml b/pom.xml
index e8932da..91d1ed3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
4.0.0
gov.cms.madie.packaging
packaging-utility
- 0.2.3
+ 0.2.4
packaging-utility
A simple packaging-utility.
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 085315e..5feea7a 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
@@ -21,6 +21,7 @@
import gov.cms.madie.packaging.utils.PackagingUtility;
import gov.cms.madie.packaging.utils.ZipUtility;
import lombok.extern.slf4j.Slf4j;
+import org.hl7.fhir.r4.model.Measure;
@Slf4j
public class PackagingUtilityImpl implements PackagingUtility {
@@ -138,12 +139,25 @@ private byte[] zipEntries(
CQL_DIRECTORY + library.getCqlLibraryName() + "-" + library.getVersion() + ".cql";
entries.put(filePath, library.getCql().getBytes());
}
+
+ // add Measure Resource to Export
+ List measure = getMeasureResource(bundle);
+ for (Measure measure1 : measure) {
+ String json = jsonParser.setPrettyPrint(true).encodeResourceToString(measure1);
+ String xml = xmlParser.setPrettyPrint(true).encodeResourceToString(measure1);
+ String fileName =
+ RESOURCES_DIRECTORY + "measure-" + measure1.getName() + "-" + measure1.getVersion();
+ entries.put(fileName + ".json", json.getBytes());
+ entries.put(fileName + ".xml", xml.getBytes());
+ }
+
// add Library Resources to Export
List libraries = getLibraryResources(bundle);
for (Library library1 : libraries) {
String json = jsonParser.setPrettyPrint(true).encodeResourceToString(library1);
String xml = xmlParser.setPrettyPrint(true).encodeResourceToString(library1);
- String fileName = RESOURCES_DIRECTORY + library1.getName() + "-" + library1.getVersion();
+ String fileName =
+ RESOURCES_DIRECTORY + "library-" + library1.getName() + "-" + library1.getVersion();
entries.put(fileName + ".json", json.getBytes());
entries.put(fileName + ".xml", xml.getBytes());
}
@@ -185,4 +199,12 @@ private List getLibraryResources(Bundle measureBundle) {
.map(entry -> (Library) entry.getResource())
.toList();
}
+
+ private List getMeasureResource(Bundle measureBundle) {
+ return measureBundle.getEntry().stream()
+ .filter(
+ entry -> StringUtils.equals("Measure", entry.getResource().getResourceType().name()))
+ .map(entry -> (Measure) entry.getResource())
+ .toList();
+ }
}
diff --git a/src/test/java/gov/cms/madie/measure/utilities/qicore411/PackagingUtilityImplTest.java b/src/test/java/gov/cms/madie/measure/utilities/qicore411/PackagingUtilityImplTest.java
index c0b3fb6..152b030 100644
--- a/src/test/java/gov/cms/madie/measure/utilities/qicore411/PackagingUtilityImplTest.java
+++ b/src/test/java/gov/cms/madie/measure/utilities/qicore411/PackagingUtilityImplTest.java
@@ -79,10 +79,10 @@ void testGetZipBundleWithLibraries() throws IOException {
zipContents.get("widget.xml").startsWith(""),
is(true));
- assertThat(zipContents.containsKey("TestCreateNewLibrary-1.0.000.xml"), is(true));
+ assertThat(zipContents.containsKey("library-TestCreateNewLibrary-1.0.000.xml"), is(true));
assertThat(
zipContents
- .get("TestCreateNewLibrary-1.0.000.xml")
+ .get("library-TestCreateNewLibrary-1.0.000.xml")
.startsWith(""),
is(true));
@@ -100,12 +100,26 @@ void testGetZipBundleWithLibraries() throws IOException {
.startsWith("library TestCreateNewLibrary version '1.0.000'"),
is(true));
- assertThat(zipContents.containsKey("TestCreateNewLibrary-1.0.000.json"), is(true));
+ assertThat(zipContents.containsKey("library-TestCreateNewLibrary-1.0.000.json"), is(true));
assertThat(
zipContents
- .get("TestCreateNewLibrary-1.0.000.json")
+ .get("library-TestCreateNewLibrary-1.0.000.json")
.startsWith("{\n \"resourceType\": \"Library\","),
is(true));
+
+ assertThat(zipContents.containsKey("measure-TestCreateNewLibrary-1.0.000.json"), is(true));
+ assertThat(
+ zipContents
+ .get("measure-TestCreateNewLibrary-1.0.000.json")
+ .startsWith("{\n \"resourceType\": \"Measure\","),
+ is(true));
+
+ assertThat(zipContents.containsKey("measure-TestCreateNewLibrary-1.0.000.xml"), is(true));
+ assertThat(
+ zipContents
+ .get("measure-TestCreateNewLibrary-1.0.000.xml")
+ .startsWith(""),
+ is(true));
}
@Test