public class FhirContext extends Object
Important usage notes:
registerCustomType(java.lang.Class<? extends org.hl7.fhir.instance.model.api.IBase>) and registerCustomTypes(java.util.Collection<java.lang.Class<? extends org.hl7.fhir.instance.model.api.IBase>>) methods.
| Constructor and Description |
|---|
FhirContext()
Deprecated.
It is recommended that you use one of the static initializer methods instead
of this method, e.g.
forDstu2() or forDstu3() or forR4() |
FhirContext(Class<?>... theResourceTypes)
Deprecated.
It is recommended that you use one of the static initializer methods instead
of this method, e.g.
forDstu2() or forDstu3() or forR4() |
FhirContext(Class<? extends IBaseResource> theResourceType)
Deprecated.
It is recommended that you use one of the static initializer methods instead
of this method, e.g.
forDstu2() or forDstu3() or forR4() |
FhirContext(Collection<Class<? extends IBaseResource>> theResourceTypes)
Deprecated.
It is recommended that you use one of the static initializer methods instead
of this method, e.g.
forDstu2() or forDstu3() or forR4() |
FhirContext(FhirVersionEnum theVersion)
In most cases it is recommended that you use one of the static initializer methods instead
of this method, e.g.
|
| Modifier and Type | Method and Description |
|---|---|
static FhirContext |
forDstu2_1()
Creates and returns a new FhirContext with version
DSTU2 (2016 May DSTU3 Snapshot) |
static FhirContext |
forDstu2()
Creates and returns a new FhirContext with version
DSTU2 |
static FhirContext |
forDstu2Hl7Org()
Creates and returns a new FhirContext with version
DSTU2 (using the Reference
Implementation Structures) |
static FhirContext |
forDstu3()
Creates and returns a new FhirContext with version
DSTU3 |
static FhirContext |
forR4()
Creates and returns a new FhirContext with version
R4 |
static FhirContext |
forR5()
Creates and returns a new FhirContext with version
R5 |
AddProfileTagEnum |
getAddProfileTagWhenEncoding()
When encoding resources, this setting configures the parser to include
an entry in the resource's metadata section which indicates which profile(s) the
resource claims to conform to.
|
Class<? extends IBaseResource> |
getDefaultTypeForProfile(String theProfile)
Returns the default resource type for the given profile
|
BaseRuntimeElementDefinition<?> |
getElementDefinition(Class<? extends IBase> theElementType)
Returns the scanned runtime model for the given type.
|
BaseRuntimeElementDefinition<?> |
getElementDefinition(String theElementName)
Returns the scanned runtime model for the given type.
|
Collection<BaseRuntimeElementDefinition<?>> |
getElementDefinitions()
Returns all element definitions (resources, datatypes, etc.)
|
HapiLocalizer |
getLocalizer()
This feature is not yet in its final state and should be considered an internal part of HAPI for now - use with
caution
|
INarrativeGenerator |
getNarrativeGenerator() |
ParserOptions |
getParserOptions()
Returns the parser options object which will be used to supply default
options to newly created parsers
|
Set<PerformanceOptionsEnum> |
getPerformanceOptions()
Get the configured performance options
|
RuntimeResourceDefinition |
getResourceDefinition(Class<? extends IBaseResource> theResourceType)
Returns the scanned runtime model for the given type.
|
RuntimeResourceDefinition |
getResourceDefinition(FhirVersionEnum theVersion,
String theResourceName) |
RuntimeResourceDefinition |
getResourceDefinition(IBaseResource theResource)
Returns the scanned runtime model for the given type.
|
RuntimeResourceDefinition |
getResourceDefinition(String theResourceName)
Returns the scanned runtime model for the given type.
|
RuntimeResourceDefinition |
getResourceDefinitionById(String theId)
Returns the scanned runtime model for the given type.
|
Collection<RuntimeResourceDefinition> |
getResourceDefinitionsWithExplicitId()
Returns the scanned runtime models.
|
Set<String> |
getResourceNames()
Returns an unmodifiable set containing all resource names known to this
context
|
IRestfulClientFactory |
getRestfulClientFactory()
Get the restful client factory.
|
RuntimeChildUndeclaredExtensionDefinition |
getRuntimeChildUndeclaredExtensionDefinition() |
IContextValidationSupport<?,?,?,?,?,?> |
getValidationSupport()
Returns the validation support module configured for this context, creating a default
implementation if no module has been passed in via the
setValidationSupport(IContextValidationSupport)
method |
IFhirVersion |
getVersion() |
boolean |
hasDefaultTypeForProfile()
Returns
true if any default types for specific profiles have been defined
within this context. |
IVersionSpecificBundleFactory |
newBundleFactory() |
IFluentPath |
newFluentPath()
Creates a new FluentPath engine which can be used to exvaluate
path expressions over FHIR resources.
|
IParser |
newJsonParser()
Create and return a new JSON parser.
|
IParser |
newRDFParser()
Deprecated.
THIS FEATURE IS NOT YET COMPLETE
|
<T extends IRestfulClient> |
newRestfulClient(Class<T> theClientType,
String theServerBase)
Instantiates a new client instance.
|
IGenericClient |
newRestfulGenericClient(String theServerBase)
Instantiates a new generic client.
|
FhirTerser |
newTerser() |
FhirValidator |
newValidator()
Create a new validator instance.
|
ViewGenerator |
newViewGenerator() |
IParser |
newXmlParser()
Create and return a new XML parser.
|
void |
registerCustomType(Class<? extends IBase> theType)
This method may be used to register a custom resource or datatype.
|
void |
registerCustomTypes(Collection<Class<? extends IBase>> theTypes)
This method may be used to register a custom resource or datatype.
|
void |
setAddProfileTagWhenEncoding(AddProfileTagEnum theAddProfileTagWhenEncoding)
When encoding resources, this setting configures the parser to include
an entry in the resource's metadata section which indicates which profile(s) the
resource claims to conform to.
|
void |
setDefaultTypeForProfile(String theProfile,
Class<? extends IBaseResource> theClass)
Sets the default type which will be used when parsing a resource that is found to be
of the given profile.
|
void |
setLocalizer(HapiLocalizer theMessages)
This feature is not yet in its final state and should be considered an internal part of HAPI for now - use with
caution
|
void |
setNarrativeGenerator(INarrativeGenerator theNarrativeGenerator) |
void |
setParserErrorHandler(IParserErrorHandler theParserErrorHandler)
Sets a parser error handler to use by default on all parsers
|
void |
setParserOptions(ParserOptions theParserOptions)
Sets the parser options object which will be used to supply default
options to newly created parsers
|
void |
setPerformanceOptions(Collection<PerformanceOptionsEnum> theOptions)
Sets the configured performance options
|
void |
setPerformanceOptions(PerformanceOptionsEnum... thePerformanceOptions)
Sets the configured performance options
|
void |
setRestfulClientFactory(IRestfulClientFactory theRestfulClientFactory)
Set the restful client factory
|
void |
setValidationSupport(IContextValidationSupport<?,?,?,?,?,?> theValidationSupport)
Sets the validation support module to use for this context.
|
@Deprecated public FhirContext()
forDstu2() or forDstu3() or forR4()@Deprecated public FhirContext(Class<? extends IBaseResource> theResourceType)
forDstu2() or forDstu3() or forR4()@Deprecated public FhirContext(Class<?>... theResourceTypes)
forDstu2() or forDstu3() or forR4()@Deprecated public FhirContext(Collection<Class<? extends IBaseResource>> theResourceTypes)
forDstu2() or forDstu3() or forR4()public FhirContext(FhirVersionEnum theVersion)
forDstu2() or forDstu3() or forR4(), but
this method can also be used if you wish to supply the version programmatically.public AddProfileTagEnum getAddProfileTagWhenEncoding()
AddProfileTagEnum.ONLY_FOR_CUSTOM.for more informationpublic void setAddProfileTagWhenEncoding(AddProfileTagEnum theAddProfileTagWhenEncoding)
AddProfileTagEnum.ONLY_FOR_CUSTOM.
This feature is intended for situations where custom resource types are being used, avoiding the need to manually add profile declarations for these custom types.
See Profiling and Extensions for more information on using custom types.
Note that this feature automatically adds the profile, but leaves any profile tags which have been manually added in place as well.
theAddProfileTagWhenEncoding - The add profile mode (must not be null)public Class<? extends IBaseResource> getDefaultTypeForProfile(String theProfile)
setDefaultTypeForProfile(String, Class)public BaseRuntimeElementDefinition<?> getElementDefinition(Class<? extends IBase> theElementType)
public BaseRuntimeElementDefinition<?> getElementDefinition(String theElementName)
Note that this method is case insensitive!
public Collection<BaseRuntimeElementDefinition<?>> getElementDefinitions()
public HapiLocalizer getLocalizer()
public void setLocalizer(HapiLocalizer theMessages)
public INarrativeGenerator getNarrativeGenerator()
public void setNarrativeGenerator(INarrativeGenerator theNarrativeGenerator)
public ParserOptions getParserOptions()
nullpublic void setParserOptions(ParserOptions theParserOptions)
theParserOptions - The parser options object - Must not be nullpublic Set<PerformanceOptionsEnum> getPerformanceOptions()
public void setPerformanceOptions(Collection<PerformanceOptionsEnum> theOptions)
for a list of available optionspublic RuntimeResourceDefinition getResourceDefinition(Class<? extends IBaseResource> theResourceType)
public RuntimeResourceDefinition getResourceDefinition(FhirVersionEnum theVersion, String theResourceName)
public RuntimeResourceDefinition getResourceDefinition(IBaseResource theResource)
public RuntimeResourceDefinition getResourceDefinition(String theResourceName) throws DataFormatException
Note that this method is case insensitive!
DataFormatException - If the resource name is not knownpublic RuntimeResourceDefinition getResourceDefinitionById(String theId)
public Collection<RuntimeResourceDefinition> getResourceDefinitionsWithExplicitId()
public Set<String> getResourceNames()
public IRestfulClientFactory getRestfulClientFactory()
public void setRestfulClientFactory(IRestfulClientFactory theRestfulClientFactory)
theRestfulClientFactory - public RuntimeChildUndeclaredExtensionDefinition getRuntimeChildUndeclaredExtensionDefinition()
public IContextValidationSupport<?,?,?,?,?,?> getValidationSupport()
setValidationSupport(IContextValidationSupport)
methodpublic void setValidationSupport(IContextValidationSupport<?,?,?,?,?,?> theValidationSupport)
public IFhirVersion getVersion()
public boolean hasDefaultTypeForProfile()
true if any default types for specific profiles have been defined
within this context.public IVersionSpecificBundleFactory newBundleFactory()
public IFluentPath newFluentPath()
context validation support module which is
configured on the context at the time this method is called.
In other words, call setValidationSupport(IContextValidationSupport) before
calling newFluentPath()
Note that this feature was added for FHIR DSTU3 and is not available
for contexts configured to use an older version of FHIR. Calling this method
on a context for a previous version of fhir will result in an
UnsupportedOperationException
public IParser newJsonParser()
Thread safety: Parsers are not guaranteed to be thread safe. Create a new parser instance for every thread or every message being parsed/encoded.
Performance Note: This method is cheap to call, and may be called once for every message being processed without incurring any performance penalty
@Deprecated public IParser newRDFParser()
Thread safety: Parsers are not guaranteed to be thread safe. Create a new parser instance for every thread or every message being parsed/encoded.
Performance Note: This method is cheap to call, and may be called once for every message being processed without incurring any performance penalty
public <T extends IRestfulClient> T newRestfulClient(Class<T> theClientType, String theServerBase)
IRestfulClient (or commonly its
sub-interface IBasicClient). See the RESTful Client documentation for more
information on how to define this interface.
Performance Note: This method is cheap to call, and may be called once for every operation invocation without incurring any performance penalty
theClientType - The client type, which is an interface type to be instantiatedtheServerBase - The URL of the base for the restful FHIR server to connect toConfigurationException - If the interface type is not an interfacepublic IGenericClient newRestfulGenericClient(String theServerBase)
non-generic clients).
Performance Note: This method is cheap to call, and may be called once for every operation invocation without incurring any performance penalty
theServerBase - The URL of the base for the restful FHIR server to connect topublic FhirTerser newTerser()
public FhirValidator newValidator()
Note on thread safety: Validators are thread safe, you may use a single validator in multiple threads. (This is in contrast to parsers)
public ViewGenerator newViewGenerator()
public IParser newXmlParser()
Thread safety: Parsers are not guaranteed to be thread safe. Create a new parser instance for every thread or every message being parsed/encoded.
Performance Note: This method is cheap to call, and may be called once for every message being processed without incurring any performance penalty
public void registerCustomType(Class<? extends IBase> theType)
THREAD SAFETY WARNING: This method is not thread safe. It should be called before any threads are able to call any methods on this context.
theType - The custom type to add (must not be null)public void registerCustomTypes(Collection<Class<? extends IBase>> theTypes)
THREAD SAFETY WARNING: This method is not thread safe. It should be called before any threads are able to call any methods on this context.
theTypes - The custom types to add (must not be null or contain null elements in the collection)public void setDefaultTypeForProfile(String theProfile, Class<? extends IBaseResource> theClass)
For example, this method is invoked with the profile string of
"http://example.com/some_patient_profile" and the type of MyPatient.class,
if the parser is parsing a resource and finds that it declares that it conforms to that profile,
the MyPatient type will be used unless otherwise specified.
theProfile - The profile string, e.g. "http://example.com/some_patient_profile". Must not be
null or empty.theClass - The resource type, or null to clear any existing typepublic void setParserErrorHandler(IParserErrorHandler theParserErrorHandler)
theParserErrorHandler - The error handlerpublic void setPerformanceOptions(PerformanceOptionsEnum... thePerformanceOptions)
for a list of available optionspublic static FhirContext forDstu2()
DSTU2public static FhirContext forDstu2Hl7Org()
DSTU2 (using the Reference
Implementation Structures)public static FhirContext forDstu2_1()
DSTU2 (2016 May DSTU3 Snapshot)public static FhirContext forDstu3()
DSTU3public static FhirContext forR4()
R4public static FhirContext forR5()
R5Copyright © 2014–2019 University Health Network. All rights reserved.