Search in sources :

Example 26 with IdType

use of org.hl7.fhir.dstu2.model.IdType in project cqf-ruler by DBCG.

the class MeasureEvaluateProviderIT method testMeasureEvaluate.

@Test
public void testMeasureEvaluate() throws Exception {
    String bundleAsText = stringFromResource("Exm105Fhir3Measure.json");
    Bundle bundle = (Bundle) getFhirContext().newJsonParser().parseResource(bundleAsText);
    getClient().transaction().withBundle(bundle).execute();
    Parameters params = new Parameters();
    params.addParameter().setName("periodStart").setValue(new StringType("2019-01-01"));
    params.addParameter().setName("periodEnd").setValue(new StringType("2020-01-01"));
    params.addParameter().setName("reportType").setValue(new StringType("individual"));
    params.addParameter().setName("subject").setValue(new StringType("Patient/denom-EXM105-FHIR3"));
    params.addParameter().setName("lastReceivedOn").setValue(new StringType("2019-12-12"));
    MeasureReport returnMeasureReport = getClient().operation().onInstance(new IdType("Measure", "measure-EXM105-FHIR3-8.0.000")).named("$evaluate-measure").withParameters(params).returnResourceType(MeasureReport.class).execute();
    assertNotNull(returnMeasureReport);
// System.out.println("Resource:"+this.getFhirContext().newJsonParser().setPrettyPrint(true).encodeResourceToString(returnMeasureReport));
}
Also used : Parameters(org.hl7.fhir.dstu3.model.Parameters) StringType(org.hl7.fhir.dstu3.model.StringType) Bundle(org.hl7.fhir.dstu3.model.Bundle) MeasureReport(org.hl7.fhir.dstu3.model.MeasureReport) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 27 with IdType

use of org.hl7.fhir.dstu2.model.IdType in project cqf-ruler by DBCG.

the class MeasureEvaluateProviderIT method testMeasureEvaluateWithAdditionalData.

@Test
public void testMeasureEvaluateWithAdditionalData() throws Exception {
    String mainBundleAsText = stringFromResource("Exm105FhirR3MeasurePartBundle.json");
    Bundle bundle = (Bundle) getFhirContext().newJsonParser().parseResource(mainBundleAsText);
    getClient().transaction().withBundle(bundle).execute();
    String additionalBundleAsText = stringFromResource("Exm105FhirR3MeasureAdditionalData.json");
    Bundle additionalData = (Bundle) getFhirContext().newJsonParser().parseResource(additionalBundleAsText);
    Parameters params = new Parameters();
    params.addParameter().setName("periodStart").setValue(new StringType("2019-01-01"));
    params.addParameter().setName("periodEnd").setValue(new StringType("2020-01-01"));
    params.addParameter().setName("reportType").setValue(new StringType("individual"));
    params.addParameter().setName("subject").setValue(new StringType("Patient/denom-EXM105-FHIR3"));
    params.addParameter().setName("lastReceivedOn").setValue(new StringType("2019-12-12"));
    params.addParameter().setName("additionalData").setResource(additionalData);
    MeasureReport returnMeasureReport = getClient().operation().onInstance(new IdType("Measure", "measure-EXM105-FHIR3-8.0.000")).named("$evaluate-measure").withParameters(params).returnResourceType(MeasureReport.class).execute();
    assertNotNull(returnMeasureReport);
}
Also used : Parameters(org.hl7.fhir.dstu3.model.Parameters) StringType(org.hl7.fhir.dstu3.model.StringType) Bundle(org.hl7.fhir.dstu3.model.Bundle) MeasureReport(org.hl7.fhir.dstu3.model.MeasureReport) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 28 with IdType

use of org.hl7.fhir.dstu2.model.IdType in project cqf-ruler by DBCG.

the class SubmitDataProviderIT method testSubmitDataNoId.

@Test
public void testSubmitDataNoId() {
    // Create a MR and a resource
    MeasureReport mr = newResource(MeasureReport.class).setMeasure(new Reference("Measure/123"));
    Observation obs = newResource(Observation.class).setValue(new StringType("ABC"));
    // Submit it
    mySubmitDataProvider.submitData(new SystemRequestDetails(), new IdType("Measure", "123"), mr, Lists.newArrayList(obs));
    // Check if they made it to the db
    Observation savedObs = search(Observation.class, Searches.all()).single();
    assertNotNull(savedObs);
    assertEquals("ABC", savedObs.getValue().primitiveValue());
    MeasureReport savedMr = search(MeasureReport.class, Searches.all()).single();
    assertNotNull(savedMr);
    assertEquals("Measure/123", savedMr.getMeasure().getReference());
}
Also used : StringType(org.hl7.fhir.dstu3.model.StringType) SystemRequestDetails(ca.uhn.fhir.jpa.partition.SystemRequestDetails) Reference(org.hl7.fhir.dstu3.model.Reference) Observation(org.hl7.fhir.dstu3.model.Observation) MeasureReport(org.hl7.fhir.dstu3.model.MeasureReport) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.jupiter.api.Test) DaoIntegrationTest(org.opencds.cqf.ruler.test.DaoIntegrationTest) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 29 with IdType

use of org.hl7.fhir.dstu2.model.IdType in project cqf-ruler by DBCG.

the class DataOperationProviderIT method testDstu3MeasureDataRequirementsOperation.

@Disabled("Erroring because could not convert r5 Library to dstu3")
@Test
public void testDstu3MeasureDataRequirementsOperation() throws IOException {
    String bundleAsText = stringFromResource("Exm105Dstu3MeasureBundle.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-EXM105-FHIR3-8.0.000")).named("$data-requirements").withParameters(params).returnResourceType(Library.class).execute();
    assertNotNull(returnLibrary);
}
Also used : Parameters(org.hl7.fhir.dstu3.model.Parameters) StringType(org.hl7.fhir.dstu3.model.StringType) Bundle(org.hl7.fhir.dstu3.model.Bundle) Library(org.hl7.fhir.dstu3.model.Library) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest) Disabled(org.junit.jupiter.api.Disabled)

Example 30 with IdType

use of org.hl7.fhir.dstu2.model.IdType in project cqf-ruler by DBCG.

the class LibraryEvaluationProviderIT method testLibraryEvaluationValidationThrows.

@Test
public void testLibraryEvaluationValidationThrows() throws IOException {
    Parameters params = new Parameters();
    params.addParameter().setName("periodStart").setValue(new StringType("2021-01-01"));
    params.addParameter().setName("periodEnd").setValue(new StringType("2021-12-31"));
    params.addParameter().setName("patientId").setValue(null);
    params.addParameter().setName("context").setValue(new StringType("Patient"));
    String packagePrefix = "org/opencds/cqf/ruler/cpg/r4/provider/";
    loadResource(packagePrefix + "ColorectalCancerScreeningsFHIR.json");
    Library lib = getClient().read().resource(Library.class).withId("ColorectalCancerScreeningsFHIR").execute();
    assertNotNull(lib);
    assertThrows(InternalErrorException.class, () -> {
        getClient().operation().onInstance(new IdType("Library", "ColorectalCancerScreeningsFHIR")).named("$evaluate").withParameters(params).returnResourceType(Bundle.class).execute();
    });
}
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) 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)

Aggregations

IdType (org.hl7.fhir.r4.model.IdType)240 Test (org.junit.Test)240 IdType (org.hl7.fhir.dstu3.model.IdType)217 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)87 Test (org.junit.jupiter.api.Test)72 HashMap (java.util.HashMap)70 JsonObject (javax.json.JsonObject)55 Path (javax.ws.rs.Path)55 Produces (javax.ws.rs.Produces)55 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)50 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)49 Bundle (org.hl7.fhir.r4.model.Bundle)45 Date (java.util.Date)44 GET (javax.ws.rs.GET)40 ArrayList (java.util.ArrayList)38 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)36 Coding (org.hl7.fhir.r4.model.Coding)34 IBaseBundle (org.hl7.fhir.instance.model.api.IBaseBundle)33 Resource (org.hl7.fhir.r4.model.Resource)33 Provenance (org.hl7.fhir.r4.model.Provenance)32