Search in sources :

Example 61 with ValueSet

use of org.hl7.fhir.r4.model.ValueSet 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.r4.model.Endpoint) StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) Resource(org.hl7.fhir.r4.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 62 with ValueSet

use of org.hl7.fhir.r4.model.ValueSet 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.r4.model.Bundle.BundleEntryComponent) Endpoint(org.hl7.fhir.r4.model.Endpoint) StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) Bundle(org.hl7.fhir.r4.model.Bundle) Resource(org.hl7.fhir.r4.model.Resource) ValueSet(org.hl7.fhir.r4.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 63 with ValueSet

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

the class CodeSystemProviderIT method testR4ICD10PerformCodeSystemUpdateByList.

@Test
@Order(4)
public void testR4ICD10PerformCodeSystemUpdateByList() throws IOException {
    log.info("Beginning Test R4 SNOMED CodeSystemUpdate");
    BufferedReader reader = new BufferedReader(new InputStreamReader(CodeSystemProviderIT.class.getResourceAsStream("valueset" + "/" + "valueset-pdmp-review-procedure.json")));
    String resourceString = reader.lines().collect(Collectors.joining(System.lineSeparator()));
    reader.close();
    ValueSet vs = (ValueSet) loadResource("json", resourceString);
    assertEquals(0, performCodeSystemSearchByUrl(snomedSctUrl).size());
    codeSystemUpdateProvider.performCodeSystemUpdate(Arrays.asList(vs));
    OperationOutcome outcome = codeSystemUpdateProvider.updateCodeSystems(vs.getIdElement());
    for (OperationOutcomeIssueComponent issue : outcome.getIssue()) {
        assertEquals(OperationOutcome.IssueSeverity.INFORMATION, issue.getSeverity());
        assertTrue(issue.getDetails().getText().startsWith("Successfully updated the following CodeSystems: "));
        assertTrue(issue.getDetails().getText().contains("sct"));
    }
    assertEquals(1, performCodeSystemSearchByUrl(snomedSctUrl).size());
    log.info("Finished Test R4 SNOMED CodeSystemUpdate");
}
Also used : InputStreamReader(java.io.InputStreamReader) OperationOutcomeIssueComponent(org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent) OperationOutcome(org.hl7.fhir.r4.model.OperationOutcome) BufferedReader(java.io.BufferedReader) ValueSet(org.hl7.fhir.r4.model.ValueSet) Order(org.junit.jupiter.api.Order) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 64 with ValueSet

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

the class CodeSystemProviderIT method testR4RxNormCodeSystemUpdateById.

@Test
@Order(3)
public void testR4RxNormCodeSystemUpdateById() throws IOException {
    log.info("Beginning Test R4 LOINC CodeSystemUpdate");
    ValueSet vs = (ValueSet) loadResource("org/opencds/cqf/ruler/devtools/r4/valueset/valueset-pain-treatment-plan.json");
    assertEquals(0, performCodeSystemSearchByUrl(loincUrl).size());
    OperationOutcome outcome = codeSystemUpdateProvider.updateCodeSystems(vs.getIdElement());
    for (OperationOutcomeIssueComponent issue : outcome.getIssue()) {
        assertEquals(OperationOutcome.IssueSeverity.INFORMATION, issue.getSeverity());
        assertTrue(issue.getDetails().getText().startsWith("Successfully updated the following CodeSystems: "));
        assertTrue(issue.getDetails().getText().contains("loinc"));
    }
    assertEquals(1, performCodeSystemSearchByUrl(loincUrl).size());
    log.info("Finished Test R4 LOINC CodeSystemUpdate");
}
Also used : OperationOutcomeIssueComponent(org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent) OperationOutcome(org.hl7.fhir.r4.model.OperationOutcome) ValueSet(org.hl7.fhir.r4.model.ValueSet) Order(org.junit.jupiter.api.Order) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 65 with ValueSet

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

the class CodeSystemProviderIT method testCodeSystemUpdateValueSetDNE.

@Test
@Order(1)
public void testCodeSystemUpdateValueSetDNE() throws IOException {
    ValueSet vs = (ValueSet) readResource("org/opencds/cqf/ruler/devtools/r4/valueset/valueset-pain-treatment-plan.json");
    OperationOutcome outcome = codeSystemUpdateProvider.updateCodeSystems(vs.getIdElement());
    assertEquals(1, outcome.getIssue().size());
    OperationOutcomeIssueComponent issue = outcome.getIssue().get(0);
    assertEquals(OperationOutcome.IssueSeverity.ERROR, issue.getSeverity());
    assertTrue(issue.getDetails().getText().startsWith("Unable to find Resource: " + vs.getIdElement().getIdPart()));
}
Also used : OperationOutcomeIssueComponent(org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent) OperationOutcome(org.hl7.fhir.r4.model.OperationOutcome) ValueSet(org.hl7.fhir.r4.model.ValueSet) Order(org.junit.jupiter.api.Order) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

ValueSet (org.hl7.fhir.r5.model.ValueSet)159 ValueSet (org.hl7.fhir.r4.model.ValueSet)116 Test (org.junit.jupiter.api.Test)115 ArrayList (java.util.ArrayList)101 FHIRException (org.hl7.fhir.exceptions.FHIRException)100 IOException (java.io.IOException)97 ValueSet (org.hl7.fhir.dstu3.model.ValueSet)59 ValueSet (org.hl7.fhir.r4b.model.ValueSet)59 FileNotFoundException (java.io.FileNotFoundException)58 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)56 TerminologyServiceException (org.hl7.fhir.exceptions.TerminologyServiceException)46 HashMap (java.util.HashMap)45 Test (org.junit.Test)45 CodeSystem (org.hl7.fhir.r5.model.CodeSystem)43 File (java.io.File)36 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)36 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)31 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)29 RestIntegrationTest (org.opencds.cqf.ruler.test.RestIntegrationTest)29 FileInputStream (java.io.FileInputStream)27