Skip to content

Commit 6467ad5

Browse files
committed
Merge master updates (#588, #592)
1 parent c65d3c5 commit 6467ad5

24 files changed

Lines changed: 6527849 additions & 172 deletions

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

Lines changed: 215 additions & 117 deletions
Large diffs are not rendered by default.

tooling-casereporting/src/main/resources/eRSDv2_specification_bundle.json

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

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

Lines changed: 66 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
package org.opencds.cqf.tooling.casereporting.transformer;
22

3-
import static org.testng.Assert.assertEquals;
4-
import static org.testng.Assert.assertNotNull;
3+
import static org.testng.Assert.*;
54

65
import ca.uhn.fhir.context.FhirContext;
76
import ca.uhn.fhir.parser.JsonParser;
87
import ca.uhn.fhir.parser.XmlParser;
98
import java.io.File;
109
import java.io.FileInputStream;
1110
import java.util.HashSet;
12-
import java.util.List;
13-
import org.hl7.fhir.r4.model.Bundle;
14-
import org.hl7.fhir.r4.model.Library;
15-
import org.hl7.fhir.r4.model.UsageContext;
16-
import org.hl7.fhir.r4.model.ValueSet;
11+
import org.hl7.fhir.r4.model.*;
1712
import org.opencds.cqf.tooling.parameter.TransformErsdParameters;
1813
import org.opencds.cqf.tooling.utilities.IOUtils;
1914
import org.slf4j.Logger;
@@ -188,6 +183,7 @@ public void testErsdTransformerEmergentPriorityUseContextPreserved() throws Exce
188183
Bundle outputBundle = transformBundle(params, outputBundleFileName);
189184

190185
assertNotNull(outputBundle);
186+
191187
ValueSet dxtcValueSet = (ValueSet) outputBundle.getEntry().stream()
192188
.filter(x -> x.hasResource()
193189
&& x.getResource().fhirType().equals("ValueSet")
@@ -198,18 +194,49 @@ public void testErsdTransformerEmergentPriorityUseContextPreserved() throws Exce
198194

199195
assertNotNull(dxtcValueSet);
200196

201-
List<UsageContext> usageContexts = dxtcValueSet.getUseContext();
202-
UsageContext usageContext = usageContexts.stream()
203-
.filter(x -> x.hasCode()
204-
&& x.getCode().getCode().equals("priority")
205-
&& x.hasValueCodeableConcept()
206-
&& x.getValueCodeableConcept()
207-
.getCodingFirstRep()
208-
.getCode()
209-
.equals("emergent"))
197+
// ValueSet should no longer contain the priority useContext
198+
boolean valueSetHasPriority = dxtcValueSet.getUseContext().stream()
199+
.anyMatch(x -> x.hasCode() && "priority".equals(x.getCode().getCode()));
200+
201+
assertFalse(valueSetHasPriority);
202+
203+
// Find the CRMI manifest Library
204+
Library manifestLibrary = (Library) outputBundle.getEntry().stream()
205+
.filter(x -> x.hasResource()
206+
&& x.getResource().fhirType().equals("Library")
207+
&& ((Library) x.getResource()).getMeta().getProfile().stream()
208+
.anyMatch(p -> p.getValue().contains("crmi-manifestlibrary")))
209+
.findFirst()
210+
.get()
211+
.getResource();
212+
213+
assertNotNull(manifestLibrary);
214+
215+
// Find relatedArtifact referencing the DXTC ValueSet
216+
RelatedArtifact relatedArtifact = manifestLibrary.getRelatedArtifact().stream()
217+
.filter(ra -> ra.getType() == RelatedArtifact.RelatedArtifactType.DEPENDSON
218+
&& ra.hasResource()
219+
&& ra.getResource().equals("http://hl7.org/fhir/us/ecr/ValueSet/dxtc"))
210220
.findFirst()
211-
.get();
212-
assertNotNull(usageContext);
221+
.orElse(null);
222+
223+
assertNotNull(relatedArtifact);
224+
225+
// Verify priority=emergent usageContext exists as CRMI extension
226+
boolean priorityFound = relatedArtifact.getExtension().stream()
227+
.filter(ext -> ext.getUrl()
228+
.equals("http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-intendedUsageContext"))
229+
.filter(ext -> ext.getValue() instanceof UsageContext)
230+
.map(ext -> (UsageContext) ext.getValue())
231+
.anyMatch(uc -> uc.hasCode()
232+
&& "priority".equals(uc.getCode().getCode())
233+
&& uc.hasValueCodeableConcept()
234+
&& "emergent"
235+
.equals(uc.getValueCodeableConcept()
236+
.getCodingFirstRep()
237+
.getCode()));
238+
239+
assertTrue(priorityFound);
213240

214241
logger.info("Transform");
215242
}
@@ -226,41 +253,35 @@ public void testErsdTransformerManifestElementPresence() throws Exception {
226253
Bundle outputBundle = transformBundle(params, outputBundleFileName);
227254

228255
assertNotNull(outputBundle);
229-
Library manifestLibrary;
230-
manifestLibrary = (Library) outputBundle.getEntry().stream()
256+
257+
Library manifestLibrary = (Library) outputBundle.getEntry().stream()
231258
.filter(x -> x.hasResource()
232259
&& x.getResource().fhirType().equals("Library")
233-
&& x.getResource().getId().equals("Library/ersd-specification-library"))
260+
&& ((Library) x.getResource())
261+
.getUrl()
262+
.equals("http://ersd.aimsplatform.org/fhir/Library/ersd-specification"))
234263
.findFirst()
235264
.get()
236265
.getResource();
237266

238267
assertNotNull(manifestLibrary);
239268

240-
List<UsageContext> useContexts = manifestLibrary.getUseContext();
241-
UsageContext reportingUseContext = useContexts.stream()
242-
.filter(x -> x.hasCode()
243-
&& x.getCode().getCode().equals("reporting")
244-
&& x.hasValueCodeableConcept()
245-
&& x.getValueCodeableConcept()
246-
.getCodingFirstRep()
247-
.getCode()
248-
.equals("triggering"))
249-
.findFirst()
250-
.get();
251-
assertNotNull(reportingUseContext);
252-
253-
UsageContext specificationTypeUseContext = useContexts.stream()
254-
.filter(x -> x.hasCode()
255-
&& x.getCode().getCode().equals("reporting")
256-
&& x.hasValueCodeableConcept()
257-
&& x.getValueCodeableConcept()
258-
.getCodingFirstRep()
259-
.getCode()
260-
.equals("triggering"))
261-
.findFirst()
262-
.get();
263-
assertNotNull(specificationTypeUseContext);
269+
// Verify at least one relatedArtifact contains reporting=triggering as CRMI intendedUsageContext
270+
boolean reportingFound = manifestLibrary.getRelatedArtifact().stream()
271+
.flatMap(ra -> ra.hasExtension() ? ra.getExtension().stream() : java.util.stream.Stream.empty())
272+
.filter(ext -> ext.getUrl()
273+
.equals("http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-intendedUsageContext"))
274+
.filter(ext -> ext.getValue() instanceof UsageContext)
275+
.map(ext -> (UsageContext) ext.getValue())
276+
.anyMatch(uc -> uc.hasCode()
277+
&& "reporting".equals(uc.getCode().getCode())
278+
&& uc.hasValueCodeableConcept()
279+
&& "triggering"
280+
.equals(uc.getValueCodeableConcept()
281+
.getCodingFirstRep()
282+
.getCode()));
283+
284+
assertTrue(reportingFound);
264285

265286
assertNotNull(manifestLibrary.getDate());
266287
assertNotNull(manifestLibrary.getEffectivePeriod());

tooling-casereporting/src/test/resources/casereporting/ersdutils/20240202-eRSD-for-import.json

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

0 commit comments

Comments
 (0)