From 53882b2c231b99269755bc3ed507a956d191b4a7 Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Mon, 10 Mar 2014 18:17:30 -0400
Subject: [PATCH] Fix unit tests
---
hapi-fhir-base/TODO.txt | 4 +-
hapi-fhir-base/pom.xml | 3 +-
...BaseRuntimeElementCompositeDefinition.java | 5 +-
.../ca/uhn/fhir/context/ModelScanner.java | 12 +-
...ChildCompositeBoundDatatypeDefinition.java | 27 ++++
.../RuntimeChildResourceDefinition.java | 6 +-
...imeChildUndeclaredExtensionDefinition.java | 6 +-
.../context/RuntimeResourceDefinition.java | 1 +
.../RuntimeResourceReferenceDefinition.java | 6 +-
.../ca/uhn/fhir/model/api/BaseElement.java | 29 +++++
.../fhir/model/api/BaseResourceReference.java | 8 ++
.../api/ISupportsUndeclaredExtensions.java | 12 +-
.../uhn/fhir/model/api/ResourceReference.java | 32 -----
.../fhir/model/api/UndeclaredExtension.java | 41 +++++-
.../model/api/annotation/ResourceDef.java | 2 +
.../fhir/model/dstu/composite/AddressDt.java | 3 +-
.../model/dstu/composite/AttachmentDt.java | 3 +-
.../dstu/composite/CodeableConceptDt.java | 3 +-
.../fhir/model/dstu/composite/CodingDt.java | 11 +-
.../fhir/model/dstu/composite/ContactDt.java | 3 +-
.../model/dstu/composite/HumanNameDt.java | 3 +-
.../model/dstu/composite/IdentifierDt.java | 11 +-
.../fhir/model/dstu/composite/PeriodDt.java | 3 +-
.../fhir/model/dstu/composite/QuantityDt.java | 7 +-
.../fhir/model/dstu/composite/RangeDt.java | 3 +-
.../fhir/model/dstu/composite/RatioDt.java | 3 +-
.../dstu/composite/ResourceReferenceDt.java | 3 +-
.../model/dstu/composite/SampledDataDt.java | 19 +--
.../fhir/model/dstu/composite/ScheduleDt.java | 7 +-
.../uhn/fhir/model/dstu/resource/Device.java | 26 ++--
.../uhn/fhir/model/dstu/resource/Group.java | 8 +-
.../fhir/model/dstu/resource/Location.java | 30 ++---
.../fhir/model/dstu/resource/Medication.java | 16 +--
.../fhir/model/dstu/resource/Observation.java | 30 ++---
.../model/dstu/resource/Organization.java | 18 +--
.../uhn/fhir/model/dstu/resource/Patient.java | 32 ++---
.../model/dstu/resource/Practitioner.java | 26 ++--
.../uhn/fhir/model/dstu/resource/Profile.java | 2 +-
.../fhir/model/dstu/resource/Specimen.java | 40 +++---
.../fhir/model/dstu/resource/Substance.java | 10 +-
.../fhir/model/dstu/resource/ValueSet.java | 2 +-
.../java/ca/uhn/fhir/parser/ParserState.java | 41 +++---
.../java/ca/uhn/fhir/parser/XmlParser.java | 122 ++++++++++++------
.../uhn/fhir/rest/server/RestfulServer.java | 12 +-
.../java/ca/uhn/fhir/util/ElementUtil.java | 13 +-
.../java/example/ExampleRestfulServlet.java | 38 ++++++
.../RestfulObservationResourceProvider.java | 86 ++++++++++++
.../example/java/example/RestfulServlet.java | 30 -----
.../src/site/xdoc/doc_rest_server.xml | 38 +++++-
.../ca/uhn/fhir/context/ModelScannerTest.java | 12 +-
.../fhir/context/ResourceWithExtensionsA.java | 16 +--
.../RuntimeResourceDefinitionTest.java | 29 +++--
.../ca/uhn/fhir/parser/XmlParserTest.java | 76 +++++++++--
.../fhir/rest/server/ResfulServerTest.java | 21 ++-
.../uhn/fhir/tinder/BaseStructureParser.java | 1 +
.../BaseStructureSpreadsheetParser.java | 2 +
.../java/ca/uhn/fhir/tinder/model/Child.java | 2 +-
.../ca/uhn/fhir/tinder/model/Resource.java | 9 ++
.../src/main/resources/vm/dt_composite.vm | 4 +-
.../src/main/resources/vm/resource.vm | 2 +-
60 files changed, 710 insertions(+), 360 deletions(-)
create mode 100644 hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildCompositeBoundDatatypeDefinition.java
create mode 100644 hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BaseResourceReference.java
delete mode 100644 hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ResourceReference.java
create mode 100644 hapi-fhir-base/src/site/example/java/example/ExampleRestfulServlet.java
create mode 100644 hapi-fhir-base/src/site/example/java/example/RestfulObservationResourceProvider.java
delete mode 100644 hapi-fhir-base/src/site/example/java/example/RestfulServlet.java
diff --git a/hapi-fhir-base/TODO.txt b/hapi-fhir-base/TODO.txt
index b1fcbb91c2f..e16839de24e 100644
--- a/hapi-fhir-base/TODO.txt
+++ b/hapi-fhir-base/TODO.txt
@@ -27,4 +27,6 @@
* Support slices in the model
- * Support extensions (declared and undeclared) in primitives, narratives, etc.
\ No newline at end of file
+ * Support extensions (declared and undeclared) in primitives, narratives, etc.
+
+ * Create a Maven archetype for a server project and a client project
\ No newline at end of file
diff --git a/hapi-fhir-base/pom.xml b/hapi-fhir-base/pom.xml
index d065a22968d..305c65e4647 100644
--- a/hapi-fhir-base/pom.xml
+++ b/hapi-fhir-base/pom.xml
@@ -151,6 +151,8 @@
3.3org.apache.maven.pluginsmaven-surefire-report-plugin
@@ -176,7 +178,6 @@
maven-jxr-plugin2.3
- -->
org.apache.maven.pluginsmaven-project-info-reports-plugin
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeElementCompositeDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeElementCompositeDefinition.java
index 0d49ee54711..c0a99f4da16 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeElementCompositeDefinition.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeElementCompositeDefinition.java
@@ -24,6 +24,9 @@ public abstract class BaseRuntimeElementCompositeDefinition();
- for (BaseRuntimeChildDefinition next : myChildren) {
+ for (BaseRuntimeChildDefinition next : myChildren) {
for (String nextName : next.getValidChildNames()) {
if (myNameToChild.containsKey(nextName)) {
throw new ConfigurationException("Duplicate child name: " + nextName);
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/ModelScanner.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/ModelScanner.java
index dbcedb7581d..67b31b32d73 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/ModelScanner.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/ModelScanner.java
@@ -27,7 +27,7 @@ import ca.uhn.fhir.model.api.IPrimitiveDatatype;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.IResourceBlock;
import ca.uhn.fhir.model.api.IValueSetEnumBinder;
-import ca.uhn.fhir.model.api.ResourceReference;
+import ca.uhn.fhir.model.api.BaseResourceReference;
import ca.uhn.fhir.model.api.annotation.Block;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.CodeTableDef;
@@ -37,6 +37,7 @@ import ca.uhn.fhir.model.api.annotation.Extension;
import ca.uhn.fhir.model.api.annotation.ResourceDef;
import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
import ca.uhn.fhir.model.primitive.BoundCodeDt;
+import ca.uhn.fhir.model.primitive.BoundCodeableConceptDt;
import ca.uhn.fhir.model.primitive.CodeDt;
import ca.uhn.fhir.model.primitive.DateDt;
import ca.uhn.fhir.model.primitive.ICodedDatatype;
@@ -323,7 +324,7 @@ class ModelScanner {
if (IElement.class.isAssignableFrom(nextElementType)) {
addScanAlso((Class extends IElement>) nextElementType);
}
- } else if (ResourceReference.class.isAssignableFrom(nextElementType)) {
+ } else if (BaseResourceReference.class.isAssignableFrom(nextElementType)) {
/*
* Child is a resource reference
*/
@@ -362,7 +363,12 @@ class ModelScanner {
def = new RuntimeChildPrimitiveDatatypeDefinition(next, elementName, descriptionAnnotation, childAnnotation, nextDatatype);
}
} else {
- def = new RuntimeChildCompositeDatatypeDefinition(next, elementName, childAnnotation, descriptionAnnotation, nextDatatype);
+ if (nextElementType.equals(BoundCodeableConceptDt.class)) {
+ IValueSetEnumBinder> binder = getBoundCodeBinder(next);
+ def = new RuntimeChildCompositeBoundDatatypeDefinition(next, elementName, childAnnotation, descriptionAnnotation, nextDatatype, binder);
+ } else {
+ def = new RuntimeChildCompositeDatatypeDefinition(next, elementName, childAnnotation, descriptionAnnotation, nextDatatype);
+ }
}
CodeableConceptElement concept = next.getAnnotation(CodeableConceptElement.class);
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildCompositeBoundDatatypeDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildCompositeBoundDatatypeDefinition.java
new file mode 100644
index 00000000000..11edc636551
--- /dev/null
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildCompositeBoundDatatypeDefinition.java
@@ -0,0 +1,27 @@
+package ca.uhn.fhir.context;
+
+import java.lang.reflect.Field;
+
+import ca.uhn.fhir.model.api.IDatatype;
+import ca.uhn.fhir.model.api.IValueSetEnumBinder;
+import ca.uhn.fhir.model.api.annotation.Child;
+import ca.uhn.fhir.model.api.annotation.Description;
+
+public class RuntimeChildCompositeBoundDatatypeDefinition extends RuntimeChildCompositeDatatypeDefinition {
+
+ private IValueSetEnumBinder> myBinder;
+
+ public RuntimeChildCompositeBoundDatatypeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class extends IDatatype> theDatatype, IValueSetEnumBinder> theBinder) {
+ super(theField, theElementName, theChildAnnotation, theDescriptionAnnotation, theDatatype);
+ myBinder = theBinder;
+ if (theBinder==null) {
+ throw new IllegalArgumentException("Binder must not be null");
+ }
+ }
+
+ @Override
+ public IValueSetEnumBinder> getInstanceConstructorArguments() {
+ return myBinder;
+ }
+
+}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildResourceDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildResourceDefinition.java
index 119115b77f5..949df26577a 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildResourceDefinition.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildResourceDefinition.java
@@ -8,7 +8,7 @@ import java.util.Set;
import ca.uhn.fhir.model.api.IElement;
import ca.uhn.fhir.model.api.IResource;
-import ca.uhn.fhir.model.api.ResourceReference;
+import ca.uhn.fhir.model.api.BaseResourceReference;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.Description;
@@ -28,7 +28,7 @@ public class RuntimeChildResourceDefinition extends BaseRuntimeDeclaredChildDefi
@Override
public String getChildNameByDatatype(Class extends IElement> theDatatype) {
- if (ResourceReference.class.equals(theDatatype)) {
+ if (BaseResourceReference.class.isAssignableFrom(theDatatype)) {
return getElementName();
}
return null;
@@ -36,7 +36,7 @@ public class RuntimeChildResourceDefinition extends BaseRuntimeDeclaredChildDefi
@Override
public BaseRuntimeElementDefinition> getChildElementDefinitionByDatatype(Class extends IElement> theDatatype) {
- if (ResourceReference.class.equals(theDatatype)) {
+ if (BaseResourceReference.class.isAssignableFrom(theDatatype)) {
return myRuntimeDef;
}
return null;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildUndeclaredExtensionDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildUndeclaredExtensionDefinition.java
index e967126ab67..057ce9e7b37 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildUndeclaredExtensionDefinition.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildUndeclaredExtensionDefinition.java
@@ -11,7 +11,7 @@ import java.util.Set;
import ca.uhn.fhir.model.api.IDatatype;
import ca.uhn.fhir.model.api.IElement;
import ca.uhn.fhir.model.api.IResource;
-import ca.uhn.fhir.model.api.ResourceReference;
+import ca.uhn.fhir.model.api.BaseResourceReference;
import ca.uhn.fhir.model.api.UndeclaredExtension;
public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildDefinition {
@@ -70,13 +70,13 @@ public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildD
}
// Resource Reference
- myDatatypeToAttributeName.put(ResourceReference.class, "valueReference");
+ myDatatypeToAttributeName.put(BaseResourceReference.class, "valueReference");
List> types = new ArrayList>();
types.add(IResource.class);
RuntimeResourceReferenceDefinition def = new RuntimeResourceReferenceDefinition("valueResource", types);
def.sealAndInitialize(theClassToElementDefinitions);
myAttributeNameToDefinition.put("valueResource", def);
- myDatatypeToDefinition.put(ResourceReference.class, def);
+ myDatatypeToDefinition.put(BaseResourceReference.class, def);
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeResourceDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeResourceDefinition.java
index 8659fb5f77a..451ef2d6619 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeResourceDefinition.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeResourceDefinition.java
@@ -208,6 +208,7 @@ public class RuntimeResourceDefinition extends BaseRuntimeElementCompositeDefini
StructureElement extSlice = theStruct.addElement();
extSlice.setName(elementName);
extSlice.setPath(join(path, '.') + '.' + elementName);
+ extSlice.getDefinition().setIsModifier(theIsModifier);
extSlice.getDefinition().addType().setCode(DataTypeEnum.EXTENSION);
extSlice.getDefinition().setMin(0);
extSlice.getDefinition().setMax("*");
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeResourceReferenceDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeResourceReferenceDefinition.java
index 56978651a9d..64955c5f955 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeResourceReferenceDefinition.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeResourceReferenceDefinition.java
@@ -6,15 +6,15 @@ import java.util.Map;
import ca.uhn.fhir.model.api.IElement;
import ca.uhn.fhir.model.api.IResource;
-import ca.uhn.fhir.model.api.ResourceReference;
+import ca.uhn.fhir.model.api.BaseResourceReference;
-public class RuntimeResourceReferenceDefinition extends BaseRuntimeElementDefinition {
+public class RuntimeResourceReferenceDefinition extends BaseRuntimeElementDefinition {
private final List> myResourceTypes;
private HashMap, RuntimeResourceDefinition> myResourceTypeToDefinition;
public RuntimeResourceReferenceDefinition(String theName, List> theResourceTypes) {
- super(theName, ResourceReference.class);
+ super(theName, BaseResourceReference.class);
if (theResourceTypes == null || theResourceTypes.isEmpty()) {
throw new ConfigurationException("Element '" + theName + "' has no resource types noted");
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BaseElement.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BaseElement.java
index 0b17337ce29..22a5998e4c9 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BaseElement.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BaseElement.java
@@ -1,11 +1,25 @@
package ca.uhn.fhir.model.api;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
public abstract class BaseElement implements IElement, ISupportsUndeclaredExtensions {
private List myUndeclaredExtensions;
+ private List myUndeclaredModifierExtensions;
+
+ @Override
+ public List getAllUndeclaredExtensions() {
+ ArrayList retVal = new ArrayList();
+ if (myUndeclaredExtensions != null) {
+ retVal.addAll(myUndeclaredExtensions);
+ }
+ if (myUndeclaredModifierExtensions != null) {
+ retVal.addAll(myUndeclaredModifierExtensions);
+ }
+ return Collections.unmodifiableList(retVal);
+ }
@Override
public List getUndeclaredExtensions() {
@@ -15,6 +29,14 @@ public abstract class BaseElement implements IElement, ISupportsUndeclaredExtens
return myUndeclaredExtensions;
}
+ @Override
+ public List getUndeclaredModifierExtensions() {
+ if (myUndeclaredModifierExtensions == null) {
+ myUndeclaredModifierExtensions = new ArrayList();
+ }
+ return myUndeclaredModifierExtensions;
+ }
+
/**
* Intended to be called by extending classes {@link #isEmpty()} implementations, returns true if all content in this superclass instance is empty per the semantics of
* {@link #isEmpty()}.
@@ -27,6 +49,13 @@ public abstract class BaseElement implements IElement, ISupportsUndeclaredExtens
}
}
}
+ if (myUndeclaredModifierExtensions != null) {
+ for (UndeclaredExtension next : myUndeclaredModifierExtensions) {
+ if (!next.isEmpty()) {
+ return false;
+ }
+ }
+ }
return true;
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BaseResourceReference.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BaseResourceReference.java
new file mode 100644
index 00000000000..170decfb627
--- /dev/null
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/BaseResourceReference.java
@@ -0,0 +1,8 @@
+package ca.uhn.fhir.model.api;
+
+
+
+public abstract class BaseResourceReference extends BaseElement {
+
+
+}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ISupportsUndeclaredExtensions.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ISupportsUndeclaredExtensions.java
index 65183d43475..6866d0495bc 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ISupportsUndeclaredExtensions.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ISupportsUndeclaredExtensions.java
@@ -5,8 +5,18 @@ import java.util.List;
public interface ISupportsUndeclaredExtensions {
/**
- * Returns a list containing all undeclared extensions
+ * Returns a list containing all undeclared non-modifier extensions
*/
List getUndeclaredExtensions();
+
+ /**
+ * Returns an immutable list containing all extensions (modifier and non-modifier)
+ */
+ List getAllUndeclaredExtensions();
+
+ /**
+ * Returns a list containing all undeclared modifier extensions
+ */
+ List getUndeclaredModifierExtensions();
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ResourceReference.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ResourceReference.java
deleted file mode 100644
index 523481210d4..00000000000
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ResourceReference.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package ca.uhn.fhir.model.api;
-
-import org.apache.commons.lang3.StringUtils;
-
-
-public class ResourceReference implements IDatatype {
-
- private String myDisplay;
- private String myReference;
-
- public String getDisplay() {
- return myDisplay;
- }
-
- public String getReference() {
- return myReference;
- }
-
- public void setDisplay(String theDisplay) {
- myDisplay = theDisplay;
- }
-
- public void setReference(String theReference) {
- myReference = theReference;
- }
-
- @Override
- public boolean isEmpty() {
- return StringUtils.isBlank(myDisplay) && StringUtils.isBlank(myReference);
- }
-
-}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/UndeclaredExtension.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/UndeclaredExtension.java
index a880f3002cc..fde7d177e26 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/UndeclaredExtension.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/UndeclaredExtension.java
@@ -1,27 +1,54 @@
package ca.uhn.fhir.model.api;
-
public class UndeclaredExtension extends BaseElement {
private String myUrl;
private IElement myValue;
+ private boolean myIsModifier;
- public UndeclaredExtension() {
- super();
+ public UndeclaredExtension(boolean theIsModifier) {
+ myIsModifier = theIsModifier;
}
-
- public UndeclaredExtension(String theUrl) {
- myUrl=theUrl;
+
+ public UndeclaredExtension(boolean theIsModifier, String theUrl) {
+ myIsModifier = theIsModifier;
+ myUrl = theUrl;
+ }
+
+ public boolean isModifier() {
+ return myIsModifier;
}
public String getUrl() {
return myUrl;
}
+ /**
+ * Returns the value of this extension, if one exists.
+ *
+ * Note that if this extension contains extensions (instead of a datatype) then this method will return null. In that case, you must use {@link #getUndeclaredExtensions()} and
+ * {@link #getUndeclaredModifierExtensions()} to retrieve the child extensions.
+ *
+ */
public IElement getValue() {
return myValue;
}
+ /**
+ * Returns the value of this extension, casted to a primitive datatype. This is a convenience method which should only be called if you are sure that the value for this particular extension will
+ * be a primitive.
+ *
+ * Note that if this extension contains extensions (instead of a datatype) then this method will return null. In that case, you must use {@link #getUndeclaredExtensions()} and
+ * {@link #getUndeclaredModifierExtensions()} to retrieve the child extensions.
+ *
+ *
+ * @throws ClassCastException
+ * If the value of this extension is not a primitive datatype
+ */
+ public IPrimitiveDatatype> getValueAsPrimitive() {
+ return (IPrimitiveDatatype>) getValue();
+ }
+
public void setUrl(String theUrl) {
myUrl = theUrl;
}
@@ -32,7 +59,7 @@ public class UndeclaredExtension extends BaseElement {
@Override
public boolean isEmpty() {
- return myValue == null || myValue.isEmpty();
+ return super.isBaseEmpty() && myValue == null || myValue.isEmpty();
}
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/annotation/ResourceDef.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/annotation/ResourceDef.java
index 89524b5c7d8..5d706809600 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/annotation/ResourceDef.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/annotation/ResourceDef.java
@@ -12,6 +12,8 @@ public @interface ResourceDef {
int ORDER_NOT_SPECIFIED = -1;
String name();
+
+ String id() default "";
String profile() default "";
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/AddressDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/AddressDt.java
index 33d482a0835..9159d021fd9 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/AddressDt.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/AddressDt.java
@@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
*
*/
@DatatypeDef(name="Address")
-public class AddressDt extends BaseElement implements ICompositeDatatype {
+public class AddressDt
+ extends BaseElement implements ICompositeDatatype {
@Child(name="use", type=CodeDt.class, order=0, min=0, max=1)
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/AttachmentDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/AttachmentDt.java
index 35a435fc30b..e31060e9eba 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/AttachmentDt.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/AttachmentDt.java
@@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
*
*/
@DatatypeDef(name="Attachment")
-public class AttachmentDt extends BaseElement implements ICompositeDatatype {
+public class AttachmentDt
+ extends BaseElement implements ICompositeDatatype {
@Child(name="contentType", type=CodeDt.class, order=0, min=1, max=1)
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/CodeableConceptDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/CodeableConceptDt.java
index 35af2dac29e..2b363a3ca2d 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/CodeableConceptDt.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/CodeableConceptDt.java
@@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
*
*/
@DatatypeDef(name="CodeableConcept")
-public class CodeableConceptDt extends BaseElement implements ICompositeDatatype {
+public class CodeableConceptDt
+ extends BaseElement implements ICompositeDatatype {
@Child(name="coding", type=CodingDt.class, order=0, min=0, max=Child.MAX_UNLIMITED)
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/CodingDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/CodingDt.java
index 8e7b851e79e..028ea184375 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/CodingDt.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/CodingDt.java
@@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
*
*/
@DatatypeDef(name="Coding")
-public class CodingDt extends BaseElement implements ICompositeDatatype {
+public class CodingDt
+ extends BaseElement implements ICompositeDatatype {
@Child(name="system", type=UriDt.class, order=0, min=0, max=1)
@@ -83,7 +84,7 @@ public class CodingDt extends BaseElement implements ICompositeDatatype {
shortDefinition="Set this coding was chosen from",
formalDefinition="The set of possible coded values this coding was chosen from or constrained by"
)
- private ResourceReference myValueSet;
+ private ResourceReferenceDt myValueSet;
@Override
@@ -316,9 +317,9 @@ public class CodingDt extends BaseElement implements ICompositeDatatype {
* The set of possible coded values this coding was chosen from or constrained by
*
*/
- public ResourceReference getValueSet() {
+ public ResourceReferenceDt getValueSet() {
if (myValueSet == null) {
- myValueSet = new ResourceReference();
+ myValueSet = new ResourceReferenceDt();
}
return myValueSet;
}
@@ -331,7 +332,7 @@ public class CodingDt extends BaseElement implements ICompositeDatatype {
* The set of possible coded values this coding was chosen from or constrained by
*
*/
- public void setValueSet(ResourceReference theValue) {
+ public void setValueSet(ResourceReferenceDt theValue) {
myValueSet = theValue;
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/ContactDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/ContactDt.java
index c2c7239748d..5daf48837b3 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/ContactDt.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/ContactDt.java
@@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
*
*/
@DatatypeDef(name="Contact")
-public class ContactDt extends BaseElement implements ICompositeDatatype {
+public class ContactDt
+ extends BaseElement implements ICompositeDatatype {
@Child(name="system", type=CodeDt.class, order=0, min=0, max=1)
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/HumanNameDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/HumanNameDt.java
index 1027abf8329..282b1379f71 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/HumanNameDt.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/HumanNameDt.java
@@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
*
*/
@DatatypeDef(name="HumanName")
-public class HumanNameDt extends BaseElement implements ICompositeDatatype {
+public class HumanNameDt
+ extends BaseElement implements ICompositeDatatype {
@Child(name="use", type=CodeDt.class, order=0, min=0, max=1)
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/IdentifierDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/IdentifierDt.java
index 474eb927dba..1cb8b3c8950 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/IdentifierDt.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/IdentifierDt.java
@@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
*
*/
@DatatypeDef(name="Identifier")
-public class IdentifierDt extends BaseElement implements ICompositeDatatype , IQueryParameterType {
+public class IdentifierDt
+ extends BaseElement implements ICompositeDatatype , IQueryParameterType {
/**
* Creates a new identifier
@@ -97,7 +98,7 @@ public class IdentifierDt extends BaseElement implements ICompositeDatatype , I
shortDefinition="Organization that issued id (may be just text)",
formalDefinition="Organization that issued/manages the identifier"
)
- private ResourceReference myAssigner;
+ private ResourceReferenceDt myAssigner;
@Override
@@ -318,9 +319,9 @@ public class IdentifierDt extends BaseElement implements ICompositeDatatype , I
* Organization that issued/manages the identifier
*
*/
- public ResourceReference getAssigner() {
+ public ResourceReferenceDt getAssigner() {
if (myAssigner == null) {
- myAssigner = new ResourceReference();
+ myAssigner = new ResourceReferenceDt();
}
return myAssigner;
}
@@ -333,7 +334,7 @@ public class IdentifierDt extends BaseElement implements ICompositeDatatype , I
* Organization that issued/manages the identifier
*
*/
- public void setAssigner(ResourceReference theValue) {
+ public void setAssigner(ResourceReferenceDt theValue) {
myAssigner = theValue;
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/PeriodDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/PeriodDt.java
index ff0c227f265..b3bd50b223f 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/PeriodDt.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/PeriodDt.java
@@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
*
*/
@DatatypeDef(name="Period")
-public class PeriodDt extends BaseElement implements ICompositeDatatype {
+public class PeriodDt
+ extends BaseElement implements ICompositeDatatype {
@Child(name="start", type=DateTimeDt.class, order=0, min=0, max=1)
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/QuantityDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/QuantityDt.java
index 5bdf114fa35..4e1a68a8fb6 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/QuantityDt.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/QuantityDt.java
@@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
*
*/
@DatatypeDef(name="Quantity")
-public class QuantityDt extends BaseElement implements ICompositeDatatype {
+public class QuantityDt
+ extends BaseElement implements ICompositeDatatype {
@Child(name="value", type=DecimalDt.class, order=0, min=0, max=1)
@@ -120,7 +121,7 @@ public class QuantityDt extends BaseElement implements ICompositeDatatype {
* The value of the measured amount. The value includes an implicit precision in the presentation of the value
*
*/
- public void setValue( long theValue) {
+ public void setValue( java.math.BigDecimal theValue) {
myValue = new DecimalDt(theValue);
}
@@ -144,7 +145,7 @@ public class QuantityDt extends BaseElement implements ICompositeDatatype {
* The value of the measured amount. The value includes an implicit precision in the presentation of the value
*
*/
- public void setValue( java.math.BigDecimal theValue) {
+ public void setValue( long theValue) {
myValue = new DecimalDt(theValue);
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/RangeDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/RangeDt.java
index 75115642c4a..53f75792ad8 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/RangeDt.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/RangeDt.java
@@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
*
*/
@DatatypeDef(name="Range")
-public class RangeDt extends BaseElement implements ICompositeDatatype {
+public class RangeDt
+ extends BaseElement implements ICompositeDatatype {
@Child(name="low", type=QuantityDt.class, order=0, min=0, max=1)
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/RatioDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/RatioDt.java
index 41f9ecb47d4..a4a7ea55260 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/RatioDt.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/RatioDt.java
@@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
*
*/
@DatatypeDef(name="Ratio")
-public class RatioDt extends BaseElement implements ICompositeDatatype {
+public class RatioDt
+ extends BaseElement implements ICompositeDatatype {
@Child(name="numerator", type=QuantityDt.class, order=0, min=0, max=1)
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/ResourceReferenceDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/ResourceReferenceDt.java
index 238b199f83b..46a73fc35c0 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/ResourceReferenceDt.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/ResourceReferenceDt.java
@@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
*
*/
@DatatypeDef(name="ResourceReference")
-public class ResourceReferenceDt extends BaseElement implements ICompositeDatatype {
+public class ResourceReferenceDt
+ extends BaseResourceReference implements ICompositeDatatype {
@Child(name="reference", type=StringDt.class, order=0, min=0, max=1)
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/SampledDataDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/SampledDataDt.java
index 805688d25be..c4b4775e4f0 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/SampledDataDt.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/SampledDataDt.java
@@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
*
*/
@DatatypeDef(name="SampledData")
-public class SampledDataDt extends BaseElement implements ICompositeDatatype {
+public class SampledDataDt
+ extends BaseElement implements ICompositeDatatype {
@Child(name="origin", type=QuantityDt.class, order=0, min=1, max=1)
@@ -165,7 +166,7 @@ public class SampledDataDt extends BaseElement implements ICompositeDatatype {
* The length of time between sampling times, measured in milliseconds
*
*/
- public void setPeriod( long theValue) {
+ public void setPeriod( java.math.BigDecimal theValue) {
myPeriod = new DecimalDt(theValue);
}
@@ -189,7 +190,7 @@ public class SampledDataDt extends BaseElement implements ICompositeDatatype {
* The length of time between sampling times, measured in milliseconds
*
*/
- public void setPeriod( java.math.BigDecimal theValue) {
+ public void setPeriod( long theValue) {
myPeriod = new DecimalDt(theValue);
}
@@ -232,7 +233,7 @@ public class SampledDataDt extends BaseElement implements ICompositeDatatype {
* A correction factor that is applied to the sampled data points before they are added to the origin
*
*/
- public void setFactor( long theValue) {
+ public void setFactor( java.math.BigDecimal theValue) {
myFactor = new DecimalDt(theValue);
}
@@ -256,7 +257,7 @@ public class SampledDataDt extends BaseElement implements ICompositeDatatype {
* A correction factor that is applied to the sampled data points before they are added to the origin
*
*/
- public void setFactor( java.math.BigDecimal theValue) {
+ public void setFactor( long theValue) {
myFactor = new DecimalDt(theValue);
}
@@ -299,7 +300,7 @@ public class SampledDataDt extends BaseElement implements ICompositeDatatype {
* The lower limit of detection of the measured points. This is needed if any of the data points have the value \"L\" (lower than detection limit)
*
*/
- public void setLowerLimit( long theValue) {
+ public void setLowerLimit( java.math.BigDecimal theValue) {
myLowerLimit = new DecimalDt(theValue);
}
@@ -323,7 +324,7 @@ public class SampledDataDt extends BaseElement implements ICompositeDatatype {
* The lower limit of detection of the measured points. This is needed if any of the data points have the value \"L\" (lower than detection limit)
*
*/
- public void setLowerLimit( java.math.BigDecimal theValue) {
+ public void setLowerLimit( long theValue) {
myLowerLimit = new DecimalDt(theValue);
}
@@ -366,7 +367,7 @@ public class SampledDataDt extends BaseElement implements ICompositeDatatype {
* The upper limit of detection of the measured points. This is needed if any of the data points have the value \"U\" (higher than detection limit)
*
*/
- public void setUpperLimit( long theValue) {
+ public void setUpperLimit( java.math.BigDecimal theValue) {
myUpperLimit = new DecimalDt(theValue);
}
@@ -390,7 +391,7 @@ public class SampledDataDt extends BaseElement implements ICompositeDatatype {
* The upper limit of detection of the measured points. This is needed if any of the data points have the value \"U\" (higher than detection limit)
*
*/
- public void setUpperLimit( java.math.BigDecimal theValue) {
+ public void setUpperLimit( long theValue) {
myUpperLimit = new DecimalDt(theValue);
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/ScheduleDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/ScheduleDt.java
index a15f63fc99f..94093399c8d 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/ScheduleDt.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/composite/ScheduleDt.java
@@ -38,7 +38,8 @@ import ca.uhn.fhir.model.dstu.resource.*;
*
*/
@DatatypeDef(name="Schedule")
-public class ScheduleDt extends BaseElement implements ICompositeDatatype {
+public class ScheduleDt
+ extends BaseElement implements ICompositeDatatype {
@Child(name="event", type=PeriodDt.class, order=0, min=0, max=Child.MAX_UNLIMITED)
@@ -319,7 +320,7 @@ public class ScheduleDt extends BaseElement implements ICompositeDatatype {
* How long each repetition should last
*
*/
- public void setDuration( long theValue) {
+ public void setDuration( java.math.BigDecimal theValue) {
myDuration = new DecimalDt(theValue);
}
@@ -343,7 +344,7 @@ public class ScheduleDt extends BaseElement implements ICompositeDatatype {
* How long each repetition should last
*
*/
- public void setDuration( java.math.BigDecimal theValue) {
+ public void setDuration( long theValue) {
myDuration = new DecimalDt(theValue);
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Device.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Device.java
index 9e3f7966739..ffced6b7a53 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Device.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Device.java
@@ -37,7 +37,7 @@ import ca.uhn.fhir.model.dstu.valueset.*;
* Allows institutions to track their devices.
*
*/
-@ResourceDef(name="Device", profile="http://hl7.org/fhir/profiles/Device")
+@ResourceDef(name="Device", profile="http://hl7.org/fhir/profiles/Device", id="device")
public class Device extends BaseResource implements IResource {
/**
@@ -184,7 +184,7 @@ public class Device extends BaseResource implements IResource {
shortDefinition="Organization responsible for device",
formalDefinition="An organization that is responsible for the provision and ongoing maintenance of the device"
)
- private ResourceReference myOwner;
+ private ResourceReferenceDt myOwner;
@Child(name="location", order=9, min=0, max=1, type={
Location.class,
@@ -193,7 +193,7 @@ public class Device extends BaseResource implements IResource {
shortDefinition="Where the resource is found",
formalDefinition="The resource may be found in a literal location (i.e. GPS coordinates), a logical place (i.e. \"in/with the patient\"), or a coded location"
)
- private ResourceReference myLocation;
+ private ResourceReferenceDt myLocation;
@Child(name="patient", order=10, min=0, max=1, type={
Patient.class,
@@ -202,7 +202,7 @@ public class Device extends BaseResource implements IResource {
shortDefinition="If the resource is affixed to a person",
formalDefinition="Patient information, if the resource is affixed to a person"
)
- private ResourceReference myPatient;
+ private ResourceReferenceDt myPatient;
@Child(name="contact", type=ContactDt.class, order=11, min=0, max=Child.MAX_UNLIMITED)
@Description(
@@ -579,9 +579,9 @@ public class Device extends BaseResource implements IResource {
* An organization that is responsible for the provision and ongoing maintenance of the device
*
*/
- public ResourceReference getOwner() {
+ public ResourceReferenceDt getOwner() {
if (myOwner == null) {
- myOwner = new ResourceReference();
+ myOwner = new ResourceReferenceDt();
}
return myOwner;
}
@@ -594,7 +594,7 @@ public class Device extends BaseResource implements IResource {
* An organization that is responsible for the provision and ongoing maintenance of the device
*
*/
- public void setOwner(ResourceReference theValue) {
+ public void setOwner(ResourceReferenceDt theValue) {
myOwner = theValue;
}
@@ -610,9 +610,9 @@ public class Device extends BaseResource implements IResource {
* The resource may be found in a literal location (i.e. GPS coordinates), a logical place (i.e. \"in/with the patient\"), or a coded location
*
*/
- public ResourceReference getLocation() {
+ public ResourceReferenceDt getLocation() {
if (myLocation == null) {
- myLocation = new ResourceReference();
+ myLocation = new ResourceReferenceDt();
}
return myLocation;
}
@@ -625,7 +625,7 @@ public class Device extends BaseResource implements IResource {
* The resource may be found in a literal location (i.e. GPS coordinates), a logical place (i.e. \"in/with the patient\"), or a coded location
*
*/
- public void setLocation(ResourceReference theValue) {
+ public void setLocation(ResourceReferenceDt theValue) {
myLocation = theValue;
}
@@ -641,9 +641,9 @@ public class Device extends BaseResource implements IResource {
* Patient information, if the resource is affixed to a person
*
*/
- public ResourceReference getPatient() {
+ public ResourceReferenceDt getPatient() {
if (myPatient == null) {
- myPatient = new ResourceReference();
+ myPatient = new ResourceReferenceDt();
}
return myPatient;
}
@@ -656,7 +656,7 @@ public class Device extends BaseResource implements IResource {
* Patient information, if the resource is affixed to a person
*
*/
- public void setPatient(ResourceReference theValue) {
+ public void setPatient(ResourceReferenceDt theValue) {
myPatient = theValue;
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Group.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Group.java
index ecbee6acec2..b82c0dc9c14 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Group.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Group.java
@@ -37,7 +37,7 @@ import ca.uhn.fhir.model.dstu.valueset.*;
*
*
*/
-@ResourceDef(name="Group", profile="http://hl7.org/fhir/profiles/Group")
+@ResourceDef(name="Group", profile="http://hl7.org/fhir/profiles/Group", id="group")
public class Group extends BaseResource implements IResource {
/**
@@ -191,7 +191,7 @@ public class Group extends BaseResource implements IResource {
shortDefinition="Who is in group",
formalDefinition="Identifies the resource instances that are members of the group."
)
- private List myMember;
+ private List myMember;
@Override
@@ -487,7 +487,7 @@ public class Group extends BaseResource implements IResource {
* Identifies the resource instances that are members of the group.
*
*/
- public List getMember() {
+ public List getMember() {
return myMember;
}
@@ -499,7 +499,7 @@ public class Group extends BaseResource implements IResource {
* Identifies the resource instances that are members of the group.
*
*/
- public void setMember(List theValue) {
+ public void setMember(List theValue) {
myMember = theValue;
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Location.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Location.java
index e796d2d588c..55974f4329f 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Location.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Location.java
@@ -37,7 +37,7 @@ import ca.uhn.fhir.model.dstu.valueset.*;
*
*
*/
-@ResourceDef(name="Location", profile="http://hl7.org/fhir/profiles/Location")
+@ResourceDef(name="Location", profile="http://hl7.org/fhir/profiles/Location", id="location")
public class Location extends BaseResource implements IResource {
/**
@@ -184,7 +184,7 @@ public class Location extends BaseResource implements IResource {
shortDefinition="The organization that is responsible for the provisioning and upkeep of the location",
formalDefinition=""
)
- private ResourceReference myManagingOrganization;
+ private ResourceReferenceDt myManagingOrganization;
@Child(name="status", type=CodeDt.class, order=9, min=0, max=1)
@Description(
@@ -200,7 +200,7 @@ public class Location extends BaseResource implements IResource {
shortDefinition="Another Location which this Location is physically part of",
formalDefinition=""
)
- private ResourceReference myPartOf;
+ private ResourceReferenceDt myPartOf;
@Child(name="mode", type=CodeDt.class, order=11, min=0, max=1)
@Description(
@@ -522,9 +522,9 @@ public class Location extends BaseResource implements IResource {
*
*
*/
- public ResourceReference getManagingOrganization() {
+ public ResourceReferenceDt getManagingOrganization() {
if (myManagingOrganization == null) {
- myManagingOrganization = new ResourceReference();
+ myManagingOrganization = new ResourceReferenceDt();
}
return myManagingOrganization;
}
@@ -537,7 +537,7 @@ public class Location extends BaseResource implements IResource {
*
*
*/
- public void setManagingOrganization(ResourceReference theValue) {
+ public void setManagingOrganization(ResourceReferenceDt theValue) {
myManagingOrganization = theValue;
}
@@ -596,9 +596,9 @@ public class Location extends BaseResource implements IResource {
*
*
*/
- public ResourceReference getPartOf() {
+ public ResourceReferenceDt getPartOf() {
if (myPartOf == null) {
- myPartOf = new ResourceReference();
+ myPartOf = new ResourceReferenceDt();
}
return myPartOf;
}
@@ -611,7 +611,7 @@ public class Location extends BaseResource implements IResource {
*
*
*/
- public void setPartOf(ResourceReference theValue) {
+ public void setPartOf(ResourceReferenceDt theValue) {
myPartOf = theValue;
}
@@ -736,7 +736,7 @@ public class Location extends BaseResource implements IResource {
* Longitude. The value domain and the interpretation are the same as for the text of the longitude element in KML (see notes below)
*
*/
- public void setLongitude( long theValue) {
+ public void setLongitude( java.math.BigDecimal theValue) {
myLongitude = new DecimalDt(theValue);
}
@@ -760,7 +760,7 @@ public class Location extends BaseResource implements IResource {
* Longitude. The value domain and the interpretation are the same as for the text of the longitude element in KML (see notes below)
*
*/
- public void setLongitude( java.math.BigDecimal theValue) {
+ public void setLongitude( long theValue) {
myLongitude = new DecimalDt(theValue);
}
@@ -803,7 +803,7 @@ public class Location extends BaseResource implements IResource {
* Latitude. The value domain and the interpretation are the same as for the text of the latitude element in KML (see notes below)
*
*/
- public void setLatitude( long theValue) {
+ public void setLatitude( java.math.BigDecimal theValue) {
myLatitude = new DecimalDt(theValue);
}
@@ -827,7 +827,7 @@ public class Location extends BaseResource implements IResource {
* Latitude. The value domain and the interpretation are the same as for the text of the latitude element in KML (see notes below)
*
*/
- public void setLatitude( java.math.BigDecimal theValue) {
+ public void setLatitude( long theValue) {
myLatitude = new DecimalDt(theValue);
}
@@ -870,7 +870,7 @@ public class Location extends BaseResource implements IResource {
* Altitude. The value domain and the interpretation are the same as for the text of the altitude element in KML (see notes below)
*
*/
- public void setAltitude( long theValue) {
+ public void setAltitude( java.math.BigDecimal theValue) {
myAltitude = new DecimalDt(theValue);
}
@@ -894,7 +894,7 @@ public class Location extends BaseResource implements IResource {
* Altitude. The value domain and the interpretation are the same as for the text of the altitude element in KML (see notes below)
*
*/
- public void setAltitude( java.math.BigDecimal theValue) {
+ public void setAltitude( long theValue) {
myAltitude = new DecimalDt(theValue);
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Medication.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Medication.java
index 39f4a5e6c93..3b86e38cfe6 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Medication.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Medication.java
@@ -37,7 +37,7 @@ import ca.uhn.fhir.model.dstu.valueset.*;
*
*
*/
-@ResourceDef(name="Medication", profile="http://hl7.org/fhir/profiles/Medication")
+@ResourceDef(name="Medication", profile="http://hl7.org/fhir/profiles/Medication", id="medication")
public class Medication extends BaseResource implements IResource {
/**
@@ -139,7 +139,7 @@ public class Medication extends BaseResource implements IResource {
shortDefinition="Manufacturer of the item",
formalDefinition="Describes the details of the manufacturer"
)
- private ResourceReference myManufacturer;
+ private ResourceReferenceDt myManufacturer;
@Child(name="kind", type=CodeDt.class, order=4, min=0, max=1)
@Description(
@@ -295,9 +295,9 @@ public class Medication extends BaseResource implements IResource {
* Describes the details of the manufacturer
*
*/
- public ResourceReference getManufacturer() {
+ public ResourceReferenceDt getManufacturer() {
if (myManufacturer == null) {
- myManufacturer = new ResourceReference();
+ myManufacturer = new ResourceReferenceDt();
}
return myManufacturer;
}
@@ -310,7 +310,7 @@ public class Medication extends BaseResource implements IResource {
* Describes the details of the manufacturer
*
*/
- public void setManufacturer(ResourceReference theValue) {
+ public void setManufacturer(ResourceReferenceDt theValue) {
myManufacturer = theValue;
}
@@ -561,7 +561,7 @@ public class Medication extends BaseResource implements IResource {
shortDefinition="The product contained",
formalDefinition="The actual ingredient - either a substance (simple ingredient) or another medication"
)
- private ResourceReference myItem;
+ private ResourceReferenceDt myItem;
@Child(name="amount", type=RatioDt.class, order=1, min=0, max=1)
@Description(
@@ -586,7 +586,7 @@ public class Medication extends BaseResource implements IResource {
* The actual ingredient - either a substance (simple ingredient) or another medication
*
*/
- public ResourceReference getItem() {
+ public ResourceReferenceDt getItem() {
return myItem;
}
@@ -598,7 +598,7 @@ public class Medication extends BaseResource implements IResource {
* The actual ingredient - either a substance (simple ingredient) or another medication
*
*/
- public void setItem(ResourceReference theValue) {
+ public void setItem(ResourceReferenceDt theValue) {
myItem = theValue;
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Observation.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Observation.java
index 0ccf99e77c3..d94464091b3 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Observation.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Observation.java
@@ -37,7 +37,7 @@ import ca.uhn.fhir.model.dstu.valueset.*;
* Observations are a key aspect of healthcare. This resource is used to capture those that do not require more sophisticated mechanisms.
*
*/
-@ResourceDef(name="Observation", profile="http://hl7.org/fhir/profiles/Observation")
+@ResourceDef(name="Observation", profile="http://hl7.org/fhir/profiles/Observation", id="observation")
public class Observation extends BaseResource implements IResource {
/**
@@ -289,7 +289,7 @@ public class Observation extends BaseResource implements IResource {
shortDefinition="Who and/or what this is about",
formalDefinition="The thing the observation is being made about"
)
- private ResourceReference mySubject;
+ private ResourceReferenceDt mySubject;
@Child(name="specimen", order=12, min=0, max=1, type={
Specimen.class,
@@ -298,7 +298,7 @@ public class Observation extends BaseResource implements IResource {
shortDefinition="Specimen used for this observation",
formalDefinition="The specimen that was used when this observation was made"
)
- private ResourceReference mySpecimen;
+ private ResourceReferenceDt mySpecimen;
@Child(name="performer", order=13, min=0, max=Child.MAX_UNLIMITED, type={
Practitioner.class,
@@ -309,7 +309,7 @@ public class Observation extends BaseResource implements IResource {
shortDefinition="Who did the observation",
formalDefinition="Who was responsible for asserting the observed value as \"true\""
)
- private List myPerformer;
+ private List myPerformer;
@Child(name="referenceRange", order=14, min=0, max=Child.MAX_UNLIMITED)
@Description(
@@ -748,7 +748,7 @@ public class Observation extends BaseResource implements IResource {
* The thing the observation is being made about
*
*/
- public ResourceReference getSubject() {
+ public ResourceReferenceDt getSubject() {
return mySubject;
}
@@ -760,7 +760,7 @@ public class Observation extends BaseResource implements IResource {
* The thing the observation is being made about
*
*/
- public void setSubject(ResourceReference theValue) {
+ public void setSubject(ResourceReferenceDt theValue) {
mySubject = theValue;
}
@@ -776,9 +776,9 @@ public class Observation extends BaseResource implements IResource {
* The specimen that was used when this observation was made
*
*/
- public ResourceReference getSpecimen() {
+ public ResourceReferenceDt getSpecimen() {
if (mySpecimen == null) {
- mySpecimen = new ResourceReference();
+ mySpecimen = new ResourceReferenceDt();
}
return mySpecimen;
}
@@ -791,7 +791,7 @@ public class Observation extends BaseResource implements IResource {
* The specimen that was used when this observation was made
*
*/
- public void setSpecimen(ResourceReference theValue) {
+ public void setSpecimen(ResourceReferenceDt theValue) {
mySpecimen = theValue;
}
@@ -807,7 +807,7 @@ public class Observation extends BaseResource implements IResource {
* Who was responsible for asserting the observed value as \"true\"
*
*/
- public List getPerformer() {
+ public List getPerformer() {
return myPerformer;
}
@@ -819,7 +819,7 @@ public class Observation extends BaseResource implements IResource {
* Who was responsible for asserting the observed value as \"true\"
*
*/
- public void setPerformer(List theValue) {
+ public void setPerformer(List theValue) {
myPerformer = theValue;
}
@@ -1111,7 +1111,7 @@ public class Observation extends BaseResource implements IResource {
shortDefinition="Observation that is related to this one",
formalDefinition="A reference to the observation that is related to this observation"
)
- private ResourceReference myTarget;
+ private ResourceReferenceDt myTarget;
@Override
@@ -1172,9 +1172,9 @@ public class Observation extends BaseResource implements IResource {
* A reference to the observation that is related to this observation
*
*/
- public ResourceReference getTarget() {
+ public ResourceReferenceDt getTarget() {
if (myTarget == null) {
- myTarget = new ResourceReference();
+ myTarget = new ResourceReferenceDt();
}
return myTarget;
}
@@ -1187,7 +1187,7 @@ public class Observation extends BaseResource implements IResource {
* A reference to the observation that is related to this observation
*
*/
- public void setTarget(ResourceReference theValue) {
+ public void setTarget(ResourceReferenceDt theValue) {
myTarget = theValue;
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Organization.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Organization.java
index e0a9377148c..69fce53ac2b 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Organization.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Organization.java
@@ -37,7 +37,7 @@ import ca.uhn.fhir.model.dstu.valueset.*;
*
*
*/
-@ResourceDef(name="Organization", profile="http://hl7.org/fhir/profiles/Organization")
+@ResourceDef(name="Organization", profile="http://hl7.org/fhir/profiles/Organization", id="organization")
public class Organization extends BaseResource implements IResource {
/**
@@ -153,7 +153,7 @@ public class Organization extends BaseResource implements IResource {
shortDefinition="The organization of which this organization forms a part",
formalDefinition="The organization of which this organization forms a part"
)
- private ResourceReference myPartOf;
+ private ResourceReferenceDt myPartOf;
@Child(name="contact", order=6, min=0, max=Child.MAX_UNLIMITED)
@Description(
@@ -169,7 +169,7 @@ public class Organization extends BaseResource implements IResource {
shortDefinition="Location(s) the organization uses to provide services",
formalDefinition="Location(s) the organization uses to provide services"
)
- private List myLocation;
+ private List myLocation;
@Child(name="active", type=BooleanDt.class, order=8, min=0, max=1)
@Description(
@@ -412,9 +412,9 @@ public class Organization extends BaseResource implements IResource {
* The organization of which this organization forms a part
*
*/
- public ResourceReference getPartOf() {
+ public ResourceReferenceDt getPartOf() {
if (myPartOf == null) {
- myPartOf = new ResourceReference();
+ myPartOf = new ResourceReferenceDt();
}
return myPartOf;
}
@@ -427,7 +427,7 @@ public class Organization extends BaseResource implements IResource {
* The organization of which this organization forms a part
*
*/
- public void setPartOf(ResourceReference theValue) {
+ public void setPartOf(ResourceReferenceDt theValue) {
myPartOf = theValue;
}
@@ -487,9 +487,9 @@ public class Organization extends BaseResource implements IResource {
* Location(s) the organization uses to provide services
*
*/
- public List getLocation() {
+ public List getLocation() {
if (myLocation == null) {
- myLocation = new ArrayList();
+ myLocation = new ArrayList();
}
return myLocation;
}
@@ -502,7 +502,7 @@ public class Organization extends BaseResource implements IResource {
* Location(s) the organization uses to provide services
*
*/
- public void setLocation(List theValue) {
+ public void setLocation(List theValue) {
myLocation = theValue;
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Patient.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Patient.java
index 6a9909d807c..b846500b7c4 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Patient.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Patient.java
@@ -37,7 +37,7 @@ import ca.uhn.fhir.model.dstu.valueset.*;
* Tracking patient is the center of the healthcare process
*
*/
-@ResourceDef(name="Patient", profile="http://hl7.org/fhir/profiles/Patient")
+@ResourceDef(name="Patient", profile="http://hl7.org/fhir/profiles/Patient", id="patient")
public class Patient extends BaseResource implements IResource {
/**
@@ -296,7 +296,7 @@ public class Patient extends BaseResource implements IResource {
shortDefinition="Patient's nominated care provider",
formalDefinition="Patient's nominated care provider"
)
- private List myCareProvider;
+ private List myCareProvider;
@Child(name="managingOrganization", order=14, min=0, max=1, type={
Organization.class,
@@ -305,7 +305,7 @@ public class Patient extends BaseResource implements IResource {
shortDefinition="Organization that is the custodian of the patient record",
formalDefinition="Organization that is the custodian of the patient record"
)
- private ResourceReference myManagingOrganization;
+ private ResourceReferenceDt myManagingOrganization;
@Child(name="link", order=15, min=0, max=Child.MAX_UNLIMITED)
@Description(
@@ -873,7 +873,7 @@ public class Patient extends BaseResource implements IResource {
* Patient's nominated care provider
*
*/
- public List getCareProvider() {
+ public List getCareProvider() {
return myCareProvider;
}
@@ -885,7 +885,7 @@ public class Patient extends BaseResource implements IResource {
* Patient's nominated care provider
*
*/
- public void setCareProvider(List theValue) {
+ public void setCareProvider(List theValue) {
myCareProvider = theValue;
}
@@ -901,9 +901,9 @@ public class Patient extends BaseResource implements IResource {
* Organization that is the custodian of the patient record
*
*/
- public ResourceReference getManagingOrganization() {
+ public ResourceReferenceDt getManagingOrganization() {
if (myManagingOrganization == null) {
- myManagingOrganization = new ResourceReference();
+ myManagingOrganization = new ResourceReferenceDt();
}
return myManagingOrganization;
}
@@ -916,7 +916,7 @@ public class Patient extends BaseResource implements IResource {
* Organization that is the custodian of the patient record
*
*/
- public void setManagingOrganization(ResourceReference theValue) {
+ public void setManagingOrganization(ResourceReferenceDt theValue) {
myManagingOrganization = theValue;
}
@@ -1062,7 +1062,7 @@ public class Patient extends BaseResource implements IResource {
shortDefinition="Organization that is associated with the contact",
formalDefinition="Organization on behalf of which the contact is acting or for which the contact is working."
)
- private ResourceReference myOrganization;
+ private ResourceReferenceDt myOrganization;
@Override
@@ -1273,9 +1273,9 @@ public class Patient extends BaseResource implements IResource {
* Organization on behalf of which the contact is acting or for which the contact is working.
*
*/
- public ResourceReference getOrganization() {
+ public ResourceReferenceDt getOrganization() {
if (myOrganization == null) {
- myOrganization = new ResourceReference();
+ myOrganization = new ResourceReferenceDt();
}
return myOrganization;
}
@@ -1288,7 +1288,7 @@ public class Patient extends BaseResource implements IResource {
* Organization on behalf of which the contact is acting or for which the contact is working.
*
*/
- public void setOrganization(ResourceReference theValue) {
+ public void setOrganization(ResourceReferenceDt theValue) {
myOrganization = theValue;
}
@@ -1463,7 +1463,7 @@ public class Patient extends BaseResource implements IResource {
shortDefinition="The other patient resource that the link refers to",
formalDefinition="The other patient resource that the link refers to"
)
- private ResourceReference myOther;
+ private ResourceReferenceDt myOther;
@Child(name="type", type=CodeDt.class, order=1, min=1, max=1)
@Description(
@@ -1488,9 +1488,9 @@ public class Patient extends BaseResource implements IResource {
* The other patient resource that the link refers to
*
*/
- public ResourceReference getOther() {
+ public ResourceReferenceDt getOther() {
if (myOther == null) {
- myOther = new ResourceReference();
+ myOther = new ResourceReferenceDt();
}
return myOther;
}
@@ -1503,7 +1503,7 @@ public class Patient extends BaseResource implements IResource {
* The other patient resource that the link refers to
*
*/
- public void setOther(ResourceReference theValue) {
+ public void setOther(ResourceReferenceDt theValue) {
myOther = theValue;
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Practitioner.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Practitioner.java
index 518ba942d36..6ab63339554 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Practitioner.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Practitioner.java
@@ -37,7 +37,7 @@ import ca.uhn.fhir.model.dstu.valueset.*;
* Need to track doctors, staff, locums etc. for both healthcare practitioners, funders, etc.
*
*/
-@ResourceDef(name="Practitioner", profile="http://hl7.org/fhir/profiles/Practitioner")
+@ResourceDef(name="Practitioner", profile="http://hl7.org/fhir/profiles/Practitioner", id="practitioner")
public class Practitioner extends BaseResource implements IResource {
/**
@@ -187,7 +187,7 @@ public class Practitioner extends BaseResource implements IResource {
shortDefinition="The represented organization",
formalDefinition="The organization that the practitioner represents"
)
- private ResourceReference myOrganization;
+ private ResourceReferenceDt myOrganization;
@Child(name="role", type=CodeableConceptDt.class, order=8, min=0, max=Child.MAX_UNLIMITED)
@Description(
@@ -217,7 +217,7 @@ public class Practitioner extends BaseResource implements IResource {
shortDefinition="The location(s) at which this practitioner provides care",
formalDefinition="The location(s) at which this practitioner provides care"
)
- private List myLocation;
+ private List myLocation;
@Child(name="qualification", order=12, min=0, max=Child.MAX_UNLIMITED)
@Description(
@@ -541,9 +541,9 @@ public class Practitioner extends BaseResource implements IResource {
* The organization that the practitioner represents
*
*/
- public ResourceReference getOrganization() {
+ public ResourceReferenceDt getOrganization() {
if (myOrganization == null) {
- myOrganization = new ResourceReference();
+ myOrganization = new ResourceReferenceDt();
}
return myOrganization;
}
@@ -556,7 +556,7 @@ public class Practitioner extends BaseResource implements IResource {
* The organization that the practitioner represents
*
*/
- public void setOrganization(ResourceReference theValue) {
+ public void setOrganization(ResourceReferenceDt theValue) {
myOrganization = theValue;
}
@@ -715,9 +715,9 @@ public class Practitioner extends BaseResource implements IResource {
* The location(s) at which this practitioner provides care
*
*/
- public List getLocation() {
+ public List getLocation() {
if (myLocation == null) {
- myLocation = new ArrayList();
+ myLocation = new ArrayList();
}
return myLocation;
}
@@ -730,7 +730,7 @@ public class Practitioner extends BaseResource implements IResource {
* The location(s) at which this practitioner provides care
*
*/
- public void setLocation(List theValue) {
+ public void setLocation(List theValue) {
myLocation = theValue;
}
@@ -856,7 +856,7 @@ public class Practitioner extends BaseResource implements IResource {
shortDefinition="Organization that regulates and issues the qualification",
formalDefinition="Organization that regulates and issues the qualification"
)
- private ResourceReference myIssuer;
+ private ResourceReferenceDt myIssuer;
@Override
@@ -936,9 +936,9 @@ public class Practitioner extends BaseResource implements IResource {
* Organization that regulates and issues the qualification
*
*/
- public ResourceReference getIssuer() {
+ public ResourceReferenceDt getIssuer() {
if (myIssuer == null) {
- myIssuer = new ResourceReference();
+ myIssuer = new ResourceReferenceDt();
}
return myIssuer;
}
@@ -951,7 +951,7 @@ public class Practitioner extends BaseResource implements IResource {
* Organization that regulates and issues the qualification
*
*/
- public void setIssuer(ResourceReference theValue) {
+ public void setIssuer(ResourceReferenceDt theValue) {
myIssuer = theValue;
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Profile.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Profile.java
index d2ba7c55214..5dc4be3e513 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Profile.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Profile.java
@@ -37,7 +37,7 @@ import ca.uhn.fhir.model.dstu.valueset.*;
*
*
*/
-@ResourceDef(name="Profile", profile="http://hl7.org/fhir/profiles/Profile")
+@ResourceDef(name="Profile", profile="http://hl7.org/fhir/profiles/Profile", id="profile")
public class Profile extends BaseResource implements IResource {
/**
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Specimen.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Specimen.java
index a4640cc7dc7..e75d11bb040 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Specimen.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Specimen.java
@@ -37,7 +37,7 @@ import ca.uhn.fhir.model.dstu.valueset.*;
*
*
*/
-@ResourceDef(name="Specimen", profile="http://hl7.org/fhir/profiles/Specimen")
+@ResourceDef(name="Specimen", profile="http://hl7.org/fhir/profiles/Specimen", id="specimen")
public class Specimen extends BaseResource implements IResource {
/**
@@ -82,7 +82,7 @@ public class Specimen extends BaseResource implements IResource {
shortDefinition="Where the specimen came from. This may be the patient(s) or from the environment or a device",
formalDefinition=""
)
- private ResourceReference mySubject;
+ private ResourceReferenceDt mySubject;
@Child(name="accessionIdentifier", type=IdentifierDt.class, order=4, min=0, max=1)
@Description(
@@ -254,7 +254,7 @@ public class Specimen extends BaseResource implements IResource {
*
*
*/
- public ResourceReference getSubject() {
+ public ResourceReferenceDt getSubject() {
return mySubject;
}
@@ -266,7 +266,7 @@ public class Specimen extends BaseResource implements IResource {
*
*
*/
- public void setSubject(ResourceReference theValue) {
+ public void setSubject(ResourceReferenceDt theValue) {
mySubject = theValue;
}
@@ -502,7 +502,7 @@ public class Specimen extends BaseResource implements IResource {
shortDefinition="The subject of the relationship",
formalDefinition="The specimen resource that is the target of this relationship"
)
- private List myTarget;
+ private List myTarget;
@Override
@@ -563,9 +563,9 @@ public class Specimen extends BaseResource implements IResource {
* The specimen resource that is the target of this relationship
*
*/
- public List getTarget() {
+ public List getTarget() {
if (myTarget == null) {
- myTarget = new ArrayList();
+ myTarget = new ArrayList();
}
return myTarget;
}
@@ -578,7 +578,7 @@ public class Specimen extends BaseResource implements IResource {
* The specimen resource that is the target of this relationship
*
*/
- public void setTarget(List theValue) {
+ public void setTarget(List theValue) {
myTarget = theValue;
}
@@ -606,7 +606,7 @@ public class Specimen extends BaseResource implements IResource {
shortDefinition="Who collected the specimen",
formalDefinition="Person who collected the specimen"
)
- private ResourceReference myCollector;
+ private ResourceReferenceDt myCollector;
@Child(name="comment", type=StringDt.class, order=1, min=0, max=Child.MAX_UNLIMITED)
@Description(
@@ -662,9 +662,9 @@ public class Specimen extends BaseResource implements IResource {
* Person who collected the specimen
*
*/
- public ResourceReference getCollector() {
+ public ResourceReferenceDt getCollector() {
if (myCollector == null) {
- myCollector = new ResourceReference();
+ myCollector = new ResourceReferenceDt();
}
return myCollector;
}
@@ -677,7 +677,7 @@ public class Specimen extends BaseResource implements IResource {
* Person who collected the specimen
*
*/
- public void setCollector(ResourceReference theValue) {
+ public void setCollector(ResourceReferenceDt theValue) {
myCollector = theValue;
}
@@ -911,7 +911,7 @@ public class Specimen extends BaseResource implements IResource {
shortDefinition="Material used in the processing step",
formalDefinition=""
)
- private List myAdditive;
+ private List myAdditive;
@Override
@@ -1015,9 +1015,9 @@ public class Specimen extends BaseResource implements IResource {
*
*
*/
- public List getAdditive() {
+ public List getAdditive() {
if (myAdditive == null) {
- myAdditive = new ArrayList();
+ myAdditive = new ArrayList();
}
return myAdditive;
}
@@ -1030,7 +1030,7 @@ public class Specimen extends BaseResource implements IResource {
*
*
*/
- public void setAdditive(List theValue) {
+ public void setAdditive(List theValue) {
myAdditive = theValue;
}
@@ -1093,7 +1093,7 @@ public class Specimen extends BaseResource implements IResource {
shortDefinition="Additive associated with container",
formalDefinition="Additive associated with the container"
)
- private ResourceReference myAdditive;
+ private ResourceReferenceDt myAdditive;
@Override
@@ -1291,9 +1291,9 @@ public class Specimen extends BaseResource implements IResource {
* Additive associated with the container
*
*/
- public ResourceReference getAdditive() {
+ public ResourceReferenceDt getAdditive() {
if (myAdditive == null) {
- myAdditive = new ResourceReference();
+ myAdditive = new ResourceReferenceDt();
}
return myAdditive;
}
@@ -1306,7 +1306,7 @@ public class Specimen extends BaseResource implements IResource {
* Additive associated with the container
*
*/
- public void setAdditive(ResourceReference theValue) {
+ public void setAdditive(ResourceReferenceDt theValue) {
myAdditive = theValue;
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Substance.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Substance.java
index 5d0e886fc16..f20432a72b2 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Substance.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Substance.java
@@ -37,7 +37,7 @@ import ca.uhn.fhir.model.dstu.valueset.*;
*
*
*/
-@ResourceDef(name="Substance", profile="http://hl7.org/fhir/profiles/Substance")
+@ResourceDef(name="Substance", profile="http://hl7.org/fhir/profiles/Substance", id="substance")
public class Substance extends BaseResource implements IResource {
/**
@@ -470,7 +470,7 @@ public class Substance extends BaseResource implements IResource {
shortDefinition="A component of the substance",
formalDefinition="Another substance that is a component of this substance"
)
- private ResourceReference mySubstance;
+ private ResourceReferenceDt mySubstance;
@Override
@@ -519,9 +519,9 @@ public class Substance extends BaseResource implements IResource {
* Another substance that is a component of this substance
*
*/
- public ResourceReference getSubstance() {
+ public ResourceReferenceDt getSubstance() {
if (mySubstance == null) {
- mySubstance = new ResourceReference();
+ mySubstance = new ResourceReferenceDt();
}
return mySubstance;
}
@@ -534,7 +534,7 @@ public class Substance extends BaseResource implements IResource {
* Another substance that is a component of this substance
*
*/
- public void setSubstance(ResourceReference theValue) {
+ public void setSubstance(ResourceReferenceDt theValue) {
mySubstance = theValue;
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/ValueSet.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/ValueSet.java
index e76975e55d9..2decd6fc49b 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/ValueSet.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/ValueSet.java
@@ -37,7 +37,7 @@ import ca.uhn.fhir.model.dstu.valueset.*;
*
*
*/
-@ResourceDef(name="ValueSet", profile="http://hl7.org/fhir/profiles/ValueSet")
+@ResourceDef(name="ValueSet", profile="http://hl7.org/fhir/profiles/ValueSet", id="valueset")
public class ValueSet extends BaseResource implements IResource {
/**
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/ParserState.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/ParserState.java
index ca6c541a581..671a79bc77b 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/ParserState.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/ParserState.java
@@ -30,8 +30,9 @@ import ca.uhn.fhir.model.api.IPrimitiveDatatype;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.IResourceBlock;
import ca.uhn.fhir.model.api.ISupportsUndeclaredExtensions;
-import ca.uhn.fhir.model.api.ResourceReference;
+import ca.uhn.fhir.model.api.BaseResourceReference;
import ca.uhn.fhir.model.api.UndeclaredExtension;
+import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
import ca.uhn.fhir.model.primitive.XhtmlDt;
class ParserState {
@@ -58,8 +59,8 @@ class ParserState {
myState.enteringNewElement(theNamespaceURI, theName);
}
- public void enteringNewElementExtension(StartElement theElem, String theUrlAttr) {
- myState.enteringNewElementExtension(theElem, theUrlAttr);
+ public void enteringNewElementExtension(StartElement theElem, String theUrlAttr, boolean theIsModifier) {
+ myState.enteringNewElementExtension(theElem, theUrlAttr, theIsModifier);
}
public T getObject() {
@@ -370,15 +371,19 @@ class ParserState {
/**
* Default implementation just handles undeclared extensions
*/
- public void enteringNewElementExtension(@SuppressWarnings("unused") StartElement theElement, String theUrlAttr) {
+ public void enteringNewElementExtension(@SuppressWarnings("unused") StartElement theElement, String theUrlAttr, boolean theIsModifier) {
if (getCurrentElement() instanceof ISupportsUndeclaredExtensions) {
- UndeclaredExtension newExtension = new UndeclaredExtension(theUrlAttr);
- // TODO: fail if we don't support undeclared extensions
- ((ISupportsUndeclaredExtensions) getCurrentElement()).getUndeclaredExtensions().add(newExtension);
+ UndeclaredExtension newExtension = new UndeclaredExtension(theIsModifier, theUrlAttr);
+ ISupportsUndeclaredExtensions elem = (ISupportsUndeclaredExtensions) getCurrentElement();
+ if (theIsModifier) {
+ elem.getUndeclaredModifierExtensions().add(newExtension);
+ } else {
+ elem.getUndeclaredExtensions().add(newExtension);
+ }
ExtensionState newState = new ExtensionState(newExtension);
push(newState);
} else {
- throw new DataFormatException("Extension is not supported at this position");
+ throw new DataFormatException("Type " + getCurrentElement() + " does not support undeclared extentions, and found an extension with URL: " + theUrlAttr);
}
}
@@ -446,7 +451,7 @@ class ParserState {
}
case RESOURCE_REF: {
RuntimeResourceReferenceDefinition resourceRefTarget = (RuntimeResourceReferenceDefinition) target;
- ResourceReference newChildInstance = new ResourceReference();
+ ResourceReferenceDt newChildInstance = new ResourceReferenceDt();
myDefinition.getMutator().addValue(myParentInstance, newChildInstance);
ResourceReferenceState newState = new ResourceReferenceState(resourceRefTarget, newChildInstance);
push(newState);
@@ -463,7 +468,7 @@ class ParserState {
}
@Override
- public void enteringNewElementExtension(StartElement theElement, String theUrlAttr) {
+ public void enteringNewElementExtension(StartElement theElement, String theUrlAttr, boolean theIsModifier) {
RuntimeChildDeclaredExtensionDefinition declaredExtension = myDefinition.getChildExtensionForUrl(theUrlAttr);
if (declaredExtension != null) {
if (myChildInstance == null) {
@@ -473,7 +478,7 @@ class ParserState {
BaseState newState = new DeclaredExtensionState(declaredExtension, myChildInstance);
push(newState);
} else {
- super.enteringNewElementExtension(theElement, theUrlAttr);
+ super.enteringNewElementExtension(theElement, theUrlAttr, theIsModifier);
}
}
@@ -514,7 +519,7 @@ class ParserState {
switch (target.getChildType()) {
case COMPOSITE_DATATYPE: {
BaseRuntimeElementCompositeDefinition> compositeTarget = (BaseRuntimeElementCompositeDefinition>) target;
- ICompositeDatatype newChildInstance = (ICompositeDatatype) compositeTarget.newInstance();
+ ICompositeDatatype newChildInstance = (ICompositeDatatype) compositeTarget.newInstance(child.getInstanceConstructorArguments());
child.getMutator().addValue(myInstance, newChildInstance);
ElementCompositeState newState = new ElementCompositeState(compositeTarget, newChildInstance);
push(newState);
@@ -531,7 +536,7 @@ class ParserState {
}
case RESOURCE_REF: {
RuntimeResourceReferenceDefinition resourceRefTarget = (RuntimeResourceReferenceDefinition) target;
- ResourceReference newChildInstance = new ResourceReference();
+ ResourceReferenceDt newChildInstance = new ResourceReferenceDt();
child.getMutator().addValue(myInstance, newChildInstance);
ResourceReferenceState newState = new ResourceReferenceState(resourceRefTarget, newChildInstance);
push(newState);
@@ -564,13 +569,13 @@ class ParserState {
}
@Override
- public void enteringNewElementExtension(StartElement theElement, String theUrlAttr) {
+ public void enteringNewElementExtension(StartElement theElement, String theUrlAttr, boolean theIsModifier) {
RuntimeChildDeclaredExtensionDefinition declaredExtension = myDefinition.getDeclaredExtension(theUrlAttr);
if (declaredExtension != null) {
BaseState newState = new DeclaredExtensionState(declaredExtension, myInstance);
push(newState);
} else {
- super.enteringNewElementExtension(theElement, theUrlAttr);
+ super.enteringNewElementExtension(theElement, theUrlAttr, theIsModifier);
}
}
@@ -623,7 +628,7 @@ class ParserState {
}
case RESOURCE_REF: {
RuntimeResourceReferenceDefinition resourceRefTarget = (RuntimeResourceReferenceDefinition) target;
- ResourceReference newChildInstance = new ResourceReference();
+ ResourceReferenceDt newChildInstance = new ResourceReferenceDt();
myExtension.setValue(newChildInstance);
ResourceReferenceState newState = new ResourceReferenceState(resourceRefTarget, newChildInstance);
push(newState);
@@ -784,10 +789,10 @@ class ParserState {
private class ResourceReferenceState extends BaseState {
private RuntimeResourceReferenceDefinition myDefinition;
- private ResourceReference myInstance;
+ private ResourceReferenceDt myInstance;
private ResourceReferenceSubState mySubState;
- public ResourceReferenceState(RuntimeResourceReferenceDefinition theDefinition, ResourceReference theInstance) {
+ public ResourceReferenceState(RuntimeResourceReferenceDefinition theDefinition, ResourceReferenceDt theInstance) {
myDefinition = theDefinition;
myInstance = theInstance;
mySubState = ResourceReferenceSubState.INITIAL;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/XmlParser.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/XmlParser.java
index cb25fcb31dc..9ffb9643e3e 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/XmlParser.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/XmlParser.java
@@ -34,6 +34,7 @@ import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition;
import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.context.RuntimeChildDeclaredExtensionDefinition;
import ca.uhn.fhir.context.RuntimeChildUndeclaredExtensionDefinition;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.model.api.Bundle;
@@ -42,8 +43,9 @@ import ca.uhn.fhir.model.api.IElement;
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.ISupportsUndeclaredExtensions;
-import ca.uhn.fhir.model.api.ResourceReference;
+import ca.uhn.fhir.model.api.BaseResourceReference;
import ca.uhn.fhir.model.api.UndeclaredExtension;
+import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
import ca.uhn.fhir.model.primitive.InstantDt;
import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.model.primitive.XhtmlDt;
@@ -89,7 +91,14 @@ public class XmlParser implements IParser {
if (urlAttr == null || isBlank(urlAttr.getValue())) {
throw new DataFormatException("Extension element has no 'url' attribute");
}
- parserState.enteringNewElementExtension(elem, urlAttr.getValue());
+ parserState.enteringNewElementExtension(elem, urlAttr.getValue(),false);
+ } else if ("modifierExtension".equals(elem.getName().getLocalPart())) {
+ Attribute urlAttr = elem.getAttributeByName(new QName("url"));
+ if (urlAttr == null || isBlank(urlAttr.getValue())) {
+ throw new DataFormatException("Extension element has no 'url' attribute");
+ }
+ parserState.enteringNewElementExtension(elem, urlAttr.getValue(),true);
+
} else {
String elementName = elem.getName().getLocalPart();
@@ -131,7 +140,7 @@ public class XmlParser implements IParser {
parserState.xmlEvent(nextEvent);
} catch (DataFormatException e) {
- throw new DataFormatException("DataFormatException at [" + nextEvent.getLocation().toString() + "]: "+e.getMessage(), e);
+ throw new DataFormatException("DataFormatException at [" + nextEvent.getLocation().toString() + "]: " + e.getMessage(), e);
}
}
return null;
@@ -140,7 +149,9 @@ public class XmlParser implements IParser {
}
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see ca.uhn.fhir.parser.IParser#encodeBundleToString(ca.uhn.fhir.model.api.Bundle)
*/
@Override
@@ -151,7 +162,9 @@ public class XmlParser implements IParser {
return stringWriter.toString();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see ca.uhn.fhir.parser.IParser#encodeBundleToWriter(ca.uhn.fhir.model.api.Bundle, java.io.Writer)
*/
@Override
@@ -211,13 +224,12 @@ public class XmlParser implements IParser {
}
}
-
-
- private void encodeChildElementToStreamWriter(XMLStreamWriter theEventWriter, IElement nextValue, String childName, BaseRuntimeElementDefinition> childDef, String theExtensionUrl) throws XMLStreamException, DataFormatException {
+ private void encodeChildElementToStreamWriter(XMLStreamWriter theEventWriter, IElement nextValue, String childName, BaseRuntimeElementDefinition> childDef, String theExtensionUrl)
+ throws XMLStreamException, DataFormatException {
if (nextValue.isEmpty()) {
return;
}
-
+
switch (childDef.getChildType()) {
case PRIMITIVE_DATATYPE: {
IPrimitiveDatatype> pd = (IPrimitiveDatatype>) nextValue;
@@ -243,7 +255,7 @@ public class XmlParser implements IParser {
break;
}
case RESOURCE_REF: {
- ResourceReference ref = (ResourceReference) nextValue;
+ ResourceReferenceDt ref = (ResourceReferenceDt) nextValue;
if (!ref.isEmpty()) {
theEventWriter.writeStartElement(childName);
encodeResourceReferenceToStreamWriter(theEventWriter, ref);
@@ -268,7 +280,8 @@ public class XmlParser implements IParser {
}
- private void encodeCompositeElementChildrenToStreamWriter(IElement theElement, XMLStreamWriter theEventWriter, List extends BaseRuntimeChildDefinition> children) throws XMLStreamException, DataFormatException {
+ private void encodeCompositeElementChildrenToStreamWriter(IElement theElement, XMLStreamWriter theEventWriter, List extends BaseRuntimeChildDefinition> children) throws XMLStreamException,
+ DataFormatException {
for (BaseRuntimeChildDefinition nextChild : children) {
List extends IElement> values = nextChild.getAccessor().getValues(theElement);
if (values == null || values.isEmpty()) {
@@ -288,7 +301,13 @@ public class XmlParser implements IParser {
}
if (extensionUrl != null && childName.equals("extension") == false) {
- theEventWriter.writeStartElement("extension");
+ RuntimeChildDeclaredExtensionDefinition extDef = (RuntimeChildDeclaredExtensionDefinition) nextChild;
+ if (extDef.isModifier()) {
+ theEventWriter.writeStartElement("modifierExtension");
+ }else {
+ theEventWriter.writeStartElement("extension");
+ }
+
theEventWriter.writeAttribute("url", extensionUrl);
encodeChildElementToStreamWriter(theEventWriter, nextValue, childName, childDef, null);
theEventWriter.writeEndElement();
@@ -299,50 +318,57 @@ public class XmlParser implements IParser {
}
}
- private void encodeCompositeElementToStreamWriter(IElement theElement, XMLStreamWriter theEventWriter, BaseRuntimeElementCompositeDefinition> resDef) throws XMLStreamException, DataFormatException {
+ private void encodeCompositeElementToStreamWriter(IElement theElement, XMLStreamWriter theEventWriter, BaseRuntimeElementCompositeDefinition> resDef) throws XMLStreamException,
+ DataFormatException {
encodeExtensionsIfPresent(theEventWriter, theElement);
encodeCompositeElementChildrenToStreamWriter(theElement, theEventWriter, resDef.getExtensions());
encodeCompositeElementChildrenToStreamWriter(theElement, theEventWriter, resDef.getChildren());
}
private void encodeExtensionsIfPresent(XMLStreamWriter theWriter, IElement theResource) throws XMLStreamException, DataFormatException {
- boolean retVal = false;
if (theResource instanceof ISupportsUndeclaredExtensions) {
- for (UndeclaredExtension next : ((ISupportsUndeclaredExtensions) theResource).getUndeclaredExtensions()) {
- retVal = true;
- theWriter.writeStartElement("extension");
- theWriter.writeAttribute("url", next.getUrl());
+ ISupportsUndeclaredExtensions res = (ISupportsUndeclaredExtensions) theResource;
+ encodeUndeclaredExtensions(theWriter, res.getUndeclaredExtensions(), "extension");
+ encodeUndeclaredExtensions(theWriter, res.getUndeclaredModifierExtensions(), "modifierExtension");
+ }
+ }
- if (next.getValue() != null) {
- IElement nextValue = next.getValue();
- RuntimeChildUndeclaredExtensionDefinition extDef = myContext.getRuntimeChildUndeclaredExtensionDefinition();
- String childName = extDef.getChildNameByDatatype(nextValue.getClass());
- BaseRuntimeElementDefinition> childDef = extDef.getChildElementDefinitionByDatatype(nextValue.getClass());
- encodeChildElementToStreamWriter(theWriter, nextValue, childName, childDef, null);
- }
+ private void encodeUndeclaredExtensions(XMLStreamWriter theWriter, List extensions, String tagName) throws XMLStreamException {
+ for (UndeclaredExtension next : extensions) {
+ theWriter.writeStartElement(tagName);
+ theWriter.writeAttribute("url", next.getUrl());
- // child extensions
- encodeExtensionsIfPresent(theWriter, next);
-
- theWriter.writeEndElement();
+ if (next.getValue() != null) {
+ IElement nextValue = next.getValue();
+ RuntimeChildUndeclaredExtensionDefinition extDef = myContext.getRuntimeChildUndeclaredExtensionDefinition();
+ String childName = extDef.getChildNameByDatatype(nextValue.getClass());
+ BaseRuntimeElementDefinition> childDef = extDef.getChildElementDefinitionByDatatype(nextValue.getClass());
+ encodeChildElementToStreamWriter(theWriter, nextValue, childName, childDef, null);
}
+
+ // child extensions
+ encodeExtensionsIfPresent(theWriter, next);
+
+ theWriter.writeEndElement();
}
}
- private void encodeResourceReferenceToStreamWriter(XMLStreamWriter theEventWriter, ResourceReference theRef) throws XMLStreamException {
- if (StringUtils.isNotBlank(theRef.getDisplay())) {
+ private void encodeResourceReferenceToStreamWriter(XMLStreamWriter theEventWriter, ResourceReferenceDt theRef) throws XMLStreamException {
+ if (!(theRef.getDisplay().isEmpty())) {
theEventWriter.writeStartElement("display");
- theEventWriter.writeAttribute("value", theRef.getDisplay());
+ theEventWriter.writeAttribute("value", theRef.getDisplay().getValue());
theEventWriter.writeEndElement();
}
- if (StringUtils.isNotBlank(theRef.getReference())) {
+ if (!(theRef.getReference().isEmpty())) {
theEventWriter.writeStartElement("reference");
- theEventWriter.writeAttribute("value", theRef.getReference());
+ theEventWriter.writeAttribute("value", theRef.getReference().getValue());
theEventWriter.writeEndElement();
}
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see ca.uhn.fhir.parser.IParser#encodeResourceToString(ca.uhn.fhir.model.api.IResource)
*/
@Override
@@ -352,7 +378,9 @@ public class XmlParser implements IParser {
return stringWriter.toString();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see ca.uhn.fhir.parser.IParser#encodeResourceToWriter(ca.uhn.fhir.model.api.IResource, java.io.Writer)
*/
@Override
@@ -368,7 +396,9 @@ public class XmlParser implements IParser {
}
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see ca.uhn.fhir.parser.IParser#encodeResourceToXmlStreamWriter(ca.uhn.fhir.model.api.IResource, javax.xml.stream.XMLStreamWriter)
*/
@Override
@@ -431,7 +461,7 @@ public class XmlParser implements IParser {
theEventWriter.writeStartElement(se.getName().getLocalPart());
if (StringUtils.isBlank(se.getName().getPrefix())) {
theEventWriter.writeDefaultNamespace(se.getName().getNamespaceURI());
- }else {
+ } else {
theEventWriter.writeNamespace(se.getName().getPrefix(), se.getName().getNamespaceURI());
}
} else {
@@ -442,8 +472,8 @@ public class XmlParser implements IParser {
if (StringUtils.isBlank(se.getName().getPrefix())) {
theEventWriter.writeStartElement(se.getName().getLocalPart());
theEventWriter.writeDefaultNamespace(se.getName().getNamespaceURI());
- }else {
- theEventWriter.writeStartElement(se.getName().getNamespaceURI(), se.getName().getLocalPart());
+ } else {
+ theEventWriter.writeStartElement(se.getName().getNamespaceURI(), se.getName().getLocalPart());
}
}
} else {
@@ -464,7 +494,9 @@ public class XmlParser implements IParser {
}
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see ca.uhn.fhir.parser.IParser#parseBundle(java.lang.String)
*/
@Override
@@ -478,7 +510,9 @@ public class XmlParser implements IParser {
return doXmlLoop(theStreamReader, parserState);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see ca.uhn.fhir.parser.IParser#parseResource(java.lang.String)
*/
@Override
@@ -486,7 +520,9 @@ public class XmlParser implements IParser {
return parseResource(null, theMessageString);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see ca.uhn.fhir.parser.IParser#parseResource(javax.xml.stream.XMLEventReader)
*/
@Override
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java
index eb8cb3c9108..d36af3a0193 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java
@@ -17,6 +17,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import ca.uhn.fhir.rest.server.exceptions.*;
+
import org.apache.commons.lang3.StringUtils;
import ca.uhn.fhir.context.FhirContext;
@@ -98,9 +99,18 @@ public abstract class RestfulServer extends HttpServlet {
}
}
+ /**
+ * This method must be overridden to provide one or more resource providers
+ */
public abstract Collection getResourceProviders();
- public abstract ISecurityManager getSecurityManager();
+ /**
+ * This method should be overridden to provide a security manager
+ * instance. By default, returns null.
+ */
+ public ISecurityManager getSecurityManager() {
+ return null;
+ }
protected void handleRequest(SearchMethodBinding.RequestType requestType, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/ElementUtil.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/ElementUtil.java
index d25740d3189..77aa1151660 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/ElementUtil.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/ElementUtil.java
@@ -8,17 +8,16 @@ public class ElementUtil {
@SuppressWarnings("unchecked")
public static boolean isEmpty(Object... theElements) {
- if (theElements ==null) {
+ if (theElements == null) {
return true;
}
for (int i = 0; i < theElements.length; i++) {
Object next = theElements[i];
if (next instanceof List) {
- if (!isEmpty((List extends IElement>)next)) {
+ if (!isEmpty((List extends IElement>) next)) {
return false;
}
- }
- if (next != null && !((IElement)next).isEmpty()) {
+ } else if (next != null && !((IElement) next).isEmpty()) {
return false;
}
}
@@ -26,7 +25,7 @@ public class ElementUtil {
}
public static boolean isEmpty(IElement... theElements) {
- if (theElements ==null) {
+ if (theElements == null) {
return true;
}
for (int i = 0; i < theElements.length; i++) {
@@ -39,7 +38,7 @@ public class ElementUtil {
}
public static boolean isEmpty(List extends IElement> theElements) {
- if (theElements ==null) {
+ if (theElements == null) {
return true;
}
for (int i = 0; i < theElements.size(); i++) {
@@ -50,5 +49,5 @@ public class ElementUtil {
}
return true;
}
-
+
}
diff --git a/hapi-fhir-base/src/site/example/java/example/ExampleRestfulServlet.java b/hapi-fhir-base/src/site/example/java/example/ExampleRestfulServlet.java
new file mode 100644
index 00000000000..39447f74649
--- /dev/null
+++ b/hapi-fhir-base/src/site/example/java/example/ExampleRestfulServlet.java
@@ -0,0 +1,38 @@
+package example;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.servlet.annotation.WebServlet;
+
+import ca.uhn.fhir.rest.server.IResourceProvider;
+import ca.uhn.fhir.rest.server.RestfulServer;
+
+//START SNIPPET: servlet
+/**
+ * In this example, we are using Servlet 3.0 annotations to define
+ * the URL pattern for this servlet, but we could also
+ * define this in a web.xml file.
+ */
+@WebServlet(urlPatterns= {"/fhir/*"}, displayName="FHIR Server")
+public class ExampleRestfulServlet extends RestfulServer {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Restful servers must provide an implementation of this method, which
+ * returns all resource providers to be used by this server. In the example
+ * below, we are creating a RESTful server which is able to serve
+ * Patient and Observation resources.
+ */
+ @Override
+ public Collection getResourceProviders() {
+ List retVal = new ArrayList();
+ retVal.add(new RestfulPatientResourceProvider());
+ retVal.add(new RestfulObservationResourceProvider());
+ return retVal;
+ }
+
+}
+//END SNIPPET: servlet
diff --git a/hapi-fhir-base/src/site/example/java/example/RestfulObservationResourceProvider.java b/hapi-fhir-base/src/site/example/java/example/RestfulObservationResourceProvider.java
new file mode 100644
index 00000000000..9890131b4d6
--- /dev/null
+++ b/hapi-fhir-base/src/site/example/java/example/RestfulObservationResourceProvider.java
@@ -0,0 +1,86 @@
+package example;
+
+import java.util.Collections;
+import java.util.List;
+
+import ca.uhn.fhir.model.dstu.resource.Patient;
+import ca.uhn.fhir.model.dstu.valueset.AdministrativeGenderCodesEnum;
+import ca.uhn.fhir.model.dstu.valueset.IdentifierUseEnum;
+import ca.uhn.fhir.model.primitive.IdDt;
+import ca.uhn.fhir.model.primitive.StringDt;
+import ca.uhn.fhir.model.primitive.UriDt;
+import ca.uhn.fhir.rest.annotation.Read;
+import ca.uhn.fhir.rest.server.IResourceProvider;
+import ca.uhn.fhir.rest.server.operations.Search;
+import ca.uhn.fhir.rest.server.parameters.Required;
+
+//START SNIPPET: provider
+/**
+ * All resource providers must implement IResourceProvider
+ */
+public class RestfulObservationResourceProvider implements IResourceProvider {
+
+ /**
+ * The getResourceType method comes from IResourceProvider, and must
+ * be overridden to indicate what type of resource this provider
+ * supplies.
+ */
+ @Override
+ public Class getResourceType() {
+ return Patient.class;
+ }
+
+ /**
+ * The "@Read" annotation indicates that this method supports the
+ * read operation. It takes one argument, the Resource type being returned.
+ *
+ * @param theId
+ * The read operation takes one parameter, which must be of type
+ * IdDt and must be annotated with the "@Read.IdParam" annotation.
+ * @return
+ * Returns a resource matching this identifier, or null if none exists.
+ */
+ @Read(Patient.class)
+ public Patient getResourceById(@Read.IdParam IdDt theId) {
+ Patient patient = new Patient();
+ patient.addIdentifier();
+ patient.getIdentifier().get(0).setSystem(new UriDt("urn:hapitest:mrns"));
+ patient.getIdentifier().get(0).setValue("00002");
+ patient.addName().addFamily("Test");
+ patient.getName().get(0).addGiven("PatientOne");
+ patient.setGender(AdministrativeGenderCodesEnum.F);
+ return patient;
+ }
+
+ /**
+ * The "@Search" annotation indicates that this method supports the
+ * search operation. You may have many different method annotated with
+ * this annotation, to support many different search criteria. This
+ * example searches by family name.
+ *
+ * @param theIdentifier
+ * This operation takes one parameter which is the search criteria. It is
+ * annotated with the "@Required" annotation. This annotation takes one argument,
+ * a string containing the name of the search criteria. The datatype here
+ * is StringDt, but there are other possible parameter types depending on the
+ * specific search criteria.
+ * @return
+ * This method returns a list of Patients. This list may contain multiple
+ * matching resources, or it may also be empty.
+ */
+ @Search(Patient.class)
+ public List getPatient(@Required(name = Patient.SP_FAMILY) StringDt theFamilyName) {
+ Patient patient = new Patient();
+ patient.addIdentifier();
+ patient.getIdentifier().get(0).setUse(IdentifierUseEnum.OFFICIAL);
+ patient.getIdentifier().get(0).setSystem(new UriDt("urn:hapitest:mrns"));
+ patient.getIdentifier().get(0).setValue("00001");
+ patient.addName();
+ patient.getName().get(0).addFamily("Test");
+ patient.getName().get(0).addGiven("PatientOne");
+ patient.getGender().setText("M");
+ return Collections.singletonList(patient);
+ }
+
+}
+//END SNIPPET: provider
diff --git a/hapi-fhir-base/src/site/example/java/example/RestfulServlet.java b/hapi-fhir-base/src/site/example/java/example/RestfulServlet.java
deleted file mode 100644
index da5916f2d6e..00000000000
--- a/hapi-fhir-base/src/site/example/java/example/RestfulServlet.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package example;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-import ca.uhn.fhir.rest.server.IResourceProvider;
-import ca.uhn.fhir.rest.server.ISecurityManager;
-import ca.uhn.fhir.rest.server.RestfulServer;
-
-public class RestfulServlet extends RestfulServer {
-
- private static final long serialVersionUID = 1L;
-
- private Collection myResourceProviders;
-
- public RestfulServlet(IResourceProvider... theResourceProviders) {
- myResourceProviders = Arrays.asList(theResourceProviders);
- }
-
- @Override
- public Collection getResourceProviders() {
- return myResourceProviders;
- }
-
- @Override
- public ISecurityManager getSecurityManager() {
- return null;
- }
-
-}
diff --git a/hapi-fhir-base/src/site/xdoc/doc_rest_server.xml b/hapi-fhir-base/src/site/xdoc/doc_rest_server.xml
index 1b466c29a48..8ff2103729f 100644
--- a/hapi-fhir-base/src/site/xdoc/doc_rest_server.xml
+++ b/hapi-fhir-base/src/site/xdoc/doc_rest_server.xml
@@ -9,7 +9,7 @@
-
+
@@ -26,7 +26,7 @@
be possible to create a FHIR compliant server quickly and easily.
-
+
The first step in creating a FHIR RESTful Server is to define one or
@@ -41,7 +41,9 @@
- Resource providers each contain one or more methods which have been
+ A Resource provider class must implement the
+ IResourceProvider interface,
+ and will contain one or more methods which have been
annotated with special annotations indicating which RESTful operation
that method supports. Below is a simple example of a resource provider
which supports the
@@ -59,7 +61,37 @@
+
+
+ Once your resource providers are created, your next step is to
+ define a server class.
+
+
+
+ HAPI provides a class called
+ RestfulServer, which
+ is a specialized Java Servlet. To create a server, you simply create a class
+ which extends RestfulServer as shown in the example below.
+
+
+
+
+
+
+
+
+
+
+
+
+ Once you have created your resource providers and your restful server class,
+ you can bundle these into a WAR file and you are ready to deploy to
+ any JEE container (Tomcat, Websphere, Glassfish, etc).
+