Online Help - Region 1: [CORE HL7 API Basic] |
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
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.
Property Name |
Data Type |
ExceptionHandling |
Uses the Standard Exceptions Interface |
BufferedMessageCount |
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 |
FAError |
Enum: UPFA_ErrorType (read only) - Result enum |
FileIsOpen |
bool (read only) - Will indicate whether the analyzer is currently holding a file open. |
FileName |
string (read only) - Will be the full file name of the last file analyzed. |
MaxLoad |
int (Default = 0) - If set to > 0 the file analyzer will cap all mapping operations to a maximum of MaxLoad. |
MessageCount |
int (read only) - Will be the number of HL7 Messages detected during the last analysis operation. |
ParentController |
Controller Object (read only) - Will be the parent controller object that created the analyzer. |
Tag |
CORETag object - General purpose Tag object for custom programming code |
Method |
Return Value |
ExceptionHandling |
Uses the Standard Exceptions Interface |
AllMessagesEX() |
COREExceptionEX[] - Returns a single dimension array of COREExceptionEX objects (See GetMessageEX()) Will be an empty array if MessageCount == 0. |
AllRawMessages() |
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. |
Clear() |
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 FormResults.ErrorMsgBox(oController.LastException.ExtendedErrorMessage); return; } if (!fa1.AnalyzeFile(fileName)) { //Something went wrong FormResults.ErrorMsgBox(fa1.LastException.ExtendedErrorMessage); //CLEAR the object when we are done. fa1.Clear(); return; }
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()); return; } //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); return; } //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) { return; } } FormResults.InfoBox("Completed iteration of " + fa1.MessageCount.ToString() + " items."); //Remember finally to clear the object return;
}
|
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:
•.EXE
•.COM
•.LNK
•.ZIP
•.RAR
•.TAR
•.MSI
•.CAB
•.DLL