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

The following examples show how to use org.hl7.fhir.utilities.xhtml.XhtmlNode#br() . 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: DataRenderer.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
protected void smartAddText(XhtmlNode p, String text) {
  if (text == null)
    return;

  String[] lines = text.split("\\r\\n");
  for (int i = 0; i < lines.length; i++) {
    if (i > 0)
      p.br();
    p.addText(lines[i]);
  }
}
 
Example 2
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void smartAddText(XhtmlNode p, String text) {
 if (text == null)
   return;

  String[] lines = text.split("\\r\\n");
  for (int i = 0; i < lines.length; i++) {
    if (i > 0)
      p.br();
    p.addText(lines[i]);
  }
}
 
Example 3
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void smartAddText(XhtmlNode p, String text) {
 if (text == null)
   return;

  String[] lines = text.split("\\r\\n");
  for (int i = 0; i < lines.length; i++) {
    if (i > 0)
      p.br();
    p.addText(lines[i]);
  }
}
 
Example 4
Source File: ValueSetRenderer.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 doLevel, boolean doSystem, boolean doDefinition, List<UsedConceptMap> maps, CodeSystem allCS, List<String> langs) {
  XhtmlNode tr = t.tr();
  XhtmlNode td = tr.td();

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

  if (doLevel) {
    td.addText(Integer.toString(i));
    td = tr.td();
  }
  String s = Utilities.padLeft("", '\u00A0', i*2);
  td.attribute("style", "white-space:nowrap").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 = getContext().getWorker().fetchCodeSystem(c.getSystem());
    td = tr.td();
    if (cs != null)
      td.addText(CodeSystemUtilities.getCodeDefinition(cs, c.getCode()));
  }
  for (UsedConceptMap m : maps) {
    td = tr.td();
    List<TargetElementComponentWrapper> mappings = findMappingsForCode(c.getCode(), m.getMap());
    boolean first = true;
    for (TargetElementComponentWrapper mapping : mappings) {
      if (!first)
          td.br();
      first = false;
      XhtmlNode span = td.span(null, mapping.comp.getRelationship().toString());
      span.addText(getCharForRelationship(mapping.comp));
      addRefToCode(td, mapping.group.getTarget(), m.getLink(), 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, doLevel, doSystem, doDefinition, maps, allCS, langs);
  }
}
 
Example 5
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("rawtypes")
private void generateVersionNotice(XhtmlNode x, ValueSetExpansionComponent expansion) {
  Map<String, String> versions = new HashMap<String, String>();
  boolean firstVersion = true;
  for (ValueSetExpansionParameterComponent p : expansion.getParameter()) {
    if (p.getName().equals("version")) {
      String[] parts = ((PrimitiveType) p.getValue()).asStringValue().split("\\|");
      if (parts.length == 2)
        versions.put(parts[0], parts[1]);
      if (!versions.isEmpty()) {
        StringBuilder b = new StringBuilder();
        if (firstVersion) {
          // the first version
          // set the <p> tag and style attribute
          x.para().setAttribute("style", "border: black 1px dotted; background-color: #EEEEEE; padding: 8px");
      	  firstVersion = false;
        } else {
          // the second (or greater) version
          x.br(); // add line break before the version text
        }
        b.append("Expansion based on ");
        boolean firstPart = true;
        for (String s : versions.keySet()) {
          if (firstPart)
            firstPart = false;
          else
            b.append(", ");
          if (!s.equals("http://snomed.info/sct"))
            b.append(describeSystem(s)+" version "+versions.get(s));
          else {
            parts = versions.get(s).split("\\/");
            if (parts.length >= 5) {
              String m = describeModule(parts[4]);
              if (parts.length == 7)
                b.append("SNOMED CT "+m+" edition "+formatSCTDate(parts[6]));
              else
                b.append("SNOMED CT "+m+" edition");
            } else
              b.append(describeSystem(s)+" version "+versions.get(s));
          }
        }
        x.addText(b.toString()); // add the version text
      }
    }
  }
}
 
Example 6
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 doLevel, boolean doSystem, boolean doDefinition, List<UsedConceptMap> maps, CodeSystem allCS, List<String> langs) {
  XhtmlNode tr = t.tr();
  XhtmlNode td = tr.td();

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

  if (doLevel) {
    td.addText(Integer.toString(i));
    td = tr.td();
  }
  String s = Utilities.padLeft("", '\u00A0', i*2);
  td.attribute("style", "white-space:nowrap").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 (UsedConceptMap m : maps) {
    td = tr.td();
    List<TargetElementComponentWrapper> mappings = findMappingsForCode(c.getCode(), m.getMap());
    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));
      addRefToCode(td, mapping.group.getTarget(), m.getLink(), 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, doLevel, doSystem, doDefinition, maps, allCS, langs);
  }
}
 
Example 7
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("rawtypes")
private void generateVersionNotice(XhtmlNode x, ValueSetExpansionComponent expansion) {
  Map<String, String> versions = new HashMap<String, String>();
  boolean firstVersion = true;
  for (ValueSetExpansionParameterComponent p : expansion.getParameter()) {
    if (p.getName().equals("version")) {
      String[] parts = ((PrimitiveType) p.getValue()).asStringValue().split("\\|");
      if (parts.length == 2)
        versions.put(parts[0], parts[1]);
      if (!versions.isEmpty()) {
        StringBuilder b = new StringBuilder();
        if (firstVersion) {
          // the first version
          // set the <p> tag and style attribute
          x.para().setAttribute("style", "border: black 1px dotted; background-color: #EEEEEE; padding: 8px");
      	  firstVersion = false;
        } else {
          // the second (or greater) version
          x.br(); // add line break before the version text
        }
        b.append("Expansion based on ");
        boolean firstPart = true;
        for (String s : versions.keySet()) {
          if (firstPart)
            firstPart = false;
          else
            b.append(", ");
          if (!s.equals("http://snomed.info/sct"))
            b.append(describeSystem(s)+" version "+versions.get(s));
          else {
            parts = versions.get(s).split("\\/");
            if (parts.length >= 5) {
              String m = describeModule(parts[4]);
              if (parts.length == 7)
                b.append("SNOMED CT "+m+" edition "+formatSCTDate(parts[6]));
              else
                b.append("SNOMED CT "+m+" edition");
            } else
              b.append(describeSystem(s)+" version "+versions.get(s));
          }
        }
        x.addText(b.toString()); // add the version text
      }
    }
  }
}
 
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);
  }
}