Search in sources :

Example 11 with OperationOutcome

use of org.hl7.fhir.r5.model.OperationOutcome 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 12 with OperationOutcome

use of org.hl7.fhir.r5.model.OperationOutcome 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 13 with OperationOutcome

use of org.hl7.fhir.r5.model.OperationOutcome 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)

Example 14 with OperationOutcome

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

the class FhirTestBase method mockNotFound.

protected void mockNotFound(String resource) {
    OperationOutcome outcome = new OperationOutcome();
    outcome.getText().setStatusAsString("generated");
    outcome.getIssueFirstRep().setSeverity(IssueSeverity.ERROR).setCode(OperationOutcome.IssueType.PROCESSING).setDiagnostics(resource);
    mockFhirResourceRetrieval(get(urlMatching(resource)), getFhirParser(), outcome, getFhirServerConfig(), 404);
}
Also used : OperationOutcome(org.hl7.fhir.r4.model.OperationOutcome)

Example 15 with OperationOutcome

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

the class CohortServiceExceptionMapperTest method testToResponseResourceNotFoundExceptionHAPIFormat.

@Test
public void testToResponseResourceNotFoundExceptionHAPIFormat() throws Exception {
    OperationOutcome outcome = new OperationOutcome();
    outcome.getText().setStatusAsString("generated");
    outcome.getIssueFirstRep().setSeverity(IssueSeverity.ERROR).setCode(OperationOutcome.IssueType.PROCESSING).setDiagnostics("Resource Patient/something is not found");
    ResourceNotFoundException ex = new ResourceNotFoundException("Error", outcome);
    ex.setResponseBody(parser.encodeResourceToString(outcome));
    Response response = new CohortServiceExceptionMapper().toResponse(ex);
    ServiceErrorList actual = (ServiceErrorList) response.getEntity();
    ServiceErrorList expected = new ServiceErrorList();
    expected.setStatusCode(400);
    expected.getErrors().add(newServiceError(404, "FHIR Resource Not Found: Error", "{\"resourceType\":\"OperationOutcome\",\"text\":{\"status\":\"generated\"},\"issue\":[{\"severity\":\"error\",\"code\":\"processing\",\"diagnostics\":\"Resource Patient/something is not found\"}]}"));
    expected.setErrorSource(ErrorSource.FHIR_SERVER);
    testErrorListEquality(expected, actual);
}
Also used : Response(javax.ws.rs.core.Response) OperationOutcome(org.hl7.fhir.r4.model.OperationOutcome) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) ServiceErrorList(com.ibm.cohort.engine.api.service.model.ServiceErrorList) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)214 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)181 OperationOutcome (org.hl7.fhir.r4.model.OperationOutcome)161 OperationOutcome (org.hl7.fhir.dstu3.model.OperationOutcome)144 Test (org.junit.jupiter.api.Test)42 BaseFhirIntegrationTest (org.openmrs.module.fhir2.BaseFhirIntegrationTest)31 IOException (java.io.IOException)26 IBaseOperationOutcome (org.hl7.fhir.instance.model.api.IBaseOperationOutcome)24 OperationOutcomeIssueComponent (org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent)23 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)22 OperationOutcome (org.hl7.fhir.r5.model.OperationOutcome)20 IdType (org.hl7.fhir.dstu3.model.IdType)17 IdType (org.hl7.fhir.r4.model.IdType)17 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)15 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)15 URISyntaxException (java.net.URISyntaxException)13 GET (javax.ws.rs.GET)12 Path (javax.ws.rs.Path)12 Produces (javax.ws.rs.Produces)12 Header (org.apache.http.Header)11