Java Code Examples for org.hl7.fhir.utilities.xhtml.XhtmlNode#tx()

The following examples show how to use org.hl7.fhir.utilities.xhtml.XhtmlNode#tx() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListRenderer.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private XhtmlNode shortForRef(XhtmlNode x, Base ref) throws UnsupportedEncodingException, IOException {
  if (ref == null) {
    x.tx("(null)");
  } else {
    String disp = ref.getChildByName("display") != null && ref.getChildByName("display").hasValues() ? ref.getChildByName("display").getValues().get(0).primitiveValue() : null;
    if (ref.getChildByName("reference").hasValues()) {
      String url = ref.getChildByName("reference").getValues().get(0).primitiveValue();
      ResourceWithReference r = context.getResolver().resolve(context, url);
      if (r == null) {
        if (disp == null) {
          disp = url;
        }
        x.tx(disp);
      } else if (r.getResource() != null) {
        RendererFactory.factory(r.getResource().getName(), context).renderReference(r.getResource(), x, (Reference) ref);
      } else {
        RendererFactory.factory(url, context).renderReference(r.getResource(), x, (Reference) ref);
      }
    } else if (disp != null) {
      x.tx(disp);      
    } else {
      x.tx("?ngen-16?");
    }     
  }
  return x;
}
 
Example 2
Source File: ValueSetComparer.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public XhtmlNode renderExpansion(ValueSetComparison csc, String id, String prefix) throws IOException {
    if (csc.getExpansion() == null) {
      XhtmlNode p = new XhtmlNode(NodeType.Element, "p");
      p.tx("Unable to generate expansion - see errors");
      return p;
    }
    // columns: code(+system), version, display , abstract, inactive,
    boolean hasSystem = csc.getExpansion().getChildren().isEmpty() ? false : getSystemVaries(csc.getExpansion(), csc.getExpansion().getChildren().get(0).either().getSystem());
    boolean hasVersion = findVersion(csc.getExpansion());
    boolean hasAbstract = findAbstract(csc.getExpansion());
    boolean hasInactive = findInactive(csc.getExpansion());

    HierarchicalTableGenerator gen = new HierarchicalTableGenerator(Utilities.path("[tmp]", "comparison"), false);
    TableModel model = gen.new TableModel(id, true);
    model.setAlternating(true);
    if (hasSystem) {
      model.getTitles().add(gen.new Title(null, null, "System", "The code for the concept", null, 100));
    }
    model.getTitles().add(gen.new Title(null, null, "Code", "The system for the concept", null, 100));
    model.getTitles().add(gen.new Title(null, null, "Display", "The display for the concept", null, 200, 2));
//    if (hasVersion) {
//      model.getTitles().add(gen.new Title(null, null, "Version", "The version for the concept", null, 200, 2));
//    }
//    if (hasAbstract) {
//      model.getTitles().add(gen.new Title(null, null, "Abstract", "The abstract flag for the concept", null, 200, 2));
//    }
//    if (hasInactive) {
//      model.getTitles().add(gen.new Title(null, null, "Inactive", "The inactive flag for the concept", null, 200, 2));
//    }
    model.getTitles().add(gen.new Title(null, null, "Comments", "Additional information about the comparison", null, 200));
    for (StructuralMatch<ValueSetExpansionContainsComponent> t : csc.getExpansion().getChildren()) {
      addExpansionRow(gen, model.getRows(), t, hasSystem, hasVersion, hasAbstract, hasInactive);
    }
    return gen.generate(model, prefix, 0, null);
  }
 
Example 3
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void renderRange(Range q, XhtmlNode x) {
  if (q.hasLow())
    x.addText(q.getLow().getValue().toString());
  else
    x.tx("?");
  x.tx("-");
  if (q.hasHigh())
    x.addText(q.getHigh().getValue().toString());
  else
    x.tx("?");
  if (q.getLow().hasUnit())
    x.tx(" "+q.getLow().getUnit());
}
 
Example 4
Source File: CapabilityStatementUtilities.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void genSP(XhtmlNode td, CapabilityStatementRestResourceComponent r, CapabilityStatementRestResourceComponent other, boolean errorIfNoMatch) {
  boolean first = true;
  for (CapabilityStatementRestResourceSearchParamComponent i : r.getSearchParam()) {
    if (first) first = false; else td.tx(", ");
    if (exists(other, i)) {
      td.code().span("background-color: #bbff99; border: 1px solid #44cc00; margin-width: 10px", null).tx(i.getName());
    } else if (errorIfNoMatch){
      td.code().span("background-color: #ffe6e6; border: 1px solid #ff1a1a; margin-width: 10px", null).tx(i.getName());
    } else {
      td.code(i.getName());
    }
  }    
}
 
Example 5
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void renderRange(Range q, XhtmlNode x) {
  if (q.hasLow())
    x.addText(q.getLow().getValue().toString());
  else
    x.tx("?");
  x.tx("-");
  if (q.hasHigh())
    x.addText(q.getHigh().getValue().toString());
  else
    x.tx("?");
  if (q.getLow().hasUnit())
    x.tx(" "+q.getLow().getUnit());
}
 
Example 6
Source File: ValueSetRenderer.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void addCSRef(XhtmlNode x, String url) {
  CodeSystem cs = getContext().getWorker().fetchCodeSystem(url);
  if (cs == null) {
    x.code(url);
  } else if (cs.hasUserData("path")) {
    x.ah(cs.getUserString("path")).tx(cs.present());
  } else {
    x.code(url);
    x.tx(" ("+cs.present()+")");
  }
}
 
Example 7
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void renderQuantity(Quantity q, XhtmlNode x, boolean showCodeDetails) {
  if (q.hasComparator())
    x.addText(q.getComparator().toCode());
  x.addText(q.getValue().toString());
  if (q.hasUnit())
    x.tx(" "+q.getUnit());
  else if (q.hasCode())
    x.tx(" "+q.getCode());
  if (showCodeDetails && q.hasCode()) {
    x.span("background: LightGoldenRodYellow", null).tx(" (Details: "+describeSystem(q.getSystem())+" code "+q.getCode()+" = '"+lookupCode(q.getSystem(), q.getCode())+"')");
  }
}
 
Example 8
Source File: ConceptMapRenderer.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public void renderCSDetailsLink(XhtmlNode tr, String url, boolean span2) {
  CodeSystem cs;
  XhtmlNode td;
  cs = getContext().getWorker().fetchCodeSystem(url);
  td = tr.td();
  if (span2) {
    td.colspan("2");
  }
  td.b().tx("Code");
  td.tx(" from ");
  if (cs == null)
    td.tx(url);
  else
    td.ah(context.fixReference(cs.getUserString("path"))).attribute("title", url).tx(cs.present());
}
 
Example 9
Source File: DataRenderer.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
protected void renderQuantity(XhtmlNode x, Quantity q, boolean showCodeDetails) {
  if (q.hasComparator())
    x.addText(q.getComparator().toCode());
  if (q.hasValue()) {
    x.addText(q.getValue().toString());
  }
  if (q.hasUnit())
    x.tx(" "+q.getUnit());
  else if (q.hasCode())
    x.tx(" "+q.getCode());
  if (showCodeDetails && q.hasCode()) {
    x.span("background: LightGoldenRodYellow", null).tx(" (Details: "+TerminologyRenderer.describeSystem(q.getSystem())+" code "+q.getCode()+" = '"+lookupCode(q.getSystem(), q.getCode())+"')");
  }
}
 
Example 10
Source File: ResourceRenderer.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public void renderReference(ResourceWrapper rw, XhtmlNode x, BaseWrapper r) throws UnsupportedEncodingException, IOException {
  XhtmlNode c = x;
  ResourceWithReference tr = null;
  String v;
  if (r.has("reference")) {
    v = r.get("reference").primitiveValue();
    tr = resolveReference(rw, v);

    if (!v.startsWith("#")) {
      if (tr != null && tr.getReference() != null)
        c = x.ah(tr.getReference());
      else
        c = x.ah(v);
    }
  } else {
    v = "";
  }
  // what to display: if text is provided, then that. if the reference was resolved, then show the generated narrative
  if (r.has("display")) {
    c.addText(r.get("display").primitiveValue());
    if (tr != null && tr.getResource() != null) {
      c.tx(". Generated Summary: ");
      new ProfileDrivenRenderer(context).generateResourceSummary(c, tr.getResource(), true, v.startsWith("#"));
    }
  } else if (tr != null && tr.getResource() != null) {
    new ProfileDrivenRenderer(context).generateResourceSummary(c, tr.getResource(), v.startsWith("#"), v.startsWith("#"));
  } else {
    c.addText(v);
  }
}
 
Example 11
Source File: ElementWrappers.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
@Override
public void describe(XhtmlNode x) {
  if (wrapped.hasChild("title") && wrapped.getChildValue("title") != null) {
    x.tx(wrapped.getChildValue("title"));
  } else if (wrapped.hasChild("name") && wrapped.getChildValue("name") != null) {
    x.tx(wrapped.getChildValue("name"));       
  } else {
    x.tx("?ngen-1?");
  }
}
 
Example 12
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void generateResourceSummary(XhtmlNode x, ResourceWrapper res, boolean textAlready, boolean showCodeDetails, ResourceContext rc) throws FHIRException, UnsupportedEncodingException, IOException {
  if (!textAlready) {
    XhtmlNode div = res.getNarrative();
    if (div != null) {
      if (div.allChildrenAreText())
        x.getChildNodes().addAll(div.getChildNodes());
      if (div.getChildNodes().size() == 1 && div.getChildNodes().get(0).allChildrenAreText())
        x.getChildNodes().addAll(div.getChildNodes().get(0).getChildNodes());
    }
    x.tx("Generated Summary: ");
  }
  String path = res.getName();
  StructureDefinition profile = context.fetchResource(StructureDefinition.class, path);
  if (profile == null)
    x.tx("unknown resource " +path);
  else {
    boolean firstElement = true;
    boolean last = false;
    for (PropertyWrapper p : res.children()) {
      ElementDefinition child = getElementDefinition(profile.getSnapshot().getElement(), path+"."+p.getName(), p);
      if (p.getValues().size() > 0 && p.getValues().get(0) != null && child != null && isPrimitive(child) && includeInSummary(child)) {
        if (firstElement)
          firstElement = false;
        else if (last)
          x.tx("; ");
        boolean first = true;
        last = false;
        for (BaseWrapper v : p.getValues()) {
          if (first)
            first = false;
          else if (last)
            x.tx(", ");
          last = displayLeaf(res, v, child, x, p.getName(), showCodeDetails, rc) || last;
        }
      }
    }
  }
}
 
Example 13
Source File: NamingSystemRenderer.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
private XhtmlNode row(XhtmlNode tbl, String name, String value) {
  XhtmlNode td = row(tbl, name);
  td.tx(value);
  return td;
}
 
Example 14
Source File: ConceptMapRenderer.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
public void describe(XhtmlNode x, ConceptMap cm) {
  x.tx(display(cm));
}
 
Example 15
Source File: NamingSystemRenderer.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
public void describe(XhtmlNode x, NamingSystem ns) {
  x.tx(display(ns));
}
 
Example 16
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
private void generatePatientSummary(XhtmlNode c, ResourceWrapper r) {
  c.tx("to do");
}
 
Example 17
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
private boolean generateComposition(ResourceContext rcontext, XhtmlNode x, ValueSet vs, boolean header, List<UsedConceptMap> maps) throws FHIRException, IOException {
 boolean hasExtensions = false;
  List<String> langs = new ArrayList<String>();

  if (header) {
    XhtmlNode h = x.h2();
    h.addText(vs.present());
    addMarkdown(x, vs.getDescription());
    if (vs.hasCopyrightElement())
      generateCopyright(x, vs);
  }
  XhtmlNode p = x.para();
  p.tx("This value set includes codes from the following code systems:");

  XhtmlNode ul = x.ul();
  XhtmlNode li;
  for (ConceptSetComponent inc : vs.getCompose().getInclude()) {
    hasExtensions = genInclude(rcontext, ul, inc, "Include", langs, maps) || hasExtensions;
  }
  for (ConceptSetComponent exc : vs.getCompose().getExclude()) {
    hasExtensions = genInclude(rcontext, ul, exc, "Exclude", langs, maps) || hasExtensions;
  }

  // now, build observed languages

  if (langs.size() > 0) {
    Collections.sort(langs);
    x.para().b().tx("Additional Language Displays");
    XhtmlNode t = x.table( "codes");
    XhtmlNode tr = t.tr();
    tr.td().b().tx("Code");
    for (String lang : langs)
      tr.td().b().addText(describeLang(lang));
    for (ConceptSetComponent c : vs.getCompose().getInclude()) {
      for (ConceptReferenceComponent cc : c.getConcept()) {
        addLanguageRow(cc, t, langs);
      }
    }
  }

  return hasExtensions;
}
 
Example 18
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
private void displayReferenceId(XhtmlNode c, BaseWrapper v) {
  c.tx("to do");
}
 
Example 19
Source File: ImplementationGuideRenderer.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
public void describe(XhtmlNode x, ImplementationGuide ig) {
  x.tx(display(ig));
}
 
Example 20
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
private void displayReferenceId(XhtmlNode c, BaseWrapper v) {
  c.tx("to do");
}