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

The following examples show how to use org.hl7.fhir.utilities.xhtml.XhtmlNode#allChildrenAreText() . 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: ProfileDrivenRenderer.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
public void generateResourceSummary(XhtmlNode x, ResourceWrapper res, boolean textAlready, boolean showCodeDetails) 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 = getContext().getWorker().fetchResource(StructureDefinition.class, path);
  if (profile == null)
    x.tx("unknown resource " +path);
  else {
    boolean firstElement = true;
    boolean last = false;
    for (PropertyWrapper p : res.children()) {
      if (!ignoreProperty(p)) {
        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, false) || last;
          }
        }
      }
    }
  }
}
 
Example 2
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 3
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) 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.addText("Generated Summary: ");
  }
  String path = res.getName();
  StructureDefinition profile = context.fetchResource(StructureDefinition.class, path);
  if (profile == null)
    x.addText("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.addText("; ");
        boolean first = true;
        last = false;
        for (BaseWrapper v : p.getValues()) {
          if (first)
            first = false;
          else if (last)
            x.addText(", ");
          last = displayLeaf(res, v, child, x, p.getName(), showCodeDetails) || last;
        }
      }
    }
  }
}
 
Example 4
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) 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) || last;
        }
      }
    }
  }
}
 
Example 5
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) 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.addText("Generated Summary: ");
  }
  String path = res.getName();
  StructureDefinition profile = context.fetchResource(StructureDefinition.class, path);
  if (profile == null)
    x.addText("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.addText("; ");
        boolean first = true;
        last = false;
        for (BaseWrapper v : p.getValues()) {
          if (first)
            first = false;
          else if (last)
            x.addText(", ");
          last = displayLeaf(res, v, child, x, p.getName(), showCodeDetails) || last;
        }
      }
    }
  }
}