From 6330c20d2f17d812112d2c7d9b7372cd7320ae5e Mon Sep 17 00:00:00 2001 From: Shane Froebel Date: Wed, 20 Dec 2023 19:25:11 -0500 Subject: [PATCH 1/2] fix: field.ts fix * if the field is not found as an array, then we go ahead and return the same object Fixes #44 Closes #44 --- .gitignore | 2 +- __tests__/hl7.build.test.ts | 1 + package.json | 4 ++-- src/builder/modules/field.ts | 3 +-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 6a31afe..74103ac 100644 --- a/.gitignore +++ b/.gitignore @@ -135,8 +135,8 @@ docs lib .npmrc package-lock.json -.npmrc # Webstorm .idea +.run temp diff --git a/__tests__/hl7.build.test.ts b/__tests__/hl7.build.test.ts index a0222d0..eb3f071 100644 --- a/__tests__/hl7.build.test.ts +++ b/__tests__/hl7.build.test.ts @@ -1021,6 +1021,7 @@ describe('node hl7 client - builder tests', () => { expect(message.get('MSH.9.2').toString()).toBe("A01") expect(message.get('MSH.9.3').toString()).toBe("ADT_A01") expect(message.get('MSH.10').toString()).toBe("12345") + expect(message.get('MSH.11.1').toString()).toBe("") expect(message.get('MSH.12').toString()).toBe("2.7") expect(message.get('EVN.2').toString()).toBe("20081231") diff --git a/package.json b/package.json index 451f1c2..1616489 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,8 @@ "clean": "rm -rf coverage docs lib temp", "build": "tsc && tsc -p tsconfig.cjs.json && tsc -p tsconfig.types.json && ./bin/build-types.sh", "build:watch": "tsc -w", - "lint": "ts-standard --parser @typescript-eslint/parser | snazzy", - "lint:fix": "ts-standard --fix --parser @typescript-eslint/parser | snazzy", + "lint": "ts-standard | snazzy", + "lint:fix": "ts-standard --fix | snazzy", "pack": "npm pack", "prepublishOnly": "npm run clean && npm run build && npm run test:ci && npm run pack", "test": "jest", diff --git a/src/builder/modules/field.ts b/src/builder/modules/field.ts index 74e287a..7a73d96 100644 --- a/src/builder/modules/field.ts +++ b/src/builder/modules/field.ts @@ -1,4 +1,3 @@ -import { HL7FatalError } from '../../utils/exception.js' import { Delimiters } from '../../utils/enum.js' import { Node } from '../interface/node.js' import { FieldRepetition } from './fieldRepetition.js' @@ -17,7 +16,7 @@ export class Field extends ValueNode { if (this.children.length > 0) { return this.children[0].read(path) } - throw new HL7FatalError(500, 'We have a problem.') + return this } /** @internal */ From 789ed52db2f099ecaa99266be43c74f57ab4b74a Mon Sep 17 00:00:00 2001 From: Shane Froebel Date: Wed, 20 Dec 2023 20:28:00 -0500 Subject: [PATCH 2/2] fix: end 2 end test fix * MSH.11.1 or MSH.11 must be defined for spec 2.7 Closes #44 --- __tests__/hl7.end2end.test.ts | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/__tests__/hl7.end2end.test.ts b/__tests__/hl7.end2end.test.ts index 225a573..4654536 100644 --- a/__tests__/hl7.end2end.test.ts +++ b/__tests__/hl7.end2end.test.ts @@ -337,7 +337,7 @@ describe('node hl7 end to end', () => { let LISTEN_PORT: number - const hl7_string: string = "MSH|^~\\&|||||20081231||ADT^A01^ADT_A01|12345||2.7\rEVN||20081231" + const hl7_string: string = "MSH|^~\\&|||||20081231||ADT^A01^ADT_A01|12345|D|2.7\rEVN||20081231" beforeAll(async () => { @@ -355,7 +355,7 @@ describe('node hl7 end to end', () => { const message = new Message({text: hl7_string, date: "8"}) message.toFile('readFileTestMSH', true, 'temp/') - await sleep(2) + await sleep(15) }) @@ -383,7 +383,7 @@ describe('node hl7 end to end', () => { expect(messageRes.get('MSA.1').toString()).toBe('AA') }) - await sleep(5) + await sleep(15) const fileBatch = await OB_ADT.readFile(`temp/hl7.readFileTestMSH.20081231.hl7`) @@ -422,7 +422,7 @@ describe('node hl7 end to end', () => { expect(messageRes.get('MSA.1').toString()).toBe('AA') }) - await sleep(5) + await sleep(15) const fileBatch = await OB_ADT.readFile(`temp/hl7.readFileTestMSH.20081231.hl7`) diff --git a/package.json b/package.json index 1616489..147c0f0 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "@typescript-eslint/parser": "^6.15.0", "jest": "^29.7.0", "jest-ts-webcompat-resolver": "^1.0.0", - "node-hl7-server": "^1.0.0-beta.4", + "node-hl7-server": "^1.0.0-beta.7", "npm-check-updates": "^16.14.12", "portfinder": "^1.0.32", "pre-commit": "^1.2.2",