lib7exception

Module Contents

exception lib7exception.Hl7Exception

Bases: Exception

Base class for hl7 exceptions

exception lib7exception.Hl7Exception

Bases: Exception

Base class for hl7 exceptions

exception lib7exception.Hl7StructureException

Bases: Hl7Exception

raised when a node is not in a structure which top most parent is a message_t node

exception lib7exception.Hl7SetNodeException(addr: str, return_code: int)

Bases: Hl7Exception

int node_set_by_addr(…) raised an exception

Error codes:

  • -1: Failed to allocate fieldlist

  • -2: Failed to allocate field

  • -3: Failed to set data on field

  • -4: Failed to pad children on field (Comp)

  • -5: Failed to set data on comp

  • -6: Failed to pad children on field (subcmp)

  • -7: Failed to set data on subcomp

  • -21: tryed to add a component to a field that already has data

  • -22: tryed to add a sub-component to a component that already has data

code_to_str(self, return_code: int)
exception lib7exception.Hl7ParseException(return_code: int)

Bases: Hl7Exception

hl7_decode() raised an exception

return codes of lib7.hl7_parse:

Error codes:

  • 1: failed to allocate memory for line buffer

  • 2: failed to allocate more memory for line buffer

  • 3: EOF was reached unexpectedly

  • 4: maximum delimiters per segment is reached, raise MAX_FIELDS

  • 5: failed to allocate raw_field @see create_raw_field_t()

  • 6: failed to allocate node_t @see create_node_t()

  • 7: failed to process sub field elements @see process_node()

  • 8: failed to append child @see node_append()

  • 9: failed to allocate memory for segment name

code_to_str(self, return_code: int)
exception lib7exception.Hl7AddressException(addr: str, return_code: int)

Bases: Hl7Exception

Raised when an invalid address is used

return codes from address.h: int set_addr_from_string(char *str, hl7_addr_t **ret_addr);

returns 0 on succes and the following error codes otherwise:

  • -1: string length 0

  • -2: segment count not ended by ‘)’

  • -3: field address must start with ‘-’

  • -4: field address is not a digit

  • -5: expected ‘(’ or ‘.’ after field

  • -6: invalid field address, must at least set SEG-N

  • -7: field repetition ‘(’ must be followed by digit

  • -8: field repetition may only contain digits between ‘(’ and ‘)’

  • -9: premature end in field repetition (fieldlist)

  • -10: preamture end, expecting component address after ‘.’

  • -11: value error, only digits allowed in component address after ‘.’

  • -12: premature end, comp address is empty

  • -13: invalid character followed after comp

  • -14: ‘.’ for subcomp must be followed by an address, end of string reached

  • -15: premature end, subcomp address is empty

code_to_str(self, return_code: int)