EdiFabric - Change separator from caret to colon (or any change of separator) - edi

This applies to EdiFabric 6.7.2.
In the code below, I'm loading a list in an 837 EDI format on a D_1328_7 field.
When the EDI is output the List<string> is arranged with a caret (^) separator. I've been informed by the consumer of my EDI 837 file that the separator must be a colon (:).
For the life of me I can't figure out how to change it, or even where the caret separator comes from.
object837.G_HL[_heirachy_HL_Index].G_CLM[_HL_G_CLM_Index].G_LX[_LX_Index].S_SV1.D_1328_7 = new List<string>();
object837.G_HL[_heirachy_HL_Index].G_CLM[_HL_G_CLM_Index].G_LX[_LX_Index].S_SV1.D_1328_7.Add(_diagnosisPointer1);
object837.G_HL[_heirachy_HL_Index].G_C
LM[_HL_G_CLM_Index].G_LX[_LX_Index].S_SV1.D_1328_7.Add(_diagnosisPointer2);
OUTPUT = SV1*HC:98940*75*UN*1*11**1^2**N**
Note the caret between 1 and 2.

Which version are you using and which 837 transaction ?
The caret '^' is the default repetition separator for X12. When you generate EDI you can specify explicitly which separators to use by setting the InterchangeContext in ToEdi(InterchangeContext context = null)

Related

Want file in CSV. I need a Regex to change a space to a comma on each line EXCEPT the Description Field which should remain with a space

Goal:
I want a CSV file as my result. I want to change the space char to a comma on each line of data. BUT, I also need the data for the 3rd field (Description) to remain as is with original space chars. Each line of data is terminated with a newline char.
Flipping spaces to commas on every line is easy with regex. But how do 'bookend' the string of text which will then become the 3rd/Description field and preserve its spaces? Currently I manually change commas back to spaces just in that text string. Painful.
Example of Final result needed (including column names)
Transaction Date,Posting Date,Description,Reference Number,Account Number,Amount
12/23,12/24,GOOGLE*DOMAINS SUPPORT.GOOGLCA,7811,8550,12.00
My sample data:
12/23 12/24 GOOGLE*DOMAINS SUPPORT.GOOGLCA 7811 8550 12.00
01/02 01/04 CREPEVINE - OAKLAND OAKLAND 234567 CA 1087 8220 16.32
01/06 01/07 AB* ABEBOOKS.CO J6YDBX HTTPSWWW.ABEBWA 6289 85332 6.98
01/20 01/21 SQ *BAGEL STREET CAFE Oakland CA 2313 44444 24.43
A few of My Regex attempts
This cmd changes spaces to commas over all 5 lines by combining it with Join cmd. Easy.
And just fyi: "\n" would not work for some reason so I do the <Ctrl+Enter> keys to inject a newline char, ie the two lines. For now it orks fine.
=regexreplace(join("
",A1:A5)," ",",")
RESULT:
12/23,12/24,GOOGLE*DOMAINS,SUPPORT.GOOGLCA,7811,8550,12.00
...
01/02,01/04,CREPEVINE,-,OAKLAND,OAKLAND,CA,1087,8550,16.32
...
Here is my poor attemp to bookend the description field, then flip commas back to spaces, but no luck either.
=REGEXREPLACE(A1,"(,[A-Z]+[A-Z],)"," ")
How do I craft a regex to do this?
cheers,
Damon
Using Regex101 to reverse learn how you did it
Can you try:
=index(if(len(A:A),regexreplace(A:A,"(?U)(.*) (.*) (.*) (\d[^A-Za-z]*) (\d.*) (\d.*)","$1,$2,$3,$4,$5,$6"),))

How to make a variable non delimited file to be a delimited one

Hello guys I want to convert my non delimited file into a delimited file
Example of the file is as follows.
Name. CIF Address line 1 State Phn Address line 2 Country Billing Address line 3
Alex. 44A. Biston NJ 25478163 4th,floor XY USA 55/2018 kenning
And so on all the data are in this format.
First three lines are metadata and then the data.
How can I make it delimited in proper format using logic.
There are two parts in the problem:
how to find the column widths
how to split each line into fields and output a new line with delimiters
I could not propose an automated solution for the first one, because (not knowing anything about the metadata format), there is no clear way to find where one column ends and the next one begins. Some of the column headings contain multiple space-separated words and space is also used as a separator between the headings (and apparently one cannot use the rule "more than one space means the end of a heading name" because there's only one space between "Address line 2" and "Country" - and they're clearly separate columns. Clearly, finding the correct column widths requires understanding English and this is not something that you can write a program for.
For the second problem, things are much easier - once you have the column positions. If you figure the column positions manually (or programmatically, if you know something about the metadata that I don't - and you have a simple method for finding what's a column heading), then a program written in AWK can do this, for example:
cols="8,15,32,40,53,66,83,105"
awk_prog='BEGIN {
nt=split(cols,tabs,",")
delim=","
ORS=""
}
{ o=1 ;
for (i in tabs) { t=tabs[i] ; f=substr($0,o,t-o); sub(" *$","",f) ; print f
delim ; o=t } ;
print substr($0, o) "\n"
}'
awk -v cols="$cols" "$awk_prog" input_file
NOTE that the above program does not deal correctly with the case when the separator character (e.g. ",") appears inside the data. If you decide to use this as-is, be sure to use a separator that is not present in the input data. It may be better to modify the code to escape any separator characters found in the input data (there are different ways to do this - depends on what you plan to feed the output file to).

Behavior of STRING verb

I am reading a COBOL program file and I am struggling to understand the way the STRING command works in the following example
STRING WK-NO-EMP-SGE
','
WK-DT-DEB-PER-FEU-TEM
','
WK-DT-FIN-PER-FEU-TEM
DELIMITED BY SIZE
INTO UUUUUU-CO-CLE-ERR-DB2
I have three possible understandings of what it does:
Either the code concatenate each variables into UUUUUU-CO-CLE-ERR-DB2 and separate each values with ',', and the last variable is delimited by size;
Either the code concatenate each variables into UUUUUU-CO-CLE-ERR-DB2 and separate each values with ',', but all the values are delimited by size (meaning that the DELIMITED BY SIZE in this case applies to all the values passed in the string command;
Or each variable is delimited by a specific character, for example WK-NO-EMP-SGE would be delimited by ',', WK-DT-DEB-PER-FEU-TEM by ',' and WK-DT-FIN-PER-FEU-TEM would then be DELIMITED BY SIZE.
Which of my reading is actually the good one?
Here's the syntax-diagram for STRING (from the Enterprise COBOL Language Reference):
Now you need to know how to read it.
Fortunately, the same document tells you how:
How to read the syntax diagrams
Use the following description to read the syntax diagrams in this
document:
. Read the syntax diagrams from left to right, from top to bottom,
following the path of the line.
The >>--- symbol indicates the beginning of a syntax diagram.
The ---> symbol indicates that the syntax diagram is continued on the
next line.
The >--- symbol indicates that the syntax diagram is continued from
the previous line.
The --->< symbol indicates the end of a syntax diagram. Diagrams of
syntactical units other than complete statements start with the >---
symbol and end with the ---> symbol.
. Required items appear on the horizontal line (the main path).
. Optional items appear below the main path.
. When you can choose from two or more items, they appear vertically,
in a stack.
If you must choose one of the items, one item of the stack appears on
the main path.
If choosing one of the items is optional, the entire stack appears
below the main path.
. An arrow returning to the left above the main line indicates an item
that can be repeated.
A repeat arrow above a stack indicates that you can make more than one
choice from the stacked items, or repeat a single choice.
. Variables appear in italic lowercase letters (for example, parmx).
They represent user-supplied names or values.
. If punctuation marks, parentheses, arithmetic operators, or other
such symbols are shown, they must be entered as part of the syntax.
All that means, if you follow it through, that your number 2 is correct.
You can use a delimiter (when you don't have fixed-length data) or just use the size. Any item which is not explicit in how it is delimited, is delimited by the next DELIMITED BY statement.
One thing to watch for with STRING, which doesn't matter in your case, is that the target field does not get space-padded if the data is shorter than the target. With variable-length data, you need to clear the field to space before the STRING executes.
There is a nuance one must grasp in order to understand the results. DELIMITED BY SIZE can be misleading if one has experience in other programming languages.
Each of the three variables has a size that is defined in WORKING-STORAGE. Let's presume it looks something like this.
05 WK-NO-EMP-SGE PIC X(04).
05 WK-DT-DEB-PER-FEU-TEM PIC X(10).
05 WK-DT-FIN-PER-FEU-TEM PIC X(10).
If the value of the variables were set like this:
MOVE 'BOB' TO WK-NO-EMP-SGE.
MOVE 'Q' TO WK-DT-DEB-PER-FEU-TEM.
MOVE 'D19EIEIO2B' TO WK-DT-FIN-PER-FEU-TEM.
Then one might expect the value of UUUUUU-CO-CLE-ERR-DB2 to be:
BOB,Q,D19EIEIO2B
But it would actually be:
BOB ,Q ,D19EIEIO2B

How to mask specific elements in HL7?

Currently I am learning how to work with HL7 and how to parse it in python. Now I was wondering what happens if a value in a HL7 segment contains a pipe sign, e.g. '|'. How is this sign handled? If there is no masking, it would lead to a crash of the HL7 parser. Is there a masking possibility?
\F\
You should read the relevant sections of chapter 2 of the version 2 standard about how escaping works in version 2.
The HL7 structure has defined escape sequences for the separators like |.
When you look at a HL7 message, the used five delimiters are right after the MSH:
MSH|^~\&
| is the Field separator F
^ the component separator S
~ is the repetition separator (for the second level elements) R
\ is the escape character E
& is the sub-component separator T
So to escape one of the special characters like |, you have to take the escape character and then add the defined letter (F,S, etc.)
So in above case, to escape the | you would have to put \F\. Or escaping the escape character is \E\.
If you like you can also change the delimiters after the MSH completely, but I don't recommend that.

EDI X12 tool is not able to convert the perpendicular as a segment separator

While processing an EDI 210 X12 inbound file, receiving a following exception as EdiInvoice Service process failed: '', hexadecimal value 0x15, is an invalid character. Line 2, position 37.'. Because X12 Input file having a perpendicular in 106 position of ISA 16 element.
Can you please provide a solution to handle this symbol
It is not uncommon to define a segment separator like "|" is the X12 ISA segment (ISA16, character 106 of the ISA segment). Have a look at a related tutorial.
To my knowledge, characters with ASCII codes below 128 (hex 0x80) are allowed.
If your EdiInvoice service cannot handle partner-specific segment separators, you most likely have to contact the developer of your tool or the provider of your service first.
As suggested by eppye: If the sending partner can switch to an "easier" segment separator, this would also be an option, but there has to be a good reason for the partner to invest time and effort.
If the syntax of the EDI 210 X12 message conforms to the specification, the sending partner has no obligation to change anything.
No, neither CR nor CR+LF are allowed as Segment Terminator.
X12 is based on the idea of "graphical characters", to be independent of character encodings. CR is a non-printable character, not a graphical character.
The allowable chars in the basic char list are
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
!"&'()*+,-./:;?="
The extended character list is
"abcdefghijklmnopqrstuvwxyz%#[]_{}\|<>~^`#$"
Supporting the extended characters is a Trading Partner agreement item.
To be "X12 legal", a character from the basic set must be used. If the extended set is supported, a char from it may be used.
"X12 legal" is only as important as your trading partner thinks it is (or their software).
Using CR or CR+LF is not uncommon, even if frowned upon by purists.
Having a CR or CR+LF after each Segment Terminator is more common.
some companies indeed use non-printable character as segment terminator. AFAIK this is OK in ANSI X12. Sort of smart, as you are not allowed to use the segment terminator in your data, and data will (almost;-)) never contain hex 15. I have seen hex 07, carriage return etc..
possible solutions:
1. Contact the provider of the service, they should fix it.
2. Ask edi-partner if they can use other segment terminator.
3. pre-process the file and replace that character. Maybe not possible.
Not sure which EDI tool you're using, but another option is to define the element and segment terminators in your partner profile in your tool. I've done this in Sterling Integrator and know others support this as well.
In your case you need to confirm the trading partner of the below rule so that they may not get mistaken ISA16 with Segment Terminator or Suffix .
ISA16 (Sub Element separator)
Char
3a if the type is Hex
Limited to the values in the ASCII character set.
Segment terminator
~ if the type is Char
7e if the type is Hex.
empty
but if you do, you need to designate a suffix.This element is limited to the values in the ASCII character set.
Suffix
either None
CR (carriage return)
LF(line feed)
CRLF (carriage return/line feed).
Various combination for Segment Terminator and Suffix
Segment terminator
Segment terminator + carriage return
Segment terminator + line feed
Segment terminator + carriage return/line feed
Carriage return
Line feed
Carriage return/line feed

Resources