use of org.hl7.fhir.r5.elementmodel.Property in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeValueSetConceptSetFilterComponent.
protected void composeValueSetConceptSetFilterComponent(Complex parent, String parentType, String name, ValueSet.ConceptSetFilterComponent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeBackboneElement(t, "filter", name, element, index);
if (element.hasPropertyElement())
composeCode(t, "ValueSet", "property", element.getPropertyElement(), -1);
if (element.hasOpElement())
composeEnum(t, "ValueSet", "op", element.getOpElement(), -1);
if (element.hasValueElement())
composeCode(t, "ValueSet", "value", element.getValueElement(), -1);
}
use of org.hl7.fhir.r5.elementmodel.Property in project org.hl7.fhir.core by hapifhir.
the class ParserBase method getChildProperties.
protected List<Property> getChildProperties(Property property, String elementName, String statedType) throws DefinitionException {
ElementDefinition ed = property.getDefinition();
StructureDefinition sd = property.getStructure();
List<ElementDefinition> children = ProfileUtilities.getChildMap(sd, ed);
if (children.isEmpty()) {
// ok, find the right definitions
String t = null;
if (ed.getType().size() == 1)
t = ed.getType().get(0).getCode();
else if (ed.getType().size() == 0)
throw new Error("types == 0, and no children found");
else {
t = ed.getType().get(0).getCode();
boolean all = true;
for (TypeRefComponent tr : ed.getType()) {
if (!tr.getCode().equals(t)) {
all = false;
break;
}
}
if (!all) {
// ok, it's polymorphic
if (ed.hasRepresentation(PropertyRepresentation.TYPEATTR)) {
t = statedType;
if (t == null && ToolingExtensions.hasExtension(ed, "http://hl7.org/fhir/StructureDefinition/elementdefinition-defaultype"))
t = ToolingExtensions.readStringExtension(ed, "http://hl7.org/fhir/StructureDefinition/elementdefinition-defaultype");
boolean ok = false;
for (TypeRefComponent tr : ed.getType()) if (tr.getCode().equals(t))
ok = true;
if (!ok)
throw new DefinitionException("Type '" + t + "' is not an acceptable type for '" + elementName + "' on property " + property.getDefinition().getPath());
} else {
t = elementName.substring(tail(ed.getPath()).length() - 3);
if (isPrimitive(lowFirst(t)))
t = lowFirst(t);
}
}
}
if (!"xhtml".equals(t)) {
sd = context.fetchTypeDefinition(t);
if (sd == null)
throw new DefinitionException("Unable to find class '" + t + "' for name '" + elementName + "' on property " + property.getDefinition().getPath());
children = ProfileUtilities.getChildMap(sd, sd.getSnapshot().getElement().get(0));
}
}
List<Property> properties = new ArrayList<Property>();
for (ElementDefinition child : children) {
properties.add(new Property(context, child, sd));
}
return properties;
}
use of org.hl7.fhir.r5.elementmodel.Property in project org.hl7.fhir.core by hapifhir.
the class CodeSystem method setProperty.
@Override
public void setProperty(String name, Base value) throws FHIRException {
if (name.equals("url"))
// UriType
this.url = castToUri(value);
else if (name.equals("identifier"))
// Identifier
this.identifier = castToIdentifier(value);
else if (name.equals("version"))
// StringType
this.version = castToString(value);
else if (name.equals("name"))
// StringType
this.name = castToString(value);
else if (name.equals("status"))
// Enumeration<ConformanceResourceStatus>
this.status = new ConformanceResourceStatusEnumFactory().fromType(value);
else if (name.equals("experimental"))
// BooleanType
this.experimental = castToBoolean(value);
else if (name.equals("publisher"))
// StringType
this.publisher = castToString(value);
else if (name.equals("contact"))
this.getContact().add((CodeSystemContactComponent) value);
else if (name.equals("date"))
// DateTimeType
this.date = castToDateTime(value);
else if (name.equals("description"))
// StringType
this.description = castToString(value);
else if (name.equals("useContext"))
this.getUseContext().add(castToCodeableConcept(value));
else if (name.equals("requirements"))
// StringType
this.requirements = castToString(value);
else if (name.equals("copyright"))
// StringType
this.copyright = castToString(value);
else if (name.equals("caseSensitive"))
// BooleanType
this.caseSensitive = castToBoolean(value);
else if (name.equals("valueSet"))
// UriType
this.valueSet = castToUri(value);
else if (name.equals("compositional"))
// BooleanType
this.compositional = castToBoolean(value);
else if (name.equals("versionNeeded"))
// BooleanType
this.versionNeeded = castToBoolean(value);
else if (name.equals("content"))
// Enumeration<CodeSystemContentMode>
this.content = new CodeSystemContentModeEnumFactory().fromType(value);
else if (name.equals("count"))
// UnsignedIntType
this.count = castToUnsignedInt(value);
else if (name.equals("filter"))
this.getFilter().add((CodeSystemFilterComponent) value);
else if (name.equals("property"))
this.getProperty().add((CodeSystemPropertyComponent) value);
else if (name.equals("concept"))
this.getConcept().add((ConceptDefinitionComponent) value);
else
super.setProperty(name, value);
}
use of org.hl7.fhir.r5.elementmodel.Property in project org.hl7.fhir.core by hapifhir.
the class JsonParser method parse.
public Element parse(JsonObject object) throws Exception {
JsonElement rt = object.get("resourceType");
if (rt == null) {
logError(line(object), col(object), "$", IssueType.INVALID, "Unable to find resourceType property", IssueSeverity.FATAL);
return null;
} else {
String name = rt.getAsString();
String path = "/" + name;
StructureDefinition sd = getDefinition(line(object), col(object), name);
if (sd == null)
return null;
Element result = new Element(name, new Property(context, sd.getSnapshot().getElement().get(0), sd));
checkObject(object, path);
result.markLocation(line(object), col(object));
result.setType(name);
parseChildren(path, object, result, true);
result.numberChildren();
return result;
}
}
use of org.hl7.fhir.r5.elementmodel.Property in project org.hl7.fhir.core by hapifhir.
the class XmlParser method parseResource.
private void parseResource(String string, org.w3c.dom.Element container, Element parent) throws Exception {
org.w3c.dom.Element res = XMLUtil.getFirstChild(container);
String name = res.getLocalName();
StructureDefinition sd = context.fetchTypeDefinition(name);
if (sd == null)
throw new FHIRFormatError("Contained resource does not appear to be a FHIR resource (unknown name '" + res.getLocalName() + "')");
parent.updateProperty(new Property(context, sd.getSnapshot().getElement().get(0), sd), parent.getProperty().getName().equals("contained") ? SpecialElement.CONTAINED : SpecialElement.BUNDLE_ENTRY);
parent.setType(name);
parseChildren(res.getLocalName(), res, parent);
}
Aggregations