use of org.hl7.fhir.r4.model.Property in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeCodeSystem.
protected void composeCodeSystem(Complex parent, String parentType, String name, CodeSystem element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeDomainResource(t, "CodeSystem", name, element, index);
if (element.hasUrlElement())
composeUri(t, "CodeSystem", "url", element.getUrlElement(), -1);
if (element.hasIdentifier())
composeIdentifier(t, "CodeSystem", "identifier", element.getIdentifier(), -1);
if (element.hasVersionElement())
composeString(t, "CodeSystem", "version", element.getVersionElement(), -1);
if (element.hasNameElement())
composeString(t, "CodeSystem", "name", element.getNameElement(), -1);
if (element.hasStatusElement())
composeEnum(t, "CodeSystem", "status", element.getStatusElement(), -1);
if (element.hasExperimentalElement())
composeBoolean(t, "CodeSystem", "experimental", element.getExperimentalElement(), -1);
if (element.hasPublisherElement())
composeString(t, "CodeSystem", "publisher", element.getPublisherElement(), -1);
for (int i = 0; i < element.getContact().size(); i++) composeCodeSystemCodeSystemContactComponent(t, "CodeSystem", "contact", element.getContact().get(i), i);
if (element.hasDateElement())
composeDateTime(t, "CodeSystem", "date", element.getDateElement(), -1);
if (element.hasDescriptionElement())
composeString(t, "CodeSystem", "description", element.getDescriptionElement(), -1);
for (int i = 0; i < element.getUseContext().size(); i++) composeCodeableConcept(t, "CodeSystem", "useContext", element.getUseContext().get(i), i);
if (element.hasRequirementsElement())
composeString(t, "CodeSystem", "requirements", element.getRequirementsElement(), -1);
if (element.hasCopyrightElement())
composeString(t, "CodeSystem", "copyright", element.getCopyrightElement(), -1);
if (element.hasCaseSensitiveElement())
composeBoolean(t, "CodeSystem", "caseSensitive", element.getCaseSensitiveElement(), -1);
if (element.hasValueSetElement())
composeUri(t, "CodeSystem", "valueSet", element.getValueSetElement(), -1);
if (element.hasCompositionalElement())
composeBoolean(t, "CodeSystem", "compositional", element.getCompositionalElement(), -1);
if (element.hasVersionNeededElement())
composeBoolean(t, "CodeSystem", "versionNeeded", element.getVersionNeededElement(), -1);
if (element.hasContentElement())
composeEnum(t, "CodeSystem", "content", element.getContentElement(), -1);
if (element.hasCountElement())
composeUnsignedInt(t, "CodeSystem", "count", element.getCountElement(), -1);
for (int i = 0; i < element.getFilter().size(); i++) composeCodeSystemCodeSystemFilterComponent(t, "CodeSystem", "filter", element.getFilter().get(i), i);
for (int i = 0; i < element.getProperty().size(); i++) composeCodeSystemCodeSystemPropertyComponent(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.r4.model.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++) composeCodeSystemConceptDefinitionPropertyComponent(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.r4.model.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
*/
private boolean compareElements(ProfileComparison outcome, String path, DefinitionNavigator left, DefinitionNavigator right) throws DefinitionException, IOException {
// 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.setComments(mergeText(subset, outcome, path, "comments", left.current().getComments(), right.current().getComments()));
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);
}
use of org.hl7.fhir.r4.model.Property in project org.hl7.fhir.core by hapifhir.
the class StructureMapUtilities method analyseSource.
private VariablesForProfiling analyseSource(String ruleId, TransformContext context, VariablesForProfiling vars, StructureMapGroupRuleSourceComponent src, XhtmlNode td) throws Exception {
VariableForProfiling var = vars.get(VariableMode.INPUT, src.getContext());
if (var == null)
throw new FHIRException("Rule \"" + ruleId + "\": Unknown input variable " + src.getContext());
PropertyWithType prop = var.getProperty();
boolean optional = false;
boolean repeating = false;
if (src.hasCondition()) {
optional = true;
}
if (src.hasElement()) {
Property element = prop.getBaseProperty().getChild(prop.types.getType(), src.getElement());
if (element == null)
throw new Exception("Rule \"" + ruleId + "\": Unknown element name " + src.getElement());
if (element.getDefinition().getMin() == 0)
optional = true;
if (element.getDefinition().getMax().equals("*"))
repeating = true;
VariablesForProfiling result = vars.copy(optional, repeating);
TypeDetails type = new TypeDetails(CollectionStatus.SINGLETON);
for (TypeRefComponent tr : element.getDefinition().getType()) {
if (!tr.hasCode())
throw new Error("Rule \"" + ruleId + "\": Element has no type");
ProfiledType pt = new ProfiledType(tr.getCode());
if (tr.hasProfile())
pt.addProfile(tr.getProfile());
if (element.getDefinition().hasBinding())
pt.addBinding(element.getDefinition().getBinding());
type.addType(pt);
}
td.addText(prop.getPath() + "." + src.getElement());
if (src.hasVariable())
result.add(VariableMode.INPUT, src.getVariable(), new PropertyWithType(prop.getPath() + "." + src.getElement(), element, null, type));
return result;
} else {
// ditto!
td.addText(prop.getPath());
return vars.copy(optional, repeating);
}
}
use of org.hl7.fhir.r4.model.Property in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeDevice.
protected void composeDevice(Complex parent, String parentType, String name, Device element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeDomainResource(t, "Device", name, element, index);
for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "Device", "identifier", element.getIdentifier().get(i), i);
if (element.hasDefinition())
composeReference(t, "Device", "definition", element.getDefinition(), -1);
for (int i = 0; i < element.getUdiCarrier().size(); i++) composeDeviceDeviceUdiCarrierComponent(t, "Device", "udiCarrier", element.getUdiCarrier().get(i), i);
if (element.hasStatusElement())
composeEnum(t, "Device", "status", element.getStatusElement(), -1);
for (int i = 0; i < element.getStatusReason().size(); i++) composeCodeableConcept(t, "Device", "statusReason", element.getStatusReason().get(i), i);
if (element.hasDistinctIdentifierElement())
composeString(t, "Device", "distinctIdentifier", element.getDistinctIdentifierElement(), -1);
if (element.hasManufacturerElement())
composeString(t, "Device", "manufacturer", element.getManufacturerElement(), -1);
if (element.hasManufactureDateElement())
composeDateTime(t, "Device", "manufactureDate", element.getManufactureDateElement(), -1);
if (element.hasExpirationDateElement())
composeDateTime(t, "Device", "expirationDate", element.getExpirationDateElement(), -1);
if (element.hasLotNumberElement())
composeString(t, "Device", "lotNumber", element.getLotNumberElement(), -1);
if (element.hasSerialNumberElement())
composeString(t, "Device", "serialNumber", element.getSerialNumberElement(), -1);
for (int i = 0; i < element.getDeviceName().size(); i++) composeDeviceDeviceDeviceNameComponent(t, "Device", "deviceName", element.getDeviceName().get(i), i);
if (element.hasModelNumberElement())
composeString(t, "Device", "modelNumber", element.getModelNumberElement(), -1);
if (element.hasPartNumberElement())
composeString(t, "Device", "partNumber", element.getPartNumberElement(), -1);
if (element.hasType())
composeCodeableConcept(t, "Device", "type", element.getType(), -1);
for (int i = 0; i < element.getSpecialization().size(); i++) composeDeviceDeviceSpecializationComponent(t, "Device", "specialization", element.getSpecialization().get(i), i);
for (int i = 0; i < element.getVersion().size(); i++) composeDeviceDeviceVersionComponent(t, "Device", "version", element.getVersion().get(i), i);
for (int i = 0; i < element.getProperty().size(); i++) composeDeviceDevicePropertyComponent(t, "Device", "property", element.getProperty().get(i), i);
if (element.hasPatient())
composeReference(t, "Device", "patient", element.getPatient(), -1);
if (element.hasOwner())
composeReference(t, "Device", "owner", element.getOwner(), -1);
for (int i = 0; i < element.getContact().size(); i++) composeContactPoint(t, "Device", "contact", element.getContact().get(i), i);
if (element.hasLocation())
composeReference(t, "Device", "location", element.getLocation(), -1);
if (element.hasUrlElement())
composeUri(t, "Device", "url", element.getUrlElement(), -1);
for (int i = 0; i < element.getNote().size(); i++) composeAnnotation(t, "Device", "note", element.getNote().get(i), i);
for (int i = 0; i < element.getSafety().size(); i++) composeCodeableConcept(t, "Device", "safety", element.getSafety().get(i), i);
if (element.hasParent())
composeReference(t, "Device", "parent", element.getParent(), -1);
}
Aggregations