Search in sources :

Example 31 with Narrative

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

Example 32 with Narrative

use of org.hl7.fhir.r5.model.Narrative in project openmrs-module-fhir2 by openmrs.

the class MedicationNarrativeTest method shouldGenerateMedicationNarrative.

/**
 * Check that the expected narrative is generated for some example Medication resource
 *
 * @throws IOException
 */
@Test
public void shouldGenerateMedicationNarrative() throws IOException {
    Medication given = parser.parseResource(Medication.class, getClass().getClassLoader().getResourceAsStream(EXAMPLE_RESOURCE_PATH));
    Medication result = parser.parseResource(Medication.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 : Medication(org.hl7.fhir.r4.model.Medication) Test(org.junit.Test)

Example 33 with Narrative

use of org.hl7.fhir.r5.model.Narrative in project openmrs-module-fhir2 by openmrs.

the class MedicationRequestNarrativeTest method shouldGenerateMedicationRequestNarrative.

/**
 * Check that the expected narrative is generated for some example MedicationRequest resource
 *
 * @throws IOException
 */
@Test
public void shouldGenerateMedicationRequestNarrative() throws IOException {
    MedicationRequest given = parser.parseResource(MedicationRequest.class, getClass().getClassLoader().getResourceAsStream(EXAMPLE_RESOURCE_PATH));
    MedicationRequest result = parser.parseResource(MedicationRequest.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 : MedicationRequest(org.hl7.fhir.r4.model.MedicationRequest) Test(org.junit.Test)

Example 34 with Narrative

use of org.hl7.fhir.r5.model.Narrative in project openmrs-module-fhir2 by openmrs.

the class ObservationNarrativeTest method shouldGenerateObservationNarrative.

/**
 * Check that the expected narrative is generated for some example Observation resource
 *
 * @throws IOException
 */
@Test
public void shouldGenerateObservationNarrative() throws IOException {
    Observation given = parser.parseResource(Observation.class, getClass().getClassLoader().getResourceAsStream(EXAMPLE_RESOURCE_PATH));
    Observation result = parser.parseResource(Observation.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 : Observation(org.hl7.fhir.r4.model.Observation) Test(org.junit.Test)

Example 35 with Narrative

use of org.hl7.fhir.r5.model.Narrative in project openmrs-module-fhir2 by openmrs.

the class PersonNarrativeTest method shouldGeneratePersonNarrative.

/**
 * Check that the expected narrative is generated for some example Person resource
 *
 * @throws IOException
 */
@Test
public void shouldGeneratePersonNarrative() throws IOException {
    Person given = parser.parseResource(Person.class, getClass().getClassLoader().getResourceAsStream(EXAMPLE_RESOURCE_PATH));
    Person result = parser.parseResource(Person.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 : Person(org.hl7.fhir.r4.model.Person) Test(org.junit.Test)

Aggregations

XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)80 FHIRException (org.hl7.fhir.exceptions.FHIRException)40 IOException (java.io.IOException)34 NotImplementedException (org.apache.commons.lang3.NotImplementedException)30 UnsupportedEncodingException (java.io.UnsupportedEncodingException)27 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)23 Test (org.junit.Test)22 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)19 ArrayList (java.util.ArrayList)19 XhtmlParser (org.hl7.fhir.utilities.xhtml.XhtmlParser)17 Narrative (org.hl7.fhir.r4.model.Narrative)15 Narrative (org.hl7.fhir.r5.model.Narrative)15 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)14 XhtmlComposer (org.hl7.fhir.utilities.xhtml.XhtmlComposer)14 GET (javax.ws.rs.GET)12 Path (javax.ws.rs.Path)12 Produces (javax.ws.rs.Produces)12 IBaseOperationOutcome (org.hl7.fhir.instance.model.api.IBaseOperationOutcome)12 FileNotFoundException (java.io.FileNotFoundException)10 LinkedHashMap (java.util.LinkedHashMap)10