Debug HL7 Activities with Visual Studio

Return to Tutorial Directory

Video Transcript

Debug HL7 Activities with Visual Studio:

Welcome to this tutorial on “Debugging HL7 activities with Visual Studio and HL7 Soup”.

We'll start by looking at the workflow. We have our “Add Patient” receiver which receives a message on MLLP TCP, and then what we do is we “Add Patient by Message”. This is a custom activity that we've written already in our “Add Patient to Database with Activities Tutorial”. The source code is available for this if you'd like to follow along. All it does is receives the message that came in from our TCP receiver, adds a record to a database, and returns the newly created database ID to the caller.

Let's run it and take a look. Start the workflow and send a message.

We have an error! It's telling us we have an invalid column called “Patient”. That's correct, the table on my database doesn't have a column called "Patient". There is one called “PatientID”, I suspect that's wrong. But the first place we always want to look for errors is at the HL7 Message Log, so I'm going to close this message and open up the workflow designer.

On the right, we can see the message logs. If I expand our message we can see that there was an error and it explains to us it was the “invalid column name patient”, and also if we look specifically at the add patient by message activity we can see it's received a source, but it didn't do anything else.

Okay, so we're going to have to look further.

Next, we'll take a look at the HL7 Soup log file. You’ll find this on your file system at the file path “%appdata%”. Hit “Enter”, this is your roaming app data directory. Then choose HL7 Soup and your log file is “HL7Soup.log”.

I'll open that in Notepad, and here we can see the message coming through followed by the error received. Again, it tells us this is an “invalid column name patient”. There's a whole lot of SqlClient exceptions, and here in our namespace is our custom activity. “Add Patient by Message”, and we can see it errored during the “Process” method.

Okay, so now that we know where it is, let's go and actually debug the code from our custom activity. I'll start by jumping across to Visual Studio, and here you can see I have my activity already loaded up. What I'm going to do is add a breakpoint, and now I can attach to the HL7 Soup process.

Find HL7 Soup, and now our Visual Studio is attached to HL7 Soup ready for debugging.

Now, all we have to do is go over to HL7 Soup, send a message through, and we should hit our breakpoint.

Let me start receiving again, send the message, and straight away our breakpoint is hit.

We can now step through the code easily with Visual Studio and we can even take a look at the values that were sent to us. For instance, if I look at the HL7 message, we can see an MDM T01 was sent through, and that was an “Original document notification”.

If I expand we can see the full message details, and if we zoom in on the text we can see the entire HL7 message. We also have a segments debugger helper. If we expand that we can see all the segments that belong to the message, including their description. If I expand one of these we can see the details about this segment and we can also see another debugger helper.

Now if we zoom into this we can see all the fields that are in this segment, including their address and descriptions.

Let's expand with one of those, and as you can see we can keep going further and further into the message, and find all the information we need to know. It's incredibly helpful when you're trying to debug paths or just want to know what another value is in a message.

Let’s continue stepping through the code of this activity.

You'll notice all variables are still available as I continue through and here we've gotten to the code where we create the command text, then execute the SQL.

I can see here right away, I've accidentally typed “SELECT Patient from Patient” instead of “SELECT PatientID from Patient”.

Thanks to the debugging experience, I can now edit this, then compile and redeploy this activity back into HL7 Soup, and I've fixed my problem.

I hope this enables you to see how easy and powerful debugging is in HL7 Soup, and I look forward to seeing the fantastic activities you can create.

If you'd like to see more of these tutorials please click “Subscribe”, and you'd help us out greatly if you click the like button.

Also if you haven't already seen it, watch our video on “Adding the Patient to the Database with Activities Tutorial”, and this will teach you all about the code we've just written.

Don't forget you can download the free trial of HL7 Soup from the HL7 Soup website.

Download 30 Day Free Trial of HL7 Soup