Package Gnumed :: Package business :: Module gmHL7 |
[frames] | no frames]

# Module gmHL7

source code

Some HL7 handling.

Author: K.Hilbert <Karsten.Hilbert@gmx.net>

License: GPL v2 or later

Functions
extract_HL7_from_XML_CDATA(filename, xml_path, target_dir=None) | source code
split_hl7_file(filename, target_dir=None, encoding='utf8') Multi-step processing of HL7 files. | source code
format_hl7_message(message=None, skip_empty_fields=True, eol='\n ', source=None) | source code
format_hl7_file(filename, skip_empty_fields=True, eol='\n ', return_filename=False, fix_hl7=True) | source code
stage_single_PID_hl7_file(filename, source=None, encoding='utf8') Multi-step processing of HL7 files. | source code
process_staged_single_PID_hl7_file(staged_item) | source code
import_single_PID_hl7_file(filename) | source code

Variables
| HL7_EOL = `'\r'`
| HL7_BRK = `'\.br\\'`
| HL7_SEGMENTS = `'FHS BHS MSH PID PV1 OBX NTE ORC OBR'.split()`
| HL7_segment2field_count = `{'FHS': 12, 'BHS': 12, 'MSH': 19, 'P`...``
| MSH_field__sending_lab = `3`
| PID_field__name = `5`
| PID_field__dob = `7`
| PID_field__gender = `8`
| PID_component__lastname = `1`
| PID_component__firstname = `2`
| PID_component__middlename = `3`
| OBR_field__service_name = `4`
| OBR_field__ts_requested = `6`
| OBR_field__ts_started = `7`
| OBR_field__ts_ended = `8`
| OBR_field__ts_specimen_received = `14`
| OBX_field__set_id = `1`
| OBX_field__datatype = `2`
| OBX_field__type = `3`
| OBX_component__loinc = `1`
| OBX_component__name = `2`
| OBX_field__subid = `4`
| OBX_field__value = `5`
| OBX_field__unit = `6`
| OBX_field__range = `7`
| OBX_field__abnormal_flag = `8`
| OBX_field__status = `11`
| OBX_field__timestamp = `14`
| NET_field__set_id = `1`
| NET_field__src = `2`
| NET_field__note = `3`
| HL7_field_labels = `{'MSH': {0: 'Segment Type', 1: 'Field Separ`...``
| HL7_GENDERS = `{'F': 'f', 'M': 'm', 'O': None, 'U': None, None:`...``

Imports: sys, os, io, logging, time, shutil, pyDT, pyhl7, pyxml, gmI18N, gmTools, gmBusinessDBObject, gmPG2, gmDateTime, gmIncomingData, gmPathLab, gmPerson, gmPraxis, gmStaff

Function Details

### split_hl7_file(filename, target_dir=None, encoding='utf8') | source code
    Multi-step processing of HL7 files.

    - input can be multi-MSH / multi-PID / partially malformed HL7
    - tries to fix oddities
    - splits by MSH
    - splits by PID into <target_dir>

    - needs write permissions in dir_of(filename)
    - moves HL7 files which were successfully split up into dir_of(filename)/done/

    - returns (True|False, list_of_PID_files)

### stage_single_PID_hl7_file(filename, source=None, encoding='utf8') | source code
    Multi-step processing of HL7 files.

    - input must be single-MSH / single-PID / normalized HL7

    - imports into clin.incoming_data_unmatched

    - needs write permissions in dir_of(filename)
    - moves PID files which were successfully staged into dir_of(filename)/done/PID/

Variables Details

  ### HL7_segment2field_count Value:
      {'FHS': 12, 'BHS': 12, 'MSH': 19, 'PID': 30, 'PV1': 52, 'OBR': 43, 'OB
      X': 17, 'NTE': 3, 'ORC': 19}

  ### HL7_field_labels Value:
      {'MSH': {0: 'Segment Type', 1: 'Field Separator', 2: 'Encoding Charact
      ers', 3: 'Sending Application', 4: 'Sending Facility', 5: 'Receiving A
      pplication', 6: 'Receiving Facility', 7: 'Date/Time of Message', 8: 'S
      ecurity', 9: 'Message Type', 10: 'ID: Message Control', 11: 'ID: Proce
      ssing', 12: 'ID: Version', 14: 'Continuation Pointer', 15: 'Accept Ack
      nowledgement Type', 16: 'Application Acknowledgement Type'}, 'PID': {0
      : 'Segment Type', 1: '<PID> Set ID', 2: 'Patient ID (external)', 3: 'P
      atient ID (internal)', 4: 'Patient ID (alternate)', 5: 'Patient Name',
      ...

  ### HL7_GENDERS Value:
      {'F': 'f', 'M': 'm', 'O': None, 'U': None, None: None}