
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
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic classclassclassstatic classstatic class -
Field Summary
FieldsModifier 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 intstatic final intstatic final intstatic final intstatic final intstatic final String -
Constructor Summary
ConstructorsConstructorDescriptionProfileUtilities(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 TypeMethodDescriptionvoidaddToCSV(CSVWriter csv, StructureDefinition structure) protected booleanbaseWalksInto(List<ElementDefinition> elements, int cursor) static Stringprotected booleanvoidcheckExtensions(ElementDefinition outcome) protected voidcheckNotGenerating(StructureDefinition sd, String role) protected BaseTypeSlicechooseMatchingBaseSlice(List<BaseTypeSlice> baseSlices, String type) voidvoidcloseDifferential(StructureDefinition base, StructureDefinition derived) protected StringdescED(List<ElementDefinition> list, int index) static Stringprotected StringdetermineTypeSlicePath(String path, String cpath) protected booleandiffsConstrainTypes(List<ElementDefinition> diffMatches, String cPath, List<TypeSlice> typeList) protected booleandiscriminatorMatches(List<ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent> diff, List<ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent> base) protected ElementDefinitionfillOutFromBase(ElementDefinition profile, ElementDefinition usage) protected List<BaseTypeSlice> findBaseSlices(StructureDefinition.StructureDefinitionSnapshotComponent list, int start) protected intfindEndOfElement(StructureDefinition.StructureDefinitionDifferentialComponent context, int cursor) protected intfindEndOfElement(StructureDefinition.StructureDefinitionSnapshotComponent context, int cursor) protected intfindEndOfElementNoSlices(StructureDefinition.StructureDefinitionSnapshotComponent context, int cursor) protected StringfixedPathDest(String contextPath, String pathSimple, List<ElementRedirection> redirector, String redirectSource) protected StringfixedPathSource(String contextPath, String pathSimple, List<ElementRedirection> redirector) voidgenerateCsv(OutputStream dest, StructureDefinition structure, boolean asXml) generateExamples(StructureDefinition sd, boolean evenWhenNoExamples) protected voidgenerateIds(List<ElementDefinition> list, String name, String type, StructureDefinition srcSD) voidgenerateSchematrons(OutputStream dest, StructureDefinition structure) voidgenerateSnapshot(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 ElementDefinitiongetById(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, boolean chaseTypes) getChildMap(StructureDefinition profile, ElementDefinition element, boolean chaseTypes, String type) org.hl7.fhir.r5.conformance.profile.ProfileUtilities.ElementDefinitionComparergetComparer(org.hl7.fhir.r5.conformance.profile.ProfileUtilities.ElementDefinitionComparer cmp, org.hl7.fhir.r5.conformance.profile.ProfileUtilities.ElementDefinitionHolder child) static StringgetCSUrl(StructureDefinition profile) protected List<ElementDefinition> getDiffMatches(StructureDefinition.StructureDefinitionDifferentialComponent context, String path, int start, int end, String profileName) getElementById(StructureDefinition source, List<ElementDefinition> elements, String contentReference) getFpe()List<org.hl7.fhir.utilities.validation.ValidationMessage> getPkp()getProfile(StructureDefinition source, String url) protected StructureDefinitiongetProfileForDataType(String type) protected StructureDefinitiongetProfileForDataType(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.ValidationOptionsstatic StringgetUrlFromCSUrl(String url) protected StringgetWebUrl(StructureDefinition dt, String webUrl) getXver()static booleaninterpretR2Discriminator(String discriminator, boolean isExists) booleanprotected booleanstatic booleanprotected booleanbooleanisDebug()protected booleanisExtension(ElementDefinition currentBase) static booleanbooleanprotected booleanisImplicitSlicing(ElementDefinition ed, String path) protected booleanisMatchingType(StructureDefinition sd, List<ElementDefinition.TypeRefComponent> types, String inner) static booleanbooleanprotected booleanisPrimitive(String value) static booleanstatic booleanprotected booleanstatic booleanbooleanprotected booleanprotected booleanbooleanstatic StructureDefinitionmakeBaseDefinition(String fhirVersion) static StructureDefinitionmakeBaseDefinition(Enumerations.FHIRVersion fhirVersion) static StructureDefinitionmakeExtensionForVersionedURL(IWorkerContext context, String url) protected voidmarkDerived(ElementDefinition outcome) static voidmarkExtensions(ElementDefinition ed, boolean overrideSource, StructureDefinition src) protected booleanorderMatches(BooleanType diff, BooleanType base) protected booleanpathStartsWith(String p1, String p2) protected StringpathTail(List<ElementDefinition> diffMatches, int i) voidprocessConstraint(List<ElementDefinition> children, ElementDefinition.ElementDefinitionConstraintComponent c) static StringprocessRelativeUrls(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 voidreplaceFromContentReference(ElementDefinition outcome, ElementDefinition tgt) protected Stringprotected booleanstatic StringvoidsetAllowUnknownProfile(ProfileUtilities.AllowUnknownProfile allowUnknownProfile) setAutoFixSliceNames(boolean autoFixSliceNames) voidsetDebug(boolean debug) voidsetDefWebRoot(String defWebRoot) voidsetForPublication(boolean forPublication) voidsetIds(StructureDefinition sd, boolean checkFirst) voidsetLocalFileNames(Set<String> localFileNames) voidsetMasterSourceFileNames(Set<String> masterSourceFileNames) voidsetMessages(List<org.hl7.fhir.utilities.validation.ValidationMessage> messages) setNewSlicingProcessing(boolean newSlicingProcessing) voidsetSuppressedMappings(List<String> suppressedMappings) static voidsetSuppressIgnorableExceptions(boolean suppressIgnorableExceptions) voidsetTerminologyServiceOptions(org.hl7.fhir.utilities.validation.ValidationOptions terminologyServiceOptions) voidsetThrowException(boolean exception) voidsetWantFixDifferentialFirstElementType(boolean wantFixDifferentialFirstElementType) setXver(XVerExtensionManager xver) protected StringsliceNames(List<ElementDefinition> diffMatches) voidsortDifferential(StructureDefinition base, StructureDefinition diff, String name, List<String> errors, boolean errorIfChanges) protected Stringprotected booleanunbounded(ElementDefinition definition) protected voidprotected voidupdateFromBase(ElementDefinition derived, ElementDefinition base, String baseProfileUrl) protected voidupdateFromDefinition(ElementDefinition dest, ElementDefinition source, String pn, boolean trimDifferential, String purl, StructureDefinition srcSD, StructureDefinition derivedSrc, String path, MappingAssistant mappings, boolean fromSlicer) voidprotected voidupdateFromSlicing(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_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, boolean chaseTypes) throws org.hl7.fhir.exceptions.DefinitionException - Throws:
org.hl7.fhir.exceptions.DefinitionException
-
getChildMap
public ProfileUtilities.SourcedChildDefinitions getChildMap(StructureDefinition profile, ElementDefinition element, boolean chaseTypes, String type) 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.FHIRExceptionorg.hl7.fhir.exceptions.DefinitionExceptionException
-
getById
-
updateConstraintSources
-
getListOfTypes
-
sliceNames
-
isMatchingType
protected boolean isMatchingType(StructureDefinition sd, List<ElementDefinition.TypeRefComponent> types, String inner) -
isValidType
-
checkNotGenerating
-
isBaseResource
-
chooseMatchingBaseSlice
-
findBaseSlices
protected List<BaseTypeSlice> findBaseSlices(StructureDefinition.StructureDefinitionSnapshotComponent list, int start) -
getWebUrl
-
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
-
isTypeSlicing
-
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) -
findEndOfElementNoSlices
protected int findEndOfElementNoSlices(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, boolean fromSlicer) throws org.hl7.fhir.exceptions.DefinitionException, org.hl7.fhir.exceptions.FHIRException - Throws:
org.hl7.fhir.exceptions.DefinitionExceptionorg.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.FHIRExceptionError
-
sdNs
-
generateSchematrons
public void generateSchematrons(OutputStream dest, StructureDefinition structure) throws IOException, org.hl7.fhir.exceptions.DefinitionException - Throws:
IOExceptionorg.hl7.fhir.exceptions.DefinitionException
-
generateCsv
public void generateCsv(OutputStream dest, StructureDefinition structure, boolean asXml) throws IOException, org.hl7.fhir.exceptions.DefinitionException, Exception - Throws:
IOExceptionorg.hl7.fhir.exceptions.DefinitionExceptionException
-
addToCSV
public void addToCSV(CSVWriter csv, StructureDefinition structure) throws IOException, org.hl7.fhir.exceptions.DefinitionException, Exception - Throws:
IOExceptionorg.hl7.fhir.exceptions.DefinitionExceptionException
-
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
-
markExtensions
public static void markExtensions(ElementDefinition ed, boolean overrideSource, StructureDefinition src) -
hasObligations
-
getSuppressedMappings
-
setSuppressedMappings
-
getCSUrl
-
getUrlFromCSUrl
-
getFpe
-