Skip to main content

EnsLib.EDI.X12.Util.Validator

abstract class EnsLib.EDI.X12.Util.Validator

Method Inventory

Parameters

parameter DOMAIN = Ensemble;
Use our own domain for localization

Methods

classmethod CleanupValidationData(pDocID As %Integer)
Kill off validation data for the batch if there is any.
classmethod ConstructBatchReply(pOriginalDoc As EnsLib.EDI.X12.Document, ByRef pSC As %Status, pBatchReplyType As %String = "All", pForceTA1 As %Boolean = 0, pBatchErrorAction As %String = "Indiv", pValidation As %String = "SNIP:1", pLocalApplicationID As %String = "@:@", pAddNackErrText As %Boolean = 0, pCleanupTempValData As %Boolean = 1) as EnsLib.EDI.X12.Document
Construct the Reply Interchange containing a 999 or 997 Transaction Set based on validation against pOriginalDoc
If prior validation data exists, it will be used. Otherwise, this method will perform the validation specified in Validation in type:level format, so SNIP 1 validation is 'SNIP:1' and dm Flag validation is 'Flags:dm'
pSC represents any parsing errors in the original document

pBatchReplyType is string indicating what kind of batch reply should we construct for an Interchange batch we have received Note that all the options here that relate to TA1 segments are used to force a TA1 segment to be generated, often as the only body segment of the reply interchange. This is used to represent the presence or absence of errors in the whole inbound Interchange. However if an error is found in the incoming ISA or IEA that can only be reported in a TA1 segment, then a TA1 will be generated even if the configured setting does not force a TA1 to appear.

- All : Generate a reply Interchange containing a reply notification for every TransactionSet in the Interchange we received
- All+ISA14TA1 : Generate a reply Interchange containing a TA1 segment only if either a 1 appears in field ISA:14 of the ISA header segment or if there is an error at the Interchange level. If no error at the Interchange level, then send a reply for each Transaction Set we received.
- Errors : Generate a reply Interchange containing reply notifications only for TransactionSets in which errors are detected, or an empty Interchange if no error is found
- OnlyIfErrors : Only if errors are found, generate a reply Interchange containing reply notifications only for TransactionSets in which errors are detected
- Successes : Generate a reply Interchange containing reply notifications only for TransactionSets in which no errors are detected, or an empty Interchange if only errors are found
pForceTA1 is a boolean indicating whether to include a TA1 segment in the reply even if there are no Interchange-level errors

pBatchErrorAction is a string indicating what to do when detecting a validation error in a batch Interchange document:
- Reject With All Errors : Reject the whole batch if any error is found in any document within it. Enumerate all errors found if BatchReplyType allows for reporting them. This will prevent forwarding any documents in a batch until all have been read and validated.
- Accept With Errors : Accept documents with errors, but do take note of all errors found if BatchReplyType allows for reporting them. This will prevent forwarding any documents in a batch until all have been read and validated.
- Reject On First Error : Reject the whole batch when the first error is found in any document within it. Don't bother checking for more errors or parsing any further contents of the Interchange. This will prevent forwarding any documents in a batch until all have been read and validated.
- Reject Individual Errors : Reject only those documents within the Interchange that have errors. Forward each acceptable child document to the target config item(s) as soon as it has been read and validated.

pLocalApplicationID is colon-separated Local ID:Qualifier codes representing this (receiving) facility and application
These are used in constructing reply document headers.
The '@' symbol represents using the corresponding field from the incoming message.
If your ID must contain a literal @ symbol, escape it with backslash: '\@'

pAddNackErrText is a boolean indicating whether to add error status text as an extra field in the AK5, AK9, and TA1 segments. This is not part of the X12 standard.

classmethod GetSegmentErrors(pSegment As EnsLib.EDI.X12.Segment, pSNIPLevel As %Integer, pDocType As %String = "", pGSGreater As %Boolean = 1, ByRef pDataElemErrs) as %Integer
classmethod GetTransactionSetErrorCodes(pTransactionSet As EnsLib.EDI.X12.Document, pSNIPLevel As %Integer, ByRef pIK3Errs, pBatchErrorAction As %String = "Indiv") as %String
classmethod PerformSNIPValidation(pOriginalDocument As EnsLib.EDI.X12.Document, pSNIPLevel As %Integer = 1, pBatchErrorAction As %String = "Indiv", pSC As %Status = $$$OK, pCleanupTempValData As %Boolean = 1) as %Status
Perform X12 document validation based on SNIP level criteria.
This returns a %Status code indicating success or failure. It also gathers the information needed for generating a reply or performing batch splitting.
pOriginalDocument is the X12 document to be validated.
pSNIPLevel is an %Integer indicating the level of validation to perform. Supported levels are 1 and 2. pBatchErrorAction is a %String indicating how the validator should behave upon encountering errors. Permitted values are:
"All" - Reject With All Errors : Reject the whole batch if any error is found in any document within it. Enumerate all errors found in the generated reply document.
"Note" - Accept With Errors : Accept documents with errors, but do take note of all errors found. This will always return OK but will include any errors in the generated reply document.
"First" - Reject On First Error : Reject the whole batch when the first error is found in any document within it. Don't bother checking for more errors or parsing any further contents of the Interchange.
"Indiv" - Reject Individual Errors : Reject only those documents within the Interchange that have errors. Parent documents won't fail validation unless all their children fail.
pSC is an optional %Status result of attempting to parse the document stream.
pCleanupTempData is an optional boolean indicator of whether this method will cleanup the temporary global used for storing validation data. This defaults to true, but may be set to false in order to enable batch splitting or to avoid having to perform validation again in order to generate a reply document. If this is set to false, the data can be cleaned up later by calling CleanupValidationData()
classmethod SplitBatch(pOriginalDoc As EnsLib.EDI.X12.Document, Output pGoodBatch As EnsLib.EDI.X12.Document, Output pBadBatch As EnsLib.EDI.X12.Document, pValidationType As %String = "SNIP", pValidationLevel As %String = 1, pReuseOriginalIfMutable As %Boolean = 0, pSaveBadBatch As %Boolean = 1, pCleanupTempValData As %Boolean = 1) as %Status
For X12 batch pOriginalDoc split the batch into two separate batches - one containing only children which pass validation and one containing only children which fail validation. ValidationType can be either SNIP or Flags.
ValidationLevel is either the SNIP level or the validation flags to use.
If prior validation data exists, it must match the Type and Level specified. If SNIP validation, it must have been batch handling of 'Indiv' and if Flags validation, it must have 'e' in the ValSpec to ensure all errors are recorded. If prior validation data exists and does not match, call CleanupValidationData() first.
pReuseOriginalIfMutable is an optional boolean indicator to modify the pOriginalDoc if its IsMutable property is false rather than creating a new X12 document object for the pGoodBatch. If this is set to true and there are no errors, then the returned pGoodBatch will be pOriginalDoc. If this is set to false and there are no errors, then the returned pGoodBatch will be a clone of the original. The default is false.
pSaveBadBatch is an optional boolean indicator to create the pBadBatch object. If false, no new X12 document object will be created and the parameter will return a NULLOREF. The default is true.
pCleanupTempData is an optional boolean indicator of whether this method will cleanup the temporary global used for storing validation data. This defaults to true, but may be set to false in order to avoid having to perform validation again in order to generate a reply document. If this is set to false, the data can be cleaned up later by calling CleanupValidationData()
classmethod SplitGroup(pOriginalDoc As EnsLib.EDI.X12.Document, Output pGoodGroup As EnsLib.EDI.X12.Document, Output pBadGroup As EnsLib.EDI.X12.Document, pValidationType As %String = "SNIP", pValidationLevel As %String = 1, pReuseOriginalIfMutable As %Boolean = 0, pSaveBadGroup As %Boolean = 1, pCleanupTempValData As %Boolean = 1) as %Status
For X12 Group pOriginalDoc split the Group into two separate Groups - one containing only Transaction Sets which pass validation and one containing only Transaction Sets which fail validation. ValidationType can be either SNIP or Flags.
ValidationLevel is either the SNIP level or the validation flags to use.
If prior validation data exists, it must match the Type and Level specified. If SNIP validation, it must have been batch handling of 'Indiv' and if Flags validation, it must have 'e' in the ValSpec to ensure all errors are recorded. If prior validation data exists and does not match, call CleanupValidationData() first.
pReuseOriginalIfMutable is an optional boolean indicator to modify the pOriginalDoc if its IsMutable property is false rather than creating a new X12 document object for the pGoodGroup The default is false.
pSaveBadGroup is an optional boolean indicator to create the pBadGroup object. If false, no new X12 document object will be created and the parameter will return a NULLOREF. The default is true.
pCleanupTempData is an optional boolean indicator of whether this method will cleanup the temporary global used for storing validation data. This defaults to true, but may be set to false in order to avoid having to perform validation again in order to generate a reply document. If this is set to false, the data can be cleaned up later by calling CleanupValidationData()
classmethod Validate(pDoc As EnsLib.EDI.X12.Document, pValSpec As %String = 1, pValidateChildren As %Boolean = 1, pSetTempValData As %Boolean = 0, pBatchErrorAction As %String = "Indiv") as %Status
pDoc is the X12 document to validate. pValSpec is a string specifying types of Validation to perform

Set to 1 to block documents that don't pass default validation. Default validation requires a DocType and blocks messages with any other error encountered while mapping the document's sequence of segments using the X12 schema structure specified by the document's DocType. This is equivalent to 'dm'.

All flags relating to fields/components apply only if 's'/'c' also specified (eg. if set to 'dmslt' then the length and datatype of fields will be checked, but the length and datatype of components will not be)

'd' - require DocType
'm' - don't tolerate BuildMap segment mapping errors
's' - enforce segment structures (number and repetition of fields)
'c' - enforce composite structures (number of components)
'r' - enforce required fields/components being present
'u' - enforce non-use of fields/components marked 'Not Used' - Note this is not available when using a new-style only schema
'l' - enforce field/component length restrictions
't' - enforce correct datatypes used for field/component values
'v' - enforce correct code table values used where specified in the schema - Note this is not available when using a new-style only schema
'x' - enforce relational conditions where specified in the schema - Note this is not available when using a new-style only schema
'n' - perform all validation available to new style schemas. This is equivalent to 'dmscrlt'
'a' - perform all available validation. This is equivalent to 'dmscrultv'
'e' - continue validating after errors are encountered - specify this to scan the entire document and report all errors

pValidateChildren is a boolean indication of whether we should only validate at the current level (false) or validate any nested children (true). The default is true. pSetTempValData is a boolean indication of whether to set the temporary data needed for generating reply documents and performing batch splitting. The default is false. pBatchErrorAction is relevant only if pSetTempValData is true. For batch splitting, this must have a value of 'Indiv'. See the EnsLib.EDI.X12.Service.Standard property 'BatchErrorAction' for other options.

classmethod ValidateDateTime(pValue As %String, pFormat As %String) as %Integer
Validate that date/time value pValue which is expected to follow format code pFormat Expected formats for each code are as follows:
'CC' = 'First Two Digits of Year Expressed in Format CCYY'
'CD' = 'Month and Year Expressed in Format MMMYYYY'
'CM' = 'Date in Format CCYYMM'
'CQ' = 'Date in Format CCYYQ'
'CY' = 'Year Expressed in Format CCYY'
'D6' = 'Date Expressed in Format YYMMDD'
'D8' = 'Date Expressed in Format CCYYMMDD'
'DA' = 'Range of Dates within a Single Month Expressed in Format DD-DD'
'DB' = 'Date Expressed in Format MMDDCCYY'
'DD' = 'Day of Month in Numeric Format'
'DT' = 'Date and Time Expressed in Format CCYYMMDDHHMM'
'DTS' = 'Range of Date and Time Expressed in Format CCYYMMDDHHMMSS-CCYYMMDDHHMMSS'
'EH' = 'Last Digit of Year and Julian Date Expressed in Format YDDD'
'KA' = 'Date Expressed in Format YYMMMDD'
'MD' = 'Month of Year and Day of Month Expressed in Format MMDD'
'MM' = 'Month of Year in Numeric Format'
'RD' = 'Range of Dates Expressed in Format MMDDCCYY-MMDDCCYY'
'RD2' = 'Range of Years Expressed in Format YY-YY'
'RD4' = 'Range of Years Expressed in Format CCYY-CCYY'
'RD5' = 'Range of Years and Months Expressed in Format CCYYMM-CCYYMM'
'RD6' = 'Range of Dates Expressed in Format YYMMDD-YYMMDD'
'RD8' = 'Range of Dates Expressed in Format CCYYMMDD-CCYYMMDD'
'RDM' = 'Range of Dates Expressed in Format YYMMDD-MMDD'
'RDT' = 'Range of Date and Time, Expressed in Format CCYYMMDDHHMM-CCYYMMDDHHMM'
'RMD' = 'Range of Months and Days Expressed in Format MMDD-MMDD'
'RMY' = 'Range of Years and Months Expressed in Format YYMM-YYMM'
'RTM' = 'Range of Time Expressed in Format HHMM-HHMM'
'RTS' = 'Date and Time Expressed in Format CCYYMMDDHHMMSS'
'TC' = 'Julian Date Expressed in Format DDD'
'TM' = 'Time Expressed in Format HHMM'
'TQ' = 'Date Expressed in Format MMYY'
'TR' = 'Date and Time Expressed in Format DDMMYYHHMM'
'TS' = 'Time Expressed in Format HHMMSS'
'TT' = 'Date Expressed in Format MMDDYY'
'TU' = 'Date Expressed in Format YYDDD'
'UN' = 'Unstructured'
'YM' = 'Year and Month Expressed in Format YYMM'
'YMM' = 'Range of Year and Months, Expressed in CCYYMMM-MMM Format'
'YY' = 'Last Two Digits of Year Expressed in Format CCYY'
classmethod ValidateOneDataElem(pValue As %String, pElemPosition As %Integer, pElemData, pOldData As %Integer, pDTFormat As %String = "", pSNIPGreater As %Boolean = 0, ByRef pIK304 As %Integer = 0, ByRef pDataElemErrs As %Integer = 0, pEleSep As %String = $$$X12DefElementSeparator) as %String
FeedbackOpens in a new tab