I've run into a need to be able to parse batch and file HL7 and retain the FHS/FTS and BHS/BTS information.
Obviously I can do this outside of python-hl7, but I thought that others might also be able to use it (and I hate writing the same code twice).
Seems to me the cleanest way to do this is to add two new container types (Batch and File) and two new parse methods (parse_batch and parse_file) given that the rules for parsing batches and files don't directly track to the rules for parsing a message.
The Batch container would provide access to the BHS and BTS information (as Segments if present, they're optional) and the contained messages as Messages. It would serialize back out as a hl7 batch.
The File container would provide access to the FHS and FTS information (as Segments if present, they're optional) and either the contained Batches or the contained Messages (the BHS/BTS segments are optional). It would serialize back out as an hl7 file.
The parse_batch and parse_file methods would take into account the optional FHS/FTS and BHS/BTS segments. I'm also thinking about a parse_hl7 top-level "factory" method that figures out if its a Message, Batch or File and does the right thing.
Finally, I would add an isbatch method that was similar to the isfile method in util.
This would be a non-breaking change.
If you agree with that approach I will write it and drop a PR.