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

The following examples show how to use org.hl7.fhir.utilities.xhtml.XhtmlNode#ah() . 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: 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, Reference r, boolean allowLinks) throws UnsupportedEncodingException, IOException {
  if (r == null) {
    x.tx("null!");
    return;
  }
  XhtmlNode c = null;
  ResourceWithReference tr = null;
  if (r.hasReferenceElement() && allowLinks) {
    tr = resolveReference(rw, r.getReference());

    if (!r.getReference().startsWith("#")) {
      if (tr != null && tr.getReference() != null)
        c = x.ah(tr.getReference());
      else
        c = x.ah(r.getReference());
    } else {
      c = x.ah(r.getReference());
    }
  } else {
    c = x.span(null, null);
  }
  // what to display: if text is provided, then that. if the reference was resolved, then show the generated narrative
  if (r.hasDisplayElement()) {
    c.addText(r.getDisplay());
    if (tr != null && tr.getResource() != null) {
      c.tx(". Generated Summary: ");
      new ProfileDrivenRenderer(context).generateResourceSummary(c, tr.getResource(), true, r.getReference().startsWith("#"));
    }
  } else if (tr != null && tr.getResource() != null) {
    new ProfileDrivenRenderer(context).generateResourceSummary(c, tr.getResource(), r.getReference().startsWith("#"), r.getReference().startsWith("#"));
  } else {
    c.addText(r.getReference());
  }
}
 
Example 2
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 3
Source File: TerminologyRenderer.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
protected void addMapHeaders(XhtmlNode tr, List<UsedConceptMap> maps) throws FHIRFormatError, DefinitionException, IOException {
  for (UsedConceptMap m : maps) {
    XhtmlNode td = tr.td();
    XhtmlNode b = td.b();
    XhtmlNode a = b.ah(getContext().getSpecificationLink()+m.getLink());
    a.addText(m.getDetails().getName());
    if (m.getDetails().isDoDescription() && m.getMap().hasDescription())
      addMarkdown(td, m.getMap().getDescription());
  }
}
 
Example 4
Source File: ValueSetRenderer.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void addRefToCode(XhtmlNode td, String target, String vslink, String code) {
  CodeSystem cs = getContext().getWorker().fetchCodeSystem(target);
  String cslink = getCsRef(cs);
  XhtmlNode a = null;
  if (cslink != null) 
    a = td.ah(getContext().getSpecificationLink()+cslink+"#"+cs.getId()+"-"+code);
  else
    a = td.ah(getContext().getSpecificationLink()+vslink+"#"+code);
  a.addText(code);
}
 
Example 5
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void addMapHeaders(XhtmlNode tr, List<UsedConceptMap> maps) throws FHIRFormatError, DefinitionException, IOException {
 for (UsedConceptMap m : maps) {
 	XhtmlNode td = tr.td();
 	XhtmlNode b = td.b();
 	XhtmlNode a = b.ah(prefix+m.getLink());
    a.addText(m.getDetails().getName());
    if (m.getDetails().isDoDescription() && m.getMap().hasDescription())
      addMarkdown(td, m.getMap().getDescription());
 }
}
 
Example 6
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void addRefToCode(XhtmlNode td, String target, String vslink, String code) {
  CodeSystem cs = context.fetchCodeSystem(target);
  String cslink = getCsRef(cs);
  XhtmlNode a = null;
  if (cslink != null) 
    a = td.ah(prefix+cslink+"#"+cs.getId()+"-"+code);
  else
    a = td.ah(prefix+vslink+"#"+code);
  a.addText(code);
}
 
Example 7
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void addMapHeaders(XhtmlNode tr, Map<ConceptMap, String> mymaps) throws FHIRFormatError, DefinitionException, IOException {
 for (ConceptMap m : mymaps.keySet()) {
 	XhtmlNode td = tr.td();
 	XhtmlNode b = td.b();
 	XhtmlNode a = b.ah(prefix+mymaps.get(m));
    a.addText(m.getName());
    if (m.hasDescription())
      addMarkdown(td, m.getDescription());
 }
}
 
Example 8
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
private void addExpansionRowToTable(XhtmlNode t, ValueSetExpansionContainsComponent c, int i, boolean doSystem, boolean doDefinition, Map<ConceptMap, String> mymaps, CodeSystem allCS, List<String> langs) {
  XhtmlNode tr = t.tr();
  XhtmlNode td = tr.td();

  String tgt = makeAnchor(c.getSystem(), c.getCode());
  td.an(tgt);

  String s = Utilities.padLeft("", '\u00A0', i*2);

  td.addText(s);
  addCodeToTable(c.getAbstract(), c.getSystem(), c.getCode(), c.getDisplay(), td);
  if (doSystem) {
    td = tr.td();
    td.addText(c.getSystem());
  }
  td = tr.td();
  if (c.hasDisplayElement())
    td.addText(c.getDisplay());

  if (doDefinition) {
    CodeSystem cs = allCS;
    if (cs == null)
      cs = context.fetchCodeSystem(c.getSystem());
    td = tr.td();
    if (cs != null)
      td.addText(CodeSystemUtilities.getCodeDefinition(cs, c.getCode()));
  }
  for (ConceptMap m : mymaps.keySet()) {
    td = tr.td();
    List<TargetElementComponentWrapper> mappings = findMappingsForCode(c.getCode(), m);
    boolean first = true;
    for (TargetElementComponentWrapper mapping : mappings) {
      if (!first)
          td.br();
      first = false;
      XhtmlNode span = td.span(null, mapping.comp.getEquivalence().toString());
      span.addText(getCharForEquivalence(mapping.comp));
      XhtmlNode a = td.ah(prefix+mymaps.get(m)+"#"+mapping.comp.getCode());
      a.addText(mapping.comp.getCode());
      if (!Utilities.noString(mapping.comp.getComment()))
        td.i().tx("("+mapping.comp.getComment()+")");
    }
  }
  for (Extension ext : c.getExtension()) {
    if (ToolingExtensions.EXT_TRANSLATION.equals(ext.getUrl())) {
      String lang = ToolingExtensions.readStringExtension(ext,  "lang");
      if (!Utilities.noString(lang) && !langs.contains(lang))
        langs.add(lang);
    }
  }
  for (ValueSetExpansionContainsComponent cc : c.getContains()) {
    addExpansionRowToTable(t, cc, i+1, doSystem, doDefinition, mymaps, allCS, langs);
  }
}