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      throw new Error("ImplementationGuideRenderer only renders native resources directly");
029    }
030  }
031  
032  @Override
033  public String buildSummary(ResourceWrapper r) throws UnsupportedEncodingException, IOException {
034    return canonicalTitle(r);
035  }
036
037
038  public void render(RenderingStatus status, XhtmlNode x, ImplementationGuide ig) throws FHIRFormatError, DefinitionException, IOException {
039
040    x.h2().addText(ig.getName());
041    x.para().tx(context.formatPhrase(RenderingContext.IMP_GUIDE_URL)+" ");
042    x.pre().tx(ig.getUrl());
043    addMarkdown(x, ig.getDescription());
044  }
045
046  public void describe(XhtmlNode x, ImplementationGuide ig) {
047    x.tx(display(ig));
048  }
049
050  public String display(ImplementationGuide ig) {
051    return ig.present();
052  }
053
054
055}