Package org.hl7.fhir.dstu3.hapi.ctx
Class HapiWorkerContext
- java.lang.Object
-
- org.hl7.fhir.dstu3.hapi.ctx.HapiWorkerContext
-
- All Implemented Interfaces:
IWorkerContext,ValueSetExpander,ValueSetExpanderFactory
public final class HapiWorkerContext extends Object implements IWorkerContext, ValueSetExpander, ValueSetExpanderFactory
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.hl7.fhir.dstu3.context.IWorkerContext
IWorkerContext.ILoggingService, IWorkerContext.ValidationResult
-
Nested classes/interfaces inherited from interface org.hl7.fhir.dstu3.terminologies.ValueSetExpander
ValueSetExpander.ETooCostly, ValueSetExpander.TerminologyServiceErrorClass, ValueSetExpander.ValueSetExpansionOutcome
-
-
Constructor Summary
Constructors Constructor Description HapiWorkerContext(ca.uhn.fhir.context.FhirContext theCtx, IValidationSupport theValidationSupport)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<MetadataResource>allConformanceResources()List<StructureDefinition>allStructures()ValueSetExpander.ValueSetExpansionOutcomeexpand(ValueSet theSource, ExpansionProfile theProfile)ValueSet.ValueSetExpansionComponentexpandVS(ValueSet.ConceptSetComponent theInc, boolean theHeiarchical)Value set expanion inside the internal expansion engine - used for references to supported system (see "supportsSystem") for which there is no value set.ValueSetExpander.ValueSetExpansionOutcomeexpandVS(ValueSet theSource, boolean theCacheOk, boolean theHeiarchical)ValueSet Expansion - see $expandCodeSystemfetchCodeSystem(String theSystem)Find the code system definition for the nominated system uri.<T extends Resource>
TfetchResource(Class<T> theClass, String theUri)Find an identified resource.<T extends Resource>
TfetchResourceWithException(Class<T> theClass_, String theUri)StructureDefinitionfetchTypeDefinition(String theCode)List<ConceptMap>findMapsForSource(String theUrl)find concept maps for a sourceStringgetAbbreviation(String theName)returns the recommended tla for the typeValueSetExpandergetExpander()ExpansionProfilegetExpansionProfile()INarrativeGeneratorgetNarrativeGenerator(String thePrefix, String theBasePath)Get a generator that can generate narrative for the instanceIParsergetParser(String theType)Get a parser to read/write instances.IParsergetParser(ParserType theType)Get a parser to read/write instances.List<String>getResourceNames()Set<String>getResourceNamesAsSet()List<String>getTypeNames()StringgetVersion()Get the versions of the definitions loaded in contextbooleanhasCache()<T extends Resource>
booleanhasResource(Class<T> theClass_, String theUri)find whether a resource is available.booleanisNoTerminologyServer()IParsernewJsonParser()Get a JSON parserIResourceValidatornewValidator()Get a validator that can check whether a resource is validIParsernewXmlParser()Get an XML parserStringoid2Uri(String theCode)voidsetExpansionProfile(ExpansionProfile theExpProfile)voidsetLogger(IWorkerContext.ILoggingService theLogger)booleansupportsSystem(String theSystem)True if the underlying terminology service provider will do expansion and code validation for the terminology.Set<String>typeTails()IWorkerContext.ValidationResultvalidateCode(String theSystem, String theCode, String theDisplay)Validation of a code - consult the terminology service to see whether it is known.IWorkerContext.ValidationResultvalidateCode(String theSystem, String theCode, String theDisplay, ValueSet theVs)Validation of a code - consult the terminology service to see whether it is known.IWorkerContext.ValidationResultvalidateCode(String theSystem, String theCode, String theDisplay, ValueSet.ConceptSetComponent theVsi)Validation of a code - consult the terminology service to see whether it is known.IWorkerContext.ValidationResultvalidateCode(CodeableConcept theCode, ValueSet theVs)IWorkerContext.ValidationResultvalidateCode(Coding theCode, ValueSet theVs)
-
-
-
Constructor Detail
-
HapiWorkerContext
public HapiWorkerContext(ca.uhn.fhir.context.FhirContext theCtx, IValidationSupport theValidationSupport)
-
-
Method Detail
-
allConformanceResources
public List<MetadataResource> allConformanceResources()
- Specified by:
allConformanceResourcesin interfaceIWorkerContext
-
allStructures
public List<StructureDefinition> allStructures()
- Specified by:
allStructuresin interfaceIWorkerContext
-
expand
public ValueSetExpander.ValueSetExpansionOutcome expand(ValueSet theSource, ExpansionProfile theProfile)
- Specified by:
expandin interfaceValueSetExpander- Parameters:
theSource- the value set definition to expandtheProfile- a profile affecting the outcome. If you don't supply a profile, the default internal expansion profile will be used.- Returns:
-
expandVS
public ValueSetExpander.ValueSetExpansionOutcome expandVS(ValueSet theSource, boolean theCacheOk, boolean theHeiarchical)
Description copied from interface:IWorkerContextValueSet Expansion - see $expand- Specified by:
expandVSin interfaceIWorkerContext- Returns:
-
expandVS
public ValueSet.ValueSetExpansionComponent expandVS(ValueSet.ConceptSetComponent theInc, boolean theHeiarchical)
Description copied from interface:IWorkerContextValue set expanion inside the internal expansion engine - used for references to supported system (see "supportsSystem") for which there is no value set.- Specified by:
expandVSin interfaceIWorkerContext- Returns:
-
fetchTypeDefinition
public StructureDefinition fetchTypeDefinition(String theCode)
- Specified by:
fetchTypeDefinitionin interfaceIWorkerContext
-
fetchCodeSystem
public CodeSystem fetchCodeSystem(String theSystem)
Description copied from interface:IWorkerContextFind the code system definition for the nominated system uri. return null if there isn't one (then the tool might try supportsSystem)- Specified by:
fetchCodeSystemin interfaceIWorkerContext- Returns:
-
fetchResource
public <T extends Resource> T fetchResource(Class<T> theClass, String theUri)
Description copied from interface:IWorkerContextFind an identified resource. The most common use of this is to access the the standard conformance resources that are part of the standard - structure definitions, value sets, concept maps, etc. Also, the narrative generator uses this, and may access any kind of resource The URI is called speculatively for things that might exist, so not finding a matching resouce, return null, not an error The URI can have one of 3 formats: - a full URL e.g. http://acme.org/fhir/ValueSet/[id] - a relative URL e.g. ValueSet/[id] - a logical id e.g. [id] It's an error if the second form doesn't agree with class_. It's an error if class_ is null for the last form- Specified by:
fetchResourcein interfaceIWorkerContext- Returns:
-
fetchResourceWithException
public <T extends Resource> T fetchResourceWithException(Class<T> theClass_, String theUri) throws org.hl7.fhir.exceptions.FHIRException
- Specified by:
fetchResourceWithExceptionin interfaceIWorkerContext- Throws:
org.hl7.fhir.exceptions.FHIRException
-
findMapsForSource
public List<ConceptMap> findMapsForSource(String theUrl)
Description copied from interface:IWorkerContextfind concept maps for a source- Specified by:
findMapsForSourcein interfaceIWorkerContext- Returns:
-
getAbbreviation
public String getAbbreviation(String theName)
Description copied from interface:IWorkerContextreturns the recommended tla for the type- Specified by:
getAbbreviationin interfaceIWorkerContext- Returns:
-
getExpander
public ValueSetExpander getExpander()
- Specified by:
getExpanderin interfaceValueSetExpanderFactory
-
getExpansionProfile
public ExpansionProfile getExpansionProfile()
- Specified by:
getExpansionProfilein interfaceIWorkerContext
-
setExpansionProfile
public void setExpansionProfile(ExpansionProfile theExpProfile)
- Specified by:
setExpansionProfilein interfaceIWorkerContext
-
getNarrativeGenerator
public INarrativeGenerator getNarrativeGenerator(String thePrefix, String theBasePath)
Description copied from interface:IWorkerContextGet a generator that can generate narrative for the instance- Specified by:
getNarrativeGeneratorin interfaceIWorkerContext- Returns:
- a prepared generator
-
newValidator
public IResourceValidator newValidator() throws org.hl7.fhir.exceptions.FHIRException
Description copied from interface:IWorkerContextGet a validator that can check whether a resource is valid- Specified by:
newValidatorin interfaceIWorkerContext- Returns:
- a prepared generator
- Throws:
org.hl7.fhir.exceptions.FHIRException
-
getParser
public IParser getParser(ParserType theType)
Description copied from interface:IWorkerContextGet a parser to read/write instances. Use the defined type (will be extended as further types are added, though the only currently anticipate type is RDF) XML/JSON - the standard renderers XHTML - render the narrative only (generate it if necessary)- Specified by:
getParserin interfaceIWorkerContext- Returns:
-
getParser
public IParser getParser(String theType)
Description copied from interface:IWorkerContextGet a parser to read/write instances. Determine the type from the stated type. Supported value for type: - the recommended MIME types - variants of application/xml and application/json - _format values xml, json- Specified by:
getParserin interfaceIWorkerContext- Returns:
-
getResourceNames
public List<String> getResourceNames()
- Specified by:
getResourceNamesin interfaceIWorkerContext
-
getResourceNamesAsSet
public Set<String> getResourceNamesAsSet()
- Specified by:
getResourceNamesAsSetin interfaceIWorkerContext
-
getTypeNames
public List<String> getTypeNames()
- Specified by:
getTypeNamesin interfaceIWorkerContext
-
getVersion
public String getVersion()
Description copied from interface:IWorkerContextGet the versions of the definitions loaded in context- Specified by:
getVersionin interfaceIWorkerContext- Returns:
-
hasCache
public boolean hasCache()
- Specified by:
hasCachein interfaceIWorkerContext
-
hasResource
public <T extends Resource> boolean hasResource(Class<T> theClass_, String theUri)
Description copied from interface:IWorkerContextfind whether a resource is available. Implementations of the interface can assume that if hasResource ruturns true, the resource will usually be fetched subsequently- Specified by:
hasResourcein interfaceIWorkerContext- Returns:
-
isNoTerminologyServer
public boolean isNoTerminologyServer()
- Specified by:
isNoTerminologyServerin interfaceIWorkerContext
-
newJsonParser
public IParser newJsonParser()
Description copied from interface:IWorkerContextGet a JSON parser- Specified by:
newJsonParserin interfaceIWorkerContext- Returns:
-
newXmlParser
public IParser newXmlParser()
Description copied from interface:IWorkerContextGet an XML parser- Specified by:
newXmlParserin interfaceIWorkerContext- Returns:
-
oid2Uri
public String oid2Uri(String theCode)
- Specified by:
oid2Uriin interfaceIWorkerContext
-
setLogger
public void setLogger(IWorkerContext.ILoggingService theLogger)
- Specified by:
setLoggerin interfaceIWorkerContext
-
supportsSystem
public boolean supportsSystem(String theSystem)
Description copied from interface:IWorkerContextTrue if the underlying terminology service provider will do expansion and code validation for the terminology. Corresponds to the extension http://hl7.org/fhir/StructureDefinition/capabilitystatement-supported-system in the Conformance resource- Specified by:
supportsSystemin interfaceIWorkerContext- Returns:
-
typeTails
public Set<String> typeTails()
- Specified by:
typeTailsin interfaceIWorkerContext
-
validateCode
public IWorkerContext.ValidationResult validateCode(CodeableConcept theCode, ValueSet theVs)
- Specified by:
validateCodein interfaceIWorkerContext
-
validateCode
public IWorkerContext.ValidationResult validateCode(Coding theCode, ValueSet theVs)
- Specified by:
validateCodein interfaceIWorkerContext
-
validateCode
public IWorkerContext.ValidationResult validateCode(String theSystem, String theCode, String theDisplay)
Description copied from interface:IWorkerContextValidation of a code - consult the terminology service to see whether it is known. If known, return a description of it note: always return a result, with either an error or a code description corresponds to 2 terminology service calls: $validate-code and $lookup- Specified by:
validateCodein interfaceIWorkerContext- Returns:
-
validateCode
public IWorkerContext.ValidationResult validateCode(String theSystem, String theCode, String theDisplay, ValueSet.ConceptSetComponent theVsi)
Description copied from interface:IWorkerContextValidation of a code - consult the terminology service to see whether it is known. If known, return a description of it Also, check whether it's in the provided value set fragment (for supported systems with no value set definition) note: always return a result, with either an error or a code description, or both (e.g. known code, but not in the value set) corresponds to 2 terminology service calls: $validate-code and $lookup- Specified by:
validateCodein interfaceIWorkerContext- Returns:
-
validateCode
public IWorkerContext.ValidationResult validateCode(String theSystem, String theCode, String theDisplay, ValueSet theVs)
Description copied from interface:IWorkerContextValidation of a code - consult the terminology service to see whether it is known. If known, return a description of it Also, check whether it's in the provided value set note: always return a result, with either an error or a code description, or both (e.g. known code, but not in the value set) corresponds to 2 terminology service calls: $validate-code and $lookup- Specified by:
validateCodein interfaceIWorkerContext- Returns:
-
-