Search in sources :

Example 1 with MeasureReport

use of org.hl7.fhir.r4.model.MeasureReport in project cqf-ruler by DBCG.

the class MeasureDataProcessProviderIT method testMeasureReportExtractLineListData.

@Test
public void testMeasureReportExtractLineListData() throws IOException {
    String packagePrefix = "org/opencds/cqf/ruler/casereporting/r4/";
    loadResource(packagePrefix + "Patient-ra-patient01.json");
    loadResource(packagePrefix + "Patient-ra-patient02.json");
    loadResource(packagePrefix + "Patient-ra-patient03.json");
    loadResource(packagePrefix + "Group-ra-group00.json");
    loadResource(packagePrefix + "Group-ra-group01.json");
    loadResource(packagePrefix + "Group-ra-group02.json");
    loadResource(packagePrefix + "MeasureReport-ra-measurereport01.json");
    MeasureReport measureReport = getClient().read().resource(MeasureReport.class).withId("ra-measurereport01").execute();
    assertNotNull(measureReport);
    Parameters params = new Parameters();
    params.addParameter().setName("measureReport").setResource(measureReport);
    params.addParameter().setName("subjectList").setValue(null);
    Bundle returnBundle = getClient().operation().onType(MeasureReport.class).named("$extract-line-list-data").withParameters(params).returnResourceType(Bundle.class).execute();
    assertNotNull(returnBundle);
}
Also used : Parameters(org.hl7.fhir.r4.model.Parameters) Bundle(org.hl7.fhir.r4.model.Bundle) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 2 with MeasureReport

use of org.hl7.fhir.r4.model.MeasureReport in project cqf-ruler by DBCG.

the class SubmitDataProviderIT method testSubmitData.

@Test
public void testSubmitData() {
    // Create a MR and a resource
    MeasureReport mr = newResource(MeasureReport.class, "test-mr");
    Observation obs = newResource(Observation.class, "test-obs");
    // Submit it
    mySubmitDataProvider.submitData(new SystemRequestDetails(), new IdType("Measure", "test-m"), mr, Lists.newArrayList(obs));
    // Check if they made it to the db
    Observation savedObs = read(obs.getIdElement());
    assertNotNull(savedObs);
    MeasureReport savedMr = read(mr.getIdElement());
    assertNotNull(savedMr);
}
Also used : SystemRequestDetails(ca.uhn.fhir.jpa.partition.SystemRequestDetails) Observation(org.hl7.fhir.r4.model.Observation) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) IdType(org.hl7.fhir.r4.model.IdType) Test(org.junit.jupiter.api.Test) DaoIntegrationTest(org.opencds.cqf.ruler.test.DaoIntegrationTest) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with MeasureReport

use of org.hl7.fhir.r4.model.MeasureReport in project cqf-ruler by DBCG.

the class ReportProvider method patientReport.

private Parameters.ParametersParameterComponent patientReport(Patient thePatient, Period thePeriod, String serverBase) {
    String patientId = thePatient.getIdElement().getIdPart();
    final Map<IIdType, IAnyResource> bundleEntries = new HashMap<>();
    bundleEntries.put(thePatient.getIdElement(), thePatient);
    ReferenceParam subjectParam = new ReferenceParam(patientId);
    search(MeasureReport.class, Searches.byParam("subject", subjectParam)).getAllResourcesTyped().forEach(measureReport -> {
        if (measureReport.getPeriod().getEnd().before(thePeriod.getStart()) || measureReport.getPeriod().getStart().after(thePeriod.getEnd())) {
            return;
        }
        bundleEntries.putIfAbsent(measureReport.getIdElement(), measureReport);
        getEvaluatedResources(measureReport).values().forEach(resource -> bundleEntries.putIfAbsent(resource.getIdElement(), resource));
    });
    Bundle patientReportBundle = new Bundle();
    patientReportBundle.setMeta(new Meta().addProfile(PATIENT_REPORT_PROFILE_URL));
    patientReportBundle.setType(Bundle.BundleType.COLLECTION);
    patientReportBundle.setTimestamp(new Date());
    patientReportBundle.setId(patientId + "-report");
    patientReportBundle.setIdentifier(new Identifier().setSystem("urn:ietf:rfc:3986").setValue("urn:uuid:" + UUID.randomUUID().toString()));
    bundleEntries.entrySet().forEach(resource -> patientReportBundle.addEntry(new Bundle.BundleEntryComponent().setResource((Resource) resource.getValue()).setFullUrl(Operations.getFullUrl(serverBase, resource.getValue().fhirType(), resource.getValue().getIdElement().getIdPart()))));
    Parameters.ParametersParameterComponent patientParameter = new Parameters.ParametersParameterComponent();
    patientParameter.setResource(patientReportBundle);
    patientParameter.setId(thePatient.getIdElement().getIdPart() + "-report");
    patientParameter.setName("return");
    return patientParameter;
}
Also used : Meta(org.hl7.fhir.r4.model.Meta) Parameters(org.hl7.fhir.r4.model.Parameters) HashMap(java.util.HashMap) Bundle(org.hl7.fhir.r4.model.Bundle) IAnyResource(org.hl7.fhir.instance.model.api.IAnyResource) Resource(org.hl7.fhir.r4.model.Resource) ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) Date(java.util.Date) Identifier(org.hl7.fhir.r4.model.Identifier) IAnyResource(org.hl7.fhir.instance.model.api.IAnyResource) IIdType(org.hl7.fhir.instance.model.api.IIdType)

Example 4 with MeasureReport

use of org.hl7.fhir.r4.model.MeasureReport 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 5 with MeasureReport

use of org.hl7.fhir.r4.model.MeasureReport in project cqf-ruler by DBCG.

the class MeasureEvaluateProviderIT method testMeasureEvaluate.

@Test
public void testMeasureEvaluate() throws Exception {
    String bundleAsText = stringFromResource("Exm104FhirR4MeasureBundle.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/numer-EXM104"));
    params.addParameter().setName("lastReceivedOn").setValue(new StringType("2019-12-12"));
    MeasureReport returnMeasureReport = getClient().operation().onInstance(new IdType("Measure", "measure-EXM104-8.2.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.r4.model.Parameters) StringType(org.hl7.fhir.r4.model.StringType) Bundle(org.hl7.fhir.r4.model.Bundle) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) 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

MeasureReport (org.hl7.fhir.r4.model.MeasureReport)51 Test (org.junit.Test)35 Measure (org.hl7.fhir.r4.model.Measure)31 Patient (org.hl7.fhir.r4.model.Patient)29 Library (org.hl7.fhir.r4.model.Library)23 HashMap (java.util.HashMap)19 CapabilityStatement (org.hl7.fhir.r4.model.CapabilityStatement)18 Extension (org.hl7.fhir.r4.model.Extension)17 MeasureEvidenceOptions (com.ibm.cohort.engine.measure.evidence.MeasureEvidenceOptions)16 StringType (org.hl7.fhir.r4.model.StringType)16 Test (org.junit.jupiter.api.Test)16 ArrayList (java.util.ArrayList)15 Map (java.util.Map)13 Bundle (org.hl7.fhir.r4.model.Bundle)13 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)13 BooleanType (org.hl7.fhir.r4.model.BooleanType)10 CanonicalType (org.hl7.fhir.r4.model.CanonicalType)10 MeasurePopulationType (org.opencds.cqf.common.evaluation.MeasurePopulationType)10 BooleanParameter (com.ibm.cohort.cql.evaluation.parameters.BooleanParameter)9 CodeParameter (com.ibm.cohort.cql.evaluation.parameters.CodeParameter)9