Please enable JavaScript to view this site.


Online Help - Region 1: [CORE HL7 API Basic]

Other CORE HL7 API Help Regions

Download the API Libraries


Object: HL7FileAnalyzer

NOTE: No public entry point. Created only through a Controller object.

Description: Use the HL7FileAnalyzer object to "map" a data file containing HL7 messages and retrieve them.


HL7FileAnalyzer Object

HL7FileAnalyzer Object


You can also interchangeably use the HL7DataAnalyzer object as it maintains an internal HL7StringAnalyzer object as well as an internal HL7FileAnalyzer object to analyze HL7 data by dynamically deciding which analyzer will provide the best performance for an analysis operation.




Public Properties:


Property Name

Data Type


Uses the Standard Exceptions Interface


int (read only) - Will be the number of HL7 Messages detected during the last analysis operation which have been loaded from the file into memory


Enum: UPFA_ErrorType (read only) - Result enum


bool (read only) - Will indicate whether the analyzer is currently holding a file open.


string (read only) - Will be the full file name of the last file analyzed.


int (Default = 0) - If set to > 0 the file analyzer will cap all mapping operations to a maximum of MaxLoad.


int (read only) - Will be the number of HL7 Messages detected during the last analysis operation.


Controller Object (read only) - Will be the parent controller object that created the analyzer.


CORETag object - General purpose Tag object for custom programming code







Public Methods:



Return Value


Uses the Standard Exceptions Interface


COREExceptionEX[] - Returns a single dimension array of COREExceptionEX objects (See GetMessageEX()) Will be an empty array if MessageCount == 0.


string[] - Returns a single dimension array of raw HL7 message strings loaded. Will be an empty array if MessageCount == 0.

AnalyzeFile(string fileName)

bool - Returns true if the file was successfully opened and examined and HL7 messages were discovered.


void - Clears the object, closes any open files, and clears any memory buffers.

GetHL7Message(int index)

HL7Message object. Returns the HL7Message object loaded from the raw HL7 value ( see GetRawHL7() ) at #index in the file.

GetMessageEX(int index)

COREExceptionEX object - See GetMessageEX() a Better Iterator.

GetRawHL7(int index)

string Returns the Raw String Value of HL7 Message #index in the file and buffers the contents in memory if not already buffered.

Analyzing a HL7 Data File

Here's a quick C# code snippet for a Windows Forms project that displays creating and using a HL7FileAnalyzer object.


      private COREUtilities MyUtilities = new COREUtilities();

      private HL7Controller oController = new HL7Controller(LPInternals.ACTIVATIONHANDLE);

      private HL7Message oMessage = null;


      private void DemoFileAnalyzer()


          //I'm going to use this object below so I'll initialize it

          //just in case

           oMessage = oController.NewHL7Message();

          string fileName = "C:\\HL7 Messages\\10Messages.hl7";

           HL7FileAnalyzer fa1 = oController.NewFileAnalyzer();

          if (fa1 == null)


              //something went wrong




          if (!fa1.AnalyzeFile(fileName))


              //Something went wrong


              //From this point on AFTER we call .AnalyzeFile we should make sure we

              //CLEAR the object when we are done.





          int msgCount = fa1.MessageCount;

           FormResults.MsgBox("File Contains: " + msgCount.ToString() + " HL7 Messages");


          //Now we can iterate through the HL7 messages remembering that the access indexer

          //is 1 based


          for (int i = 1; i <= msgCount; i++)


              //Get the HL7Message objct

               HL7Message msg = fa1.GetHL7Message(i);

              //Should always check it for error just in case

              if (msg.HasException)


                  //There was an error in what the Analyzer found

                   FormResults.ErrorMsgBox("Error found on message #" + i.ToString());




              //OR I could get the RAW HL7 string value

              string rv = fa1.GetRawHL7(i);

              //And load it into a message myself

              if (!oMessage.LoadHL7Message(rv))   //See the HL7Message Object


                  //There was an error in what the Analyzer found

                   FormResults.ErrorMsgBox("Error on item [" + i.ToString()

                       + "] " + oMessage.LastException.ExtendedErrorMessage);




              //Put the text in a RichTextBox control

               RTF1.Text = msg.Value;

              string sMsg = "You are looking at item #" + i.ToString() + " of " + fa1.MessageCount.ToString() +

                   COREUtilities.DoubleSpace() + "Continue to the next one?";


              if (FormResults.QuestionBox(sMsg,"Keep Going?") != DialogResult.Yes)






           FormResults.InfoBox("Completed iteration of " + fa1.MessageCount.ToString() + " items.");

          //Remember finally to clear the object








Prohibited Files and File Extensions:


The HL7FileAnalyzer will fail automatically if you call the AnalyzeFile() method on any file which has one of the following file extensions:















Keyboard Navigation

F7 for caret browsing
Hold ALT and press letter

This Info: ALT+q
Nav Header: ALT+n
Page Header: ALT+h
Topic Header: ALT+t
Topic Body: ALT+b
Exit Menu/Up: ESC