();
}
return myUndeclaredModifierExtensions;
}
@@ -54,14 +54,14 @@ public abstract class BaseElement implements IIdentifiableElement, ISupportsUnde
*/
protected boolean isBaseEmpty() {
if (myUndeclaredExtensions != null) {
- for (UndeclaredExtension next : myUndeclaredExtensions) {
+ for (ExtensionDt next : myUndeclaredExtensions) {
if (!next.isEmpty()) {
return false;
}
}
}
if (myUndeclaredModifierExtensions != null) {
- for (UndeclaredExtension next : myUndeclaredModifierExtensions) {
+ for (ExtensionDt next : myUndeclaredModifierExtensions) {
if (!next.isEmpty()) {
return false;
}
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/ExtensionDt.java
similarity index 67%
rename from hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/UndeclaredExtension.java
rename to hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ExtensionDt.java
index 4015aaff043..0dec4e14cb1 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/ExtensionDt.java
@@ -1,31 +1,43 @@
package ca.uhn.fhir.model.api;
-public class UndeclaredExtension extends BaseElement {
+import ca.uhn.fhir.model.api.annotation.Child;
+import ca.uhn.fhir.model.api.annotation.DatatypeDef;
+import ca.uhn.fhir.model.primitive.StringDt;
+
+@DatatypeDef(name="Extension")
+public class ExtensionDt extends BaseElement {
- private String myUrl;
- private IElement myValue;
private boolean myIsModifier;
+
+ @Child(name="use", type=StringDt.class, order=0, min=1, max=1)
+ private StringDt myUrl;
+
+ @Child(name="value", type=IDatatype.class, order=1, min=0, max=1)
+ private IElement myValue;
- public UndeclaredExtension() {
+ public ExtensionDt() {
}
- public UndeclaredExtension(boolean theIsModifier) {
+ public ExtensionDt(boolean theIsModifier) {
myIsModifier = theIsModifier;
}
- public UndeclaredExtension(boolean theIsModifier, String theUrl) {
+ public ExtensionDt(boolean theIsModifier, String theUrl) {
myIsModifier = theIsModifier;
- myUrl = theUrl;
+ myUrl = new StringDt(theUrl);
}
- public boolean isModifier() {
- return myIsModifier;
- }
-
- public String getUrl() {
+ public StringDt getUrl() {
+ if (myUrl==null) {
+ myUrl=new StringDt();
+ }
return myUrl;
}
+ public String getUrlAsString() {
+ return myUrl.getValue();
+ }
+
/**
* Returns the value of this extension, if one exists.
*
@@ -36,7 +48,7 @@ public class UndeclaredExtension extends BaseElement {
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.
@@ -52,7 +64,20 @@ public class UndeclaredExtension extends BaseElement {
return (IPrimitiveDatatype>) getValue();
}
+ @Override
+ public boolean isEmpty() {
+ return super.isBaseEmpty() && myValue == null || myValue.isEmpty();
+ }
+
+ public boolean isModifier() {
+ return myIsModifier;
+ }
+
public void setUrl(String theUrl) {
+ myUrl = new StringDt(theUrl);
+ }
+
+ public void setUrl(StringDt theUrl) {
myUrl = theUrl;
}
@@ -60,9 +85,4 @@ public class UndeclaredExtension extends BaseElement {
myValue = theValue;
}
- @Override
- public boolean isEmpty() {
- return super.isBaseEmpty() && myValue == null || myValue.isEmpty();
- }
-
}
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 d5ffdfed423..9747e3cf48a 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
@@ -7,16 +7,16 @@ public interface ISupportsUndeclaredExtensions extends IElement {
/**
* Returns a list containing all undeclared non-modifier extensions
*/
- List getUndeclaredExtensions();
+ List getUndeclaredExtensions();
/**
* Returns an immutable list containing all extensions (modifier and non-modifier)
*/
- List getAllUndeclaredExtensions();
+ List getAllUndeclaredExtensions();
/**
* Returns a list containing all undeclared modifier extensions
*/
- List getUndeclaredModifierExtensions();
+ List getUndeclaredModifierExtensions();
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Alert.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Alert.java
new file mode 100644
index 00000000000..b0d05cebd91
--- /dev/null
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Alert.java
@@ -0,0 +1,406 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+package ca.uhn.fhir.model.dstu.resource;
+
+
+import java.util.List;
+
+import ca.uhn.fhir.model.api.BaseResource;
+import ca.uhn.fhir.model.api.IElement;
+import ca.uhn.fhir.model.api.IResource;
+import ca.uhn.fhir.model.api.annotation.Child;
+import ca.uhn.fhir.model.api.annotation.Description;
+import ca.uhn.fhir.model.api.annotation.ResourceDef;
+import ca.uhn.fhir.model.dstu.composite.CodeableConceptDt;
+import ca.uhn.fhir.model.dstu.composite.IdentifierDt;
+import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
+import ca.uhn.fhir.model.dstu.valueset.AlertStatusEnum;
+import ca.uhn.fhir.model.dstu.valueset.IdentifierUseEnum;
+import ca.uhn.fhir.model.primitive.BoundCodeDt;
+import ca.uhn.fhir.model.primitive.CodeDt;
+import ca.uhn.fhir.model.primitive.StringDt;
+
+
+/**
+ * HAPI/FHIR Alert Resource
+ * (Key information to flag to healthcare providers)
+ *
+ *
+ * Definition:
+ * Prospective warnings of potential issues when providing care to the patient
+ *
+ *
+ *
+ * Requirements:
+ *
+ *
+ */
+@ResourceDef(name="Alert", profile="http://hl7.org/fhir/profiles/Alert", id="alert")
+public class Alert extends BaseResource implements IResource {
+
+ /**
+ * Search parameter constant for subject
+ *
+ * Description: The identity of a subject to list alerts for
+ * Type: reference
+ * Path: Alert.subject
+ *
+ */
+ public static final String SP_SUBJECT = "subject";
+
+
+ @Child(name="identifier", type=IdentifierDt.class, order=0, min=0, max=Child.MAX_UNLIMITED)
+ @Description(
+ shortDefinition="Business identifier",
+ formalDefinition="Identifier assigned to the alert for external use (outside the FHIR environment)"
+ )
+ private java.util.List myIdentifier;
+
+ @Child(name="category", type=CodeableConceptDt.class, order=1, min=0, max=1)
+ @Description(
+ shortDefinition="Clinical, administrative, etc.",
+ formalDefinition="Allows an alert to be divided into different categories like clinical, administrative etc."
+ )
+ private CodeableConceptDt myCategory;
+
+ @Child(name="status", type=CodeDt.class, order=2, min=1, max=1)
+ @Description(
+ shortDefinition="active | inactive | entered in error",
+ formalDefinition="Supports basic workflow"
+ )
+ private BoundCodeDt myStatus;
+
+ @Child(name="subject", order=3, min=1, max=1, type={
+ ca.uhn.fhir.model.dstu.resource.Patient.class,
+ })
+ @Description(
+ shortDefinition="Who is alert about?",
+ formalDefinition="The person who this alert concerns"
+ )
+ private ResourceReferenceDt mySubject;
+
+ @Child(name="author", order=4, min=0, max=1, type={
+ ca.uhn.fhir.model.dstu.resource.Practitioner.class,
+ ca.uhn.fhir.model.dstu.resource.Patient.class,
+ ca.uhn.fhir.model.dstu.resource.Device.class,
+ })
+ @Description(
+ shortDefinition="Alert creator",
+ formalDefinition="The person or device that created the alert"
+ )
+ private ResourceReferenceDt myAuthor;
+
+ @Child(name="note", type=StringDt.class, order=5, min=1, max=1)
+ @Description(
+ shortDefinition="Text of alert",
+ formalDefinition="The textual component of the alert to display to the user"
+ )
+ private StringDt myNote;
+
+
+ @Override
+ public boolean isEmpty() {
+ return super.isBaseEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty( myIdentifier, myCategory, myStatus, mySubject, myAuthor, myNote);
+ }
+
+ @Override
+ public java.util.List getAllPopulatedChildElements() {
+ return getAllPopulatedChildElementsOfType(null);
+ }
+
+ @Override
+ public List getAllPopulatedChildElementsOfType(Class theType) {
+ return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(theType, myIdentifier, myCategory, myStatus, mySubject, myAuthor, myNote);
+ }
+
+ /**
+ * Gets the value(s) for identifier (Business identifier).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * Identifier assigned to the alert for external use (outside the FHIR environment)
+ *
+ */
+ public java.util.List getIdentifier() {
+ if (myIdentifier == null) {
+ myIdentifier = new java.util.ArrayList();
+ }
+ return myIdentifier;
+ }
+
+ /**
+ * Sets the value(s) for identifier (Business identifier)
+ *
+ *
+ * Definition:
+ * Identifier assigned to the alert for external use (outside the FHIR environment)
+ *
+ */
+ public Alert setIdentifier(java.util.List theValue) {
+ myIdentifier = theValue;
+ return this;
+ }
+
+ /**
+ * Adds and returns a new value for identifier (Business identifier)
+ *
+ *
+ * Definition:
+ * Identifier assigned to the alert for external use (outside the FHIR environment)
+ *
+ */
+ public IdentifierDt addIdentifier() {
+ IdentifierDt newType = new IdentifierDt();
+ getIdentifier().add(newType);
+ return newType;
+ }
+
+ /**
+ * Gets the first repetition for identifier (Business identifier),
+ * creating it if it does not already exist.
+ *
+ *
+ * Definition:
+ * Identifier assigned to the alert for external use (outside the FHIR environment)
+ *
+ */
+ public IdentifierDt getIdentifierFirstRep() {
+ if (getIdentifier().isEmpty()) {
+ return addIdentifier();
+ }
+ return getIdentifier().get(0);
+ }
+ /**
+ * Adds a new value for identifier (Business identifier)
+ *
+ *
+ * Definition:
+ * Identifier assigned to the alert for external use (outside the FHIR environment)
+ *
+ *
+ * @return Returns a reference to this object, to allow for simple chaining.
+ */
+ public Alert addIdentifier( IdentifierUseEnum theUse, String theSystem, String theValue, String theLabel) {
+ if (myIdentifier == null) {
+ myIdentifier = new java.util.ArrayList();
+ }
+ myIdentifier.add(new IdentifierDt(theUse, theSystem, theValue, theLabel));
+ return this;
+ }
+
+ /**
+ * Adds a new value for identifier (Business identifier)
+ *
+ *
+ * Definition:
+ * Identifier assigned to the alert for external use (outside the FHIR environment)
+ *
+ *
+ * @return Returns a reference to this object, to allow for simple chaining.
+ */
+ public Alert addIdentifier( String theSystem, String theValue) {
+ if (myIdentifier == null) {
+ myIdentifier = new java.util.ArrayList();
+ }
+ myIdentifier.add(new IdentifierDt(theSystem, theValue));
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for category (Clinical, administrative, etc.).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * Allows an alert to be divided into different categories like clinical, administrative etc.
+ *
+ */
+ public CodeableConceptDt getCategory() {
+ if (myCategory == null) {
+ myCategory = new CodeableConceptDt();
+ }
+ return myCategory;
+ }
+
+ /**
+ * Sets the value(s) for category (Clinical, administrative, etc.)
+ *
+ *
+ * Definition:
+ * Allows an alert to be divided into different categories like clinical, administrative etc.
+ *
+ */
+ public Alert setCategory(CodeableConceptDt theValue) {
+ myCategory = theValue;
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for status (active | inactive | entered in error).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * Supports basic workflow
+ *
+ */
+ public BoundCodeDt getStatus() {
+ if (myStatus == null) {
+ myStatus = new BoundCodeDt(AlertStatusEnum.VALUESET_BINDER);
+ }
+ return myStatus;
+ }
+
+ /**
+ * Sets the value(s) for status (active | inactive | entered in error)
+ *
+ *
+ * Definition:
+ * Supports basic workflow
+ *
+ */
+ public Alert setStatus(BoundCodeDt theValue) {
+ myStatus = theValue;
+ return this;
+ }
+
+ /**
+ * Sets the value(s) for status (active | inactive | entered in error)
+ *
+ *
+ * Definition:
+ * Supports basic workflow
+ *
+ */
+ public Alert setStatus(AlertStatusEnum theValue) {
+ getStatus().setValueAsEnum(theValue);
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for subject (Who is alert about?).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * The person who this alert concerns
+ *
+ */
+ public ResourceReferenceDt getSubject() {
+ if (mySubject == null) {
+ mySubject = new ResourceReferenceDt();
+ }
+ return mySubject;
+ }
+
+ /**
+ * Sets the value(s) for subject (Who is alert about?)
+ *
+ *
+ * Definition:
+ * The person who this alert concerns
+ *
+ */
+ public Alert setSubject(ResourceReferenceDt theValue) {
+ mySubject = theValue;
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for author (Alert creator).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * The person or device that created the alert
+ *
+ */
+ public ResourceReferenceDt getAuthor() {
+ return myAuthor;
+ }
+
+ /**
+ * Sets the value(s) for author (Alert creator)
+ *
+ *
+ * Definition:
+ * The person or device that created the alert
+ *
+ */
+ public Alert setAuthor(ResourceReferenceDt theValue) {
+ myAuthor = theValue;
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for note (Text of alert).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * The textual component of the alert to display to the user
+ *
+ */
+ public StringDt getNote() {
+ if (myNote == null) {
+ myNote = new StringDt();
+ }
+ return myNote;
+ }
+
+ /**
+ * Sets the value(s) for note (Text of alert)
+ *
+ *
+ * Definition:
+ * The textual component of the alert to display to the user
+ *
+ */
+ public Alert setNote(StringDt theValue) {
+ myNote = theValue;
+ return this;
+ }
+
+ /**
+ * Sets the value for note (Text of alert)
+ *
+ *
+ * Definition:
+ * The textual component of the alert to display to the user
+ *
+ */
+ public Alert setNote( String theString) {
+ myNote = new StringDt(theString);
+ return this;
+ }
+
+
+
+
+}
\ No newline at end of file
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/OperationOutcome.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/OperationOutcome.java
new file mode 100644
index 00000000000..c34e12ce48a
--- /dev/null
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/OperationOutcome.java
@@ -0,0 +1,397 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+package ca.uhn.fhir.model.dstu.resource;
+
+
+import java.util.List;
+
+import ca.uhn.fhir.model.api.BaseElement;
+import ca.uhn.fhir.model.api.BaseResource;
+import ca.uhn.fhir.model.api.IElement;
+import ca.uhn.fhir.model.api.IResource;
+import ca.uhn.fhir.model.api.IResourceBlock;
+import ca.uhn.fhir.model.api.annotation.Block;
+import ca.uhn.fhir.model.api.annotation.Child;
+import ca.uhn.fhir.model.api.annotation.Description;
+import ca.uhn.fhir.model.api.annotation.ResourceDef;
+import ca.uhn.fhir.model.dstu.composite.CodingDt;
+import ca.uhn.fhir.model.dstu.valueset.IssueSeverityEnum;
+import ca.uhn.fhir.model.primitive.BoundCodeDt;
+import ca.uhn.fhir.model.primitive.CodeDt;
+import ca.uhn.fhir.model.primitive.StringDt;
+
+
+/**
+ * HAPI/FHIR OperationOutcome Resource
+ * (Information about the success/failure of an action)
+ *
+ *
+ * Definition:
+ * A collection of error, warning or information messages that result from a system action
+ *
+ *
+ *
+ * Requirements:
+ *
+ *
+ */
+@ResourceDef(name="OperationOutcome", profile="http://hl7.org/fhir/profiles/OperationOutcome", id="operationoutcome")
+public class OperationOutcome extends BaseResource implements IResource {
+
+
+ @Child(name="issue", order=0, min=1, max=Child.MAX_UNLIMITED)
+ @Description(
+ shortDefinition="A single issue associated with the action",
+ formalDefinition="An error, warning or information message that results from a system action"
+ )
+ private java.util.List myIssue;
+
+
+ @Override
+ public boolean isEmpty() {
+ return super.isBaseEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty( myIssue);
+ }
+
+ @Override
+ public java.util.List getAllPopulatedChildElements() {
+ return getAllPopulatedChildElementsOfType(null);
+ }
+
+ @Override
+ public List getAllPopulatedChildElementsOfType(Class theType) {
+ return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(theType, myIssue);
+ }
+
+ /**
+ * Gets the value(s) for issue (A single issue associated with the action).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * An error, warning or information message that results from a system action
+ *
+ */
+ public java.util.List getIssue() {
+ if (myIssue == null) {
+ myIssue = new java.util.ArrayList();
+ }
+ return myIssue;
+ }
+
+ /**
+ * Sets the value(s) for issue (A single issue associated with the action)
+ *
+ *
+ * Definition:
+ * An error, warning or information message that results from a system action
+ *
+ */
+ public OperationOutcome setIssue(java.util.List theValue) {
+ myIssue = theValue;
+ return this;
+ }
+
+ /**
+ * Adds and returns a new value for issue (A single issue associated with the action)
+ *
+ *
+ * Definition:
+ * An error, warning or information message that results from a system action
+ *
+ */
+ public Issue addIssue() {
+ Issue newType = new Issue();
+ getIssue().add(newType);
+ return newType;
+ }
+
+ /**
+ * Gets the first repetition for issue (A single issue associated with the action),
+ * creating it if it does not already exist.
+ *
+ *
+ * Definition:
+ * An error, warning or information message that results from a system action
+ *
+ */
+ public Issue getIssueFirstRep() {
+ if (getIssue().isEmpty()) {
+ return addIssue();
+ }
+ return getIssue().get(0);
+ }
+
+ /**
+ * Block class for child element: OperationOutcome.issue (A single issue associated with the action)
+ *
+ *
+ * Definition:
+ * An error, warning or information message that results from a system action
+ *
+ */
+ @Block(name="OperationOutcome.issue")
+ public static class Issue extends BaseElement implements IResourceBlock {
+
+ @Child(name="severity", type=CodeDt.class, order=0, min=1, max=1)
+ @Description(
+ shortDefinition="fatal | error | warning | information",
+ formalDefinition="Indicates whether the issue indicates a variation from successful processing"
+ )
+ private BoundCodeDt mySeverity;
+
+ @Child(name="type", type=CodingDt.class, order=1, min=0, max=1)
+ @Description(
+ shortDefinition="Error or warning code",
+ formalDefinition="A code indicating the type of error, warning or information message."
+ )
+ private CodingDt myType;
+
+ @Child(name="details", type=StringDt.class, order=2, min=0, max=1)
+ @Description(
+ shortDefinition="Additional description of the issue",
+ formalDefinition="Additional description of the issue"
+ )
+ private StringDt myDetails;
+
+ @Child(name="location", type=StringDt.class, order=3, min=0, max=Child.MAX_UNLIMITED)
+ @Description(
+ shortDefinition="XPath of element(s) related to issue",
+ formalDefinition="A simple XPath limited to element names, repetition indicators and the default child access that identifies one of the elements in the resource that caused this issue to be raised."
+ )
+ private java.util.List myLocation;
+
+
+ @Override
+ public boolean isEmpty() {
+ return super.isBaseEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty( mySeverity, myType, myDetails, myLocation);
+ }
+
+ @Override
+ public java.util.List getAllPopulatedChildElements() {
+ return getAllPopulatedChildElementsOfType(null);
+ }
+
+ @Override
+ public List getAllPopulatedChildElementsOfType(Class theType) {
+ return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(theType, mySeverity, myType, myDetails, myLocation);
+ }
+
+ /**
+ * Gets the value(s) for severity (fatal | error | warning | information).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * Indicates whether the issue indicates a variation from successful processing
+ *
+ */
+ public BoundCodeDt getSeverity() {
+ if (mySeverity == null) {
+ mySeverity = new BoundCodeDt(IssueSeverityEnum.VALUESET_BINDER);
+ }
+ return mySeverity;
+ }
+
+ /**
+ * Sets the value(s) for severity (fatal | error | warning | information)
+ *
+ *
+ * Definition:
+ * Indicates whether the issue indicates a variation from successful processing
+ *
+ */
+ public Issue setSeverity(BoundCodeDt theValue) {
+ mySeverity = theValue;
+ return this;
+ }
+
+ /**
+ * Sets the value(s) for severity (fatal | error | warning | information)
+ *
+ *
+ * Definition:
+ * Indicates whether the issue indicates a variation from successful processing
+ *
+ */
+ public Issue setSeverity(IssueSeverityEnum theValue) {
+ getSeverity().setValueAsEnum(theValue);
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for type (Error or warning code).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * A code indicating the type of error, warning or information message.
+ *
+ */
+ public CodingDt getType() {
+ if (myType == null) {
+ myType = new CodingDt();
+ }
+ return myType;
+ }
+
+ /**
+ * Sets the value(s) for type (Error or warning code)
+ *
+ *
+ * Definition:
+ * A code indicating the type of error, warning or information message.
+ *
+ */
+ public Issue setType(CodingDt theValue) {
+ myType = theValue;
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for details (Additional description of the issue).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * Additional description of the issue
+ *
+ */
+ public StringDt getDetails() {
+ if (myDetails == null) {
+ myDetails = new StringDt();
+ }
+ return myDetails;
+ }
+
+ /**
+ * Sets the value(s) for details (Additional description of the issue)
+ *
+ *
+ * Definition:
+ * Additional description of the issue
+ *
+ */
+ public Issue setDetails(StringDt theValue) {
+ myDetails = theValue;
+ return this;
+ }
+
+ /**
+ * Sets the value for details (Additional description of the issue)
+ *
+ *
+ * Definition:
+ * Additional description of the issue
+ *
+ */
+ public Issue setDetails( String theString) {
+ myDetails = new StringDt(theString);
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for location (XPath of element(s) related to issue).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * A simple XPath limited to element names, repetition indicators and the default child access that identifies one of the elements in the resource that caused this issue to be raised.
+ *
+ */
+ public java.util.List getLocation() {
+ if (myLocation == null) {
+ myLocation = new java.util.ArrayList();
+ }
+ return myLocation;
+ }
+
+ /**
+ * Sets the value(s) for location (XPath of element(s) related to issue)
+ *
+ *
+ * Definition:
+ * A simple XPath limited to element names, repetition indicators and the default child access that identifies one of the elements in the resource that caused this issue to be raised.
+ *
+ */
+ public Issue setLocation(java.util.List theValue) {
+ myLocation = theValue;
+ return this;
+ }
+
+ /**
+ * Adds and returns a new value for location (XPath of element(s) related to issue)
+ *
+ *
+ * Definition:
+ * A simple XPath limited to element names, repetition indicators and the default child access that identifies one of the elements in the resource that caused this issue to be raised.
+ *
+ */
+ public StringDt addLocation() {
+ StringDt newType = new StringDt();
+ getLocation().add(newType);
+ return newType;
+ }
+
+ /**
+ * Gets the first repetition for location (XPath of element(s) related to issue),
+ * creating it if it does not already exist.
+ *
+ *
+ * Definition:
+ * A simple XPath limited to element names, repetition indicators and the default child access that identifies one of the elements in the resource that caused this issue to be raised.
+ *
+ */
+ public StringDt getLocationFirstRep() {
+ if (getLocation().isEmpty()) {
+ return addLocation();
+ }
+ return getLocation().get(0);
+ }
+ /**
+ * Adds a new value for location (XPath of element(s) related to issue)
+ *
+ *
+ * Definition:
+ * A simple XPath limited to element names, repetition indicators and the default child access that identifies one of the elements in the resource that caused this issue to be raised.
+ *
+ *
+ * @return Returns a reference to this object, to allow for simple chaining.
+ */
+ public Issue addLocation( String theString) {
+ if (myLocation == null) {
+ myLocation = new java.util.ArrayList();
+ }
+ myLocation.add(new StringDt(theString));
+ return this;
+ }
+
+
+
+ }
+
+
+
+
+}
\ No newline at end of file
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 d8660382a8f..057f9fd05da 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
@@ -43,7 +43,12 @@ import ca.uhn.fhir.model.dstu.valueset.AnimalSpeciesEnum;
import ca.uhn.fhir.model.dstu.valueset.IdentifierUseEnum;
import ca.uhn.fhir.model.dstu.valueset.LinkTypeEnum;
import ca.uhn.fhir.model.dstu.valueset.MaritalStatusCodesEnum;
-import ca.uhn.fhir.model.primitive.*;
+import ca.uhn.fhir.model.primitive.BooleanDt;
+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.DateTimeDt;
+import ca.uhn.fhir.model.primitive.IntegerDt;
/**
@@ -343,6 +348,7 @@ public class Patient extends BaseResource implements IResource {
formalDefinition="Whether this patient record is in active use"
)
private BooleanDt myActive;
+
@Override
public boolean isEmpty() {
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Query.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Query.java
new file mode 100644
index 00000000000..e5f3885fc3d
--- /dev/null
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Query.java
@@ -0,0 +1,824 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+package ca.uhn.fhir.model.dstu.resource;
+
+
+import java.util.List;
+
+import ca.uhn.fhir.model.api.BaseElement;
+import ca.uhn.fhir.model.api.BaseResource;
+import ca.uhn.fhir.model.api.ExtensionDt;
+import ca.uhn.fhir.model.api.IElement;
+import ca.uhn.fhir.model.api.IResource;
+import ca.uhn.fhir.model.api.IResourceBlock;
+import ca.uhn.fhir.model.api.annotation.Block;
+import ca.uhn.fhir.model.api.annotation.Child;
+import ca.uhn.fhir.model.api.annotation.Description;
+import ca.uhn.fhir.model.api.annotation.ResourceDef;
+import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
+import ca.uhn.fhir.model.dstu.valueset.QueryOutcomeEnum;
+import ca.uhn.fhir.model.primitive.BoundCodeDt;
+import ca.uhn.fhir.model.primitive.CodeDt;
+import ca.uhn.fhir.model.primitive.IntegerDt;
+import ca.uhn.fhir.model.primitive.UriDt;
+
+
+/**
+ * HAPI/FHIR Query Resource
+ * (A description of a query with a set of parameters)
+ *
+ *
+ * Definition:
+ *
+ *
+ *
+ *
+ * Requirements:
+ *
+ *
+ */
+@ResourceDef(name="Query", profile="http://hl7.org/fhir/profiles/Query", id="query")
+public class Query extends BaseResource implements IResource {
+
+ /**
+ * Search parameter constant for identifier
+ *
+ * Description:
+ * Type: token
+ * Path: Query.identifier
+ *
+ */
+ public static final String SP_IDENTIFIER = "identifier";
+
+ /**
+ * Search parameter constant for response
+ *
+ * Description:
+ * Type: token
+ * Path: Query.response.identifier
+ *
+ */
+ public static final String SP_RESPONSE = "response";
+
+
+ @Child(name="identifier", type=UriDt.class, order=0, min=1, max=1)
+ @Description(
+ shortDefinition="Links query and its response(s)",
+ formalDefinition=""
+ )
+ private UriDt myIdentifier;
+
+ @Child(name="parameter", type=ExtensionDt.class, order=1, min=1, max=Child.MAX_UNLIMITED)
+ @Description(
+ shortDefinition="Set of query parameters with values",
+ formalDefinition=""
+ )
+ private java.util.List myParameter;
+
+ @Child(name="response", order=2, min=0, max=1)
+ @Description(
+ shortDefinition="If this is a response to a query",
+ formalDefinition=""
+ )
+ private Response myResponse;
+
+
+ @Override
+ public boolean isEmpty() {
+ return super.isBaseEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty( myIdentifier, myParameter, myResponse);
+ }
+
+ @Override
+ public java.util.List getAllPopulatedChildElements() {
+ return getAllPopulatedChildElementsOfType(null);
+ }
+
+ @Override
+ public List getAllPopulatedChildElementsOfType(Class theType) {
+ return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(theType, myIdentifier, myParameter, myResponse);
+ }
+
+ /**
+ * Gets the value(s) for identifier (Links query and its response(s)).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public UriDt getIdentifier() {
+ if (myIdentifier == null) {
+ myIdentifier = new UriDt();
+ }
+ return myIdentifier;
+ }
+
+ /**
+ * Sets the value(s) for identifier (Links query and its response(s))
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public Query setIdentifier(UriDt theValue) {
+ myIdentifier = theValue;
+ return this;
+ }
+
+ /**
+ * Sets the value for identifier (Links query and its response(s))
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public Query setIdentifier( String theUri) {
+ myIdentifier = new UriDt(theUri);
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for parameter (Set of query parameters with values).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public java.util.List getParameter() {
+ if (myParameter == null) {
+ myParameter = new java.util.ArrayList();
+ }
+ return myParameter;
+ }
+
+ /**
+ * Sets the value(s) for parameter (Set of query parameters with values)
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public Query setParameter(java.util.List theValue) {
+ myParameter = theValue;
+ return this;
+ }
+
+ /**
+ * Adds and returns a new value for parameter (Set of query parameters with values)
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public ExtensionDt addParameter() {
+ ExtensionDt newType = new ExtensionDt();
+ getParameter().add(newType);
+ return newType;
+ }
+
+ /**
+ * Gets the first repetition for parameter (Set of query parameters with values),
+ * creating it if it does not already exist.
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public ExtensionDt getParameterFirstRep() {
+ if (getParameter().isEmpty()) {
+ return addParameter();
+ }
+ return getParameter().get(0);
+ }
+
+ /**
+ * Gets the value(s) for response (If this is a response to a query).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public Response getResponse() {
+ if (myResponse == null) {
+ myResponse = new Response();
+ }
+ return myResponse;
+ }
+
+ /**
+ * Sets the value(s) for response (If this is a response to a query)
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public Query setResponse(Response theValue) {
+ myResponse = theValue;
+ return this;
+ }
+
+
+ /**
+ * Block class for child element: Query.response (If this is a response to a query)
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ @Block(name="Query.response")
+ public static class Response extends BaseElement implements IResourceBlock {
+
+ @Child(name="identifier", type=UriDt.class, order=0, min=1, max=1)
+ @Description(
+ shortDefinition="Links response to source query",
+ formalDefinition=""
+ )
+ private UriDt myIdentifier;
+
+ @Child(name="outcome", type=CodeDt.class, order=1, min=1, max=1)
+ @Description(
+ shortDefinition="ok | limited | refused | error",
+ formalDefinition="Outcome of processing the query"
+ )
+ private BoundCodeDt myOutcome;
+
+ @Child(name="total", type=IntegerDt.class, order=2, min=0, max=1)
+ @Description(
+ shortDefinition="Total number of matching records",
+ formalDefinition=""
+ )
+ private IntegerDt myTotal;
+
+ @Child(name="parameter", type=ExtensionDt.class, order=3, min=0, max=Child.MAX_UNLIMITED)
+ @Description(
+ shortDefinition="Parameters server used",
+ formalDefinition=""
+ )
+ private java.util.List myParameter;
+
+ @Child(name="first", type=ExtensionDt.class, order=4, min=0, max=Child.MAX_UNLIMITED)
+ @Description(
+ shortDefinition="To get first page (if paged)",
+ formalDefinition=""
+ )
+ private java.util.List myFirst;
+
+ @Child(name="previous", type=ExtensionDt.class, order=5, min=0, max=Child.MAX_UNLIMITED)
+ @Description(
+ shortDefinition="To get previous page (if paged)",
+ formalDefinition=""
+ )
+ private java.util.List myPrevious;
+
+ @Child(name="next", type=ExtensionDt.class, order=6, min=0, max=Child.MAX_UNLIMITED)
+ @Description(
+ shortDefinition="To get next page (if paged)",
+ formalDefinition=""
+ )
+ private java.util.List myNext;
+
+ @Child(name="last", type=ExtensionDt.class, order=7, min=0, max=Child.MAX_UNLIMITED)
+ @Description(
+ shortDefinition="To get last page (if paged)",
+ formalDefinition=""
+ )
+ private java.util.List myLast;
+
+ @Child(name="reference", order=8, min=0, max=Child.MAX_UNLIMITED, type={
+ IResource.class,
+ })
+ @Description(
+ shortDefinition="Resources that are the results of the search",
+ formalDefinition=""
+ )
+ private java.util.List myReference;
+
+
+ @Override
+ public boolean isEmpty() {
+ return super.isBaseEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty( myIdentifier, myOutcome, myTotal, myParameter, myFirst, myPrevious, myNext, myLast, myReference);
+ }
+
+ @Override
+ public java.util.List getAllPopulatedChildElements() {
+ return getAllPopulatedChildElementsOfType(null);
+ }
+
+ @Override
+ public List getAllPopulatedChildElementsOfType(Class theType) {
+ return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(theType, myIdentifier, myOutcome, myTotal, myParameter, myFirst, myPrevious, myNext, myLast, myReference);
+ }
+
+ /**
+ * Gets the value(s) for identifier (Links response to source query).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public UriDt getIdentifier() {
+ if (myIdentifier == null) {
+ myIdentifier = new UriDt();
+ }
+ return myIdentifier;
+ }
+
+ /**
+ * Sets the value(s) for identifier (Links response to source query)
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public Response setIdentifier(UriDt theValue) {
+ myIdentifier = theValue;
+ return this;
+ }
+
+ /**
+ * Sets the value for identifier (Links response to source query)
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public Response setIdentifier( String theUri) {
+ myIdentifier = new UriDt(theUri);
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for outcome (ok | limited | refused | error).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * Outcome of processing the query
+ *
+ */
+ public BoundCodeDt getOutcome() {
+ if (myOutcome == null) {
+ myOutcome = new BoundCodeDt(QueryOutcomeEnum.VALUESET_BINDER);
+ }
+ return myOutcome;
+ }
+
+ /**
+ * Sets the value(s) for outcome (ok | limited | refused | error)
+ *
+ *
+ * Definition:
+ * Outcome of processing the query
+ *
+ */
+ public Response setOutcome(BoundCodeDt theValue) {
+ myOutcome = theValue;
+ return this;
+ }
+
+ /**
+ * Sets the value(s) for outcome (ok | limited | refused | error)
+ *
+ *
+ * Definition:
+ * Outcome of processing the query
+ *
+ */
+ public Response setOutcome(QueryOutcomeEnum theValue) {
+ getOutcome().setValueAsEnum(theValue);
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for total (Total number of matching records).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public IntegerDt getTotal() {
+ if (myTotal == null) {
+ myTotal = new IntegerDt();
+ }
+ return myTotal;
+ }
+
+ /**
+ * Sets the value(s) for total (Total number of matching records)
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public Response setTotal(IntegerDt theValue) {
+ myTotal = theValue;
+ return this;
+ }
+
+ /**
+ * Sets the value for total (Total number of matching records)
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public Response setTotal( int theInteger) {
+ myTotal = new IntegerDt(theInteger);
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for parameter (Parameters server used).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public java.util.List getParameter() {
+ if (myParameter == null) {
+ myParameter = new java.util.ArrayList();
+ }
+ return myParameter;
+ }
+
+ /**
+ * Sets the value(s) for parameter (Parameters server used)
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public Response setParameter(java.util.List theValue) {
+ myParameter = theValue;
+ return this;
+ }
+
+ /**
+ * Adds and returns a new value for parameter (Parameters server used)
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public ExtensionDt addParameter() {
+ ExtensionDt newType = new ExtensionDt();
+ getParameter().add(newType);
+ return newType;
+ }
+
+ /**
+ * Gets the first repetition for parameter (Parameters server used),
+ * creating it if it does not already exist.
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public ExtensionDt getParameterFirstRep() {
+ if (getParameter().isEmpty()) {
+ return addParameter();
+ }
+ return getParameter().get(0);
+ }
+
+ /**
+ * Gets the value(s) for first (To get first page (if paged)).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public java.util.List getFirst() {
+ if (myFirst == null) {
+ myFirst = new java.util.ArrayList();
+ }
+ return myFirst;
+ }
+
+ /**
+ * Sets the value(s) for first (To get first page (if paged))
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public Response setFirst(java.util.List theValue) {
+ myFirst = theValue;
+ return this;
+ }
+
+ /**
+ * Adds and returns a new value for first (To get first page (if paged))
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public ExtensionDt addFirst() {
+ ExtensionDt newType = new ExtensionDt();
+ getFirst().add(newType);
+ return newType;
+ }
+
+ /**
+ * Gets the first repetition for first (To get first page (if paged)),
+ * creating it if it does not already exist.
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public ExtensionDt getFirstFirstRep() {
+ if (getFirst().isEmpty()) {
+ return addFirst();
+ }
+ return getFirst().get(0);
+ }
+
+ /**
+ * Gets the value(s) for previous (To get previous page (if paged)).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public java.util.List getPrevious() {
+ if (myPrevious == null) {
+ myPrevious = new java.util.ArrayList();
+ }
+ return myPrevious;
+ }
+
+ /**
+ * Sets the value(s) for previous (To get previous page (if paged))
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public Response setPrevious(java.util.List theValue) {
+ myPrevious = theValue;
+ return this;
+ }
+
+ /**
+ * Adds and returns a new value for previous (To get previous page (if paged))
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public ExtensionDt addPrevious() {
+ ExtensionDt newType = new ExtensionDt();
+ getPrevious().add(newType);
+ return newType;
+ }
+
+ /**
+ * Gets the first repetition for previous (To get previous page (if paged)),
+ * creating it if it does not already exist.
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public ExtensionDt getPreviousFirstRep() {
+ if (getPrevious().isEmpty()) {
+ return addPrevious();
+ }
+ return getPrevious().get(0);
+ }
+
+ /**
+ * Gets the value(s) for next (To get next page (if paged)).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public java.util.List getNext() {
+ if (myNext == null) {
+ myNext = new java.util.ArrayList();
+ }
+ return myNext;
+ }
+
+ /**
+ * Sets the value(s) for next (To get next page (if paged))
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public Response setNext(java.util.List theValue) {
+ myNext = theValue;
+ return this;
+ }
+
+ /**
+ * Adds and returns a new value for next (To get next page (if paged))
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public ExtensionDt addNext() {
+ ExtensionDt newType = new ExtensionDt();
+ getNext().add(newType);
+ return newType;
+ }
+
+ /**
+ * Gets the first repetition for next (To get next page (if paged)),
+ * creating it if it does not already exist.
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public ExtensionDt getNextFirstRep() {
+ if (getNext().isEmpty()) {
+ return addNext();
+ }
+ return getNext().get(0);
+ }
+
+ /**
+ * Gets the value(s) for last (To get last page (if paged)).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public java.util.List getLast() {
+ if (myLast == null) {
+ myLast = new java.util.ArrayList();
+ }
+ return myLast;
+ }
+
+ /**
+ * Sets the value(s) for last (To get last page (if paged))
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public Response setLast(java.util.List theValue) {
+ myLast = theValue;
+ return this;
+ }
+
+ /**
+ * Adds and returns a new value for last (To get last page (if paged))
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public ExtensionDt addLast() {
+ ExtensionDt newType = new ExtensionDt();
+ getLast().add(newType);
+ return newType;
+ }
+
+ /**
+ * Gets the first repetition for last (To get last page (if paged)),
+ * creating it if it does not already exist.
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public ExtensionDt getLastFirstRep() {
+ if (getLast().isEmpty()) {
+ return addLast();
+ }
+ return getLast().get(0);
+ }
+
+ /**
+ * Gets the value(s) for reference (Resources that are the results of the search).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public java.util.List getReference() {
+ if (myReference == null) {
+ myReference = new java.util.ArrayList();
+ }
+ return myReference;
+ }
+
+ /**
+ * Sets the value(s) for reference (Resources that are the results of the search)
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public Response setReference(java.util.List theValue) {
+ myReference = theValue;
+ return this;
+ }
+
+ /**
+ * Adds and returns a new value for reference (Resources that are the results of the search)
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public ResourceReferenceDt addReference() {
+ ResourceReferenceDt newType = new ResourceReferenceDt();
+ getReference().add(newType);
+ return newType;
+ }
+
+
+ }
+
+
+
+
+}
\ No newline at end of file
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Questionnaire.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Questionnaire.java
new file mode 100644
index 00000000000..5aeb8a832e6
--- /dev/null
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/resource/Questionnaire.java
@@ -0,0 +1,1404 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+package ca.uhn.fhir.model.dstu.resource;
+
+
+import java.util.Date;
+import java.util.List;
+
+import ca.uhn.fhir.model.api.BaseElement;
+import ca.uhn.fhir.model.api.BaseResource;
+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.IResourceBlock;
+import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
+import ca.uhn.fhir.model.api.annotation.Block;
+import ca.uhn.fhir.model.api.annotation.Child;
+import ca.uhn.fhir.model.api.annotation.Description;
+import ca.uhn.fhir.model.api.annotation.ResourceDef;
+import ca.uhn.fhir.model.dstu.composite.CodeableConceptDt;
+import ca.uhn.fhir.model.dstu.composite.CodingDt;
+import ca.uhn.fhir.model.dstu.composite.IdentifierDt;
+import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
+import ca.uhn.fhir.model.dstu.valueset.IdentifierUseEnum;
+import ca.uhn.fhir.model.dstu.valueset.QuestionnaireGroupNameEnum;
+import ca.uhn.fhir.model.dstu.valueset.QuestionnaireNameEnum;
+import ca.uhn.fhir.model.dstu.valueset.QuestionnaireStatusEnum;
+import ca.uhn.fhir.model.primitive.BooleanDt;
+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.DateTimeDt;
+import ca.uhn.fhir.model.primitive.DecimalDt;
+import ca.uhn.fhir.model.primitive.InstantDt;
+import ca.uhn.fhir.model.primitive.IntegerDt;
+import ca.uhn.fhir.model.primitive.StringDt;
+
+
+/**
+ * HAPI/FHIR Questionnaire Resource
+ * (A structured set of questions and their answers)
+ *
+ *
+ * Definition:
+ * A structured set of questions and their answers. The Questionnaire may contain questions, answers or both. The questions are ordered and grouped into coherent subsets, corresponding to the structure of the grouping of the underlying questions
+ *
+ *
+ *
+ * Requirements:
+ * To support structured, hierarchical registration of data gathered using digital forms and other questionnaires.
+ *
+ */
+@ResourceDef(name="Questionnaire", profile="http://hl7.org/fhir/profiles/Questionnaire", id="questionnaire")
+public class Questionnaire extends BaseResource implements IResource {
+
+ /**
+ * Search parameter constant for status
+ *
+ * Description: The status of the questionnaire
+ * Type: token
+ * Path: Questionnaire.status
+ *
+ */
+ public static final String SP_STATUS = "status";
+
+ /**
+ * Search parameter constant for authored
+ *
+ * Description: When the questionnaire was authored
+ * Type: date
+ * Path: Questionnaire.authored
+ *
+ */
+ public static final String SP_AUTHORED = "authored";
+
+ /**
+ * Search parameter constant for subject
+ *
+ * Description: The subject of the questionnaire
+ * Type: reference
+ * Path: Questionnaire.subject
+ *
+ */
+ public static final String SP_SUBJECT = "subject";
+
+ /**
+ * Search parameter constant for author
+ *
+ * Description: The author of the questionnaire
+ * Type: reference
+ * Path: Questionnaire.author
+ *
+ */
+ public static final String SP_AUTHOR = "author";
+
+ /**
+ * Search parameter constant for identifier
+ *
+ * Description: An identifier for the questionnaire
+ * Type: token
+ * Path: Questionnaire.identifier
+ *
+ */
+ public static final String SP_IDENTIFIER = "identifier";
+
+ /**
+ * Search parameter constant for name
+ *
+ * Description: Name of the questionnaire
+ * Type: token
+ * Path: Questionnaire.name
+ *
+ */
+ public static final String SP_NAME = "name";
+
+ /**
+ * Search parameter constant for encounter
+ *
+ * Description: Encounter during which questionnaire was authored
+ * Type: reference
+ * Path: Questionnaire.encounter
+ *
+ */
+ public static final String SP_ENCOUNTER = "encounter";
+
+
+ @Child(name="status", type=CodeDt.class, order=0, min=1, max=1)
+ @Description(
+ shortDefinition="draft | published | retired | in progress | completed | amended",
+ formalDefinition="The lifecycle status of the questionnaire as a whole."
+ )
+ private BoundCodeDt myStatus;
+
+ @Child(name="authored", type=DateTimeDt.class, order=1, min=1, max=1)
+ @Description(
+ shortDefinition="Date this version was authored",
+ formalDefinition="The date and/or time that this version of the questionnaire was authored"
+ )
+ private DateTimeDt myAuthored;
+
+ @Child(name="subject", order=2, min=0, max=1, type={
+ ca.uhn.fhir.model.dstu.resource.Patient.class,
+ ca.uhn.fhir.model.dstu.resource.RelatedPerson.class,
+ })
+ @Description(
+ shortDefinition="The subject of the questions",
+ formalDefinition="The subject of the questionnaires: this is the patient that the answers apply to, but this person is not necessarily the source of information"
+ )
+ private ResourceReferenceDt mySubject;
+
+ @Child(name="author", order=3, min=0, max=1, type={
+ ca.uhn.fhir.model.dstu.resource.Practitioner.class,
+ ca.uhn.fhir.model.dstu.resource.Patient.class,
+ ca.uhn.fhir.model.dstu.resource.RelatedPerson.class,
+ })
+ @Description(
+ shortDefinition="Person who received and recorded the answers",
+ formalDefinition="Person who received the answers to the questions in the Questionnaire and recorded them in the system"
+ )
+ private ResourceReferenceDt myAuthor;
+
+ @Child(name="source", order=4, min=0, max=1, type={
+ ca.uhn.fhir.model.dstu.resource.Patient.class,
+ ca.uhn.fhir.model.dstu.resource.Practitioner.class,
+ ca.uhn.fhir.model.dstu.resource.RelatedPerson.class,
+ })
+ @Description(
+ shortDefinition="The person who answered the questions",
+ formalDefinition="The person who answered the questions about the subject. Only used when this is not the subject him/herself"
+ )
+ private ResourceReferenceDt mySource;
+
+ @Child(name="name", type=CodeableConceptDt.class, order=5, min=0, max=1)
+ @Description(
+ shortDefinition="Name/code for a predefined list of questions",
+ formalDefinition="Structured name for a predefined list of questions this questionnaire is responding to"
+ )
+ private BoundCodeableConceptDt myName;
+
+ @Child(name="identifier", type=IdentifierDt.class, order=6, min=0, max=Child.MAX_UNLIMITED)
+ @Description(
+ shortDefinition="External Ids for this questionnaire",
+ formalDefinition="This records identifiers associated with this question/answer set that are defined by business processed and/ or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation)"
+ )
+ private java.util.List myIdentifier;
+
+ @Child(name="encounter", order=7, min=0, max=1, type={
+ ca.uhn.fhir.model.dstu.resource.Encounter.class,
+ })
+ @Description(
+ shortDefinition="Primary encounter during which the answers were collected",
+ formalDefinition="Encounter during which this questionnaire answers were collected. When there were multiple encounters, this is the one considered most relevant to the context of the answers."
+ )
+ private ResourceReferenceDt myEncounter;
+
+ @Child(name="group", order=8, min=0, max=1)
+ @Description(
+ shortDefinition="Grouped questions",
+ formalDefinition="A group of questions to a possibly similarly grouped set of questions in the questionnaire"
+ )
+ private Group myGroup;
+
+
+ @Override
+ public boolean isEmpty() {
+ return super.isBaseEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty( myStatus, myAuthored, mySubject, myAuthor, mySource, myName, myIdentifier, myEncounter, myGroup);
+ }
+
+ @Override
+ public java.util.List getAllPopulatedChildElements() {
+ return getAllPopulatedChildElementsOfType(null);
+ }
+
+ @Override
+ public List getAllPopulatedChildElementsOfType(Class theType) {
+ return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(theType, myStatus, myAuthored, mySubject, myAuthor, mySource, myName, myIdentifier, myEncounter, myGroup);
+ }
+
+ /**
+ * Gets the value(s) for status (draft | published | retired | in progress | completed | amended).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * The lifecycle status of the questionnaire as a whole.
+ *
+ */
+ public BoundCodeDt getStatus() {
+ if (myStatus == null) {
+ myStatus = new BoundCodeDt(QuestionnaireStatusEnum.VALUESET_BINDER);
+ }
+ return myStatus;
+ }
+
+ /**
+ * Sets the value(s) for status (draft | published | retired | in progress | completed | amended)
+ *
+ *
+ * Definition:
+ * The lifecycle status of the questionnaire as a whole.
+ *
+ */
+ public Questionnaire setStatus(BoundCodeDt theValue) {
+ myStatus = theValue;
+ return this;
+ }
+
+ /**
+ * Sets the value(s) for status (draft | published | retired | in progress | completed | amended)
+ *
+ *
+ * Definition:
+ * The lifecycle status of the questionnaire as a whole.
+ *
+ */
+ public Questionnaire setStatus(QuestionnaireStatusEnum theValue) {
+ getStatus().setValueAsEnum(theValue);
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for authored (Date this version was authored).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * The date and/or time that this version of the questionnaire was authored
+ *
+ */
+ public DateTimeDt getAuthored() {
+ if (myAuthored == null) {
+ myAuthored = new DateTimeDt();
+ }
+ return myAuthored;
+ }
+
+ /**
+ * Sets the value(s) for authored (Date this version was authored)
+ *
+ *
+ * Definition:
+ * The date and/or time that this version of the questionnaire was authored
+ *
+ */
+ public Questionnaire setAuthored(DateTimeDt theValue) {
+ myAuthored = theValue;
+ return this;
+ }
+
+ /**
+ * Sets the value for authored (Date this version was authored)
+ *
+ *
+ * Definition:
+ * The date and/or time that this version of the questionnaire was authored
+ *
+ */
+ public Questionnaire setAuthored( Date theDate, TemporalPrecisionEnum thePrecision) {
+ myAuthored = new DateTimeDt(theDate, thePrecision);
+ return this;
+ }
+
+ /**
+ * Sets the value for authored (Date this version was authored)
+ *
+ *
+ * Definition:
+ * The date and/or time that this version of the questionnaire was authored
+ *
+ */
+ public Questionnaire setAuthoredWithSecondsPrecision( Date theDate) {
+ myAuthored = new DateTimeDt(theDate);
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for subject (The subject of the questions).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * The subject of the questionnaires: this is the patient that the answers apply to, but this person is not necessarily the source of information
+ *
+ */
+ public ResourceReferenceDt getSubject() {
+ return mySubject;
+ }
+
+ /**
+ * Sets the value(s) for subject (The subject of the questions)
+ *
+ *
+ * Definition:
+ * The subject of the questionnaires: this is the patient that the answers apply to, but this person is not necessarily the source of information
+ *
+ */
+ public Questionnaire setSubject(ResourceReferenceDt theValue) {
+ mySubject = theValue;
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for author (Person who received and recorded the answers).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * Person who received the answers to the questions in the Questionnaire and recorded them in the system
+ *
+ */
+ public ResourceReferenceDt getAuthor() {
+ return myAuthor;
+ }
+
+ /**
+ * Sets the value(s) for author (Person who received and recorded the answers)
+ *
+ *
+ * Definition:
+ * Person who received the answers to the questions in the Questionnaire and recorded them in the system
+ *
+ */
+ public Questionnaire setAuthor(ResourceReferenceDt theValue) {
+ myAuthor = theValue;
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for source (The person who answered the questions).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * The person who answered the questions about the subject. Only used when this is not the subject him/herself
+ *
+ */
+ public ResourceReferenceDt getSource() {
+ return mySource;
+ }
+
+ /**
+ * Sets the value(s) for source (The person who answered the questions)
+ *
+ *
+ * Definition:
+ * The person who answered the questions about the subject. Only used when this is not the subject him/herself
+ *
+ */
+ public Questionnaire setSource(ResourceReferenceDt theValue) {
+ mySource = theValue;
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for name (Name/code for a predefined list of questions).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * Structured name for a predefined list of questions this questionnaire is responding to
+ *
+ */
+ public BoundCodeableConceptDt getName() {
+ if (myName == null) {
+ myName = new BoundCodeableConceptDt(QuestionnaireNameEnum.VALUESET_BINDER);
+ }
+ return myName;
+ }
+
+ /**
+ * Sets the value(s) for name (Name/code for a predefined list of questions)
+ *
+ *
+ * Definition:
+ * Structured name for a predefined list of questions this questionnaire is responding to
+ *
+ */
+ public Questionnaire setName(BoundCodeableConceptDt theValue) {
+ myName = theValue;
+ return this;
+ }
+
+ /**
+ * Sets the value(s) for name (Name/code for a predefined list of questions)
+ *
+ *
+ * Definition:
+ * Structured name for a predefined list of questions this questionnaire is responding to
+ *
+ */
+ public Questionnaire setName(QuestionnaireNameEnum theValue) {
+ getName().setValueAsEnum(theValue);
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for identifier (External Ids for this questionnaire).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * This records identifiers associated with this question/answer set that are defined by business processed and/ or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation)
+ *
+ */
+ public java.util.List getIdentifier() {
+ if (myIdentifier == null) {
+ myIdentifier = new java.util.ArrayList();
+ }
+ return myIdentifier;
+ }
+
+ /**
+ * Sets the value(s) for identifier (External Ids for this questionnaire)
+ *
+ *
+ * Definition:
+ * This records identifiers associated with this question/answer set that are defined by business processed and/ or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation)
+ *
+ */
+ public Questionnaire setIdentifier(java.util.List theValue) {
+ myIdentifier = theValue;
+ return this;
+ }
+
+ /**
+ * Adds and returns a new value for identifier (External Ids for this questionnaire)
+ *
+ *
+ * Definition:
+ * This records identifiers associated with this question/answer set that are defined by business processed and/ or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation)
+ *
+ */
+ public IdentifierDt addIdentifier() {
+ IdentifierDt newType = new IdentifierDt();
+ getIdentifier().add(newType);
+ return newType;
+ }
+
+ /**
+ * Gets the first repetition for identifier (External Ids for this questionnaire),
+ * creating it if it does not already exist.
+ *
+ *
+ * Definition:
+ * This records identifiers associated with this question/answer set that are defined by business processed and/ or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation)
+ *
+ */
+ public IdentifierDt getIdentifierFirstRep() {
+ if (getIdentifier().isEmpty()) {
+ return addIdentifier();
+ }
+ return getIdentifier().get(0);
+ }
+ /**
+ * Adds a new value for identifier (External Ids for this questionnaire)
+ *
+ *
+ * Definition:
+ * This records identifiers associated with this question/answer set that are defined by business processed and/ or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation)
+ *
+ *
+ * @return Returns a reference to this object, to allow for simple chaining.
+ */
+ public Questionnaire addIdentifier( IdentifierUseEnum theUse, String theSystem, String theValue, String theLabel) {
+ if (myIdentifier == null) {
+ myIdentifier = new java.util.ArrayList();
+ }
+ myIdentifier.add(new IdentifierDt(theUse, theSystem, theValue, theLabel));
+ return this;
+ }
+
+ /**
+ * Adds a new value for identifier (External Ids for this questionnaire)
+ *
+ *
+ * Definition:
+ * This records identifiers associated with this question/answer set that are defined by business processed and/ or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation)
+ *
+ *
+ * @return Returns a reference to this object, to allow for simple chaining.
+ */
+ public Questionnaire addIdentifier( String theSystem, String theValue) {
+ if (myIdentifier == null) {
+ myIdentifier = new java.util.ArrayList();
+ }
+ myIdentifier.add(new IdentifierDt(theSystem, theValue));
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for encounter (Primary encounter during which the answers were collected).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * Encounter during which this questionnaire answers were collected. When there were multiple encounters, this is the one considered most relevant to the context of the answers.
+ *
+ */
+ public ResourceReferenceDt getEncounter() {
+ if (myEncounter == null) {
+ myEncounter = new ResourceReferenceDt();
+ }
+ return myEncounter;
+ }
+
+ /**
+ * Sets the value(s) for encounter (Primary encounter during which the answers were collected)
+ *
+ *
+ * Definition:
+ * Encounter during which this questionnaire answers were collected. When there were multiple encounters, this is the one considered most relevant to the context of the answers.
+ *
+ */
+ public Questionnaire setEncounter(ResourceReferenceDt theValue) {
+ myEncounter = theValue;
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for group (Grouped questions).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * A group of questions to a possibly similarly grouped set of questions in the questionnaire
+ *
+ */
+ public Group getGroup() {
+ if (myGroup == null) {
+ myGroup = new Group();
+ }
+ return myGroup;
+ }
+
+ /**
+ * Sets the value(s) for group (Grouped questions)
+ *
+ *
+ * Definition:
+ * A group of questions to a possibly similarly grouped set of questions in the questionnaire
+ *
+ */
+ public Questionnaire setGroup(Group theValue) {
+ myGroup = theValue;
+ return this;
+ }
+
+
+ /**
+ * Block class for child element: Questionnaire.group (Grouped questions)
+ *
+ *
+ * Definition:
+ * A group of questions to a possibly similarly grouped set of questions in the questionnaire
+ *
+ */
+ @Block(name="Questionnaire.group")
+ public static class Group extends BaseElement implements IResourceBlock {
+
+ @Child(name="name", type=CodeableConceptDt.class, order=0, min=0, max=1)
+ @Description(
+ shortDefinition="Code or name of the section on a questionnaire",
+ formalDefinition="Structured name for a section of a predefined list of questions this questionnaire is responding to."
+ )
+ private BoundCodeableConceptDt myName;
+
+ @Child(name="header", type=StringDt.class, order=1, min=0, max=1)
+ @Description(
+ shortDefinition="Text that is displayed above the contents of the group",
+ formalDefinition=""
+ )
+ private StringDt myHeader;
+
+ @Child(name="text", type=StringDt.class, order=2, min=0, max=1)
+ @Description(
+ shortDefinition="Additional text for the group",
+ formalDefinition="Additional text for the group, used for display purposes"
+ )
+ private StringDt myText;
+
+ @Child(name="subject", order=3, min=0, max=1, type={
+ IResource.class,
+ })
+ @Description(
+ shortDefinition="The subject this group's answers are about",
+ formalDefinition="More specific subject this section's answers are about, details the subject given in Questionnaire"
+ )
+ private ResourceReferenceDt mySubject;
+
+ @Child(name="group", type=Group.class, order=4, min=0, max=Child.MAX_UNLIMITED)
+ @Description(
+ shortDefinition="Nested questionnaire group",
+ formalDefinition="A sub-group within a group. The ordering of groups within this group is relevant"
+ )
+ private java.util.List myGroup;
+
+ @Child(name="question", order=5, min=0, max=Child.MAX_UNLIMITED)
+ @Description(
+ shortDefinition="Questions in this group",
+ formalDefinition="Set of questions within this group. The order of questions within the group is relevant"
+ )
+ private java.util.List myQuestion;
+
+
+ @Override
+ public boolean isEmpty() {
+ return super.isBaseEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty( myName, myHeader, myText, mySubject, myGroup, myQuestion);
+ }
+
+ @Override
+ public java.util.List getAllPopulatedChildElements() {
+ return getAllPopulatedChildElementsOfType(null);
+ }
+
+ @Override
+ public List getAllPopulatedChildElementsOfType(Class theType) {
+ return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(theType, myName, myHeader, myText, mySubject, myGroup, myQuestion);
+ }
+
+ /**
+ * Gets the value(s) for name (Code or name of the section on a questionnaire).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * Structured name for a section of a predefined list of questions this questionnaire is responding to.
+ *
+ */
+ public BoundCodeableConceptDt getName() {
+ if (myName == null) {
+ myName = new BoundCodeableConceptDt(QuestionnaireGroupNameEnum.VALUESET_BINDER);
+ }
+ return myName;
+ }
+
+ /**
+ * Sets the value(s) for name (Code or name of the section on a questionnaire)
+ *
+ *
+ * Definition:
+ * Structured name for a section of a predefined list of questions this questionnaire is responding to.
+ *
+ */
+ public Group setName(BoundCodeableConceptDt theValue) {
+ myName = theValue;
+ return this;
+ }
+
+ /**
+ * Sets the value(s) for name (Code or name of the section on a questionnaire)
+ *
+ *
+ * Definition:
+ * Structured name for a section of a predefined list of questions this questionnaire is responding to.
+ *
+ */
+ public Group setName(QuestionnaireGroupNameEnum theValue) {
+ getName().setValueAsEnum(theValue);
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for header (Text that is displayed above the contents of the group).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public StringDt getHeader() {
+ if (myHeader == null) {
+ myHeader = new StringDt();
+ }
+ return myHeader;
+ }
+
+ /**
+ * Sets the value(s) for header (Text that is displayed above the contents of the group)
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public Group setHeader(StringDt theValue) {
+ myHeader = theValue;
+ return this;
+ }
+
+ /**
+ * Sets the value for header (Text that is displayed above the contents of the group)
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public Group setHeader( String theString) {
+ myHeader = new StringDt(theString);
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for text (Additional text for the group).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * Additional text for the group, used for display purposes
+ *
+ */
+ public StringDt getText() {
+ if (myText == null) {
+ myText = new StringDt();
+ }
+ return myText;
+ }
+
+ /**
+ * Sets the value(s) for text (Additional text for the group)
+ *
+ *
+ * Definition:
+ * Additional text for the group, used for display purposes
+ *
+ */
+ public Group setText(StringDt theValue) {
+ myText = theValue;
+ return this;
+ }
+
+ /**
+ * Sets the value for text (Additional text for the group)
+ *
+ *
+ * Definition:
+ * Additional text for the group, used for display purposes
+ *
+ */
+ public Group setText( String theString) {
+ myText = new StringDt(theString);
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for subject (The subject this group's answers are about).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * More specific subject this section's answers are about, details the subject given in Questionnaire
+ *
+ */
+ public ResourceReferenceDt getSubject() {
+ if (mySubject == null) {
+ mySubject = new ResourceReferenceDt();
+ }
+ return mySubject;
+ }
+
+ /**
+ * Sets the value(s) for subject (The subject this group's answers are about)
+ *
+ *
+ * Definition:
+ * More specific subject this section's answers are about, details the subject given in Questionnaire
+ *
+ */
+ public Group setSubject(ResourceReferenceDt theValue) {
+ mySubject = theValue;
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for group (Nested questionnaire group).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * A sub-group within a group. The ordering of groups within this group is relevant
+ *
+ */
+ public java.util.List getGroup() {
+ if (myGroup == null) {
+ myGroup = new java.util.ArrayList();
+ }
+ return myGroup;
+ }
+
+ /**
+ * Sets the value(s) for group (Nested questionnaire group)
+ *
+ *
+ * Definition:
+ * A sub-group within a group. The ordering of groups within this group is relevant
+ *
+ */
+ public Group setGroup(java.util.List theValue) {
+ myGroup = theValue;
+ return this;
+ }
+
+ /**
+ * Adds and returns a new value for group (Nested questionnaire group)
+ *
+ *
+ * Definition:
+ * A sub-group within a group. The ordering of groups within this group is relevant
+ *
+ */
+ public Group addGroup() {
+ Group newType = new Group();
+ getGroup().add(newType);
+ return newType;
+ }
+
+ /**
+ * Gets the first repetition for group (Nested questionnaire group),
+ * creating it if it does not already exist.
+ *
+ *
+ * Definition:
+ * A sub-group within a group. The ordering of groups within this group is relevant
+ *
+ */
+ public Group getGroupFirstRep() {
+ if (getGroup().isEmpty()) {
+ return addGroup();
+ }
+ return getGroup().get(0);
+ }
+
+ /**
+ * Gets the value(s) for question (Questions in this group).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * Set of questions within this group. The order of questions within the group is relevant
+ *
+ */
+ public java.util.List getQuestion() {
+ if (myQuestion == null) {
+ myQuestion = new java.util.ArrayList();
+ }
+ return myQuestion;
+ }
+
+ /**
+ * Sets the value(s) for question (Questions in this group)
+ *
+ *
+ * Definition:
+ * Set of questions within this group. The order of questions within the group is relevant
+ *
+ */
+ public Group setQuestion(java.util.List theValue) {
+ myQuestion = theValue;
+ return this;
+ }
+
+ /**
+ * Adds and returns a new value for question (Questions in this group)
+ *
+ *
+ * Definition:
+ * Set of questions within this group. The order of questions within the group is relevant
+ *
+ */
+ public GroupQuestion addQuestion() {
+ GroupQuestion newType = new GroupQuestion();
+ getQuestion().add(newType);
+ return newType;
+ }
+
+ /**
+ * Gets the first repetition for question (Questions in this group),
+ * creating it if it does not already exist.
+ *
+ *
+ * Definition:
+ * Set of questions within this group. The order of questions within the group is relevant
+ *
+ */
+ public GroupQuestion getQuestionFirstRep() {
+ if (getQuestion().isEmpty()) {
+ return addQuestion();
+ }
+ return getQuestion().get(0);
+ }
+
+
+ }
+
+ /**
+ * Block class for child element: Questionnaire.group.question (Questions in this group)
+ *
+ *
+ * Definition:
+ * Set of questions within this group. The order of questions within the group is relevant
+ *
+ */
+ @Block(name="Questionnaire.group.question")
+ public static class GroupQuestion extends BaseElement implements IResourceBlock {
+
+ @Child(name="name", type=CodeableConceptDt.class, order=0, min=0, max=1)
+ @Description(
+ shortDefinition="Code or name of the question",
+ formalDefinition="Structured name for the question that identifies this question within the Questionnaire or Group"
+ )
+ private CodeableConceptDt myName;
+
+ @Child(name="text", type=StringDt.class, order=1, min=0, max=1)
+ @Description(
+ shortDefinition="Text of the question as it is shown to the user",
+ formalDefinition=""
+ )
+ private StringDt myText;
+
+ @Child(name="answer", order=2, min=0, max=1, type={
+ DecimalDt.class,
+ IntegerDt.class,
+ BooleanDt.class,
+ DateDt.class,
+ StringDt.class,
+ DateTimeDt.class,
+ InstantDt.class,
+ })
+ @Description(
+ shortDefinition="Single-valued answer to the question",
+ formalDefinition="Single-valued answer to the question"
+ )
+ private IDatatype myAnswer;
+
+ @Child(name="choice", type=CodingDt.class, order=3, min=0, max=Child.MAX_UNLIMITED)
+ @Description(
+ shortDefinition="Selected options",
+ formalDefinition="Selections made by the user from the list of options"
+ )
+ private java.util.List myChoice;
+
+ @Child(name="options", order=4, min=0, max=1, type={
+ ca.uhn.fhir.model.dstu.resource.ValueSet.class,
+ })
+ @Description(
+ shortDefinition="Valueset containing the possible options",
+ formalDefinition="Reference to a valueset containing the possible options"
+ )
+ private ResourceReferenceDt myOptions;
+
+ @Child(name="data", type=IDatatype.class, order=5, min=0, max=1)
+ @Description(
+ shortDefinition="Structured answer",
+ formalDefinition="Structured answer in the form of a FHIR Resource or datatype"
+ )
+ private IDatatype myData;
+
+ @Child(name="remarks", type=StringDt.class, order=6, min=0, max=1)
+ @Description(
+ shortDefinition="Remarks about the answer given",
+ formalDefinition="The remark contains information about the answer given. This is additional information about the answer the author wishes to convey, but should not be used to contain information that is part of the answer itself."
+ )
+ private StringDt myRemarks;
+
+ @Child(name="group", type=Group.class, order=7, min=0, max=Child.MAX_UNLIMITED)
+ @Description(
+ shortDefinition="Nested questionnaire group",
+ formalDefinition="Nested group, containing nested question for this question. The order of groups within the question is relevant"
+ )
+ private java.util.List myGroup;
+
+
+ @Override
+ public boolean isEmpty() {
+ return super.isBaseEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty( myName, myText, myAnswer, myChoice, myOptions, myData, myRemarks, myGroup);
+ }
+
+ @Override
+ public java.util.List getAllPopulatedChildElements() {
+ return getAllPopulatedChildElementsOfType(null);
+ }
+
+ @Override
+ public List getAllPopulatedChildElementsOfType(Class theType) {
+ return ca.uhn.fhir.util.ElementUtil.allPopulatedChildElements(theType, myName, myText, myAnswer, myChoice, myOptions, myData, myRemarks, myGroup);
+ }
+
+ /**
+ * Gets the value(s) for name (Code or name of the question).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * Structured name for the question that identifies this question within the Questionnaire or Group
+ *
+ */
+ public CodeableConceptDt getName() {
+ if (myName == null) {
+ myName = new CodeableConceptDt();
+ }
+ return myName;
+ }
+
+ /**
+ * Sets the value(s) for name (Code or name of the question)
+ *
+ *
+ * Definition:
+ * Structured name for the question that identifies this question within the Questionnaire or Group
+ *
+ */
+ public GroupQuestion setName(CodeableConceptDt theValue) {
+ myName = theValue;
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for text (Text of the question as it is shown to the user).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public StringDt getText() {
+ if (myText == null) {
+ myText = new StringDt();
+ }
+ return myText;
+ }
+
+ /**
+ * Sets the value(s) for text (Text of the question as it is shown to the user)
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public GroupQuestion setText(StringDt theValue) {
+ myText = theValue;
+ return this;
+ }
+
+ /**
+ * Sets the value for text (Text of the question as it is shown to the user)
+ *
+ *
+ * Definition:
+ *
+ *
+ */
+ public GroupQuestion setText( String theString) {
+ myText = new StringDt(theString);
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for answer[x] (Single-valued answer to the question).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * Single-valued answer to the question
+ *
+ */
+ public IDatatype getAnswer() {
+ return myAnswer;
+ }
+
+ /**
+ * Sets the value(s) for answer[x] (Single-valued answer to the question)
+ *
+ *
+ * Definition:
+ * Single-valued answer to the question
+ *
+ */
+ public GroupQuestion setAnswer(IDatatype theValue) {
+ myAnswer = theValue;
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for choice (Selected options).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * Selections made by the user from the list of options
+ *
+ */
+ public java.util.List getChoice() {
+ if (myChoice == null) {
+ myChoice = new java.util.ArrayList();
+ }
+ return myChoice;
+ }
+
+ /**
+ * Sets the value(s) for choice (Selected options)
+ *
+ *
+ * Definition:
+ * Selections made by the user from the list of options
+ *
+ */
+ public GroupQuestion setChoice(java.util.List theValue) {
+ myChoice = theValue;
+ return this;
+ }
+
+ /**
+ * Adds and returns a new value for choice (Selected options)
+ *
+ *
+ * Definition:
+ * Selections made by the user from the list of options
+ *
+ */
+ public CodingDt addChoice() {
+ CodingDt newType = new CodingDt();
+ getChoice().add(newType);
+ return newType;
+ }
+
+ /**
+ * Gets the first repetition for choice (Selected options),
+ * creating it if it does not already exist.
+ *
+ *
+ * Definition:
+ * Selections made by the user from the list of options
+ *
+ */
+ public CodingDt getChoiceFirstRep() {
+ if (getChoice().isEmpty()) {
+ return addChoice();
+ }
+ return getChoice().get(0);
+ }
+
+ /**
+ * Gets the value(s) for options (Valueset containing the possible options).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * Reference to a valueset containing the possible options
+ *
+ */
+ public ResourceReferenceDt getOptions() {
+ if (myOptions == null) {
+ myOptions = new ResourceReferenceDt();
+ }
+ return myOptions;
+ }
+
+ /**
+ * Sets the value(s) for options (Valueset containing the possible options)
+ *
+ *
+ * Definition:
+ * Reference to a valueset containing the possible options
+ *
+ */
+ public GroupQuestion setOptions(ResourceReferenceDt theValue) {
+ myOptions = theValue;
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for data[x] (Structured answer).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * Structured answer in the form of a FHIR Resource or datatype
+ *
+ */
+ public IDatatype getData() {
+ return myData;
+ }
+
+ /**
+ * Sets the value(s) for data[x] (Structured answer)
+ *
+ *
+ * Definition:
+ * Structured answer in the form of a FHIR Resource or datatype
+ *
+ */
+ public GroupQuestion setData(IDatatype theValue) {
+ myData = theValue;
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for remarks (Remarks about the answer given).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * The remark contains information about the answer given. This is additional information about the answer the author wishes to convey, but should not be used to contain information that is part of the answer itself.
+ *
+ */
+ public StringDt getRemarks() {
+ if (myRemarks == null) {
+ myRemarks = new StringDt();
+ }
+ return myRemarks;
+ }
+
+ /**
+ * Sets the value(s) for remarks (Remarks about the answer given)
+ *
+ *
+ * Definition:
+ * The remark contains information about the answer given. This is additional information about the answer the author wishes to convey, but should not be used to contain information that is part of the answer itself.
+ *
+ */
+ public GroupQuestion setRemarks(StringDt theValue) {
+ myRemarks = theValue;
+ return this;
+ }
+
+ /**
+ * Sets the value for remarks (Remarks about the answer given)
+ *
+ *
+ * Definition:
+ * The remark contains information about the answer given. This is additional information about the answer the author wishes to convey, but should not be used to contain information that is part of the answer itself.
+ *
+ */
+ public GroupQuestion setRemarks( String theString) {
+ myRemarks = new StringDt(theString);
+ return this;
+ }
+
+
+ /**
+ * Gets the value(s) for group (Nested questionnaire group).
+ * creating it if it does
+ * not exist. Will not return null
.
+ *
+ *
+ * Definition:
+ * Nested group, containing nested question for this question. The order of groups within the question is relevant
+ *
+ */
+ public java.util.List getGroup() {
+ if (myGroup == null) {
+ myGroup = new java.util.ArrayList();
+ }
+ return myGroup;
+ }
+
+ /**
+ * Sets the value(s) for group (Nested questionnaire group)
+ *
+ *
+ * Definition:
+ * Nested group, containing nested question for this question. The order of groups within the question is relevant
+ *
+ */
+ public GroupQuestion setGroup(java.util.List theValue) {
+ myGroup = theValue;
+ return this;
+ }
+
+ /**
+ * Adds and returns a new value for group (Nested questionnaire group)
+ *
+ *
+ * Definition:
+ * Nested group, containing nested question for this question. The order of groups within the question is relevant
+ *
+ */
+ public Group addGroup() {
+ Group newType = new Group();
+ getGroup().add(newType);
+ return newType;
+ }
+
+ /**
+ * Gets the first repetition for group (Nested questionnaire group),
+ * creating it if it does not already exist.
+ *
+ *
+ * Definition:
+ * Nested group, containing nested question for this question. The order of groups within the question is relevant
+ *
+ */
+ public Group getGroupFirstRep() {
+ if (getGroup().isEmpty()) {
+ return addGroup();
+ }
+ return getGroup().get(0);
+ }
+
+
+ }
+
+
+
+
+
+}
\ No newline at end of file
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/valueset/AlertStatusEnum.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/valueset/AlertStatusEnum.java
new file mode 100644
index 00000000000..39142fef91f
--- /dev/null
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/valueset/AlertStatusEnum.java
@@ -0,0 +1,124 @@
+
+package ca.uhn.fhir.model.dstu.valueset;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import ca.uhn.fhir.model.api.IValueSetEnumBinder;
+
+public enum AlertStatusEnum {
+
+ /**
+ * Code Value: active
+ *
+ * A current alert that should be displayed to a user. A system may use the category to determine which roles should view the alert.
+ */
+ ACTIVE("active", "http://hl7.org/fhir/alert-status"),
+
+ /**
+ * Code Value: inactive
+ *
+ * The alert does not need to be displayed any more.
+ */
+ INACTIVE("inactive", "http://hl7.org/fhir/alert-status"),
+
+ /**
+ * Code Value: entered in error
+ *
+ * The alert was added in error, and should no longer be displayed.
+ */
+ ENTERED_IN_ERROR("entered in error", "http://hl7.org/fhir/alert-status"),
+
+ ;
+
+ /**
+ * Identifier for this Value Set:
+ * http://hl7.org/fhir/vs/alert-status
+ */
+ public static final String VALUESET_IDENTIFIER = "http://hl7.org/fhir/vs/alert-status";
+
+ /**
+ * Name for this Value Set:
+ * AlertStatus
+ */
+ public static final String VALUESET_NAME = "AlertStatus";
+
+ private static Map CODE_TO_ENUM = new HashMap();
+ private static Map> SYSTEM_TO_CODE_TO_ENUM = new HashMap>();
+
+ private final String myCode;
+ private final String mySystem;
+
+ static {
+ for (AlertStatusEnum next : AlertStatusEnum.values()) {
+ CODE_TO_ENUM.put(next.getCode(), next);
+
+ if (!SYSTEM_TO_CODE_TO_ENUM.containsKey(next.getSystem())) {
+ SYSTEM_TO_CODE_TO_ENUM.put(next.getSystem(), new HashMap());
+ }
+ SYSTEM_TO_CODE_TO_ENUM.get(next.getSystem()).put(next.getCode(), next);
+ }
+ }
+
+ /**
+ * Returns the code associated with this enumerated value
+ */
+ public String getCode() {
+ return myCode;
+ }
+
+ /**
+ * Returns the code system associated with this enumerated value
+ */
+ public String getSystem() {
+ return mySystem;
+ }
+
+ /**
+ * Returns the enumerated value associated with this code
+ */
+ public AlertStatusEnum forCode(String theCode) {
+ AlertStatusEnum retVal = CODE_TO_ENUM.get(theCode);
+ return retVal;
+ }
+
+ /**
+ * Converts codes to their respective enumerated values
+ */
+ public static final IValueSetEnumBinder VALUESET_BINDER = new IValueSetEnumBinder() {
+ @Override
+ public String toCodeString(AlertStatusEnum theEnum) {
+ return theEnum.getCode();
+ }
+
+ @Override
+ public String toSystemString(AlertStatusEnum theEnum) {
+ return theEnum.getSystem();
+ }
+
+ @Override
+ public AlertStatusEnum fromCodeString(String theCodeString) {
+ return CODE_TO_ENUM.get(theCodeString);
+ }
+
+ @Override
+ public AlertStatusEnum fromCodeString(String theCodeString, String theSystemString) {
+ Map map = SYSTEM_TO_CODE_TO_ENUM.get(theSystemString);
+ if (map == null) {
+ return null;
+ }
+ return map.get(theCodeString);
+ }
+
+ };
+
+ /**
+ * Constructor
+ */
+ AlertStatusEnum(String theCode, String theSystem) {
+ myCode = theCode;
+ mySystem = theSystem;
+ }
+
+
+}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/valueset/IssueSeverityEnum.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/valueset/IssueSeverityEnum.java
new file mode 100644
index 00000000000..7a1c8916145
--- /dev/null
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/valueset/IssueSeverityEnum.java
@@ -0,0 +1,131 @@
+
+package ca.uhn.fhir.model.dstu.valueset;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import ca.uhn.fhir.model.api.IValueSetEnumBinder;
+
+public enum IssueSeverityEnum {
+
+ /**
+ * Code Value: fatal
+ *
+ * The issue caused the action to fail, and no further checking could be performed.
+ */
+ FATAL("fatal", "http://hl7.org/fhir/issue-severity"),
+
+ /**
+ * Code Value: error
+ *
+ * The issue is sufficiently important to cause the action to fail.
+ */
+ ERROR("error", "http://hl7.org/fhir/issue-severity"),
+
+ /**
+ * Code Value: warning
+ *
+ * The issue is not important enough to cause the action to fail, but may cause it to be performed suboptimally or in a way that is not as desired.
+ */
+ WARNING("warning", "http://hl7.org/fhir/issue-severity"),
+
+ /**
+ * Code Value: information
+ *
+ * The issue has no relation to the degree of success of the action.
+ */
+ INFORMATION("information", "http://hl7.org/fhir/issue-severity"),
+
+ ;
+
+ /**
+ * Identifier for this Value Set:
+ * http://hl7.org/fhir/vs/issue-severity
+ */
+ public static final String VALUESET_IDENTIFIER = "http://hl7.org/fhir/vs/issue-severity";
+
+ /**
+ * Name for this Value Set:
+ * IssueSeverity
+ */
+ public static final String VALUESET_NAME = "IssueSeverity";
+
+ private static Map CODE_TO_ENUM = new HashMap();
+ private static Map> SYSTEM_TO_CODE_TO_ENUM = new HashMap>();
+
+ private final String myCode;
+ private final String mySystem;
+
+ static {
+ for (IssueSeverityEnum next : IssueSeverityEnum.values()) {
+ CODE_TO_ENUM.put(next.getCode(), next);
+
+ if (!SYSTEM_TO_CODE_TO_ENUM.containsKey(next.getSystem())) {
+ SYSTEM_TO_CODE_TO_ENUM.put(next.getSystem(), new HashMap());
+ }
+ SYSTEM_TO_CODE_TO_ENUM.get(next.getSystem()).put(next.getCode(), next);
+ }
+ }
+
+ /**
+ * Returns the code associated with this enumerated value
+ */
+ public String getCode() {
+ return myCode;
+ }
+
+ /**
+ * Returns the code system associated with this enumerated value
+ */
+ public String getSystem() {
+ return mySystem;
+ }
+
+ /**
+ * Returns the enumerated value associated with this code
+ */
+ public IssueSeverityEnum forCode(String theCode) {
+ IssueSeverityEnum retVal = CODE_TO_ENUM.get(theCode);
+ return retVal;
+ }
+
+ /**
+ * Converts codes to their respective enumerated values
+ */
+ public static final IValueSetEnumBinder VALUESET_BINDER = new IValueSetEnumBinder() {
+ @Override
+ public String toCodeString(IssueSeverityEnum theEnum) {
+ return theEnum.getCode();
+ }
+
+ @Override
+ public String toSystemString(IssueSeverityEnum theEnum) {
+ return theEnum.getSystem();
+ }
+
+ @Override
+ public IssueSeverityEnum fromCodeString(String theCodeString) {
+ return CODE_TO_ENUM.get(theCodeString);
+ }
+
+ @Override
+ public IssueSeverityEnum fromCodeString(String theCodeString, String theSystemString) {
+ Map map = SYSTEM_TO_CODE_TO_ENUM.get(theSystemString);
+ if (map == null) {
+ return null;
+ }
+ return map.get(theCodeString);
+ }
+
+ };
+
+ /**
+ * Constructor
+ */
+ IssueSeverityEnum(String theCode, String theSystem) {
+ myCode = theCode;
+ mySystem = theSystem;
+ }
+
+
+}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/valueset/IssueTypeEnum.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/valueset/IssueTypeEnum.java
new file mode 100644
index 00000000000..dc93781ae31
--- /dev/null
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/valueset/IssueTypeEnum.java
@@ -0,0 +1,131 @@
+
+package ca.uhn.fhir.model.dstu.valueset;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import ca.uhn.fhir.model.api.IValueSetEnumBinder;
+
+public enum IssueTypeEnum {
+
+ /**
+ * Code Value: invalid
+ *
+ * Content invalid against Specification or Profile.
+ */
+ INVALID("invalid", "http://hl7.org/fhir/issue-type"),
+
+ /**
+ * Code Value: security
+ *
+ * authorization/permissions issue.
+ */
+ SECURITY("security", "http://hl7.org/fhir/issue-type"),
+
+ /**
+ * Code Value: processing
+ *
+ * processing issues.
+ */
+ PROCESSING("processing", "http://hl7.org/fhir/issue-type"),
+
+ /**
+ * Code Value: transient
+ *
+ * transient processing issues.
+ */
+ TRANSIENT("transient", "http://hl7.org/fhir/issue-type"),
+
+ ;
+
+ /**
+ * Identifier for this Value Set:
+ * http://hl7.org/fhir/vs/issue-type
+ */
+ public static final String VALUESET_IDENTIFIER = "http://hl7.org/fhir/vs/issue-type";
+
+ /**
+ * Name for this Value Set:
+ * IssueType
+ */
+ public static final String VALUESET_NAME = "IssueType";
+
+ private static Map CODE_TO_ENUM = new HashMap();
+ private static Map> SYSTEM_TO_CODE_TO_ENUM = new HashMap>();
+
+ private final String myCode;
+ private final String mySystem;
+
+ static {
+ for (IssueTypeEnum next : IssueTypeEnum.values()) {
+ CODE_TO_ENUM.put(next.getCode(), next);
+
+ if (!SYSTEM_TO_CODE_TO_ENUM.containsKey(next.getSystem())) {
+ SYSTEM_TO_CODE_TO_ENUM.put(next.getSystem(), new HashMap());
+ }
+ SYSTEM_TO_CODE_TO_ENUM.get(next.getSystem()).put(next.getCode(), next);
+ }
+ }
+
+ /**
+ * Returns the code associated with this enumerated value
+ */
+ public String getCode() {
+ return myCode;
+ }
+
+ /**
+ * Returns the code system associated with this enumerated value
+ */
+ public String getSystem() {
+ return mySystem;
+ }
+
+ /**
+ * Returns the enumerated value associated with this code
+ */
+ public IssueTypeEnum forCode(String theCode) {
+ IssueTypeEnum retVal = CODE_TO_ENUM.get(theCode);
+ return retVal;
+ }
+
+ /**
+ * Converts codes to their respective enumerated values
+ */
+ public static final IValueSetEnumBinder VALUESET_BINDER = new IValueSetEnumBinder() {
+ @Override
+ public String toCodeString(IssueTypeEnum theEnum) {
+ return theEnum.getCode();
+ }
+
+ @Override
+ public String toSystemString(IssueTypeEnum theEnum) {
+ return theEnum.getSystem();
+ }
+
+ @Override
+ public IssueTypeEnum fromCodeString(String theCodeString) {
+ return CODE_TO_ENUM.get(theCodeString);
+ }
+
+ @Override
+ public IssueTypeEnum fromCodeString(String theCodeString, String theSystemString) {
+ Map map = SYSTEM_TO_CODE_TO_ENUM.get(theSystemString);
+ if (map == null) {
+ return null;
+ }
+ return map.get(theCodeString);
+ }
+
+ };
+
+ /**
+ * Constructor
+ */
+ IssueTypeEnum(String theCode, String theSystem) {
+ myCode = theCode;
+ mySystem = theSystem;
+ }
+
+
+}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/valueset/QueryOutcomeEnum.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/valueset/QueryOutcomeEnum.java
new file mode 100644
index 00000000000..c5bc615b3c4
--- /dev/null
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/valueset/QueryOutcomeEnum.java
@@ -0,0 +1,131 @@
+
+package ca.uhn.fhir.model.dstu.valueset;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import ca.uhn.fhir.model.api.IValueSetEnumBinder;
+
+public enum QueryOutcomeEnum {
+
+ /**
+ * Code Value: ok
+ *
+ * The query was processed successfully.
+ */
+ OK("ok", "http://hl7.org/fhir/query-outcome"),
+
+ /**
+ * Code Value: limited
+ *
+ * The query was processed successfully, but some additional limitations were added.
+ */
+ LIMITED("limited", "http://hl7.org/fhir/query-outcome"),
+
+ /**
+ * Code Value: refused
+ *
+ * The server refused to process the query.
+ */
+ REFUSED("refused", "http://hl7.org/fhir/query-outcome"),
+
+ /**
+ * Code Value: error
+ *
+ * The server tried to process the query, but some error occurred.
+ */
+ ERROR("error", "http://hl7.org/fhir/query-outcome"),
+
+ ;
+
+ /**
+ * Identifier for this Value Set:
+ * http://hl7.org/fhir/vs/query-outcome
+ */
+ public static final String VALUESET_IDENTIFIER = "http://hl7.org/fhir/vs/query-outcome";
+
+ /**
+ * Name for this Value Set:
+ * QueryOutcome
+ */
+ public static final String VALUESET_NAME = "QueryOutcome";
+
+ private static Map CODE_TO_ENUM = new HashMap();
+ private static Map> SYSTEM_TO_CODE_TO_ENUM = new HashMap>();
+
+ private final String myCode;
+ private final String mySystem;
+
+ static {
+ for (QueryOutcomeEnum next : QueryOutcomeEnum.values()) {
+ CODE_TO_ENUM.put(next.getCode(), next);
+
+ if (!SYSTEM_TO_CODE_TO_ENUM.containsKey(next.getSystem())) {
+ SYSTEM_TO_CODE_TO_ENUM.put(next.getSystem(), new HashMap());
+ }
+ SYSTEM_TO_CODE_TO_ENUM.get(next.getSystem()).put(next.getCode(), next);
+ }
+ }
+
+ /**
+ * Returns the code associated with this enumerated value
+ */
+ public String getCode() {
+ return myCode;
+ }
+
+ /**
+ * Returns the code system associated with this enumerated value
+ */
+ public String getSystem() {
+ return mySystem;
+ }
+
+ /**
+ * Returns the enumerated value associated with this code
+ */
+ public QueryOutcomeEnum forCode(String theCode) {
+ QueryOutcomeEnum retVal = CODE_TO_ENUM.get(theCode);
+ return retVal;
+ }
+
+ /**
+ * Converts codes to their respective enumerated values
+ */
+ public static final IValueSetEnumBinder VALUESET_BINDER = new IValueSetEnumBinder() {
+ @Override
+ public String toCodeString(QueryOutcomeEnum theEnum) {
+ return theEnum.getCode();
+ }
+
+ @Override
+ public String toSystemString(QueryOutcomeEnum theEnum) {
+ return theEnum.getSystem();
+ }
+
+ @Override
+ public QueryOutcomeEnum fromCodeString(String theCodeString) {
+ return CODE_TO_ENUM.get(theCodeString);
+ }
+
+ @Override
+ public QueryOutcomeEnum fromCodeString(String theCodeString, String theSystemString) {
+ Map map = SYSTEM_TO_CODE_TO_ENUM.get(theSystemString);
+ if (map == null) {
+ return null;
+ }
+ return map.get(theCodeString);
+ }
+
+ };
+
+ /**
+ * Constructor
+ */
+ QueryOutcomeEnum(String theCode, String theSystem) {
+ myCode = theCode;
+ mySystem = theSystem;
+ }
+
+
+}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/valueset/QuestionnaireGroupNameEnum.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/valueset/QuestionnaireGroupNameEnum.java
new file mode 100644
index 00000000000..72a7183efb0
--- /dev/null
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/valueset/QuestionnaireGroupNameEnum.java
@@ -0,0 +1,133 @@
+
+package ca.uhn.fhir.model.dstu.valueset;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import ca.uhn.fhir.model.api.IValueSetEnumBinder;
+
+public enum QuestionnaireGroupNameEnum {
+
+ /**
+ * Display: Hair Color
+ * Code Value: B.001
+ */
+ HAIR_COLOR("B.001", "http://hl7.org/fhir/questionnaire-group-name"),
+
+ /**
+ * Display: Vision
+ * Code Value: B.002
+ */
+ VISION("B.002", "http://hl7.org/fhir/questionnaire-group-name"),
+
+ /**
+ * Display: Sleepwalker
+ * Code Value: B.003
+ */
+ SLEEPWALKER("B.003", "http://hl7.org/fhir/questionnaire-group-name"),
+
+ /**
+ * Display: Tooth extraction
+ * Code Value: B.004
+ */
+ TOOTH_EXTRACTION("B.004", "http://hl7.org/fhir/questionnaire-group-name"),
+
+ /**
+ * Display: Stutter
+ * Code Value: B.005
+ */
+ STUTTER("B.005", "http://hl7.org/fhir/questionnaire-group-name"),
+
+ ;
+
+ /**
+ * Identifier for this Value Set:
+ * http://hl7.org/fhir/vs/questionnaire-group-name
+ */
+ public static final String VALUESET_IDENTIFIER = "http://hl7.org/fhir/vs/questionnaire-group-name";
+
+ /**
+ * Name for this Value Set:
+ * QuestionnaireGroupName
+ */
+ public static final String VALUESET_NAME = "QuestionnaireGroupName";
+
+ private static Map CODE_TO_ENUM = new HashMap();
+ private static Map> SYSTEM_TO_CODE_TO_ENUM = new HashMap>();
+
+ private final String myCode;
+ private final String mySystem;
+
+ static {
+ for (QuestionnaireGroupNameEnum next : QuestionnaireGroupNameEnum.values()) {
+ CODE_TO_ENUM.put(next.getCode(), next);
+
+ if (!SYSTEM_TO_CODE_TO_ENUM.containsKey(next.getSystem())) {
+ SYSTEM_TO_CODE_TO_ENUM.put(next.getSystem(), new HashMap());
+ }
+ SYSTEM_TO_CODE_TO_ENUM.get(next.getSystem()).put(next.getCode(), next);
+ }
+ }
+
+ /**
+ * Returns the code associated with this enumerated value
+ */
+ public String getCode() {
+ return myCode;
+ }
+
+ /**
+ * Returns the code system associated with this enumerated value
+ */
+ public String getSystem() {
+ return mySystem;
+ }
+
+ /**
+ * Returns the enumerated value associated with this code
+ */
+ public QuestionnaireGroupNameEnum forCode(String theCode) {
+ QuestionnaireGroupNameEnum retVal = CODE_TO_ENUM.get(theCode);
+ return retVal;
+ }
+
+ /**
+ * Converts codes to their respective enumerated values
+ */
+ public static final IValueSetEnumBinder VALUESET_BINDER = new IValueSetEnumBinder() {
+ @Override
+ public String toCodeString(QuestionnaireGroupNameEnum theEnum) {
+ return theEnum.getCode();
+ }
+
+ @Override
+ public String toSystemString(QuestionnaireGroupNameEnum theEnum) {
+ return theEnum.getSystem();
+ }
+
+ @Override
+ public QuestionnaireGroupNameEnum fromCodeString(String theCodeString) {
+ return CODE_TO_ENUM.get(theCodeString);
+ }
+
+ @Override
+ public QuestionnaireGroupNameEnum fromCodeString(String theCodeString, String theSystemString) {
+ Map map = SYSTEM_TO_CODE_TO_ENUM.get(theSystemString);
+ if (map == null) {
+ return null;
+ }
+ return map.get(theCodeString);
+ }
+
+ };
+
+ /**
+ * Constructor
+ */
+ QuestionnaireGroupNameEnum(String theCode, String theSystem) {
+ myCode = theCode;
+ mySystem = theSystem;
+ }
+
+
+}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/valueset/QuestionnaireNameEnum.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/valueset/QuestionnaireNameEnum.java
new file mode 100644
index 00000000000..6dcc14e2b62
--- /dev/null
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/valueset/QuestionnaireNameEnum.java
@@ -0,0 +1,121 @@
+
+package ca.uhn.fhir.model.dstu.valueset;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import ca.uhn.fhir.model.api.IValueSetEnumBinder;
+
+public enum QuestionnaireNameEnum {
+
+ /**
+ * Display: Cancer Treatment Quality Questionnaire 2012
+ * Code Value: CTQQ-2012
+ */
+ CANCER_TREATMENT_QUALITY_QUESTIONNAIRE_2012("CTQQ-2012", "http://hl7.org/fhir/questionnaire-name"),
+
+ /**
+ * Display: Pre-admission standard Form A
+ * Code Value: PA.form.A
+ */
+ PRE_ADMISSION_STANDARD_FORM_A("PA.form.A", "http://hl7.org/fhir/questionnaire-name"),
+
+ /**
+ * Display: Brazelton Neonatal Assessment Scale
+ * Code Value: BNAS
+ */
+ BRAZELTON_NEONATAL_ASSESSMENT_SCALE("BNAS", "http://hl7.org/fhir/questionnaire-name"),
+
+ ;
+
+ /**
+ * Identifier for this Value Set:
+ * http://hl7.org/fhir/vs/questionnaire-name
+ */
+ public static final String VALUESET_IDENTIFIER = "http://hl7.org/fhir/vs/questionnaire-name";
+
+ /**
+ * Name for this Value Set:
+ * QuestionnaireName
+ */
+ public static final String VALUESET_NAME = "QuestionnaireName";
+
+ private static Map CODE_TO_ENUM = new HashMap();
+ private static Map> SYSTEM_TO_CODE_TO_ENUM = new HashMap>();
+
+ private final String myCode;
+ private final String mySystem;
+
+ static {
+ for (QuestionnaireNameEnum next : QuestionnaireNameEnum.values()) {
+ CODE_TO_ENUM.put(next.getCode(), next);
+
+ if (!SYSTEM_TO_CODE_TO_ENUM.containsKey(next.getSystem())) {
+ SYSTEM_TO_CODE_TO_ENUM.put(next.getSystem(), new HashMap());
+ }
+ SYSTEM_TO_CODE_TO_ENUM.get(next.getSystem()).put(next.getCode(), next);
+ }
+ }
+
+ /**
+ * Returns the code associated with this enumerated value
+ */
+ public String getCode() {
+ return myCode;
+ }
+
+ /**
+ * Returns the code system associated with this enumerated value
+ */
+ public String getSystem() {
+ return mySystem;
+ }
+
+ /**
+ * Returns the enumerated value associated with this code
+ */
+ public QuestionnaireNameEnum forCode(String theCode) {
+ QuestionnaireNameEnum retVal = CODE_TO_ENUM.get(theCode);
+ return retVal;
+ }
+
+ /**
+ * Converts codes to their respective enumerated values
+ */
+ public static final IValueSetEnumBinder VALUESET_BINDER = new IValueSetEnumBinder() {
+ @Override
+ public String toCodeString(QuestionnaireNameEnum theEnum) {
+ return theEnum.getCode();
+ }
+
+ @Override
+ public String toSystemString(QuestionnaireNameEnum theEnum) {
+ return theEnum.getSystem();
+ }
+
+ @Override
+ public QuestionnaireNameEnum fromCodeString(String theCodeString) {
+ return CODE_TO_ENUM.get(theCodeString);
+ }
+
+ @Override
+ public QuestionnaireNameEnum fromCodeString(String theCodeString, String theSystemString) {
+ Map map = SYSTEM_TO_CODE_TO_ENUM.get(theSystemString);
+ if (map == null) {
+ return null;
+ }
+ return map.get(theCodeString);
+ }
+
+ };
+
+ /**
+ * Constructor
+ */
+ QuestionnaireNameEnum(String theCode, String theSystem) {
+ myCode = theCode;
+ mySystem = theSystem;
+ }
+
+
+}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/valueset/QuestionnaireStatusEnum.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/valueset/QuestionnaireStatusEnum.java
new file mode 100644
index 00000000000..e52f949ae6d
--- /dev/null
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/dstu/valueset/QuestionnaireStatusEnum.java
@@ -0,0 +1,151 @@
+
+package ca.uhn.fhir.model.dstu.valueset;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import ca.uhn.fhir.model.api.IValueSetEnumBinder;
+
+public enum QuestionnaireStatusEnum {
+
+ /**
+ * Display: draft
+ * Code Value: draft
+ *
+ * This Questionnaire is used as a template but the template is not ready for use or publication.
+ */
+ DRAFT("draft", "http://hl7.org/fhir/questionnaire-status"),
+
+ /**
+ * Display: published
+ * Code Value: published
+ *
+ * This Questionnaire is used as a template, is published and ready for use.
+ */
+ PUBLISHED("published", "http://hl7.org/fhir/questionnaire-status"),
+
+ /**
+ * Display: retired
+ * Code Value: retired
+ *
+ * This Questionnaire is used as a template but should no longer be used for new Questionnaires.
+ */
+ RETIRED("retired", "http://hl7.org/fhir/questionnaire-status"),
+
+ /**
+ * Display: in progress
+ * Code Value: in progress
+ *
+ * This Questionnaire has been filled out with answers, but changes or additions are still expected to be made to it.
+ */
+ IN_PROGRESS("in progress", "http://hl7.org/fhir/questionnaire-status"),
+
+ /**
+ * Display: complete
+ * Code Value: completed
+ *
+ * This Questionnaire has been filled out with answers, and the current content is regarded as definitive.
+ */
+ COMPLETE("completed", "http://hl7.org/fhir/questionnaire-status"),
+
+ /**
+ * Display: amended
+ * Code Value: amended
+ *
+ * This Questionnaire has been filled out with answers, then marked as complete, yet changes or additions have been made to it afterwards.
+ */
+ AMENDED("amended", "http://hl7.org/fhir/questionnaire-status"),
+
+ ;
+
+ /**
+ * Identifier for this Value Set:
+ * http://hl7.org/fhir/vs/questionnaire-status
+ */
+ public static final String VALUESET_IDENTIFIER = "http://hl7.org/fhir/vs/questionnaire-status";
+
+ /**
+ * Name for this Value Set:
+ * QuestionnaireStatus
+ */
+ public static final String VALUESET_NAME = "QuestionnaireStatus";
+
+ private static Map CODE_TO_ENUM = new HashMap();
+ private static Map> SYSTEM_TO_CODE_TO_ENUM = new HashMap>();
+
+ private final String myCode;
+ private final String mySystem;
+
+ static {
+ for (QuestionnaireStatusEnum next : QuestionnaireStatusEnum.values()) {
+ CODE_TO_ENUM.put(next.getCode(), next);
+
+ if (!SYSTEM_TO_CODE_TO_ENUM.containsKey(next.getSystem())) {
+ SYSTEM_TO_CODE_TO_ENUM.put(next.getSystem(), new HashMap());
+ }
+ SYSTEM_TO_CODE_TO_ENUM.get(next.getSystem()).put(next.getCode(), next);
+ }
+ }
+
+ /**
+ * Returns the code associated with this enumerated value
+ */
+ public String getCode() {
+ return myCode;
+ }
+
+ /**
+ * Returns the code system associated with this enumerated value
+ */
+ public String getSystem() {
+ return mySystem;
+ }
+
+ /**
+ * Returns the enumerated value associated with this code
+ */
+ public QuestionnaireStatusEnum forCode(String theCode) {
+ QuestionnaireStatusEnum retVal = CODE_TO_ENUM.get(theCode);
+ return retVal;
+ }
+
+ /**
+ * Converts codes to their respective enumerated values
+ */
+ public static final IValueSetEnumBinder VALUESET_BINDER = new IValueSetEnumBinder() {
+ @Override
+ public String toCodeString(QuestionnaireStatusEnum theEnum) {
+ return theEnum.getCode();
+ }
+
+ @Override
+ public String toSystemString(QuestionnaireStatusEnum theEnum) {
+ return theEnum.getSystem();
+ }
+
+ @Override
+ public QuestionnaireStatusEnum fromCodeString(String theCodeString) {
+ return CODE_TO_ENUM.get(theCodeString);
+ }
+
+ @Override
+ public QuestionnaireStatusEnum fromCodeString(String theCodeString, String theSystemString) {
+ Map map = SYSTEM_TO_CODE_TO_ENUM.get(theSystemString);
+ if (map == null) {
+ return null;
+ }
+ return map.get(theCodeString);
+ }
+
+ };
+
+ /**
+ * Constructor
+ */
+ QuestionnaireStatusEnum(String theCode, String theSystem) {
+ myCode = theCode;
+ mySystem = theSystem;
+ }
+
+
+}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BaseDateTimeDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BaseDateTimeDt.java
index 62baf6a0052..f0b0ffb863b 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BaseDateTimeDt.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BaseDateTimeDt.java
@@ -1,10 +1,6 @@
package ca.uhn.fhir.model.primitive;
-import static ca.uhn.fhir.model.api.TemporalPrecisionEnum.DAY;
-import static ca.uhn.fhir.model.api.TemporalPrecisionEnum.MILLI;
-import static ca.uhn.fhir.model.api.TemporalPrecisionEnum.MONTH;
-import static ca.uhn.fhir.model.api.TemporalPrecisionEnum.SECOND;
-import static ca.uhn.fhir.model.api.TemporalPrecisionEnum.YEAR;
+import static ca.uhn.fhir.model.api.TemporalPrecisionEnum.*;
import java.text.ParseException;
import java.util.Calendar;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BoundCodeableConceptDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BoundCodeableConceptDt.java
index 3b66614175a..c3c51aa7f01 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BoundCodeableConceptDt.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BoundCodeableConceptDt.java
@@ -1,6 +1,6 @@
package ca.uhn.fhir.model.primitive;
-import static org.apache.commons.lang3.StringUtils.defaultString;
+import static org.apache.commons.lang3.StringUtils.*;
import java.util.HashSet;
import java.util.Set;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BoundCodingDt__.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BoundCodingDt__.java
index 15495309a09..17d111f2844 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BoundCodingDt__.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/BoundCodingDt__.java
@@ -1,6 +1,6 @@
package ca.uhn.fhir.model.primitive;
-import static org.apache.commons.lang3.StringUtils.defaultString;
+import static org.apache.commons.lang3.StringUtils.*;
import ca.uhn.fhir.model.api.IValueSetEnumBinder;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
import ca.uhn.fhir.model.dstu.composite.CodingDt;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/CodeDt.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/CodeDt.java
index 61c4ca700ff..f4afcf5779b 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/CodeDt.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/primitive/CodeDt.java
@@ -1,6 +1,6 @@
package ca.uhn.fhir.model.primitive;
-import static org.apache.commons.lang3.StringUtils.defaultString;
+import static org.apache.commons.lang3.StringUtils.*;
import ca.uhn.fhir.model.api.BasePrimitive;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
import ca.uhn.fhir.model.api.annotation.SimpleSetter;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGenerator.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGenerator.java
index 4440699aa37..8774086704e 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGenerator.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGenerator.java
@@ -1,6 +1,6 @@
package ca.uhn.fhir.narrative;
-import static org.apache.commons.lang3.StringUtils.isBlank;
+import static org.apache.commons.lang3.StringUtils.*;
import java.io.IOException;
import java.io.InputStream;
@@ -33,7 +33,6 @@ import org.thymeleaf.util.DOMUtils;
import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.dstu.composite.NarrativeDt;
-import ca.uhn.fhir.model.dstu.composite.QuantityDt;
import ca.uhn.fhir.model.dstu.valueset.NarrativeStatusEnum;
import ca.uhn.fhir.model.primitive.XhtmlDt;
import ca.uhn.fhir.parser.DataFormatException;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/JsonParser.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/JsonParser.java
index cbf9888827f..839ae19ec70 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/JsonParser.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/JsonParser.java
@@ -1,7 +1,6 @@
package ca.uhn.fhir.parser;
-import static org.apache.commons.lang3.StringUtils.isBlank;
-import static org.apache.commons.lang3.StringUtils.isNotBlank;
+import static org.apache.commons.lang3.StringUtils.*;
import java.io.IOException;
import java.io.Reader;
@@ -42,12 +41,12 @@ import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.model.api.BaseBundle;
import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.api.BundleEntry;
+import ca.uhn.fhir.model.api.ExtensionDt;
import ca.uhn.fhir.model.api.IElement;
import ca.uhn.fhir.model.api.IIdentifiableElement;
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.UndeclaredExtension;
import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.dstu.composite.ContainedDt;
import ca.uhn.fhir.model.dstu.composite.NarrativeDt;
@@ -408,7 +407,7 @@ public class JsonParser extends BaseParser implements IParser {
return this;
}
- private void addToHeldExtensions(int valueIdx, List ext, ArrayList> list) {
+ private void addToHeldExtensions(int valueIdx, List ext, ArrayList> list) {
if (ext.size() > 0) {
list.ensureCapacity(valueIdx);
while (list.size() <= valueIdx) {
@@ -417,7 +416,7 @@ public class JsonParser extends BaseParser implements IParser {
if (list.get(valueIdx) == null) {
list.set(valueIdx, new ArrayList());
}
- for (UndeclaredExtension next : ext) {
+ for (ExtensionDt next : ext) {
list.get(valueIdx).add(new HeldExtension(next));
}
}
@@ -619,7 +618,7 @@ public class JsonParser extends BaseParser implements IParser {
}
if (nextValue instanceof ISupportsUndeclaredExtensions) {
- List ext = ((ISupportsUndeclaredExtensions) nextValue).getUndeclaredExtensions();
+ List ext = ((ISupportsUndeclaredExtensions) nextValue).getUndeclaredExtensions();
addToHeldExtensions(valueIdx, ext, extensions);
ext = ((ISupportsUndeclaredExtensions) nextValue).getUndeclaredModifierExtensions();
@@ -718,7 +717,7 @@ public class JsonParser extends BaseParser implements IParser {
theEventWriter.writeEnd();
}
- private void encodeUndeclaredExtensions(RuntimeResourceDefinition theResDef, IResource theResource, JsonGenerator theWriter, List extensions, String theTagName)
+ private void encodeUndeclaredExtensions(RuntimeResourceDefinition theResDef, IResource theResource, JsonGenerator theWriter, List extensions, String theTagName)
throws IOException {
if (extensions.isEmpty()) {
return;
@@ -726,11 +725,11 @@ public class JsonParser extends BaseParser implements IParser {
theWriter.writeStartArray(theTagName);
- for (UndeclaredExtension next : extensions) {
+ for (ExtensionDt next : extensions) {
theWriter.writeStartObject();
- theWriter.write("url", next.getUrl());
+ theWriter.write("url", next.getUrl().getValue());
if (next.getValue() != null) {
IElement nextValue = next.getValue();
@@ -786,9 +785,9 @@ public class JsonParser extends BaseParser implements IParser {
private class HeldExtension {
- private UndeclaredExtension myUndeclaredExtension;
+ private ExtensionDt myUndeclaredExtension;
- public HeldExtension(UndeclaredExtension theUndeclaredExtension) {
+ public HeldExtension(ExtensionDt theUndeclaredExtension) {
myUndeclaredExtension = theUndeclaredExtension;
}
@@ -798,16 +797,16 @@ public class JsonParser extends BaseParser implements IParser {
}
}
- private void writeUndeclaredExt(RuntimeResourceDefinition theResDef, IResource theResource, JsonGenerator theEventWriter, UndeclaredExtension ext) throws IOException {
+ private void writeUndeclaredExt(RuntimeResourceDefinition theResDef, IResource theResource, JsonGenerator theEventWriter, ExtensionDt ext) throws IOException {
theEventWriter.writeStartObject();
- theEventWriter.write("url", ext.getUrl());
+ theEventWriter.write("url", ext.getUrl().getValue());
IElement value = ext.getValue();
if (value == null && ext.getAllUndeclaredExtensions().isEmpty()) {
theEventWriter.writeNull();
} else if (value == null) {
theEventWriter.writeStartArray("extension");
- for (UndeclaredExtension next : ext.getUndeclaredExtensions()) {
+ for (ExtensionDt next : ext.getUndeclaredExtensions()) {
writeUndeclaredExt(theResDef, theResource, theEventWriter, next);
}
theEventWriter.writeEnd();
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 c85257537cd..3ed4aaaa255 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
@@ -1,6 +1,6 @@
package ca.uhn.fhir.parser;
-import static org.apache.commons.lang3.StringUtils.isNotBlank;
+import static org.apache.commons.lang3.StringUtils.*;
import java.util.ArrayList;
import java.util.HashMap;
@@ -28,6 +28,7 @@ import ca.uhn.fhir.model.api.BaseBundle;
import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.api.BundleCategory;
import ca.uhn.fhir.model.api.BundleEntry;
+import ca.uhn.fhir.model.api.ExtensionDt;
import ca.uhn.fhir.model.api.ICompositeDatatype;
import ca.uhn.fhir.model.api.ICompositeElement;
import ca.uhn.fhir.model.api.IElement;
@@ -35,7 +36,6 @@ 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.UndeclaredExtension;
import ca.uhn.fhir.model.dstu.composite.ContainedDt;
import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
import ca.uhn.fhir.model.primitive.IdDt;
@@ -399,7 +399,7 @@ class ParserState {
*/
public void enteringNewElementExtension(@SuppressWarnings("unused") StartElement theElement, String theUrlAttr, boolean theIsModifier) {
if (myPreResourceState != null && getCurrentElement() instanceof ISupportsUndeclaredExtensions) {
- UndeclaredExtension newExtension = new UndeclaredExtension(theIsModifier, theUrlAttr);
+ ExtensionDt newExtension = new ExtensionDt(theIsModifier, theUrlAttr);
ISupportsUndeclaredExtensions elem = (ISupportsUndeclaredExtensions) getCurrentElement();
if (theIsModifier) {
elem.getUndeclaredModifierExtensions().add(newExtension);
@@ -672,9 +672,9 @@ class ParserState {
private class ExtensionState extends BaseState {
- private UndeclaredExtension myExtension;
+ private ExtensionDt myExtension;
- public ExtensionState(PreResourceState thePreResourceState, UndeclaredExtension theExtension) {
+ public ExtensionState(PreResourceState thePreResourceState, ExtensionDt theExtension) {
super(thePreResourceState);
myExtension = theExtension;
}
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 c658b35261d..e7e9e83df0c 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
@@ -1,7 +1,6 @@
package ca.uhn.fhir.parser;
-import static org.apache.commons.lang3.StringUtils.isBlank;
-import static org.apache.commons.lang3.StringUtils.isNotBlank;
+import static org.apache.commons.lang3.StringUtils.*;
import java.io.Reader;
import java.io.StringWriter;
@@ -38,11 +37,11 @@ import ca.uhn.fhir.context.RuntimeChildUndeclaredExtensionDefinition;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.api.BundleEntry;
+import ca.uhn.fhir.model.api.ExtensionDt;
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.UndeclaredExtension;
import ca.uhn.fhir.model.dstu.composite.ContainedDt;
import ca.uhn.fhir.model.dstu.composite.NarrativeDt;
import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
@@ -449,10 +448,10 @@ public class XmlParser extends BaseParser implements IParser {
theEventWriter.writeEndElement();
}
- private void encodeUndeclaredExtensions(RuntimeResourceDefinition theResDef, IResource theResource, XMLStreamWriter theWriter, List extensions, String tagName) throws XMLStreamException, DataFormatException {
- for (UndeclaredExtension next : extensions) {
+ private void encodeUndeclaredExtensions(RuntimeResourceDefinition theResDef, IResource theResource, XMLStreamWriter theWriter, List extensions, String tagName) throws XMLStreamException, DataFormatException {
+ for (ExtensionDt next : extensions) {
theWriter.writeStartElement(tagName);
- theWriter.writeAttribute("url", next.getUrl());
+ theWriter.writeAttribute("url", next.getUrl().getValue());
if (next.getValue() != null) {
IElement nextValue = next.getValue();
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/Create.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/Create.java
new file mode 100644
index 00000000000..b6baa8db274
--- /dev/null
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/Create.java
@@ -0,0 +1,18 @@
+package ca.uhn.fhir.rest.annotation;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+
+/**
+ * RESTful method annotation to be used for the FHIR
+ * create method.
+ *
+ *
+ * Create is used to save a new resource, allowing the server to assign a new ID and version ID.
+ *
+ */
+public @interface Create {
+ // nothing
+}
\ No newline at end of file
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/POST.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/Id.java
similarity index 51%
rename from hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/POST.java
rename to hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/Id.java
index 1c3b62bd40b..4417b05cf5a 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/POST.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/Id.java
@@ -1,10 +1,12 @@
package ca.uhn.fhir.rest.annotation;
+import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
-
-public @interface POST {
-
+@Target(ElementType.PARAMETER)
+public @interface Id {
+ // just a marker
}
\ No newline at end of file
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/Read.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/Read.java
index 104d42d9ea3..00b3d9e126a 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/Read.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/Read.java
@@ -19,17 +19,5 @@ public @interface Read {
*/
// NB: Read, Search (maybe others) share this annotation, so update the javadocs everywhere
Class extends IResource> type() default IResource.class;
-
- @Retention(RetentionPolicy.RUNTIME)
- @Target(ElementType.PARAMETER)
- public @interface IdParam {
- // just a marker
- }
-
- @Retention(RetentionPolicy.RUNTIME)
- @Target(ElementType.PARAMETER)
- public @interface VersionIdParam {
- // just a marker
- }
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/VersionId.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/VersionId.java
new file mode 100644
index 00000000000..98e74c486ea
--- /dev/null
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/VersionId.java
@@ -0,0 +1,12 @@
+package ca.uhn.fhir.rest.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.PARAMETER)
+public @interface VersionId {
+ // just a marker
+}
\ No newline at end of file
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/MethodOutcome.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/MethodOutcome.java
new file mode 100644
index 00000000000..e51060bd280
--- /dev/null
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/MethodOutcome.java
@@ -0,0 +1,35 @@
+package ca.uhn.fhir.rest.api;
+
+import ca.uhn.fhir.model.primitive.IdDt;
+
+public class MethodOutcome {
+
+ private IdDt myId;
+ private IdDt myVersionId;
+
+ public IdDt getId() {
+ return myId;
+ }
+
+ public MethodOutcome() {
+ }
+
+ public MethodOutcome(IdDt theId, IdDt theVersionId) {
+ super();
+ myId = theId;
+ myVersionId = theVersionId;
+ }
+
+ public void setId(IdDt theId) {
+ myId = theId;
+ }
+
+ public IdDt getVersionId() {
+ return myVersionId;
+ }
+
+ public void setVersionId(IdDt theVersionId) {
+ myVersionId = theVersionId;
+ }
+
+}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/ClientInvocationHandler.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/ClientInvocationHandler.java
index d2ee77e31c8..0847b21bd6f 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/ClientInvocationHandler.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/ClientInvocationHandler.java
@@ -7,9 +7,7 @@ import java.io.StringReader;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.nio.charset.Charset;
-import java.util.Collections;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import org.apache.commons.io.IOUtils;
@@ -21,27 +19,19 @@ import org.apache.http.entity.ContentType;
import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.context.FhirContext;
-import ca.uhn.fhir.model.api.Bundle;
-import ca.uhn.fhir.model.api.IResource;
-import ca.uhn.fhir.parser.IParser;
import ca.uhn.fhir.rest.client.api.IRestfulClient;
-import ca.uhn.fhir.rest.client.exceptions.InvalidResponseException;
-import ca.uhn.fhir.rest.client.exceptions.NonFhirResponseException;
import ca.uhn.fhir.rest.method.BaseMethodBinding;
-import ca.uhn.fhir.rest.server.Constants;
public class ClientInvocationHandler implements InvocationHandler {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ClientInvocationHandler.class);
private final Map myBindings = new HashMap();
private final HttpClient myClient;
- private final FhirContext myContext;
private final String myUrlBase;
private final Map myMethodToReturnValue = new HashMap();
public ClientInvocationHandler(HttpClient theClient, FhirContext theContext, String theUrlBase, Class extends IRestfulClient> theClientType) {
myClient = theClient;
- myContext = theContext;
myUrlBase = theUrlBase;
try {
@@ -83,51 +73,10 @@ public class ClientInvocationHandler implements InvocationHandler {
ContentType ct = ContentType.get(response.getEntity());
- IParser parser;
String mimeType = ct.getMimeType();
- if (Constants.CT_ATOM_XML.equals(mimeType)) {
- parser = myContext.newXmlParser();
- } else if (Constants.CT_FHIR_XML.equals(mimeType)) {
- parser = myContext.newXmlParser();
- } else {
- throw new NonFhirResponseException("Response contains non-FHIR content-type: " + mimeType, mimeType, response.getStatusLine().getStatusCode(), IOUtils.toString(reader));
- }
-
- switch (binding.getReturnType()) {
- case BUNDLE: {
- Bundle bundle = parser.parseBundle(reader);
- switch (binding.getMethodReturnType()) {
- case BUNDLE:
- return bundle;
- case LIST_OF_RESOURCES:
- return bundle.toListOfResources();
- case RESOURCE:
- List list = bundle.toListOfResources();
- if (list.size() == 0) {
- return null;
- } else if (list.size() == 1) {
- return list.get(0);
- } else {
- throw new InvalidResponseException("FHIR server call returned a bundle with multiple resources, but this method is only able to returns one.");
- }
- }
- break;
- }
- case RESOURCE: {
- IResource resource = parser.parseResource(reader);
- switch (binding.getMethodReturnType()) {
- case BUNDLE:
- return Bundle.withSingleResource(resource);
- case LIST_OF_RESOURCES:
- return Collections.singletonList(resource);
- case RESOURCE:
- return resource;
- }
- break;
- }
- }
-
- throw new IllegalStateException("Should not get here!");
+
+ return binding.invokeClient(mimeType, reader, response.getStatusLine().getStatusCode());
+
} finally {
if (response instanceof CloseableHttpResponse) {
((CloseableHttpResponse) response).close();
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/RestfulClientFactory.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/RestfulClientFactory.java
index a2cf2219218..63b9512608f 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/RestfulClientFactory.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/RestfulClientFactory.java
@@ -84,7 +84,7 @@ public class RestfulClientFactory implements IRestfulClientFactory {
}
resReturnType = (Class extends IResource>) returnTypeColl;
}
- BaseMethodBinding binding = BaseMethodBinding.bindMethod(resReturnType, nextMethod);
+ BaseMethodBinding binding = BaseMethodBinding.bindMethod(resReturnType, nextMethod, myContext);
invocationHandler.addBinding(nextMethod, binding);
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/BaseMethodBinding.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/BaseMethodBinding.java
index 9e549e23102..845d0e13c8d 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/BaseMethodBinding.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/BaseMethodBinding.java
@@ -1,58 +1,58 @@
package ca.uhn.fhir.rest.method;
+import java.io.IOException;
+import java.io.Reader;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import java.util.Map;
+
+import javax.servlet.http.HttpServletResponse;
import ca.uhn.fhir.context.ConfigurationException;
-import ca.uhn.fhir.model.api.Bundle;
+import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IResource;
-import ca.uhn.fhir.model.api.annotation.ResourceDef;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationSystemEnum;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationTypeEnum;
-import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.rest.annotation.Metadata;
import ca.uhn.fhir.rest.annotation.Read;
import ca.uhn.fhir.rest.annotation.Search;
import ca.uhn.fhir.rest.client.GetClientInvocation;
-import ca.uhn.fhir.rest.server.IResourceProvider;
+import ca.uhn.fhir.rest.server.RestfulServer;
+import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
-import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
public abstract class BaseMethodBinding {
- private String myResourceName;
- private MethodReturnTypeEnum myMethodReturnType;
+ private Method myMethod;
+ private FhirContext myContext;
- public BaseMethodBinding(MethodReturnTypeEnum theMethodReturnType, Class extends IResource> theReturnResourceType) {
- ResourceDef resourceDefAnnotation = theReturnResourceType.getAnnotation(ResourceDef.class);
- if (resourceDefAnnotation == null) {
- throw new ConfigurationException(theReturnResourceType.getCanonicalName() + " has no @" + ResourceDef.class.getSimpleName() + " annotation");
- }
- myResourceName = resourceDefAnnotation.name();
- myMethodReturnType = theMethodReturnType;
+ public BaseMethodBinding(Method theMethod, FhirContext theConetxt) {
+ assert theMethod!=null;
+ assert theConetxt!=null;
+
+ myMethod = theMethod;
+ myContext=theConetxt;
}
- public abstract ReturnTypeEnum getReturnType();
+ public FhirContext getContext() {
+ return myContext;
+ }
+
+ public Method getMethod() {
+ return myMethod;
+ }
public abstract GetClientInvocation invokeClient(Object[] theArgs) throws InternalErrorException;
- public abstract List invokeServer(IResourceProvider theResourceProvider, IdDt theId, IdDt theVersionId, Map theParameterValues) throws InvalidRequestException, InternalErrorException;
-
public abstract RestfulOperationTypeEnum getResourceOperationType();
-
+
public abstract RestfulOperationSystemEnum getSystemOperationType();
-
+
public abstract boolean matches(Request theRequest);
- public String getResourceName() {
- return myResourceName;
- }
-
- public static BaseMethodBinding bindMethod(Class extends IResource> theReturnType, Method theMethod) {
+ public static BaseMethodBinding bindMethod(Class extends IResource> theReturnType, Method theMethod, FhirContext theContext) {
Read read = theMethod.getAnnotation(Read.class);
Search search = theMethod.getAnnotation(Search.class);
Metadata conformance = theMethod.getAnnotation(Metadata.class);
@@ -60,18 +60,6 @@ public abstract class BaseMethodBinding {
return null;
}
- Class> methodReturnType = theMethod.getReturnType();
- MethodReturnTypeEnum methodReturnTypeEnum;
- if (Collection.class.isAssignableFrom(methodReturnType)) {
- methodReturnTypeEnum = MethodReturnTypeEnum.LIST_OF_RESOURCES;
- } else if (IResource.class.isAssignableFrom(methodReturnType)) {
- methodReturnTypeEnum = MethodReturnTypeEnum.RESOURCE;
- } else if (Bundle.class.isAssignableFrom(methodReturnType)) {
- methodReturnTypeEnum = MethodReturnTypeEnum.BUNDLE;
- } else {
- throw new ConfigurationException("Invalid return type '" + methodReturnType.getCanonicalName() + "' on method '" + theMethod.getName() + "' on type: " + theMethod.getDeclaringClass().getCanonicalName());
- }
-
Class extends IResource> returnType = theReturnType;
if (returnType == null) {
if (read != null) {
@@ -84,14 +72,14 @@ public abstract class BaseMethodBinding {
throw new ConfigurationException("Could not determine return type for method '" + theMethod.getName() + "'. Try explicitly specifying one in the operation annotation.");
}
}
-
+
if (read != null) {
- return new ReadMethodBinding(methodReturnTypeEnum, returnType, theMethod);
+ return new ReadMethodBinding(returnType, theMethod, theContext);
} else if (search != null) {
String queryName = search.queryName();
- return new SearchMethodBinding(methodReturnTypeEnum, returnType, theMethod, queryName);
+ return new SearchMethodBinding(returnType, theMethod, queryName,theContext);
} else if (conformance != null) {
- return new ConformanceMethodBinding(methodReturnTypeEnum, returnType, theMethod);
+ return new ConformanceMethodBinding(theMethod, theContext);
} else {
throw new ConfigurationException("Did not detect any FHIR annotations on method '" + theMethod.getName() + "' on type: " + theMethod.getDeclaringClass().getCanonicalName());
}
@@ -118,8 +106,6 @@ public abstract class BaseMethodBinding {
// return sm;
}
-
-
public static boolean verifyMethodHasZeroOrOneOperationAnnotation(Method theNextMethod, Object... theAnnotations) {
Object obj1 = null;
for (Object object : theAnnotations) {
@@ -159,15 +145,10 @@ public abstract class BaseMethodBinding {
}
}
- public enum MethodReturnTypeEnum {
- RESOURCE, BUNDLE, LIST_OF_RESOURCES
- }
- public enum ReturnTypeEnum {
- BUNDLE, RESOURCE
- }
- public MethodReturnTypeEnum getMethodReturnType() {
- return myMethodReturnType;
- }
+ public abstract void invokeServer(RestfulServer theServer, Request theRequest, HttpServletResponse theResponse) throws BaseServerResponseException, IOException;
+
+ public abstract Object invokeClient(String theResponseMimeType, Reader theResponseReader, int theResponseStatusCode) throws IOException;
+
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/BaseResourceReturningMethodBinding.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/BaseResourceReturningMethodBinding.java
new file mode 100644
index 00000000000..97d0f553d5f
--- /dev/null
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/BaseResourceReturningMethodBinding.java
@@ -0,0 +1,336 @@
+package ca.uhn.fhir.rest.method;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import ca.uhn.fhir.context.ConfigurationException;
+import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.context.RuntimeResourceDefinition;
+import ca.uhn.fhir.model.api.Bundle;
+import ca.uhn.fhir.model.api.BundleEntry;
+import ca.uhn.fhir.model.api.IResource;
+import ca.uhn.fhir.model.api.annotation.ResourceDef;
+import ca.uhn.fhir.model.primitive.IdDt;
+import ca.uhn.fhir.parser.IParser;
+import ca.uhn.fhir.rest.client.exceptions.InvalidResponseException;
+import ca.uhn.fhir.rest.client.exceptions.NonFhirResponseException;
+import ca.uhn.fhir.rest.server.Constants;
+import ca.uhn.fhir.rest.server.EncodingUtil;
+import ca.uhn.fhir.rest.server.IResourceProvider;
+import ca.uhn.fhir.rest.server.RestfulServer;
+import ca.uhn.fhir.rest.server.RestfulServer.NarrativeModeEnum;
+import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
+import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
+import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
+import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
+
+public abstract class BaseResourceReturningMethodBinding extends BaseMethodBinding {
+
+ protected static final Set ALLOWED_PARAMS;
+ private MethodReturnTypeEnum myMethodReturnType;
+ private String myResourceName;
+
+ public BaseResourceReturningMethodBinding(Class extends IResource> theReturnResourceType, Method theMethod, FhirContext theConetxt) {
+ super(theMethod, theConetxt);
+
+ Class> methodReturnType = theMethod.getReturnType();
+ if (Collection.class.isAssignableFrom(methodReturnType)) {
+ myMethodReturnType = MethodReturnTypeEnum.LIST_OF_RESOURCES;
+ } else if (IResource.class.isAssignableFrom(methodReturnType)) {
+ myMethodReturnType = MethodReturnTypeEnum.RESOURCE;
+ } else if (Bundle.class.isAssignableFrom(methodReturnType)) {
+ myMethodReturnType = MethodReturnTypeEnum.BUNDLE;
+ } else {
+ throw new ConfigurationException("Invalid return type '" + methodReturnType.getCanonicalName() + "' on method '" + theMethod.getName() + "' on type: " + theMethod.getDeclaringClass().getCanonicalName());
+ }
+
+ ResourceDef resourceDefAnnotation = theReturnResourceType.getAnnotation(ResourceDef.class);
+ if (resourceDefAnnotation == null) {
+ throw new ConfigurationException(theReturnResourceType.getCanonicalName() + " has no @" + ResourceDef.class.getSimpleName() + " annotation");
+ }
+ myResourceName = resourceDefAnnotation.name();
+ }
+
+ public MethodReturnTypeEnum getMethodReturnType() {
+ return myMethodReturnType;
+ }
+
+ public String getResourceName() {
+ return myResourceName;
+ }
+
+ public abstract ReturnTypeEnum getReturnType();
+
+ @Override
+ public Object invokeClient(String theResponseMimeType, Reader theResponseReader, int theResponseStatusCode) throws IOException {
+ IParser parser;
+ if (Constants.CT_ATOM_XML.equals(theResponseMimeType)) {
+ parser = getContext().newXmlParser();
+ } else if (Constants.CT_FHIR_XML.equals(theResponseMimeType)) {
+ parser = getContext().newXmlParser();
+ } else {
+ throw new NonFhirResponseException("Response contains non-FHIR content-type: " + theResponseMimeType, theResponseMimeType, theResponseStatusCode, IOUtils.toString(theResponseReader));
+ }
+
+ switch (getReturnType()) {
+ case BUNDLE: {
+ Bundle bundle = parser.parseBundle(theResponseReader);
+ switch (getMethodReturnType()) {
+ case BUNDLE:
+ return bundle;
+ case LIST_OF_RESOURCES:
+ return bundle.toListOfResources();
+ case RESOURCE:
+ List list = bundle.toListOfResources();
+ if (list.size() == 0) {
+ return null;
+ } else if (list.size() == 1) {
+ return list.get(0);
+ } else {
+ throw new InvalidResponseException("FHIR server call returned a bundle with multiple resources, but this method is only able to returns one.");
+ }
+ }
+ break;
+ }
+ case RESOURCE: {
+ IResource resource = parser.parseResource(theResponseReader);
+ switch (getMethodReturnType()) {
+ case BUNDLE:
+ return Bundle.withSingleResource(resource);
+ case LIST_OF_RESOURCES:
+ return Collections.singletonList(resource);
+ case RESOURCE:
+ return resource;
+ }
+ break;
+ }
+ }
+
+ throw new IllegalStateException("Should not get here!");
+ }
+
+ public abstract List invokeServer(IResourceProvider theResourceProvider, IdDt theId, IdDt theVersionId, Map theParameterValues) throws InvalidRequestException, InternalErrorException;
+
+ @Override
+ public void invokeServer(RestfulServer theServer, Request theRequest, HttpServletResponse theResponse) throws BaseServerResponseException, IOException {
+
+ // Pretty print
+ Map params = theRequest.getParameters();
+ String[] pretty = params.remove(Constants.PARAM_PRETTY);
+ boolean prettyPrint = false;
+ if (pretty != null && pretty.length > 0) {
+ if ("true".equals(pretty[0])) {
+ prettyPrint = true;
+ }
+ }
+
+ // Narrative mode
+ String[] narrative = params.remove(Constants.PARAM_NARRATIVE);
+ NarrativeModeEnum narrativeMode = null;
+ if (narrative != null && narrative.length > 0) {
+ narrativeMode = NarrativeModeEnum.valueOfCaseInsensitive(narrative[0]);
+ }
+ if (narrativeMode == null) {
+ narrativeMode = NarrativeModeEnum.NORMAL;
+ }
+
+ // Determine response encoding
+ EncodingUtil responseEncoding = determineResponseEncoding(theRequest.getServletRequest(), params);
+
+ // Is this request coming from a browser
+ String uaHeader = theRequest.getServletRequest().getHeader("user-agent");
+ boolean requestIsBrowser = false;
+ if (uaHeader != null && uaHeader.contains("Mozilla")) {
+ requestIsBrowser = true;
+ }
+
+ List result = invokeServer(theRequest.getResourceProvider(), theRequest.getId(), theRequest.getVersion(), theRequest.getParameters());
+ switch (getReturnType()) {
+ case BUNDLE:
+ streamResponseAsBundle(theServer, theResponse, result, responseEncoding, theRequest.getFhirServerBase(), theRequest.getCompleteUrl(), prettyPrint, requestIsBrowser, narrativeMode);
+ break;
+ case RESOURCE:
+ if (result.size() == 0) {
+ throw new ResourceNotFoundException(theRequest.getId());
+ } else if (result.size() > 1) {
+ throw new InternalErrorException("Method returned multiple resources");
+ }
+ streamResponseAsResource(theServer, theResponse, result.get(0), responseEncoding, prettyPrint, requestIsBrowser, narrativeMode);
+ break;
+ }
+ }
+
+ private EncodingUtil determineResponseEncoding(HttpServletRequest theRequest, Map theParams) {
+ String[] format = theParams.remove(Constants.PARAM_FORMAT);
+ if (format != null) {
+ for (String nextFormat : format) {
+ EncodingUtil retVal = Constants.FORMAT_VAL_TO_ENCODING.get(nextFormat);
+ if (retVal != null) {
+ return retVal;
+ }
+ }
+ }
+
+ Enumeration acceptValues = theRequest.getHeaders("Accept");
+ if (acceptValues != null) {
+ while (acceptValues.hasMoreElements()) {
+ EncodingUtil retVal = Constants.FORMAT_VAL_TO_ENCODING.get(acceptValues.nextElement());
+ if (retVal != null) {
+ return retVal;
+ }
+ }
+ }
+ return EncodingUtil.XML;
+ }
+
+ static {
+ HashSet set = new HashSet();
+ set.add(Constants.PARAM_FORMAT);
+ set.add(Constants.PARAM_NARRATIVE);
+ set.add(Constants.PARAM_PRETTY);
+ ALLOWED_PARAMS = Collections.unmodifiableSet(set);
+ }
+
+ private IParser getNewParser(EncodingUtil theResponseEncoding, boolean thePrettyPrint, NarrativeModeEnum theNarrativeMode) {
+ IParser parser;
+ switch (theResponseEncoding) {
+ case JSON:
+ parser = getContext().newJsonParser();
+ break;
+ case XML:
+ default:
+ parser = getContext().newXmlParser();
+ break;
+ }
+ return parser.setPrettyPrint(thePrettyPrint).setSuppressNarratives(theNarrativeMode == NarrativeModeEnum.SUPPRESS);
+ }
+
+ private void streamResponseAsBundle(RestfulServer theServer, HttpServletResponse theHttpResponse, List theResult, EncodingUtil theResponseEncoding, String theServerBase, String theCompleteUrl, boolean thePrettyPrint, boolean theRequestIsBrowser,
+ NarrativeModeEnum theNarrativeMode) throws IOException {
+ assert !theServerBase.endsWith("/");
+
+ theHttpResponse.setStatus(200);
+
+ if (theRequestIsBrowser && theServer.isUseBrowserFriendlyContentTypes()) {
+ theHttpResponse.setContentType(theResponseEncoding.getBrowserFriendlyBundleContentType());
+ } else if (theNarrativeMode == NarrativeModeEnum.ONLY) {
+ theHttpResponse.setContentType(Constants.CT_HTML);
+ } else {
+ theHttpResponse.setContentType(theResponseEncoding.getBundleContentType());
+ }
+
+ theHttpResponse.setCharacterEncoding("UTF-8");
+
+ Bundle bundle = new Bundle();
+ bundle.getAuthorName().setValue(getClass().getCanonicalName());
+ bundle.getBundleId().setValue(UUID.randomUUID().toString());
+ bundle.getPublished().setToCurrentTimeInLocalTimeZone();
+ bundle.getLinkBase().setValue(theServerBase);
+ bundle.getLinkSelf().setValue(theCompleteUrl);
+
+ for (IResource next : theResult) {
+ BundleEntry entry = new BundleEntry();
+ bundle.getEntries().add(entry);
+
+ entry.setResource(next);
+
+ RuntimeResourceDefinition def = getContext().getResourceDefinition(next);
+
+ if (next.getId() != null && StringUtils.isNotBlank(next.getId().getValue())) {
+ entry.getEntryId().setValue(next.getId().getValue());
+ entry.getTitle().setValue(def.getName() + " " + next.getId().getValue());
+
+ StringBuilder b = new StringBuilder();
+ b.append(theServerBase);
+ b.append('/');
+ b.append(def.getName());
+ b.append('/');
+ b.append(next.getId().getValue());
+ boolean haveQ = false;
+ if (thePrettyPrint) {
+ b.append('?').append(Constants.PARAM_PRETTY).append("=true");
+ haveQ = true;
+ }
+ if (theResponseEncoding == EncodingUtil.JSON) {
+ if (!haveQ) {
+ b.append('?');
+ haveQ = true;
+ } else {
+ b.append('&');
+ }
+ b.append(Constants.PARAM_FORMAT).append("=json");
+ }
+ if (theNarrativeMode != NarrativeModeEnum.NORMAL) {
+ b.append(Constants.PARAM_NARRATIVE).append("=").append(theNarrativeMode.name().toLowerCase());
+ }
+ entry.getLinkSelf().setValue(b.toString());
+ }
+ }
+
+ bundle.getTotalResults().setValue(theResult.size());
+
+ PrintWriter writer = theHttpResponse.getWriter();
+ try {
+ if (theNarrativeMode == NarrativeModeEnum.ONLY) {
+ for (IResource next : theResult) {
+ writer.append(next.getText().getDiv().getValueAsString());
+ writer.append("
");
+ }
+ } else {
+ getNewParser(theResponseEncoding, thePrettyPrint, theNarrativeMode).encodeBundleToWriter(bundle, writer);
+ }
+ } finally {
+ writer.close();
+ }
+ }
+
+ private void streamResponseAsResource(RestfulServer theServer, HttpServletResponse theHttpResponse, IResource theResource, EncodingUtil theResponseEncoding, boolean thePrettyPrint, boolean theRequestIsBrowser, NarrativeModeEnum theNarrativeMode) throws IOException {
+
+ theHttpResponse.setStatus(200);
+ if (theRequestIsBrowser && theServer.isUseBrowserFriendlyContentTypes()) {
+ theHttpResponse.setContentType(theResponseEncoding.getBrowserFriendlyBundleContentType());
+ } else if (theNarrativeMode == NarrativeModeEnum.ONLY) {
+ theHttpResponse.setContentType(Constants.CT_HTML);
+ } else {
+ theHttpResponse.setContentType(theResponseEncoding.getResourceContentType());
+ }
+ theHttpResponse.setCharacterEncoding("UTF-8");
+
+ PrintWriter writer = theHttpResponse.getWriter();
+ try {
+ if (theNarrativeMode == NarrativeModeEnum.ONLY) {
+ writer.append(theResource.getText().getDiv().getValueAsString());
+ } else {
+ getNewParser(theResponseEncoding, thePrettyPrint, theNarrativeMode).encodeResourceToWriter(theResource, writer);
+ }
+ } finally {
+ writer.close();
+ }
+
+ }
+
+ public enum MethodReturnTypeEnum {
+ BUNDLE, LIST_OF_RESOURCES, RESOURCE
+ }
+
+ public enum ReturnTypeEnum {
+ BUNDLE, RESOURCE
+ }
+
+}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/ConformanceMethodBinding.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/ConformanceMethodBinding.java
index 64cfd17fab4..c102cfff752 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/ConformanceMethodBinding.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/ConformanceMethodBinding.java
@@ -6,6 +6,7 @@ import java.util.List;
import java.util.Map;
import ca.uhn.fhir.context.ConfigurationException;
+import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.dstu.resource.Conformance;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationSystemEnum;
@@ -17,18 +18,14 @@ import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
-public class ConformanceMethodBinding extends BaseMethodBinding {
+public class ConformanceMethodBinding extends BaseResourceReturningMethodBinding {
- private Method myMethod;
-
- public ConformanceMethodBinding(MethodReturnTypeEnum theMethodReturnType, Class extends IResource> theReturnType, Method theMethod) {
- super(theMethodReturnType, Conformance.class);
+ public ConformanceMethodBinding(Method theMethod, FhirContext theContext) {
+ super(Conformance.class, theMethod, theContext);
- if (theMethodReturnType != MethodReturnTypeEnum.RESOURCE) {
+ if (getMethodReturnType() != MethodReturnTypeEnum.RESOURCE) {
throw new ConfigurationException("Conformance resource provider '" + theMethod.getName() + "' should return type " + Conformance.class);
}
-
- myMethod = theMethod;
}
@Override
@@ -45,7 +42,7 @@ public class ConformanceMethodBinding extends BaseMethodBinding {
public List invokeServer(IResourceProvider theResourceProvider, IdDt theId, IdDt theVersionId, Map theParameterValues) throws InvalidRequestException, InternalErrorException {
IResource conf;
try {
- conf = (Conformance) myMethod.invoke(theResourceProvider);
+ conf = (Conformance) getMethod().invoke(theResourceProvider);
} catch (Exception e) {
throw new InternalErrorException("Failed to call access method",e);
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/CreateMethodBinding.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/CreateMethodBinding.java
new file mode 100644
index 00000000000..123d9f962e7
--- /dev/null
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/CreateMethodBinding.java
@@ -0,0 +1,70 @@
+package ca.uhn.fhir.rest.method;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.lang.reflect.Method;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang3.StringUtils;
+
+import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.model.dstu.valueset.RestfulOperationSystemEnum;
+import ca.uhn.fhir.model.dstu.valueset.RestfulOperationTypeEnum;
+import ca.uhn.fhir.rest.client.GetClientInvocation;
+import ca.uhn.fhir.rest.method.SearchMethodBinding.RequestType;
+import ca.uhn.fhir.rest.server.RestfulServer;
+import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
+import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
+
+public class CreateMethodBinding extends BaseMethodBinding {
+
+ public CreateMethodBinding(Method theMethod, FhirContext theContext) {
+ super(theMethod, theContext);
+ }
+
+ @Override
+ public GetClientInvocation invokeClient(Object[] theArgs) throws InternalErrorException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+
+ @Override
+ public RestfulOperationTypeEnum getResourceOperationType() {
+ return RestfulOperationTypeEnum.CREATE;
+ }
+
+ @Override
+ public RestfulOperationSystemEnum getSystemOperationType() {
+ return null;
+ }
+
+ @Override
+ public boolean matches(Request theRequest) {
+ if (theRequest.getRequestType()!= RequestType.POST) {
+ return false;
+ }
+ if (StringUtils.isBlank(theRequest.getResourceName())) {
+ return false;
+ }
+ if (StringUtils.isNotBlank(theRequest.getOperation())) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public void invokeServer(RestfulServer theServer, Request theRequest, HttpServletResponse theResponse) throws BaseServerResponseException, IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Object invokeClient(String theResponseMimeType, Reader theResponseReader, int theResponseStatusCode) throws IOException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/ReadMethodBinding.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/ReadMethodBinding.java
index bf8aaaf5e95..03980f2c326 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/ReadMethodBinding.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/ReadMethodBinding.java
@@ -7,6 +7,7 @@ import java.util.Map;
import org.apache.commons.lang3.Validate;
import ca.uhn.fhir.context.ConfigurationException;
+import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationSystemEnum;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationTypeEnum;
@@ -18,26 +19,24 @@ import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
-public class ReadMethodBinding extends BaseMethodBinding {
+public class ReadMethodBinding extends BaseResourceReturningMethodBinding {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ReadMethodBinding.class);
- private Method myMethod;
private Integer myIdIndex;
private Integer myVersionIdIndex;
private int myParameterCount;
- public ReadMethodBinding(MethodReturnTypeEnum theMethodReturnType, Class extends IResource> theAnnotatedResourceType, Method theMethod) {
- super(theMethodReturnType, theAnnotatedResourceType);
+ public ReadMethodBinding(Class extends IResource> theAnnotatedResourceType, Method theMethod, FhirContext theContext) {
+ super( theAnnotatedResourceType, theMethod, theContext);
Validate.notNull(theMethod, "Method must not be null");
Integer idIndex = Util.findReadIdParameterIndex(theMethod);
Integer versionIdIndex = Util.findReadVersionIdParameterIndex(theMethod);
- myMethod = theMethod;
myIdIndex = idIndex;
myVersionIdIndex = versionIdIndex;
- myParameterCount = myMethod.getParameterTypes().length;
+ myParameterCount = getMethod().getParameterTypes().length;
Class>[] parameterTypes = theMethod.getParameterTypes();
if (!IdDt.class.equals(parameterTypes[myIdIndex])) {
@@ -58,8 +57,10 @@ public class ReadMethodBinding extends BaseMethodBinding {
if (!theRequest.getResourceName().equals(getResourceName())) {
return false;
}
- if (theRequest.getParameterNames().isEmpty() == false) {
- return false;
+ for (String next : theRequest.getParameters().keySet()) {
+ if (!ALLOWED_PARAMS.contains(next)) {
+ return false;
+ }
}
if ((theRequest.getVersion() == null) != (myVersionIdIndex == null)) {
return false;
@@ -90,7 +91,7 @@ public class ReadMethodBinding extends BaseMethodBinding {
Object response;
try {
- response = myMethod.invoke(theResourceProvider, params);
+ response = getMethod().invoke(theResourceProvider, params);
} catch (Exception e) {
throw new InternalErrorException("Failed to call access method",e);
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/Request.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/Request.java
index e29db2af696..7d1519fbdf5 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/Request.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/Request.java
@@ -1,31 +1,52 @@
package ca.uhn.fhir.rest.method;
+import java.io.Reader;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+import javax.servlet.http.HttpServletRequest;
+
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.rest.method.SearchMethodBinding.RequestType;
+import ca.uhn.fhir.rest.server.IResourceProvider;
public class Request {
+ private String myCompleteUrl;
+ private String myFhirServerBase;
private IdDt myId;
+ private Reader myInputReader;
private String myOperation;
- private Map myParameterNames;
+ private Map myParameters;
private RequestType myRequestType;
private String myResourceName;
+ private IResourceProvider myResourceProvider;
private IdDt myVersion;
+ private HttpServletRequest myServletRequest;
+
+ public String getCompleteUrl() {
+ return myCompleteUrl;
+ }
+
+ public String getFhirServerBase() {
+ return myFhirServerBase;
+ }
public IdDt getId() {
return myId;
}
+ public Reader getInputReader() {
+ return myInputReader;
+ }
+
public String getOperation() {
return myOperation;
}
- public Map getParameterNames() {
- return myParameterNames;
+ public Map getParameters() {
+ return myParameters;
}
public RequestType getRequestType() {
@@ -36,22 +57,40 @@ public class Request {
return myResourceName;
}
+ public IResourceProvider getResourceProvider() {
+ return myResourceProvider;
+ }
+
public IdDt getVersion() {
return myVersion;
}
+
+ public void setCompleteUrl(String theCompleteUrl) {
+ myCompleteUrl=theCompleteUrl;
+ }
+
+ public void setFhirServerBase(String theFhirServerBase) {
+ myFhirServerBase=theFhirServerBase;
+ }
+
public void setId(IdDt theId) {
myId = theId;
}
+ public void setInputReader(Reader theReader) {
+ myInputReader=theReader;
+ }
+
public void setOperation(String theOperation) {
myOperation = theOperation;
}
- public void setParameterNames(Map theParams) {
- myParameterNames = theParams;
+ public void setParameters(Map theParams) {
+ myParameters = theParams;
}
+
public void setRequestType(RequestType theRequestType) {
myRequestType = theRequestType;
}
@@ -60,6 +99,10 @@ public class Request {
myResourceName = theResourceName;
}
+ public void setResourceProvider(IResourceProvider theResourceProvider) {
+ myResourceProvider=theResourceProvider;
+ }
+
public void setVersion(IdDt theVersion) {
myVersion = theVersion;
}
@@ -72,8 +115,16 @@ public class Request {
for (String next : theParamNames) {
paramNames.put(next, new String[0]);
}
- retVal.setParameterNames(paramNames);
+ retVal.setParameters(paramNames);
return retVal;
}
+ public void setServletRequest(HttpServletRequest theRequest) {
+ myServletRequest=theRequest;
+ }
+
+ public HttpServletRequest getServletRequest() {
+ return myServletRequest;
+ }
+
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/SearchMethodBinding.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/SearchMethodBinding.java
index f83019d321d..53ecf5bd6ee 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/SearchMethodBinding.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/SearchMethodBinding.java
@@ -12,6 +12,7 @@ import java.util.Set;
import org.apache.commons.lang3.StringUtils;
+import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationSystemEnum;
import ca.uhn.fhir.model.dstu.valueset.RestfulOperationTypeEnum;
@@ -27,17 +28,15 @@ import ca.uhn.fhir.util.QueryUtil;
/**
* Created by dsotnikov on 2/25/2014.
*/
-public class SearchMethodBinding extends BaseMethodBinding {
+public class SearchMethodBinding extends BaseResourceReturningMethodBinding {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SearchMethodBinding.class);
- private Method myMethod;
private Class> myDeclaredResourceType;
private List myParameters;
private String myQueryName;
- public SearchMethodBinding(MethodReturnTypeEnum theMethodReturnTypeEnum, Class extends IResource> theReturnResourceType, Method theMethod, String theQueryName) {
- super(theMethodReturnTypeEnum, theReturnResourceType);
- this.myMethod = theMethod;
+ public SearchMethodBinding(Class extends IResource> theReturnResourceType, Method theMethod, String theQueryName, FhirContext theContext) {
+ super(theReturnResourceType, theMethod, theContext);
this.myParameters = Util.getResourceParameters(theMethod);
this.myQueryName = StringUtils.defaultIfBlank(theQueryName, null);
this.myDeclaredResourceType = theMethod.getReturnType();
@@ -47,19 +46,25 @@ public class SearchMethodBinding extends BaseMethodBinding {
return myDeclaredResourceType.getClass();
}
- public Method getMethod() {
- return myMethod;
- }
-
public List getParameters() {
return myParameters;
}
+ @Override
+ public RestfulOperationTypeEnum getResourceOperationType() {
+ return RestfulOperationTypeEnum.SEARCH_TYPE;
+ }
+
@Override
public ReturnTypeEnum getReturnType() {
return ReturnTypeEnum.BUNDLE;
}
+ @Override
+ public RestfulOperationSystemEnum getSystemOperationType() {
+ return null;
+ }
+
@Override
public GetClientInvocation invokeClient(Object[] theArgs) throws InternalErrorException {
assert (myQueryName == null || ((theArgs != null ? theArgs.length : 0) == myParameters.size())) : "Wrong number of arguments: " + theArgs;
@@ -135,7 +140,7 @@ public class SearchMethodBinding extends BaseMethodBinding {
Object response;
try {
- response = this.myMethod.invoke(theResourceProvider, params);
+ response = this.getMethod().invoke(theResourceProvider, params);
} catch (IllegalAccessException e) {
throw new InternalErrorException(e);
} catch (IllegalArgumentException e) {
@@ -151,7 +156,7 @@ public class SearchMethodBinding extends BaseMethodBinding {
@Override
public boolean matches(Request theRequest) {
if (!theRequest.getResourceName().equals(getResourceName())) {
- ourLog.trace("Method {} doesn't match because resource name {} != {}", myMethod.getName(), theRequest.getResourceName(), getResourceName());
+ ourLog.trace("Method {} doesn't match because resource name {} != {}", getMethod().getName(), theRequest.getResourceName(), getResourceName());
return false;
}
if (theRequest.getId() != null || theRequest.getVersion() != null) {
@@ -171,13 +176,13 @@ public class SearchMethodBinding extends BaseMethodBinding {
for (int i = 0; i < this.myParameters.size(); i++) {
IParameter temp = this.myParameters.get(i);
methodParamsTemp.add(temp.getName());
- if (temp.isRequired() && !theRequest.getParameterNames().containsKey(temp.getName())) {
- ourLog.trace("Method {} doesn't match param '{}' is not present", myMethod.getName(), temp.getName());
+ if (temp.isRequired() && !theRequest.getParameters().containsKey(temp.getName())) {
+ ourLog.trace("Method {} doesn't match param '{}' is not present", getMethod().getName(), temp.getName());
return false;
}
}
if (myQueryName != null) {
- String[] queryNameValues = theRequest.getParameterNames().get(Constants.PARAM_QUERY);
+ String[] queryNameValues = theRequest.getParameters().get(Constants.PARAM_QUERY);
if (queryNameValues != null && StringUtils.isNotBlank(queryNameValues[0])) {
String queryName = queryNameValues[0];
if (!myQueryName.equals(queryName)) {
@@ -191,17 +196,18 @@ public class SearchMethodBinding extends BaseMethodBinding {
return false;
}
}
- boolean retVal = methodParamsTemp.containsAll(theRequest.getParameterNames().keySet());
+ for (String next : theRequest.getParameters().keySet()) {
+ if (ALLOWED_PARAMS.contains(next)) {
+ methodParamsTemp.add(next);
+ }
+ }
+ boolean retVal = methodParamsTemp.containsAll(theRequest.getParameters().keySet());
- ourLog.trace("Method {} matches: {}", myMethod.getName(), retVal);
+ ourLog.trace("Method {} matches: {}", getMethod().getName(), retVal);
return retVal;
}
- public void setMethod(Method method) {
- this.myMethod = method;
- }
-
public void setParameters(List parameters) {
this.myParameters = parameters;
}
@@ -211,17 +217,7 @@ public class SearchMethodBinding extends BaseMethodBinding {
}
public static enum RequestType {
- DELETE, GET, POST, PUT, OPTIONS
- }
-
- @Override
- public RestfulOperationTypeEnum getResourceOperationType() {
- return RestfulOperationTypeEnum.SEARCH_TYPE;
- }
-
- @Override
- public RestfulOperationSystemEnum getSystemOperationType() {
- return null;
+ DELETE, GET, OPTIONS, POST, PUT
}
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/Util.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/Util.java
index 64517e67b32..2c286ff574f 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/Util.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/Util.java
@@ -12,10 +12,11 @@ import java.util.Map;
import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.model.api.PathSpecification;
+import ca.uhn.fhir.rest.annotation.Id;
import ca.uhn.fhir.rest.annotation.Include;
import ca.uhn.fhir.rest.annotation.Optional;
-import ca.uhn.fhir.rest.annotation.Read;
import ca.uhn.fhir.rest.annotation.Required;
+import ca.uhn.fhir.rest.annotation.VersionId;
import ca.uhn.fhir.rest.param.CollectionBinder;
import ca.uhn.fhir.rest.param.IParameter;
import ca.uhn.fhir.rest.param.IncludeParameter;
@@ -107,11 +108,11 @@ class Util {
}
public static Integer findReadIdParameterIndex(Method theMethod) {
- return findParamIndex(theMethod, Read.IdParam.class);
+ return findParamIndex(theMethod, Id.class);
}
public static Integer findReadVersionIdParameterIndex(Method theMethod) {
- return findParamIndex(theMethod, Read.VersionIdParam.class);
+ return findParamIndex(theMethod, VersionId.class);
}
private static Integer findParamIndex(Method theMethod, Class> toFind) {
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/EncodingUtil.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/EncodingUtil.java
index ce2430b3bad..65cbb3f6977 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/EncodingUtil.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/EncodingUtil.java
@@ -1,6 +1,6 @@
package ca.uhn.fhir.rest.server;
-enum EncodingUtil {
+public enum EncodingUtil {
XML(Constants.CT_FHIR_XML, Constants.CT_ATOM_XML, Constants.CT_XML),
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 d6713e85609..29ea61bd76f 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
@@ -1,16 +1,12 @@
package ca.uhn.fhir.rest.server;
import java.io.IOException;
-import java.io.PrintWriter;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Collection;
-import java.util.Enumeration;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
-import java.util.UUID;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
@@ -21,12 +17,9 @@ import org.apache.commons.lang3.StringUtils;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
-import ca.uhn.fhir.model.api.Bundle;
-import ca.uhn.fhir.model.api.BundleEntry;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.narrative.INarrativeGenerator;
-import ca.uhn.fhir.parser.IParser;
import ca.uhn.fhir.rest.method.BaseMethodBinding;
import ca.uhn.fhir.rest.method.Request;
import ca.uhn.fhir.rest.method.SearchMethodBinding;
@@ -35,7 +28,6 @@ import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.MethodNotFoundException;
-import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import ca.uhn.fhir.rest.server.provider.ServerConformanceProvider;
import ca.uhn.fhir.rest.server.provider.ServerProfileProvider;
@@ -47,133 +39,22 @@ public abstract class RestfulServer extends HttpServlet {
private static final long serialVersionUID = 1L;
private FhirContext myFhirContext;
- private boolean myUseBrowserFriendlyContentTypes;
+
private INarrativeGenerator myNarrativeGenerator;
-
- public INarrativeGenerator getNarrativeGenerator() {
- return myNarrativeGenerator;
- }
-
- /**
- * Sets the {@link INarrativeGenerator Narrative Generator} to use when serializing responses from this server, or null
(which is the default) to disable narrative generation.
- *
- * @throws IllegalStateException
- * Note that this method can only be called prior to {@link #init() initialization} and will throw an {@link IllegalStateException} if called after that.
- */
- public void setNarrativeGenerator(INarrativeGenerator theNarrativeGenerator) {
- if (myFhirContext != null) {
- throw new IllegalStateException("Server has already been initialized, can not change this property");
- }
- myNarrativeGenerator = theNarrativeGenerator;
- }
-
- /**
- * If set to true
(default is false), the server will use browser friendly content-types (instead of standard FHIR ones) when it detects that the request is coming from a browser
- * instead of a FHIR
- */
- public void setUseBrowserFriendlyContentTypes(boolean theUseBrowserFriendlyContentTypes) {
- myUseBrowserFriendlyContentTypes = theUseBrowserFriendlyContentTypes;
- }
-
private Map, IResourceProvider> myTypeToProvider = new HashMap, IResourceProvider>();
+ private boolean myUseBrowserFriendlyContentTypes;
// map of request handler resources keyed by resource name
private Map resources = new HashMap();
private ISecurityManager securityManager;
- private EncodingUtil determineResponseEncoding(HttpServletRequest theRequest, Map theParams) {
- String[] format = theParams.remove(Constants.PARAM_FORMAT);
- if (format != null) {
- for (String nextFormat : format) {
- EncodingUtil retVal = Constants.FORMAT_VAL_TO_ENCODING.get(nextFormat);
- if (retVal != null) {
- return retVal;
- }
- }
- }
-
- Enumeration acceptValues = theRequest.getHeaders("Accept");
- if (acceptValues != null) {
- while (acceptValues.hasMoreElements()) {
- EncodingUtil retVal = Constants.FORMAT_VAL_TO_ENCODING.get(acceptValues.nextElement());
- if (retVal != null) {
- return retVal;
- }
- }
- }
- return EncodingUtil.XML;
- }
-
- @Override
- protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- handleRequest(SearchMethodBinding.RequestType.DELETE, request, response);
- }
-
- @Override
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- handleRequest(SearchMethodBinding.RequestType.GET, request, response);
- }
-
- @Override
- protected void doOptions(HttpServletRequest theReq, HttpServletResponse theResp) throws ServletException, IOException {
- handleRequest(SearchMethodBinding.RequestType.OPTIONS, theReq, theResp);
- }
-
- @Override
- protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- handleRequest(SearchMethodBinding.RequestType.POST, request, response);
- }
-
- @Override
- protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- handleRequest(SearchMethodBinding.RequestType.PUT, request, response);
- }
-
- private void findResourceMethods(IResourceProvider theProvider) throws Exception {
-
- Class extends IResource> resourceType = theProvider.getResourceType();
- RuntimeResourceDefinition definition = myFhirContext.getResourceDefinition(resourceType);
-
- ResourceBinding r = new ResourceBinding();
- r.setResourceProvider(theProvider);
- r.setResourceName(definition.getName());
- resources.put(definition.getName(), r);
-
- ourLog.info("Scanning type for RESTful methods: {}", theProvider.getClass());
-
- Class> clazz = theProvider.getClass();
- for (Method m : clazz.getDeclaredMethods()) {
- if (Modifier.isPublic(m.getModifiers())) {
- ourLog.debug("Scanning public method: {}#{}", theProvider.getClass(), m.getName());
-
- BaseMethodBinding foundMethodBinding = BaseMethodBinding.bindMethod(theProvider.getResourceType(), m);
- if (foundMethodBinding != null) {
- r.addMethod(foundMethodBinding);
- ourLog.info(" * Method: {}#{} is a handler", theProvider.getClass(), m.getName());
- } else {
- ourLog.debug(" * Method: {}#{} is not a handler", theProvider.getClass(), m.getName());
- }
- }
- }
- }
-
public FhirContext getFhirContext() {
return myFhirContext;
}
- private IParser getNewParser(EncodingUtil theResponseEncoding, boolean thePrettyPrint, NarrativeModeEnum theNarrativeMode) {
- IParser parser;
- switch (theResponseEncoding) {
- case JSON:
- parser = myFhirContext.newJsonParser();
- break;
- case XML:
- default:
- parser = myFhirContext.newXmlParser();
- break;
- }
- return parser.setPrettyPrint(thePrettyPrint).setSuppressNarratives(theNarrativeMode == NarrativeModeEnum.SUPPRESS);
+ public INarrativeGenerator getNarrativeGenerator() {
+ return myNarrativeGenerator;
}
public Collection getResourceBindings() {
@@ -200,14 +81,122 @@ public abstract class RestfulServer extends HttpServlet {
return new ServerProfileProvider(getFhirContext());
}
- public enum NarrativeModeEnum {
- NORMAL,
- SUPPRESS,
- ONLY;
-
- public static NarrativeModeEnum valueOfCaseInsensitive(String theCode) {
- return valueOf(NarrativeModeEnum.class, theCode.toUpperCase());
+ @Override
+ public final void init() throws ServletException {
+ initialize();
+ try {
+ ourLog.info("Initializing HAPI FHIR restful server");
+
+ securityManager = getSecurityManager();
+ if (null == securityManager) {
+ ourLog.warn("No security manager has been provided, requests will not be authenticated!");
+ }
+
+ Collection resourceProvider = getResourceProviders();
+ for (IResourceProvider nextProvider : resourceProvider) {
+ if (myTypeToProvider.containsKey(nextProvider.getResourceType())) {
+ throw new ServletException("Multiple providers for type: " + nextProvider.getResourceType().getCanonicalName());
+ }
+ myTypeToProvider.put(nextProvider.getResourceType(), nextProvider);
+ }
+
+ ourLog.info("Got {} resource providers", myTypeToProvider.size());
+
+ myFhirContext = new FhirContext(myTypeToProvider.keySet());
+ myFhirContext.setNarrativeGenerator(myNarrativeGenerator);
+
+ for (IResourceProvider provider : myTypeToProvider.values()) {
+ findResourceMethods(provider);
+ }
+
+ findResourceMethods(getServerProfilesProvider());
+ findResourceMethods(getServerConformanceProvider());
+
+ } catch (Exception ex) {
+ ourLog.error("An error occurred while loading request handlers!", ex);
+ throw new ServletException("Failed to initialize FHIR Restful server", ex);
}
+
+ ourLog.info("A FHIR has been lit on this server");
+ }
+
+ public boolean isUseBrowserFriendlyContentTypes() {
+ return myUseBrowserFriendlyContentTypes;
+ }
+
+ /**
+ * Sets the {@link INarrativeGenerator Narrative Generator} to use when serializing responses from this server, or null
(which is the default) to disable narrative generation.
+ *
+ * @throws IllegalStateException
+ * Note that this method can only be called prior to {@link #init() initialization} and will throw an {@link IllegalStateException} if called after that.
+ */
+ public void setNarrativeGenerator(INarrativeGenerator theNarrativeGenerator) {
+ if (myFhirContext != null) {
+ throw new IllegalStateException("Server has already been initialized, can not change this property");
+ }
+ myNarrativeGenerator = theNarrativeGenerator;
+ }
+
+ /**
+ * If set to true
(default is false), the server will use browser friendly content-types (instead of standard FHIR ones) when it detects that the request is coming from a browser
+ * instead of a FHIR
+ */
+ public void setUseBrowserFriendlyContentTypes(boolean theUseBrowserFriendlyContentTypes) {
+ myUseBrowserFriendlyContentTypes = theUseBrowserFriendlyContentTypes;
+ }
+
+
+ private void findResourceMethods(IResourceProvider theProvider) throws Exception {
+
+ Class extends IResource> resourceType = theProvider.getResourceType();
+ RuntimeResourceDefinition definition = myFhirContext.getResourceDefinition(resourceType);
+
+ ResourceBinding r = new ResourceBinding();
+ r.setResourceProvider(theProvider);
+ r.setResourceName(definition.getName());
+ resources.put(definition.getName(), r);
+
+ ourLog.info("Scanning type for RESTful methods: {}", theProvider.getClass());
+
+ Class> clazz = theProvider.getClass();
+ for (Method m : clazz.getDeclaredMethods()) {
+ if (Modifier.isPublic(m.getModifiers())) {
+ ourLog.debug("Scanning public method: {}#{}", theProvider.getClass(), m.getName());
+
+ BaseMethodBinding foundMethodBinding = BaseMethodBinding.bindMethod(theProvider.getResourceType(), m, myFhirContext);
+ if (foundMethodBinding != null) {
+ r.addMethod(foundMethodBinding);
+ ourLog.info(" * Method: {}#{} is a handler", theProvider.getClass(), m.getName());
+ } else {
+ ourLog.debug(" * Method: {}#{} is not a handler", theProvider.getClass(), m.getName());
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ handleRequest(SearchMethodBinding.RequestType.DELETE, request, response);
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ handleRequest(SearchMethodBinding.RequestType.GET, request, response);
+ }
+
+ @Override
+ protected void doOptions(HttpServletRequest theReq, HttpServletResponse theResp) throws ServletException, IOException {
+ handleRequest(SearchMethodBinding.RequestType.OPTIONS, theReq, theResp);
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ handleRequest(SearchMethodBinding.RequestType.POST, request, response);
+ }
+
+ @Override
+ protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ handleRequest(SearchMethodBinding.RequestType.PUT, request, response);
}
protected void handleRequest(SearchMethodBinding.RequestType requestType, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
@@ -217,12 +206,6 @@ public abstract class RestfulServer extends HttpServlet {
securityManager.authenticate(request);
}
- String uaHeader = request.getHeader("user-agent");
- boolean requestIsBrowser = false;
- if (uaHeader != null && uaHeader.contains("Mozilla")) {
- requestIsBrowser = true;
- }
-
String resourceName = null;
String requestFullPath = StringUtils.defaultString(request.getRequestURI());
// String contextPath = StringUtils.defaultString(request.getContextPath());
@@ -266,24 +249,6 @@ public abstract class RestfulServer extends HttpServlet {
String completeUrl = StringUtils.isNotBlank(request.getQueryString()) ? requestUrl + "?" + request.getQueryString() : requestUrl.toString();
Map params = new HashMap(request.getParameterMap());
- EncodingUtil responseEncoding = determineResponseEncoding(request, params);
-
- String[] pretty = params.remove(Constants.PARAM_PRETTY);
- boolean prettyPrint = false;
- if (pretty != null && pretty.length > 0) {
- if ("true".equals(pretty[0])) {
- prettyPrint = true;
- }
- }
-
- String[] narrative = params.remove(Constants.PARAM_NARRATIVE);
- NarrativeModeEnum narrativeMode = null;
- if (narrative != null && narrative.length > 0) {
- narrativeMode = NarrativeModeEnum.valueOfCaseInsensitive(narrative[0]);
- }
- if (narrativeMode==null) {
- narrativeMode = NarrativeModeEnum.NORMAL;
- }
StringTokenizer tok = new StringTokenizer(requestPath, "/");
if (!tok.hasMoreTokens()) {
@@ -330,29 +295,20 @@ public abstract class RestfulServer extends HttpServlet {
r.setId(id);
r.setVersion(versionId);
r.setOperation(operation);
- r.setParameterNames(params);
+ r.setParameters(params);
r.setRequestType(requestType);
+ r.setResourceProvider(resourceBinding.getResourceProvider());
+ r.setInputReader(request.getReader());
+ r.setFhirServerBase(fhirServerBase);
+ r.setCompleteUrl(completeUrl);
+ r.setServletRequest(request);
BaseMethodBinding resourceMethod = resourceBinding.getMethod(r);
if (null == resourceMethod) {
throw new MethodNotFoundException("No resource method available for the supplied parameters " + params);
}
- List