Question
· Nov 23, 2016

Text File Fixed Format

I have a standard text file that is coming out of a system new line delimited. Each document will have the same field structure each time.

ID: xxxxxxxxx
Name: xxxx,xxxx   Age: xx   Sex: x

OSU Wexner Medical Center Harding Hospital
Treatment at  7/14/2016   10:39:34 AM

% Energy Set                                    50 %
Charge Delivered                             255.4 mC
Current                                       0.91 A
Stimulus Duration                              7.0 Sec
Frequency                                       40 Hz
Pulse Width                                   0.50 mSec
Static Impedance                              1170 Ohm
Dynamic Impedance                              200 Ohm
EEG Endpoint is not detected
EMG Endpoint                                    15 Sec
Base Heart Rate                                 78 b/m
Peak Heart Rate                                 91 b/m
Average Seizure Energy Index                7471.4 ?V?
Postictal Suppression Index                    N/A
Maximum Sustained Power                    15787.0 ?V?
Time to Peak Power                              12 Sec
Maximum Sustained Coherence                   99.3 %
Time to Peak Coherence                          17 Sec
Early Ictal Amplitude                        113.1 ?V
Midictal Amplitude                           177.7 ?V
Post-Ictal Amplitude                           N/A
Program Selected:   LOW 0.5 CHARGE RATE

Is there a way we could read this into Ensemble to parse it out into an HL7 flow sheet message?

Discussion (7)1
Log in or sign up to continue

As I see you have multiple tasks. At first, you should parse this file. But I don't see any code from you, how you tried to do this task. So, I'm not going to do it instead of you. Just give you some advices. Looks like format for this file is fixed, you can use %Stream.FileCharacter class to read file line by line, with method ReadLine. Then for each read line of text you can use regular expression to extract needed data. 

But I don't know what to say about second part of your question because I have not worked yet with HL7.

I think the way I would code this is create a new message object which contains properties for all the fields that might appear in the file.  Then create a new custom file service using the adapter EnsLib.File.InboundAdapter.  In the OnProcessInput for that new file service, use Dmitry and Carlos's suggestion to read the file with pRequest.ReadLine() and parse each line to extract the property name and value and store the value in the appropriate property of the new message object.

Then, have the service send that message object to a router with a DTL transform which will convert from your new message object class into an HL7 message and send that message to the target.

I'm not sure that the Ensemble Record Mapper makes this much easier than just reading the stream. Unless you don't treat the end of line as terminator, each line will be a separate record. It is possible that you could use the Complex Record Mapper to create one record from the file using the first column as the leading text, but that requires defining one record map for each line in the file. I'm not sure how to handle the Hospital name and blank lines. I don't think that batch record map would help because there's different kinds of information on each line.

But I think most of the work is not going to be parsing the input file but in making sure that the HL7 message has all the right segments and fields.