Skip to content

Commit

Permalink
Merge pull request #23 from MeasureAuthoringTool/develop
Browse files Browse the repository at this point in the history
Release 0.2.4
  • Loading branch information
sb-prateekkeerthi committed Sep 3, 2024
2 parents 93a83fd + 59c4389 commit 5201f7c
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 28 deletions.
40 changes: 25 additions & 15 deletions 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 All @@ -18,7 +18,7 @@
<maven.compiler.target>17</maven.compiler.target>
<junit-jupiter.version>5.9.3</junit-jupiter.version>
<slf4j.version>2.0.7</slf4j.version>
<hapi.fhir.r4.version>6.4.1</hapi.fhir.r4.version>
<hapi.fhir.r4.version>6.6.1</hapi.fhir.r4.version>
<slf4j.version>2.0.7</slf4j.version>
</properties>

Expand Down Expand Up @@ -154,30 +154,40 @@
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<plugin>
<groupId>com.spotify.fmt</groupId>
<artifactId>fmt-maven-plugin</artifactId>
<version>2.23</version>
<executions>
<execution>
<goals>
<goal>format</goal>
</goals>
</execution>
</executions>
<configuration>
<skipSortingImports>true</skipSortingImports>
<style>google</style>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.theoryinpractise</groupId>
<artifactId>googleformatter-maven-plugin</artifactId>
<version>1.7.3</version>
<groupId>com.spotify.fmt</groupId>
<artifactId>fmt-maven-plugin</artifactId>
<version>2.21.1</version>
<executions>
<execution>
<id>reformat-sources</id>
<phase>process-sources</phase>
<goals>
<goal>format</goal>
</goals>
<configuration>
<includeStale>false</includeStale>
<style>GOOGLE</style>
<filterModified>false</filterModified>
<skip>false</skip>
<fixImports>false</fixImports>
<maxLineLength>100</maxLineLength>
</configuration>
</execution>
</executions>
<configuration>
<skipSortingImports>true</skipSortingImports>
<style>google</style>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
public class PackagingUtilityFactory {

public static PackagingUtility getInstance(String model)
throws InstantiationException, IllegalAccessException, IllegalArgumentException,
InvocationTargetException, NoSuchMethodException, SecurityException,
throws InstantiationException,
IllegalAccessException,
IllegalArgumentException,
InvocationTargetException,
NoSuchMethodException,
SecurityException,
ClassNotFoundException {
Map<String, String> modelMap =
new HashMap<>() {
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 Expand Up @@ -153,9 +167,9 @@ void testGetZipBundleForMultipleTestCases() throws IOException {
String testCaseBundleJson1 = getStringFromTestResource("/testCaseBundle.json");
String testCaseBundleJson2 = getStringFromTestResource("/testCaseBundle.json");
Bundle testCaseBundle1 =
FhirContext.forR4().newJsonParser().parseResource(Bundle.class, testCaseBundleJson1);
FhirContext.forR4().newJsonParser().parseResource(Bundle.class, testCaseBundleJson1);
Bundle testCaseBundle2 =
FhirContext.forR4().newJsonParser().parseResource(Bundle.class, testCaseBundleJson2);
FhirContext.forR4().newJsonParser().parseResource(Bundle.class, testCaseBundleJson2);
Map<String, Bundle> multiTestCases = new HashMap<>();
multiTestCases.put("TC1", testCaseBundle1);
multiTestCases.put("TC2", testCaseBundle2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

import org.junit.jupiter.api.Test;

import gov.cms.madie.packaging.utils.PackagingUtility;
import gov.cms.madie.packaging.utils.PackagingUtilityFactory;

class ResourceUtilityFactoryTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.MockedStatic;
import org.mockito.Mockito;

import java.util.Map;
Expand Down

0 comments on commit 5201f7c

Please sign in to comment.