001package org.hl7.fhir.r5.renderers; 002 003import java.io.IOException; 004import java.io.UnsupportedEncodingException; 005 006import org.hl7.fhir.exceptions.DefinitionException; 007import org.hl7.fhir.exceptions.FHIRException; 008import org.hl7.fhir.exceptions.FHIRFormatError; 009import org.hl7.fhir.r5.model.ActorDefinition; 010import org.hl7.fhir.r5.model.CapabilityStatement; 011import org.hl7.fhir.r5.model.Library; 012import org.hl7.fhir.r5.model.UrlType; 013import org.hl7.fhir.r5.renderers.utils.RenderingContext; 014import org.hl7.fhir.r5.renderers.utils.ResourceWrapper; 015import org.hl7.fhir.r5.utils.EOperationOutcome; 016import org.hl7.fhir.utilities.xhtml.XhtmlNode; 017 018public class ActorDefinitionRenderer extends ResourceRenderer { 019 020 021 public ActorDefinitionRenderer(RenderingContext context) { 022 super(context); 023 } 024 025 @Override 026 public void buildNarrative(RenderingStatus status, XhtmlNode x, ResourceWrapper r) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome { 027 renderResourceTechDetails(r, x); 028 genSummaryTable(status, x, r); 029 render(status, x, r); 030 } 031 032 @Override 033 public String buildSummary(ResourceWrapper r) throws UnsupportedEncodingException, IOException { 034 return canonicalTitle(r); 035 } 036 037 public void render(RenderingStatus status, XhtmlNode x, ResourceWrapper acd) throws FHIRFormatError, DefinitionException, IOException { 038 XhtmlNode tbl = x.table("grid"); 039 XhtmlNode tr = tbl.tr(); 040 tr.td().b().tx(context.formatPhrase(RenderingContext.ACTOR_DEF_ACT, context.getTranslated(acd.child("name"))) + " "); 041 tr.td().tx(context.getTranslated(acd.child("title"))); 042 tr.td().tx(context.formatPhrase(RenderingContext.ACTOR_DEF_TYP, acd.primitiveValue("type")) + " "); 043 XhtmlNode td = tbl.tr().td().colspan("3"); 044 addMarkdown(td, context.getTranslated(acd.child("documentation"))); 045 if (acd.has("reference")) { 046 tbl.tr().td().tx(context.formatPhrase(RenderingContext.GENERAL_REFS)); 047 td = tr.td().colspan("2"); 048 boolean first = true; 049 for (ResourceWrapper t : acd.children("reference")) { 050 if (first) first = false; else x.br(); 051 renderUri(status, td, t); 052 } 053 } 054 if (acd.has("capabilities")) { 055 tr = tbl.tr(); 056 tr.td().tx(context.formatPhrase(RenderingContext.ACTOR_DEF_CAP)); 057 td = tr.td().colspan("2"); 058 renderCanonical(status, td, acd.child("capabilities")); 059 } 060 if (acd.has("derivedFrom")) { 061 tbl.tr().td().tx(context.formatPhrase(RenderingContext.ACTOR_DEF_DER)); 062 td = tr.td().colspan("2"); 063 boolean first = true; 064 for (ResourceWrapper t : acd.children("reference")) { 065 if (first) first = false; else x.br(); 066 renderUri(status, td, t); 067 } 068 } 069 } 070 071 public void describe(XhtmlNode x, Library lib) { 072 x.tx(display(lib)); 073 } 074 075 public String display(Library lib) { 076 return lib.present(); 077 } 078 079}