Skip to content

Commit

Permalink
fix: parsing error
Browse files Browse the repository at this point in the history
- for lines ending with line breaks #96
  • Loading branch information
Bugs5382 committed Jun 3, 2024
1 parent 4b515e6 commit adb0911
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions __tests__/hl7.sanity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,14 @@ describe('node hl7 client - sanity tests', () => {
const hl7_non_standard: string = 'MSH:-+?*:field2:field3component1-field3component2:field4repeat1+field4repeat2:field5subcomponent1*field5subcomponent2:field6?R?'
const hl7_batch: string = 'BHS|^~\\&|||||20231208\rMSH|^~\\&|||||20231208||ADT^A01^ADT_A01|CONTROL_ID||2.7\rEVN||20081231\rEVN||20081231\rBTS|1'
const hl7_batch_non_standard: string = 'BHS:-+?*:::::20231208\rMSH|^~\\&|||||20231208||ADT^A01^ADT_A01|CONTROL_ID||2.7\rEVN||20081231\rEVN||20081231\rBTS|1'
const hl7_line_breaks: string = 'MSH|^~\\&|device||Host||20240101000000+0000||OUL^R22^OUL_R22|2|P|2.5.1|||NE|AL||UNICODE UTF-8|||LAB-01^IHE\r'

test('...clean up line breaks', async () => {

const message = new Message({ text: hl7_line_breaks });
expect(message.get('MSH.12').toString()).toBe('2.5.1')

})

test('...verify MSH input', async () => {
const message = new Message({ text: hl7_string })
Expand Down
2 changes: 2 additions & 0 deletions src/utils/normalizedBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ export function normalizedClientMessageBuilderOptions (raw?: ClientBuilderMessag
props.separatorSubComponent = plan.separatorSubComponent
// remove default specs
props.specification = undefined
// cleanup
props.text = props.text.trim()
}

return props
Expand Down

0 comments on commit adb0911

Please sign in to comment.