コード例 #1
0
 /// <summary> Encodes the given Type, using the given encoding characters.
 /// It is assumed that the Type represents a complete field rather than a component.
 /// </summary>
 public static System.String encode(Type source, EncodingCharacters encodingChars)
 {
     System.Text.StringBuilder field = new System.Text.StringBuilder();
     for (int i = 1; i <= Terser.numComponents(source); i++)
     {
         System.Text.StringBuilder comp = new System.Text.StringBuilder();
         for (int j = 1; j <= Terser.numSubComponents(source, i); j++)
         {
             Primitive p = Terser.getPrimitive(source, i, j);
             comp.Append(encodePrimitive(p, encodingChars));
             comp.Append(encodingChars.SubcomponentSeparator);
         }
         field.Append(stripExtraDelimiters(comp.ToString(), encodingChars.SubcomponentSeparator));
         field.Append(encodingChars.ComponentSeparator);
     }
     return(stripExtraDelimiters(field.ToString(), encodingChars.ComponentSeparator));
     //return encode(source, encodingChars, false);
 }
コード例 #2
0
        /// <summary> Encodes the given Type, using the given encoding characters.
        /// It is assumed that the Type represents a complete field rather than a component.
        /// </summary>
        protected virtual Control encode(Type source, EncodingCharacters encodingChars)
        {
            if (source is ca.uhn.hl7v2.model.Composite)
            {
                TableCell td;
                TableRow  tr;
                Table     tbl = new Table();
                tbl.Attributes["border"] = _componentBorder.ToString();
                tbl.CellSpacing          = _componentCellSpacing;
                tbl.CellPadding          = _componentCellPadding;
                for (int i = 1; i <= Terser.numComponents(source); i++)
                {
                    for (int j = 1; j <= Terser.numSubComponents(source, i); j++)
                    {
                        tr = new TableRow();
                        Primitive p    = Terser.getPrimitive(source, i, j);
                        Type      type = (Type)p;
                        td = new TableCell();
                        if (_cssComponentField != null)
                        {
                            td.CssClass = _cssComponentField;
                        }
                        string desc = "&nbsp;";
                        if (type.Description != null && type.Description.Trim().Length > 0)
                        {
                            desc = type.Description;
                        }
                        if (j > 1)
                        {
                            desc = "&nbsp;&nbsp;&nbsp;-" + desc;
                        }

                        td.Text = desc;
                        tr.Cells.Add(td);
                        string val = "&nbsp;";
                        if (p.Value != null && p.Value.Trim().Length > 0)
                        {
                            val = p.Value;
                            val = val.Replace(@"\.br\", "<BR>");
                        }
                        td      = new TableCell();
                        td.Text = val;
                        tr.Cells.Add(td);
                        tbl.Rows.Add(tr);
                    }
                }
                return(tbl);
            }
            else
            {
                Primitive p   = Terser.getPrimitive(source, 1, 1);
                string    val = "&nbsp;";

                if (p.Value != null && p.Value.Trim().Length > 0)
                {
                    val = p.Value;
                    val = val.Replace(@"\.br\", "<BR>");
                }
                return(new LiteralControl(val));
            }
        }