hl7apy icon indicating copy to clipboard operation
hl7apy copied to clipboard

Add a to_dict() method to Element

Open prschmid opened this issue 8 years ago • 1 comments

Many times it's easier to quickly view the contents of an HL7 message in a dictionary format (or convert it to JSON). It would be great if there was a simple to_dict() method on Element that would recursively "do the right thing" and call the to_er7() method while retuning that contents as a dict. I've written some helper methods that I have used for my use case, that could relatively easily be adapted to this use case:

https://gist.github.com/prschmid/801e86891026a39b1fb4df7178828321

Let me know if you have any questions, or if you would like this as a pull request.

prschmid avatar Nov 07 '16 22:11 prschmid

Ideally this would be a to_json() method. Many elements in HL7 can repeat and thus would need to go into an array instead of a direct dictionary.

n-mcf avatar Nov 30 '19 20:11 n-mcf