();
+ resourceProviders.add(new RestfulPatientResourceProvider());
+ resourceProviders.add(new RestfulObservationResourceProvider());
+ setResourceProviders(resourceProviders);
}
-
+
}
//END SNIPPET: servlet
diff --git a/hapi-fhir-base/src/site/example/java/example/FhirContextIntro.java b/hapi-fhir-base/src/site/example/java/example/FhirContextIntro.java
index 1ba333336c0..1e1f278ec02 100644
--- a/hapi-fhir-base/src/site/example/java/example/FhirContextIntro.java
+++ b/hapi-fhir-base/src/site/example/java/example/FhirContextIntro.java
@@ -67,6 +67,22 @@ System.out.println(encoded);
}
+
+
+public void fluent() throws DataFormatException, IOException {
+FhirContext ctx = new FhirContext(Patient.class, Observation.class);
+String encoded;
+//START SNIPPET: encodeMsgFluent
+Patient patient = new Patient();
+patient.addIdentifier().setSystem("http://example.com/fictitious-mrns").setValue("MRN001");
+patient.addName().setUse(NameUseEnum.OFFICIAL).addFamily("Tester").addGiven("John").addGiven("Q");
+
+encoded = ctx.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient);
+System.out.println(encoded);
+//END SNIPPET: encodeMsgFluent
+
+}
+
public static void parseMsg() {
FhirContext ctx = new FhirContext(Patient.class, Observation.class);
diff --git a/hapi-fhir-base/src/site/example/java/example/RestfulPatientResourceProviderMore.java b/hapi-fhir-base/src/site/example/java/example/RestfulPatientResourceProviderMore.java
index fc5bf590148..e6211f7566a 100644
--- a/hapi-fhir-base/src/site/example/java/example/RestfulPatientResourceProviderMore.java
+++ b/hapi-fhir-base/src/site/example/java/example/RestfulPatientResourceProviderMore.java
@@ -28,6 +28,7 @@ import ca.uhn.fhir.model.dstu.valueset.QuantityCompararatorEnum;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.parser.DataFormatException;
+import ca.uhn.fhir.rest.annotation.Count;
import ca.uhn.fhir.rest.annotation.Create;
import ca.uhn.fhir.rest.annotation.History;
import ca.uhn.fhir.rest.annotation.IdParam;
@@ -38,11 +39,13 @@ import ca.uhn.fhir.rest.annotation.Read;
import ca.uhn.fhir.rest.annotation.RequiredParam;
import ca.uhn.fhir.rest.annotation.ResourceParam;
import ca.uhn.fhir.rest.annotation.Search;
+import ca.uhn.fhir.rest.annotation.Since;
import ca.uhn.fhir.rest.annotation.Update;
import ca.uhn.fhir.rest.annotation.Validate;
import ca.uhn.fhir.rest.annotation.VersionIdParam;
import ca.uhn.fhir.rest.api.MethodOutcome;
import ca.uhn.fhir.rest.client.ITestClient;
+import ca.uhn.fhir.rest.client.api.IBasicClient;
import ca.uhn.fhir.rest.client.api.IRestfulClient;
import ca.uhn.fhir.rest.param.CodingListParam;
import ca.uhn.fhir.rest.param.DateRangeParam;
@@ -443,22 +446,29 @@ public interface MetadataClient extends IRestfulClient {
}
//END SNIPPET: metadataClient
-public interface HistoryClient {
//START SNIPPET: historyClient
-// Server level (history of ALL resources)
-@History
-Bundle getHistoryServer();
+public interface HistoryClient extends IBasicClient {
+ /** Server level (history of ALL resources) */
+ @History
+ Bundle getHistoryServer();
-// Type level (history of all resources of a given type)
-@History(type=Patient.class)
-Bundle getHistoryPatientType();
+ /** Type level (history of all resources of a given type) */
+ @History(type=Patient.class)
+ Bundle getHistoryPatientType();
+
+ /** Instance level (history of a specific resource instance by type and ID) */
+ @History(type=Patient.class)
+ Bundle getHistoryPatientInstance(@IdParam IdDt theId);
+
+ /**
+ * Either (or both) of the "since" and "count" paramaters can
+ * also be included in any of the methods above.
+ */
+ @History
+ Bundle getHistoryServerWithCriteria(@Since Date theDate, @Count int theCount);
-// Instance level (history of a specific resource instance by type and ID)
-@History(type=Patient.class)
-Bundle getHistoryPatientInstance(@IdParam IdDt theId);
-//END SNIPPET: historyClient
-
}
+//END SNIPPET: historyClient
public void bbbbb() throws DataFormatException, IOException {
diff --git a/hapi-fhir-base/src/site/xdoc/doc_intro.xml b/hapi-fhir-base/src/site/xdoc/doc_intro.xml
index 1f87384614d..259b61ce3e5 100644
--- a/hapi-fhir-base/src/site/xdoc/doc_intro.xml
+++ b/hapi-fhir-base/src/site/xdoc/doc_intro.xml
@@ -109,6 +109,9 @@
+
+
This code gives the following output:
@@ -129,6 +132,26 @@
+
+
+
+ Much of the HAPI FHIR API is designed using a fluent style,
+ where method calls can be chained in a natural way. This
+ leads to tighter and easier-to-read code.
+
+
+
+ The following snippet is functionally identical to the
+ example above:
+
+
+
+
+
+
+
+
+
diff --git a/hapi-fhir-base/src/site/xdoc/doc_rest_operations.xml b/hapi-fhir-base/src/site/xdoc/doc_rest_operations.xml
index 7e003ca0da7..96567adbf90 100644
--- a/hapi-fhir-base/src/site/xdoc/doc_rest_operations.xml
+++ b/hapi-fhir-base/src/site/xdoc/doc_rest_operations.xml
@@ -10,6 +10,14 @@
+
+ Jump To...
+
+
+
RESTful Clients and Servers both share the same
method pattern, with one key difference: A client
@@ -26,6 +34,10 @@
implementations, but client methods will follow the same patterns.
+
+
+
+
The following table lists the operations supported by
HAPI FHIR RESTful Servers and Clients.
@@ -81,7 +93,7 @@
- Type - Create
+ Type - Create
|
Create a new resource with a server assigned id
@@ -99,14 +111,6 @@
Search the resource type based on some filter criteria
|
-
-
- Type - Search
- |
-
- Search the resource type based on some filter criteria
- |
-
Type - History
@@ -892,7 +896,7 @@
- Not yet implemented
+ Not yet implemented - Get in touch if you would like to help!
@@ -905,7 +909,7 @@
- Not yet implemented
+ Not yet implemented - Get in touch if you would like to help!
@@ -945,18 +949,38 @@
annotated with the
@IdParam
annotation, indicating the ID of the resource for which to return history.
+ -
+ For a server
+ implementation, the method must either be defined in a
+ resource provider
+ or have a
type() value in the @History annotation if it is
+ defined in a
+ plain provider.
+
- For an
+ For a
Type History
method, the method must not have any @IdParam parameter.
+ -
+ For a server
+ implementation, the method must either be defined in a
+ resource provider
+ or have a
type() value in the @History annotation if it is
+ defined in a
+ plain provider.
+
- For an
+ For a
Server History
- method, the method must not have any @IdParam parameter
- and must not be found in a ResourceProvider definition.
-
+ method, the method must not have any @IdParam parameter, and
+ must not have a type() value specified in
+ the @History annotation.
+ -
+ In a server implementation, the method must
+ be defined in a plain provider.
+
@@ -977,6 +1001,32 @@
+
+
+
+
+
+
+ When implementing a server operation, there are a number of failure conditions
+ specified. For example, an
+ Instance Read request might specify an unknown
+ resource ID, or a Type Create request might contain an
+ invalid resource which can not be created.
+
+
+ In these cases, an appropriate exception should be thrown. The HAPI RESTful
+ API includes a set of exceptions extending
+ BaseServerResponseException
+ which represent specific HTTP failure codes.
+
+
+ See the
+ Exceptions List
+ for a complete list of these exceptions. Note that these exceptions are all unchecked
+ exceptions, so they do not need to ne explicitly declared in the method
+ signature.
+
+
|