Search in sources :

Example 6 with LiquidDocument

use of org.hl7.fhir.r4b.utils.LiquidEngine.LiquidDocument in project org.hl7.fhir.core by hapifhir.

the class ComparisonRenderer method processTemplate.

private String processTemplate(String template, String name, Map<String, Base> vars) {
    LiquidEngine engine = new LiquidEngine(contextRight, this);
    LiquidDocument doc = engine.parse(template, name + ".template");
    return engine.evaluate(doc, Tuple.fromMap(vars), vars);
}
Also used : LiquidDocument(org.hl7.fhir.r5.utils.LiquidEngine.LiquidDocument) LiquidEngine(org.hl7.fhir.r5.utils.LiquidEngine)

Example 7 with LiquidDocument

use of org.hl7.fhir.r4b.utils.LiquidEngine.LiquidDocument in project org.hl7.fhir.core by hapifhir.

the class ComparisonRenderer method processTemplate.

private String processTemplate(String template, String name, Map<String, Base> vars) {
    LiquidEngine engine = new LiquidEngine(contextRight, this);
    LiquidDocument doc = engine.parse(template, name + ".template");
    return engine.evaluate(doc, Tuple.fromMap(vars), vars);
}
Also used : LiquidDocument(org.hl7.fhir.r4b.utils.LiquidEngine.LiquidDocument) LiquidEngine(org.hl7.fhir.r4b.utils.LiquidEngine)

Example 8 with LiquidDocument

use of org.hl7.fhir.r4b.utils.LiquidEngine.LiquidDocument in project org.hl7.fhir.core by hapifhir.

the class LiquidRenderer method render.

@Override
public boolean render(XhtmlNode x, ResourceWrapper r) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome {
    LiquidEngine engine = new LiquidEngine(context.getWorker(), context.getServices());
    XhtmlNode xn;
    try {
        LiquidDocument doc = engine.parse(liquidTemplate, "template");
        String html = engine.evaluate(doc, r.getBase(), rcontext);
        xn = new XhtmlParser().parseFragment(html);
        if (!x.getName().equals("div"))
            throw new FHIRException("Error in template: Root element is not 'div'");
    } catch (FHIRException | IOException e) {
        xn = new XhtmlNode(NodeType.Element, "div");
        xn.para().b().style("color: maroon").tx("Exception generating Narrative: " + e.getMessage());
    }
    x.getChildNodes().addAll(xn.getChildNodes());
    return true;
}
Also used : LiquidDocument(org.hl7.fhir.r5.utils.LiquidEngine.LiquidDocument) XhtmlParser(org.hl7.fhir.utilities.xhtml.XhtmlParser) IOException(java.io.IOException) LiquidEngine(org.hl7.fhir.r5.utils.LiquidEngine) FHIRException(org.hl7.fhir.exceptions.FHIRException) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 9 with LiquidDocument

use of org.hl7.fhir.r4b.utils.LiquidEngine.LiquidDocument in project org.hl7.fhir.core by hapifhir.

the class LiquidRenderer method render.

@Override
public boolean render(XhtmlNode x, ResourceWrapper r) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome {
    LiquidEngine engine = new LiquidEngine(context.getWorker(), context.getServices());
    XhtmlNode xn;
    try {
        LiquidDocument doc = engine.parse(liquidTemplate, "template");
        String html = engine.evaluate(doc, r.getBase(), rcontext);
        xn = new XhtmlParser().parseFragment(html);
        if (!x.getName().equals("div"))
            throw new FHIRException("Error in template: Root element is not 'div'");
    } catch (FHIRException | IOException e) {
        xn = new XhtmlNode(NodeType.Element, "div");
        xn.para().b().style("color: maroon").tx("Exception generating Narrative: " + e.getMessage());
    }
    x.getChildNodes().addAll(xn.getChildNodes());
    return true;
}
Also used : LiquidDocument(org.hl7.fhir.r4b.utils.LiquidEngine.LiquidDocument) XhtmlParser(org.hl7.fhir.utilities.xhtml.XhtmlParser) IOException(java.io.IOException) LiquidEngine(org.hl7.fhir.r4b.utils.LiquidEngine) FHIRException(org.hl7.fhir.exceptions.FHIRException) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 10 with LiquidDocument

use of org.hl7.fhir.r4b.utils.LiquidEngine.LiquidDocument in project org.hl7.fhir.core by hapifhir.

the class LiquidRenderer method render.

@Override
public boolean render(XhtmlNode x, Resource r) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome {
    LiquidEngine engine = new LiquidEngine(context.getWorker(), context.getServices());
    XhtmlNode xn;
    try {
        LiquidDocument doc = engine.parse(liquidTemplate, "template");
        String html = engine.evaluate(doc, r, rcontext);
        xn = new XhtmlParser().parseFragment(html);
        if (!x.getName().equals("div"))
            throw new FHIRException("Error in template: Root element is not 'div'");
    } catch (FHIRException | IOException e) {
        xn = new XhtmlNode(NodeType.Element, "div");
        xn.para().b().style("color: maroon").tx("Exception generating Narrative: " + e.getMessage());
    }
    x.getChildNodes().addAll(xn.getChildNodes());
    return true;
}
Also used : LiquidDocument(org.hl7.fhir.r4b.utils.LiquidEngine.LiquidDocument) XhtmlParser(org.hl7.fhir.utilities.xhtml.XhtmlParser) IOException(java.io.IOException) LiquidEngine(org.hl7.fhir.r4b.utils.LiquidEngine) FHIRException(org.hl7.fhir.exceptions.FHIRException) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Aggregations

IOException (java.io.IOException)5 FHIRException (org.hl7.fhir.exceptions.FHIRException)5 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)5 XhtmlParser (org.hl7.fhir.utilities.xhtml.XhtmlParser)5 LiquidDocument (org.hl7.fhir.r4b.utils.LiquidEngine.LiquidDocument)4 LiquidDocument (org.hl7.fhir.r5.utils.LiquidEngine.LiquidDocument)4 LiquidEngine (org.hl7.fhir.r4b.utils.LiquidEngine)3 LiquidEngine (org.hl7.fhir.r5.utils.LiquidEngine)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 MethodSource (org.junit.jupiter.params.provider.MethodSource)3 LiquidDocument (org.hl7.fhir.r4.utils.LiquidEngine.LiquidDocument)2