Java Code Examples for org.hl7.fhir.dstu3.model.ElementDefinition#hasBinding()

The following examples show how to use org.hl7.fhir.dstu3.model.ElementDefinition#hasBinding() . 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: ProfileUtilities.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
/**
 * Finds internal references in an Element's Binding and StructureDefinition references (in TypeRef) and bases them on the given url
 * @param url - the base url to use to turn internal references into absolute references
 * @param element - the Element to update
 * @return - the updated Element
 */
private ElementDefinition updateURLs(String url, ElementDefinition element) {
  if (element != null) {
    ElementDefinition defn = element;
    if (defn.hasBinding() && defn.getBinding().getValueSet() instanceof Reference && ((Reference)defn.getBinding().getValueSet()).getReference().startsWith("#"))
      ((Reference)defn.getBinding().getValueSet()).setReference(url+((Reference)defn.getBinding().getValueSet()).getReference());
    for (TypeRefComponent t : defn.getType()) {
      if (t.hasProfile()) {
        if (t.getProfile().startsWith("#"))
          t.setProfile(url+t.getProfile());
      }
      if (t.hasTargetProfile()) {
        if (t.getTargetProfile().startsWith("#"))
          t.setTargetProfile(url+t.getTargetProfile());
      }
    }
  }
  return element;
}
 
Example 2
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 3
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 4
Source File: CSVWriter.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
public void processElement(ElementDefinition ed) throws Exception {
  CSVLine line = new CSVLine();
  lines.add(line);
  line.addString(ed.getPath());
  line.addString(ed.getSliceName());
  line.addString(itemList(ed.getAlias()));
  line.addString(ed.getLabel());
  line.addValue(ed.getMin());
  line.addValue(ed.getMax());
  line.addString(ed.getMustSupport() ? "Y" : "");
  line.addString(ed.getIsModifier() ? "Y" : "");
  line.addString(ed.getIsSummary() ? "Y" : "");
  line.addString(itemList(ed.getType()));
  line.addString(ed.getShort());
  line.addString(ed.getDefinition());
  line.addString(ed.getComment());
  line.addString(ed.getRequirements());
  line.addString(ed.getDefaultValue()!=null ? renderType(ed.getDefaultValue()) : "");
  line.addString(ed.getMeaningWhenMissing());
  line.addString(ed.hasFixed() ? renderType(ed.getFixed()) : "");
  line.addString(ed.hasPattern() ? renderType(ed.getPattern()) : "");
  line.addString(ed.hasExample() ? renderType(ed.getExample().get(0).getValue()) : ""); // todo...?
  line.addString(ed.hasMinValue() ? renderType(ed.getMinValue()) : "");
  line.addString(ed.hasMaxValue() ? renderType(ed.getMaxValue()) : "");
  line.addValue((ed.hasMaxLength() ? Integer.toString(ed.getMaxLength()) : ""));
  if (ed.hasBinding()) {
    line.addString(ed.getBinding().getStrength()!=null ? ed.getBinding().getStrength().toCode() : "");
    line.addString(ed.getBinding().getDescription());
    if (ed.getBinding().getValueSet()==null)
      line.addString("");
    else if (ed.getBinding().getValueSet() instanceof Reference)
    line.addString(ed.getBinding().getValueSetReference().getReference());
    else
    line.addString(ed.getBinding().getValueSetUriType().getValue());
  } else {
    line.addValue("");
    line.addValue("");
    line.addValue("");
  }
  line.addString(itemList(ed.getCode()));
  if (ed.hasSlicing()) {
    line.addString(itemList(ed.getSlicing().getDiscriminator()));
    line.addString(ed.getSlicing().getDescription());
    line.addBoolean(ed.getSlicing().getOrdered());
    line.addString(ed.getSlicing().getRules()!=null ? ed.getSlicing().getRules().toCode() : "");
  } else {
    line.addValue("");
    line.addValue("");
    line.addValue("");      
  }
  if (ed.getBase()!=null) {
    line.addString(ed.getBase().getPath());
    line.addValue(ed.getBase().getMin());
    line.addValue(ed.getBase().getMax());
  } else {
    line.addValue("");
    line.addValue("");
    line.addValue("");      
  }
  line.addString(itemList(ed.getCondition()));
  line.addString(itemList(ed.getConstraint()));
  for (StructureDefinitionMappingComponent mapKey : def.getMapping()) {
    for (ElementDefinitionMappingComponent map : ed.getMapping()) {
      if (map.getIdentity().equals(mapKey.getIdentity()))
      	line.addString(map.getMap());
    }
  }
}