use of org.hl7.fhir.dstu3.model.DataRequirement in project clinical_quality_language by cqframework.
the class DataRequirementsProcessorTest method TestLibraryDataRequirementsRecursive.
@Test
public void TestLibraryDataRequirementsRecursive() {
CqlTranslatorOptions cqlTranslatorOptions = new CqlTranslatorOptions();
cqlTranslatorOptions.getFormats().add(CqlTranslator.Format.JSON);
cqlTranslatorOptions.setCollapseDataRequirements(true);
try {
CqlTranslator translator = createTranslator("DataRequirements/DataRequirementsLibraryTest.cql", cqlTranslatorOptions);
translator.toELM();
assertTrue(translator.getErrors().isEmpty());
libraryManager.cacheLibrary(translator.getTranslatedLibrary());
DataRequirementsProcessor dqReqTrans = new DataRequirementsProcessor();
org.hl7.fhir.r5.model.Library moduleDefinitionLibrary = dqReqTrans.gatherDataRequirements(libraryManager, translator.getTranslatedLibrary(), cqlTranslatorOptions, null, false);
assertTrue(moduleDefinitionLibrary.getType().getCode("http://terminology.hl7.org/CodeSystem/library-type").equalsIgnoreCase("module-definition"));
DataRequirement encounterRequirement = null;
for (DataRequirement dr : moduleDefinitionLibrary.getDataRequirement()) {
if (dr.getType() == Enumerations.FHIRAllTypes.ENCOUNTER) {
encounterRequirement = dr;
break;
}
}
assertTrue(encounterRequirement != null);
FhirContext context = getFhirContext();
IParser parser = context.newJsonParser();
String moduleDefString = parser.setPrettyPrint(true).encodeResourceToString(moduleDefinitionLibrary);
logger.debug(moduleDefString);
} catch (IOException ioException) {
ioException.printStackTrace();
}
}
use of org.hl7.fhir.dstu3.model.DataRequirement in project cqf-ruler by DBCG.
the class DataOperationProviderIT method testR4LibraryEvaluationTest.
@Test
public void testR4LibraryEvaluationTest() throws IOException {
String bundleAsText = stringFromResource("bundlegen-bundle.json");
Bundle bundle = (Bundle) getFhirContext().newJsonParser().parseResource(bundleAsText);
getClient().transaction().withBundle(bundle).execute();
Parameters params = new Parameters();
params.addParameter().setName("target").setValue(new StringType("dummy"));
Library returnLibrary = getClient().operation().onInstance(new IdType("Library", "LibraryEvaluationTest")).named("$data-requirements").withParameters(params).returnResourceType(Library.class).execute();
assertNotNull(returnLibrary);
System.out.println("Resource:" + this.getFhirContext().newJsonParser().setPrettyPrint(true).encodeResourceToString(returnLibrary));
for (DataRequirement dr : returnLibrary.getDataRequirement()) {
String query = dr.getExtensionByUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-fhirQueryPattern").getValueAsPrimitive().getValueAsString();
switch(dr.getType()) {
case "Patient":
{
assertTrue("Patient?_id={{context.patientId}}".equals(query));
}
break;
case "Condition":
{
if (dr.hasCodeFilter() && dr.getCodeFilter().size() > 0) {
assertTrue("Condition?category:in=http://mcg.com/fhir/ValueSet/condition-problem-list-category&subject=Patient/{{context.patientId}}".equals(query));
} else {
assertTrue("Condition?subject=Patient/{{context.patientId}}".equals(query));
}
}
break;
case "Encounter":
{
assertTrue("Encounter?subject=Patient/{{context.patientId}}".equals(query));
}
break;
case "Procedure":
{
assertTrue("Procedure?subject=Patient/{{context.patientId}}".equals(query));
}
break;
}
}
}
use of org.hl7.fhir.dstu3.model.DataRequirement in project cqf-ruler by DBCG.
the class DataOperationProviderIT method testR4LibraryFhirQueryPattern.
@Test
public void testR4LibraryFhirQueryPattern() throws IOException {
String bundleAsText = stringFromResource("ExmLogicTransactionBundle.json");
Bundle bundle = (Bundle) getFhirContext().newJsonParser().parseResource(bundleAsText);
getClient().transaction().withBundle(bundle).execute();
Parameters params = new Parameters();
params.addParameter().setName("target").setValue(new StringType("dummy"));
Library returnLibrary = getClient().operation().onInstance(new IdType("Library", "EXMLogic")).named("$data-requirements").withParameters(params).returnResourceType(Library.class).execute();
assertNotNull(returnLibrary);
for (DataRequirement dr : returnLibrary.getDataRequirement()) {
switch(dr.getType()) {
case "Patient":
{
String query = dr.getExtensionByUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-fhirQueryPattern").getValueAsPrimitive().getValueAsString();
assertTrue("Patient?_id={{context.patientId}}".equals(query));
}
break;
case "Encounter":
{
String query = dr.getExtensionByUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-fhirQueryPattern").getValueAsPrimitive().getValueAsString();
if (dr.hasCodeFilter()) {
assertTrue("Encounter?status=finished&subject=Patient/{{context.patientId}}&type:in=http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292".equals(query));
} else {
assertTrue("Encounter?subject=Patient/{{context.patientId}}".equals(query));
}
}
break;
case "Coverage":
{
String query = dr.getExtensionByUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-fhirQueryPattern").getValueAsPrimitive().getValueAsString();
assertTrue("Coverage?policy-holder=Patient/{{context.patientId}}&type:in=http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591".equals(query));
}
break;
}
}
}
use of org.hl7.fhir.dstu3.model.DataRequirement in project cqf-ruler by DBCG.
the class DataOperationProviderIT method testR4MeasureFhirQueryPattern.
@Test
public void testR4MeasureFhirQueryPattern() throws IOException {
String bundleAsText = stringFromResource("ExmLogicMeasureTransactionBundle.json");
Bundle bundle = (Bundle) getFhirContext().newJsonParser().parseResource(bundleAsText);
getClient().transaction().withBundle(bundle).execute();
Parameters params = new Parameters();
params.addParameter().setName("startPeriod").setValue(new StringType("2019-01-01"));
params.addParameter().setName("endPeriod").setValue(new StringType("2020-01-01"));
Library returnLibrary = getClient().operation().onInstance(new IdType("Measure", "measure-exm")).named("$data-requirements").withParameters(params).returnResourceType(Library.class).execute();
assertNotNull(returnLibrary);
for (DataRequirement dr : returnLibrary.getDataRequirement()) {
switch(dr.getType()) {
case "Patient":
{
String query = dr.getExtensionByUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-fhirQueryPattern").getValueAsPrimitive().getValueAsString();
assertTrue("Patient?_id={{context.patientId}}".equals(query));
}
break;
case "Encounter":
{
String query = dr.getExtensionByUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-fhirQueryPattern").getValueAsPrimitive().getValueAsString();
if (dr.hasCodeFilter()) {
assertTrue("Encounter?status=finished&subject=Patient/{{context.patientId}}&type:in=http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292".equals(query));
} else {
assertTrue("Encounter?subject=Patient/{{context.patientId}}".equals(query));
}
}
break;
case "Coverage":
{
String query = dr.getExtensionByUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-fhirQueryPattern").getValueAsPrimitive().getValueAsString();
assertTrue("Coverage?policy-holder=Patient/{{context.patientId}}&type:in=http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591".equals(query));
}
break;
}
}
}
use of org.hl7.fhir.dstu3.model.DataRequirement in project cqf-ruler by DBCG.
the class DiscoveryResolutionR4 method getPrefetchUrlList.
public PrefetchUrlList getPrefetchUrlList(PlanDefinition planDefinition) {
PrefetchUrlList prefetchList = new PrefetchUrlList();
if (planDefinition == null)
return null;
if (!isEca(planDefinition))
return null;
Library library = resolvePrimaryLibrary(planDefinition);
// TODO: resolve data requirements
if (library == null || !library.hasDataRequirement())
return null;
for (DataRequirement dataRequirement : library.getDataRequirement()) {
List<String> requestUrls = createRequestUrl(dataRequirement);
if (requestUrls != null) {
prefetchList.addAll(requestUrls);
}
}
return prefetchList;
}
Aggregations