From f1c151b2f5ef79328e0367adc045b5d84579e354 Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Mon, 5 Jan 2015 21:19:47 -0500 Subject: [PATCH] Documentation --- .../src/main/java/example/Dstu2Examples.java | 57 +++++++++ hapi-fhir-base/.classpath | 2 +- hapi-fhir-jpaserver-base/.classpath | 2 +- hapi-fhir-structures-dev/.project | 4 +- src/site/site.xml | 5 +- src/site/xdoc/doc_dstu2.xml | 116 ++++++++++++++++++ src/site/xdoc/download.xml.vm | 6 +- 7 files changed, 184 insertions(+), 8 deletions(-) create mode 100644 examples/src/main/java/example/Dstu2Examples.java create mode 100644 src/site/xdoc/doc_dstu2.xml diff --git a/examples/src/main/java/example/Dstu2Examples.java b/examples/src/main/java/example/Dstu2Examples.java new file mode 100644 index 00000000000..24688e70e45 --- /dev/null +++ b/examples/src/main/java/example/Dstu2Examples.java @@ -0,0 +1,57 @@ +package example; + +import java.util.Collection; + +import javax.servlet.ServletException; + +import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.parser.IParser; +import ca.uhn.fhir.rest.client.IGenericClient; +import ca.uhn.fhir.rest.server.IResourceProvider; +import ca.uhn.fhir.rest.server.RestfulServer; + +@SuppressWarnings("serial") +public class Dstu2Examples { + private Collection resourceProviderList; + + public static void main(String[] args) { + new Dstu2Examples().getResourceTags(); + } + + @SuppressWarnings("unused") + public void getResourceTags() { + // START SNIPPET: context + // Create a "dev" context, which supports DSTU2 + FhirContext ctx = FhirContext.forDev(); + + // This parser supports DSTU2 + IParser parser = ctx.newJsonParser(); + + // This client supports DSTU2 + IGenericClient client = ctx.newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu2"); + // END SNIPPET: context + } + + + // START SNIPPET: server + public class MyServer extends RestfulServer + { + + @Override + protected void initialize() throws ServletException { + + // In your initialize method, assign a DEV FhirContext. This + // is all that is required in order to put the server + // into DSTU2 mode + setFhirContext(FhirContext.forDev()); + + // Then set resource providers as normal, and do any other + // configuration you need to do. + setResourceProviders(resourceProviderList); + + } + + } + // END SNIPPET: server + +} diff --git a/hapi-fhir-base/.classpath b/hapi-fhir-base/.classpath index 2a04d82eca6..550e3f2ae04 100644 --- a/hapi-fhir-base/.classpath +++ b/hapi-fhir-base/.classpath @@ -30,7 +30,7 @@ - + diff --git a/hapi-fhir-jpaserver-base/.classpath b/hapi-fhir-jpaserver-base/.classpath index 026194a3623..8dd4c8aaceb 100644 --- a/hapi-fhir-jpaserver-base/.classpath +++ b/hapi-fhir-jpaserver-base/.classpath @@ -6,7 +6,7 @@ - + diff --git a/hapi-fhir-structures-dev/.project b/hapi-fhir-structures-dev/.project index 511aef143b0..acca3e99ff6 100644 --- a/hapi-fhir-structures-dev/.project +++ b/hapi-fhir-structures-dev/.project @@ -16,12 +16,12 @@ - org.eclipse.m2e.core.maven2Builder + org.eclipse.wst.validation.validationbuilder - org.eclipse.wst.validation.validationbuilder + org.eclipse.m2e.core.maven2Builder diff --git a/src/site/site.xml b/src/site/site.xml index d217626a159..3d838f51842 100644 --- a/src/site/site.xml +++ b/src/site/site.xml @@ -58,7 +58,10 @@ - + + + + diff --git a/src/site/xdoc/doc_dstu2.xml b/src/site/xdoc/doc_dstu2.xml new file mode 100644 index 00000000000..3f4ea72593d --- /dev/null +++ b/src/site/xdoc/doc_dstu2.xml @@ -0,0 +1,116 @@ + + + + + FHIR DSTU2 Support - HAPI FHIR + James Agnew + + + + +
+ +

+ Although DSTU2 has not yet been balloted and finalized by HL7, + there are several proposed changes which have been incorporated + into the current + Continuous Integration Builds + of the FHIR specification itself and many (if not most) of these changes will + end up in the final DSTU2 specification which is expected to be released + in mid-2015. +

+

+ The most interesting changes to DSTU2 include: +

+
    +
  • + New + "id" and "meta" + elements which are present on all resources and explicitly state the resource's + ID, version, tags, and a few other things. All of these concepts had previously + existed in FHIR but were not a part of the resource body itself (rather they lived + in URLs and HTTP headers outside of the payload) +
  • +
  • + A new + Bundle + format which is no longer based on Atom. The new format does resemble the + Atom format so it will not be unfamiliar to anyone who is used to DSTU1 bundles + but it has a few differences. On a conceptual level FHIR now thinks of Bundles as + resources themselves, so the new bundle also gains the meta element described above. +
  • +
  • + In JSON encoding, the + encoding of extensions has changed a bit, so that extensions on non-primitive + elements now appear with the extension URL as the JSON key, instead of being + a value in an object called "extension". See the JSON documentation to see how + this new style looks. +
  • +
  • + A number of new resources have been added, and some existing resources have changed. + One particularly visible (and non-backwards-compatible) change is that + Patient.gender has changed from a CodeableConcept to a Code. While this new type + is much more intuitive (having multiple codings attached to a single gender field is + confusing) it does mean that existing DSTU1 Patient resources will not parse correctly + as DSTU2 resources if they include a gender. +
  • +
+ + + +

+ As of HAPI FHIR 0.9, support for DSTU2 has been added to the library. Although upgrading + existing applications from DSTU1 to DSTU2 will not be completely painless, we have + tried as much as possible to make it easy. +

+ +

+ First, support for DSTU2 capabilities has been added in a second optional dependency JAR which + you must add to your classpath. This JAR is called hapi-structures-dev-[version].jar. + See the download page for information on adding this JAR. +

+ +

+ The FHIR version you are targeting is a property of the + FhirContext. + This means that if you use a FhirContext instance that is configured for DSTU2, any parsers, clients, + servers, etc. which use that context will be operating in DSTU2 mode. +

+ +

+ To create a DSTU2 context, simply use the "forDev" factory method on the FhirContext class: +

+ + + + + + +
+ + + +

+ To support DSTU2 in your server, simply set the FhirContext in the server to be + one configured for DSTU2. +

+ + + + + + +

+ Note that it is possible to share your resource provider classes between + servers supporting DSTU1 and servers supporting DSTU2 (including in the same WAR + instance on the same web server). This should make the process of upgrading your + server to the latest version of FHIR a bit easier. +

+ +
+ +
+ + + +
diff --git a/src/site/xdoc/download.xml.vm b/src/site/xdoc/download.xml.vm index 57dc42b9a81..27a470f4562 100644 --- a/src/site/xdoc/download.xml.vm +++ b/src/site/xdoc/download.xml.vm @@ -39,7 +39,7 @@ ${project.version} ]]> - +

HAPI also has a hapi-fhir-structures-dev-[version].jar, which @@ -47,11 +47,11 @@ your classpath if you want to use resources that were created or updated by HL7 after the DSTU1 release. Be warned though that using these resources can lead to incompatibility between your application and other applications - if those applications use libraries that do not support DEV resources. + if those applications are designed to be compliant with FHIR DSTU1.

- If you are using Maven, ad the following dependency to include DEV resources: + If you are using Maven, add the following dependency to include DEV resources:

ca.uhn.hapi.fhir