Search in sources :

Example 1 with StringAndListParam

use of ca.uhn.fhir.rest.param.StringAndListParam in project cqf-ruler by DBCG.

the class CacheValueSetsProviderIT method testCacheValueSetsAlreadyExpanded.

// Get help with this....
// @Test
// public void testCacheValueSetsExpandAndAddConcepts() throws Exception {
// Endpoint endpoint = uploadLocalServerEndpoint();
// RequestDetails details = Mockito.mock(RequestDetails.class);
// ValueSet vs =
// uploadValueSet("valueset/valueset-buprenorphine-and-methadone-medications.json");
// vs.getCompose().getInclude().forEach(include -> {
// assertTrue(!include.hasConcept());
// });
// StringAndListParam stringAndListParam =
// getStringAndListParamFromValueSet(vs);
// IGenericClient localClient = createClient(ourCtx, endpoint);
// //
// localClient.operation().onServer().named("updateCodeSystems").withNoParameters(Parameters.class).execute();
// Resource outcomeResource = cacheValueSetsProvider.cacheValuesets(details,
// endpoint.getIdElement(), stringAndListParam, null, null);
// assertTrue(outcomeResource instanceof Bundle);
// Bundle resultBundle = (Bundle) outcomeResource;
// assertTrue(resultBundle.getEntry().size() == 1);
// BundleEntryComponent entry = resultBundle.getEntry().get(0);
// assertTrue(entry.getResponse().getLocation().startsWith("ValueSet/" +
// vs.getIdElement().getIdPart()));
// assertTrue(entry.getResponse().getStatus().equals("200 OK"));
// ValueSet resultingValueSet =
// localClient.read().resource(ValueSet.class).withId(vs.getIdElement()).execute();
// resultingValueSet.getCompose().getInclude().forEach(include -> {
// assertTrue(include.hasConcept());
// });
// }
@Test
public void testCacheValueSetsAlreadyExpanded() throws Exception {
    Endpoint endpoint = uploadLocalServerEndpoint();
    RequestDetails details = Mockito.mock(RequestDetails.class);
    ValueSet vs = uploadValueSet("valueset/valueset-benzodiazepine-medications.json");
    StringAndListParam stringAndListParam = getStringAndListParamFromValueSet(vs);
    Resource outcomeResource = cacheValueSetsProvider.cacheValuesets(details, endpoint.getIdElement(), stringAndListParam, null, null);
    assertTrue(outcomeResource instanceof Bundle);
    Bundle resultBundle = (Bundle) outcomeResource;
    assertEquals(1, resultBundle.getEntry().size());
    BundleEntryComponent entry = resultBundle.getEntry().get(0);
    assertTrue(entry.getResponse().getLocation().startsWith("ValueSet/" + vs.getIdElement().getIdPart()));
    assertEquals("200 OK", entry.getResponse().getStatus());
}
Also used : BundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent) Endpoint(org.hl7.fhir.dstu3.model.Endpoint) StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) Bundle(org.hl7.fhir.dstu3.model.Bundle) Resource(org.hl7.fhir.dstu3.model.Resource) ValueSet(org.hl7.fhir.dstu3.model.ValueSet) RequestDetails(ca.uhn.fhir.rest.api.server.RequestDetails) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 2 with StringAndListParam

use of ca.uhn.fhir.rest.param.StringAndListParam in project cqf-ruler by DBCG.

the class CacheValueSetsProviderIT method testCacheValueSetsEndpointNull.

@Test
public void testCacheValueSetsEndpointNull() throws Exception {
    StringAndListParam stringAndListParam = getStringAndListParamFromValueSet("valueset/AcuteInpatient.json");
    RequestDetails details = Mockito.mock(RequestDetails.class);
    Resource outcomeResource = cacheValueSetsProvider.cacheValuesets(details, new Endpoint().getIdElement(), stringAndListParam, null, null);
    validateOutcome(outcomeResource, "Could not find Endpoint/null");
}
Also used : Endpoint(org.hl7.fhir.dstu3.model.Endpoint) StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) Resource(org.hl7.fhir.dstu3.model.Resource) RequestDetails(ca.uhn.fhir.rest.api.server.RequestDetails) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 3 with StringAndListParam

use of ca.uhn.fhir.rest.param.StringAndListParam in project cqf-ruler by DBCG.

the class CacheValueSetsProviderIT method testCacheValueSetsNoCompose.

@Test
public void testCacheValueSetsNoCompose() throws Exception {
    Endpoint endpoint = uploadLocalServerEndpoint();
    RequestDetails details = Mockito.mock(RequestDetails.class);
    ValueSet vs = uploadValueSet("valueset/valueset-benzodiazepine-medications.json");
    assertTrue(vs.getCompose().getInclude().isEmpty());
    StringAndListParam stringAndListParam = getStringAndListParamFromValueSet(vs);
    Resource outcomeResource = cacheValueSetsProvider.cacheValuesets(details, endpoint.getIdElement(), stringAndListParam, null, null);
    assertTrue(outcomeResource instanceof Bundle);
    Bundle resultBundle = (Bundle) outcomeResource;
    assertEquals(1, resultBundle.getEntry().size());
    BundleEntryComponent entry = resultBundle.getEntry().get(0);
    assertTrue(entry.getResponse().getLocation().startsWith("ValueSet/" + vs.getIdElement().getIdPart()));
    assertEquals("200 OK", entry.getResponse().getStatus());
// ValueSet resultingValueSet = createClient(ourCtx,
// endpoint).read().resource(ValueSet.class).withId(vs.getIdElement()).execute();
// resultingValueSet not returning with a version
// assertTrue(resultingValueSet.getVersion().endsWith("-cached"));
}
Also used : BundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent) Endpoint(org.hl7.fhir.dstu3.model.Endpoint) StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) Bundle(org.hl7.fhir.dstu3.model.Bundle) Resource(org.hl7.fhir.dstu3.model.Resource) ValueSet(org.hl7.fhir.dstu3.model.ValueSet) RequestDetails(ca.uhn.fhir.rest.api.server.RequestDetails) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 4 with StringAndListParam

use of ca.uhn.fhir.rest.param.StringAndListParam in project cqf-ruler by DBCG.

the class CacheValueSetsProviderIT method testCacheValueSetsAuthenticationErrorUsername.

@Test
public void testCacheValueSetsAuthenticationErrorUsername() throws Exception {
    Endpoint endpoint = uploadLocalServerEndpoint();
    StringAndListParam stringAndListParam = getStringAndListParamFromValueSet("valueset/AcuteInpatient.json");
    RequestDetails details = Mockito.mock(RequestDetails.class);
    Resource outcomeResource = cacheValueSetsProvider.cacheValuesets(details, endpoint.getIdElement(), stringAndListParam, "username", null);
    String detailMessage = "User name was provided, but not a password.";
    validateOutcome(outcomeResource, detailMessage);
}
Also used : Endpoint(org.hl7.fhir.dstu3.model.Endpoint) StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) Resource(org.hl7.fhir.dstu3.model.Resource) RequestDetails(ca.uhn.fhir.rest.api.server.RequestDetails) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 5 with StringAndListParam

use of ca.uhn.fhir.rest.param.StringAndListParam in project cqf-ruler by DBCG.

the class CacheValueSetsProviderIT method getStringAndListParamFromValueSet.

private StringAndListParam getStringAndListParamFromValueSet(ValueSet vs) throws IOException {
    StringAndListParam stringAndListParam = new StringAndListParam();
    stringAndListParam.setValuesAsQueryTokens(getFhirContext(), "valueset", Arrays.asList(QualifiedParamList.singleton(vs.getIdElement().getIdPart())));
    return stringAndListParam;
}
Also used : StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam)

Aggregations

StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)264 StringParam (ca.uhn.fhir.rest.param.StringParam)243 Test (org.junit.Test)233 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)232 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)157 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)137 StringOrListParam (ca.uhn.fhir.rest.param.StringOrListParam)110 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)91 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)37 MockIBundleProvider (org.openmrs.module.fhir2.providers.r4.MockIBundleProvider)30 Practitioner (org.hl7.fhir.r4.model.Practitioner)26 Patient (org.hl7.fhir.r4.model.Patient)21 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)21 Test (org.junit.jupiter.api.Test)20 SimpleBundleProvider (ca.uhn.fhir.rest.server.SimpleBundleProvider)18 RequestDetails (ca.uhn.fhir.rest.api.server.RequestDetails)16 RestIntegrationTest (org.opencds.cqf.ruler.test.RestIntegrationTest)16 Location (org.hl7.fhir.r4.model.Location)14 Person (org.hl7.fhir.r4.model.Person)14 SortSpec (ca.uhn.fhir.rest.api.SortSpec)13