SchemaMap.Tool.Data.Parse
abstract class SchemaMap.Tool.Data.Parse
Provides utility methods for taking apart path strings and putting them back together. Many of these methods were originally in SchemaMap.Data.Read, but all do more than simply read data.Use caution when calling macros other than $$$MapLog* macros in this class. Methods in this class are called from SchemaMap.Tool.Build.Generate to generate the ^SchemaMap.Paths global upon which most of the macros are based.
Method Inventory
- BuildInfoPath()
- ComposePathFromChild()
- ComposePathFromChildPaths()
- FormMapResultObjectFromValues()
- FormPathFromParts()
- GetClassBasedIndexValue()
- GetClassParameterIfAny()
- GetDTLClassname()
- GetDataTypeInfoFromColumn()
- GetFHIRCodeValue()
- GetFHIRDataTypeInfoFromColumn()
- GetFHIRSortOrderIndexValue()
- GetLongestDocumentedPath()
- GetLookupNamesFromClassMethodValue()
- GetNextChildFromRemainderPath()
- GetSDA3DataTypeInfoFromColumn()
- GetTypeWithValueSetForCode()
- GetVariantFieldPath()
- IsPathChildTypeCircular()
- ParseFieldFromPathStartsWith()
- ParseLeafFromPath()
- ParseParentFromPath()
- PathContainsSubFields()
- PathDown()
- PathStartsWith()
- PathUp()
- PivotTop()
- PivotType()
- RemoveListSuffixIfAny()
- ReversePair()
- SetPairFrom()
- SkipFHIRDeepSubpath()
- StripExcessChildRepeats()
Methods
A top path is a path that is directly documented in one of the FHIR schema definitions from HL7.org. It therefore appears in a schema CSV file and contains information in the ^SchemaMap.Paths global.
The InfoPath for a top path is itself.
A deeper path, alternatively called a subpath, is a longer, but still valid path in a FHIR schema. It is not directly documented in the schema definition or in the schema CSV file because that would be redundant, when the FHIR schema definition hierarchy can be navigated from parent to child easily, by clicking online links on HL7.org or in the SchemaMap UI.
The InfoPath for a deeper path is some top path within its own schema.
If this method cannot determine an InfoPath, it returns an empty string.
This method walks up and down path segments, pivoting on path types and BackboneElement types when needed. In the process, when reforming paths, it consults the schema definition, for example regarding cardinality (should there be a [n] in the path).
This method detects if its path walking has become circular, by detecting when its processing has produced an exact repeat of the original path that was input to it, without also finding a solution for that path.
Since it is not possible to anticipate and evade all possible variations on malformed input paths as the value of the original argument, this method also counts its cycles. It stops if it reaches a limit (currently 1000 cycles). In this case it outputs a LOGIC message to ^SchemaMap.Log.
Uses several $$$Map macros, which means it can invoke GetInfoPath. Also see ComposePathFromChildPaths.
The method creates a %ZEN.proxyObject that has the same properties as the %SQL.StatementResult that would be returned from the SchemaMap.Tool.SQL.Read:Map method, if such a row existed in the mapping table.
The caller can send this %ZEN.proxyObject into SchemaMap.Tool.Validate.Datatype:GetInfo to find out what the resulting MapIssues would be, if the row existed. This is handy for SchemaMap.Tool.UI.Edit and for other cases in SchemaMap.Tool. It is also used in each mapping table %OnBeforeSave method, to calculate a MapIssues value.
%DynamicObject doesn't let code access properties on both objects the same way, so did not use it.
Only those properties of the SchemaMap.Tool.SQL.Read:Map %SQL.StatementResult that are actually useful as inputs to GetInfo are supported as input values to this method. These are properties that have some effect on calculating the MapIssues value for a row: SourcePath, SourceValue, SourceTransform, TargetPath, TargetTransform AutoMapped, SubTransform, ClassMethod, DefaultValue, Extension, DependsOn, MapNotes, Append, ExcludeList, Active
Note that whenever the result properties from the Map method change, developers need to see if FormMapResultObjectFromValues needs to be updated, or calls to GetInfo (that depend on it) could break.
Note: since all input paths that are accepted for consideration are top paths,
macros that call *Lookup* methods may be (and should be) avoided in this code.
Such macros call GetInfoPath, and so will cause
The type argument is a string found in the schema table data type column. This method parses the raw value in type, to return various information.
The type string is expected to possibly contain ObjectScript class parameters that constrain the type. The input argument param identifies the class parameter we are looking for in the type string.
This method parses type to find param, and if found, returns the value of param to the caller in two forms: text: a text value, and (when applicable) number: the same value as text, as a numeric value. The caller should know which of these values it needs.
Currently the ObjectScript types this method handles are %String and %Numeric and the ObjectScript class parameters for constraining data types that this method handles are VALUELIST, DISPLAYLIST, MAXLEN, SCALE.
TO DO: Other types and parameters might be needed (but these cover a lot of the cases we need).
typeShortName is just the data type name without any modifiers that might appear after it in the type string.
simpleType is a returned string which tells us which simple type it is: "IsString" "IsInteger", "IsDecimal", "IsBoolean", "IsTime", "IsBinary".
If simpleType is non-empty, generalType is "IsPrimitive". If simpleType is empty, generalType is one of these: "IsCode", "IsReference", "IsBackbone", "IsVariantRoot", or "IsComplex" (the default if not any of the others).
If this method is unable to determine generalType or typeShortName, it sets all of the output values to "". The caller should check for this. There is no valid case where typeShortName or generalType is empty. simpleType may be empty, as above, when no simple type applies.
codeStatus and valueSet apply only if the schema is a FHIR type and the generalType is "IsCode". codeStatus indicates how flexible FHIR is about the value set: "IsPreferred", "IsRequired", "IsExtensible", "IsExample"; valueSet is the name of the value set, or "*" for any value set.
if generalType is "IsReference" then valueSet is a list of the resources that Reference can point to.
if generalType is "IsVariantRoot" then valueSet is a list of the data types the field can have.
For accuracy, for any combination of schema, path, and type input to GetDataTypeInfoFromColumn, SetPathsElementInfo or SetPathsElementInfo must first be called, immediately prior to calling GetDataTypeInfoFromColumn.
This method parses the raw value in type to store various information in the ^SchemaMap.Paths global.
The multiple Output arguments serve various purposes for the caller: codeValue is the part of the type string that contains either the value set name and symbols in parentheses; valueSet is the value set for the code in codeValue (if there is one), without any parentheses or symbols; codeValue may be (*) and valueSet may be * which indicates that any value set is fine.
For the FHIR data types code and Coding, this method seeks a Coding or CodeableConcept ancestor for the input path, to determine which is really the correct value set limitation (if any), because the code or Coding object definition simply uses * (no specific value set)
sortOrder is "spec" for FHIR spec order, or empty string for the default alphabetical.
When sortOrder = "spec" the UI sorts the list of fields in a resource using schema table row ID value for each field. When this is true this method generates simulated schema table row ID values that place FHIR inherited base fields together at the bottom of each resource display table, after all the other fields.
For alphabetical order, the resulting index guarantees the same UI behavior, but using a slightly different convention, to cause the indexes to sort at the end alphabetically.
The result might be the same as the input path, but could be a parent of the input path.
The resulting path might only consist of the resource (left of the colon).
Every documented path is a top path, but many top paths are not documented paths. Top paths (in the ^SchemaMap.Paths global) are derived at import time, based on documented paths (in the schema table).
If the field is also type code or Coding, get the FHIR value set restriction from the parent (or grandparent) object, Store the modified type in the DataType node of the Paths global and return it as the method value. Also store the ancestor field Description in the Description node of the Paths global for the input path.
In all other cases, return the input argument type unchanged, and leave the Paths global unchanged.
Expects a full path including resource name, colon separator, and field path with dot separators, and possibly [n] in it.
If the input path string has no colon separator, return "" (indicating that we are already at the top resource).
Otherwise, parse the input path string to the right of the colon, to get the next level up in the path (working around the [n] convention for collection members). If the path to the right of the colon only had one node (has no dot separators), return the parent resource (left of the colon separator) without the colon (just the resource name).
schema is the "from" schema for the current view. It must be FHIR. If the subpath is too long (more than 1 level below the current level) we wish to exclude it from display. In this case we return true.
Note: the UI offers the grid icon where needed to navigate down levels in the table.