Title: PipeParser treats choice/conditional segments in groups as invalid segments · Issue #794 · nHapiNET/nHapi · GitHub
Open Graph Title: PipeParser treats choice/conditional segments in groups as invalid segments · Issue #794 · nHapiNET/nHapi
X Title: PipeParser treats choice/conditional segments in groups as invalid segments · Issue #794 · nHapiNET/nHapi
Description: Describe the bug PipeParser.Parse() does not properly parse conditional segments in groups, such as in the ORDER_DETAIL group in ORM_O01 messages. Instead, the parser erroneously treats these as invalid segments. Attempt to parse the att...
Open Graph Description: Describe the bug PipeParser.Parse() does not properly parse conditional segments in groups, such as in the ORDER_DETAIL group in ORM_O01 messages. Instead, the parser erroneously treats these as in...
X Description: Describe the bug PipeParser.Parse() does not properly parse conditional segments in groups, such as in the ORDER_DETAIL group in ORM_O01 messages. Instead, the parser erroneously treats these as in...
Opengraph URL: https://github.com/nHapiNET/nHapi/issues/794
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"PipeParser treats choice/conditional segments in groups as invalid segments","articleBody":"**Describe the bug**\n`PipeParser.Parse()` does not properly parse conditional segments in groups, such as in the `ORDER_DETAIL` group in `ORM_O01` messages. Instead, the parser erroneously treats these as invalid segments.\n\nAttempt to parse the attached HL7 message using a `PipeParser` with the option:\n```\nUnexpectedSegmentBehaviour = UnexpectedSegmentBehaviour.ThrowHl7Exception\n```\n\nThe call to `Parse()` will throw an exception, despite the HL7 message being valid. The exception message states that `RXO` is not a valid segment when attempting to parse the `ORDER_DETAIL` group. `RXO` should be parsed correctly because it is a valid conditional element within the `ORDER_DETAIL` group. The message appears to be parsed correctly when using `LegacyPipeParser`. Without the parser option set, the message will parse, but the `RXO` structure will not be populated with the data from the message.\n\nThe error appears to stem from the fact that all of the models mark conditional fields as required, but `IsChoiceElement` is always set to false for these items. See [`AbstractGroup.cs(429)`](https://github.com/nHapiNET/nHapi/blob/master/src/NHapi.Base/Model/AbstractGroup.cs#L429). There appears to be no way to ascertain this information in the parser without changes to the generated models.\n\nHere is an example HL7 message\n```\nMSH|^~\\\\\u0026|HIS|MedCenter|LIS|MedCenter|20060307110114||ORM^O01|MSGID20060307110114|P|2.3.1\nPID|||12001||Jones^John^^^Mr.||19670824|M|||123 West St.^^Denver^CO^80020^USA|||||||\nPV1||O|OP^PAREG^||||2342^Jones^Bob|||OP|||||||||2|||||||||||||||||||||||||20060307110111|\nORC|NW|1016314\nRXO|65862000330^MIRTAZAPINE^NDC^^REMERON^|1||30MG|TAB||1 TAB By Mouth QHS(2000)||G||60|Doses|0|123456^Jones, NP^Joan\n```\n\n**Environment details:**\n- OS: Windows 11\n- Target Framework: .NET 8\n- Version: 3.2.4\n- HL7 Version: tested using versions 2.3, 2.3.1, 2.5, 2.5.1","author":{"url":"https://github.com/rlannon","@type":"Person","name":"rlannon"},"datePublished":"2026-01-27T16:15:10.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/794/nHapi/issues/794"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a429a54a-5c3e-7af2-2b03-03c7ab1baacc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B2CA:327B79:65D88F:8B1E14:6A4C7D79 |
| html-safe-nonce | 14d4a50a7222f3152215211bc7ac2c3ad150c0be46ef0850ea90e84f3a93608a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMkNBOjMyN0I3OTo2NUQ4OEY6OEIxRTE0OjZBNEM3RDc5IiwidmlzaXRvcl9pZCI6IjQwNDk0Mzg4NTIyODgxMTgxMzciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5090eaf989c7a030726e2ba21f49114909d817779d6c9b99c767aa3af168e046 |
| hovercard-subject-tag | issue:3861336014 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nHapiNET/nHapi/794/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1189193ac764a0e80e6d9486b4535c319987b204f500f88e478c725210d43f8c/nHapiNET/nHapi/issues/794 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1189193ac764a0e80e6d9486b4535c319987b204f500f88e478c725210d43f8c/nHapiNET/nHapi/issues/794 |
| og:image:alt | Describe the bug PipeParser.Parse() does not properly parse conditional segments in groups, such as in the ORDER_DETAIL group in ORM_O01 messages. Instead, the parser erroneously treats these as in... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rlannon |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3d11bb817438277de2a940854450e83a7d32b6aeb5014e9e6b00a6423900251c |
| turbo-cache-control | no-preview |
| go-import | github.com/nHapiNET/nHapi git https://github.com/nHapiNET/nHapi.git |
| octolytics-dimension-user_id | 70870423 |
| octolytics-dimension-user_login | nHapiNET |
| octolytics-dimension-repository_id | 29993598 |
| octolytics-dimension-repository_nwo | nHapiNET/nHapi |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 29993598 |
| octolytics-dimension-repository_network_root_nwo | nHapiNET/nHapi |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | cd470457e909b9d062f8002cf438ba870e6acff6 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width