fix(core): update content type to 'sequence' when Field changes to complex datatype. Fix of #144#150
Open
germiBest wants to merge 1 commit intocrs4:developfrom
Open
fix(core): update content type to 'sequence' when Field changes to complex datatype. Fix of #144#150germiBest wants to merge 1 commit intocrs4:developfrom
germiBest wants to merge 1 commit intocrs4:developfrom
Conversation
…mplex datatype. Fixes crs4#144
Author
|
@svituz Hi, happy holidays! Is there a way to review and merge this? Tiny fix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem: When setting a Field's datatype to a complex/composite datatype (e.g., ED, RP, CE), the serialization incorrectly produced empty output instead of the expected HL7 formatted string.
Example of the bug from #144:
Root cause: According to the https://hl7-definition.caristix.com/v2/HL7v2.5/DataTypes/ED, this is explicitly a composite datatype containing multiple components.
When a Field's datatype is changed to a composite datatype, the code must update the field's content type from 'leaf' to 'sequence' to indicate it has a composite structure with multiple child components. This content type is used by ElementFinder._parse_structure() to determine whether to build the necessary ordered_children and
structure_by_name dictionaries
Bug was that the
SupportComplexDataType._set_datatype()method was updating the children reference and datatype, but forgot to update the content type from 'leaf' to 'sequence'. This caused the serialization logic to skip building the structure dictionaries, resulting in empty output.Fix is actually a one-line change – setting content type to 'sequence' for composite datatypes
This aligns with the existing CanBeVaries implementation (used by Components) which already sets 'sequence' for composite datatypes at initialization.
Also added single unit test to verify serialization works correctly.