diff --git a/__tests__/hl7.sanity.test.ts b/__tests__/hl7.sanity.test.ts index 2a42db3..bd2f08d 100644 --- a/__tests__/hl7.sanity.test.ts +++ b/__tests__/hl7.sanity.test.ts @@ -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 }) diff --git a/src/utils/normalizedBuilder.ts b/src/utils/normalizedBuilder.ts index 242da70..f8d4449 100644 --- a/src/utils/normalizedBuilder.ts +++ b/src/utils/normalizedBuilder.ts @@ -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