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-7653 facilitate the measure resources in QI Core exports #22

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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>gov.cms.madie.packaging</groupId>
<artifactId>packaging-utility</artifactId>
<version>0.2.3</version>
<version>0.2.4</version>

<name>packaging-utility</name>
<description>A simple packaging-utility.</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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> 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<Library> 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());
}
Expand Down Expand Up @@ -185,4 +199,12 @@ private List<Library> getLibraryResources(Bundle measureBundle) {
.map(entry -> (Library) entry.getResource())
.toList();
}

private List<Measure> getMeasureResource(Bundle measureBundle) {
return measureBundle.getEntry().stream()
.filter(
entry -> StringUtils.equals("Measure", entry.getResource().getResourceType().name()))
.map(entry -> (Measure) entry.getResource())
.toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ void testGetZipBundleWithLibraries() throws IOException {
zipContents.get("widget.xml").startsWith("<Bundle xmlns=\"http://hl7.org/fhir\">"),
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("<Library xmlns=\"http://hl7.org/fhir\">"),
is(true));

Expand All @@ -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("<Measure xmlns=\"http://hl7.org/fhir\">"),
is(true));
}

@Test
Expand Down
Loading