Class: Roqua::Healthy::A19::Transformer
- Inherits:
-
Object
- Object
- Roqua::Healthy::A19::Transformer
- Defined in:
- lib/roqua/healthy/a19/transformer.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
- #birthdate ⇒ Object
- #email ⇒ Object
- #gender ⇒ Object
- #identities ⇒ Object
-
#initialize(message) ⇒ Transformer
constructor
A new instance of Transformer.
- #phone_cell ⇒ Object
- #source ⇒ Object
- #status ⇒ Object
- #to_patient ⇒ Object
Constructor Details
#initialize(message) ⇒ Transformer
Returns a new instance of Transformer.
11 12 13 14 15 16 17 18 |
# File 'lib/roqua/healthy/a19/transformer.rb', line 11 def initialize() @message = @message['PID']['PID.3'] = [@message.fetch('PID').fetch('PID.3')].flatten.compact @message['PID']['PID.5'] = [@message.fetch('PID').fetch('PID.5')].flatten.compact @message['PID']['PID.11'] = [@message.fetch('PID').fetch('PID.11')].flatten.compact @message['PID']['PID.13'] = [@message.fetch('PID').fetch('PID.13')].flatten.compact @message = MessageCleaner.new(@message). end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
9 10 11 |
# File 'lib/roqua/healthy/a19/transformer.rb', line 9 def @message end |
Instance Method Details
#birthdate ⇒ Object
56 57 58 59 |
# File 'lib/roqua/healthy/a19/transformer.rb', line 56 def birthdate birthdate_details = .fetch('PID').fetch('PID.7') birthdate_details.fetch('PID.7.1') if birthdate_details end |
#email ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/roqua/healthy/a19/transformer.rb', line 61 def email email_record = .fetch('PID').fetch('PID.13').find do |record| record.fetch('PID.13.2', :unknown_type_of_phone_record) == 'NET' end return nil unless email_record email_address = email_record.fetch('PID.13.1', "") email_address = email_record.fetch('PID.13.4', "") if email_address.blank? email_address end |
#gender ⇒ Object
86 87 88 |
# File 'lib/roqua/healthy/a19/transformer.rb', line 86 def gender .fetch('PID').fetch('PID.8').fetch('PID.8.1') end |
#identities ⇒ Object
49 50 51 52 53 54 |
# File 'lib/roqua/healthy/a19/transformer.rb', line 49 def identities .fetch('PID').fetch('PID.3').map do |identity| next if identity.fetch('PID.3.1').blank? {ident: identity.fetch('PID.3.1'), authority: identity.fetch('PID.3.5')} end.compact end |
#phone_cell ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/roqua/healthy/a19/transformer.rb', line 72 def phone_cell phone_cell_record = .fetch('PID').fetch('PID.13').find do |record| record.fetch('PID.13.2', :unknown_type_of_phone_record) == 'ORN' end phone_cell_record ||= .fetch('PID').fetch('PID.13').find do |record| record.fetch('PID.13.1', '') =~ /\A06/ end return nil unless phone_cell_record phone_cell_record.fetch('PID.13.1', "") end |
#source ⇒ Object
45 46 47 |
# File 'lib/roqua/healthy/a19/transformer.rb', line 45 def source .fetch('MSH').fetch('MSH.4').fetch('MSH.4.1') end |
#status ⇒ Object
41 42 43 |
# File 'lib/roqua/healthy/a19/transformer.rb', line 41 def status 'SUCCESS' end |
#to_patient ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/roqua/healthy/a19/transformer.rb', line 20 def to_patient { status: status, source: source, identities: identities, firstname: name.firstname, initials: name.initials, lastname: name.lastname, display_name: name.display_name, email: email, address_type: address.address_type, street: address.street, city: address.city, zipcode: address.zipcode, country: address.country, birthdate: birthdate, gender: gender, phone_cell: phone_cell } end |