Class: HealthcarePhony::Hl7Message

Inherits:
Object
  • Object
show all
Defined in:
lib/healthcare_phony/hl7_message.rb

Overview

Public: Generates information needed to build an HL7v2 message

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**init_args) ⇒ Hl7Message

Public: Initializes an Address. Pass in hash of different parameters, currently this includes: message_version - HL7v2 version (MSH.12) message_processing_id - Typically P or T (MSH.11) message_types - Array of Message Types (MSH.9.1) to randomly choose from. Specified as comma separated String or Ruby array. message_type_file - Location of file containing Message Types (MSH.9.1). If not specified then included hl7_message_types.yml file will be used. message_events - Generic array of Trigger Events (MSH.9.2) to randomly choose from. Specified as command separated String or Ruby array. adt_events - Array of ADT Trigger Events (MSH.9.2) to randomly choose from. Used (if specified) if the Message type for the message is ADT. ADT events from adt_event_types.yml will be used by default. oru_events - Array of ORU Trigger Events (MSH.9.2) to randomly choose from. Used (if specified) if the Message type for the message is ORU. ORU events from oru_event_types.yml will be used by default. mdm_events - Array of MDM Trigger Events (MSH.9.2) to randomly choose from. Used (if speciifed) if the Message type for the message is MDM. MDM events from mdm_event_types.yml will be used by default. message_control_id_pattern - Regex pattern used to randomly generate MSH.10 values. Default is PHONYd10 which will generate a value like: PHONY6850295805 message_sending_facility - Array of Sending Facilities (MSH.4) to randomly choose from. Specified as comma separated String or Ruby Array. message_sending_application - Array of Sending Applications (MSH.3) to randomly choose from. Specified as comma separated String or Ruby Array. message_receiving_application - Array of Receiving Applications (MSH.5) to randomly choose from. Specified as comma separated String or Ruby Array. message_receiving_facility - Array of Receiving Facilities (MSH.6) to randomly choose from. Specified as comma separated String or Ruby Array.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/healthcare_phony/hl7_message.rb', line 45

def initialize(**init_args)
  define_message_type(init_args)
  define_trigger_event(init_args)
  define_control_id(init_args)
  @version = init_args[:message_version].nil? ? '2.5.1' : init_args[:message_version]
  define_sending_facility(init_args)
  define_sending_application(init_args)
  define_receiving_application(init_args)
  define_receiving_facility(init_args)

  # Potential use case to allow you to provide begin/end date?
  @message_datetime = Time.now

  @processing_id = init_args[:message_processing_id].nil? ? 'P' : init_args[:message_processing_id]
end

Instance Attribute Details

#message_control_idObject

Returns the value of attribute message_control_id.



6
7
8
# File 'lib/healthcare_phony/hl7_message.rb', line 6

def message_control_id
  @message_control_id
end

#message_datetimeObject

Returns the value of attribute message_datetime.



6
7
8
# File 'lib/healthcare_phony/hl7_message.rb', line 6

def message_datetime
  @message_datetime
end

#message_typeObject

Returns the value of attribute message_type.



6
7
8
# File 'lib/healthcare_phony/hl7_message.rb', line 6

def message_type
  @message_type
end

#processing_idObject

Returns the value of attribute processing_id.



6
7
8
# File 'lib/healthcare_phony/hl7_message.rb', line 6

def processing_id
  @processing_id
end

#receiving_applicationObject

Returns the value of attribute receiving_application.



6
7
8
# File 'lib/healthcare_phony/hl7_message.rb', line 6

def receiving_application
  @receiving_application
end

#receiving_facilityObject

Returns the value of attribute receiving_facility.



6
7
8
# File 'lib/healthcare_phony/hl7_message.rb', line 6

def receiving_facility
  @receiving_facility
end

#sending_applicationObject

Returns the value of attribute sending_application.



6
7
8
# File 'lib/healthcare_phony/hl7_message.rb', line 6

def sending_application
  @sending_application
end

#sending_facilityObject

Returns the value of attribute sending_facility.



6
7
8
# File 'lib/healthcare_phony/hl7_message.rb', line 6

def sending_facility
  @sending_facility
end

#trigger_eventObject

Returns the value of attribute trigger_event.



6
7
8
# File 'lib/healthcare_phony/hl7_message.rb', line 6

def trigger_event
  @trigger_event
end

#versionObject

Returns the value of attribute version.



6
7
8
# File 'lib/healthcare_phony/hl7_message.rb', line 6

def version
  @version
end