Code Monkey home page Code Monkey logo

Comments (3)

RobHolme avatar RobHolme commented on September 3, 2024 1

Should be trivial to remove the vertical tab characters from the file before you parse them. I assume something like:

(Get-Content -Path c:\temp\test.hl7).Replace("`v","") | Out-File -Path C:\temp\test.hl7 

Or even better, find out why the vertical tab is added to the file in the first place and fix the root issue. The vertical tab is part of the MLLP frame, but any MLLP framing is typically removed before saving the message to a file.

from hl7-powershell-module.

newcreature517 avatar newcreature517 commented on September 3, 2024

Rob,
Thanks for the quick answer. Unfortunately, the files come from the vendor with the `v on them, and removing it from all the files before processing is doable, but isn't the best solution. I need to get a few dozen values out of each file and then write them to a database, so opening each HL7 message a few dozen times (some of which are several MB) multiplied by about 20 million would be pretty inefficient.

Ideally, if your cmdlet would have a -text option that would allow it to read the text from a variable already in memory (which is where I would strip the `v), the file access would only have to happen once for each message, saving tons of I/O.

from hl7-powershell-module.

RobHolme avatar RobHolme commented on September 3, 2024

You can retrieve more than 1 value from a single query, this would remove the need to open each file multiple times. e.g.

> Select-HL7Item -ItemPosition MSH-9.2, PID-3[1].1, PID-5, PID-7, PV1-2 -Path .\test.hl7

MSH-9.2    : A01
PID-3[1].1 : 10006579
PID-5      : DUCK^DONALD^D
PID-7      : 19241010
PV1-2      : I
Filename   : C:\scratch\test.hl7

If you need to do further processing via a script, save the result object to a variable and access the values via the variable's properties. e.g.

> $results = Select-HL7Item -ItemPosition MSH-9.2, PID-3[1].1, PID-5, PID-7, PV1-2 -Path .\test.hl7

> $results.'MSH-9.2'
A01

> $results.'PID-5'
DUCK^DONALD^D

Reading the message contents from a file into a variable, then passing this in as a parameter will still require just as many file reads as the example above.

from hl7-powershell-module.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.