Bugs5382 / node-hl7-client

A pure Node.js HL7 Client that allows for communication to a HL7 Broker/Server that can send properly formatted HL7 messages with ease.It can also parse and then you can extract message segments out.
MIT License
15 stars 4 forks source link

fix: Unable to do addSegment and then do ('PV1.1', <value>) --> Invalid Index #33

Open Bugs5382 opened 9 months ago

Bugs5382 commented 9 months ago
const message = new Message({
    messageHeader: {
      msh_9_1: "ADT",
      msh_9_2: "AO1",
      msh_10: "CONTROL_ID"
    }
  })

  let segment = message.addSegment('PV1')
  segment.set('PV1.1', 1) // this should be a valid since it's not MSH, BHS, or FHS.

Current getting error:

Can't have an index < 1 or not be a valid number.
HL7FatalError: Can't have an index < 1 or not be a valid number.
    at Segment.writeCore (/Users/userdirectory/Documents/projects/GIT.nosync/fastify-hl7/node_modules/node-hl7-client/lib/cjs/builder/modules/segment.js:100:19)
    at Segment.write (/Users/userdirectory/Documents/projects/GIT.nosync/fastify-hl7/node_modules/node-hl7-client/lib/cjs/builder/modules/nodeBase.js:183:21)
    at Segment.set (/Users/userdirectory/Documents/projects/GIT.nosync/fastify-hl7/node_modules/node-hl7-client/lib/cjs/builder/modules/segment.js:71:22)
    at Object.<anonymous> (/Users/userdirectory/Documents/projects/GIT.nosync/fastify-hl7/__tests__/fastify.tests.ts:31:14)
    at Promise.then.completed (/Users/userdirectory/Documents/projects/GIT.nosync/fastify-hl7/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/Users/userdirectory/Documents/projects/GIT.nosync/fastify-hl7/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusTest (/Users/userdirectory/Documents/projects/GIT.nosync/fastify-hl7/node_modules/jest-circus/build/run.js:316:40)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async _runTest (/Users/userdirectory/Documents/projects/GIT.nosync/fastify-hl7/node_modules/jest-circus/build/run.js:252:3)
    at async _runTestsForDescribeBlock (/Users/userdirectory/Documents/projects/GIT.nosync/fastify-hl7/node_modules/jest-circus/build/run.js:126:9)
    at async run (/Users/userdirectory/Documents/projects/GIT.nosync/fastify-hl7/node_modules/jest-circus/build/run.js:71:3)
    at async runAndTransformResultsToJestFormat (/Users/userdirectory/Documents/projects/GIT.nosync/fastify-hl7/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
    at async jestAdapter (/Users/userdirectory/Documents/projects/GIT.nosync/fastify-hl7/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
    at async runTestInternal (/Users/userdirectory/Documents/projects/GIT.nosync/fastify-hl7/node_modules/jest-runner/build/runTest.js:367:16)
    at async runTest (/Users/userdirectory/Documents/projects/GIT.nosync/fastify-hl7/node_modules/jest-runner/build/runTest.js:444:34)

Need to figure out where it is. I check the based NPM that I used as a base, but can't find the cause. Backlog for now..

Bugs5382 commented 2 months ago

Still failing... help!