PowerShell Short Scripts

As a Data Engineer using Mirth Connect, it’s often tricky to review my team’s merge requests because the merge request document contains the XML representation of the channel. In order to understand what we’re looking at without loading the Mirth Connect Console, we have to be able to sight-inspect XML, which is not easy. Fortunately, there are a few things we can do in PowerShell to make this easier to read through, but it does require a copy of the file being reviewed.

First, we can check out the list of transformer steps in each of the destinations with some Select-Xml and Select-Object manipulation:

Select-Xml  .\CHANNEL.xml -XPath '//channel/destinationConnectors/connector' `
     | Select-Object -Property @{Name='Destination'; Expression={$_.node.name}}, `
                               @{Name='TransformerStep'; Expression={$_.node.transformer.elements.ForEach({$_.ChildNodes.name.Where({$_ -ne '#whitespace'})})}} `
     | ConvertTo-Json

Note: that there’s a ConvertTo-Json at the end only to make the output more readable.

If we want to take a closer look at the transformer steps, we can do that as well:

$connector="DATA_EXTRACTION"; 
Select-Xml .\CHANNEL.xml -XPath "//channel/destinationConnectors/connector[name='$connector']/transformer/elements/*" `
     | Select-Object -ExpandProperty Node

We can also take a look at the names of the filter steps:

Get-Childitem .\CHANNEL.xml | ForEach-Object { $ChannelFile = $_.Name; Select-Xml $_ -XPath '//channel/destinationConnectors/connector' `
     | Select-Object -Property @{Name='Channel'; Expression={$ChannelFile}}, `
                               @{Name='Destination'; Expression={$_.node.name}}, `
                               @{Name='FilterStep'; Expression={$_.node.filter.elements.ForEach({$_.ChildNodes.name.Where({$_ -ne '#whitespace'})})}}} `
     | ConvertTo-Json

This obviously doesn’t show absolutely all of the details so it’s not a substitute for viewing the channel in the Mirth Connect Editor, but it can give us a way to take a quick look when we’re in a pinch.

2025

Making PowerShell “Posh”

Back in the days when DOS and Windows were separate programs, the default Command Prompt didn’t look exactly the way that it does now. I can’t recall if it w...

Back to Top ↑

2024

PowerShell Short Scripts

As a Data Engineer using Mirth Connect, it’s often tricky to review my team’s merge requests because the merge request document contains the XML representati...

PowerShell Short Scripts

When dealing with Python dependencies, it’s sometimes necessary to determine if a given project is using a given version of a library. Since our team is usin...

Storing dotfiles in GitHub Revisited

A while ago, I wrote about using a bare git repository to manage my dotfiles. That worked somewhat well, but it had some shortcomings. Since, I’ve started us...

Python Context Managers

One of my current projects involves some improvements to code that I wrote last year – specifically enhancing the “Patient Identity Fixer”, which is my pet p...

PowerShell for Data Transformation: JSON

My team at work has a custom FHIR resource that we work with often called an Operation Outcome. We generate one of these for nearly every record we process, ...

Back to Top ↑

2021

Raspberry Pi Zero W “Busy Light”

COVID-19 has us many of us working from home. My husband and I are both fortunate enough to be in this group. However, as a teacher, his schedule is very pre...

Back to Top ↑

2020

Raspberry Pi Setup Script

When I set up a Raspberry Pi, there are a few things that I have to do right out of the gate to make things easier on myself. They involve putting a few file...

Storing dotfiles in GitHub

While I don’t use Linux as my primary operating system, I do use it a lot both at home and at work. It can be frustrating to try to sync up configurations be...

Nitro Cold Brew at Home!

Anyone who knows my husband or me knows that we really like our cold brew, and they also know that we make our own at home. Nitro cold brew has become a bit ...

OpenVPN On Raspberry Pi

So you want to run an OpenVPN Server on a Raspberry Pi? I did too, but it wasn’t easy to figure out the first time. If you want to skip all of this and do it...

Back to Top ↑