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

The following examples show how to use org.hl7.fhir.utilities.xhtml.XhtmlNode#tr() . 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: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private void addLanguageRow(ValueSetExpansionContainsComponent c, XhtmlNode t, List<String> langs) {
  XhtmlNode tr = t.tr();
  tr.td().addText(c.getCode());
  for (String lang : langs) {
    String d = null;
    for (Extension ext : c.getExtension()) {
      if (ToolingExtensions.EXT_TRANSLATION.equals(ext.getUrl())) {
        String l = ToolingExtensions.readStringExtension(ext, "lang");
        if (lang.equals(l))
          d = ToolingExtensions.readStringExtension(ext, "content");
      }
    }
    tr.td().addText(d == null ? "" : d);
  }
  for (ValueSetExpansionContainsComponent cc : c.getContains()) {
    addLanguageRow(cc, t, langs);
  }
}
 
Example 2
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private void addLanguageRow(ValueSetExpansionContainsComponent c, XhtmlNode t, List<String> langs) {
  XhtmlNode tr = t.tr();
  tr.td().addText(c.getCode());
  for (String lang : langs) {
    String d = null;
    for (Extension ext : c.getExtension()) {
      if (ToolingExtensions.EXT_TRANSLATION.equals(ext.getUrl())) {
        String l = ToolingExtensions.readStringExtension(ext, "lang");
        if (lang.equals(l))
          d = ToolingExtensions.readStringExtension(ext, "content");;
      }
    }
    tr.td().addText(d == null ? "" : d);
  }
  for (ValueSetExpansionContainsComponent cc : c.getContains()) {
    addLanguageRow(cc, t, langs);
  }
}
 
Example 3
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public boolean generate(ResourceContext rcontext, OperationDefinition opd) throws EOperationOutcome, FHIRException, IOException {
   XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
   x.h2().addText(opd.getName());
   x.para().addText(Utilities.capitalize(opd.getKind().toString())+": "+opd.getName());
   x.para().tx("The official URL for this operation definition is: ");
   x.pre().tx(opd.getUrl());
   addMarkdown(x, opd.getDescription());

   if (opd.getSystem())
     x.para().tx("URL: [base]/$"+opd.getCode());
   for (CodeType c : opd.getResource()) {
     if (opd.getType())
       x.para().tx("URL: [base]/"+c.getValue()+"/$"+opd.getCode());
     if (opd.getInstance())
       x.para().tx("URL: [base]/"+c.getValue()+"/[id]/$"+opd.getCode());
   }

   x.para().tx("Parameters");
   XhtmlNode tbl = x.table( "grid");
   XhtmlNode tr = tbl.tr();
   tr.td().b().tx("Use");
   tr.td().b().tx("Name");
   tr.td().b().tx("Cardinality");
   tr.td().b().tx("Type");
   tr.td().b().tx("Binding");
   tr.td().b().tx("Documentation");
   for (OperationDefinitionParameterComponent p : opd.getParameter()) {
     genOpParam(rcontext, tbl, "", p);
   }
   addMarkdown(x, opd.getComment());
   inject(opd, x, NarrativeStatus.GENERATED);
   return true;
}
 
Example 4
Source File: CapabilityStatementUtilities.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private XhtmlNode startTable(XhtmlNode x, CapabilityStatement self, CapabilityStatement other) {
  XhtmlNode tbl = x.table("grid");    
  XhtmlNode tr = tbl.tr();
  tr.td().b().nbsp();
  tr.td().b().addText(selfName);
  tr.td().b().addText(otherName);
  tr.td().b().addText("Comparison");
  return tbl;
}
 
Example 5
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private XhtmlNode addTableHeaderRowStandard(XhtmlNode t, boolean hasHierarchy, boolean hasDisplay, boolean definitions, boolean comments, boolean deprecated) {
  XhtmlNode tr = t.tr();
  if (hasHierarchy)
    tr.td().b().tx("Lvl");
  tr.td().b().tx("Code");
  if (hasDisplay)
    tr.td().b().tx("Display");
  if (definitions)
    tr.td().b().tx("Definition");
  if (deprecated)
    tr.td().b().tx("Deprecated");
  if (comments)
    tr.td().b().tx("Comments");
  return tr;
}
 
Example 6
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void addObservationToTable(XhtmlNode tbl, ObservationNode o, int i) {
  XhtmlNode tr = tbl.tr();
  if (o.obs == null) {
    XhtmlNode td = tr.td().colspan("6");
    td.i().tx("This Observation could not be resolved");
  } else {
    addObservationToTable(tr, o.obs, i);
    // todo: contained observations
  }
  for (ObservationNode c : o.contained) {
    addObservationToTable(tbl, c, i+1);
  }
}
 
Example 7
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void addObservationToTable(XhtmlNode tbl, ObservationNode o, int i) {
  XhtmlNode tr = tbl.tr();
  if (o.obs == null) {
    XhtmlNode td = tr.td().colspan("6");
    td.i().tx("This Observation could not be resolved");
  } else {
    addObservationToTable(tr, o.obs, i);
    // todo: contained observations
  }
  for (ObservationNode c : o.contained) {
    addObservationToTable(tbl, c, i+1);
  }
}
 
Example 8
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void addLanguageRow(ConceptReferenceComponent c, XhtmlNode t, List<String> langs) {
  XhtmlNode tr = t.tr();
  tr.td().addText(c.getCode());
  for (String lang : langs) {
    String d = null;
    for (ConceptReferenceDesignationComponent cd : c.getDesignation()) {
      String l = cd.getLanguage();
      if (lang.equals(l))
        d = cd.getValue();
    }
    tr.td().addText(d == null ? "" : d);
  }
}
 
Example 9
Source File: QuestionnaireRenderer.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void defn(XhtmlNode tbl, String name, String value, String url) {
  if (!Utilities.noString(value)) {
    XhtmlNode tr = tbl.tr();
    tr.td().tx(name);
    tr.td().ah(url).tx(value);
  }    
}
 
Example 10
Source File: QuestionnaireRenderer.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void defn(XhtmlNode tbl, String name, String nurl, String value, String url) {
  if (!Utilities.noString(value)) {
    XhtmlNode tr = tbl.tr();
    tr.td().ah(nurl).tx(name);
    if (url != null) {
      tr.td().ah(url).tx(value);
    } else {
      tr.td().tx(value);
    }
  }    
}
 
Example 11
Source File: ResourceComparer.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public XhtmlNode renderErrors(ResourceComparison csc) {
  XhtmlNode div = new XhtmlNode(NodeType.Element, "div");
  XhtmlNode tbl = div.table("grid");
  for (ValidationMessage vm : csc.messages) {
    XhtmlNode tr = tbl.tr();
    tr.style("background-color: "+colorForLevel(vm.getLevel()));
    tr.td().tx(vm.getLocation());
    tr.td().tx(vm.getMessage());
    tr.td().tx(vm.getLevel().getDisplay());
  }
  return div;
}
 
Example 12
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void addLanguageRow(ConceptReferenceComponent c, XhtmlNode t, List<String> langs) {
  XhtmlNode tr = t.tr();
  tr.td().addText(c.getCode());
  for (String lang : langs) {
    String d = null;
    for (ConceptReferenceDesignationComponent cd : c.getDesignation()) {
      String l = cd.getLanguage();
      if (lang.equals(l))
        d = cd.getValue();
    }
    tr.td().addText(d == null ? "" : d);
  }
}
 
Example 13
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void addLanguageRow(ConceptDefinitionComponent c, XhtmlNode t, List<String> langs) {
  XhtmlNode tr = t.tr();
  tr.td().addText(c.getCode());
  for (String lang : langs) {
    ConceptDefinitionDesignationComponent d = null;
    for (ConceptDefinitionDesignationComponent designation : c.getDesignation()) {
      if (lang.equals(designation.getLanguage()))
        d = designation;
    }
    tr.td().addText(d == null ? "" : d.getValue());
  }
}
 
Example 14
Source File: OperationDefinitionRenderer.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public boolean render(XhtmlNode x, OperationDefinition opd) throws IOException, FHIRException, EOperationOutcome {
  x.h2().addText(opd.getName());
  x.para().addText(Utilities.capitalize(opd.getKind().toString())+": "+opd.getName());
  x.para().tx("The official URL for this operation definition is: ");
  x.pre().tx(opd.getUrl());
  addMarkdown(x, opd.getDescription());

  if (opd.getSystem())
    x.para().tx("URL: [base]/$"+opd.getCode());
  for (CodeType c : opd.getResource()) {
    if (opd.getType())
      x.para().tx("URL: [base]/"+c.getValue()+"/$"+opd.getCode());
    if (opd.getInstance())
      x.para().tx("URL: [base]/"+c.getValue()+"/[id]/$"+opd.getCode());
  }

  x.para().tx("Parameters");
  XhtmlNode tbl = x.table( "grid");
  XhtmlNode tr = tbl.tr();
  tr.td().b().tx("Use");
  tr.td().b().tx("Name");
  tr.td().b().tx("Cardinality");
  tr.td().b().tx("Type");
  tr.td().b().tx("Binding");
  tr.td().b().tx("Documentation");
  for (OperationDefinitionParameterComponent p : opd.getParameter()) {
    genOpParam(tbl, "", p);
  }
  addMarkdown(x, opd.getComment());
  return true;
}
 
Example 15
Source File: ValueSetRenderer.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void addLanguageRow(ConceptReferenceComponent c, XhtmlNode t, List<String> langs) {
  XhtmlNode tr = t.tr();
  tr.td().addText(c.getCode());
  for (String lang : langs) {
    String d = null;
    for (ConceptReferenceDesignationComponent cd : c.getDesignation()) {
      String l = cd.getLanguage();
      if (lang.equals(l))
        d = cd.getValue();
    }
    tr.td().addText(d == null ? "" : d);
  }
}
 
Example 16
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
private void addTableRow(XhtmlNode t, String name, String value) {
  XhtmlNode tr = t.tr();
  tr.td().addText(name);
  tr.td().addText(value);
}
 
Example 17
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 18
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);
  }
}
 
Example 19
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
public boolean generate(ResourceContext rcontext, CapabilityStatement conf) throws FHIRFormatError, DefinitionException, IOException {
  XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
  x.h2().addText(conf.getName());
  addMarkdown(x, conf.getDescription());
  if (conf.getRest().size() > 0) {
    CapabilityStatementRestComponent rest = conf.getRest().get(0);
    XhtmlNode t = x.table(null);
    addTableRow(t, "Mode", rest.getMode().toString());
    addTableRow(t, "Description", rest.getDocumentation());

    addTableRow(t, "Transaction", showOp(rest, SystemRestfulInteraction.TRANSACTION));
    addTableRow(t, "System History", showOp(rest, SystemRestfulInteraction.HISTORYSYSTEM));
    addTableRow(t, "System Search", showOp(rest, SystemRestfulInteraction.SEARCHSYSTEM));

    t = x.table(null);
    XhtmlNode tr = t.tr();
    tr.th().b().tx("Resource Type");
    tr.th().b().tx("Profile");
    tr.th().b().tx("Read");
    tr.th().b().tx("V-Read");
    tr.th().b().tx("Search");
    tr.th().b().tx("Update");
    tr.th().b().tx("Updates");
    tr.th().b().tx("Create");
    tr.th().b().tx("Delete");
    tr.th().b().tx("History");

    for (CapabilityStatementRestResourceComponent r : rest.getResource()) {
      tr = t.tr();
      tr.td().addText(r.getType());
      if (r.hasProfile()) {
        tr.td().ah(prefix+r.getProfile().getReference()).addText(r.getProfile().getReference());
      }
      tr.td().addText(showOp(r, TypeRestfulInteraction.READ));
      tr.td().addText(showOp(r, TypeRestfulInteraction.VREAD));
      tr.td().addText(showOp(r, TypeRestfulInteraction.SEARCHTYPE));
      tr.td().addText(showOp(r, TypeRestfulInteraction.UPDATE));
      tr.td().addText(showOp(r, TypeRestfulInteraction.HISTORYINSTANCE));
      tr.td().addText(showOp(r, TypeRestfulInteraction.CREATE));
      tr.td().addText(showOp(r, TypeRestfulInteraction.DELETE));
      tr.td().addText(showOp(r, TypeRestfulInteraction.HISTORYTYPE));
    }
  }

  inject(conf, x, NarrativeStatus.GENERATED);
  return true;
}
 
Example 20
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;
}