Search in sources :

Example 6 with GENERATED

use of org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.GENERATED 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 7 with GENERATED

use of org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.GENERATED 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)

Example 8 with GENERATED

use of org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.GENERATED in project openmrs-module-fhir2 by openmrs.

the class PractitionerRoleNarrativeTest method shouldGeneratePractitionerRoleNarrative.

/**
 * Check that the expected narrative is generated for some example PractitionerRole resource
 *
 * @throws IOException
 */
@Test
public void shouldGeneratePractitionerRoleNarrative() throws IOException {
    PractitionerRole given = parser.parseResource(PractitionerRole.class, getClass().getClassLoader().getResourceAsStream(EXAMPLE_RESOURCE_PATH));
    PractitionerRole result = parser.parseResource(PractitionerRole.class, parser.encodeResourceToString(given));
    assertThat(result, notNullValue());
    assertThat(result.getText(), notNullValue());
    assertThat(result.getText().getStatusAsString(), equalTo("generated"));
    assertThat(result.getText().getDivAsString(), equalTo(readNarrativeFile(EXPECTED_NARRATIVE_PATH)));
}
Also used : PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole) Test(org.junit.Test)

Example 9 with GENERATED

use of org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.GENERATED in project openmrs-module-fhir2 by openmrs.

the class RelatedPersonNarrativeTest method shouldGenerateRelatedPersonNarrative.

/**
 * Check that the expected narrative is generated for some example RelatedPerson resource
 *
 * @throws IOException
 */
@Test
public void shouldGenerateRelatedPersonNarrative() throws IOException {
    RelatedPerson given = parser.parseResource(RelatedPerson.class, getClass().getClassLoader().getResourceAsStream(EXAMPLE_RESOURCE_PATH));
    RelatedPerson result = parser.parseResource(RelatedPerson.class, parser.encodeResourceToString(given));
    assertThat(result, notNullValue());
    assertThat(result.getText(), notNullValue());
    assertThat(result.getText().getStatusAsString(), equalTo("generated"));
    assertThat(result.getText().getDivAsString(), equalTo(readNarrativeFile(EXPECTED_NARRATIVE_PATH)));
}
Also used : RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) Test(org.junit.Test)

Example 10 with GENERATED

use of org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus.GENERATED in project openmrs-module-fhir2 by openmrs.

the class ConditionNarrativeTest method shouldGenerateConditionNarrative.

/**
 * Check that the expected narrative is generated for some example Condition resource
 *
 * @throws IOException
 */
@Test
public void shouldGenerateConditionNarrative() throws IOException {
    Condition given = parser.parseResource(Condition.class, getClass().getClassLoader().getResourceAsStream(EXAMPLE_RESOURCE_PATH));
    Condition result = parser.parseResource(Condition.class, parser.encodeResourceToString(given));
    assertThat(result, notNullValue());
    assertThat(result.getText(), notNullValue());
    assertThat(result.getText().getStatusAsString(), equalTo("generated"));
    assertThat(result.getText().getDivAsString(), equalTo(readNarrativeFile(EXPECTED_NARRATIVE_PATH)));
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) Test(org.junit.Test)

Aggregations

XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)37 FHIRException (org.hl7.fhir.exceptions.FHIRException)28 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)24 IOException (java.io.IOException)22 NotImplementedException (org.apache.commons.lang3.NotImplementedException)19 Test (org.junit.Test)18 UnsupportedEncodingException (java.io.UnsupportedEncodingException)14 FileOutputStream (java.io.FileOutputStream)8 ItemComponent (org.hl7.fhir.dstu3.model.ExplanationOfBenefit.ItemComponent)8 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)8 ParseException (java.text.ParseException)7 BigDecimal (java.math.BigDecimal)6 Narrative (org.hl7.fhir.dstu3.model.Narrative)6 TerminologyServiceException (org.hl7.fhir.exceptions.TerminologyServiceException)6 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)6 XhtmlComposer (org.hl7.fhir.utilities.xhtml.XhtmlComposer)6 HashMap (java.util.HashMap)5 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)5 OutputStreamWriter (java.io.OutputStreamWriter)4 ArrayList (java.util.ArrayList)4