Documentation updates

This commit is contained in:
James Agnew 2015-06-12 17:50:01 -04:00
parent a46890b0d2
commit 0cc53ca742
7 changed files with 115 additions and 7 deletions

View File

@ -24,6 +24,11 @@
<artifactId>hapi-fhir-structures-dstu2</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>

View File

@ -14,11 +14,33 @@ public class FhirContextIntro {
@SuppressWarnings("unused")
public static void creatingContext() {
// START SNIPPET: creatingContext
// Create a context for DSTU1
FhirContext ctx = FhirContext.forDstu1();
// Alternately, create a context for DSTU2
FhirContext ctxDstu2 = FhirContext.forDstu2();
// END SNIPPET: creatingContext
}
@SuppressWarnings("unused")
public static void creatingContextHl7org() {
// START SNIPPET: creatingContextHl7org
// To use the RI structures, you need to specifically use a FhirContext configured
// for HL7.org Structures
FhirContext ctx = FhirContext.forDstu2Hl7Org();
// Working with RI structures is similar to how it works with the HAPI structures
org.hl7.fhir.instance.model.Patient patient = new org.hl7.fhir.instance.model.Patient();
patient.addName().addGiven("John").addFamily("Smith");
patient.getBirthDateElement().setValueAsString("1998-02-22");
// Parsing and encoding works the same way too
String encoded = ctx.newJsonParser().encodeResourceToString(patient);
// END SNIPPET: creatingContextHl7org
}
public static void main(String[] args) throws DataFormatException {

View File

@ -24,10 +24,12 @@ import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import org.hl7.fhir.instance.model.api.IAnyResource;
import org.hl7.fhir.instance.model.api.IBaseResource;
import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.TagList;
/**
@ -120,11 +122,12 @@ public interface IParser {
<T extends IBaseResource> T parseResource(Class<T> theResourceType, String theString) throws DataFormatException;
/**
* Parses a resource
* Parses a resource
*
* @param theReader
* The reader to parse input from. Note that the Reader will not be closed by the parser upon completion.
* @return A parsed resource
* @return A parsed resource. Note that the returned object will be an instance of {@link IResource} or {@link IAnyResource}
* depending on the specific FhirContext which created this parser.
* @throws DataFormatException
* If the resource can not be parsed because the data is not recognized or invalid for any reason
*/
@ -135,7 +138,8 @@ public interface IParser {
*
* @param theMessageString
* The string to parse
* @return A parsed resource
* @return A parsed resource. Note that the returned object will be an instance of {@link IResource} or {@link IAnyResource}
* depending on the specific FhirContext which created this parser.
* @throws DataFormatException
* If the resource can not be parsed because the data is not recognized or invalid for any reason
*/

View File

@ -1,5 +1,25 @@
package ca.uhn.fhir.rest.api;
/*
* #%L
* HAPI FHIR - Core Library
* %%
* Copyright (C) 2014 - 2015 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import org.hl7.fhir.instance.model.api.IBase;
/**

View File

@ -1,5 +1,25 @@
package ca.uhn.fhir.rest.method;
/*
* #%L
* HAPI FHIR - Core Library
* %%
* Copyright (C) 2014 - 2015 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

View File

@ -161,7 +161,7 @@
is shown, so that we can deploy the site even if the project is on a
snapshot version.
-->
<hapi_stable_version>0.9</hapi_stable_version>
<hapi_stable_version>1.0</hapi_stable_version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -17,13 +17,13 @@
</p>
<p>
HAPI was originally started as a separate Java implementation of FHIR,
but with a fairly different focus: implementing servers with an easily
with a fairly different focus: implementing servers with an easily
extendible data model. Over time though, the two Java implementations have
shown a fair bit of overlap, so at the 2014
<a href="http://fhir.furore.com/Events/DevDaysEval2014">DevDays</a> we decided
to try and harmonize the two libraries.
</p>
<p>
<p>
HAPI FHIR 1.1 begins the availability of a harmonized library. Note that
this version has not yet been formally released, but is currently available in
"snapshot" development builds.
@ -39,7 +39,7 @@
of HAPI's code-first statically bound extension mechanism.
</p>
<subsection name="How it Works">
<subsection name="The RI Data Model">
<p>
At this point, the RI integration consists of a new parallel set of
classes representing the FHIR data model. For example, in addition to the
@ -69,8 +69,45 @@
<img src="./images/hapi-1.1-structs-datatypes.png" alt="Structures"/>
</subsection>
<subsection name="Using the RI Structures in Your Application">
<p>
If you want to use the RI structures in your application,
you will need to use the "hapi-fhir-structures-hl7org-dstu2-[version].jar"
library.
</p>
<p>
Using these structures is then similar to using other structures.
</p>
<macro name="snippet">
<param name="id" value="creatingContextHl7org" />
<param name="file" value="examples/src/main/java/example/FhirContextIntro.java" />
</macro>
</subsection>
</section>
<section name="Upgrading Existing Applications to HAPI FHIR 1.1">
<p>
If you have an existing application built using a version of previous
version of HAPI FHIR, there is one change that may affect you. As shown above,
a new interface called <code>IBaseResource</code> has been introduced, and the
<code>IResource</code> interface extends from it. Many methods in the API which
previously returned <code>IResource</code> now return <code>IBaseResource</code>.
</p>
<p>
For these methods, you may cast the <code>IBaseResource</code> to
<code>IResource</code>.
</p>
</section>
<!--
<section name="Upgrading to HAPI FHIR 0.8">