Search in sources :

Example 71 with Identifier

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

the class RestFhirMeasureResolverIntegrationTest method resolve_by_identifier_without_version___returns_newest_semver.

@Test
public void resolve_by_identifier_without_version___returns_newest_semver() throws Exception {
    String measureName = "Measure1";
    Identifier identifier = mockMultipleSearchResults(measureName, "2.0.0", "1.1.0");
    Measure resolved = resolver.resolveByIdentifier(identifier.getValue(), identifier.getSystem(), null);
    assertEquals("2.0.0", resolved.getVersion());
}
Also used : Identifier(org.hl7.fhir.r4.model.Identifier) Measure(org.hl7.fhir.r4.model.Measure) Test(org.junit.Test)

Example 72 with Identifier

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

the class DefaultVT method testMeasureEvaluationByMeasureIdentifier.

// to tag a specific test to be part of DVT (deployment verification test)
@Category(DVT.class)
@Test
public /**
 * Test a successful measure evaluation using identifier and version as the lookup key
 */
void testMeasureEvaluationByMeasureIdentifier() throws Exception {
    // You want -Denabled.dark.features=all in your Liberty jvm.options
    Assume.assumeTrue(isServiceDarkFeatureEnabled(CohortEngineRestConstants.DARK_LAUNCHED_MEASURE_EVALUATION));
    final String RESOURCE = getUrlBase() + CohortServiceAPISpec.CREATE_DELETE_EVALUATION_PATH;
    FhirContext fhirContext = FhirContext.forR4();
    IParser parser = fhirContext.newJsonParser().setPrettyPrint(true);
    Library library = TestHelper.getTemplateLibrary();
    Identifier identifier = new Identifier().setValue("measure-identifier").setSystem("http://ibm.com/health/test");
    Measure measure = TestHelper.getTemplateMeasure(library);
    measure.setIdentifier(Arrays.asList(identifier));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    TestHelper.createMeasureArtifact(baos, parser, measure, library);
    // Files.write( baos.toByteArray(), new File("target/test_measure_v1_0_0.zip"));
    Map<String, Parameter> parameterOverrides = new HashMap<>();
    parameterOverrides.put("Measurement Period", new IntervalParameter(new DateParameter("2019-07-04"), true, new DateParameter("2020-07-04"), true));
    MeasureEvaluation requestData = new MeasureEvaluation();
    requestData.setDataServerConfig(dataServerConfig);
    requestData.setTerminologyServerConfig(termServerConfig);
    // This is a patient ID that is assumed to exist in the target FHIR server
    requestData.setPatientId(VALID_PATIENT_ID);
    requestData.setMeasureContext(new MeasureContext(null, parameterOverrides, new com.ibm.cohort.engine.measure.Identifier(identifier.getSystem(), identifier.getValue()), measure.getVersion()));
    requestData.setEvidenceOptions(new MeasureEvidenceOptions(false, MeasureEvidenceOptions.DefineReturnOptions.NONE));
    ObjectMapper om = new ObjectMapper();
    System.out.println(om.writeValueAsString(requestData));
    RequestSpecification request = buildBaseRequest(new Headers()).queryParam(CohortEngineRestHandler.VERSION, ServiceBuildConstants.DATE).multiPart(CohortEngineRestHandler.REQUEST_DATA_PART, requestData, "application/json").multiPart(CohortEngineRestHandler.MEASURE_PART, "test_measure_v1_0_0.zip", new ByteArrayInputStream(baos.toByteArray()));
    ValidatableResponse response = request.post(RESOURCE, getServiceVersion()).then();
    ValidatableResponse vr = runSuccessValidation(response, ContentType.JSON, HttpStatus.SC_OK);
    String expected = getJsonFromFile(ServiceAPIGlobalSpec.EXP_FOLDER_TYPE, "measure_evaluation_exp.json");
    String actual = vr.extract().asString();
    assertMeasureReportEquals(parser, expected, actual, false);
}
Also used : FhirContext(ca.uhn.fhir.context.FhirContext) ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) HashMap(java.util.HashMap) MeasureEvaluation(com.ibm.cohort.engine.api.service.model.MeasureEvaluation) PatientListMeasureEvaluation(com.ibm.cohort.engine.api.service.model.PatientListMeasureEvaluation) Headers(com.jayway.restassured.response.Headers) RequestSpecification(com.jayway.restassured.specification.RequestSpecification) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MeasureEvidenceOptions(com.ibm.cohort.engine.measure.evidence.MeasureEvidenceOptions) MeasureContext(com.ibm.cohort.engine.measure.MeasureContext) Identifier(org.hl7.fhir.r4.model.Identifier) DateParameter(com.ibm.cohort.cql.evaluation.parameters.DateParameter) ByteArrayInputStream(java.io.ByteArrayInputStream) Measure(org.hl7.fhir.r4.model.Measure) DateParameter(com.ibm.cohort.cql.evaluation.parameters.DateParameter) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) Library(org.hl7.fhir.r4.model.Library) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IParser(ca.uhn.fhir.parser.IParser) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 73 with Identifier

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

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

the class IdentifierBuilderTest method testBuilder.

@Test
public void testBuilder() {
    String system = "TEST SYSTEM";
    String code = "TEST CODE";
    String display = "TEST DISPLAY";
    String value = "TEST VALUE";
    Coding coding = new Coding(system, code, display);
    CodeableConcept type = new CodeableConcept(coding);
    Period period = new Period();
    period.setStart(new Date());
    period.setEnd(new Date());
    Reference assigner = new Reference("TEST REFERENCE");
    Identifier identifier = new IdentifierBuilder().buildUse(IdentifierUse.OFFICIAL).buildSystem(system).buildType(type).buildPeriod(period).buildValue(value).buildAssigner(assigner).build();
    assertEquals(IdentifierUse.OFFICIAL, identifier.getUse());
    assertEquals(system, identifier.getSystem());
    assertEquals(type, identifier.getType());
    assertEquals(period, identifier.getPeriod());
    assertEquals(value, identifier.getValue());
    assertEquals(assigner, identifier.getAssigner());
}
Also used : Identifier(org.hl7.fhir.r4.model.Identifier) Coding(org.hl7.fhir.r4.model.Coding) Reference(org.hl7.fhir.r4.model.Reference) Period(org.hl7.fhir.r4.model.Period) Date(java.util.Date) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.Test)

Example 75 with Identifier

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

the class IdentifierBuilderTest method testStringUse.

@Test
public void testStringUse() {
    Identifier identifier = new IdentifierBuilder().buildUse("official").build();
    assertEquals(IdentifierUse.OFFICIAL, identifier.getUse());
}
Also used : Identifier(org.hl7.fhir.r4.model.Identifier) Test(org.junit.Test)

Aggregations

Identifier (org.hl7.fhir.r4.model.Identifier)212 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)143 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)125 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)116 Test (org.junit.Test)109 Test (org.junit.jupiter.api.Test)84 ArrayList (java.util.ArrayList)67 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)66 Reference (org.hl7.fhir.r4.model.Reference)57 Identifier (org.hl7.fhir.dstu3.model.Identifier)55 Patient (org.hl7.fhir.r4.model.Patient)55 Coding (org.hl7.fhir.r4.model.Coding)49 List (java.util.List)47 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)41 Practitioner (org.hl7.fhir.r4.model.Practitioner)41 Date (java.util.Date)40 Collectors (java.util.stream.Collectors)38 Resource (org.hl7.fhir.r4.model.Resource)37 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)36 InvalidRequestException (ca.uhn.fhir.rest.server.exceptions.InvalidRequestException)34