Search in sources :

Example 36 with Observation

use of org.hl7.fhir.r5.model.Observation in project cqf-ruler by DBCG.

the class CollectDataProviderIT method testCollectData.

@Test
public void testCollectData() {
    // Create test Measure
    String cql = CqlBuilder.newCqlLibrary("4.0.1").addExpression("Initial Population", "exists([Observation])").build();
    Library lib = Libraries.library(cql);
    Measure m = MeasureBuilder.newCohortMeasure(lib).build();
    this.update(lib);
    this.update(m);
    // Create test data
    Patient john = Patients.john_doe();
    this.create(john);
    Observation obs = newResource(Observation.class).setSubject(new Reference(john));
    this.create(obs);
    Encounter enc = newResource(Encounter.class).setSubject(new Reference(john));
    this.create(enc);
    // Submit it
    Parameters results = collectDataProvider.collectData(new SystemRequestDetails(), m.getIdElement(), "2019-01-01", "2019-12-31", Ids.simple(john), null, null);
    List<ParametersParameterComponent> resources = org.opencds.cqf.ruler.utility.r4.Parameters.getPartsByName(results, "resource");
    assertEquals(1, resources.size());
    assertEquals("Observation", resources.get(0).getResource().fhirType());
    List<ParametersParameterComponent> reports = org.opencds.cqf.ruler.utility.r4.Parameters.getPartsByName(results, "measureReport");
    assertEquals(1, reports.size());
    assertEquals("MeasureReport", reports.get(0).getResource().fhirType());
}
Also used : Parameters(org.hl7.fhir.r4.model.Parameters) SystemRequestDetails(ca.uhn.fhir.jpa.partition.SystemRequestDetails) Reference(org.hl7.fhir.r4.model.Reference) Measure(org.hl7.fhir.r4.model.Measure) Observation(org.hl7.fhir.r4.model.Observation) Patient(org.hl7.fhir.r4.model.Patient) Encounter(org.hl7.fhir.r4.model.Encounter) Library(org.hl7.fhir.r4.model.Library) ParametersParameterComponent(org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent) Test(org.junit.jupiter.api.Test) DaoIntegrationTest(org.opencds.cqf.ruler.test.DaoIntegrationTest) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 37 with Observation

use of org.hl7.fhir.r5.model.Observation 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 38 with Observation

use of org.hl7.fhir.r5.model.Observation in project cqf-ruler by DBCG.

the class CqlExecutionProviderIT method testDataBundleCqlExecutionProviderWithSubject.

@Test
public void testDataBundleCqlExecutionProviderWithSubject() throws Exception {
    Parameters params = new Parameters();
    Parameters libraryParameter = new Parameters();
    params.addParameter().setName("subject").setValue(new StringType("Patient/SimplePatient"));
    libraryParameter.addParameter().setName("url").setValue(new StringType(this.getClient().getServerBase() + "Library/SimpleDstu3Library"));
    libraryParameter.addParameter().setName("name").setValue(new StringType("SimpleDstu3Library"));
    params.addParameter().setName("library").setResource(libraryParameter);
    params.addParameter().setName("expression").setValue(new StringType("SimpleDstu3Library.\"observationRetrieve\""));
    String packagePrefix = "org/opencds/cqf/ruler/cpg/dstu3/provider/";
    loadResource(packagePrefix + "SimpleDstu3Library.json");
    loadResource(packagePrefix + "SimplePatient.json");
    Bundle data = (Bundle) loadResource(packagePrefix + "SimpleDataBundle.json");
    params.addParameter().setName("data").setResource(data);
    params.addParameter().setName("useServerData").setValue(new BooleanType(false));
    Parameters results = getClient().operation().onServer().named("$cql").withParameters(params).execute();
    assertTrue(results.getParameter().get(0).getResource() instanceof Bundle);
    assertTrue(((Bundle) results.getParameter().get(0).getResource()).getEntry().get(0).getResource() instanceof Observation);
    assertTrue(results.getParameter().get(1).getValue() instanceof StringType);
    assertTrue(((StringType) results.getParameter().get(1).getValue()).asStringValue().equals("List"));
    logger.debug("Results: ", results);
}
Also used : Parameters(org.hl7.fhir.dstu3.model.Parameters) StringType(org.hl7.fhir.dstu3.model.StringType) Bundle(org.hl7.fhir.dstu3.model.Bundle) BooleanType(org.hl7.fhir.dstu3.model.BooleanType) Observation(org.hl7.fhir.dstu3.model.Observation) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 39 with Observation

use of org.hl7.fhir.r5.model.Observation in project cqf-ruler by DBCG.

the class CqlExecutionProviderIT method testDataBundleCqlExecutionProvider.

@Test
public void testDataBundleCqlExecutionProvider() throws Exception {
    Parameters params = new Parameters();
    Parameters libraryParameter = new Parameters();
    libraryParameter.addParameter().setName("url").setValue(new StringType(this.getClient().getServerBase() + "Library/SimpleDstu3Library"));
    libraryParameter.addParameter().setName("name").setValue(new StringType("SimpleDstu3Library"));
    params.addParameter().setName("library").setResource(libraryParameter);
    params.addParameter().setName("expression").setValue(new StringType("SimpleDstu3Library.\"observationRetrieve\""));
    String packagePrefix = "org/opencds/cqf/ruler/cpg/dstu3/provider/";
    loadResource(packagePrefix + "SimpleDstu3Library.json");
    loadResource(packagePrefix + "SimplePatient.json");
    Bundle data = (Bundle) loadResource(packagePrefix + "SimpleDataBundle.json");
    params.addParameter().setName("data").setResource(data);
    params.addParameter().setName("useServerData").setValue(new BooleanType(false));
    Parameters results = getClient().operation().onServer().named("$cql").withParameters(params).execute();
    assertTrue(results.getParameter().get(0).getResource() instanceof Bundle);
    assertTrue(((Bundle) results.getParameter().get(0).getResource()).getEntry().get(0).getResource() instanceof Observation);
    assertTrue(results.getParameter().get(1).getValue() instanceof StringType);
    assertTrue(((StringType) results.getParameter().get(1).getValue()).asStringValue().equals("List"));
    logger.debug("Results: ", results);
}
Also used : Parameters(org.hl7.fhir.dstu3.model.Parameters) StringType(org.hl7.fhir.dstu3.model.StringType) Bundle(org.hl7.fhir.dstu3.model.Bundle) BooleanType(org.hl7.fhir.dstu3.model.BooleanType) Observation(org.hl7.fhir.dstu3.model.Observation) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 40 with Observation

use of org.hl7.fhir.r5.model.Observation in project BridgeServer2 by Sage-Bionetworks.

the class CRCControllerTest method makeObservation.

private String makeObservation(String json) {
    IParser parser = FHIR_CONTEXT.newJsonParser();
    Observation observation = parser.parseResource(Observation.class, json);
    return FHIR_CONTEXT.newJsonParser().encodeResourceToString(observation);
}
Also used : Observation(org.hl7.fhir.dstu3.model.Observation) IParser(ca.uhn.fhir.parser.IParser)

Aggregations

Observation (org.hl7.fhir.r4.model.Observation)237 Test (org.junit.Test)235 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)114 Test (org.junit.jupiter.api.Test)107 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)106 Observation (org.hl7.fhir.dstu3.model.Observation)94 Bundle (org.hl7.fhir.r4.model.Bundle)88 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)64 ArrayList (java.util.ArrayList)62 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)59 Resource (org.hl7.fhir.r4.model.Resource)55 Bundle (org.hl7.fhir.dstu3.model.Bundle)53 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)47 Coding (org.hl7.fhir.r4.model.Coding)46 Reference (org.hl7.fhir.r4.model.Reference)41 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)37 TokenParam (ca.uhn.fhir.rest.param.TokenParam)37 Date (java.util.Date)34 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)32 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)32