write data into Interchange Object

Jul 15, 2013 at 8:39 AM

I have parsed Interchange object to get Segment values.Its working fine.

I want to update(inject) the Data into segment like patient Name. How to inject value into Interchange object.

Jul 18, 2013 at 11:41 PM
Edited Jul 18, 2013 at 11:51 PM
You need to first grab the segment that contains the element for the patient name.

So as you know each interchange can contain 1 or more functional groups and each functional group can contain 1 or more transactions

So the first step for you will be getting down to the transaction level because this is your actual document (855, 990 ect) the rest is more or less just the envelope your information will be sent inside.

For the sake of this sample i'm just going to assume there is 1 interchange, 1 functional group and 1 transaction.

Our first step is again to get down to the transaction.
            var tran = interchange.FunctionGroups.First().Transactions.First();
Now that we have our transaction we need to get the segment that contains the element we want to modify.

To find your segment you need to make sure you understand the spec you are working with. To get the segment you need to understand where it really is in the document (is it inside of a loop you will need to find first ect). I will provide the most basic example of getting a segment called "IT1"
var segment = transaction.Segments.FirstOrDefault(o => o.SegmentId == "IT1");
Now we are finally able to modify our segment. I will modify the first element in this segment to hold "myvalue".
Jul 25, 2013 at 10:30 AM
Hi Thanks for your response. I have another Doubt regarding Add new "K3" segment to pass the information to client in 837 file. I tried to add the segment. but its added in last position in the Segments. How to add the K3 segment in between REF and NTE. Could you please assit me to update the K3 in Exact position.

Gnanadesigan k
Jul 29, 2013 at 7:44 PM
Edited Jul 29, 2013 at 7:45 PM
You should be able to do this by modifying the Ansi-*-4010Specification.xml file and just ordering them. Obviously a child segment inside of a loop should remain in that loop or you could have all kinds of other issues.

**PS the placement of this segment should really not matter to you or any other standard translator except for possibly the preference of you manually reading the EDI.