protected virtual void encode(Segment source, EncodingCharacters encodingChars, Table tbl)
        {
            TableRow tr;
            TableCell td;
            tr = new TableRow();
            td = new TableCell();
            td.ColumnSpan = 3;
            if(_cssSegmentHeader!=null && _cssSegmentHeader.Trim().Length>0)
            {
                tr.CssClass=_cssSegmentHeader;
            }
            td.Text = source.getStructureName();
            tr.Cells.Add(td);
            tbl.Rows.Add(tr);

            //start at field 2 for MSH segment because field 1 is the field delimiter
            int startAt = 1;
            if (isDelimDefSegment(source.getStructureName()))
                startAt = 2;

            //loop through fields; for every field delimit any repetitions and add field delimiter after ...
            int numFields = source.numFields();
            for (int i = startAt; i <= numFields; i++)
            {
                try
                {
                    tr = new TableRow();

                    td = new TableCell();
                    td.Text = i.ToString();
                    tr.Cells.Add(td);

                    Type[] reps = source.getField(i);
                    string description = source.getFieldDescription(i);
                    td = new TableCell();
                    if(_cssSegmentField!=null)
                        td.CssClass = _cssSegmentField;
                    if(description!=null && description.Trim().Length>0)
                        td.Text = description;
                    else
                        td.Text ="&nbsp;";

                    tr.Cells.Add(td);

                    td = new TableCell();
                    if(reps.Length==0)
                        td.Text = "&nbsp;";
                    else
                    {
                        for (int j = 0; j < reps.Length; j++)
                        {
                            td.Controls.Add(encode(reps[j], encodingChars));
                            if(j<reps.Length-1)
                                td.Controls.Add(new LiteralControl("<hr size='2'>"));
                        }
                    }
                    tr.Cells.Add(td);
                    tbl.Rows.Add(tr);
                }
                catch (HL7Exception e)
                {
                    log.error("Error while encoding segment: ", e);
                }
            }
        }
Beispiel #2
0
        protected virtual void encode(Segment source, EncodingCharacters encodingChars, Table tbl)
        {
            TableRow  tr;
            TableCell td;

            tr            = new TableRow();
            td            = new TableCell();
            td.ColumnSpan = 3;
            if (_cssSegmentHeader != null && _cssSegmentHeader.Trim().Length > 0)
            {
                tr.CssClass = _cssSegmentHeader;
            }
            td.Text = source.getStructureName();
            tr.Cells.Add(td);
            tbl.Rows.Add(tr);


            //start at field 2 for MSH segment because field 1 is the field delimiter
            int startAt = 1;

            if (isDelimDefSegment(source.getStructureName()))
            {
                startAt = 2;
            }

            //loop through fields; for every field delimit any repetitions and add field delimiter after ...
            int numFields = source.numFields();

            for (int i = startAt; i <= numFields; i++)
            {
                try
                {
                    tr = new TableRow();

                    td      = new TableCell();
                    td.Text = i.ToString();
                    tr.Cells.Add(td);

                    Type[] reps        = source.getField(i);
                    string description = source.getFieldDescription(i);
                    td = new TableCell();
                    if (_cssSegmentField != null)
                    {
                        td.CssClass = _cssSegmentField;
                    }
                    if (description != null && description.Trim().Length > 0)
                    {
                        td.Text = description;
                    }
                    else
                    {
                        td.Text = "&nbsp;";
                    }

                    tr.Cells.Add(td);

                    td = new TableCell();
                    if (reps.Length == 0)
                    {
                        td.Text = "&nbsp;";
                    }
                    else
                    {
                        for (int j = 0; j < reps.Length; j++)
                        {
                            td.Controls.Add(encode(reps[j], encodingChars));
                            if (j < reps.Length - 1)
                            {
                                td.Controls.Add(new LiteralControl("<hr size='2'>"));
                            }
                        }
                    }
                    tr.Cells.Add(td);
                    tbl.Rows.Add(tr);
                }
                catch (HL7Exception e)
                {
                    log.error("Error while encoding segment: ", e);
                }
            }
        }