public String summary(FetchedResource r, boolean xml, boolean json, boolean ttl)
      throws Exception {
    //    return "[--Summary goes here--]";
    StringBuilder b = new StringBuilder();
    b.append("<table class=\"grid\">\r\n");
    b.append(
        " <tbody><tr><td>Defining URL:</td><td>"
            + Utilities.escapeXml(map.getUrl())
            + "</td></tr>\r\n");
    b.append(" <tr><td>Name:</td><td>" + Utilities.escapeXml(map.getName()) + "</td></tr>\r\n");
    if (map.hasDescription())
      b.append(
          " <tr><td>Definition:</td><td>"
              + processMarkdown("description", map.getDescription())
              + "</td></tr>\r\n");
    if (map.hasPublisher())
      b.append(
          " <tr><td>Publisher:</td><td>"
              + Utilities.escapeXml(map.getPublisher())
              + "</td></tr>\r\n");
    if (map.hasCopyright())
      b.append(
          " <tr><td>Copyright:</td><td>"
              + Utilities.escapeXml(map.getCopyright())
              + "</td></tr>\r\n");
    if (xml || json || ttl) {
      b.append(" <tr><td>Source Resource</td><td>");
      boolean first = true;
      String filename = igp.getProperty(r, "format");
      if (filename == null) filename = "ValueSet-" + r.getId() + ".{{[fmt]}}.html";
      if (xml) {
        first = false;
        b.append("<a href=\"" + igp.doReplacements(filename, r, null, "xml") + "\">XML</a>");
      }
      if (json) {
        if (first) first = false;
        else b.append(" / ");
        b.append("<a href=\"" + igp.doReplacements(filename, r, null, "json") + "\">JSON</a>");
      }
      if (ttl) {
        if (first) first = false;
        else b.append(" / ");
        b.append("<a href=\"" + igp.doReplacements(filename, r, null, "ttl") + "\">Turtle</a>");
      }
      b.append("</td></tr>\r\n");
    }
    b.append("</tbody></table>\r\n");

    return b.toString();
  }
 private String ref(BindingSpecification cd) {
   if (!cd.hasReference()) return Utilities.escapeXml(cd.getDescription());
   else if (cd.getValueSet() != null)
     return "<a href=\""
         + cd.getReference()
         + ".html\">"
         + Utilities.escapeXml(cd.getValueSet().getName())
         + "</a>";
   else
     return "<a href=\""
         + cd.getReference()
         + "\">"
         + Utilities.escapeXml(cd.getDescription())
         + "</a>";
 }
 public String toXML() {
   return "<message source=\""
       + source
       + "\" line=\""
       + line
       + "\" col=\""
       + col
       + "\" location=\""
       + Utilities.escapeXml(location)
       + "\" type=\""
       + type
       + "\" level=\""
       + level
       + "\"><plain>"
       + Utilities.escapeXml(message)
       + "</plain><html>"
       + html
       + "</html></message>";
 }
Exemple #4
0
 public static Narrative newNarrative(NarrativeStatus status, String html)
     throws IOException, FHIRException {
   Narrative n = new Narrative();
   n.setStatus(status);
   try {
     n.setDiv(new XhtmlParser().parseFragment("<div>" + Utilities.escapeXml(html) + "</div>"));
   } catch (org.hl7.fhir.exceptions.FHIRException e) {
     throw new FHIRException(e.getMessage(), e);
   }
   return n;
 }
 public String profiles() {
   StringBuilder b = new StringBuilder();
   b.append("<ul>\r\n");
   for (StructureDefinition sd : analysis.getProfiles()) {
     b.append(
         "  <li><a href=\""
             + sd.getUserString("path")
             + "\">"
             + Utilities.escapeXml(sd.getName())
             + "</a></li>\r\n");
   }
   b.append("</ul>\r\n");
   return b.toString();
 }
 public ValidationMessage(
     Source source, IssueType type, String path, String message, IssueSeverity level) {
   super();
   this.line = -1;
   this.col = -1;
   this.location = path;
   this.message = message;
   this.html = Utilities.escapeXml(message);
   this.level = level;
   this.source = source;
   this.type = type;
   if (level == IssueSeverity.NULL) determineLevel(path);
   if (type == null) throw new Error("A type must be provided");
 }
  private void genBinding(BindingSpecification cd, String path, boolean isCode) throws Exception {
    if (cd.getName().equals("*unbound*")) {
      write("  <li>" + path + " (Error!!!)</li>\r\n");
    } else if (cd.getBinding() == BindingSpecification.BindingMethod.Unbound) {
      write(
          "  <li>"
              + path
              + " <i>"
              + Utilities.escapeXml(cd.getName())
              + "</i>: \""
              + Utilities.escapeXml(cd.getDefinition())
              + "\". (not bound to any codes)</li>\r\n");
    } else if (cd.getBinding() == BindingSpecification.BindingMethod.CodeList) {
      String sid = "";
      String bs =
          "<a href=\"terminologies.html#"
              + cd.getStrength().toCode()
              + "\">"
              + cd.getStrength().getDisplay()
              + "</a>";
      if (!isCode) {
        sid =
            "\"<a href=\""
                + cd.getReference().substring(1)
                + ".html\">http://hl7.org/fhir/"
                + cd.getReference().substring(1)
                + "\"</a>";
        //					if (!sids.contains(sid))
        //						sids.put(sid, new DefinedCode())
        sid = " system " + sid + "";
        write(
            "  <li>"
                + path
                + " <i>"
                + Utilities.escapeXml(cd.getValueSet().getName())
                + "</i>: \""
                + Utilities.escapeXml(cd.getDefinition())
                + "\". "
                + bs
                + ". See "
                + sid
                + ".\r\n");
      } else {
        write(
            "  <li>"
                + path
                + " <i>"
                + Utilities.escapeXml(cd.getValueSet().getName())
                + "</i>: \""
                + Utilities.escapeXml(cd.getDefinition())
                + "\" "
                + bs
                + ". "
                + sid
                + ". Example values:\r\n");
        write("  <li>this list is todo:\r\n");
        // bscodes
        //        write("    <table class=\"codes\">\r\n");
        //        boolean hasComment = false;
        //        boolean hasDefinition = false;
        //        for (DefinedCode c : cd.getCodes()) {
        //          hasComment = hasComment || c.hasComment();
        //          hasDefinition = hasDefinition || c.hasDefinition();
        //        }
        //        //				if (hasComment)
        //        //					write("
        // <tr><td><b>Code</b></td><td><b>Title</b></td><td><b>Comment</b></td></tr>");
        //        //				else if (hasDefinition)
        //        //					write("    <tr><td><b>Code</b></td><td
        // colspan=\"2\"><b>Title</b></td></tr>");
        //
        //
        //        for (DefinedCode c : cd.getCodes()) {
        //          if (hasComment)
        //            write("
        // <tr><td>"+Utilities.escapeXml(c.getCode())+"</td><td>"+Utilities.escapeXml(c.getDefinition())+"</td><td>"+Utilities.escapeXml(c.getComment())+"</td></tr>");
        //          else if (hasDefinition)
        //            write("    <tr><td>"+Utilities.escapeXml(c.getCode())+"</td><td
        // colspan=\"2\">"+Utilities.escapeXml(c.getDefinition())+"</td></tr>");
        //          else
        //            write("    <tr><td
        // colspan=\"3\">"+Utilities.escapeXml(c.getCode())+"</td></tr>");
        //        }
        //        write("    </table>\r\n");
      }
      write("  </li>\r\n");

    } else if (cd.getBinding() == BindingSpecification.BindingMethod.Special) {
      if (cd.getValueSet().getName().equals("MessageEvent"))
        write(
            "<li>"
                + path
                + " of the <a href=\"message.html#Events\"> Event List in the messaging framework</a></li>\r\n");
      else if (cd.getValueSet().getName().equals("ResourceType"))
        write(
            "  <li>"
                + path
                + " of <a href=\"terminologies.html#ResourceType\"> any defined Resource Type name</a></li>\r\n");
      else if (cd.getValueSet().getName().equals("FHIRContentType"))
        write(
            "  <li>"
                + path
                + " of <a href=\"terminologies.html#fhircontenttypes\"> any defined Resource or Data Type name</a></li>\r\n");
      else
        write(
            "  <li>"
                + path
                + " of <a href=\"datatypes.html\"> any defined data Type name</a> (including <a href=\"resource.html#Resource\">Resource</a>)</li>\r\n");

    } else {
      String bs =
          "<a href=\"terminologies.html#"
              + cd.getStrength().toCode()
              + "\">"
              + cd.getStrength().getDisplay()
              + "</a>";
      write(
          "  <li>"
              + path
              + " <i>"
              + Utilities.escapeXml(cd.getValueSet().getName())
              + "</i>: \""
              + Utilities.escapeXml(cd.getDefinition())
              + "\". "
              + bs
              + ". See "
              + ref(cd)
              + "</li>\r\n");
    }
  }
  private void gen(String prefix, Map<BindingSpecification, List<CDUsage>> txusages2)
      throws Exception {
    List<BindingSpecification> cds = new ArrayList<BindingSpecification>();
    cds.addAll(txusages.keySet());
    if (cds.size() == 0) return;

    Collections.sort(cds, new MyCompare());
    write("<h3>\r\nTerminology Bindings\r\n</h3>\r\n");
    // 1. new form
    write("<table class=\"grid\">\r\n");
    write(" <tr><th>Path</th><th>Definition</th><th>Type</th><th>Reference</th></tr>\r\n");
    for (BindingSpecification cd : cds) {
      String path;
      List<CDUsage> list = txusages.get(cd);
      for (int i = 2; i < list.size(); i++) {
        if (!list.get(i).element.typeCode().equals(list.get(1).element.typeCode()))
          throw new Exception(
              "Mixed types on one concept domain in one type - not yet supported by the build process for binding "
                  + cd.getName());
      }
      String name = cd.getValueSet() != null ? cd.getValueSet().getName() : cd.getName();
      write(" <tr><td valign=\"top\" title=\"" + name + "\">");
      boolean first = true;
      for (int i = 1; i < list.size(); i++) {
        if (!first) write("<br/>");
        first = false;
        write(list.get(i).path);
      }
      write(" </td>");
      write("<td valign=\"top\">" + Utilities.escapeXml(cd.getDefinition()) + "</td>");
      if (cd.getBinding() == BindingMethod.Unbound)
        write("<td>Unknown</td><td valign=\"top\">No details provided yet</td>");
      else {
        write(
            "<td><a href=\""
                + prefix
                + "terminologies.html#"
                + cd.getStrength().toCode()
                + "\">"
                + cd.getStrength().getDisplay()
                + "</a></td>");
        write("<td valign=\"top\">");
        if (cd.getBinding() == BindingSpecification.BindingMethod.Special) {
          if (name.equals("MessageEvent"))
            write(
                "<a href=\""
                    + prefix
                    + "valueset-message-events.html\">http://hl7.org/fhir/valueset/message-events</a>");
          else if (name.equals("ResourceType"))
            write(
                "<a href=\""
                    + prefix
                    + "valueset-resource-types.html\">http://hl7.org/fhir/valueset/resource-types</a>");
          else if (name.equals("DataType"))
            write(
                "<a href=\""
                    + prefix
                    + "valueset-data-types.html\">http://hl7.org/fhir/valueset/data-types</a>");
          else if (name.equals("FHIRDefinedType"))
            write(
                "<a href=\""
                    + prefix
                    + "valueset-defined-types.html\">http://hl7.org/fhir/valueset/defined-types</a>");
          else throw new Exception("Unknown special type " + name);
        }
        if (cd.getValueSet() != null) {
          ValueSet vs = cd.getValueSet();
          String pp = (String) vs.getUserData("path");
          if (pp == null) throw new Exception("unknown path on " + cd.getReference());
          write(
              "<a href=\""
                  + prefix
                  + pp.replace(File.separatorChar, '/')
                  + "\">"
                  + vs.getName()
                  + "</a><!-- b -->");
        } else if (cd.getBinding() == BindingSpecification.BindingMethod.ValueSet) {
          if (Utilities.noString(cd.getReference())) write("??");
          else if (cd.getReference().startsWith("valueset-"))
            write(
                "<a href=\""
                    + prefix
                    + cd.getReference()
                    + ".html\">http://hl7.org/fhir/ValueSet/"
                    + cd.getReference().substring(9)
                    + "</a><!-- a -->");
          else if (cd.getReference().startsWith("http://hl7.org/fhir")) {
            if (cd.getReference().startsWith("http://hl7.org/fhir/ValueSet/v3-")) {
              ValueSet vs = page.getValueSets().get(cd.getReference());
              String pp = (String) vs.getUserData("path");
              if (pp == null) throw new Exception("unknown path on " + cd.getReference());
              write(
                  "<a href=\""
                      + prefix
                      + pp.replace(File.separatorChar, '/')
                      + "\">"
                      + cd.getReference()
                      + "</a><!-- b -->");
            } else if (cd.getReference().startsWith("http://hl7.org/fhir/ValueSet/v2-")) {
              ValueSet vs = page.getValueSets().get(cd.getReference());
              String pp = (String) vs.getUserData("path");
              write(
                  "<a href=\""
                      + prefix
                      + pp.replace(File.separatorChar, '/')
                      + "\">"
                      + cd.getReference()
                      + "</a><!-- c -->");
            } else if (cd.getReference().startsWith("http://hl7.org/fhir/ValueSet/")) {
              String ref = getBindingLink(cd);
              write("<a href=\"" + prefix + ref + "\">" + cd.getReference() + "</a><!-- d -->");
              //              BindingSpecification bs1 =
              // page.getDefinitions().getBindingByURL(cd.getReference());
              //              if (bs1 != null)
              //                write("<a
              // href=\""+cd.getReference().substring(23)+".html\">"+cd.getReference()+"</a><!-- d
              // -->");
              //              else
              //                write("<a
              // href=\"valueset-"+cd.getReference().substring(23)+".html\">"+cd.getReference()+"</a><!-- d -->");
            } else
              throw new Exception("Internal reference " + cd.getReference() + " not handled yet");
          } else if (cd.getReference().startsWith("http:"))
            write("<a href=\"" + cd.getReference() + "\">" + cd.getReference() + "</a><!-- e -->");
          else
            write(
                "<a href=\""
                    + prefix
                    + "valueset-"
                    + cd.getReference()
                    + ".html\">http://hl7.org/fhir/"
                    + cd.getReference()
                    + "</a><!-- e -->");
        } else if (cd.getBinding() == BindingSpecification.BindingMethod.CodeList) {
          write(
              "<a href=\""
                  + prefix
                  + "valueset-"
                  + cd.getReference().substring(1)
                  + ".html\">http://hl7.org/fhir/"
                  + cd.getReference().substring(1)
                  + "</a><!-- f -->");
        } else if (cd.getBinding() == BindingSpecification.BindingMethod.Reference) {
          write(
              "<a href=\""
                  + prefix
                  + cd.getReference()
                  + "\">"
                  + cd.getDescription()
                  + "</a><!-- g -->");
        }

        write("</td>");
      }
      write(" </tr>\r\n");
    }
    write("</table>\r\n<p> </p>\r\n");
  }
 public String getHtml() {
   return html == null ? Utilities.escapeXml(message) : html;
 }