WebService::Mirth - Interact with a Mirth Connect server via REST
version 0.131220
my $mirth = WebService::Mirth->new( server => 'mirth.example.com', port => 8443, username => 'admin', password => 'password', ); $mirth->export_channels({ to_dir => 'path/to/export/to/' }); $mirth->export_global_scripts({ to_dir => 'path/to/export/to/' }); $mirth->export_code_templates({ to_dir => 'path/to/export/to/' });
Mirth Connect is an open-source Java-powered application used for healthcare integration. Incoming HL7 or XML feeds containing electronic medical records can be parsed and then handled (munged, stored, sent off, etc) by Mirth Connect.
This module provides a pure-Perl means of RESTful interaction with a Mirth Connect server (referred to as "Mirth" going forward). The functionality is similar to what the "Mirth Shell" program provides within a Mirth installation.
Parser code living in Mirth can be exported as XML files locally, for off-site archival.
Mojo::DOM objects in some of the "ATTRIBUTES" could be used for inspecting or altering the channels locally (ie. turn a channel off by changing the "enabled" node from "true" to "false").
The "login" and "logout" methods will automatically be called as needed.
All internal HTTP interactions are performed via Mojo::UserAgent, so the MOJO_USERAGENT_DEBUG environment variable can be set to 1 to turn on HTTP debugging.
MOJO_USERAGENT_DEBUG
Log::Minimal is used for application logging, so the LM_DEBUG environment variable can be set to 1 for additional debugging.
LM_DEBUG
A string containing the FQDN (see "CAVEATS") of the Mirth server to connect to.
The Jetty port that Mirth is listening on for HTTP.
A string containing the version of Mirth that the "server" is hosting. This value is required by Mirth for HTTP interaction.
Defaults to "0.0.0", which should be sufficient.
The name of the user to connect with. "admin" is likely a good choice: full administrative privileges are ideal.
The corresponding password for the "username" being used.
A Mojo::URL object that represents the HTTP address of the Mirth server. The RESTful HTTP requests will be made based on this URL.
Mirth uses HTTPS, so it will be constructed into something like https://mirth.example.com:8443.
https://mirth.example.com:8443
A Mojo::DOM object of the XML representing the "Code Templates" in Mirth. Used by "get_code_templates" to create a WebService::Mirth::CodeTemplates object.
A Mojo::DOM object of the XML representing the "Global Scripts" in Mirth. Used by "get_global_scripts" to create a WebService::Mirth::GlobalScripts object.
A Mojo::DOM object of the XML representing all of the channels in Mirth. Massaged by "get_channel" to return a WebService::Mirth::Channel object.
Also used in the construction of "channel_list".
Contains a hashref representing all of the channels in Mirth. The key is a channel name and the value is the corresponding channel ID.
$mirth->login;
Login as "username" at the /users URI, via an HTTP POST. If authentication is successful, starts a session that persists until "logout" is called.
/users
This method is automatically called upon object construction.
$global_scripts = $mirth->get_global_scripts;
Returns a WebService::Mirth::GlobalScripts object of the "Global Scripts" in Mirth.
$mirth->export_global_scripts({ to_dir => 'path/to/export/to/' });
Given a path to a directory in the to_dir parameter, writes an XML file named global_scripts.xml to the directory.
to_dir
global_scripts.xml
$code_templates = $mirth->get_code_templates;
Returns a WebService::Mirth::CodeTemplates object of the "Code Templates" in Mirth.
$mirth->export_code_templates({ to_dir => 'path/to/export/to/' });
Given a path to a directory in the to_dir parameter, writes an XML file named code_templates.xml to the directory.
code_templates.xml
$channel = $mirth->get_channel('foobar'); print $channel->name, "\n"; # "foobar" print $channel->id, "\n"; # "a25ea24c-d8f4-439a-9063-62f8a2b6a4b1" print $channel->enabled, "\n"; # "true"
Given the name of a channel in Mirth, returns a WebService::Mirth::Channel object.
$mirth->export_channels({ to_dir => 'path/to/export/to/' });
Given a path to a directory in the to_dir parameter, writes XML files (with names like my_channel.xml) to the directory.
my_channel.xml
$mirth->logout;
Ends the session initiated by "login".
This method is automatically called upon object destruction.
It seems that an FQDN (fully-qualified domain name) is required for "server" in order for the session started by "login" (involving cookies) to stick.
For example, an IP address for "server" is not sufficient. A workaround could be adding an entry to /etc/hosts with something like "mirth.localhost" (in which case, see hosts(1)).
/etc/hosts
Thanks to the Informatics Corporation of America (ICA) for sponsoring the development of this module.
Tommy Stanton <tommystanton@gmail.com>
This software is copyright (c) 2013 by Tommy Stanton.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install WebService::Mirth, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WebService::Mirth
CPAN shell
perl -MCPAN -e shell install WebService::Mirth
For more information on module installation, please visit the detailed CPAN module installation guide.