HCA-Healthcare / elixir-hl7

An Elixir library for working with HL7 v2.x healthcare data
Apache License 2.0
110 stars 22 forks source link

Documentation how to add Segments #15

Open BryanJBryce opened 2 years ago

BryanJBryce commented 2 years ago

There's a lot of info in the readme about parsing HL7 messages, but I'm trying to create them and I don't see a straightforward way to add segments to a message. A new message can be created with raw input, or with a header, but how do you add segments?

DarkMarmot commented 2 years ago

Hi Bryan,

We've primarily used this library for cutting messages up (at our company we process them from hundreds of different hospitals). Most of the time when building messages, we make them as interpolated strings (and we don't do this very often).

As it is now, you could set the segments fields of the HL7.Message struct to be a list of lists and then to_string() would output the HL7 as a binary. You can see the list parsing by calling HL7.Message.to_lists/1 with some the example messages in the Examples module.

If you have an idea for additions to the API to support building them, we'd be happy to look into extending the library.

Thanks, Scott

mworrell commented 2 years ago

Hi @DarkMarmot ,

When you say that you build messages using interpolated strings, you mean that you just take a fixed template and patch the (escaped) values in there?

I was also looking for a library to build HL7 messages.

Thanks, Marc