[ <- Previous Page ] | [ ^ Table Of Contents ^ ] | [ Next Page -> ] |
Healthcare data is frequently passed between systems using a special format called hl7. If not used in the Healthcare Industry, then zWebitwill not need this class. When zWebit is used in a healthcare environment, the zHL7 class can be used for manipulating hl7 formatted data in C++ programs.
The zHl7 routines basically work by treating the entire transaction as one string of data, and applying seek and find or seek and update logic on the string. The zHl7 class is derived from the zString class.
The zHl7 class does not check for hl7 validity and is not as powerful as some other hl7 parsing tools available. However, it has proven adequate for zWebit, and it is extensible as well.
zWebit is not exclusive to the Healthcare industry alone. In fact, it can be utilized for other endeavors concerning data communication and data manipulation. zWebit is capable of using other classes and libraries for data manipulation.
LENGTH OF DATA PROCESSED | Positive Value |
SUCCESS | 0 |
NO_MEMORY | -1 |
NO_FIELD_DELIMITER | -2 |
SEG_NOT_FOUND | -3 |
FIELD_NOT_FOUND | -4 |
INVALID_SEG_ID | -5 |
LENGTH OF DATA PROCESSED | Positive Value |
Method/Function | Description |
---|---|
SegCode | Segment identifier, like MSH or OBR |
SegNo | Occurrence number to look for based on zero offset |
FieldNo | Field numbers in the segment to process |
SubField | Sub field wthin the field, -1 for all subfields |
FieldPtr | Optional pointer which returns to the beginning of the field |
Result | User supplied zString to store result |
For example, if SegCode = OBR, SegNo = 0 then this will process the first OBR record.
Method/Function | Description | Return Code |
---|---|---|
int isHl7Ack ( ) | This routine returns true if the current hl7 object is an hl7 acknowledgement. That is, MSAL/AA is found in the data. | 1=True 0=False |
int getField (const zString& SegCode, int SegNo, int FieldNo, int SubFieldNo, zString & result) | Retrieve field FieldNo subfield SubFieldNo from segment SegCode occurrence SegNo. If subfieldNo = -1, pull entire field. | See return code table |
int deleteField (const zString & SegCode, int SegNo, int FieldNo) | Delete field FieldNo from segment SegCode occurence SegNo. | See return table |
int insertField (const zString & SegCode, int SegNo, int FieldNo, const zString & data, int deleteSw) | Inserts data into segment SegCode for occurence number SegNo field number FieldNo. Set DeleteSw=z to delete pre-existing field data before insert count. If optional delete Sw = 1, field will be cleared before inserting data. | See return table |
int segCount (const zString & SegCode) | Return the count of segment codes SegCode. Special case is * which returns the count of all segments. | |
int deleteSeg (const zString & SegCode, int SegNo) | This method deletes the entire segment SegCode for occurence SegNo. | See return code table |
int expandSegFieldDelimCt (const zString SegCode, int SegNo, int FieldDelimCt) | This routine expands the total number of delimiters on segment SegCode for occurence SegNo to a minimum of FieldDelimCt. | 0=No updates 1=Expanded segment |
char getSubFieldDelimiter ( ) | This method returns the subfield delimiter. | Subfield delimiter |
char getFieldDelim (int which Delim) | WhichDelim is a valid delimiter position 0 thru 3 in the MSH-1 field. | |
void createHl7Response (const zString & msh4, const zString & msh8, const zString & mshll, const zString & msa1, const zString & msa3) | This method is used to create an hl7 ACK or NAK message. Msh11 is system id, msh8 is ACK or AK, msh11 is release level (2.2), msh1 is AA or AE, and msa3 is a comment. | |
int getSeg (const zString & SegCode, int SegNo, zString & Result) | This method returns segment SegCode occurrence number SegNo into Result. | See return code table |
zHl7 &operator = (const zString &s); | This operator is used to set the value to S | |
zHl7 &operator = (const zString *s); | This operator is used to set the value to S |
HL7 messages are typically sent from system to system with particular framing bytes. Although not all systems follow these rules, many systems frame the record as follows:
First byte | 0x0B |
Second to the last byte | 0x1C |
Last byte | 0x0D |
Data messages are stored in zWebit in an unframed manner. That is, the first byte and last bytes are removed from the transaction by the acquisition program before storing the data. The delivery program is responsible for correctly framing messages before delivering the data to its destination. The zHl7 class assumes unframed data is being processed. There are two methods, zString::FrameIt ( ) and zString::deFrameIt ( ), which can be used for handling the framing of the data. See the zString section for information regarding the frame characters.
/* zhl7 test program Copyright (c) 2000 HSC GNU/GPL */ #include#include #include "../../base/zstring.cpp" #include "../../base/zhl7.cpp" using namespace std; int main() { zHl7 hl7; zString ws; /* work string */ char c; int rc; /* load the test data record in (one byte at a time) */ ifstream infile( "testhl7.dat", ios::in ); if( !infile ){ cerr << "File testhl7.txt could not be opened" << endl; exit(1); } infile.read( &c, 1 ); while( !infile.eof()){ hl7 += c; infile.read( &c, 1 ); } infile.close(); /* load the hl7 class with data */ cout << "Loaded hl7 record =>" << hl7.getData() << "<=" << endl; cout << "hl7 message length = " << hl7.len() << endl; /* pull the fifth field from the first PID segment, all sub fields */ rc = hl7.getField( "PID", 0, 0, -1, ws ); if( rc > 0 ) cout << "PID-0 = " << ws << endl; else cout << "error " << rc << " in getField()" << endl; /* pull the fifth field from the first PID segment, all sub fields */ rc = hl7.getField( "PID", 0, 5, -1, ws ); if( rc > 0 ) cout << "PID-5 = " << ws << endl; else cout << "error " << rc << " in getField()" << endl; /* pull the fifth field from the first PID segment, second sub fields */ rc = hl7.getField( "PID", 0, 5, 1, ws ); if( rc > 0 ) cout << "PID-5-1 = " << ws << endl; else cout << "error " << rc << " in getField()" << endl; rc = hl7.deleteField( "PID", 0, 5 ); rc = hl7.insertField( "PID", 0, 5, "WONKA^WILLY^^" ); cout << "New hl7 record =>" << hl7.getData() << "<=" << endl; cout << "hl7 message length = " << hl7.len() << endl; cout << "There are " << hl7.segCount( "*" ) << " total segments" << endl; cout << "There are " << hl7.segCount( "PID" ) << " PID segments" << endl; rc = hl7.deleteSeg( "DG1", 0 ); cout << "hl7 transaction without DG1 segment =>" << hl7.getData() << "<=" << endl; cout << "hl7 message length = " << hl7.len() << endl; /* update PID segment to contain 50 fields */ hl7.expandSegFieldDelimCt( "PID", 0, 40 ); cout << "PID record with 40 fields =>" << hl7.getData() << "<=" << endl; cout << "hl7 message length = " << hl7.len() << endl; hl7.getSeg( "PID", 0, ws ); cout << "PID segment = " << ws << endl; return 0; }
[ <- Previous Page ] | [ ^ Table Of Contents ^ ] | [ ^ Top Of Page ^ ] | [ Next Page -> ] |
Visit the GNU home page.
FSF & GNU inquiries & questions to
gnu@gnu.org.
Comments on these web pages to
info@zhsac.com.
Copyright (C) 2003 HealthCare Systems and Consulting
Verbatim copying and distribution of this entire article is
permitted in any medium, provided this notice is preserved.
Last updated: 07/21/2003