Search in sources :

Example 76 with Measure

use of org.hl7.fhir.r5.model.Measure in project quality-measure-and-cohort-service by Alvearie.

the class MeasureEvaluator method evaluatePatientMeasures.

/**
 * Evaluates measures for a given patient
 *
 * @param patientId Patient id to evaluate measures for
 * @param measureContexts Measure info with parameters
 * @param evidenceOptions Evidence options impacting the returned MeasureReports
 * @return List of Measure Reports
 */
public List<MeasureReport> evaluatePatientMeasures(String patientId, List<MeasureContext> measureContexts, MeasureEvidenceOptions evidenceOptions) {
    List<MeasureReport> measureReports = new ArrayList<>();
    MeasureReport measureReport;
    for (MeasureContext measureContext : measureContexts) {
        measureReport = evaluatePatientMeasure(patientId, measureContext, evidenceOptions);
        measureReports.add(measureReport);
    }
    return measureReports;
}
Also used : ArrayList(java.util.ArrayList) MeasureReport(org.hl7.fhir.r4.model.MeasureReport)

Example 77 with Measure

use of org.hl7.fhir.r5.model.Measure in project quality-measure-and-cohort-service by Alvearie.

the class FHIRRestUtilsTest method testGetParametersForMeasureIdentifier.

/**
 * Test the successful building of a response.
 */
@Test
public void testGetParametersForMeasureIdentifier() {
    String idValue = "idValue";
    String idSystem = "idSystem";
    Identifier identifier = new Identifier().setValue(idValue).setSystem(idSystem);
    String version = "1.0.0";
    FhirResourceResolver<Measure> measureResolver = Mockito.mock(FhirResourceResolver.class);
    Mockito.when(measureResolver.resolveByIdentifier(idValue, idSystem, version)).thenReturn(createMeasure(testMeasureDef));
    List<MeasureParameterInfo> parameterInfoList = FHIRRestUtils.getParametersForMeasureIdentifier(measureResolver, identifier, version);
    MeasureParameterInfo expectedParamInfo = new MeasureParameterInfo();
    expectedParamInfo.setname("aName");
    expectedParamInfo.setUse("In");
    expectedParamInfo.setMax("1");
    expectedParamInfo.setMin(0);
    expectedParamInfo.setType("String");
    expectedParamInfo.setDocumentation(null);
    expectedParamInfo.defaultValue("42");
    assertThat(parameterInfoList, containsInAnyOrder(expectedParamInfo));
}
Also used : MeasureParameterInfo(com.ibm.cohort.engine.api.service.model.MeasureParameterInfo) Identifier(org.hl7.fhir.r4.model.Identifier) Measure(org.hl7.fhir.r4.model.Measure) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 78 with Measure

use of org.hl7.fhir.r5.model.Measure in project quality-measure-and-cohort-service by Alvearie.

the class FHIRRestUtilsTest method testGetParametersWithDefaultsForMeasureId.

@Test
public void testGetParametersWithDefaultsForMeasureId() {
    String measureId = "measureId";
    FhirResourceResolver<Measure> measureResolver = Mockito.mock(FhirResourceResolver.class);
    Mockito.when(measureResolver.resolveById(measureId)).thenReturn(createMeasure(testMeasureDef));
    List<MeasureParameterInfo> parameterInfoList = FHIRRestUtils.getParametersForMeasureId(measureResolver, measureId);
    MeasureParameterInfo expectedParamInfo = new MeasureParameterInfo();
    expectedParamInfo.setname("aName");
    expectedParamInfo.setUse("In");
    expectedParamInfo.setMax("1");
    expectedParamInfo.setMin(0);
    expectedParamInfo.setType("String");
    expectedParamInfo.setDocumentation(null);
    expectedParamInfo.defaultValue("42");
    assertThat(parameterInfoList, containsInAnyOrder(expectedParamInfo));
}
Also used : MeasureParameterInfo(com.ibm.cohort.engine.api.service.model.MeasureParameterInfo) Measure(org.hl7.fhir.r4.model.Measure) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 79 with Measure

use of org.hl7.fhir.r5.model.Measure in project quality-measure-and-cohort-service by Alvearie.

the class MeasureReportBuilderTest method testBuilder.

@Test
public void testBuilder() {
    String measureRef = "MEASURE REF";
    String patientRef = "PATIENT REF";
    MeasureReportStatus status = MeasureReportStatus.ERROR;
    MeasureReportType type = MeasureReportType.INDIVIDUAL;
    Date startDate = new Date();
    Date endDate = new Date();
    Interval interval = new Interval(DateTime.fromJavaDate(startDate), true, DateTime.fromJavaDate(endDate), true);
    MeasureReport report = new MeasureReportBuilder().buildMeasureReference(measureRef).buildPatientReference(patientRef).buildPeriod(interval).buildStatus(status.toCode()).buildType(type).build();
    assertEquals(measureRef, report.getMeasure());
    assertEquals(patientRef, report.getSubject().getReference());
    assertEquals(startDate, report.getPeriod().getStart());
    assertEquals(endDate, report.getPeriod().getEnd());
    assertEquals(status, report.getStatus());
    assertEquals(type, report.getType());
    TimeZone timeZoneUTC = TimeZone.getTimeZone("UTC");
    assertEquals(timeZoneUTC, report.getPeriod().getStartElement().getTimeZone());
    assertEquals(timeZoneUTC, report.getPeriod().getEndElement().getTimeZone());
}
Also used : TimeZone(java.util.TimeZone) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) MeasureReportStatus(org.hl7.fhir.r4.model.MeasureReport.MeasureReportStatus) MeasureReportType(org.hl7.fhir.r4.model.MeasureReport.MeasureReportType) Date(java.util.Date) Interval(org.opencds.cqf.cql.engine.runtime.Interval) Test(org.junit.Test)

Example 80 with Measure

use of org.hl7.fhir.r5.model.Measure in project quality-measure-and-cohort-service by Alvearie.

the class R4FhirBundleExtractorTest method extractAll.

@Test
public void extractAll() {
    String firstVersion = "1.0.0";
    String secondVersion = "2.0.0";
    String thirdVersion = "3.0.0";
    String fourthVersion = "4.0.0";
    Library library1 = new Library().setVersion(firstVersion);
    Library library2 = new Library().setVersion(secondVersion);
    Measure measure = new Measure().setVersion(thirdVersion);
    Library library3 = new Library().setVersion(fourthVersion);
    Bundle bundle = new Bundle();
    addToBundle(library1, bundle);
    addToBundle(library2, bundle);
    addToBundle(measure, bundle);
    addToBundle(library3, bundle);
    R4FhirBundleExtractor<Library> extractor = getExtractor();
    List<Library> libraries = extractor.extractAll(bundle);
    List<String> actual = libraries.stream().map(Library::getVersion).collect(Collectors.toList());
    List<String> expected = Arrays.asList(firstVersion, secondVersion, fourthVersion);
    Assert.assertEquals(expected, actual);
}
Also used : Bundle(org.hl7.fhir.r4.model.Bundle) Measure(org.hl7.fhir.r4.model.Measure) Library(org.hl7.fhir.r4.model.Library) Test(org.junit.Test)

Aggregations

Measure (org.hl7.fhir.r4.model.Measure)119 Test (org.junit.Test)97 Library (org.hl7.fhir.r4.model.Library)61 Patient (org.hl7.fhir.r4.model.Patient)45 MeasureReport (org.hl7.fhir.r4.model.MeasureReport)44 HashMap (java.util.HashMap)24 ArrayList (java.util.ArrayList)23 DateParameter (com.ibm.cohort.cql.evaluation.parameters.DateParameter)22 IntervalParameter (com.ibm.cohort.cql.evaluation.parameters.IntervalParameter)22 Parameter (com.ibm.cohort.cql.evaluation.parameters.Parameter)22 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)21 ByteArrayOutputStream (java.io.ByteArrayOutputStream)21 MeasureEvidenceOptions (com.ibm.cohort.engine.measure.evidence.MeasureEvidenceOptions)20 CapabilityStatement (org.hl7.fhir.r4.model.CapabilityStatement)20 Test (org.junit.jupiter.api.Test)18 Extension (org.hl7.fhir.r4.model.Extension)15 StringType (org.hl7.fhir.r4.model.StringType)15 DatetimeParameter (com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter)14 CanonicalType (org.hl7.fhir.r4.model.CanonicalType)14 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)14