Ancestor: HL7Connect.V2.DataObject

The common Component lays down common content management for the subcomponent, component and DataElement classes.

The cell may have actual contents if it doesn't have children. When the cell has contents, the content is stored internally as a sequence of content parts. The content parts may consist of a single null (for ""), or a sequence of Text, Escape and Binary Parts in any order.

The internal representation enables the full content of any valid HL7 message to be stored, but these features (escapes, binary content) are not widely used, and the internal content storage API is not a convenient form to work with simple content - which is the majority of cases.

For this reason, the content of a cell can be accessed in a number of ways:

The simple typed accessors and RawContent check that there is no escape or binary content. Errors will be raised if these exist.

Properties

string Encoded;
string AsString;
   Get the contents of the cell as a string. If the cell has children, the contents of the first child will be returned.

Note: This method returns the cell with escape sequences, using the default escaping characters

Note: Any ASCII characters of value <32 except for tab (#9) will be silently droppe

int AsInteger;
   Get the contents of the cell as an integer. If the contents are not an integer, an exception will be raised. If the cell has children, the contents of the first child will be returned.

System.DateTime AsDateTime;
   Get the contents of the cell as a datetime. If the contents are not a datetime, then an exception will be raised. if the content is blank, then the result will be 0. If the cell has children, the contents of the first child will be returned.

System.DateTime AsDate;
   Get the contents of the cell as a datetime. If the contents are not a datetime, then an exception will be raised. if the content is blank, then the result will be 0. If the cell has children, the contents of the first child will be returned.

double AsFloat;
   Get the contents of the cell as a Float. If the contents are not a number, then an exception will be raised. If the cell has children, the contents of the first child will be returned.

bool Defined;
   True if the contents are defined. This is relevent when the contents are empty, whether this is known empty, or unknown. i.e. true means that the cell contents are "" if the raw content is empty.

If the cell has children, the contents of the first child will be returned.

bool IsNull;
   True if the cell contains only "" - to indicate that the value is null

bool HasChildren;
   True if there is children of this cell

bool IsDate;
   true if the field should contain a date according to the dictionary. The contents of the cell are not checked. If the cell has children, the value for the first child will be returned.

string RawContent;
   Access raw content of the cell. Use with care:
  • this value does not properly handle "" in cells. (see Defined)
  • If the cell has real escaping (use of \H\ or \.br\ or \X..\ then the raw content does not include these parts (see ContentCount and Contents)
Setting RawContent will remove any escapes in the cell

string AsPlainText;
   Access plain text content of the cell. If there is any formatting or binary escapes (\X), they will be ignored.

Setting PlainTextContent will remove any escapes in the cell

int ElementIndex;
   The index of this cell in it's parents children

string DataTypeName;
   The Data Type of this cell, if known

bool IsRelevent;
   true if this element or any of it's children are Defined

int ContentCount;
   The numer of parts that make up the content. Usually this is one, but it might be more than one if there is \H\ or \.br\ or \X...\ in the field

bool IsSimple;
   true if there is no complex content (escapes, binary sequences) in the content of the cell

Also true if there is no content in the cell at all.

string DisplayForCode;
   if the cell is attached to a table, and the cell contains a code found in the table, then the display (print name) for the code


Methods

HL7Connect.V2.Content GetContents(int AIndex);
System.DateTime AsDateTimeWithReject(string Desc);
   Gets the content of the cell as a DateTime. If the contents are not a valid date, an exception with the message Desc will be raised (this is to assist in tracking down which field was responsible for the problem

bool IsElement(string AName);
   returns true if the segment is identified by the name provided. The syntax of name follows that of Element, with the difference that if the syntax does not specify a repeat index for segment or field, then any repeat will match

bool TableDefined();
   Check if a table is defined for this component. If the cell has children, the result for the first child will be returned.

bool ValueInTable();
   checks to see if a table is defined, then if the value provided is from the table. either code, or description is accepted. If the cell has children, the result for the first child will be returned.

bool AsTableCode(ref string VCode);
   return the code for the item provided, whether a code or text was provided. If the cell has children, the result for the first child will be returned.

bool AddTableCode(string sCode);
   look up the value provided in the table and insert the code if value is non numeric this will return false if the code was not found If the cell has children, the result for the first child will be returned..

void Decode(string sContent, string sFormat, bool bWipeContent);
   Decode the fragment over the top of the existing content

Note that when this method is used on data elements with XML, field repeats cannot be decoded

sFormat - XML or ER7

void DecodeEx(int iStart, string sContent, string sLevel);
   Decode the fragment over the top of the existing content, starting at a given offset. A tpyical use would be moving an PN to an XCN, where the XCN fields match the PN fields from component 2. If the offset is negative, then cells that under run are ignored (i.e. converting from XCN to PN)

XML is not supported. This only wipes contents in components it changes.

sLevel controls moving between components and subcomponents:

  ""  (blank)  move content and maintain level
  "up"    move content from subcomponents into components
  "down"  move content from components to subcomponents

string EnCode(string sFormat);
   This cell as encoded in ER7 or XML

Note that when this method is used on data elements with XML, field repeats cannot be encoded

void CopyCell(HL7Connect.V2.Cell ASource);
   get the values from the source. Self and source can be different types - you can assign a DataElement into a Component. This will work as long as the copy doesn't create sub-sub-components

HL7Connect.V2.Content Contents(int AIndex);
   Get the nth content section that contributes to the resource. (0 based)

There will be a content section for each of the following:

  • "" (if it's the only content in the cell)
  • any text
  • any escape that is not a syntactic escape (i.e. not an escape taking the place of the field separator for instance
  • any binary sequence (\Xxxxx)
 See notes on IHL7Content.contentType about binary sequences and XML

void HighlightAll();
   Highlight the entire content of the cell using \H\ and \N\

void Highlight(int iBegin, int iEnd);
   Highlight the selected range of the cell using \H\ and \N\. range is 0 based (i.e. to highlight 'is' in "This is a test", you would use 5,7 for the begin and end parameters

The index is calculated from the start of the cell using the Text property. Where there is escapes etc, it can get confusing to calculate the offsets, so there is a matching routine on the Content class to simplify matters in these cases.

This routine will fail with an exception if there is already highlighting on the cell

void HighlightCustom(int iBegin, int iEnd, string sStart, string sEnd);
   Highlight the selected range of the cell using \x\ and \N\. range is 0 based (i.e. to highlight 'is' in "This is a test", you would use 5,7 for the begin and end parameters)

The codes are custom codes to be used in place of \H\ and \N\. Do not use a code that has other meanings in HL7. You can use more than one character. Generally it would be recommended to start custom codes with Z to be consistent with HL7 localisation rules

This is for custom extension - other HL7 applications will only know what these extensions mean if they are specfically designed for them.

The index is calculated from the start of the cell using the Text property. Where there is escapes etc, it can get confusing to calculate the offsets, so there is a matching routine on the Content class to simplify matters in these cases.

void RemoveHighlights();
   Remove all highlights \H\ and \N\ in the cell

void RemoveHighlight(int iIndex);
   Remove the nominated highlight from the cell.

The index is the index of the Content item that encodes the H. The matching N will be automatically removed.

void RemoveEscapes();
   Remove all escape sequences in the cell

void RemoveEscape(int iIndex);
   Remove the nominated escape sequence. No other escape sequences will be removed

The index is the index of the Content item

(Same as RemoveContent, but checks that the nominated content is an escape before removing it

void RemoveContent(int iIndex);
   Remove the nominated content

The index is the index of the Content item

void AppendContent(string sContentType, string sText);
   Append content to the end of the content list. See IHL7Content for the meaning of the ContentType and Text fields.

void InsertContent(int iIndex, string sContentType, string sText);
   Insert content to at position Index in the content list (0 based).

See IHL7Content for the meaning of the ContentType and Text fields.

void ClearAll();
   Remove any content associated with the cell, and also in any children if they exist.


© Kestral Computing P/L 2000 - 2003. HL7Connect v2.00-063 generated on 30-Nov 2015.
Keywords: AddTableCode, AppendContent, AsDate, AsDateTime, AsDateTimeWithReject, AsFloat, AsInteger, AsPlainText, AsString, AsTableCode, ClearAll, ContentCount, Contents, CopyCell, DataTypeName, Decode, DecodeEx, Defined, DisplayForCode, ElementIndex, EnCode, HasChildren, Highlight, HighlightAll, HighlightCustom, InsertContent, IsDate, IsElement, IsNull, IsRelevent, IsSimple, RawContent, RemoveContent, RemoveEscape, RemoveEscapes, RemoveHighlight, RemoveHighlights, TableDefined, ValueInTable, cell, Encoded, HL7Connect.V2.Cell, GetContents