-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move some serialization-based tests out of cql-to-elm and into elm-jaxb
- Loading branch information
Showing
15 changed files
with
174 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
Src/java/cql-to-elm/src/test/java/org/cqframework/cql/cql2elm/CMS146SignatureTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package org.cqframework.cql.cql2elm; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.URL; | ||
import java.net.URLDecoder; | ||
import java.nio.charset.StandardCharsets; | ||
import org.cqframework.cql.cql2elm.CqlCompilerException.ErrorSeverity; | ||
import org.cqframework.cql.cql2elm.LibraryBuilder.SignatureLevel; | ||
import org.cqframework.cql.elm.utility.Visitors; | ||
import org.hl7.elm.r1.Element; | ||
import org.hl7.elm.r1.OperatorExpression; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
class CMS146SignatureTest { | ||
|
||
// This is a count of the number of expected | ||
// signatures for each SignatureLevel when CMS146v2_Test_CQM.cql | ||
// is compiled. | ||
private static Object[][] sigCounts() { | ||
return new Object[][] { | ||
{SignatureLevel.None, 0}, | ||
{SignatureLevel.Differing, 3}, | ||
{SignatureLevel.Overloads, 11}, | ||
{SignatureLevel.All, 34} | ||
}; | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("sigCounts") | ||
void cms146SignatureLevels(SignatureLevel signatureLevel, int expectedSignatures) throws IOException { | ||
final File cms146 = getFile("CMS146v2_Test_CQM.cql"); | ||
final ModelManager modelManager = new ModelManager(); | ||
final CqlTranslator translator = CqlTranslator.fromFile( | ||
cms146, | ||
new LibraryManager(modelManager, new CqlCompilerOptions(ErrorSeverity.Warning, signatureLevel))); | ||
|
||
var visitor = Visitors.from( | ||
(Element elm, Void context) -> { | ||
if (elm instanceof OperatorExpression fd) { | ||
return fd.getSignature().isEmpty() ? 0 : 1; | ||
} else { | ||
return 0; | ||
} | ||
}, | ||
Integer::sum); | ||
|
||
var sigCount = visitor.visitLibrary(translator.getTranslatedLibrary().getLibrary(), null); | ||
|
||
assertEquals(expectedSignatures, sigCount); | ||
} | ||
|
||
private static File getFile(String name) { | ||
final URL resource = CMS146SignatureTest.class.getResource(name); | ||
|
||
if (resource == null) { | ||
throw new IllegalArgumentException("Cannot find file with name: " + name); | ||
} | ||
|
||
return new File(URLDecoder.decode(resource.getFile(), StandardCharsets.UTF_8)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
49 changes: 49 additions & 0 deletions
49
...lm-jaxb/src/test/resources/org/cqframework/cql/elm/serializing/jaxb/CMS146v2_Test_CQM.cql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
library CMS146 version '2' | ||
|
||
using QUICK | ||
|
||
valueset "Acute Pharyngitis": '2.16.840.1.113883.3.464.1003.102.12.1011' | ||
valueset "Acute Tonsillitis": '2.16.840.1.113883.3.464.1003.102.12.1012' | ||
valueset "Ambulatory/ED Visit": '2.16.840.1.113883.3.464.1003.101.12.1061' | ||
valueset "Antibiotic Medications": '2.16.840.1.113883.3.464.1003.196.12.1001' | ||
valueset "Group A Streptococcus Test": '2.16.840.1.113883.3.464.1003.198.12.1012' | ||
|
||
parameter MeasurementPeriod default Interval[DateTime(2013, 1, 1, 0, 0, 0, 0), DateTime(2014, 1, 1, 0, 0, 0, 0)) | ||
|
||
context Patient | ||
|
||
define InDemographic: | ||
AgeInYearsAt(start of MeasurementPeriod) >= 2 and AgeInYearsAt(start of MeasurementPeriod) < 18 | ||
|
||
define Pharyngitis: | ||
[Condition: "Acute Pharyngitis"] union [Condition: "Acute Tonsillitis"] | ||
|
||
define Antibiotics: | ||
[MedicationPrescription: "Antibiotic Medications"] | ||
|
||
define TargetEncounters: | ||
[Encounter: "Ambulatory/ED Visit"] E | ||
with Pharyngitis P such that Interval[P.onsetDateTime, P.abatementDate] overlaps after E.period | ||
with Antibiotics A such that A.dateWritten 3 days or less after start of E.period | ||
where E.period during MeasurementPeriod | ||
|
||
define TargetDiagnoses: | ||
Pharyngitis P with TargetEncounters E such that Interval[P.onsetDateTime, P.abatementDate] overlaps after E.period | ||
|
||
define HasPriorAntibiotics: | ||
exists (Antibiotics A with TargetDiagnoses D such that A.dateWritten 30 days or less before D.onsetDateTime) | ||
|
||
define HasTargetEncounter: | ||
exists (TargetEncounters) | ||
|
||
define InInitialPopulation: | ||
InDemographic and HasTargetEncounter | ||
|
||
define InDenominator: | ||
true | ||
|
||
define InDenominatorExclusions: | ||
HasPriorAntibiotics | ||
|
||
define InNumerator: | ||
exists ([Observation: "Group A Streptococcus Test"] R where R.issued during MeasurementPeriod and R.valueQuantity is not null) |