use of org.hl7.fhir.r4b.elementmodel.Property in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeConceptMapOtherElementComponent.
protected void composeConceptMapOtherElementComponent(Complex parent, String parentType, String name, ConceptMap.OtherElementComponent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeBackboneElement(t, "dependsOn", name, element, index);
if (element.hasPropertyElement())
composeUri(t, "ConceptMap", "property", element.getPropertyElement(), -1);
if (element.hasSystemElement())
composeUri(t, "ConceptMap", "system", element.getSystemElement(), -1);
if (element.hasCodeElement())
composeString(t, "ConceptMap", "code", element.getCodeElement(), -1);
if (element.hasDisplayElement())
composeString(t, "ConceptMap", "display", element.getDisplayElement(), -1);
}
use of org.hl7.fhir.r4b.elementmodel.Property in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeCodeSystemConceptDefinitionComponent.
protected void composeCodeSystemConceptDefinitionComponent(Complex parent, String parentType, String name, CodeSystem.ConceptDefinitionComponent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeBackboneElement(t, "concept", name, element, index);
if (element.hasCodeElement())
composeCode(t, "CodeSystem", "code", element.getCodeElement(), -1);
if (element.hasDisplayElement())
composeString(t, "CodeSystem", "display", element.getDisplayElement(), -1);
if (element.hasDefinitionElement())
composeString(t, "CodeSystem", "definition", element.getDefinitionElement(), -1);
for (int i = 0; i < element.getDesignation().size(); i++) composeCodeSystemConceptDefinitionDesignationComponent(t, "CodeSystem", "designation", element.getDesignation().get(i), i);
for (int i = 0; i < element.getProperty().size(); i++) composeCodeSystemConceptPropertyComponent(t, "CodeSystem", "property", element.getProperty().get(i), i);
for (int i = 0; i < element.getConcept().size(); i++) composeCodeSystemConceptDefinitionComponent(t, "CodeSystem", "concept", element.getConcept().get(i), i);
}
use of org.hl7.fhir.r4b.elementmodel.Property in project org.hl7.fhir.core by hapifhir.
the class ProfileUtilities method initSpanningTable.
public TableModel initSpanningTable(HierarchicalTableGenerator gen, String prefix, boolean isLogical, String id) {
TableModel model = gen.new TableModel(id, false);
model.setDocoImg(prefix + "help16.png");
// todo: change to graph definition
model.setDocoRef(prefix + "formats.html#table");
model.getTitles().add(gen.new Title(null, model.getDocoRef(), "Property", "A profiled resource", null, 0));
model.getTitles().add(gen.new Title(null, model.getDocoRef(), "Card.", "Minimum and Maximum # of times the the element can appear in the instance", null, 0));
model.getTitles().add(gen.new Title(null, model.getDocoRef(), "Content", "What goes here", null, 0));
model.getTitles().add(gen.new Title(null, model.getDocoRef(), "Description", "Description of the profile", null, 0));
return model;
}
use of org.hl7.fhir.r4b.elementmodel.Property in project org.hl7.fhir.core by hapifhir.
the class ProfileUtilities method generateExample.
private org.hl7.fhir.dstu3.elementmodel.Element generateExample(StructureDefinition profile, ExampleValueAccessor accessor) throws FHIRException {
ElementDefinition ed = profile.getSnapshot().getElementFirstRep();
org.hl7.fhir.dstu3.elementmodel.Element r = new org.hl7.fhir.dstu3.elementmodel.Element(ed.getPath(), new Property(context, ed, profile));
List<ElementDefinition> children = getChildMap(profile, ed);
for (ElementDefinition child : children) {
if (child.getPath().endsWith(".id")) {
org.hl7.fhir.dstu3.elementmodel.Element id = new org.hl7.fhir.dstu3.elementmodel.Element("id", new Property(context, child, profile));
id.setValue(profile.getId() + accessor.getId());
r.getChildren().add(id);
} else {
org.hl7.fhir.dstu3.elementmodel.Element e = createExampleElement(profile, child, accessor);
if (e != null)
r.getChildren().add(e);
}
}
return r;
}
use of org.hl7.fhir.r4b.elementmodel.Property in project org.hl7.fhir.core by hapifhir.
the class ProfileComparer method compareElements.
/**
* left and right refer to the same element. Are they compatible?
* @param outcome
* @param outcome
* @param path
* @param left
* @param right
* @- if there's a problem that needs fixing in this code
* @throws DefinitionException
* @throws IOException
* @throws FHIRFormatError
*/
private boolean compareElements(ProfileComparison outcome, String path, DefinitionNavigator left, DefinitionNavigator right) throws DefinitionException, IOException, FHIRFormatError {
// preconditions:
assert (path != null);
assert (left != null);
assert (right != null);
assert (left.path().equals(right.path()));
// we ignore slicing right now - we're going to clone the root one anyway, and then think about clones
// simple stuff
ElementDefinition subset = new ElementDefinition();
subset.setPath(left.path());
// not allowed to be different:
// can't be bothered even testing this one
subset.getRepresentation().addAll(left.current().getRepresentation());
if (!outcome.ruleCompares(subset, left.current().getDefaultValue(), right.current().getDefaultValue(), path + ".defaultValue[x]", BOTH_NULL))
return false;
subset.setDefaultValue(left.current().getDefaultValue());
if (!outcome.ruleEqual(path, subset, left.current().getMeaningWhenMissing(), right.current().getMeaningWhenMissing(), "meaningWhenMissing Must be the same", true))
return false;
subset.setMeaningWhenMissing(left.current().getMeaningWhenMissing());
if (!outcome.ruleEqual(subset, left.current().getIsModifier(), right.current().getIsModifier(), path, "isModifier"))
return false;
subset.setIsModifier(left.current().getIsModifier());
if (!outcome.ruleEqual(subset, left.current().getIsSummary(), right.current().getIsSummary(), path, "isSummary"))
return false;
subset.setIsSummary(left.current().getIsSummary());
// descriptive properties from ElementDefinition - merge them:
subset.setLabel(mergeText(subset, outcome, path, "label", left.current().getLabel(), right.current().getLabel()));
subset.setShort(mergeText(subset, outcome, path, "short", left.current().getShort(), right.current().getShort()));
subset.setDefinition(mergeText(subset, outcome, path, "definition", left.current().getDefinition(), right.current().getDefinition()));
subset.setComment(mergeText(subset, outcome, path, "comments", left.current().getComment(), right.current().getComment()));
subset.setRequirements(mergeText(subset, outcome, path, "requirements", left.current().getRequirements(), right.current().getRequirements()));
subset.getCode().addAll(mergeCodings(left.current().getCode(), right.current().getCode()));
subset.getAlias().addAll(mergeStrings(left.current().getAlias(), right.current().getAlias()));
subset.getMapping().addAll(mergeMappings(left.current().getMapping(), right.current().getMapping()));
// left will win for example
subset.setExample(left.current().hasExample() ? left.current().getExample() : right.current().getExample());
subset.setMustSupport(left.current().getMustSupport() || right.current().getMustSupport());
ElementDefinition superset = subset.copy();
// compare and intersect
superset.setMin(unionMin(left.current().getMin(), right.current().getMin()));
superset.setMax(unionMax(left.current().getMax(), right.current().getMax()));
subset.setMin(intersectMin(left.current().getMin(), right.current().getMin()));
subset.setMax(intersectMax(left.current().getMax(), right.current().getMax()));
outcome.rule(subset, subset.getMax().equals("*") || Integer.parseInt(subset.getMax()) >= subset.getMin(), path, "Cardinality Mismatch: " + card(left) + "/" + card(right));
superset.getType().addAll(unionTypes(path, left.current().getType(), right.current().getType()));
subset.getType().addAll(intersectTypes(subset, outcome, path, left.current().getType(), right.current().getType()));
outcome.rule(subset, !subset.getType().isEmpty() || (!left.current().hasType() && !right.current().hasType()), path, "Type Mismatch:\r\n " + typeCode(left) + "\r\n " + typeCode(right));
// <fixed[x]><!-- ?? 0..1 * Value must be exactly this --></fixed[x]>
// <pattern[x]><!-- ?? 0..1 * Value must have at least these property values --></pattern[x]>
superset.setMaxLengthElement(unionMaxLength(left.current().getMaxLength(), right.current().getMaxLength()));
subset.setMaxLengthElement(intersectMaxLength(left.current().getMaxLength(), right.current().getMaxLength()));
if (left.current().hasBinding() || right.current().hasBinding()) {
compareBindings(outcome, subset, superset, path, left.current(), right.current());
}
// note these are backwards
superset.getConstraint().addAll(intersectConstraints(path, left.current().getConstraint(), right.current().getConstraint()));
subset.getConstraint().addAll(unionConstraints(subset, outcome, path, left.current().getConstraint(), right.current().getConstraint()));
// now process the slices
if (left.current().hasSlicing() || right.current().hasSlicing()) {
if (isExtension(left.path()))
return compareExtensions(outcome, path, superset, subset, left, right);
else
throw new DefinitionException("Slicing is not handled yet");
// todo: name
}
// add the children
outcome.subset.getSnapshot().getElement().add(subset);
outcome.superset.getSnapshot().getElement().add(superset);
return compareChildren(subset, outcome, path, left, right);
}
Aggregations