Smooks: How to process segments in varying order in EDI X12? - edi

I am working with Smooks to process receiving EDI messages from different vendors. I am using ejc to read the messages to get from EDI -> Java. The problem I am having is that one provider is having a segment in a different order as the rest in their EDI message.
I would hate to basically have to duplicate all of the domain code, configuration, and branch the process just to handle one segment appearing in a different order. How can I have Smooks not care about the specific order the segments are in while processing EDI -> Java via ejc?

Ahh .... I think the only option you have is if you can somehow define these different variations in the edi mapping model schema used to generate the Java object model.

Related

Is there a common way to write addresses of facilities in HL7 SIU/ADT messages?

I've found several references to SAD/AD/XAD data types in the HL7 spec, but don't see anything about this info being used to describe facilities, such as those described in the AIL segment (e.g. "2^BLUE HILL FACILITY"). But where, if anywhere, can I expect to get data about that facility, such as name, street address, etc.?
In the PV1 segment definition for HL7 2.x there isn't a dedicated field for Facility Address specifically. If you are the receiving system in this case, you may have to request that data be sent or added in from the sending system. This could be as simple as placing it in the PV1-5.X field (X being whatever subfield the sending system decides on), or adding in a custom Z segment (ZPV for example) to have this data transmitted.
Since there is no standard field for this kind of data in the PV1 segment though, you will have to confirm that the sending system can in fact send this data.
The facility name will be in a separate field. It varies from segment to segment. You just have to read the segment definition and pick the right field.

Relevance of Segment names in EDI

I have been working with EDI documents for the past few months and dealt with different EDI formats like 810 (Invoice), 850 (PO), 855 (PO Ack) etc.
I just wonder where does this Segment names comes from? What is the exact definition for each segment? Like ISA, GS, GE, IEA etc.
Also beginning of a segment possess different values for each document formats. Like BIG for 810, BEG for 850 etc. Where does these abbreviations comes from?
They come from the implementation guides. This is an example of one of them: http://www.att.com/Common/docs/EDI_820_Guide.pdf
Traditional EDI (segments/elements) documents are defined by a governing standards body, usually ANSI (X12) or EDIFACT (U.N. standard). (TRADACOMS and HL7 are also standards bodies) These entities created and published the document types, enveloping, segment names and definitions, element data types and size, component elements, etc. http://www.x12.org/ is the main site for the X12 standard (predominantly found in the US). EDIFACT can be found here: http://www.unece.org/cefact/edifact/welcome.html. These groups are repsonsible for pushing the standard further as business requirements evolve and new data attributes are created. Version 4010 in the ANSI X12 was the first Y2K compliant X12 standard released. There have been many versions released since then, but many still use version 4010 as their standard.
The decision makers made some segments somewhat "mnemonic", so that you can easily determine what kind of information is in the segment. BEG is a good example of this, as common sense would dictate it is "Beginning" of the transaction. Of course, this doesn't apply consistently in the standard. N1 for Names and Addresses, TD3 and TD5 for routing and lading qty.
The end users would then devise their own guideline as to how they implemented the standard. In some cases you'll find some bastardization of the standard to fit special case needs.
Most translators come with some kind of built-in Dictionary Viewer where you can browse. X12 is mostly closed-source and the commercial translator makers pay X12 to include the library. EDIFACT (which is not your example above) is published free of charge. There is a free tool from Liaison called EDI Notepad that you can download and get a sense of the syntax and validation. That can be found here: https://www.liaison.com/products/integrate/edi-notepad/edi-dictionary-viewer/

Can an attachment be split in an HL7 file and recreated after the message is transmitted?

I am using the HAPI parser to parse the HL7 files that come through my company. We are working on moving attachments through the OBX segment of the HL7 file. There are some validators that my stack uses that will not allow an attachment over 64k to pass. Is there a way to take multiple OBX segments and break an attachment up and then recreate it after it has passed through the wire to the other side?
HL7 identifies two possible cases and uses continuation pointer protocol for each. These cases are:
A single segment may be too large. HL7 uses the "ADD" segment to handle breaking a single segment into several smaller segments.
A single HL7 message may be too large. HL7 uses the DSC segment (in conjunction with the MSH-14 filed) and the continuation protocol to handle message fragmentation.
Chapter 2 “Controls” of the HL7v2 spec talks about it in more details.

How to understand an EDI file?

I've seen XML before, but I've never seen anything like EDI.
How do I read this file and get the data that I need? I see things like ~, REF, N1, N2, N4 but have no idea what any of this stuff means.
I am looking for Examples and Documentations.
Where can I find them?
Aslo
EDI guide i found says that it is based on " ANSI ASC X12/ ver. 4010".
Should I search form X12 ?
Kindly help.
Several of these other answers are very good. I'll try to fill in some things they haven't mentioned.
EDI is a set of standards, the most common of which are:
ANSI X12 (popular in the states)
EDIFACT (popular in Europe)
Sounds like you're looking at X12 version 4010. That's the most widely used (in my experience, anyway) version. There are lots and lots of different versions.
The file, or properly "interchange," is made up of Segments and Elements (and sometimes subelements). Each segment begins with a two- or three-word identifier (ISA, GS, ST, N1, REF).
The structure for all documents begins and ends with an envelope. The envelope is usually made up of the ISA segment and the GS segments. There can be more than one GS segment per file, but there should only be one ISA segment per file (note the should, not everyone plays by the rules).
The ISA is a special segment. Whereas all the other segments are delimited, and therefore can be of varying lenghts, the ISA segment is of fixed width. This is because it tells you how to read the rest of the file.
Start with the last three characters of the ISA segment. Those will tell you the element delimiter, the sub-element delimiter, and the segment delimiter. Here's an example ISA line.
ISA:00: :00: :01:1515151515 :01:5151515151 :041201:1217:U:00403:000032123:0:P:*~
In this case, the ":" is the element delimiter, "*" is a subelement delimiter, and "~" the segment delimiter. It's much easier if you're just trying to look at a file to put linebreaks after each segment delimiter (~).
The ISA also tells you who the document is from and to, what the version is (00403, which is also known as 4030), and the interchange control number (0000321233). The other stuff is probably not important to you at this stage.
This document is from sender "01:1515151515" and to receiver "01:5151515151". So what's with the "01:"? Well, this introduces an important concept in EDI, the qualifier. Several elements have qualifiers, which tell you what type of data the next element is. In this case, the 01 is supposed to be a Dunn and Bradstreet number. Other qualifiers for the ISA05 and ISA07 elements are 12 for phone number, and ZZ for "user defined". You'll find the concept of qualifiers all over EDI segments. A decent rule of thumb is that if it's two characters, it's a qualifier. In order to know what all the qualifiers mean, you'll need a standards guide (either in hard copy from the EDI standards body, or in some software).
The next line is the GS. This is a functional group (a way to group like documents together within an interchange.) For instance, you can have several purchase orders, and several functional acknowledgements within an ISA. These should be placed in separate functional groups (GS segments). You can figure out what type of documents are in a GS segment by looking at the first GS01 element.
GS:PO:9988776655:1122334455:20041201:1217:128:X:004030
Besides the document type, you can see the from (9988776655) and to (1122334455) again. This time they're using different identifiers, which is legal, because you may be receiving an interchange on behalf of someone else (if you're an intermediary, for instance). You can also see the version number again, this time with the trailing "0" (0004030). Use significant digits logic to strip off the leading zeros. Why is there an extra zero here and not in the ISA? I don't know. Lastly this GS segment also has it's own identifier, 128.
That's it for the beginning of the envelope. After that there will be a loop of documents beginning with ST. In this case they'd all be POs, which have a code (850), so the line would start with ST:850:blablabla
The envelope stuff ends with a GE segment which references the GS identifier (128) so you know which segment is being closed. Then comes an IEA which similarly closes out the ISA.
GE:1:128~
IEA:1:000032123~
That's an overview of the structure and how to read it. To understand it you'll need a reference book or software so you understand the codes, lots and lots of time, and lots and lots of practice. Good luck, and post again if you have more specific questions.
Wow, flashbacks. It's been over sixteen years ...
In principle, each line is a "segment", and the identifiers are the beginning of the line is a segment identifier. Each segment contains "elements" which are essentially positional fields. They are delimited by "element delimiters".
Different segments mean different things, and can indicate looping constructs, repeats, etc.
You need to get a current version of the standard for the basic parsing, and then you need the data dictionary to describe the content of the document you are dealing with, and then you might need an industry profile, implementation guide, or similar to deal with the conventions for the particular document type in your environment.
Examples? Not current, but I'm sure you could find a whole bunch using your search engine of choice. Once you get the basic segment/element parsing done, you're dealing with your application level data, and I don't know how much a general example will help you there.
EDI is a file format for structured text files, used by lots of larger organisations and companies for standard database exchange. It tends to be much shorter than XML which used to be great when data packets had to be small. Many organisations still use it, since many mainframe systems use EDI instead of XML.
With EDI messages, you're dealing with text messages that match a specific format. This would be similar to an XML schema, but EDI doesn't really have a standardized schema language. EDI messages themselves aren't really human-readable while most specifications aren't really machine-readable. This is basically the advantage of XML, where both the XML and it's schema can be read by humans and machines.
Chances are that when you're doing electronic banking through some client-side software (not browser-based) then you might already have several EDI files on your system. Banks still prefer EDI over XML to send over transaction data, although many also use their own custom text-based formats.
To understand EDI, you'll have to understand the data first, plus the EDI standard that you want to follow.
Assuming the data stream starts with “ISA”, towards the beginning there should be a section “~ST*” followed by three numeric digits. If you can post these three digits, I can probably provide you with more information. Also, knowing the industry would be helpful. For example, healthcare uses 270, 271, 276, 277 and a few others.

EDI Format

I've read XML or CSV before, but I've never seen anything like EDI.
How do I read this file and get the data that I need? I see things like ~, REF, N1, N2, N4 but have no idea what any of this stuff means.
I've seen somethings about x12 but don't know if thats what I have or not, how can I tell?
-- update
Thanks guys for the quick responses. Does anyone know of a parser that I can use in .Net? In the long run, I'm going to be converting this EDI file to a CSV file...
EDI messages are defined by the X12 standard.
If you look for X12 parsers, you can find helpful information.
For example, http://code.activestate.com/recipes/299485/
Those are ANSI X12 Files the standard is managed here http://www.wpc-edi.com/
Brief tutorial on structure
Hierarchy = Loops-> Segments -> Elements -> Sub Elements.
Loops are bounded either by control segments or logically based on the standard.
Segments are separated by the segment terminator, by default ~
Elements are separated by the element separator, by default *
Sub Elements are separated by sub element separator, by default :
EDI is a delimited file format. You have to know both the line delimiter and the column delimiter (for lack of a better answer). You might, for example, see an EDI file with the following format (from http://www.slik.co.nz/HTML_help/edi_file_format.htm):
HDR|6||||
DTL|1|ABC|xyz|123|1
DTL|13|ABC|animal|334|1
DTL|11|ABC|sfdk|432|2
DTL|12|ABC|wewdc|3|1
DTL|14|ABC|qwdx|416|4
The first line is the header and tells you there are six records. The other lines are detail lines.
X12 is one standard used by EDI. You will see X12 used commonly in healthcare. If you have X12, you can examine the X12 standard to figure out how to parse.
EDI stands for Electronic Data Interchange...
It's not a specific format per-se. Generally speaking it's a flat text file of data that usually has an associated published specification. For example: "Position 23-34 is the original price as a monetary value"
You really won't be able to do anything useful with an EDI file if you don't have the defined specification that goes along with it.
Once you get the specification, I believe how to read the file will be quite clear.
Generally the process is:
1. Read/Parse the EDI file.
2. Perform any processing/transformation on that data that you need to.
3. Persist it into your local system format (tables, other flat files, whatever).
Sorry there's not much more we could tell you unfortunately.
EDI stands for “Electronic Data Interchange.” The practice involves using computer technology to exchange information – or data – electronically between two organizations, called “Trading Partners.” Technically, EDI is a set of standards that define common formats for the information so it can be exchanged in this way.
Read more: http://www.1edisource.com/learn-about-edi/what-is-edi#ixzz2g5E4p2ET
EDI is just a flat file that contain some type of hierarchy. Usually companies buy EDI translator software to parse those files and extract data and then integrate with other systems. You can also use some type of service and they will do that for you. You can try to use Amosoft EDI Serices (www.amosoft.com) and they can help you with that.

Resources