IPWorks EDI 2020 Python Edition

Questions / Feedback?

HL7Translator Class

Properties   Methods   Events   Configuration Settings   Errors  

The HL7Translator class is optimized for HL7 translation, providing a simple way to convert HL7 documents to and from XML or JSON.

Syntax

class ipworksedi.HL7Translator

Remarks

The class provides a way to convert HL7 to XML or JSON and vice versa.

Getting Started

The class will convert a document from the format specified by input_format to the format specified by output_format. In practice this allows for converting to XML or JSON from EDI and vice versa.

Before translating from EDI to XML or JSON it is recommended to load a schema using the load_schema method. This ensures additional information can be included in the XML or JSON document. If a schema is specified the XML or JSON will include types and descriptions as element attributes which are useful for interpreting the data.

EDI elements may optionally be renamed when creating XML. To define how an element is renamed add a renaming rule by calling add_renaming_rule.

After calling translate the resulting output will contain the EDI, XML or JSON data as defined by output_format. If the output data is XML the export_xml_schema method may be called to export a schema (.xsd) defining the structure of a valid XML document. XML documents which adhere to this document may be translated from XML to EDI.

Input and Output Properties

The class will determine the source and destination of the input and output based on which properties are set.

The order in which the input properties are checked is as follows:

When a valid source is found the search stops. The order in which the output properties are checked is as follows:

Property List


The following is the full list of the properties of the class with short descriptions. Click on the links for further details.

input_dataThe data to translate.
input_fileThe file to translate.
input_formatThe format of the input data.
output_dataThe translated data.
output_fileThe file to which the translated data will be written.
output_formatThe format of the output data.
overwriteWhether to overwrite the file.
renaming_ruleThe rule defining how EDI elements are renamed when translating to XML or JSON.
renaming_rule_countThe number of renaming rules.
renaming_rule_indexThe index of the current renaming rule.
schema_formatThe format of the schema file.
suffixWhat to append after each segment delimiter.
use_schema_nameWhether the output XML uses element names based on name defined in the schema.

Method List


The following is the full list of the methods of the class with short descriptions. Click on the links for further details.

add_renaming_ruleThis method adds a renaming rule to define how an EDI element is renamed when translating to XML.
configSets or retrieves a configuration setting.
display_schema_infoReturns a string showing the structure of the schema defining the document.
export_xml_schemaExports a XML schema.
generate_ackGenerates an EDI acknowledgement.
load_renaming_rulesLoads a set of renaming rules from file.
load_schemaLoads a schema file describing a Transaction Set.
resetResets the state of the control.
save_renaming_rulesSaves the current renaming rule set to a file.
translateTranslates the specified data.

Event List


The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.

on_end_functional_groupFires whenever a control segment is read that marks the end of an interchange.
on_end_interchangeFires whenever a control segment is read that marks the end of an interchange.
on_end_loopFires when the end of a loop is detected in a transaction set.
on_end_transactionFires whenever a control segment is read that marks the end of a transaction.
on_errorInformation about errors during data delivery.
on_resolve_schemaFires whenever a new transaction set is encountered and no schema is found for it.
on_segmentFires whenever a data segment in a transaction set is read.
on_start_functional_groupFires whenever a control segment is read that marks the start of a functional group.
on_start_interchangeFires whenever a control segment is read that marks the start of an interchange.
on_start_loopFires when the starting of a loop is detected in a transaction set.
on_start_transactionFires whenever a control segment is read that marks the start of a transaction.
on_warningFires whenever a validation warning is encountered.

Configuration Settings


The following is a list of configuration settings for the class with short descriptions. Click on the links for further details.

ComponentDelimiterThe delimiter character to use to separate classes.
CrossFieldValidationEnabledEnables cross-field validation rules.
ElementDelimiterThe delimiter character to use to separate data elements.
EncodingThe character encoding to be applied when reading and writing data.
IncludeEmptyElementsWhether to include empty data elements in a composite element.
IncludeFootersWhether to include footer information in the XML.
JSONElementPrefixAn optional prefix for reserved names when translating to JSON.
LastIXControlNumberThe control number of the most recently parsed interchange.
LastTransactionControlNumberThe control number of the most recently parsed transaction.
ReleaseCharThe character to use to escape delimiters within values.
RenamingRulesDataThe renaming rules data.
RepetitionCharThe repetition character.
SegmentDelimiterThe delimiter character to use to separate segments.
StrictSchemaValidationSpecifies the behavior during schema validation.
UseXMLCommentsWhether the human readable description is stored as an attribute or XML comments.
BuildInfoInformation about the product's build.
CodePageThe system code page used for Unicode to Multibyte translations.
LicenseInfoInformation about the current license.
ProcessIdleEventsWhether the class uses its internal event loop to process events when the main thread is idle.
SelectWaitMillisThe length of time in milliseconds the class will wait when DoEvents is called if there are no events to process.
UseInternalSecurityAPITells the class whether or not to use the system security libraries or an internal implementation.

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks EDI 2020 Python Edition - Version 20.0 [Build 8203]