Class ProfileUtilities
java.lang.Object
org.hl7.fhir.r5.conformance.profile.ProfileUtilities
This class provides a set of utility operations for working with Profiles.
Key functionality:
* getChildMap --?
* getChildList
* generateSnapshot: Given a base (snapshot) profile structure, and a differential profile, generate a new snapshot profile
* closeDifferential: fill out a differential by excluding anything not mentioned
* generateExtensionsTable: generate the HTML for a hierarchical table presentation of the extensions
* generateTable: generate the HTML for a hierarchical table presentation of a structure
* generateSpanningTable: generate the HTML for a table presentation of a network of structures, starting at a nominated point
* summarize: describe the contents of a profile
note to maintainers: Do not make modifications to the snapshot generation without first changing the snapshot generation test cases to demonstrate the grounds for your change
- Author:
- Grahame
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
static class
class
class
static class
static class
-
Field Summary
Modifier and TypeFieldDescriptionThese extensions are stripped in inherited profiles (and may be replaced byThese extensions are ignored when found in differentialsWhen these extensions are found, they override whatever is set on the ancestor elementstatic final int
static final int
static final int
static final int
static final int
static final String
static final String
static final String
static final String
static final String
static final String
static final String
-
Constructor Summary
ConstructorDescriptionProfileUtilities
(IWorkerContext context, List<org.hl7.fhir.utilities.validation.ValidationMessage> messages, ProfileKnowledgeProvider pkp) ProfileUtilities
(IWorkerContext context, List<org.hl7.fhir.utilities.validation.ValidationMessage> messages, ProfileKnowledgeProvider pkp, FHIRPathEngine fpe) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addToCSV
(CSVWriter csv, StructureDefinition structure) protected boolean
baseWalksInto
(List<ElementDefinition> elements, int cursor) static String
protected boolean
void
checkExtensions
(ElementDefinition outcome) protected void
checkNotGenerating
(StructureDefinition sd, String role) protected BaseTypeSlice
chooseMatchingBaseSlice
(List<BaseTypeSlice> baseSlices, String type) void
void
closeDifferential
(StructureDefinition base, StructureDefinition derived) protected String
descED
(List<ElementDefinition> list, int index) static String
protected String
determineTypeSlicePath
(String path, String cpath) protected boolean
diffsConstrainTypes
(List<ElementDefinition> diffMatches, String cPath, List<TypeSlice> typeList) protected boolean
discriminatorMatches
(List<ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent> diff, List<ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent> base) protected ElementDefinition
fillOutFromBase
(ElementDefinition profile, ElementDefinition usage) protected List
<BaseTypeSlice> findBaseSlices
(StructureDefinition.StructureDefinitionSnapshotComponent list, int start) protected int
findEndOfElement
(StructureDefinition.StructureDefinitionDifferentialComponent context, int cursor) protected int
findEndOfElement
(StructureDefinition.StructureDefinitionSnapshotComponent context, int cursor) protected String
fixedPathDest
(String contextPath, String pathSimple, List<ElementRedirection> redirector, String redirectSource) protected String
fixedPathSource
(String contextPath, String pathSimple, List<ElementRedirection> redirector) void
generateCsv
(OutputStream dest, StructureDefinition structure, boolean asXml) generateExamples
(StructureDefinition sd, boolean evenWhenNoExamples) protected void
generateIds
(List<ElementDefinition> list, String name, String type, StructureDefinition srcSD) void
generateSchematrons
(OutputStream dest, StructureDefinition structure) void
generateSnapshot
(StructureDefinition base, StructureDefinition derived, String url, String webUrl, String profileName) Given a base (snapshot) profile structure, and a differential profile, generate a new snapshot profileprotected ElementDefinition
getById
(List<ElementDefinition> list, String baseId) protected List
<ElementDefinition.TypeRefComponent> getChildList
(StructureDefinition profile, String path, String id) Given a Structure, navigate to the element given by the path and return the direct children of that elementgetChildList
(StructureDefinition profile, String path, String id, boolean diff) getChildList
(StructureDefinition profile, String path, String id, boolean diff, boolean refs) getChildList
(StructureDefinition structure, ElementDefinition element) getChildList
(StructureDefinition structure, ElementDefinition element, boolean diff) getChildList
(StructureDefinition structure, ElementDefinition element, boolean diff, boolean refs) getChildMap
(StructureDefinition profile, ElementDefinition element) org.hl7.fhir.r5.conformance.profile.ProfileUtilities.ElementDefinitionComparer
getComparer
(org.hl7.fhir.r5.conformance.profile.ProfileUtilities.ElementDefinitionComparer cmp, org.hl7.fhir.r5.conformance.profile.ProfileUtilities.ElementDefinitionHolder child) protected List
<ElementDefinition> getDiffMatches
(StructureDefinition.StructureDefinitionDifferentialComponent context, String path, int start, int end, String profileName) getElementById
(StructureDefinition source, List<ElementDefinition> elements, String contentReference) List
<org.hl7.fhir.utilities.validation.ValidationMessage> getPkp()
getProfile
(StructureDefinition source, String url) protected StructureDefinition
getProfileForDataType
(String type) protected StructureDefinition
getProfileForDataType
(ElementDefinition.TypeRefComponent type, String webUrl, Resource src) getRowColor
(ElementDefinition element, boolean isConstraintMode) protected List
<ElementDefinition> getSiblings
(List<ElementDefinition> list, ElementDefinition current) getSliceList
(StructureDefinition profile, ElementDefinition element) org.hl7.fhir.utilities.validation.ValidationOptions
protected String
getWebUrl
(StructureDefinition dt, String webUrl) getXver()
interpretR2Discriminator
(String discriminator, boolean isExists) boolean
protected boolean
static boolean
protected boolean
boolean
isDebug()
protected boolean
isExtension
(ElementDefinition currentBase) static boolean
boolean
protected boolean
protected boolean
isImplicitSlicing
(ElementDefinition ed, String path) protected boolean
isMatchingType
(StructureDefinition sd, List<ElementDefinition.TypeRefComponent> types, String inner) static boolean
boolean
protected boolean
isPrimitive
(String value) static boolean
static boolean
protected boolean
static boolean
boolean
protected boolean
boolean
static StructureDefinition
makeBaseDefinition
(String fhirVersion) static StructureDefinition
makeBaseDefinition
(Enumerations.FHIRVersion fhirVersion) static StructureDefinition
makeExtensionForVersionedURL
(IWorkerContext context, String url) protected void
markDerived
(ElementDefinition outcome) protected boolean
orderMatches
(BooleanType diff, BooleanType base) protected boolean
pathStartsWith
(String p1, String p2) protected String
pathTail
(List<ElementDefinition> diffMatches, int i) void
processConstraint
(List<ElementDefinition> children, ElementDefinition.ElementDefinitionConstraintComponent c) static String
processRelativeUrls
(String markdown, String webUrl, String basePath, List<String> resourceNames, Set<String> baseFilenames, Set<String> localFilenames, boolean processRelatives) protected List
<ElementRedirection> redirectorStack
(List<ElementRedirection> redirector, ElementDefinition outcome, String path) protected void
removeStatusExtensions
(ElementDefinition outcome) protected void
replaceFromContentReference
(ElementDefinition outcome, ElementDefinition tgt) protected String
protected boolean
static String
void
setAllowUnknownProfile
(ProfileUtilities.AllowUnknownProfile allowUnknownProfile) setAutoFixSliceNames
(boolean autoFixSliceNames) void
setDebug
(boolean debug) void
setDefWebRoot
(String defWebRoot) void
setForPublication
(boolean forPublication) void
setIds
(StructureDefinition sd, boolean checkFirst) void
setLocalFileNames
(Set<String> localFileNames) void
setMasterSourceFileNames
(Set<String> masterSourceFileNames) void
setMessages
(List<org.hl7.fhir.utilities.validation.ValidationMessage> messages) setNewSlicingProcessing
(boolean newSlicingProcessing) static void
setSuppressIgnorableExceptions
(boolean suppressIgnorableExceptions) void
setTerminologyServiceOptions
(org.hl7.fhir.utilities.validation.ValidationOptions terminologyServiceOptions) void
setThrowException
(boolean exception) void
setWantFixDifferentialFirstElementType
(boolean wantFixDifferentialFirstElementType) setXver
(XVerExtensionManager xver) protected String
sliceNames
(List<ElementDefinition> diffMatches) void
sortDifferential
(StructureDefinition base, StructureDefinition diff, String name, List<String> errors, boolean errorIfChanges) protected String
protected boolean
unbounded
(ElementDefinition definition) protected void
protected void
updateFromBase
(ElementDefinition derived, ElementDefinition base, String baseProfileUrl) protected void
updateFromDefinition
(ElementDefinition dest, ElementDefinition source, String pn, boolean trimDifferential, String purl, StructureDefinition srcSD, StructureDefinition derivedSrc, String path, MappingAssistant mappings) void
protected void
updateFromSlicing
(ElementDefinition.ElementDefinitionSlicingComponent dst, ElementDefinition.ElementDefinitionSlicingComponent src) updateURLs
(String url, String webUrl, ElementDefinition element, boolean processRelatives) Finds internal references in an Element's Binding and StructureDefinition references (in TypeRef) and bases them on the given url
-
Field Details
-
NON_INHERITED_ED_URLS
These extensions are stripped in inherited profiles (and may be replaced by -
DEFAULT_INHERITED_ED_URLS
-
NON_OVERRIDING_ED_URLS
These extensions are ignored when found in differentials -
OVERRIDING_ED_URLS
When these extensions are found, they override whatever is set on the ancestor element -
UD_BASE_MODEL
- See Also:
-
UD_BASE_PATH
- See Also:
-
UD_DERIVATION_EQUALS
- See Also:
-
UD_DERIVATION_POINTER
- See Also:
-
UD_IS_DERIVED
- See Also:
-
UD_GENERATED_IN_SNAPSHOT
- See Also:
-
UD_ERROR_STATUS
- See Also:
-
STATUS_OK
- See Also:
-
STATUS_HINT
- See Also:
-
STATUS_WARNING
- See Also:
-
STATUS_ERROR
- See Also:
-
STATUS_FATAL
- See Also:
-
-
Constructor Details
-
ProfileUtilities
public ProfileUtilities(IWorkerContext context, List<org.hl7.fhir.utilities.validation.ValidationMessage> messages, ProfileKnowledgeProvider pkp, FHIRPathEngine fpe) -
ProfileUtilities
public ProfileUtilities(IWorkerContext context, List<org.hl7.fhir.utilities.validation.ValidationMessage> messages, ProfileKnowledgeProvider pkp)
-
-
Method Details
-
getContext
-
isWantFixDifferentialFirstElementType
-
setWantFixDifferentialFirstElementType
-
isAutoFixSliceNames
-
setAutoFixSliceNames
-
getChildMap
public ProfileUtilities.SourcedChildDefinitions getChildMap(StructureDefinition profile, ElementDefinition element) throws org.hl7.fhir.exceptions.DefinitionException - Throws:
org.hl7.fhir.exceptions.DefinitionException
-
getSliceList
public List<ElementDefinition> getSliceList(StructureDefinition profile, ElementDefinition element) throws org.hl7.fhir.exceptions.DefinitionException - Throws:
org.hl7.fhir.exceptions.DefinitionException
-
getChildList
Given a Structure, navigate to the element given by the path and return the direct children of that element- Parameters:
profile
- The structure to navigate intopath
- The path of the element within the structure to get the children for- Returns:
- A List containing the element children (all of them are Elements)
-
getChildList
public List<ElementDefinition> getChildList(StructureDefinition profile, String path, String id, boolean diff) -
getChildList
public List<ElementDefinition> getChildList(StructureDefinition profile, String path, String id, boolean diff, boolean refs) -
getChildList
public List<ElementDefinition> getChildList(StructureDefinition structure, ElementDefinition element, boolean diff, boolean refs) -
getChildList
public List<ElementDefinition> getChildList(StructureDefinition structure, ElementDefinition element, boolean diff) -
getChildList
public List<ElementDefinition> getChildList(StructureDefinition structure, ElementDefinition element) -
generateSnapshot
public void generateSnapshot(StructureDefinition base, StructureDefinition derived, String url, String webUrl, String profileName) throws org.hl7.fhir.exceptions.DefinitionException, org.hl7.fhir.exceptions.FHIRException Given a base (snapshot) profile structure, and a differential profile, generate a new snapshot profile- Parameters:
base
- - the base structure on which the differential will be appliedderived
- - the differential to apply to the baseurl
- - where the base has relative urls for profile references, these need to be converted to absolutes by prepending this URL (e.g. the canonical URL)webUrl
- - where the base has relative urls in markdown, these need to be converted to absolutes by prepending this URL (this is not the same as the canonical URL)- Throws:
org.hl7.fhir.exceptions.FHIRException
org.hl7.fhir.exceptions.DefinitionException
Exception
-
getById
-
updateConstraintSources
-
getListOfTypes
-
sliceNames
-
isMatchingType
protected boolean isMatchingType(StructureDefinition sd, List<ElementDefinition.TypeRefComponent> types, String inner) -
isValidType
-
isGenerating
-
checkNotGenerating
-
isBaseResource
-
chooseMatchingBaseSlice
-
findBaseSlices
protected List<BaseTypeSlice> findBaseSlices(StructureDefinition.StructureDefinitionSnapshotComponent list, int start) -
getWebUrl
-
removeStatusExtensions
-
descED
-
rootName
-
determineTypeSlicePath
-
isImplicitSlicing
-
diffsConstrainTypes
protected boolean diffsConstrainTypes(List<ElementDefinition> diffMatches, String cPath, List<TypeSlice> typeList) -
redirectorStack
protected List<ElementRedirection> redirectorStack(List<ElementRedirection> redirector, ElementDefinition outcome, String path) -
getByTypeName
protected List<ElementDefinition.TypeRefComponent> getByTypeName(List<ElementDefinition.TypeRefComponent> type, String t) -
replaceFromContentReference
-
baseWalksInto
-
fillOutFromBase
protected ElementDefinition fillOutFromBase(ElementDefinition profile, ElementDefinition usage) throws org.hl7.fhir.exceptions.FHIRFormatError - Throws:
org.hl7.fhir.exceptions.FHIRFormatError
-
checkExtensionDoco
-
pathTail
-
markDerived
-
updateFromBase
protected void updateFromBase(ElementDefinition derived, ElementDefinition base, String baseProfileUrl) -
pathStartsWith
-
fixedPathSource
protected String fixedPathSource(String contextPath, String pathSimple, List<ElementRedirection> redirector) -
fixedPathDest
protected String fixedPathDest(String contextPath, String pathSimple, List<ElementRedirection> redirector, String redirectSource) -
getProfileForDataType
protected StructureDefinition getProfileForDataType(ElementDefinition.TypeRefComponent type, String webUrl, Resource src) -
getProfileForDataType
-
isDataType
-
updateURLs
public ElementDefinition updateURLs(String url, String webUrl, ElementDefinition element, boolean processRelatives) Finds internal references in an Element's Binding and StructureDefinition references (in TypeRef) and bases them on the given url- Parameters:
url
- - the base url to use to turn internal references into absolute referenceselement
- - the Element to update- Returns:
- - the updated Element
-
processRelativeUrls
-
getSiblings
protected List<ElementDefinition> getSiblings(List<ElementDefinition> list, ElementDefinition current) -
updateFromSlicing
-
orderMatches
-
discriminatorMatches
-
ruleMatches
protected boolean ruleMatches(ElementDefinition.SlicingRules diff, ElementDefinition.SlicingRules base) -
isSlicedToOneOnly
-
makeExtensionSlicing
-
isExtension
-
getDiffMatches
protected List<ElementDefinition> getDiffMatches(StructureDefinition.StructureDefinitionDifferentialComponent context, String path, int start, int end, String profileName) throws org.hl7.fhir.exceptions.DefinitionException - Throws:
org.hl7.fhir.exceptions.DefinitionException
-
findEndOfElement
protected int findEndOfElement(StructureDefinition.StructureDefinitionDifferentialComponent context, int cursor) -
findEndOfElement
protected int findEndOfElement(StructureDefinition.StructureDefinitionSnapshotComponent context, int cursor) -
unbounded
-
updateFromObligationProfiles
-
updateFromDefinition
protected void updateFromDefinition(ElementDefinition dest, ElementDefinition source, String pn, boolean trimDifferential, String purl, StructureDefinition srcSD, StructureDefinition derivedSrc, String path, MappingAssistant mappings) throws org.hl7.fhir.exceptions.DefinitionException, org.hl7.fhir.exceptions.FHIRException - Throws:
org.hl7.fhir.exceptions.DefinitionException
org.hl7.fhir.exceptions.FHIRException
-
closeDifferential
public void closeDifferential(StructureDefinition base, StructureDefinition derived) throws org.hl7.fhir.exceptions.FHIRException - Throws:
org.hl7.fhir.exceptions.FHIRException
-
getElementById
protected ProfileUtilities.ElementDefinitionResolution getElementById(StructureDefinition source, List<ElementDefinition> elements, String contentReference) -
describeExtensionContext
-
tail
-
isPrimitive
-
getProfile
-
sortDifferential
public void sortDifferential(StructureDefinition base, StructureDefinition diff, String name, List<String> errors, boolean errorIfChanges) throws org.hl7.fhir.exceptions.FHIRException - Throws:
org.hl7.fhir.exceptions.FHIRException
-
getComparer
public org.hl7.fhir.r5.conformance.profile.ProfileUtilities.ElementDefinitionComparer getComparer(org.hl7.fhir.r5.conformance.profile.ProfileUtilities.ElementDefinitionComparer cmp, org.hl7.fhir.r5.conformance.profile.ProfileUtilities.ElementDefinitionHolder child) throws org.hl7.fhir.exceptions.FHIRException, Error - Throws:
org.hl7.fhir.exceptions.FHIRException
Error
-
sdNs
-
generateSchematrons
public void generateSchematrons(OutputStream dest, StructureDefinition structure) throws IOException, org.hl7.fhir.exceptions.DefinitionException - Throws:
IOException
org.hl7.fhir.exceptions.DefinitionException
-
generateCsv
public void generateCsv(OutputStream dest, StructureDefinition structure, boolean asXml) throws IOException, org.hl7.fhir.exceptions.DefinitionException, Exception - Throws:
IOException
org.hl7.fhir.exceptions.DefinitionException
Exception
-
addToCSV
public void addToCSV(CSVWriter csv, StructureDefinition structure) throws IOException, org.hl7.fhir.exceptions.DefinitionException, Exception - Throws:
IOException
org.hl7.fhir.exceptions.DefinitionException
Exception
-
setIds
public void setIds(StructureDefinition sd, boolean checkFirst) throws org.hl7.fhir.exceptions.DefinitionException - Throws:
org.hl7.fhir.exceptions.DefinitionException
-
generateIds
protected void generateIds(List<ElementDefinition> list, String name, String type, StructureDefinition srcSD) throws org.hl7.fhir.exceptions.DefinitionException - Throws:
org.hl7.fhir.exceptions.DefinitionException
-
generateExamples
public List<Element> generateExamples(StructureDefinition sd, boolean evenWhenNoExamples) throws org.hl7.fhir.exceptions.FHIRException - Throws:
org.hl7.fhir.exceptions.FHIRException
-
populateLogicalSnapshot
public void populateLogicalSnapshot(StructureDefinition sd) throws org.hl7.fhir.exceptions.FHIRException - Throws:
org.hl7.fhir.exceptions.FHIRException
-
cleanUpDifferential
-
interpretR2Discriminator
public static ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent interpretR2Discriminator(String discriminator, boolean isExists) -
buildR2Discriminator
public static String buildR2Discriminator(ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent t) throws org.hl7.fhir.exceptions.FHIRException - Throws:
org.hl7.fhir.exceptions.FHIRException
-
makeExtensionForVersionedURL
-
isThrowException
-
setThrowException
-
getTerminologyServiceOptions
-
setTerminologyServiceOptions
public void setTerminologyServiceOptions(org.hl7.fhir.utilities.validation.ValidationOptions terminologyServiceOptions) -
isNewSlicingProcessing
-
setNewSlicingProcessing
-
isDebug
-
setDebug
-
getDefWebRoot
-
setDefWebRoot
-
makeBaseDefinition
-
makeBaseDefinition
-
getXver
-
setXver
-
processConstraint
-
getMasterSourceFileNames
-
setMasterSourceFileNames
-
getLocalFileNames
-
setLocalFileNames
-
getPkp
-
getRowColor
-
isExtensionDefinition
-
getAllowUnknownProfile
-
setAllowUnknownProfile
-
isSimpleExtension
-
isComplexExtension
-
isModifierExtension
-
isForPublication
-
setForPublication
-
getMessages
-
isResourceBoundary
-
isSuppressIgnorableExceptions
-
setSuppressIgnorableExceptions
-
setMessages
-
getCachedPropertyList
-
checkExtensions
-