null
. If more than one
+ * link is found which matches the given relation, returns the first matching BundleLinkComponent.
+ *
+ * @param theRelation
+ * The relation, such as \"next\", or \"self. See the constants such as {@link IBaseBundle#LINK_SELF} and {@link IBaseBundle#LINK_NEXT}.
+ * @return Returns a matching BundleLinkComponent, or null
+ * @see IBaseBundle#LINK_NEXT
+ * @see IBaseBundle#LINK_PREV
+ * @see IBaseBundle#LINK_SELF
+ */
+ public BundleLinkComponent getLink(String theRelation) {
+ org.apache.commons.lang3.Validate.notBlank(theRelation, "theRelation may not be null or empty");
+ for (BundleLinkComponent next : getLink()) {
+ if (theRelation.equals(next.getRelation())) {
+ return next;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the {@link #getLink() link} which matches a given {@link BundleLinkComponent#getRelation() relation}.
+ * If no link is found which matches the given relation, creates a new BundleLinkComponent with the
+ * given relation and adds it to this Bundle. If more than one
+ * link is found which matches the given relation, returns the first matching BundleLinkComponent.
+ *
+ * @param theRelation
+ * The relation, such as \"next\", or \"self. See the constants such as {@link IBaseBundle#LINK_SELF} and {@link IBaseBundle#LINK_NEXT}.
+ * @return Returns a matching BundleLinkComponent, or null
+ * @see IBaseBundle#LINK_NEXT
+ * @see IBaseBundle#LINK_PREV
+ * @see IBaseBundle#LINK_SELF
+ */
+ public BundleLinkComponent getLinkOrCreate(String theRelation) {
+ org.apache.commons.lang3.Validate.notBlank(theRelation, "theRelation may not be null or empty");
+ for (BundleLinkComponent next : getLink()) {
+ if (theRelation.equals(next.getRelation())) {
+ return next;
+ }
+ }
+ BundleLinkComponent retVal = new BundleLinkComponent();
+ retVal.setRelation(theRelation);
+ getLink().add(retVal);
+ return retVal;
+ }
+
diff --git a/org.hl7.fhir.core.generator/configuration/BundleEntryComponent.java b/org.hl7.fhir.core.generator/configuration/BundleEntryComponent.java
new file mode 100644
index 000000000..1acb67e8c
--- /dev/null
+++ b/org.hl7.fhir.core.generator/configuration/BundleEntryComponent.java
@@ -0,0 +1,48 @@
+ /**
+ * Returns the {@link #getLink() link} which matches a given {@link BundleLinkComponent#getRelation() relation}.
+ * If no link is found which matches the given relation, returns null
. If more than one
+ * link is found which matches the given relation, returns the first matching BundleLinkComponent.
+ *
+ * @param theRelation
+ * The relation, such as \"next\", or \"self. See the constants such as {@link IBaseBundle#LINK_SELF} and {@link IBaseBundle#LINK_NEXT}.
+ * @return Returns a matching BundleLinkComponent, or null
+ * @see IBaseBundle#LINK_NEXT
+ * @see IBaseBundle#LINK_PREV
+ * @see IBaseBundle#LINK_SELF
+ */
+ public BundleLinkComponent getLink(String theRelation) {
+ org.apache.commons.lang3.Validate.notBlank(theRelation, "theRelation may not be null or empty");
+ for (BundleLinkComponent next : getLink()) {
+ if (theRelation.equals(next.getRelation())) {
+ return next;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the {@link #getLink() link} which matches a given {@link BundleLinkComponent#getRelation() relation}.
+ * If no link is found which matches the given relation, creates a new BundleLinkComponent with the
+ * given relation and adds it to this Bundle. If more than one
+ * link is found which matches the given relation, returns the first matching BundleLinkComponent.
+ *
+ * @param theRelation
+ * The relation, such as \"next\", or \"self. See the constants such as {@link IBaseBundle#LINK_SELF} and {@link IBaseBundle#LINK_NEXT}.
+ * @return Returns a matching BundleLinkComponent, or null
+ * @see IBaseBundle#LINK_NEXT
+ * @see IBaseBundle#LINK_PREV
+ * @see IBaseBundle#LINK_SELF
+ */
+ public BundleLinkComponent getLinkOrCreate(String theRelation) {
+ org.apache.commons.lang3.Validate.notBlank(theRelation, "theRelation may not be null or empty");
+ for (BundleLinkComponent next : getLink()) {
+ if (theRelation.equals(next.getRelation())) {
+ return next;
+ }
+ }
+ BundleLinkComponent retVal = new BundleLinkComponent();
+ retVal.setRelation(theRelation);
+ getLink().add(retVal);
+ return retVal;
+ }
+
diff --git a/org.hl7.fhir.core.generator/configuration/CanonicalResource.java b/org.hl7.fhir.core.generator/configuration/CanonicalResource.java
new file mode 100644
index 000000000..63da0ae20
--- /dev/null
+++ b/org.hl7.fhir.core.generator/configuration/CanonicalResource.java
@@ -0,0 +1,12 @@
+ @Override
+ public String toString() {
+ return fhirType()+"["+getUrl()+"]";
+ }
+
+ public String present() {
+ if (hasTitle())
+ return getTitle();
+ if (hasName())
+ return getName();
+ return toString();
+ }
diff --git a/org.hl7.fhir.core.generator/configuration/CapabilityStatement.java b/org.hl7.fhir.core.generator/configuration/CapabilityStatement.java
new file mode 100644
index 000000000..5f282702b
--- /dev/null
+++ b/org.hl7.fhir.core.generator/configuration/CapabilityStatement.java
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/org.hl7.fhir.core.generator/configuration/CodeSystem.java b/org.hl7.fhir.core.generator/configuration/CodeSystem.java
new file mode 100644
index 000000000..e9b8fa196
--- /dev/null
+++ b/org.hl7.fhir.core.generator/configuration/CodeSystem.java
@@ -0,0 +1,7 @@
+ public PropertyComponent getProperty(String code) {
+ for (PropertyComponent pd : getProperty()) {
+ if (pd.getCode().equalsIgnoreCase(code))
+ return pd;
+ }
+ return null;
+ }
diff --git a/org.hl7.fhir.core.generator/configuration/CodeType.java b/org.hl7.fhir.core.generator/configuration/CodeType.java
new file mode 100644
index 000000000..4511b7296
--- /dev/null
+++ b/org.hl7.fhir.core.generator/configuration/CodeType.java
@@ -0,0 +1,38 @@
+
+ private String system;
+
+ @Override
+ public String getSystem() {
+ return system;
+ }
+
+ @Override
+ public boolean hasSystem() {
+ return system != null;
+ }
+
+ public CodeType setSystem(String system) {
+ this.system = system;
+ return this;
+ }
+
+ @Override
+ public String getVersion() {
+ return null;
+ }
+
+ @Override
+ public boolean hasVersion() {
+ return false;
+ }
+
+ @Override
+ public String getDisplay() {
+ return null;
+ }
+
+ @Override
+ public boolean hasDisplay() {
+ return false;
+ }
+
diff --git a/org.hl7.fhir.core.generator/configuration/CodeableConcept.java b/org.hl7.fhir.core.generator/configuration/CodeableConcept.java
new file mode 100644
index 000000000..3175e2751
--- /dev/null
+++ b/org.hl7.fhir.core.generator/configuration/CodeableConcept.java
@@ -0,0 +1,15 @@
+
+ public boolean hasCoding(String system, String code) {
+ for (Coding c : getCoding()) {
+ if (system.equals(c.getSystem()) && code.equals(c.getCode()))
+ return true;
+ }
+ return false;
+ }
+
+ public CodeableConcept(Coding code) {
+ super();
+ addCoding(code);
+ }
+
+
diff --git a/org.hl7.fhir.core.generator/configuration/Coding.java b/org.hl7.fhir.core.generator/configuration/Coding.java
new file mode 100644
index 000000000..8e020a79c
--- /dev/null
+++ b/org.hl7.fhir.core.generator/configuration/Coding.java
@@ -0,0 +1,26 @@
+ @Override
+ public boolean supportsVersion() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsDisplay() {
+ return true;
+ }
+
+
+ public boolean is(String system, String code) {
+ return hasSystem() && hasCode() && this.getSystem().equals(system) && this.getCode().equals(code);
+ }
+
+ public String toString() {
+ String base = getSystem();
+ if (hasVersion())
+ base = base+"|"+getVersion();
+ base = base + "#"+getCode();
+ if (hasDisplay())
+ base = base+": "+getDisplay();
+ return base;
+
+ }
+
diff --git a/org.hl7.fhir.core.generator/configuration/ConceptDefinitionComponent.java b/org.hl7.fhir.core.generator/configuration/ConceptDefinitionComponent.java
new file mode 100644
index 000000000..503a5e63e
--- /dev/null
+++ b/org.hl7.fhir.core.generator/configuration/ConceptDefinitionComponent.java
@@ -0,0 +1,6 @@
+
+ @Override
+ public String toString() {
+ return getCode()+": "+getDisplay();
+ }
+
diff --git a/org.hl7.fhir.core.generator/configuration/DomainResource.java b/org.hl7.fhir.core.generator/configuration/DomainResource.java
new file mode 100644
index 000000000..39a1cb86c
--- /dev/null
+++ b/org.hl7.fhir.core.generator/configuration/DomainResource.java
@@ -0,0 +1,84 @@
+
+ public void checkNoModifiers(String noun, String verb) throws FHIRException {
+ if (hasModifierExtension()) {
+ throw new FHIRException("Found unknown Modifier Exceptions on "+noun+" doing "+verb);
+ }
+
+ }
+
+ public void addExtension(String url, DataType value) {
+ Extension ex = new Extension();
+ ex.setUrl(url);
+ ex.setValue(value);
+ getExtension().add(ex);
+ }
+
+
+
+
+ public boolean hasExtension(String url) {
+ for (Extension e : getExtension())
+ if (url.equals(e.getUrl()))
+ return true;
+ return false;
+ }
+
+ public Extension getExtensionByUrl(String theUrl) {
+ org.apache.commons.lang3.Validate.notBlank(theUrl, "theUrl must not be blank or null");
+ ArrayList+ * If none of the parts are populated, returns the {@link #getTextElement() text} element value instead. + *
+ */ + public String getNameAsSingleString() { + Listthis
for easy chaining
+ */
+ public Meta addTag(String theSystem, String theCode, String theDisplay) {
+ addTag().setSystem(theSystem).setCode(theCode).setDisplay(theDisplay);
+ return this;
+ }
+
+ /**
+ * Returns the first tag (if any) that has the given system and code, or returns
+ * null
if none
+ */
+ public Coding getTag(String theSystem, String theCode) {
+ for (Coding next : getTag()) {
+ if (ca.uhn.fhir.util.ObjectUtil.equals(next.getSystem(), theSystem) && ca.uhn.fhir.util.ObjectUtil.equals(next.getCode(), theCode)) {
+ return next;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the first security label (if any) that has the given system and code, or returns
+ * null
if none
+ */
+ public Coding getSecurity(String theSystem, String theCode) {
+ for (Coding next : getTag()) {
+ if (ca.uhn.fhir.util.ObjectUtil.equals(next.getSystem(), theSystem) && ca.uhn.fhir.util.ObjectUtil.equals(next.getCode(), theCode)) {
+ return next;
+ }
+ }
+ return null;
+ }
diff --git a/org.hl7.fhir.core.generator/configuration/Parameters.java b/org.hl7.fhir.core.generator/configuration/Parameters.java
new file mode 100644
index 000000000..8b3c796a8
--- /dev/null
+++ b/org.hl7.fhir.core.generator/configuration/Parameters.java
@@ -0,0 +1,93 @@
+
+ public Parameters addParameter(String name, boolean b) {
+ addParameter().setName(name).setValue(new BooleanType(b));
+ return this;
+ }
+
+ public Parameters addParameter(String name, String s) {
+ if (s != null)
+ addParameter().setName(name).setValue(new StringType(s));
+ return this;
+ }
+
+ public Parameters addParameter(String name, DataType v) {
+ if (v != null)
+ addParameter().setName(name).setValue(v);
+ return this;
+ }
+
+ public Parameters setParameter(String name, boolean b) {
+ for (ParametersParameterComponent p : getParameter()) {
+ if (p.getName().equals(name)) {
+ p.setValue(new BooleanType(b));
+ return this;
+ }
+ }
+ addParameter().setName(name).setValue(new BooleanType(b));
+ return this;
+ }
+
+ public Parameters setParameter(String name, String s) {
+ if (s != null) {
+ for (ParametersParameterComponent p : getParameter()) {
+ if (p.getName().equals(name)) {
+ p.setValue(new StringType(s));
+ return this;
+ }
+ }
+ addParameter().setName(name).setValue(new StringType(s));
+ }
+ return this;
+ }
+
+ public Parameters setParameter(String name, DataType v) {
+ if (v != null) {
+ for (ParametersParameterComponent p : getParameter() ) {
+ if (p.getName().equals(name)) {
+ p.setValue(v);
+ return this;
+ }
+ }
+ addParameter().setName(name).setValue(v);
+ }
+ return this;
+ }
+
+ public boolean hasParameter(String name) {
+ for (ParametersParameterComponent p : getParameter()) {
+ if (p.getName().equals(name))
+ return true;
+ }
+ return false;
+ }
+
+ public DataType getParameter(String name) {
+ for (ParametersParameterComponent p : getParameter()) {
+ if (p.getName().equals(name))
+ return p.getValue();
+ }
+ return null;
+ }
+
+ public List+ * Definition: + * The start of the period. The boundary is inclusive. + *
+ */ + public Period setStart( Date theDate, TemporalPrecisionEnum thePrecision) { + start = new DateTimeType(theDate, thePrecision); + return this; + } + + /** + * Sets the value for end () + * + *+ * Definition: + * The end of the period. The boundary is inclusive. + *
+ */ + public Period setEnd( Date theDate, TemporalPrecisionEnum thePrecision) { + end = new DateTimeType(theDate, thePrecision); + return this; + } + diff --git a/org.hl7.fhir.core.generator/configuration/Quantity.java b/org.hl7.fhir.core.generator/configuration/Quantity.java new file mode 100644 index 000000000..c8a29e6bf --- /dev/null +++ b/org.hl7.fhir.core.generator/configuration/Quantity.java @@ -0,0 +1,40 @@ + + @Override + public String getVersion() { + return null; + } + + @Override + public boolean hasVersion() { + return false; + } + + @Override + public boolean supportsVersion() { + return false; + } + + @Override + public String getDisplay() { + return null; + } + + @Override + public boolean hasDisplay() { + return false; + } + + @Override + public boolean supportsDisplay() { + return false; + } + + public static Quantity fromUcum(String v, String code) { + Quantity res = new Quantity(); + res.setValue(new BigDecimal(v)); + res.setSystem("http://unitsofmeasure.org"); + res.setCode(code); + return res; + } + + diff --git a/org.hl7.fhir.core.generator/configuration/Questionnaire.java b/org.hl7.fhir.core.generator/configuration/Questionnaire.java new file mode 100644 index 000000000..430eaf1b0 --- /dev/null +++ b/org.hl7.fhir.core.generator/configuration/Questionnaire.java @@ -0,0 +1,23 @@ + + public QuestionnaireItemComponent getQuestion(String linkId) { + if (linkId == null) + return null; + for (QuestionnaireItemComponent i : getItem()) { + if (i.getLinkId().equals(linkId)) + return i; + QuestionnaireItemComponent t = i.getQuestion(linkId); + if (t != null) + return t; + } + return null; + } + + public QuestionnaireItemComponent getCommonGroup(QuestionnaireItemComponent q1, QuestionnaireItemComponent q2) { + for (QuestionnaireItemComponent i : getItem()) { + QuestionnaireItemComponent t = i.getCommonGroup(q1, q2); + if (t != null) + return t; + } + return null; + } + diff --git a/org.hl7.fhir.core.generator/configuration/QuestionnaireItemComponent.java b/org.hl7.fhir.core.generator/configuration/QuestionnaireItemComponent.java new file mode 100644 index 000000000..0bdd42014 --- /dev/null +++ b/org.hl7.fhir.core.generator/configuration/QuestionnaireItemComponent.java @@ -0,0 +1,37 @@ + + public QuestionnaireItemComponent getQuestion(String linkId) { + if (linkId == null) + return null; + for (QuestionnaireItemComponent i : getItem()) { + if (i.getLinkId().equals(linkId)) + return i; + QuestionnaireItemComponent t = i.getQuestion(linkId); + if (t != null) + return t; + } + return null; + } + + public QuestionnaireItemComponent getCommonGroup(QuestionnaireItemComponent q1, QuestionnaireItemComponent q2) { + if (q1 == null || q2 == null) + return null; + for (QuestionnaireItemComponent i : getItem()) { + QuestionnaireItemComponent t = i.getCommonGroup(q1, q2); + if (t != null) + return t; + } + if (containsQuestion(q1) && containsQuestion(q2)) + return this; + return null; + } + + public boolean containsQuestion(QuestionnaireItemComponent q) { + if (q == this) + return true; + for (QuestionnaireItemComponent i : getItem()) { + if (i.containsQuestion(q)) + return true; + } + return false; + } + diff --git a/org.hl7.fhir.core.generator/configuration/RdfParser.java b/org.hl7.fhir.core.generator/configuration/RdfParser.java new file mode 100644 index 000000000..85549b02d --- /dev/null +++ b/org.hl7.fhir.core.generator/configuration/RdfParser.java @@ -0,0 +1,270 @@ +package org.hl7.fhir.r5.formats; + + +// generated + +{{license}} + +{{startMark}} + +import org.hl7.fhir.r5.model.*; +import org.hl7.fhir.utilities.Utilities; +import org.hl7.fhir.exceptions.FHIRFormatError; +import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.r5.utils.formats.Turtle.Complex; +import java.io.IOException; + +public class RdfParser extends RdfParserBase { + + public RdfParser() { + super(); + } + + public RdfParser(boolean allowUnknownContent) { + super(); + setAllowUnknownContent(allowUnknownContent); + } + + private void composeEnum(Complex parent, String parentType, String name, Enumeration extends Enum> value, int index) { + if (value == null) + return; + Complex t = parent.predicate("fhir:"+parentType+"."+name); + t.predicate("fhir:value", ttlLiteral(value.asStringValue())); + composeElement(t, parentType, name, value, index); + decorateCode(t, value); + } + + + protected void composeDate(Complex parent, String parentType, String name, DateType value, int index) { + if (value == null) + return; + Complex t = parent.predicate("fhir:"+parentType+"."+name); + t.predicate("fhir:value", ttlLiteral(value.asStringValue())); + composeElement(t, parentType, name, value, index); + } + + protected void composeDateTime(Complex parent, String parentType, String name, DateTimeType value, int index) { + if (value == null) + return; + Complex t = parent.predicate("fhir:"+parentType+"."+name); + t.predicate("fhir:value", ttlLiteral(value.asStringValue())); + composeElement(t, parentType, name, value, index); + } + + protected void composeCode(Complex parent, String parentType, String name, CodeType value, int index) { + if (value == null) + return; + Complex t = parent.predicate("fhir:"+parentType+"."+name); + t.predicate("fhir:value", ttlLiteral(value.asStringValue())); + composeElement(t, parentType, name, value, index); + decorateCode(t, value); + } + + protected void composeString(Complex parent, String parentType, String name, StringType value, int index) { + if (value == null) + return; + Complex t = parent.predicate("fhir:"+parentType+"."+name); + t.predicate("fhir:value", ttlLiteral(value.asStringValue())); + composeElement(t, parentType, name, value, index); + } + + protected void composeInteger(Complex parent, String parentType, String name, IntegerType value, int index) { + if (value == null) + return; + Complex t = parent.predicate("fhir:"+parentType+"."+name); + t.predicate("fhir:value", ttlLiteral(value.asStringValue())); + composeElement(t, parentType, name, value, index); + } + + protected void composeInteger64(Complex parent, String parentType, String name, Integer64Type value, int index) { + if (value == null) + return; + Complex t = parent.predicate("fhir:"+parentType+"."+name); + t.predicate("fhir:value", ttlLiteral(value.asStringValue())); + composeElement(t, parentType, name, value, index); + } + + protected void composeOid(Complex parent, String parentType, String name, OidType value, int index) { + if (value == null) + return; + Complex t = parent.predicate("fhir:"+parentType+"."+name); + t.predicate("fhir:value", ttlLiteral(value.asStringValue())); + composeElement(t, parentType, name, value, index); + } + + protected void composeCanonical(Complex parent, String parentType, String name, CanonicalType value, int index) { + if (value == null) + return; + Complex t = parent.predicate("fhir:"+parentType+"."+name); + t.predicate("fhir:value", ttlLiteral(value.asStringValue())); + composeElement(t, parentType, name, value, index); + } + + protected void composeUri(Complex parent, String parentType, String name, UriType value, int index) { + if (value == null) + return; + Complex t = parent.predicate("fhir:"+parentType+"."+name); + t.predicate("fhir:value", ttlLiteral(value.asStringValue())); + composeElement(t, parentType, name, value, index); + } + + protected void composeUuid(Complex parent, String parentType, String name, UuidType value, int index) { + if (value == null) + return; + Complex t = parent.predicate("fhir:"+parentType+"."+name); + t.predicate("fhir:value", ttlLiteral(value.asStringValue())); + composeElement(t, parentType, name, value, index); + } + + protected void composeUrl(Complex parent, String parentType, String name, UrlType value, int index) { + if (value == null) + return; + Complex t = parent.predicate("fhir:"+parentType+"."+name); + t.predicate("fhir:value", ttlLiteral(value.asStringValue())); + composeElement(t, parentType, name, value, index); + } + + protected void composeInstant(Complex parent, String parentType, String name, InstantType value, int index) { + if (value == null) + return; + Complex t = parent.predicate("fhir:"+parentType+"."+name); + t.predicate("fhir:value", ttlLiteral(value.asStringValue())); + composeElement(t, parentType, name, value, index); + } + + protected void composeBoolean(Complex parent, String parentType, String name, BooleanType value, int index) { + if (value == null) + return; + Complex t = parent.predicate("fhir:"+parentType+"."+name); + t.predicate("fhir:value", ttlLiteral(value.asStringValue())); + composeElement(t, parentType, name, value, index); + } + + protected void composeBase64Binary(Complex parent, String parentType, String name, Base64BinaryType value, int index) { + if (value == null) + return; + Complex t = parent.predicate("fhir:"+parentType+"."+name); + t.predicate("fhir:value", ttlLiteral(value.asStringValue())); + composeElement(t, parentType, name, value, index); + } + + protected void composeUnsignedInt(Complex parent, String parentType, String name, UnsignedIntType value, int index) { + if (value == null) + return; + Complex t = parent.predicate("fhir:"+parentType+"."+name); + t.predicate("fhir:value", ttlLiteral(value.asStringValue())); + composeElement(t, parentType, name, value, index); + } + + protected void composeMarkdown(Complex parent, String parentType, String name, MarkdownType value, int index) { + if (value == null) + return; + Complex t = parent.predicate("fhir:"+parentType+"."+name); + t.predicate("fhir:value", ttlLiteral(value.asStringValue())); + composeElement(t, parentType, name, value, index); + } + + protected void composeTime(Complex parent, String parentType, String name, TimeType value, int index) { + if (value == null) + return; + Complex t = parent.predicate("fhir:"+parentType+"."+name); + t.predicate("fhir:value", ttlLiteral(value.asStringValue())); + composeElement(t, parentType, name, value, index); + } + + protected void composeId(Complex parent, String parentType, String name, IdType value, int index) { + if (value == null) + return; + Complex t = parent.predicate("fhir:"+parentType+"."+name); + t.predicate("fhir:value", ttlLiteral(value.asStringValue())); + composeElement(t, parentType, name, value, index); + } + + protected void composePositiveInt(Complex parent, String parentType, String name, PositiveIntType value, int index) { + if (value == null) + return; + Complex t = parent.predicate("fhir:"+parentType+"."+name); + t.predicate("fhir:value", ttlLiteral(value.asStringValue())); + composeElement(t, parentType, name, value, index); + } + + protected void composeDecimal(Complex parent, String parentType, String name, DecimalType value, int index) { + if (value == null) + return; + Complex t = parent.predicate("fhir:"+parentType+"."+name); + t.predicate("fhir:value", ttlLiteral(value.asStringValue())); + composeElement(t, parentType, name, value, index); + } + +{{composer}} + + + @Override + protected void composeResource(Complex parent, Resource resource) { + if (parent == null) { + throw new Error("parent == null"); + } else if (resource == null) { + throw new Error("resource == null"); +{{compose-resource}} + } else { + throw new Error("Unhandled resource type "+resource.getClass().getName()); + } + } + + protected void composeType(Complex parent, String parentType, String name, DataType value, int index) { + if (parent == null) { + throw new Error("parent == null"); + } else if (parentType == null) { + throw new Error("parentType == null"); + } else if (name == null) { + throw new Error("name == null"); + } else if (value == null) { + throw new Error("value == null"); + } else if (value instanceof DateType) { + composeDate(parent, parentType, name, (DateType)value, index); + } else if (value instanceof DateTimeType) { + composeDateTime(parent, parentType, name, (DateTimeType)value, index); + } else if (value instanceof CodeType) { + composeCode(parent, parentType, name, (CodeType)value, index); + } else if (value instanceof StringType) { + composeString(parent, parentType, name, (StringType)value, index); + } else if (value instanceof IntegerType) { + composeInteger(parent, parentType, name, (IntegerType)value, index); + } else if (value instanceof Integer64Type) { + composeInteger64(parent, parentType, name, (Integer64Type)value, index); + } else if (value instanceof OidType) { + composeOid(parent, parentType, name, (OidType)value, index); + } else if (value instanceof CanonicalType) { + composeCanonical(parent, parentType, name, (CanonicalType)value, index); + } else if (value instanceof UriType) { + composeUri(parent, parentType, name, (UriType)value, index); + } else if (value instanceof UuidType) { + composeUuid(parent, parentType, name, (UuidType)value, index); + } else if (value instanceof UrlType) { + composeUrl(parent, parentType, name, (UrlType)value, index); + } else if (value instanceof InstantType) { + composeInstant(parent, parentType, name, (InstantType)value, index); + } else if (value instanceof BooleanType) { + composeBoolean(parent, parentType, name, (BooleanType)value, index); + } else if (value instanceof Base64BinaryType) { + composeBase64Binary(parent, parentType, name, (Base64BinaryType)value, index); + } else if (value instanceof UnsignedIntType) { + composeUnsignedInt(parent, parentType, name, (UnsignedIntType)value, index); + } else if (value instanceof MarkdownType) { + composeMarkdown(parent, parentType, name, (MarkdownType)value, index); + } else if (value instanceof TimeType) { + composeTime(parent, parentType, name, (TimeType)value, index); + } else if (value instanceof IdType) { + composeId(parent, parentType, name, (IdType)value, index); + } else if (value instanceof PositiveIntType) { + composePositiveInt(parent, parentType, name, (PositiveIntType)value, index); + } else if (value instanceof DecimalType) { + composeDecimal(parent, parentType, name, (DecimalType)value, index); +{{compose-type}} + } else { + throw new Error("Unhandled type"); + } + } + +} + diff --git a/org.hl7.fhir.core.generator/configuration/Reference.java b/org.hl7.fhir.core.generator/configuration/Reference.java new file mode 100644 index 000000000..9fc8b8c0c --- /dev/null +++ b/org.hl7.fhir.core.generator/configuration/Reference.java @@ -0,0 +1,28 @@ + + @Override + public String toString() { + if (hasReference()) + return "Reference["+getReference()+"]"; + if (hasIdentifier()) + return "Reference[id:"+getIdentifier()+"]"; + if (hasDisplay()) + return "Reference['"+getDisplay()+"']"; + return "Reference[??]"; + } + + /** + * Convenience setter which sets the reference to the complete {@link IIdType#getValue() value} of the given + * reference. + * + * @param theReference The reference, ornull
+ * @return
+ * @return Returns a reference to this
+ */
+ public Reference setReferenceElement(IIdType theReference) {
+ if (theReference != null) {
+ setReference(theReference.getValue());
+ } else {
+ setReference(null);
+ }
+ return this;
+ }
diff --git a/org.hl7.fhir.core.generator/configuration/Resource.java b/org.hl7.fhir.core.generator/configuration/Resource.java
new file mode 100644
index 000000000..d10c46a52
--- /dev/null
+++ b/org.hl7.fhir.core.generator/configuration/Resource.java
@@ -0,0 +1,16 @@
+
+ @Override
+ public String getIdBase() {
+ return getId();
+ }
+
+ @Override
+ public void setIdBase(String value) {
+ setId(value);
+ }
+ public abstract ResourceType getResourceType();
+
+ public String getLanguage(String defValue) {
+ return hasLanguage() ? getLanguage() : defValue;
+ }
+
diff --git a/org.hl7.fhir.core.generator/configuration/ResourceFactory.java b/org.hl7.fhir.core.generator/configuration/ResourceFactory.java
new file mode 100644
index 000000000..e35598735
--- /dev/null
+++ b/org.hl7.fhir.core.generator/configuration/ResourceFactory.java
@@ -0,0 +1,91 @@
+package org.hl7.fhir.r5.model;
+
+{{license}}
+
+{{startMark}}
+
+import org.hl7.fhir.exceptions.FHIRException;
+
+public class ResourceFactory extends Factory {
+
+ public static Resource createResource(String name) throws FHIRException {
+{{resource-factory}}
+ else
+ throw new FHIRException("Unknown Resource Name '"+name+"'");
+ }
+
+ public static Element createType(String name) throws FHIRException {
+ if ("base64Binary".equals(name))
+ return new Base64BinaryType();
+ if ("boolean".equals(name))
+ return new BooleanType();
+ if ("canonical".equals(name))
+ return new CanonicalType();
+ if ("code".equals(name))
+ return new CodeType();
+ if ("date".equals(name))
+ return new DateType();
+ if ("dateTime".equals(name))
+ return new DateTimeType();
+ if ("decimal".equals(name))
+ return new DecimalType();
+ if ("id".equals(name))
+ return new IdType();
+ if ("instant".equals(name))
+ return new InstantType();
+ if ("integer".equals(name))
+ return new IntegerType();
+ if ("integer64".equals(name))
+ return new Integer64Type();
+ if ("markdown".equals(name))
+ return new MarkdownType();
+ if ("oid".equals(name))
+ return new OidType();
+ if ("positiveInt".equals(name))
+ return new PositiveIntType();
+ if ("string".equals(name))
+ return new StringType();
+ if ("time".equals(name))
+ return new TimeType();
+ if ("unsignedInt".equals(name))
+ return new UnsignedIntType();
+ if ("uri".equals(name))
+ return new UriType();
+ if ("url".equals(name))
+ return new UrlType();
+ if ("uuid".equals(name))
+ return new UuidType();
+{{type-factory}}
+ else
+ throw new FHIRException("Unknown Type Name '"+name+"'"); }
+
+ public static Base createResourceOrType(String name) throws FHIRException {
+ switch (name.hashCode()) {
+ case -1216012752: return new Base64BinaryType();
+ case 64711720: return new BooleanType();
+ case 828351732: return new CanonicalType();
+ case 3059181: return new CodeType();
+ case 3076014: return new DateType();
+ case 1792749467: return new DateTimeType();
+ case 1542263633: return new DecimalType();
+ case 3355: return new IdType();
+ case 1957570017: return new InstantType();
+ case 1958052158: return new IntegerType();
+ case 246938863: return new MarkdownType();
+ case 110026: return new OidType();
+ case -131262666: return new PositiveIntType();
+ case -891985903: return new StringType();
+ case 3560141: return new TimeType();
+ case 1145198778: return new UnsignedIntType();
+ case 116076: return new UriType();
+ case 116079: return new UrlType();
+ case 3601339: return new UuidType();
+{{case-factory}}
+ default:
+ throw new FHIRException("Unknown Resource or Type Name '"+name+"'");
+ }
+ }
+
+
+}
+
diff --git a/org.hl7.fhir.core.generator/configuration/StructureDefinition.java b/org.hl7.fhir.core.generator/configuration/StructureDefinition.java
new file mode 100644
index 000000000..3b2f08ee2
--- /dev/null
+++ b/org.hl7.fhir.core.generator/configuration/StructureDefinition.java
@@ -0,0 +1,14 @@
+
+ public String describeType() {
+ if ("Extension".equals(getType()))
+ return "Extension" ;
+ switch (getKind()) {
+ case COMPLEXTYPE: return getDerivation() == TypeDerivationRule.CONSTRAINT ? "DataType Constraint" : "DataType" ;
+ case LOGICAL: return getDerivation() == TypeDerivationRule.CONSTRAINT ? "Logical Model" : "Logical Model Profile";
+ case PRIMITIVETYPE: return getDerivation() == TypeDerivationRule.CONSTRAINT ? "PrimitiveType Constraint" : "PrimitiveType";
+ case RESOURCE: return getDerivation() == TypeDerivationRule.CONSTRAINT ? "Resource Profile" : "Resource";
+ default:
+ return "Definition";
+ }
+ }
+
diff --git a/org.hl7.fhir.core.generator/configuration/StructureMap.java b/org.hl7.fhir.core.generator/configuration/StructureMap.java
new file mode 100644
index 000000000..9fcaf95c2
--- /dev/null
+++ b/org.hl7.fhir.core.generator/configuration/StructureMap.java
@@ -0,0 +1,5 @@
+
+ public String toString() {
+ return StructureMapUtilities.render(this);
+ }
+
diff --git a/org.hl7.fhir.core.generator/configuration/StructureMapGroupComponent.java b/org.hl7.fhir.core.generator/configuration/StructureMapGroupComponent.java
new file mode 100644
index 000000000..546498440
--- /dev/null
+++ b/org.hl7.fhir.core.generator/configuration/StructureMapGroupComponent.java
@@ -0,0 +1,5 @@
+
+ public String toString() {
+ return StructureMapUtilities.groupToString(this);
+ }
+
diff --git a/org.hl7.fhir.core.generator/configuration/StructureMapGroupRuleComponent.java b/org.hl7.fhir.core.generator/configuration/StructureMapGroupRuleComponent.java
new file mode 100644
index 000000000..cb894cce8
--- /dev/null
+++ b/org.hl7.fhir.core.generator/configuration/StructureMapGroupRuleComponent.java
@@ -0,0 +1,5 @@
+
+ public String toString() {
+ return StructureMapUtilities.ruleToString(this);
+ }
+
diff --git a/org.hl7.fhir.core.generator/configuration/StructureMapGroupRuleSourceComponent.java b/org.hl7.fhir.core.generator/configuration/StructureMapGroupRuleSourceComponent.java
new file mode 100644
index 000000000..e730d7a9e
--- /dev/null
+++ b/org.hl7.fhir.core.generator/configuration/StructureMapGroupRuleSourceComponent.java
@@ -0,0 +1,5 @@
+
+ public String toString() {
+ return StructureMapUtilities.sourceToString(this);
+ }
+
diff --git a/org.hl7.fhir.core.generator/configuration/StructureMapGroupRuleTargetComponent.java b/org.hl7.fhir.core.generator/configuration/StructureMapGroupRuleTargetComponent.java
new file mode 100644
index 000000000..6c8599afe
--- /dev/null
+++ b/org.hl7.fhir.core.generator/configuration/StructureMapGroupRuleTargetComponent.java
@@ -0,0 +1,5 @@
+
+ public String toString() {
+ return StructureMapUtilities.targetToString(this);
+ }
+
diff --git a/org.hl7.fhir.core.generator/configuration/StructureMapGroupRuleTargetParameterComponent.java b/org.hl7.fhir.core.generator/configuration/StructureMapGroupRuleTargetParameterComponent.java
new file mode 100644
index 000000000..a9ff001b3
--- /dev/null
+++ b/org.hl7.fhir.core.generator/configuration/StructureMapGroupRuleTargetParameterComponent.java
@@ -0,0 +1,6 @@
+
+ public String toString() {
+ return value == null ? "null!" : value.toString();
+ }
+
+
diff --git a/org.hl7.fhir.core.generator/configuration/TypeRefComponent.java b/org.hl7.fhir.core.generator/configuration/TypeRefComponent.java
new file mode 100644
index 000000000..136ba900d
--- /dev/null
+++ b/org.hl7.fhir.core.generator/configuration/TypeRefComponent.java
@@ -0,0 +1,74 @@
+
+ public boolean hasTarget() {
+ return Utilities.existsInList(getCode(), "Reference", "canonical", "CodeableReference");
+ }
+
+ /**
+ * This code checks for the system prefix and returns the FHIR type
+ *
+ * @return
+ */
+ public String getWorkingCode() {
+ if (hasExtension(ToolingExtensions.EXT_FHIR_TYPE))
+ return getExtensionString(ToolingExtensions.EXT_FHIR_TYPE);
+ if (!hasCodeElement())
+ return null;
+ if (getCodeElement().hasExtension(ToolingExtensions.EXT_XML_TYPE)) {
+ String s = getCodeElement().getExtensionString(ToolingExtensions.EXT_XML_TYPE);
+ if ("xsd:gYear OR xsd:gYearMonth OR xsd:date OR xsd:dateTime".equalsIgnoreCase(s))
+ return "dateTime";
+ if ("xsd:gYear OR xsd:gYearMonth OR xsd:date".equalsIgnoreCase(s))
+ return "date";
+ if ("xsd:dateTime".equalsIgnoreCase(s))
+ return "instant";
+ if ("xsd:token".equals(s))
+ return "code";
+ if ("xsd:boolean".equals(s))
+ return "boolean";
+ if ("xsd:string".equals(s))
+ return "string";
+ if ("xsd:time".equals(s))
+ return "time";
+ if ("xsd:int".equals(s))
+ return "integer";
+ if ("xsd:decimal OR xsd:double".equals(s))
+ return "decimal";
+ if ("xsd:decimal".equalsIgnoreCase(s))
+ return "decimal";
+ if ("xsd:base64Binary".equalsIgnoreCase(s))
+ return "base64Binary";
+ if ("xsd:positiveInteger".equalsIgnoreCase(s))
+ return "positiveInt";
+ if ("xsd:nonNegativeInteger".equalsIgnoreCase(s))
+ return "unsignedInt";
+ if ("xsd:anyURI".equalsIgnoreCase(s))
+ return "uri";
+
+ throw new Error("Unknown xml type '"+s+"'");
+ }
+ return getCode();
+ }
+
+ @Override
+ public String toString() {
+ String res = getCode();
+ if (hasProfile()) {
+ res = res + "{";
+ boolean first = true;
+ for (CanonicalType s : getProfile()) {
+ if (first) first = false; else res = res + "|";
+ res = res + s.getValue();
+ }
+ res = res + "}";
+ }
+ if (hasTargetProfile()) {
+ res = res + "->(";
+ boolean first = true;
+ for (CanonicalType s : getProfile()) {
+ if (first) first = false; else res = res + "|";
+ res = res + s.getValue();
+ }
+ res = res + ")";
+ }
+ return res;
+ }
diff --git a/org.hl7.fhir.core.generator/configuration/XmlParser.java b/org.hl7.fhir.core.generator/configuration/XmlParser.java
new file mode 100644
index 000000000..f9dacdc96
--- /dev/null
+++ b/org.hl7.fhir.core.generator/configuration/XmlParser.java
@@ -0,0 +1,922 @@
+package org.hl7.fhir.r5.formats;
+
+
+// generated
+
+{{license}}
+
+{{startMark}}
+
+import org.hl7.fhir.r5.model.*;
+import org.hl7.fhir.r5.model.Enumerations.FHIRVersion;
+import org.xmlpull.v1.*;
+import org.hl7.fhir.utilities.Utilities;
+import org.hl7.fhir.exceptions.FHIRFormatError;
+import org.hl7.fhir.exceptions.FHIRException;
+import java.io.IOException;
+
+public class XmlParser extends XmlParserBase {
+
+ public XmlParser() {
+ super();
+ }
+
+ public XmlParser(boolean allowUnknownContent) {
+ super();
+ setAllowUnknownContent(allowUnknownContent);
+ }
+
+ protected boolean parseBaseContent(int eventType, XmlPullParser xpp, Base res) throws XmlPullParserException, IOException, FHIRFormatError {
+ return false;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected null
. If more than one\r\n");
+// write(" * link is found which matches the given relation, returns the first matching BundleLinkComponent.\r\n");
+// write(" * \r\n");
+// write(" * @param theRelation\r\n");
+// write(" * The relation, such as \"next\", or \"self. See the constants such as {@link IBaseBundle#LINK_SELF} and {@link IBaseBundle#LINK_NEXT}.\r\n");
+// write(" * @return Returns a matching BundleLinkComponent, or null
\r\n");
+// write(" * @see IBaseBundle#LINK_NEXT\r\n");
+// write(" * @see IBaseBundle#LINK_PREV\r\n");
+// write(" * @see IBaseBundle#LINK_SELF\r\n");
+// write(" */\r\n");
+// write(" public BundleLinkComponent getLink(String theRelation) {\r\n");
+// write(" org.apache.commons.lang3.Validate.notBlank(theRelation, \"theRelation may not be null or empty\");\r\n");
+// write(" for (BundleLinkComponent next : getLink()) {\r\n");
+// write(" if (theRelation.equals(next.getRelation())) {\r\n");
+// write(" return next;\r\n");
+// write(" }\r\n");
+// write(" }\r\n");
+// write(" return null;\r\n");
+// write(" }\r\n");
+// write("\r\n");
+// write(" /**\r\n");
+// write(" * Returns the {@link #getLink() link} which matches a given {@link BundleLinkComponent#getRelation() relation}. \r\n");
+// write(" * If no link is found which matches the given relation, creates a new BundleLinkComponent with the\r\n");
+// write(" * given relation and adds it to this Bundle. If more than one\r\n");
+// write(" * link is found which matches the given relation, returns the first matching BundleLinkComponent.\r\n");
+// write(" * \r\n");
+// write(" * @param theRelation\r\n");
+// write(" * The relation, such as \"next\", or \"self. See the constants such as {@link IBaseBundle#LINK_SELF} and {@link IBaseBundle#LINK_NEXT}.\r\n");
+// write(" * @return Returns a matching BundleLinkComponent, or null
\r\n");
+// write(" * @see IBaseBundle#LINK_NEXT\r\n");
+// write(" * @see IBaseBundle#LINK_PREV\r\n");
+// write(" * @see IBaseBundle#LINK_SELF\r\n");
+// write(" */\r\n");
+// write(" public BundleLinkComponent getLinkOrCreate(String theRelation) {\r\n");
+// write(" org.apache.commons.lang3.Validate.notBlank(theRelation, \"theRelation may not be null or empty\");\r\n");
+// write(" for (BundleLinkComponent next : getLink()) {\r\n");
+// write(" if (theRelation.equals(next.getRelation())) {\r\n");
+// write(" return next;\r\n");
+// write(" }\r\n");
+// write(" }\r\n");
+// write(" BundleLinkComponent retVal = new BundleLinkComponent();\r\n");
+// write(" retVal.setRelation(theRelation);\r\n");
+// write(" getLink().add(retVal);\r\n");
+// write(" return retVal;\r\n");
+// write(" }\r\n");
+// write("");
+// }
+// if (upFirst(name).equals("HumanName")) {
+// write(" /**\r\n");
+// write(" /**\r\n");
+// write(" * Returns all repetitions of {@link #getGiven() given name} as a space separated string\r\n");
+// write(" * \r\n");
+// write(" * @see DatatypeUtil#joinStringsSpaceSeparated(List)\r\n");
+// write(" */\r\n");
+// write(" public String getGivenAsSingleString() {\r\n");
+// write(" return joinStringsSpaceSeparated(getGiven());\r\n");
+// write(" }\r\n");
+// write("\r\n");
+// write(" /**\r\n");
+// write(" * Returns all repetitions of {@link #getPrefix() prefix name} as a space separated string\r\n");
+// write(" * \r\n");
+// write(" * @see DatatypeUtil#joinStringsSpaceSeparated(List)\r\n");
+// write(" */\r\n");
+// write(" public String getPrefixAsSingleString() {\r\n");
+// write(" return joinStringsSpaceSeparated(getPrefix());\r\n");
+// write(" }\r\n");
+// write("\r\n");
+// write(" /**\r\n");
+// write(" * Returns all repetitions of {@link #getSuffix() suffix} as a space separated string\r\n");
+// write(" * \r\n");
+// write(" * @see DatatypeUtil#joinStringsSpaceSeparated(List)\r\n");
+// write(" */\r\n");
+// write(" public String getSuffixAsSingleString() {\r\n");
+// write(" return joinStringsSpaceSeparated(getSuffix());\r\n");
+// write(" }\r\n");
+// write("\r\n");
+// write(" /**\r\n");
+// write(" * Returns all of the components of the name (prefix, given, family, suffix) as a single string with a single spaced\r\n");
+// write(" * string separating each part.\r\n");
+// write(" * \r\n"); +// write(" * If none of the parts are populated, returns the {@link #getTextElement() text} element value instead.\r\n"); +// write(" *
\r\n"); +// write(" */\r\n"); +// write(" public String getNameAsSingleString() {\r\n"); +// write(" Listthis
for easy chaining\r\n");
+// write(" */\r\n");
+// write(" public Meta addTag(String theSystem, String theCode, String theDisplay) {\r\n");
+// write(" addTag().setSystem(theSystem).setCode(theCode).setDisplay(theDisplay);\r\n");
+// write(" return this;\r\n");
+// write(" }\r\n");
+// write("");
+// write(" /**\r\n");
+// write(" * Convenience method which adds a security tag\r\n");
+// write(" * \r\n");
+// write(" * @param theSystem The code system\r\n");
+// write(" * @param theCode The code\r\n");
+// write(" * @param theDisplay The display name\r\n");
+// write(" * @return Returns a reference to this
for easy chaining\r\n");
+// write(" */\r\n");
+// write(" public Meta addSecurity(String theSystem, String theCode, String theDisplay) {\r\n");
+// write(" addSecurity().setSystem(theSystem).setCode(theCode).setDisplay(theDisplay);\r\n");
+// write(" return this;\r\n");
+// write(" }\r\n");
+// write("");
+// write(" /**\r\n" );
+// write( " * Returns the first tag (if any) that has the given system and code, or returns\r\n");
+// write( " * null
if none\r\n");
+// write( " */\r\n" );
+// write( " public Coding getTag(String theSystem, String theCode) {\r\n");
+// write ( " for (Coding next : getTag()) {\r\n" );
+// write ( " if (ca.uhn.fhir.util.ObjectUtil.equals(next.getSystem(), theSystem) && ca.uhn.fhir.util.ObjectUtil.equals(next.getCode(), theCode)) {\r\n" );
+// write ( " return next;\r\n" );
+// write ( " }\r\n" );
+// write ( " }\r\n" );
+// write( " return null;\r\n" );
+// write( " }\r\n" );
+// write( "\r\n" );
+// write( " /**\r\n" );
+// write( " * Returns the first security label (if any) that has the given system and code, or returns\r\n" );
+// write( " * null
if none\r\n");
+// write( " */\r\n" );
+// write( " public Coding getSecurity(String theSystem, String theCode) {\r\n");
+// write( " for (Coding next : getTag()) {\r\n" );
+// write( " if (ca.uhn.fhir.util.ObjectUtil.equals(next.getSystem(), theSystem) && ca.uhn.fhir.util.ObjectUtil.equals(next.getCode(), theCode)) {\r\n" );
+// write( " return next;\r\n" );
+// write( " }\r\n" );
+// write( " }\r\n" );
+// write( " return null;\r\n");
+// write( " }\r\n");
+// }
+// if (upFirst(name).equals("Period")) {
+// write(" /**\r\n");
+// write(" * Sets the value for start ()\r\n");
+// write(" *\r\n");
+// write(" * \r\n"); +// write(" * Definition:\r\n"); +// write(" * The start of the period. The boundary is inclusive.\r\n"); +// write(" *
\r\n"); +// write(" */\r\n"); +// write(" public Period setStart( Date theDate, TemporalPrecisionEnum thePrecision) {\r\n"); +// write(" start = new DateTimeType(theDate, thePrecision); \r\n"); +// write(" return this; \r\n"); +// write(" }\r\n"); +// write("\r\n"); +// write(" /**\r\n"); +// write(" * Sets the value for end ()\r\n"); +// write(" *\r\n"); +// write(" *\r\n"); +// write(" * Definition:\r\n"); +// write(" * The end of the period. The boundary is inclusive.\r\n"); +// write(" *
\r\n"); +// write(" */\r\n"); +// write(" public Period setEnd( Date theDate, TemporalPrecisionEnum thePrecision) {\r\n"); +// write(" end = new DateTimeType(theDate, thePrecision); \r\n"); +// write(" return this; \r\n"); +// write(" }\r\n"); +// write("\r\n"); +// } +// if (upFirst(name).equals("Reference")) { +// write(" /**\r\n"); +// write(" * Convenience setter which sets the reference to the complete {@link IIdType#getValue() value} of the given\r\n"); +// write(" * reference.\r\n"); +// write(" *\r\n"); +// write(" * @param theReference The reference, ornull
\r\n");
+// write(" * @return \r\n");
+// write(" * @return Returns a reference to this\r\n");
+// write(" */\r\n");
+// write(" public Reference setReferenceElement(IIdType theReference) {\r\n");
+// write(" if (theReference != null) {\r\n");
+// write(" setReference(theReference.getValue());\r\n");
+// write(" } else {\r\n");
+// write(" setReference(null);\r\n");
+// write(" }\r\n");
+// write(" return this;\r\n");
+// write(" }\r\n");
+// write("");
+// }
+// }
+//
+// private void generateFhirType(String path) throws IOException {
+// write(" public String fhirType();\r\n\r\n");
+// }
+//
+// private void jdoc(String indent, String text) throws IOException {
+// write(indent+"/**\r\n");
+// write(indent+" * "+text+"\r\n");
+// write(indent+" */\r\n");
+// }
+//
+// private String upFirst(String name) {
+// return name.substring(0,1).toUpperCase()+name.substring(1);
+// }
+//
+// private boolean hasDecimal(ElementDefn root) {
+// for (ElementDefn e : root.getElements()) {
+// if (e.typeCode().equals("decimal") || hasDecimalInner(e))
+// return true;
+// }
+// return false;
+// }
+//
+// private boolean hasString(ElementDefn root) {
+// for (ElementDefn e : root.getElements()) {
+// if (Utilities.existsInList(e.typeCode(), "string", "id", "code", "uri", "oid", "uuid", "url", "canonical") || hasString(e))
+// return true;
+// }
+// return false;
+// }
+//
+// private boolean hasSharedEnums(ElementDefn root) {
+// for (ElementDefn e : root.getElements()) {
+// if ((e.getBinding() != null && e.getBinding().isShared()) || hasSharedEnums(e))
+// return true;
+// }
+// return false;
+// }
+//
+// private boolean hasXhtml(ElementDefn root) {
+// for (ElementDefn e : root.getElements()) {
+// if (e.isXhtmlElement() || hasXhtmlInner(e))
+// return true;
+// }
+// return false;
+// }
+//
+// private boolean hasXhtmlInner(ElementDefn e) {
+// for (ElementDefn c : e.getElements()) {
+// if (c.isXhtmlElement() || hasXhtmlInner(c))
+// return true;
+// }
+//
+// return false;
+// }
+//
+// private boolean hasDecimalInner(ElementDefn e) {
+// for (ElementDefn c : e.getElements()) {
+// if (c.typeCode().equals("decimal") || hasDecimalInner(c))
+// return true;
+// }
+//
+// return false;
+// }
+//
+// private void generateEnum(ElementDefn e, String name) throws Exception {
+// String tn = typeNames.get(e);
+// String tns = tn.substring(tn.indexOf("<")+1);
+// tns = tns.substring(0, tns.length()-1);
+// BindingSpecification cd = e.getBinding();
+// if (cd.isShared())
+// return;
+// cd.getValueSet().setUserData("java-generated", true);
+// Listthis
for easy method chaining");
+// write(indent+"public " + className + " set"+getTitle(getElementName(e.getName(), false))+"(" + "List<"+listGenericType+"> the" + getTitle(getElementName(e.getName(), false)) + ") throws FHIRException;\r\n\r\n");
+//
+// /*
+// * hasXXX() for repeatable type
+// */
+// jdoc(indent, "@return whether there is more than zero values for "+getElementName(e.getName(), false));
+// write(indent+"public boolean has"+getTitle(getElementName(e.getName(), false))+"();\r\n");
+// jdoc(indent, "@return minimum allowed cardinality for "+getElementName(e.getName(), false)+". Note that with patterns, this may be different for the underlying resource");
+// write(indent+"public int get"+getTitle(getElementName(e.getName(), false))+"Min();\r\n");
+// jdoc(indent, "@return maximum allowed cardinality for "+getElementName(e.getName(), false)+". Note that with patterns, this may be different for the underlying resource");
+// write(indent+"public int get"+getTitle(getElementName(e.getName(), false))+"Max();\r\n");
+//
+// write("\r\n");
+// if (e.getTypes().size() == 1 && (definitions.getPrimitives().containsKey(e.typeCode()) || e.typeCode().equals("xml:lang") || e.typeCode().startsWith("canonical("))) {
+// /*
+// * addXXXElement() for repeatable primitive
+// */
+// jdoc(indent, "@return {@link #"+getElementName(e.getName(), true)+"} ("+e.getDefinition()+")");
+// write(indent+"public "+tn+" add"+getTitle(getElementName(e.getName(), false))+"Element() throws FHIRException;\r\n");
+// write("\r\n");
+//
+// /*
+// * addXXX(foo) for repeatable primitive
+// */
+// jdoc(indent, "@param value {@link #"+getElementName(e.getName(), true)+"} ("+e.getDefinition()+")");
+// write(indent+"public "+className+" add"+getTitle(getElementName(e.getName(), false))+"("+simpleType+" value) throws FHIRException;\r\n");
+// write("\r\n");
+//
+// /*
+// * hasXXX(foo) for repeatable primitive
+// */
+// jdoc(indent, "@param value {@link #"+getElementName(e.getName(), true)+"} ("+e.getDefinition()+")");
+// write(indent+"public boolean has"+getTitle(getElementName(e.getName(), false))+"("+simpleType+" value) throws FHIRException;\r\n");
+// write("\r\n");
+// } else {
+// if (!definitions.getBaseResources().containsKey(tn)) {
+// /*
+// * addXXX() for repeatable composite
+// */
+// write(indent+"public "+tn+" add"+getTitle(getElementName(e.getName(), false))+"() throws FHIRException;\r\n");
+// write("\r\n");
+//
+// /*
+// * addXXX(foo) for repeatable composite
+// */
+// write(indent+"public "+className+" add"+getTitle(getElementName(e.getName(), false))+"("+tn+" t) throws FHIRException;\r\n");
+// write("\r\n");
+// } else {
+// /*
+// * addXXX(foo) for repeatable composite
+// */
+// write(indent+"public "+className+" add"+getTitle(getElementName(e.getName(), false))+"("+tn+" t) throws FHIRException;\r\n");
+// write("\r\n");
+// }
+//
+// /*
+// * getXXXFirstRep() for repeatable element
+// */
+// if (!"DomainResource".equals(className)) {
+// jdoc(indent, "@return The first repetition of repeating field {@link #"+getElementName(e.getName(), true)+"}, creating it if it does not already exist");
+// write(indent+"public "+tn+" get"+getTitle(getElementName(e.getName(), false))+"FirstRep() throws FHIRException;\r\n\r\n");
+// }
+// }
+// } else {
+// if (isJavaPrimitive(e) || (e.getTypes().size() == 1 && e.typeCode().startsWith("canonical("))) {
+// jdoc(indent, "@return {@link #"+getElementName(e.getName(), true)+"} ("+e.getDefinition()+"). This is the underlying object with id, value and extensions. The accessor \"get"+getTitle(getElementName(e.getName(), false))+"\" gives direct access to the value");
+// if (isReferenceRefField) {
+// /*
+// * Reference#getReferenceElement is defined differently in BaseReference.java?
+// */
+// write(indent+"public "+tn+" get"+getTitle(getElementName(e.getName(), false))+"Element_() throws FHIRException;\r\n");
+// } else {
+// write(indent+"public "+tn+" get"+getTitle(getElementName(e.getName(), false))+"Element() throws FHIRException;\r\n");
+// }
+// write("\r\n");
+//
+// jdoc(indent, "@return whether there is more than zero values for "+getElementName(e.getName(), false));
+// write(indent+"public boolean has"+getTitle(getElementName(e.getName(), false))+"();\r\n");
+// jdoc(indent, "@return minimum allowed cardinality for "+getElementName(e.getName(), false)+". Note that with patterns, this may be different for the underlying resource");
+// write(indent+"public int get"+getTitle(getElementName(e.getName(), false))+"Min() throws FHIRException;\r\n");
+// jdoc(indent, "@return maximum allowed cardinality for "+getElementName(e.getName(), false)+". Note that with patterns, this may be different for the underlying resource");
+// write(indent+"public int get"+getTitle(getElementName(e.getName(), false))+"Max() throws FHIRException;\r\n");
+//
+// write(indent+"public boolean has"+getTitle(getElementName(e.getName(), false))+"Element();\r\n");
+// write("\r\n");
+// jdoc(indent, "@param value {@link #"+getElementName(e.getName(), true)+"} ("+e.getDefinition()+"). This is the underlying object with id, value and extensions. The accessor \"get"+getTitle(getElementName(e.getName(), false))+"\" gives direct access to the value");
+// write(indent+"public "+className+" set"+getTitle(getElementName(e.getName(), false))+"Element("+tn+" value) throws FHIRException;\r\n");
+// write("\r\n");
+// jdoc(indent, "@return "+e.getDefinition());
+// write(indent+"public "+simpleType+" get"+getTitle(getElementName(e.getName(), false))+"() throws FHIRException;\r\n");
+// write("\r\n");
+// generateSetter(e, indent, className, tn, simpleType);
+//
+// // BigDecimal sugar methods
+// if (simpleType.equals("BigDecimal")) {
+// generateSetter(e, indent, className, tn, "long");
+// generateSetter(e, indent, className, tn, "double");
+// }
+//
+// } else {
+// jdoc(indent, "@return {@link #"+getElementName(e.getName(), true)+"} ("+e.getDefinition()+")");
+// write(indent+"public "+tn+" get"+getTitle(getElementName(e.getName(), false))+"() throws FHIRException ;\r\n");
+// write("\r\n");
+// if (e.getTypes().size() > 1 && (tn.equals("Type") || !tn.endsWith(".Type"))) {
+// for (TypeRef t : e.getTypes()) {
+// jdoc(indent, "@return {@link #"+getElementName(e.getName(), true)+"} ("+e.getDefinition()+")");
+// String ttn = getTypename(t);
+// write(indent+"public "+ttn+" get"+getTitle(getElementName(e.getName(), false))+ttn+"() throws FHIRException;\r\n");
+// write("\r\n");
+// write(indent+"public boolean has"+getTitle(getElementName(e.getName(), false))+ttn+"();\r\n");
+// write("\r\n");
+// }
+// }
+// jdoc(indent, "@return whether there is more than zero values for "+getElementName(e.getName(), false));
+// write(indent+"public boolean has"+getTitle(getElementName(e.getName(), false))+"();\r\n");
+// jdoc(indent, "@return minimum allowed cardinality for "+getElementName(e.getName(), false)+". Note that with patterns, this may be different for the underlying resource");
+// write(indent+"public int get"+getTitle(getElementName(e.getName(), false))+"Min();\r\n");
+// jdoc(indent, "@return maximum allowed cardinality for "+getElementName(e.getName(), false)+". Note that with patterns, this may be different for the underlying resource");
+// write(indent+"public int get"+getTitle(getElementName(e.getName(), false))+"Max();\r\n");
+//
+// jdoc(indent, "@param value {@link #"+getElementName(e.getName(), true)+"} ("+e.getDefinition()+")");
+// write(indent+"public "+className+" set"+getTitle(getElementName(e.getName(), false))+"("+tn+" value) throws FHIRException;\r\n");
+// write("\r\n");
+// if (e.getTypes().size() == 1 && e.typeCode().startsWith("Reference(")) {
+// List