Search in sources :

Example 21 with DataRequirement

use of org.hl7.fhir.r5.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();
    }
}
Also used : FhirContext(ca.uhn.fhir.context.FhirContext) org.hl7.fhir.r5.model(org.hl7.fhir.r5.model) IOException(java.io.IOException) IParser(ca.uhn.fhir.parser.IParser) Test(org.testng.annotations.Test)

Example 22 with DataRequirement

use of org.hl7.fhir.r5.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;
        }
    }
}
Also used : Parameters(org.hl7.fhir.r4.model.Parameters) StringType(org.hl7.fhir.r4.model.StringType) Bundle(org.hl7.fhir.r4.model.Bundle) Library(org.hl7.fhir.r4.model.Library) DataRequirement(org.hl7.fhir.r4.model.DataRequirement) IdType(org.hl7.fhir.r4.model.IdType) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 23 with DataRequirement

use of org.hl7.fhir.r5.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;
        }
    }
}
Also used : Parameters(org.hl7.fhir.r4.model.Parameters) StringType(org.hl7.fhir.r4.model.StringType) Bundle(org.hl7.fhir.r4.model.Bundle) Library(org.hl7.fhir.r4.model.Library) DataRequirement(org.hl7.fhir.r4.model.DataRequirement) IdType(org.hl7.fhir.r4.model.IdType) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 24 with DataRequirement

use of org.hl7.fhir.r5.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;
        }
    }
}
Also used : Parameters(org.hl7.fhir.r4.model.Parameters) StringType(org.hl7.fhir.r4.model.StringType) Bundle(org.hl7.fhir.r4.model.Bundle) Library(org.hl7.fhir.r4.model.Library) DataRequirement(org.hl7.fhir.r4.model.DataRequirement) IdType(org.hl7.fhir.r4.model.IdType) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 25 with DataRequirement

use of org.hl7.fhir.r5.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;
}
Also used : Library(org.hl7.fhir.r4.model.Library) DataRequirement(org.hl7.fhir.r4.model.DataRequirement)

Aggregations

DataRequirement (org.hl7.fhir.r4.model.DataRequirement)7 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)6 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)6 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)6 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)6 FhirContext (ca.uhn.fhir.context.FhirContext)4 IParser (ca.uhn.fhir.parser.IParser)4 IOException (java.io.IOException)4 Library (org.hl7.fhir.r4.model.Library)4 org.hl7.fhir.r5.model (org.hl7.fhir.r5.model)4 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)3 Bundle (org.hl7.fhir.r4.model.Bundle)3 IdType (org.hl7.fhir.r4.model.IdType)3 Parameters (org.hl7.fhir.r4.model.Parameters)3 StringType (org.hl7.fhir.r4.model.StringType)3 Attachment (org.hl7.fhir.r4b.model.Attachment)3 ContactPoint (org.hl7.fhir.r4b.model.ContactPoint)3 Attachment (org.hl7.fhir.r5.model.Attachment)3 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)3 Test (org.junit.jupiter.api.Test)3