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.FHIRFormatError;
008import org.hl7.fhir.r5.model.ImplementationGuide;
009import org.hl7.fhir.r5.model.Resource;
010import org.hl7.fhir.r5.renderers.utils.BaseWrappers.ResourceWrapper;
011import org.hl7.fhir.r5.renderers.utils.RenderingContext;
012import org.hl7.fhir.r5.renderers.utils.Resolver.ResourceContext;
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  public ImplementationGuideRenderer(RenderingContext context, ResourceContext rcontext) {
022    super(context, rcontext);
023  }
024  
025  public boolean render(XhtmlNode x, Resource dr) throws FHIRFormatError, DefinitionException, IOException {
026    return render(x, (ImplementationGuide) dr);
027  }
028
029  public boolean render(XhtmlNode x, ImplementationGuide ig) throws FHIRFormatError, DefinitionException, IOException {
030    x.h2().addText(ig.getName());
031    x.para().tx("The official URL for this implementation guide is: ");
032    x.pre().tx(ig.getUrl());
033    addMarkdown(x, ig.getDescription());
034    return true;
035  }
036
037  public void describe(XhtmlNode x, ImplementationGuide ig) {
038    x.tx(display(ig));
039  }
040
041  public String display(ImplementationGuide ig) {
042    return ig.present();
043  }
044
045  @Override
046  public String display(Resource r) throws UnsupportedEncodingException, IOException {
047    return ((ImplementationGuide) r).present();
048  }
049
050  public String display(ResourceWrapper r) throws UnsupportedEncodingException, IOException {
051    if (r.has("title")) {
052      return r.children("title").get(0).getBase().primitiveValue();
053    }
054    if (r.has("name")) {
055      return r.children("name").get(0).getBase().primitiveValue();
056    }
057    return "??";
058  }
059
060}