Search in sources :

Example 56 with ValueSet

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

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

the class CacheValueSetsProviderIT method testCacheValueSetsValueSetDNE.

@Test
public void testCacheValueSetsValueSetDNE() throws Exception {
    Endpoint endpoint = uploadLocalServerEndpoint();
    StringAndListParam stringAndListParam = new StringAndListParam();
    stringAndListParam.setValuesAsQueryTokens(getFhirContext(), "valueset", Arrays.asList(QualifiedParamList.singleton("dne")));
    RequestDetails details = Mockito.mock(RequestDetails.class);
    Resource outcomeResource = cacheValueSetsProvider.cacheValuesets(details, endpoint.getIdElement(), stringAndListParam, null, null);
    validateOutcome(outcomeResource, "HTTP 404 : Resource ValueSet/" + "dne" + " is not known");
}
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 58 with ValueSet

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

the class CodeSystemProviderIT method testDSTU3UpdateCodeSystems.

@Test
@Order(5)
public void testDSTU3UpdateCodeSystems() throws IOException {
    log.info("Beginning Test DSTU3 Update Code Systems");
    assertEquals(0, performCodeSystemSearchByUrl(cptUrl).size());
    File[] valuesets = new File(CodeSystemProviderIT.class.getResource("valueset").getPath()).listFiles();
    for (File file : valuesets) {
        if (file.isFile() && FilenameUtils.getExtension(file.getPath()).equals("json")) {
            BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
            String resourceString = reader.lines().collect(Collectors.joining(System.lineSeparator()));
            reader.close();
            loadResource("json", resourceString);
        } else if (file.isFile() && FilenameUtils.getExtension(file.getPath()).equals("xml")) {
            BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
            String resourceString = reader.lines().collect(Collectors.joining(System.lineSeparator()));
            reader.close();
            loadResource("xml", resourceString);
        }
    }
    OperationOutcome outcome = codeSystemUpdateProvider.updateCodeSystems();
    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("cpt"));
        assertTrue(issue.getDetails().getText().contains("icd-10"));
        assertTrue(issue.getDetails().getText().contains("sct"));
        assertTrue(issue.getDetails().getText().contains("rxnorm"));
    }
    assertEquals(1, performCodeSystemSearchByUrl(icd10).size());
    assertEquals(1, performCodeSystemSearchByUrl(rxNormUrl).size());
    assertEquals(1, performCodeSystemSearchByUrl(snomedSctUrl).size());
    assertEquals(1, performCodeSystemSearchByUrl(cptUrl).size());
    log.info("Finished Test DSTU3 Update Code Systems");
}
Also used : InputStreamReader(java.io.InputStreamReader) OperationOutcomeIssueComponent(org.hl7.fhir.dstu3.model.OperationOutcome.OperationOutcomeIssueComponent) OperationOutcome(org.hl7.fhir.dstu3.model.OperationOutcome) BufferedReader(java.io.BufferedReader) File(java.io.File) FileInputStream(java.io.FileInputStream) 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 59 with ValueSet

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

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

the class CacheValueSetsProviderIT method testCacheValueSetsEndpointDNE.

@Test
public void testCacheValueSetsEndpointDNE() throws Exception {
    Endpoint endpoint = new Endpoint();
    endpoint.setId(new IdType("localhost"));
    StringAndListParam stringAndListParam = getStringAndListParamFromValueSet("valueset/AcuteInpatient.json");
    RequestDetails details = Mockito.mock(RequestDetails.class);
    Resource outcomeResource = cacheValueSetsProvider.cacheValuesets(details, endpoint.getIdElement(), stringAndListParam, null, null);
    String detailMessage = "Could not find Endpoint/" + endpoint.getIdElement().getIdPart();
    validateOutcome(outcomeResource, detailMessage);
}
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) 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

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