org.hl7.fhir.dstu3.model.ElementDefinition Java Examples

The following examples show how to use org.hl7.fhir.dstu3.model.ElementDefinition. 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: ShExGenerator.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
/**
 * Generate a definition for a referenced element
 * @param sd Containing structure definition
 * @param ed Inner element
 * @return ShEx representation of element reference
 */
private String genInnerTypeDef(StructureDefinition sd, ElementDefinition ed) {
  String path = ed.hasBase() ? ed.getBase().getPath() : ed.getPath();;
  ST element_reference = tmplt(SHAPE_DEFINITION_TEMPLATE);
  element_reference.add("resourceDecl", "");  // Not a resource
  element_reference.add("id", path);
  String comment = ed.getShort();
  element_reference.add("comment", comment == null? " " : "# " + comment);

  List<String> elements = new ArrayList<String>();
  for (ElementDefinition child: ProfileUtilities.getChildList(sd, path, null))
    elements.add(genElementDefinition(sd, child));

  element_reference.add("elements", StringUtils.join(elements, "\n"));
  return element_reference.render();
}
 
Example #2
Source File: ProfileUtilities.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private String sliceSummary(ElementDefinition ed) {
  if (!ed.hasSlicing() && !ed.hasSliceName())
    return "";
  if (ed.hasSliceName())
    return " (slicename = "+ed.getSliceName()+")";
  
  StringBuilder b = new StringBuilder();
  boolean first = true;
  for (ElementDefinitionSlicingDiscriminatorComponent d : ed.getSlicing().getDiscriminator()) {
    if (first) 
      first = false;
    else
      b.append("|");
    b.append(d.getPath());
  }
  return " (slicing by "+b.toString()+")";
}
 
Example #3
Source File: StructureMapUtilities.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private void addChildMappings(StringBuilder b, String id, String indent, StructureDefinition sd, ElementDefinition ed, boolean inner) throws DefinitionException {
  boolean first = true;
  List<ElementDefinition> children = ProfileUtilities.getChildMap(sd, ed);
  for (ElementDefinition child : children) {
    if (first && inner) {
      b.append(" then {\r\n");
      first = false;
    }
    String map = getMapping(child, id);
    if (map != null) {
      b.append(indent+"  "+child.getPath()+": "+map);
      addChildMappings(b, id, indent+"  ", sd, child, true);
      b.append("\r\n");
    }
  }
  if (!first && inner)
    b.append(indent+"}");
  
}
 
Example #4
Source File: ProfileUtilities.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
public static List<ElementDefinition> getSliceList(StructureDefinition profile, ElementDefinition element) throws DefinitionException {
  if (!element.hasSlicing())
    throw new Error("getSliceList should only be called when the element has slicing");

  List<ElementDefinition> res = new ArrayList<ElementDefinition>();
  List<ElementDefinition> elements = profile.getSnapshot().getElement();
  String path = element.getPath();
  for (int index = elements.indexOf(element) + 1; index < elements.size(); index++) {
    ElementDefinition e = elements.get(index);
    if (e.getPath().startsWith(path + ".") || e.getPath().equals(path)) {
      // We want elements with the same path (until we hit an element that doesn't start with the same path)
      if (e.getPath().equals(element.getPath()))
        res.add(e);
    } else
      break;
  }
  return res;
}
 
Example #5
Source File: ObjectConverter.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private Element convertElement(Property property, Base base) throws FHIRException {
  if (base == null)
    return null;
  String tn = base.fhirType();
  StructureDefinition sd = context.fetchTypeDefinition(tn);
  if (sd == null)
    throw new FHIRException("Unable to find definition for type "+tn);
  Element res = new Element(property.getName(), property);
  if (sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE) 
    res.setValue(((PrimitiveType) base).asStringValue());

  List<ElementDefinition> children = ProfileUtilities.getChildMap(sd, sd.getSnapshot().getElementFirstRep()); 
  for (ElementDefinition child : children) {
    String n = tail(child.getPath());
    if (sd.getKind() != StructureDefinitionKind.PRIMITIVETYPE || !"value".equals(n)) {
      Base[] values = base.getProperty(n.hashCode(), n, false);
      if (values != null)
        for (Base value : values) {
          res.getChildren().add(convertElement(new Property(context, child, sd), value));
        }
    }
  }
  return res;
}
 
Example #6
Source File: ShExGenerator.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private void addComment(ST tmplt, ElementDefinition ed) {
  if(withComments && ed.hasShort() && !ed.getId().startsWith("Extension.")) {
    int nspaces;
    char[] sep;
    nspaces = Integer.max(COMMENT_COL - tmplt.add("comment", "#").render().indexOf('#'), MIN_COMMENT_SEP);
    tmplt.remove("comment");
    sep = new char[nspaces];
    Arrays.fill(sep, ' ');
    ArrayList<String> comment_lines = split_text(ed.getShort().replace("\n", " "), MAX_CHARS);
    StringBuilder comment = new StringBuilder("# ");
    char[] indent = new char[COMMENT_COL];
    Arrays.fill(indent, ' ');
    for(int i = 0; i < comment_lines.size();) {
      comment.append(comment_lines.get(i++));
      if(i < comment_lines.size())
        comment.append("\n" + new String(indent) + "# ");
    }
    tmplt.add("comment", new String(sep) + comment.toString());
  } else {
    tmplt.add("comment", " ");
  }
}
 
Example #7
Source File: Property.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
public boolean IsLogicalAndHasPrimitiveValue(String name) {
//		if (canBePrimitive!= null)
//			return canBePrimitive;
		
		canBePrimitive = false;
  	if (structure.getKind() != StructureDefinitionKind.LOGICAL)
  		return false;
  	if (!hasType(name))
  		return false;
  	StructureDefinition sd = context.fetchResource(StructureDefinition.class, structure.getUrl().substring(0, structure.getUrl().lastIndexOf("/")+1)+getType(name));
  	if (sd == null)
  	  sd = context.fetchTypeDefinition(getType(name));
    if (sd != null && sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE)
      return true;
  	if (sd == null || sd.getKind() != StructureDefinitionKind.LOGICAL)
  		return false;
  	for (ElementDefinition ed : sd.getSnapshot().getElement()) {
  		if (ed.getPath().equals(sd.getId()+".value") && ed.getType().size() == 1 && isPrimitive(ed.getType().get(0).getCode())) {
  			canBePrimitive = true;
  			return true;
  		}
  	}
  	return false;
	}
 
Example #8
Source File: ProfileUtilities.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private org.hl7.fhir.dstu3.elementmodel.Element createExampleElement(StructureDefinition profile, ElementDefinition ed, ExampleValueAccessor accessor) throws FHIRException {
  Type v = accessor.getExampleValue(ed);
  if (v != null) {
    return new ObjectConverter(context).convert(new Property(context, ed, profile), v);
  } else {
    org.hl7.fhir.dstu3.elementmodel.Element res = new org.hl7.fhir.dstu3.elementmodel.Element(tail(ed.getPath()), new Property(context, ed, profile));
    boolean hasValue = false;
    List<ElementDefinition> children = getChildMap(profile, ed);
    for (ElementDefinition child : children) {
      if (!child.hasContentReference()) {
      org.hl7.fhir.dstu3.elementmodel.Element e = createExampleElement(profile, child, accessor);
      if (e != null) {
        hasValue = true;
        res.getChildren().add(e);
      }
    }
    }
    if (hasValue)
      return res;
    else
      return null;
  }
}
 
Example #9
Source File: QuestionnaireBuilder.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private boolean isExempt(ElementDefinition element, ElementDefinition child) {
  String n = tail(child.getPath());
  String t = "";
  if (!element.getType().isEmpty())
    t =  element.getType().get(0).getCode();

  // we don't generate questions for the base stuff in every element
  if (t.equals("Resource")  && (n.equals("text") || n.equals("language") || n.equals("contained")))
    return true;
    // we don't generate questions for extensions
  else if (n.equals("extension") || n.equals("modifierExtension")) {
    if (child.getType().size() > 0 && !child.getType().get(0).hasProfile()) 
    return false;
    else
      return true;
  } else
    return false;
}
 
Example #10
Source File: ISO21090Importer.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private void produceProperties(List<ElementDefinition> elements, String name, List<Property> properties, boolean attrMode, boolean snapshot) throws FHIRFormatError {
  for (Property p : properties) {
    if (p.isattr == attrMode) {
      ElementDefinition ed = new ElementDefinition();
      elements.add(ed);
      ed.setPath(name+"."+p.name);
      if (p.type.startsWith("xsd:"))
        ToolingExtensions.addStringExtension(ed.addType(), ToolingExtensions.EXT_XML_TYPE, p.type);
      else
        ed.addType().setCode(p.type);
      ed.setMin(p.min);
      ed.setMax(p.max == Integer.MAX_VALUE ? "*" : Integer.toString(p.max));
      ed.setDefinition(p.doco);
      if (p.isattr)
        ed.addRepresentation(PropertyRepresentation.XMLATTR);
      if (p.binding != null)
        ed.getBinding().setStrength(BindingStrength.REQUIRED).setValueSet(new UriType("http://hl7.org/fhir/iso21090/ValueSet/"+p.binding));
      if (snapshot)
        ed.getBase().setPath(ed.getPath()).setMin(ed.getMin()).setMax(ed.getMax());
    }
  }
}
 
Example #11
Source File: ProfileUtilities.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
@Override
public Type getExampleValue(ElementDefinition ed) {
  if (ed.hasFixed())
    return ed.getFixed();
  for (Extension ex : ed.getExtension()) {
   String ndx = ToolingExtensions.readStringExtension(ex, "index");
   Type value = ToolingExtensions.getExtension(ex, "exValue").getValue();
   if (index.equals(ndx) && value != null)
     return value;
  }
  return null;
}
 
Example #12
Source File: ProfileUtilities.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private boolean hasMissingIds(List<ElementDefinition> list) {
  for (ElementDefinition ed : list) {
    if (!ed.hasId())
      return true;
  }    
  return false;
}
 
Example #13
Source File: CareConnectProfileFix.java    From careconnect-reference-implementation with Apache License 2.0 5 votes vote down vote up
public static ElementDefinition fixElement(ElementDefinition element) {

        if (element.hasBinding() && element.getBinding().hasValueSetReference()) {
            // Remove invalid SNOMED reference
            if (element.getBinding().getValueSetReference().getReference().equals("http://snomed.info/sct")) {
                log.info("Removing invalid SNOMED valueSet reference");
                element.setBinding(null);
            } else
            if (removeTooCostlyECL(element.getBinding().getValueSetReference().getReference())) {
                log.info("Removing costly valueSet reference");
                element.setBinding(null);
            }
        }
        if (element.hasBinding() && element.getBinding().hasValueSetUriType()) {
            if (element.getBinding().getValueSetUriType().equals("http://snomed.info/sct")) {
                log.info("Removing invalid SNOMED valueSet reference");
                element.setBinding(null);
            } else
            if (removeTooCostlyECL(element.getBinding().getValueSetUriType().getValue())) {
                log.info("Removing costly valueSet reference");
                element.setBinding(null);
            }
        }

        if (element.hasBinding() && element.getBinding().hasValueSetReference()) {
            // Remove invalid SNOMED reference

        }
        if (element.hasBinding() && element.getBinding().hasValueSetUriType() &&
                element.getBinding().getValueSetUriType().equals("http://snomed.info/sct")) {
                log.info("Removing invalid SNOMED valueSet reference");
                element.setBinding(null);

        }

        return element;
    }
 
Example #14
Source File: QuestionnaireBuilder.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void addCodeQuestions(QuestionnaireItemComponent group, ElementDefinition element, String path, List<QuestionnaireResponse.QuestionnaireResponseItemComponent> answerGroups) throws FHIRException {
  ToolingExtensions.addFhirType(group, "code");
  ValueSet vs = resolveValueSet(null, element.hasBinding() ? element.getBinding() : null);
  addQuestion(group, QuestionnaireItemType.CHOICE, path, "value", unCamelCase(tail(element.getPath())), answerGroups, vs);
  group.setText(null);
  for (QuestionnaireResponse.QuestionnaireResponseItemComponent ag : answerGroups)
    ag.setText(null);
}
 
Example #15
Source File: ProfileUtilitiesTests.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
/**
 * This is simple: we just create an empty differential, generate the snapshot, and then insist it must match the base 
 * 
 * @param context2
 * @
 * @throws EOperationOutcome 
 */
private void testSimple() throws EOperationOutcome, Exception {
  StructureDefinition focus = new StructureDefinition();
  StructureDefinition base = context.fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Patient").copy();
  focus.setUrl(Utilities.makeUuidUrn());
  focus.setBaseDefinition(base.getUrl());
  focus.setType("Patient");
  focus.setDerivation(TypeDerivationRule.CONSTRAINT);
  List<ValidationMessage> messages = new ArrayList<ValidationMessage>();
  new ProfileUtilities(context, messages, null).generateSnapshot(base, focus, focus.getUrl(), "Simple Test");

  boolean ok = base.getSnapshot().getElement().size() == focus.getSnapshot().getElement().size();
  for (int i = 0; i < base.getSnapshot().getElement().size(); i++) {
    if (ok) {
      ElementDefinition b = base.getSnapshot().getElement().get(i);
      ElementDefinition f = focus.getSnapshot().getElement().get(i);
      if (!f.hasBase() || !b.getPath().equals(f.getBase().getPath())) 
        ok = false;
      else {
        f.setBase(null);
        ok = Base.compareDeep(b, f, true);
      }
    }
  }
  
  if (!ok) {
    compareXml(base, focus);
    throw new FHIRException("Snap shot generation simple test failed");
  } else 
    System.out.println("Snap shot generation simple test passed");
}
 
Example #16
Source File: ResourceUtilities.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private static void renderDE(DataElement de, List<String> cols, StringBuilder b, boolean profileLink, String linkBase) {
  b.append("<tr>");
  for (String col : cols) {
    String v;
    ElementDefinition dee = de.getElement().get(0);
    if (col.equals("DataElement.name")) {
      v = de.hasName() ? Utilities.escapeXml(de.getName()) : "";
    } else if (col.equals("DataElement.status")) {
      v = de.hasStatusElement() ? de.getStatusElement().asStringValue() : "";
    } else if (col.equals("DataElement.code")) {
      v = renderCoding(dee.getCode());
    } else if (col.equals("DataElement.type")) {
      v = dee.hasType() ? Utilities.escapeXml(dee.getType().get(0).getCode()) : "";
    } else if (col.equals("DataElement.units")) {
      v = renderDEUnits(ToolingExtensions.getAllowedUnits(dee));
    } else if (col.equals("DataElement.binding")) {
      v = renderBinding(dee.getBinding());
    } else if (col.equals("DataElement.minValue")) {
      v = ToolingExtensions.hasExtension(de, "http://hl7.org/fhir/StructureDefinition/minValue") ? Utilities.escapeXml(ToolingExtensions.readPrimitiveExtension(de, "http://hl7.org/fhir/StructureDefinition/minValue").asStringValue()) : "";
    } else if (col.equals("DataElement.maxValue")) {
      v = ToolingExtensions.hasExtension(de, "http://hl7.org/fhir/StructureDefinition/maxValue") ? Utilities.escapeXml(ToolingExtensions.readPrimitiveExtension(de, "http://hl7.org/fhir/StructureDefinition/maxValue").asStringValue()) : "";
    } else if (col.equals("DataElement.maxLength")) {
      v = ToolingExtensions.hasExtension(de, "http://hl7.org/fhir/StructureDefinition/maxLength") ? Utilities.escapeXml(ToolingExtensions.readPrimitiveExtension(de, "http://hl7.org/fhir/StructureDefinition/maxLength").asStringValue()) : "";
    } else if (col.equals("DataElement.mask")) {
      v = ToolingExtensions.hasExtension(de, "http://hl7.org/fhir/StructureDefinition/mask") ? Utilities.escapeXml(ToolingExtensions.readPrimitiveExtension(de, "http://hl7.org/fhir/StructureDefinition/mask").asStringValue()) : "";
    } else 
      throw new Error("Unknown column name: "+col);

    b.append("<td>"+v+"</td>");
  }
  if (profileLink) {
    b.append("<td><a href=\""+linkBase+"-"+de.getId()+".html\">Profile</a>, <a href=\"http://www.opencem.org/#/20140917/Intermountain/"+de.getId()+"\">CEM</a>");
    if (ToolingExtensions.hasExtension(de, ToolingExtensions.EXT_CIMI_REFERENCE)) 
      b.append(", <a href=\""+ToolingExtensions.readStringExtension(de, ToolingExtensions.EXT_CIMI_REFERENCE)+"\">CIMI</a>");
    b.append("</td>");
  }
  b.append("</tr>\r\n");
}
 
Example #17
Source File: ProfileUtilities.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void copyElements(StructureDefinition sd, List<ElementDefinition> list) {
  for (ElementDefinition ed : list) {
    if (ed.getPath().contains(".")) {
      ElementDefinition n = ed.copy();
      n.setPath(sd.getSnapshot().getElementFirstRep().getPath()+"."+ed.getPath().substring(ed.getPath().indexOf(".")+1));
      sd.getSnapshot().addElement(n);
    }
  }
}
 
Example #18
Source File: ProfileUtilities.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private ElementDefinition getByPath(StructureDefinition base, String path) {
for (ElementDefinition ed : base.getSnapshot().getElement()) {
	if (ed.getPath().equals(path))
		return ed;
	if (ed.getPath().endsWith("[x]") && ed.getPath().length() <= path.length()-3 &&  ed.getPath().substring(0, ed.getPath().length()-3).equals(path.substring(0, ed.getPath().length()-3)))
		return ed;
  }
 return null;
}
 
Example #19
Source File: ProfileUtilities.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private List<ElementDefinition> getChildren(List<ElementDefinition> all, ElementDefinition element) {
  List<ElementDefinition> result = new ArrayList<ElementDefinition>();
  int i = all.indexOf(element)+1;
  while (i < all.size() && all.get(i).getPath().length() > element.getPath().length()) {
    if ((all.get(i).getPath().substring(0, element.getPath().length()+1).equals(element.getPath()+".")) && !all.get(i).getPath().substring(element.getPath().length()+1).contains("."))
      result.add(all.get(i));
    i++;
  }
  return result;
}
 
Example #20
Source File: ProfileComparer.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private boolean ruleEqual(String path, ElementDefinition ed, String vLeft, String vRight, String description, boolean nullOK) {
  if (vLeft == null && vRight == null && nullOK)
    return true;
  if (vLeft == null && vRight == null) {
    messages.add(new ValidationMessage(Source.ProfileComparer, ValidationMessage.IssueType.STRUCTURE, path, description+" and not null (null/null)", ValidationMessage.IssueSeverity.ERROR));
    if (ed != null)
      status(ed, ProfileUtilities.STATUS_ERROR);
  }
  if (vLeft == null || !vLeft.equals(vRight)) {
    messages.add(new ValidationMessage(Source.ProfileComparer, ValidationMessage.IssueType.STRUCTURE, path, description+" ("+vLeft+"/"+vRight+")", ValidationMessage.IssueSeverity.ERROR));
    if (ed != null)
      status(ed, ProfileUtilities.STATUS_ERROR);
  }
  return true;
}
 
Example #21
Source File: ProfileUtilities.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private boolean onlyInformationIsMapping(ElementDefinition d) {
  return !d.hasShort() && !d.hasDefinition() &&
      !d.hasRequirements() && !d.getAlias().isEmpty() && !d.hasMinElement() &&
      !d.hasMax() && !d.getType().isEmpty() && !d.hasContentReference() &&
      !d.hasExample() && !d.hasFixed() && !d.hasMaxLengthElement() &&
      !d.getCondition().isEmpty() && !d.getConstraint().isEmpty() && !d.hasMustSupportElement() &&
      !d.hasBinding();
}
 
Example #22
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
@Override
public List<PropertyWrapper> children() {
  if (list == null) {
    children = ProfileUtilities.getChildList(structure, definition);
    list = new ArrayList<NarrativeGenerator.PropertyWrapper>();
    for (ElementDefinition child : children) {
      List<Element> elements = new ArrayList<Element>();
      XMLUtil.getNamedChildrenWithWildcard(element, tail(child.getPath()), elements);
      list.add(new PropertyWrapperElement(structure, child, elements));
    }
  }
  return list;
}
 
Example #23
Source File: QuestionnaireBuilder.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void addQuantityQuestions(QuestionnaireItemComponent group, ElementDefinition element, String path, List<QuestionnaireResponse.QuestionnaireResponseItemComponent> answerGroups) throws FHIRException {
  ToolingExtensions.addFhirType(group, "Quantity");
  addQuestion(group, QuestionnaireItemType.CHOICE, path, "comparator", "comp:", answerGroups, resolveValueSet("http://hl7.org/fhir/vs/quantity-comparator"));
  addQuestion(group, QuestionnaireItemType.DECIMAL, path, "value", "value:", answerGroups);
  addQuestion(group, QuestionnaireItemType.STRING, path, "units", "units:", answerGroups);
  addQuestion(group, QuestionnaireItemType.STRING, path, "code", "coded units:", answerGroups);
  addQuestion(group, QuestionnaireItemType.STRING, path, "system", "units system:", answerGroups);
}
 
Example #24
Source File: ProfileUtilities.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private String describeCardinality(ElementDefinition definition, ElementDefinition fallback, UnusedTracker tracker) {
  IntegerType min = definition.hasMinElement() ? definition.getMinElement() : new IntegerType();
  StringType max = definition.hasMaxElement() ? definition.getMaxElement() : new StringType();
  if (min.isEmpty() && fallback != null)
    min = fallback.getMinElement();
  if (max.isEmpty() && fallback != null)
    max = fallback.getMaxElement();

  tracker.used = !max.isEmpty() && !max.getValue().equals("0");

  if (min.isEmpty() && max.isEmpty())
    return null;
  else
    return (!min.hasValue() ? "" : Integer.toString(min.getValue())) + ".." + (!max.hasValue() ? "" : max.getValue());
}
 
Example #25
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private boolean exemptFromRendering(ElementDefinition child) {
  if (child == null)
    return false;
  if ("Composition.subject".equals(child.getPath()))
    return true;
  if ("Composition.section".equals(child.getPath()))
    return true;
  return false;
}
 
Example #26
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private boolean includeInSummary(ElementDefinition child) {
  if (child.getIsModifier())
    return true;
  if (child.getMustSupport())
    return true;
  if (child.getType().size() == 1) {
    String t = child.getType().get(0).getCode();
    if (t.equals("Address") || t.equals("Contact") || t.equals("Reference") || t.equals("Uri"))
      return false;
  }
  return true;
}
 
Example #27
Source File: ProfileUtilities.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private ElementDefinition getUrlFor(StructureDefinition ed, ElementDefinition c) {
  int i = ed.getSnapshot().getElement().indexOf(c) + 1;
  while (i < ed.getSnapshot().getElement().size() && ed.getSnapshot().getElement().get(i).getPath().startsWith(c.getPath()+".")) {
    if (ed.getSnapshot().getElement().get(i).getPath().equals(c.getPath()+".url"))
      return ed.getSnapshot().getElement().get(i);
    i++;
  }
  return null;
}
 
Example #28
Source File: ProfileUtilities.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private List<String> listReferenceProfiles(ElementDefinition ed) {
  List<String> res = new ArrayList<String>();
  for (TypeRefComponent tr : ed.getType()) {
    // code is null if we're dealing with "value" and profile is null if we just have Reference()
    if (tr.getCode()!= null && "Reference".equals(tr.getCode()) && tr.getTargetProfile() != null)
      res.add(tr.getTargetProfile());
  }
  return res ;
}
 
Example #29
Source File: QuestionnaireBuilder.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void addDecimalQuestions(QuestionnaireItemComponent group, ElementDefinition element, String path, List<QuestionnaireResponse.QuestionnaireResponseItemComponent> answerGroups) throws FHIRException {
  ToolingExtensions.addFhirType(group, "decimal");
  addQuestion(group, QuestionnaireItemType.DECIMAL, path, "value", group.getText(), answerGroups);
 group.setText(null);
  for (QuestionnaireResponse.QuestionnaireResponseItemComponent ag : answerGroups)
    ag.setText(null);
}
 
Example #30
Source File: QuestionnaireBuilder.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
private void addCodingQuestions(QuestionnaireItemComponent group, ElementDefinition element, String path, List<QuestionnaireResponse.QuestionnaireResponseItemComponent> answerGroups) throws FHIRException {
  ToolingExtensions.addFhirType(group, "Coding");
  addQuestion(group, answerTypeForBinding(element.hasBinding() ? element.getBinding() : null), path, "value", group.getText(), answerGroups, resolveValueSet(null, element.hasBinding() ? element.getBinding() : null));
  group.setText(null);
  for (QuestionnaireResponse.QuestionnaireResponseItemComponent ag : answerGroups)
    ag.setText(null);
}