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.ImplementationGuide;
010import org.hl7.fhir.r5.renderers.utils.RenderingContext;
011import org.hl7.fhir.r5.renderers.utils.ResourceWrapper;
012import org.hl7.fhir.r5.utils.EOperationOutcome;
013import org.hl7.fhir.utilities.xhtml.XhtmlNode;
014
015public class ImplementationGuideRenderer extends ResourceRenderer {
016
017  public ImplementationGuideRenderer(RenderingContext context) { 
018    super(context); 
019  } 
020 
021  @Override
022  public void buildNarrative(RenderingStatus status, XhtmlNode x, ResourceWrapper r) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome {
023    if (r.isDirect()) {    
024      renderResourceTechDetails(r, x);
025      genSummaryTable(status, x, (ImplementationGuide) r.getBase());
026      render(status, x, (ImplementationGuide) r.getBase());      
027    } else {
028      // the intention is to change this in the future
029      x.para().tx("ImplementationGuideRenderer only renders native resources directly");
030    }
031  }
032  
033  @Override
034  public String buildSummary(ResourceWrapper r) throws UnsupportedEncodingException, IOException {
035    return canonicalTitle(r);
036  }
037
038
039  public void render(RenderingStatus status, XhtmlNode x, ImplementationGuide ig) throws FHIRFormatError, DefinitionException, IOException {
040
041    x.h2().addText(ig.getName());
042    x.para().tx(context.formatPhrase(RenderingContext.IMP_GUIDE_URL)+" ");
043    x.pre().tx(ig.getUrl());
044    addMarkdown(x, ig.getDescription());
045  }
046
047  public void describe(XhtmlNode x, ImplementationGuide ig) {
048    x.tx(display(ig));
049  }
050
051  public String display(ImplementationGuide ig) {
052    return ig.present();
053  }
054
055
056}