Skip to content

Commit fcf4c91

Browse files
authored
eRSD Transformer Enhancements for eRSD V3 (#592)
* Updates to eRSD Transformer for manifest parameters and other V3 improvements * Updated test cases * Remove eRSDGrouperComposeFixer * Created constants for frequently-used system url
1 parent aaf9753 commit fcf4c91

11 files changed

Lines changed: 3421905 additions & 239 deletions

File tree

tooling-cli/src/main/java/org/opencds/cqf/tooling/cli/OperationFactory.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
import org.opencds.cqf.tooling.acceleratorkit.DTProcessor;
1616
import org.opencds.cqf.tooling.acceleratorkit.Processor;
1717
import org.opencds.cqf.tooling.casereporting.tes.TESPackageGenerator;
18-
import org.opencds.cqf.tooling.casereporting.transformer.ErsdTransformer;
19-
import org.opencds.cqf.tooling.dateroller.DataDateRollerOperation;
2018
import org.opencds.cqf.tooling.exception.InvalidOperationArgs;
2119
import org.opencds.cqf.tooling.exception.OperationNotFound;
2220
import org.opencds.cqf.tooling.library.r4.LibraryGenerator;

tooling/src/main/java/org/opencds/cqf/tooling/casereporting/transformer/ErsdTransformer.java

Lines changed: 315 additions & 173 deletions
Large diffs are not rendered by default.

tooling/src/main/java/org/opencds/cqf/tooling/operation/BundleToTransactionOperation.java

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
import ca.uhn.fhir.context.FhirVersionEnum;
55
import org.hl7.fhir.dstu3.model.Bundle;
66
import org.hl7.fhir.instance.model.api.IBaseResource;
7+
import org.hl7.fhir.r4.model.CanonicalType;
8+
import org.hl7.fhir.r4.model.ResourceType;
9+
import org.hl7.fhir.r4.model.ValueSet;
710
import org.opencds.cqf.tooling.Operation;
811

912
import java.io.*;
@@ -15,6 +18,7 @@ public class BundleToTransactionOperation extends Operation {
1518
private String encoding; // -encoding (-e)
1619
private String path; // -path (-p)
1720
private String version; // -version (-v) Can be dstu2, stu3, or r4
21+
private Boolean relativeRequestUrls; // -relativerequesturls (-rru_
1822

1923
private IBaseResource theResource;
2024
private List<IBaseResource> theResources = new ArrayList<>();
@@ -49,6 +53,8 @@ public void execute(String[] args) {
4953
case "version": case "v":
5054
version = value;
5155
break;
56+
case "relativerequesturls": case "rru":
57+
relativeRequestUrls = Boolean.parseBoolean(value); break; // -relativerequesturls (-rru)
5258
default: throw new IllegalArgumentException("Unknown flag: " + flag);
5359
}
5460
}
@@ -112,7 +118,32 @@ else if (context.getVersion().getVersion() == FhirVersionEnum.R4) {
112118
org.hl7.fhir.r4.model.Bundle bundle = (org.hl7.fhir.r4.model.Bundle)resource;
113119
for (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent entry : bundle.getEntry()) {
114120
if (entry.getResource() != null) {
115-
entry.setRequest(new org.hl7.fhir.r4.model.Bundle.BundleEntryRequestComponent().setUrl(entry.getResource().getId()).setMethod(org.hl7.fhir.r4.model.Bundle.HTTPVerb.PUT));
121+
if (entry.getResource().getResourceType().compareTo(ResourceType.ValueSet) == 0) {
122+
var valueSet = (org.hl7.fhir.r4.model.ValueSet)entry.getResource();
123+
ValueSet.ValueSetComposeComponent compose = valueSet.getCompose();
124+
ValueSet.ValueSetComposeComponent newCompose = new ValueSet.ValueSetComposeComponent();
125+
List<ValueSet.ConceptSetComponent> concepts = compose.getInclude();
126+
for (ValueSet.ConceptSetComponent concept : concepts) {
127+
if (concept.hasValueSet()) {
128+
List<CanonicalType> referencedValueSets = concept.getValueSet();
129+
if (referencedValueSets.size() > 1) {
130+
131+
for (CanonicalType reference : referencedValueSets) {
132+
List<CanonicalType> newInclude = new ArrayList<>();
133+
newInclude.add(reference);
134+
newCompose.addInclude(new ValueSet.ConceptSetComponent().setValueSet(newInclude));
135+
}
136+
}
137+
}
138+
}
139+
valueSet.setCompose(newCompose);
140+
}
141+
142+
entry.setRequest(
143+
new org.hl7.fhir.r4.model.Bundle.BundleEntryRequestComponent()
144+
.setUrl(entry.getResource().getResourceType() + "/" + entry.getResource().getIdPart())
145+
.setMethod(org.hl7.fhir.r4.model.Bundle.HTTPVerb.PUT)
146+
);
116147
}
117148
}
118149
bundle.setType(org.hl7.fhir.r4.model.Bundle.BundleType.TRANSACTION);

tooling/src/main/resources/eRSDv2_specification_bundle.json

Lines changed: 575072 additions & 0 deletions
Large diffs are not rendered by default.

tooling/src/test/java/org/opencds/cqf/tooling/casereporting/transformer/ErsdTransformerIT.java

Lines changed: 161 additions & 63 deletions
Large diffs are not rendered by default.

tooling/src/test/java/org/opencds/cqf/tooling/operation/BundleToTransactionOperationTest.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,39 @@ public void testExecute_BundleDecomposition() {
4545
}
4646
Assert.assertTrue(found, "Expected file not found: " + expectedFile);
4747
}
48+
49+
@Test
50+
public void testExecute_CollectionToTransaction() {
51+
String projectPath = System.getProperty("user.dir");
52+
53+
String relativeJsonPath = "src/main/resources/eRSDv2_specification_bundle.json";
54+
String jsonFilePath = projectPath + File.separator + relativeJsonPath;
55+
56+
String relativePath = "target/test-output/bundleTransactionResults";
57+
58+
String[] args = new String[4];
59+
args[0] = "-MakeTransaction";
60+
args[1] = PATH_ARGUMENT + jsonFilePath;
61+
args[2] = ENCODING_ARGUMENT + "json";
62+
args[3] = OUTPUT_PATH_ARGUMENT + projectPath + File.separator + relativePath;
63+
bundleToTransactionOperation.execute(args);
64+
65+
File resultDir = new File(projectPath + File.separator + relativePath);
66+
67+
Assert.assertTrue(resultDir.exists() && resultDir.isDirectory(), "Result directory does not exist.");
68+
69+
String expectedFile = "Bundle-rctc-release-1.2.4.0-Bundle-rctc.json";
70+
71+
File[] actualFiles = resultDir.listFiles((dir, name) -> name.endsWith(".json"));
72+
Assert.assertNotNull(actualFiles, "Bundle resource folder should not be null.");
73+
74+
boolean found = false;
75+
for (File file : actualFiles) {
76+
if (file.getName().equals(expectedFile)) {
77+
found = true;
78+
break;
79+
}
80+
}
81+
Assert.assertTrue(found, "Expected file not found: " + expectedFile);
82+
}
4883
}

0 commit comments

Comments
 (0)