Skip to main content

HS.InteropTools.HL7.GenerateDTL.BuildHelper

class HS.InteropTools.HL7.GenerateDTL.BuildHelper extends %Library.RegisteredObject

The BuildHelper class can be extended to change behaviour of the DTL processing.
Settings:
ADDDDELIMITERSCRUBBER Boolean 0 - Default don't add a cleanup/removal of trailing delimiters, 1 - Add a method to cleanup any trailing delimiters.
ALLSTANDARDCONVERSION - String listing the methods to execute for source to target comparison ie ToUpper or ToLower.
LOOKUPTYPES - $list of field types to generate lookups for. When a clear pattern is determined x->y, a->b, e->f a lookup table will be created.
EVALUATEMAXDIFFERENT - Related to LOOKUPTYPES, the number of values different values to review before determining it cannot be a lookup (default is 200).
MAXSWITCH - When set, a CASE statement will be generated instead of a lookup table. The expectation is that this would be a small number.
DISABLESTATEMENTS - Default is 1, if there isn't 100% certainty the statement will be disabled when set to 1, a value of 0 will leave the statements enabled.
USELOOPSFORSINGLEITEMS - When set to 1, a FOR loop will be used even when there is only a single item in the data, versus a setting of 0 which will code with (1).

Additional methods can be added for field level manipulation. For example formatting a phone number in PID 13.1, we name the method PID013001 to match the field position.
In the method we take arguments of pSource and pTarget which are string values of the source and target, also accept parameter args... which will allow for future functionality.
Inside the method any functionality can be performed to determine given the source and target what transformation needs to be applied. If a transformation can be determined, return the string representing the transformation. If for every source /target combination the same string is returned that string will be used in the generated DTL.
  /// Create a helper class by extending HS.InteropTools.HL7.GenerateDTL.BuildHelper<br>
  /// In this example we have a very generic function which will format the phone number and / or remove formatting to try to match to the target value.  ie source is 5555551212 target is (555) 555-1212 or vice versa
  ClassMethod PID013001(pSource As %String, pTarget As %String, args...) As %String
  {
  	If ..FormatPhone(pSource)=pTarget {
  		Return "##class("_$className()_").FormatPhone({sourceref})"
  	}
  	If ..UnformatPhone(pSource)=pTarget {
  		Return "##class("_$className()_").UnformatPhone({sourceref})"
  	}
  	Return ""
  }
  
  /// Format a phone number 555-555-1212
  ClassMethod FormatPhone(pSource) As %String
  {
  	Quit "("_$E(pSource,1,3)_") "_$E(pSource,4,6)_"-"_$E(pSource,7,10)
  }
  
  /// remove formatting from phone number
  ClassMethod UnformatPhone(pSource) As %String
  {
  	Quit $Zstrip(pSource,"*P")
  }
  

Method Inventory

Parameters

parameter ADDDELIMITERSCRUBBER = 1;
Remove trailing delimiters
parameter ALLSTANDARDCONVERSION = ToUpper,ToLower,StripLeadingWhiteSpace,StripTrailingWhiteSpace,StripPunctuation;
List of methods which are standard data conversions ie ToUpper,ToLower, etc
parameter DISABLESTATEMENTS = 1;
By default, if there isn't 100% certainty the statement will be disabled when DISABLESTATEMENTS is 1, a value of 0 will not disable the statements.
parameter EVALUATEMAXDIFFERENT = 200;
When reviewing source value '= target value how many to review before determining it can't be lookup
parameter LOOKUPTYPES;
The HL7 v2 data type of a field which can be found in Interoperability -> Interoperate -> HL7 v2.x -> HL7 v2.x Schema Structures. After selecting a category ie 2.8 and Segment Structure, ie MSH, the Data Structure column
parameter MAXSWITCH = 0;
When determining replace values for source->target (generally a lookup table) it's possible to generate a switch statement. If for instance MAXSWITCH = 3, and there were 3 (or fewer) different source / target values ie Male -> M, Female -> F, Unkown -> U a switch statement would be generated
parameter USELOOPSFORSINGLEITEMS = 0;
if in the data analysis we only see a single data item, don't use a loop, code it as a single item, setting parameter to 1 will always generate a loop

Methods

classmethod AddTrimTrailing(pBuild As HS.InteropTools.HL7.GenerateDTL.Build, ByRef pTransform As Ens.DTL.Transform) as %Status
@API
Add ability to update pTransform, adding a delimiter scrubber (remove all trailing delimters)
@argument pBuild - not generally used but has properties relevant to DTL available, ie pBuild.Template
@argument pTransform - the current form of the transform, any updates made here will update the saved DTL
classmethod AddVersionInformation(pBuild As HS.InteropTools.HL7.GenerateDTL.Build, ByRef pTransform As Ens.DTL.Transform) as %Status
@API
Extend build helper and override as needed. This method provides the ability to generate version / conversion information, here the code generates a new DTL group and inserts it at the beginning
@argument pBuild - not generally used but has properties relevant to DTL available, ie pBuild.Template
@argument pTransform - the current form of the transform, any updates made here will update the saved DTL
classmethod DelimiterScrub(pHL7 As EnsLib.HL7.Message) as EnsLib.HL7.Message
@API Remove trailing empty delimiters from HL7v2 message, from the field and from the segment.
identification of the stream as encoded or not.
@argument pHL7 - message to strip trailing delimiters from
classmethod StripLeadingWhiteSpace(pSourceValue As %String, pTargetValue As %String, args...) as %String
@API
Convert pSourceValue to strip leading white space and compare to pTargetValue returning ..Strip({sourceref}," @argument pSourceValue - The source document field value
@argument pTargetValue - The target document field value
Additional arguments available for future use
classmethod StripPunctuation(pSourceValue As %String, pTargetValue As %String, args...) as %String
@API
Convert pSourceValue to strip punctuation and compare to pTargetValue returning ..Strip({sourceref},"*P") when there is a match
@argument pSourceValue - The source document field value
@argument pTargetValue - The target document field value
Additional arguments available for future use
classmethod StripTrailingWhiteSpace(pSourceValue As %String, pTargetValue As %String, args...) as %String
@API
Convert pSourceValue to strip trailing white space and compare to pTargetValue returning ..Strip({sourceref},">W") when there is a match
@argument pSourceValue - The source document field value
@argument pTargetValue - The target document field value
Additional arguments available for future use
classmethod ToLower(pSourceValue As %String, pTargetValue As %String, args...) as %String
@API
Convert pSourceValue to lower case and compare to pTargetValue returning ..ToLower({sourceref}) when there is a match
@argument pSourceValue - The source document field value
@argument pTargetValue - The target document field value
Additional arguments available for future use
classmethod ToUpper(pSourceValue As %String, pTargetValue As %String, args...) as %String
@API
Convert pSourceValue to upper case and compare to pTargetValue returning ..ToUpper({sourceref}) when there is a match
@argument pSourceValue - The source document field value
@argument pTargetValue - The target document field value
Additional arguments available for future use
classmethod UpdateCode(pBuild As HS.InteropTools.HL7.GenerateDTL.Build, ByRef pTransform As Ens.DTL.Transform) as %Status
@API.Overidable Method which can be overridden to update the dtl post processing. By default this helper will add a Version Header will be created (with AddVersionInformation method) and optionally code to strip trailing delimiters added when parameter ADDDELIMITERSCRUBBER = 1 @argument pBuild - not generally used but has properties relevant to DTL available, ie pBuild.Template
@argument pTransform - the current form of the transform, any updates made here will update the saved DTL

Inherited Members

Inherited Methods

FeedbackOpens in a new tab