Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method 'separator_chars' error when using default_msh: false #11

Open
speckins opened this issue Nov 5, 2020 · 1 comment

Comments

@speckins
Copy link

speckins commented Nov 5, 2020

msg = SimpleHL7::Message.new default_msh: false
msg.msh[1] = '|'
msg.msh[2] = '^~\&'
puts msg.to_hl7

Results in:

~/.gem/ruby/2.7.1/gems/simple_hl7-1.0.2/lib/simple_hl7/message.rb:33:in `to_hl7': undefined method `separator_chars' for #<SimpleHL7::Segment:0x00007fe530845a90> (NoMethodError)

This is because #to_hl7 assumes that the MSH segment is the Segment subclass MSHSegment, which responds to #separator_chars.

I could solve this by explicitly instantiating an MSHSegment and using #append_segment, but it might be nicer if the Message class either defined an explicit #msh method or added an "MSH" clause to #method_missing that instantiated the subclass.

@hportlock
Copy link
Contributor

Thanks for the thorough bug report! I think it would make sense for get_named_segment to be a bit smarter with the MSH. I'll work on a fix for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants