Search in sources :

Example 96 with DomainResource

use of org.hl7.fhir.dstu3.model.DomainResource in project org.hl7.fhir.core by hapifhir.

the class NarrativeGeneratorTests method process.

private void process(InputStream stream) throws FileNotFoundException, IOException, XmlPullParserException, EOperationOutcome, FHIRException {
    XmlParser p = new XmlParser();
    DomainResource r = (DomainResource) p.parse(stream);
    RendererFactory.factory(r, rc).render(r);
    FileOutputStream s = new FileOutputStream(TestingUtilities.tempFile("gen", "gen.xml"));
    new XmlParser().compose(s, r, true);
    s.close();
}
Also used : XmlParser(org.hl7.fhir.r5.formats.XmlParser) DomainResource(org.hl7.fhir.r5.model.DomainResource) FileOutputStream(java.io.FileOutputStream)

Example 97 with DomainResource

use of org.hl7.fhir.dstu3.model.DomainResource in project org.hl7.fhir.core by hapifhir.

the class ResourceRoundTripTests method test.

@Test
public void test() throws IOException, FHIRException, EOperationOutcome {
    DomainResource res = (DomainResource) new XmlParser().parse(TestingUtilities.loadTestResourceStream("r5", "unicode.xml"));
    RenderingContext rc = new RenderingContext(TestingUtilities.getSharedWorkerContext(), null, null, "http://hl7.org/fhir", "", null, ResourceRendererMode.END_USER);
    RendererFactory.factory(res, rc).render(res);
    IOUtils.copy(TestingUtilities.loadTestResourceStream("r5", "unicode.xml"), new FileOutputStream(TestingUtilities.tempFile("gen", "unicode.xml")));
    new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(TestingUtilities.tempFile("gen", "unicode.out.xml")), res);
}
Also used : XmlParser(org.hl7.fhir.r5.formats.XmlParser) RenderingContext(org.hl7.fhir.r5.renderers.utils.RenderingContext) DomainResource(org.hl7.fhir.r5.model.DomainResource) FileOutputStream(java.io.FileOutputStream) Test(org.junit.jupiter.api.Test)

Example 98 with DomainResource

use of org.hl7.fhir.dstu3.model.DomainResource in project org.hl7.fhir.core by hapifhir.

the class ArgonautConverter method buildNarrative.

private void buildNarrative(DomainResource resource, Element child) {
    if (!Utilities.noString(child.getTextContent())) {
        XhtmlNode div = new XhtmlNode(NodeType.Element, "div");
        String s = child.getTextContent().trim();
        if (Utilities.noString(s))
            div.addText("No Narrative provided in the source CDA document");
        else
            div.addText(s);
        resource.setText(new Narrative().setStatus(NarrativeStatus.ADDITIONAL).setDiv(div));
    }
}
Also used : XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 99 with DomainResource

use of org.hl7.fhir.dstu3.model.DomainResource in project org.hl7.fhir.core by hapifhir.

the class CCDAConverter method addItemToList.

protected ListEntryComponent addItemToList(ListResource list, DomainResource ai) throws Exception {
    list.getContained().add(ai);
    String n = nextRef();
    ai.setId(n);
    ListEntryComponent item = new ListResource.ListEntryComponent();
    list.getEntry().add(item);
    item.setItem(Factory.makeReference("#" + n));
    return item;
}
Also used : ListEntryComponent(org.hl7.fhir.dstu3.model.ListResource.ListEntryComponent)

Example 100 with DomainResource

use of org.hl7.fhir.dstu3.model.DomainResource in project org.hl7.fhir.core by hapifhir.

the class DomainResource method copyValues.

public void copyValues(DomainResource dst) {
    super.copyValues(dst);
    dst.text = text == null ? null : text.copy();
    if (contained != null) {
        dst.contained = new ArrayList<Resource>();
        for (Resource i : contained) dst.contained.add(i.copy());
    }
    ;
    if (extension != null) {
        dst.extension = new ArrayList<Extension>();
        for (Extension i : extension) dst.extension.add(i.copy());
    }
    ;
    if (modifierExtension != null) {
        dst.modifierExtension = new ArrayList<Extension>();
        for (Extension i : modifierExtension) dst.modifierExtension.add(i.copy());
    }
    ;
}
Also used : IDomainResource(org.hl7.fhir.instance.model.api.IDomainResource)

Aggregations

XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)24 FHIRException (org.hl7.fhir.exceptions.FHIRException)22 DomainResource (org.hl7.fhir.r4.model.DomainResource)21 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)16 IOException (java.io.IOException)15 DomainResource (org.hl7.fhir.dstu3.model.DomainResource)15 FileOutputStream (java.io.FileOutputStream)12 ArrayList (java.util.ArrayList)11 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)11 Test (org.junit.jupiter.api.Test)11 Resource (org.hl7.fhir.r4.model.Resource)10 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)9 FileNotFoundException (java.io.FileNotFoundException)8 List (java.util.List)8 NotImplementedException (org.apache.commons.lang3.NotImplementedException)8 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)8 SystemRequestDetails (ca.uhn.fhir.jpa.partition.SystemRequestDetails)7 File (java.io.File)7 ElementDefn (org.hl7.fhir.definitions.model.ElementDefn)7 RestIntegrationTest (org.opencds.cqf.ruler.test.RestIntegrationTest)7