With Chameleon I made a whole family of objects for configuring the HL7 parser:
Message object
Message grammar object
Segment groups
Segments
Composites
Date time formats
Way too much functionality - violating the principle of adding features increases complexity exponentially.
It’s not useful to see if the width of a field is “compliant” with the HL7 standard. The main value of the configuration grammar is to provide convenient labels for the data in the HL7 message.
Likewise within the context of the translator having date time formats or integer versus double versus string fields isn’t that useful. Might as well treat every field as a string.
So all of these objects could be reduced in complexity to the point that we find symmetry. We can represent all of these objects using one object which we could call a node.
With node is can either be:
A branch - which has children which are other nodes
A leaf - it is a string
Each node would have a:
A guid
A label
A description
Branches would has a list of the Guids of the child nodes that they have.
I am not sure how to handle optionality of segments in the tree.