hl7parse
|
hl7 meta data structures for message_t More...
Go to the source code of this file.
Classes | |
struct | hl7_meta_t |
HL7 Seperator configuration. More... | |
Typedefs | |
typedef struct hl7_meta_t | hl7_meta_t |
HL7 Seperator configuration. More... | |
typedef enum line_delimiter_t | line_delimiter_t |
possible line endings | |
Enumerations | |
enum | line_delimiter_t { DELIM_NONE = 0, DELIM_CR, DELIM_LF, DELIM_CRLF } |
possible line endings More... | |
Functions | |
hl7_meta_t * | init_hl7_meta_t (void) |
initialize the seperator data structure More... | |
char * | hl7_meta_string (hl7_meta_t *meta) |
generate printable string of the meta data More... | |
void | free_hl7_meta (hl7_meta_t *hl7_meta) |
free the data structure More... | |
line_delimiter_t | find_line_delimiter (FILE *fd) |
find line delimiter More... | |
int | read_meta (hl7_meta_t *hl7_meta, FILE *fd) |
read up until the 2nd field delimiter More... | |
hl7 meta data structures for message_t
meta_t contains information in all hl7 separators of a file and the BOM.
read_meta() can detect the delimiters of a file pointed to by *fd
.
find_line_delimiter() will seek the first CR
or LF
and will detect if CRLF
is present. In case of CRLF
the attribute crlf
is set to 1 else 0 or -1 (initial value when no detection has happened yet).
Delimiter | Value | Usage |
---|---|---|
Segment terminator | <cr> 0x0D | A carriage return terminates a segment record. You cannot change this value. |
Field separator | | | A pipe character separates two adjacent data fields within a segment. This character also separates the segment ID from the first data field in each segment. |
Component separator | ^ | A hat character separates adjacent components of data fields where allowed by the HL7 standard. |
Repetition separator | ~ | A tilde character separates multiple occurrences of components or subcomponents in a field where allowed by the HL7 standard. |
Escape character | \ | You use an escape character with any field that conforms to an ST, TX, or FT data type, or with the data (fourth) component of the ED data type. If no escape characters exist in a message, you can omit this character. However, you must include it if you use subcomponents in the message. |
Subcomponent separator | & | An ampersand character separates adjacent subcomponents of data fields where allowed by the HL7 standard. If there are no subcomponents, then you can omit this character. |
typedef struct hl7_meta_t hl7_meta_t |
HL7 Seperator configuration.
enum line_delimiter_t |
line_delimiter_t find_line_delimiter | ( | FILE * | fd | ) |
find line delimiter
This method will forward an FILE pointer upon it finds the first \n
, \r
or EOF
. The FILE pointer will be restored to it's original position.
fd | file pointer at theb eginnign of a file |
void free_hl7_meta | ( | hl7_meta_t * | hl7_meta | ) |
free the data structure
make sure nothing points to the elements in this structure. All elements in the structure will be freed (including bom
).
hl7_meta | the meta structure |
char* hl7_meta_string | ( | hl7_meta_t * | meta | ) |
generate printable string of the meta data
meta | a hopefully populated meta data struct |
hl7_meta_t* init_hl7_meta_t | ( | void | ) |
initialize the seperator data structure
int read_meta | ( | hl7_meta_t * | hl7_meta, |
FILE * | fd | ||
) |
read up until the 2nd field delimiter
read up to 8 bytes to find all hl7 delimiters. This method assumes that it is reading an MSH segment (file pointer must be positioned at 'M').
Do not use it on any other hl7 segment!
This metod will detect all separators if they are defined. If not, separators will be left at the default.
The user must make sure to parse the right segment. fd must be pointing to the start character of an MSH or MSA segment.
The file pointer is reset at the end of this method and reset back to the byte after the BOM.
If no BOM detection has been done and meta->bom still is NULL, we'll run detect_bom() first. To prevent this, initialize the bom object with a length of 0.
MSH|
will return 1
. even tho it may or maynot be a valid hl7 file MSH-2
is not followed by MSH-1
and therefore a reliable detection is not possible.Return codes:
0
: success1
: the field delimiter was not found after the delimiters2
: premature file end3
: file does not begin with MSH
hl7_meta | pointer to an empty metadata structure |
fd | file pointer pointing to the beginning of MSH or MSA segment |