HL7 output

I have a few questions that might seem unrelated, but aren’t for my task.

  1. can I produce a text file from each line in a spreadsheet? For example, if I have extracted 10 rows in an analysis, can I write each of the 10 lines out into a single file (i.e., 10 files)?

  2. can I write each of the entries into a new line (so that they are presented sequentially on one line, or placed on separate lines after a carriage return?
    e.g., the spreadsheet :
    "Patient", “BirthDate”, “ICD-10”, "Status"
    "AAM", “12/04/1976”, “Uterus”, "Alive"
    "GFD", “09/12/1954”, “Breast”, "Dead"
    becomes two plain text files
    Patient|AAM
    BirthDate|12/04/1976
    ICD-10|Uterus
    Status|Alive
    and
    Patient|GFD
    BirthDate|09/12/1954
    ICD-10|Breast
    Status|Dead

  3. Is there an existing workflow to produce a HL7 message from a single line of spreadsheet data?

I really appreciate the help given so far! If there are any people working on reporting from MOSAIQ the Oncology Information System, please drop me a line.

A

Yes that should be possible to do that. I have set up an example with your data. The results will be in the /output/ subfolder.

hl7_GFD.txt (59 Bytes)

1 Like

Dear @mlauber71

Truly, I am amazed by what you have done! It shows me that it can be done, but also that I really don’t understand how you have done it in the details.

The USE case is more complex than what I described (isn’t it always?). I was not trying to lead anyone on with the previous question, but was really trying to find out how possible it was with a simple example.

This is what I wish to do - I have a lot of exported information [16K lung function tests! 6K PSA blood tests] and which I can extract from more systems which are relevant to my patients. I can get spreadsheets of data, but except for manual entry and HL7, I have no way of getting them into my OIS (my gold-standard repository). So I need a mechanism that takes a spreadsheet format with a defined data structure, and a utility (knwf?) which will manipulate the entries into a HL7 message which can be imported into our OIS. I can then repeat this process each time I have a new spreadsheet of data. The difficulty will then be manipulating the spreadsheet data into the correct spreadsheet format before hitting the set manipulation process.

Here is the structure of an imported HL7 message. There is one HL7 message for each PATIENT-MRN, PATIENT-SURNAME and TIMESTAMP_OF_MEASURE triplet. The HL7 message can contain many contemporaneous measures. The message starts with “OBR”. Each measure starts with “OBX”. Line breaks are Windows format.

Here is a real spreadsheet with real values. If the patient changes, there will be a new line, and if the set of measures are repeated, they will have a new line also.

This is a copy of the HL7 message which was imported into our system from the measures provided above:

MSH|^~&|TestSendingSystem||||20150501202235||ORU^R01|1|P|2.3.1|123
PID|||ICCCDEPT||miller
OBR|1||1234^LAB|88304|||20150501202235||||||||||||||||||F
OBX|1|ST|pro00068||0||||||F|||201505012022|PROMPT
OBX|2|ST|pro00017||1||||||F|||201505012022|PROMPT
OBX|3|ST|pro00036||1||||||F|||201505012022|PROMPT
OBX|4|ST|pro00037||1||||||F|||201505012022|PROMPT
OBX|5|ST|pro00034||1||||||F|||201505012022|PROMPT
OBX|6|ST|pro00035||1||||||F|||201505012022|PROMPT
OBX|7|ST|pro00069||1||||||F|||201505012022|PROMPT
OBX|8|ST|pro00039||1||||||F|||201505012022|PROMPT
OBX|9|ST|pro00010||1||||||F|||201505012022|PROMPT
OBX|10|ST|pro00028||1||||||F|||201505012022|PROMPT
OBX|11|ST|pro00029||1||||||F|||201505012022|PROMPT

I hope you can help. and once again, I am in awe of you KNIME abilites. As a doctor, I make a good doctor, but as an IT person, I make a good doctor!

AAM

2 Likes

@AAM - glad you liked the initial demo. With such projects it is always the case that they are more complicated in the end. So no worries about that.

All the more important it is to make a good plan of what you want to do and right now I do not fully understand your task. You have spreadsheets from systems and you have these messages that would consist of one or more lines per patient.

From the example I assumed there would be one file per patient - which would likely mean that the target system would have to have a function to ‘bulk-load’ the data - or you would build a single TXT file that would contain the HL7 messages in the described format. That would make difference in what to do about the data. Maybe you could elaborate further.

And the best thing would be to provide a full scenario that contains all your conceptual challenges (several lines, different number of lines per patient depending on the message) and the desired outcome. So you would be able to judge if the KNIME solution did what you would expect it to do.

Then I sense that there is the question of updates and current status. I am not sure if your ‘HL7-receiving-system’ would handle that based on IDs (or names ?) and date/time - or if the KNIME system would have to deal with it - that could have some implications what kind of workflow one would have to build.

KNIME also offers the possibility to connect to several databases and systems not sure if there is a connection to the mentioned one.

Then in the example I tried to note with each node what has been done so it is easier to follow the method. Maybe that can be clarified and explained further.

Concerning the let’s say planning of this task. You might want to think about getting some help with that at your organisation. Maybe a talented student interested in data science (or hire a consultant) - or do you want to handle it all yourself - with KNIME that of course is possible since the workflow concept makes it relatively easy to scale up from a small desktop workflow up to steering big data systems for a major Telco company.

If you want to do more yourself it could make sense (besides seeking help in this forum of course :slight_smile: - which is very welcome and people are happy to help) to invest in some video courses to get a better feeling for the KNIME system. Also to make sure the output quality is what you need since with medical questions you are dealing with peoples health might be on the line.

And as it happens KNIME is offering a free introduction right next week. And besides that there are plenty of learning resources here on this site

1 Like

Dear @mlauber71,

Thank you for the reply. I can answer most of your points.

All the more important it is to make a good plan of what you want to do and right now I do not fully understand your task. You have spreadsheets from systems and you have these messages that would consist of one or more lines per patient.

I have spreadsheets with information (data points) from other systems. I do not have the messages, I wish to make the messages from the spreadsheets so that I can deliver the data inside the patient record using the infrastructure of the Oncology Information System (OIS).

From the example I assumed there would be one file per patient - which would likely mean that the target system would have to have a function to ‘bulk-load’ the data - or you would build a single TXT file that would contain the HL7 messages in the described format. That would make difference in what to do about the data. Maybe you could elaborate further.

It is likely that there will be many files per patient. Each assessment timestamp will have a separate line. I am trying to see if KNIME will do a ‘bulk production’ of HL7 messages. The subsequent ‘bulk load’ into the OIS is via an existing HL7 gateway that checks MRN, surname and item code to authorise intake.

And the best thing would be to provide a full scenario that contains all your conceptual challenges (several lines, different number of lines per patient depending on the message) and the desired outcome. So you would be able to judge if the KNIME solution did what you would expect it to do.

With all due respect, I much prefer an incremental, ‘agile’ system where I can see if and how things work and then play in a copy to see if I can rectify problems myself. It’s how I climb the learning curve. If you say that your brief example will do what I want, I’ll start fiddling with it to see if I can get it to work.

Then I sense that there is the question of updates and current status. I am not sure if your ‘HL7-receiving-system’ would handle that based on IDs (or names ?) and date/time - or if the KNIME system would have to deal with it - that could have some implications what kind of workflow one would have to build.

I don’t understand what you are saying here. You have already produced a prototype that does what is needed, i.e., a spreadsheet produces single HL7 files (*** actually, I think I have just found the answer to my problems which I will check and share later if it works!)

KNIME also offers the possibility to connect to several databases and systems not sure if there is a connection to the mentioned one.

There is no connection to a database required here. KNIME does connect to our database but the rule here is that nothing gets written in except by vendor-approved methods (as opposed to database-approved methods) and that mandates HL7 format that goes through the normal HL7 gateway input mechanism.

Then in the example I tried to note with each node what has been done so it is easier to follow the method. Maybe that can be clarified and explained further.

I shall look at the nodes again, obviously the first time I find it foreign, but I’ll try a few more times. My problem is that I have the brain of a doctor, and there is a very, very, large learning curve to climb to understand what you have done, so I find it only possible to follow examples provided by experts. I can’t spend the time needed to become fluent in ‘Computer’, and I don’t use it often enough to maintain any fluency anyway. I know what I want to do, but the actual coding/configuration requires expertise that I can’t develop except by spending full time learning.

Concerning the let’s say planning of this task. You might want to think about getting some help with that at your organisation. Maybe a talented student interested in data science (or hire a consultant) - or do you want to handle it all yourself - with KNIME that of course is possible since the workflow concept makes it relatively easy to scale up from a small desktop workflow up to steering big data systems for a major Telco company.

Unfortunately I work in a hospital where help for my information problems is not going to be provided, I have asked many times and I just get the dregs (“when I have finished all the things I need to do”). I am stuck handling this myself, OR not doing it. Though I see the need for data scientists in hospital departments (rather than IT departments), I am at least a decade in front of the curve in this view. A data scientist that I could train in data meaning would be wonderful, but the problem is that data scientists get employed and paid by managers to build dashboards showing managerial data rather than patient outcome data (as most departments don’t have outcome data). Until clinical data scientists are appointed (which will be after I retire!), the only way to collect, curate and manipulate this medical data is to do it myself.

If you want to do more yourself it could make sense (besides seeking help in this forum of course which is very welcome and people are happy to help) to invest in some video courses to get a better feeling for the KNIME system. Also to make sure the output quality is what you need since with medical questions you are dealing with peoples health might be on the line.

I have spend a great deal of time getting myself trained in KNIME and pulling resources together for my reporting needs of existing data. I have come to understand that I need specific examples to work on to learn, and even then I have to continually return to those examples. It has served me well so far. I noticed that you seem to have posted that Demo to a repository - I’ll check that out so you might be able to see some of what I have done so far.

And as it happens KNIME is offering a free introduction right next week. And besides that there are plenty of learning resources here on this site.

Thanks for that I’ll have a look.

1 Like

OK I do understand that. The example (which you can downloa dfrom the hub BTW) does transpose one single line of data into several lines. It does that for every column. Your task is more complicated from what I uderstand you would have something like:

  • one initial line (or more?)
  • and then serveral lines with information marked with OBR OBX

Such scenarios are also possible with KNIME. It would make sense if you could provide an example that represents your actual challenge so such things could be taken into account. I would like to see how the original data would be repressented in the spreadsheet. Maybe you could provide some samples and replace confindential information with dummy data.

Than I understand each message will be one (? TXT) file and the receiving system would deal with organizing it. That makes the task much easier.

It is good if you want to try everything yourself and with a tool like KNIME it should be possible also for non-experts once you have familiarized yourself with it. I thnik a comination of group, loop and transpose would be sufficient.

I can try and give more information and explain my reasoning behind several steps that I took so you might be able to judge yourself if this is what you want.

Dear @mlauber71

Thank you for the prompt return.

I think that I need to make clear that the detailed data I shared is “real” data in that the HL7 produced for you was successfully entered into the OIS. It was however fictitious data entered by me and sent to my ‘administrative’ account in the OIS (I store my letters, certificates, etc there). So there is no patient confidentiality issue in play.

I’ll have some time to play tonight and I’ll get back to you with any results. And then we’ll see what remains.

The structure of the spreadsheet is interesting. My plan is to specify the spreadsheet structure based on the KNIME SS>HL7 transformation workflow. It is too difficult to build an ‘anything goes’ spreadsheet circumstance; it has to be done a particular way for the HL7 to be produced. Ideally I would like it to be like the second SS that I shared with 2 dates (the timestamp_message could be autogenerated as well), 2 patient identifiers and named columns with a value.

Once again, many thanks for engaging with me. I’ll get back to you.

A

1 Like

@AAM very good if you gain more expertise about KNIME and your data. I think with the combination of a few KNIME nodes (LAG, Transpose, Loop, Group By, String Manipulation, TXT export) you will be able to achieve your goals. And I think the community will be happy to help along the way so pleas come back with more questions and examples.

Concerning creating time and timestamps I could offer these examples:

Back again.

I have been working some more on my problem which revolves around starting with a spreadsheet and producing HL7 messages (which are saved into text files).

I started by working on getting the spreadsheet structure and getting it simple and settled, and then working on how to get the DATE_OF_MESSAGE (today’s date) into the correct format (YYYYMMDDHHMMSS). I have achieved that! The spreadsheet structure is simple -
image
[The bottom row (#8) is the meaning of the data in the column. These examples are made up, although they look like medical data]

I have been able to take this spreadsheet and do manipulations to get the correctly 4 formatted rows that make up the expected HL7 message (it requires 4 lines with a carriage return separator). The process is listed below and in the attached file.

image

KNIME_HL7.knwf (19.6 KB)

There are two things remaining which are still out of my reach despite hours of research and playing.

  1. join the 4 lines up into one text entry. (I can’t discover how to add an ASCII 13 code).
  2. push each text entry into a separate text file (name can be “Col1”, “Col2”, etc).

Obviously, I will persist with looking for a solution, but any help at present would be appreciated.

A

1 Like

@AAM i used your example and set up a workflow that hopefully takes you further in the right direction. Feel free to test it and ask additional questions.

I saw you used an advanced Column expression. I left that as it was.

In your case I would suggest to use a Loop and handle each message (consisting of several lines as one case and export that into a txt file). Therefor you would need a unique ID that would also server as a file name.

I like to use the KNIME protocol that makes it easy to point to files relative to the workflow so you can easily exchange examples.

new_id would serve as a unique ID to identify the case later. It is the name and the ? date. You could easily extend this to make it unique and suitable

image

This new_id will be used as RowID for further reference
image

Table Row to variable Loop is my favourite loop. It uses a table you have somehow produced (in this case all your lines you want to convert) and gives you all the information you need at your fingertips. Once you have familiarised yourself with the concept it will become your swiss-army-knife of automating your tasks.

The Rule Based Row filter so some simplified language to write conditions.

In this example you use the information from the Flow Variable to construct a file name - with the unique ‘new_id’. But you are free to construct every Filename you want and path. In this case the results will land in a subfolder of the workflow - regardless of where this workflow is.

image

Then you transpose the current case. The new_id is the column and the lines contain the information. If you would add more lines there would be more.

image

Then the CSV writer would write everything to disk. You could choose various encodings. UTF-8 would be a modern standard. In this case I choose US-ASCII as this might suite your needs but you would have to check out which encoding HL7 would accept. With US-ASCII there are some obvious limitations (special characters …).

Ten you could choose the Line endings. CR should be ASCII 13 - carriage return. If this is not the case we would have to find other measures. This might be a good time to ask KNIME (@ScottF ? :slight_smile: ) if it is possible to make the line character more flexible although it might confuse people.

image

And then at the end of the loop you have the results as individual files:

Here is the full example for further investigation. If you have additional questions please ask. It is very possible that there are several ways to do this. I like using the loops with Table Rows - I think it gives me control and I can easily change settings.

kn_forum_hl7_message2.knwf (55.8 KB)

Thanks @mlauber71,

It will take me some days to get the time and neurons together to digest this. I do appreciate your efforts and am very appreciative.

A

1 Like

@mlauber71,

I have started reading. Can I please ask what this means?

image

I understand that it is a selection semantic but the syntax makes no sense to me (entirely my failing!).

A

It is a simplified code for selection conditions. Knime will assign a true or false to each line depending on the condition. Once a condition is met the result is fixed and will not change even if another condition further down the line would also be met.

The first RowId Is the column variable you get by double clicking in the column list top left. The one with red brackets is the same variable but from the flow variable list and is the current rowid from the loop.

So every line that has the current rowid will get a TRUE and every other line gets a false - therefor the last line true is false which sounds somewhat strange but represents the default outcome.

To make things easier (or more complicated) you can choose to keep either the true or the false results. Sometimes it could be easier to define a negative.

You can read more about this node here:

Also on the hub if you select the tab “nodes” you can read about each node that has been used.

1 Like

Hi,

I am also working in a hospital and I do have access to HL7 messages. i don’t understand what is the problem of generating them ? I mean if you have all the headers mentioned on Wikipedia with certain datatypes, you can generate messages. They are just CSV files but instead of “,”, they have pipe sign “|” as a separator. Am I missing something here ?

Best,
Mateen

1 Like

In this case the task was to get such messages from a dataset to a collection of individual files. And the files would contain a varying number of lines from these data source. From what I understand the syntax cvan be more complex than simple CSV and can be more like XML. But I am no expert in that field and if someone would compute their HL7 messages in a different way they might as well do it.

HL7 v2.x messages use a non-XML encoding syntax based on segments (lines) and one-character delimiters.[5] Segments have composites (fields) separated by the composite delimiter. A composite can have sub-composites (components) separated by the sub-composite delimiter, and sub-composites can have sub-sub-composites (subcomponents) separated by the sub-sub-composite delimiter.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.