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

The following examples show how to use org.hl7.fhir.utilities.xhtml.XhtmlNode#addTag() . 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: StructureMapUtilities.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private void analyseGroup(String indent, TransformContext context, StructureMap map, VariablesForProfiling vars, StructureMapGroupComponent group, StructureMapAnalysis result) throws FHIRException {
  log(indent+"Analyse Group : "+group.getName());
  // todo: extends
  // todo: check inputs
  XhtmlNode tr = result.summary.addTag("tr").setAttribute("class", "diff-title");
  XhtmlNode xs = tr.addTag("td");
  XhtmlNode xt = tr.addTag("td");
  for (StructureMapGroupInputComponent inp : group.getInput()) {
    if (inp.getMode() == StructureMapInputMode.SOURCE) 
      noteInput(vars, inp, VariableMode.INPUT, xs);
    if (inp.getMode() == StructureMapInputMode.TARGET) 
      noteInput(vars, inp, VariableMode.OUTPUT, xt);
  }
  for (StructureMapGroupRuleComponent r : group.getRule()) {
    analyseRule(indent+"  ", context, map, vars, group, r, result);
  }    
}
 
Example 2
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private void renderSections(Bundle feed, XhtmlNode node, List<SectionComponent> sections, int level) {
    for (SectionComponent section : sections) {
      node.addTag("hr");
      if (section.hasTitleElement())
        node.addTag("h"+Integer.toString(level)).addText(section.getTitle());
//      else if (section.hasCode())
//        node.addTag("h"+Integer.toString(level)).addText(displayCodeableConcept(section.getCode()));

//      if (section.hasText()) {
//        node.getChildNodes().add(section.getText().getDiv());
//      }
//
//      if (!section.getSection().isEmpty()) {
//        renderSections(feed, node.addTag("blockquote"), section.getSection(), level+1);
//      }
    }
  }
 
Example 3
Source File: StructureMapUtilities.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private void analyseRule(String indent, TransformContext context, StructureMap map, VariablesForProfiling vars, StructureMapGroupComponent group, StructureMapGroupRuleComponent rule, StructureMapAnalysis result) throws FHIRException {
    log(indent+"Analyse rule : "+rule.getName());
    XhtmlNode tr = result.summary.addTag("tr");
    XhtmlNode xs = tr.addTag("td");
    XhtmlNode xt = tr.addTag("td");

    VariablesForProfiling srcVars = vars.copy();
    if (rule.getSource().size() != 1)
      throw new FHIRException("Rule \""+rule.getName()+"\": not handled yet");
    VariablesForProfiling source = analyseSource(rule.getName(), context, srcVars, rule.getSourceFirstRep(), xs);

    TargetWriter tw = new TargetWriter();
      for (StructureMapGroupRuleTargetComponent t : rule.getTarget()) {
      analyseTarget(rule.getName(), context, source, map, t, rule.getSourceFirstRep().getVariable(), tw, result.profiles, rule.getName());
      }
    tw.commit(xt);

          for (StructureMapGroupRuleComponent childrule : rule.getRule()) {
      analyseRule(indent+"  ", context, map, source, group, childrule, result);
          }
//    for (StructureMapGroupRuleDependentComponent dependent : rule.getDependent()) {
//      executeDependency(indent+"  ", context, map, v, group, dependent); // do we need group here?
//    }
          }
 
Example 4
Source File: StructureMapUtilities.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private void analyseGroup(String indent, TransformContext context, StructureMap map, VariablesForProfiling vars, StructureMapGroupComponent group, StructureMapAnalysis result) throws Exception {
  log(indent+"Analyse Group : "+group.getName());
  // todo: extends
  // todo: check inputs
  XhtmlNode tr = result.summary.addTag("tr").setAttribute("class", "diff-title");
  XhtmlNode xs = tr.addTag("td");
  XhtmlNode xt = tr.addTag("td");
  for (StructureMapGroupInputComponent inp : group.getInput()) {
    if (inp.getMode() == StructureMapInputMode.SOURCE) 
      noteInput(vars, inp, VariableMode.INPUT, xs);
    if (inp.getMode() == StructureMapInputMode.TARGET) 
      noteInput(vars, inp, VariableMode.OUTPUT, xt);
  }
  for (StructureMapGroupRuleComponent r : group.getRule()) {
    analyseRule(indent+"  ", context, map, vars, group, r, result);
  }    
}
 
Example 5
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private  <T extends Resource> void addCsRef(ConceptSetComponent inc, XhtmlNode li, T cs) {
  String ref = null;
  if (cs != null) {
    ref = (String) cs.getUserData("filename");
    if (Utilities.noString(ref))
      ref = (String) cs.getUserData("path");
  }
  if (cs != null && ref != null) {
    if (!Utilities.noString(prefix) && ref.startsWith("http://hl7.org/fhir/"))
      ref = ref.substring(20)+"/index.html";
    else if (!ref.endsWith(".html"))
        ref = ref + ".html";
    XhtmlNode a = li.addTag("a");
    a.setAttribute("href", prefix+ref.replace("\\", "/"));
    a.addText(inc.getSystem().toString());
  } else
    li.addText(inc.getSystem().toString());
}
 
Example 6
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private  <T extends Resource> void addCsRef(ConceptSetComponent inc, XhtmlNode li, T cs) {
  String ref = null;
  if (cs != null) {
    ref = (String) cs.getUserData("filename");
    if (Utilities.noString(ref))
      ref = (String) cs.getUserData("path");
  }
  if (cs != null && ref != null) {
    if (!Utilities.noString(prefix) && ref.startsWith("http://hl7.org/fhir/"))
      ref = ref.substring(20)+"/index.html";
    else if (!ref.endsWith(".html"))
        ref = ref + ".html";
    XhtmlNode a = li.addTag("a");
    a.setAttribute("href", prefix+ref.replace("\\", "/"));
    a.addText(inc.getSystem().toString());
  } else
    li.addText(inc.getSystem().toString());
}
 
Example 7
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private void genOpParam(XhtmlNode tbl, String path, OperationDefinitionParameterComponent p) throws EOperationOutcome, FHIRException, IOException {
XhtmlNode tr;
    tr = tbl.addTag("tr");
    tr.addTag("td").addText(p.getUse().toString());
tr.addTag("td").addText(path+p.getName());
    tr.addTag("td").addText(Integer.toString(p.getMin())+".."+p.getMax());
    tr.addTag("td").addText(p.hasType() ? p.getType() : "");
    XhtmlNode td = tr.addTag("td");
    if (p.hasBinding() && p.getBinding().hasValueSet()) {
      if (p.getBinding().getValueSet() instanceof Reference)
        AddVsRef(p.getBinding().getValueSetReference().getReference(), td);
      else
        td.addTag("a").setAttribute("href", p.getBinding().getValueSetUriType().getValue()).addText("External Reference");
      td.addText(" ("+p.getBinding().getStrength().getDisplay()+")");
    }
    addMarkdown(tr.addTag("td"), p.getDocumentation());
    if (!p.hasType()) {
	for (OperationDefinitionParameterComponent pp : p.getPart()) {
		genOpParam(tbl, path+p.getName()+".", pp);
      }
    }
  }
 
Example 8
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void inject(DomainResource r, XhtmlNode x, NarrativeStatus status) {
  if (!r.hasText() || !r.getText().hasDiv() || r.getText().getDiv().getChildNodes().isEmpty()) {
    r.setText(new Narrative());
    r.getText().setDiv(x);
    r.getText().setStatus(status);
  } else {
    XhtmlNode n = r.getText().getDiv();
    n.addTag("hr");
    n.getChildNodes().addAll(x.getChildNodes());
  }
}
 
Example 9
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.addTag("tr");
  if (hasHierarchy)
    tr.addTag("td").addTag("b").addText("Lvl");
  tr.addTag("td").addTag("b").addText("Code");
  if (hasDisplay)
    tr.addTag("td").addTag("b").addText("Display");
  if (definitions)
    tr.addTag("td").addTag("b").addText("Definition");
  if (deprecated)
    tr.addTag("td").addTag("b").addText("Deprecated");
  if (comments)
    tr.addTag("td").addTag("b").addText("Comments");
  return tr;
}
 
Example 10
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.addTag("tr");
  tr.addTag("td").addText(c.getCode());
  for (String lang : langs) {
    ConceptDefinitionDesignationComponent d = null;
    for (ConceptDefinitionDesignationComponent designation : c.getDesignation()) {
      if (lang.equals(designation.getLanguage()))
        d = designation;
    }
    tr.addTag("td").addText(d == null ? "" : d.getValue());
  }
}
 
Example 11
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) {
 for (ConceptMap m : mymaps.keySet()) {
 	XhtmlNode td = tr.addTag("td");
 	XhtmlNode b = td.addTag("b");
 	XhtmlNode a = b.addTag("a");
 	a.setAttribute("href", prefix+mymaps.get(m));
 	a.addText(m.hasDescription() ? m.getDescription() : m.getName());
 }
}
 
Example 12
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.addText(" "+q.getUnit());
  else if (q.hasCode())
    x.addText(" "+q.getCode());
  if (showCodeDetails && q.hasCode()) {
    XhtmlNode sp = x.addTag("span");
    sp.setAttribute("style", "background: LightGoldenRodYellow ");
    sp.addText(" (Details: "+describeSystem(q.getSystem())+" code "+q.getCode()+" = '"+lookupCode(q.getSystem(), q.getCode())+"')");
  }
}
 
Example 13
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void inject(DomainResource r, XhtmlNode x, NarrativeStatus status) {
  if (!r.hasText() || !r.getText().hasDiv() || r.getText().getDiv().getChildNodes().isEmpty()) {
    r.setText(new Narrative());
    r.getText().setDiv(x);
    r.getText().setStatus(status);
  } else {
    XhtmlNode n = r.getText().getDiv();
    n.addTag("hr");
    n.getChildNodes().addAll(x.getChildNodes());
  }
}
 
Example 14
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.addText(" "+q.getUnit());
  else if (q.hasCode())
    x.addText(" "+q.getCode());
  if (showCodeDetails && q.hasCode()) {
    XhtmlNode sp = x.addTag("span");
    sp.setAttribute("style", "background: LightGoldenRodYellow ");
    sp.addText(" (Details: "+describeSystem(q.getSystem())+" code "+q.getCode()+" = '"+lookupCode(q.getSystem(), q.getCode())+"')");
  }
}
 
Example 15
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public void generate(OperationDefinition opd) throws EOperationOutcome, FHIRException, IOException {
   XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
   x.addTag("h2").addText(opd.getName());
   x.addTag("p").addText(Utilities.capitalize(opd.getKind().toString())+": "+opd.getName());
   addMarkdown(x, opd.getDescription());

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

   x.addTag("p").addText("Parameters");
   XhtmlNode tbl = x.addTag("table").setAttribute("class", "grid");
   XhtmlNode tr = tbl.addTag("tr");
   tr.addTag("td").addTag("b").addText("Use");
   tr.addTag("td").addTag("b").addText("Name");
   tr.addTag("td").addTag("b").addText("Cardinality");
   tr.addTag("td").addTag("b").addText("Type");
   tr.addTag("td").addTag("b").addText("Binding");
   tr.addTag("td").addTag("b").addText("Documentation");
   for (OperationDefinitionParameterComponent p : opd.getParameter()) {
     genOpParam(tbl, "", p);
   }
   addMarkdown(x, opd.getComment());
   inject(opd, x, NarrativeStatus.GENERATED);
}
 
Example 16
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
public void generate(Conformance conf) {
  XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
  x.addTag("h2").addText(conf.getName());
  smartAddText(x.addTag("p"), conf.getDescription());
  ConformanceRestComponent rest = conf.getRest().get(0);
  XhtmlNode t = x.addTag("table");
  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.addTag("table");
  XhtmlNode tr = t.addTag("tr");
  tr.addTag("th").addTag("b").addText("Resource Type");
  tr.addTag("th").addTag("b").addText("Profile");
  tr.addTag("th").addTag("b").addText("Read");
  tr.addTag("th").addTag("b").addText("V-Read");
  tr.addTag("th").addTag("b").addText("Search");
  tr.addTag("th").addTag("b").addText("Update");
  tr.addTag("th").addTag("b").addText("Updates");
  tr.addTag("th").addTag("b").addText("Create");
  tr.addTag("th").addTag("b").addText("Delete");
  tr.addTag("th").addTag("b").addText("History");

  for (ConformanceRestResourceComponent r : rest.getResource()) {
    tr = t.addTag("tr");
    tr.addTag("td").addText(r.getType());
    if (r.hasProfile()) {
    	XhtmlNode a = tr.addTag("td").addTag("a");
    	a.addText(r.getProfile().getReference());
    	a.setAttribute("href", prefix+r.getProfile().getReference());
    }
    tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.READ));
    tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.VREAD));
    tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.SEARCHTYPE));
    tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.UPDATE));
    tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.HISTORYINSTANCE));
    tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.CREATE));
    tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.DELETE));
    tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.HISTORYTYPE));
  }

  inject(conf, x, NarrativeStatus.GENERATED);
}
 
Example 17
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
private void generateCopyright(XhtmlNode x, CodeSystem cs) {
  XhtmlNode p = x.addTag("p");
  p.addTag("b").addText("Copyright Statement:");
  smartAddText(p, " " + cs.getCopyright());
}
 
Example 18
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
public void generate(Conformance conf) {
  XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
  x.addTag("h2").addText(conf.getName());
  smartAddText(x.addTag("p"), conf.getDescription());
  ConformanceRestComponent rest = conf.getRest().get(0);
  XhtmlNode t = x.addTag("table");
  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.addTag("table");
  XhtmlNode tr = t.addTag("tr");
  tr.addTag("th").addTag("b").addText("Resource Type");
  tr.addTag("th").addTag("b").addText("Profile");
  tr.addTag("th").addTag("b").addText("Read");
  tr.addTag("th").addTag("b").addText("V-Read");
  tr.addTag("th").addTag("b").addText("Search");
  tr.addTag("th").addTag("b").addText("Update");
  tr.addTag("th").addTag("b").addText("Updates");
  tr.addTag("th").addTag("b").addText("Create");
  tr.addTag("th").addTag("b").addText("Delete");
  tr.addTag("th").addTag("b").addText("History");

  for (ConformanceRestResourceComponent r : rest.getResource()) {
    tr = t.addTag("tr");
    tr.addTag("td").addText(r.getType());
    if (r.hasProfile()) {
    	XhtmlNode a = tr.addTag("td").addTag("a");
    	a.addText(r.getProfile().getReference());
    	a.setAttribute("href", prefix+r.getProfile().getReference());
    }
    tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.READ));
    tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.VREAD));
    tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.SEARCHTYPE));
    tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.UPDATE));
    tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.HISTORYINSTANCE));
    tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.CREATE));
    tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.DELETE));
    tr.addTag("td").addText(showOp(r, TypeRestfulInteraction.HISTORYTYPE));
  }

  inject(conf, x, NarrativeStatus.GENERATED);
}
 
Example 19
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
private boolean generateExpansion(XhtmlNode x, ValueSet vs, ValueSet src, boolean header) {
  boolean hasExtensions = false;
  Map<ConceptMap, String> mymaps = new HashMap<ConceptMap, String>();
  for (ConceptMap a : context.findMapsForSource(vs.getUrl())) {
      String url = "";
      ValueSet vsr = context.fetchResource(ValueSet.class, ((Reference) a.getTarget()).getReference());
      if (vsr != null)
          url = (String) vsr.getUserData("filename");
      mymaps.put(a, url);
    }

  if (header) {
    XhtmlNode h = x.addTag("h3");
    h.addText("Value Set Contents");
    if (IsNotFixedExpansion(vs))
      x.addTag("p").addText(vs.getDescription());
    if (vs.hasCopyright())
      generateCopyright(x, vs);
  }
  if (ToolingExtensions.hasExtension(vs.getExpansion(), "http://hl7.org/fhir/StructureDefinition/valueset-toocostly"))
    x.addTag("p").setAttribute("style", "border: maroon 1px solid; background-color: #FFCCCC; font-weight: bold; padding: 8px").addText(tooCostlyNote);
  else {
    Integer count = countMembership(vs);
    if (count == null)
      x.addTag("p").addText("This value set does not contain a fixed number of concepts");
    else
      x.addTag("p").addText("This value set contains "+count.toString()+" concepts");
  }

  CodeSystem allCS = null;
  boolean doSystem = checkDoSystem(vs, src);
  boolean doDefinition = checkDoDefinition(vs.getExpansion().getContains());
  if (doSystem && allFromOneSystem(vs)) {
    doSystem = false;
    XhtmlNode p = x.addTag("p");
    p.addText("All codes from system ");
    allCS = context.fetchCodeSystem(vs.getExpansion().getContains().get(0).getSystem());
    String ref = null;
    if (allCS != null)
      ref = getCsRef(allCS);
    if (ref == null) 
    p.addTag("code").addText(vs.getExpansion().getContains().get(0).getSystem());
    else
      p.addTag("a").setAttribute("href", ref).addTag("code").addText(vs.getExpansion().getContains().get(0).getSystem());
  }
  XhtmlNode t = x.addTag("table").setAttribute("class", "codes");
  XhtmlNode tr = t.addTag("tr");
  tr.addTag("td").addTag("b").addText("Code");
  if (doSystem)
    tr.addTag("td").addTag("b").addText("System");
  tr.addTag("td").addTag("b").addText("Display");
  if (doDefinition)
    tr.addTag("td").addTag("b").addText("Definition");

  addMapHeaders(tr, mymaps);
  for (ValueSetExpansionContainsComponent c : vs.getExpansion().getContains()) {
    addExpansionRowToTable(t, c, 0, doSystem, doDefinition, mymaps, allCS);
  }
  return hasExtensions;
}
 
Example 20
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
private void generateCopyright(XhtmlNode x, ValueSet vs) {
  XhtmlNode p = x.addTag("p");
  p.addTag("b").addText("Copyright Statement:");
  smartAddText(p, " " + vs.getCopyright());
}