Package ca.uhn.fhir.model.dstu.composite

Examples of ca.uhn.fhir.model.dstu.composite.NarrativeDt


  private void encodeCompositeElementChildrenToStreamWriter(RuntimeResourceDefinition theResDef, IResource theResource, IElement theElement, JsonGenerator theEventWriter, List<? extends BaseRuntimeChildDefinition> theChildren) throws IOException {
    for (BaseRuntimeChildDefinition nextChild : theChildren) {
      if (nextChild instanceof RuntimeChildNarrativeDefinition) {
        INarrativeGenerator gen = myContext.getNarrativeGenerator();
        if (gen != null) {
          NarrativeDt narr = gen.generateNarrative(theResDef.getResourceProfile(), theResource);
          if (narr != null) {
            RuntimeChildNarrativeDefinition child = (RuntimeChildNarrativeDefinition) nextChild;
            String childName = nextChild.getChildNameByDatatype(child.getDatatype());
            BaseRuntimeElementDefinition<?> type = child.getChildByName(childName);
            encodeChildElementToStreamWriter(theResDef, theResource, theEventWriter, narr, type, childName);
View Full Code Here


      List<? extends BaseRuntimeChildDefinition> children, boolean theIncludedResource) throws XMLStreamException, DataFormatException {
    for (BaseRuntimeChildDefinition nextChild : children) {
      if (nextChild instanceof RuntimeChildNarrativeDefinition && !theIncludedResource) {
        INarrativeGenerator gen = myContext.getNarrativeGenerator();
        if (gen != null) {
          NarrativeDt narr = gen.generateNarrative(theResDef.getResourceProfile(), theResource);
          if (narr != null) {
            RuntimeChildNarrativeDefinition child = (RuntimeChildNarrativeDefinition) nextChild;
            String childName = nextChild.getChildNameByDatatype(child.getDatatype());
            BaseRuntimeElementDefinition<?> type = child.getChildByName(childName);
            encodeChildElementToStreamWriter(theResDef, theResource, theEventWriter, narr, childName, type, null, theIncludedResource);
View Full Code Here

  }

  @Override
  public NarrativeDt getText() {
    if (myText == null) {
      myText = new NarrativeDt();
    }
    return myText;
  }
View Full Code Here

    }

    if (name == null) {
      if (myIgnoreMissingTemplates) {
        ourLog.debug("No narrative template available for profile: {}", theProfile);
        return new NarrativeDt(new XhtmlDt("<div>No narrative template available for resource profile: " + theProfile + "</div>"), NarrativeStatusEnum.EMPTY);
      } else {
        throw new DataFormatException("No narrative template for class " + theResource.getClass().getCanonicalName());
      }
    }

    try {
      Context context = new Context();
      context.setVariable("resource", theResource);

      String result = myProfileTemplateEngine.process(name, context);

      if (myCleanWhitespace) {
        ourLog.trace("Pre-whitespace cleaning: ", result);
        result = cleanWhitespace(result);
        ourLog.trace("Post-whitespace cleaning: ", result);
      }

      XhtmlDt div = new XhtmlDt(result);
      return new NarrativeDt(div, NarrativeStatusEnum.GENERATED);
    } catch (Exception e) {
      if (myIgnoreFailures) {
        ourLog.error("Failed to generate narrative", e);
        return new NarrativeDt(new XhtmlDt("<div>No narrative available - Error: " + e.getMessage() + "</div>"), NarrativeStatusEnum.EMPTY);
      } else {
        throw new DataFormatException(e);
      }
    }
  }
View Full Code Here

  private void encodeCompositeElementChildrenToStreamWriter(RuntimeResourceDefinition theResDef, IResource theResource, IElement theElement, XMLStreamWriter theEventWriter,
      List<? extends BaseRuntimeChildDefinition> children, boolean theIncludedResource) throws XMLStreamException, DataFormatException {
    for (BaseRuntimeChildDefinition nextChild : children) {
      if (nextChild instanceof RuntimeChildNarrativeDefinition && !theIncludedResource) {
        INarrativeGenerator gen = myContext.getNarrativeGenerator();
        NarrativeDt narr = theResource.getText();
        if (gen != null && narr.isEmpty()) {
          narr = gen.generateNarrative(theResDef.getResourceProfile(), theResource);
        }
        if (narr != null) {
          RuntimeChildNarrativeDefinition child = (RuntimeChildNarrativeDefinition) nextChild;
          String childName = nextChild.getChildNameByDatatype(child.getDatatype());
View Full Code Here

      List<? extends BaseRuntimeChildDefinition> theChildren) throws IOException {
    for (BaseRuntimeChildDefinition nextChild : theChildren) {
      if (nextChild instanceof RuntimeChildNarrativeDefinition) {
        INarrativeGenerator gen = myContext.getNarrativeGenerator();
        if (gen != null) {
          NarrativeDt narr = gen.generateNarrative(theResDef.getResourceProfile(), theResource);
          if (narr != null) {
            RuntimeChildNarrativeDefinition child = (RuntimeChildNarrativeDefinition) nextChild;
            String childName = nextChild.getChildNameByDatatype(child.getDatatype());
            BaseRuntimeElementDefinition<?> type = child.getChildByName(childName);
            encodeChildElementToStreamWriter(theResDef, theResource, theEventWriter, narr, type, childName);
View Full Code Here

  }

  @Override
  public NarrativeDt getText() {
    if (myText == null) {
      myText = new NarrativeDt();
    }
    return myText;
  }
View Full Code Here

    }

    if (name == null) {
      if (myIgnoreMissingTemplates) {
        ourLog.debug("No narrative template available for profile: {}", theProfile);
        return new NarrativeDt(new XhtmlDt("<div>No narrative template available for resource profile: " + theProfile + "</div>"), NarrativeStatusEnum.EMPTY);
      } else {
        throw new DataFormatException("No narrative template for class " + theResource.getClass().getCanonicalName());
      }
    }

    try {
      Context context = new Context();
      context.setVariable("resource", theResource);

      String result = myProfileTemplateEngine.process(name, context);

      if (myCleanWhitespace) {
        ourLog.trace("Pre-whitespace cleaning: ", result);
        result = cleanWhitespace(result);
        ourLog.trace("Post-whitespace cleaning: ", result);
      }

      XhtmlDt div = new XhtmlDt(result);
      return new NarrativeDt(div, NarrativeStatusEnum.GENERATED);
    } catch (Exception e) {
      if (myIgnoreFailures) {
        ourLog.error("Failed to generate narrative", e);
        return new NarrativeDt(new XhtmlDt("<div>No narrative available - Error: " + e.getMessage() + "</div>"), NarrativeStatusEnum.EMPTY);
      } else {
        throw new DataFormatException(e);
      }
    }
  }
View Full Code Here

    }

    if (name == null) {
      if (myIgnoreMissingTemplates) {
        ourLog.debug("No narrative template available for profile: {}", theProfile);
        return new NarrativeDt(new XhtmlDt("<div>No narrative template available for resource profile: " + theProfile + "</div>"), NarrativeStatusEnum.EMPTY);
      } else {
        throw new DataFormatException("No narrative template for class " + theResource.getClass().getCanonicalName());
      }
    }

    try {
      Context context = new Context();
      context.setVariable("resource", theResource);
     
      String result = myProfileTemplateEngine.process(name, context);

      if (myCleanWhitespace) {
        ourLog.trace("Pre-whitespace cleaning: ", result);
        result = cleanWhitespace(result);
        ourLog.trace("Post-whitespace cleaning: ", result);
      }

      XhtmlDt div = new XhtmlDt(result);
      return new NarrativeDt(div, NarrativeStatusEnum.GENERATED);
    } catch (Exception e) {
      if (myIgnoreFailures) {
        ourLog.error("Failed to generate narrative", e);
        return new NarrativeDt(new XhtmlDt("<div>No narrative available - Error: " + e.getMessage() + "</div>"), NarrativeStatusEnum.EMPTY);
      } else {
        throw new DataFormatException(e);
      }
    }
  }
View Full Code Here

      throws XMLStreamException, DataFormatException {
    for (BaseRuntimeChildDefinition nextChild : children) {
      if (nextChild instanceof RuntimeChildNarrativeDefinition && !theIncludedResource) {
        INarrativeGenerator gen = myContext.getNarrativeGenerator();
        if (gen != null) {
          NarrativeDt narr = gen.generateNarrative(theResDef.getResourceProfile(), theResource);
          if (narr != null) {
            RuntimeChildNarrativeDefinition child = (RuntimeChildNarrativeDefinition) nextChild;
            String childName = nextChild.getChildNameByDatatype(child.getDatatype());
            BaseRuntimeElementDefinition<?> type = child.getChildByName(childName);
            encodeChildElementToStreamWriter(theResDef, theResource, theEventWriter, narr, childName, type, null, theIncludedResource);
View Full Code Here

TOP

Related Classes of ca.uhn.fhir.model.dstu.composite.NarrativeDt

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.