简体   繁体   中英

c# how to add multiple RDT segments on NHapi using HL7 version 2.5.1

I'm working with nHapi v2.5.0.6 and I'm trying to create multiple RDT segments for HL7 v2.5.1.

The segments should look like this:

RDT|555444222111|Adam||19600614|M|
RDT|555444222112|Adam2||19600615|F|
RDT|555444222113|Adam3||19600616|M|

But the most I can do, is this:

RDT|555444222111
RDT|555444222112
RDT|555444222113

I don't know how to add fields after the first one!

This is my code:

private void addSegmentRDT2(DataTable informationTable)
{
    //RDT|555444222111|||19600614|M|
    var tbr_r08 = new TBR_R08();
    int rowNumber = 0;
    foreach (DataRow row in informationTable.Rows)
    {
        var RTD = tbr_r08.AddRDT();
        int columnNumber = 0;
        foreach (DataColumn column in informationTable.Columns)
        {
            NHapi.Model.V23.Datatype.ST a = new NHapi.Model.V23.Datatype.ST(tbr_r08.Message);
            a.Value = row[column]?.ToString() ?? "";
            RTD.ColumnValue.Data = a;
        }
    }
} 

Any help will be appreciated. Thanks

This is how I resolve the problem, is not the most elegant solution but it works :).


private void addSegmentRDT(DataTable informationTable)
            {
                var rowNumber = 0;
                var tbr_r08 = new TBR_R08();
                foreach (DataRow row in informationTable.Rows)
                {
                    var RTD = tbr_r08.AddRDT();
                    var values = new Varies(tbr_r08.Message);
                    var columnNumber = 0;
                    foreach (DataColumn column in informationTable.Columns)
                    {
                        var rowColumnValue = row[columnNumber]?.ToString() ?? "";
                        var HL7String = new NHapi.Model.V23.Datatype.ST(tbr_r08.Message);
                        HL7String.Value = rowColumnValue;
                        values.ExtraComponents.getComponent(columnNumber).Data = HL7String;                     
                        ++columnNumber;
                    }
                    RTD.ColumnValue.Data = values;
                    ++rowNumber;
                }
            }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM