Mirth Connect - Channel Scheduler
Summary:
Installation:
- To Download this solution, click on the 3 dots (…) in the upper right corner and select attached files.
- Install the channels to Mirth Connect
- Create the scheduling table that will store all the scheduled tasks.
Adjust the source database variables in both the source db script and source post process db script for channel Utility Scheduler.
Save and deploy channel Utility Scheduler
Adjust the source side database variables in the source transformer for channel Populate Scheduler.
Save and deploy channel Populate Scheduler
Create a new scheduled task through channel Populate Scheduler
Overview of Operations
There is a control table 'util_schedule' (details below) kept either in a local or centralized database. The overall process is pretty simple, every minute the current datetime is compared to the run_date of the entries in the table, if there is a match then all returned values are looped through and an XML triggering message is sent to the channel registered in channel_id of the table. Then the value in run_date is adjusted forward by the values contained in run_adjust_count and run_adjust_interval, together they make something like the following.
The scheduler channel queries the 'util_schedule' table every minute to compare the current whole minute to the next run times whole minutes.
SELECT
id AS report_schedule_id,
run_date AS report_schedule_run_date,
run_adjust_count,
run_adjust_interval,
channel_id,
a,
b,
c,
d,
e,
f,
g,
h
FROM
util_schedule
where
run_date <= date_trunc('minute', LOCALTIMESTAMP)
and status = true
If there is a match, then a record like the following is returned to the channel and a copy forwarded to the channel noted in field 'channel_id'. The values of fields (a-h) are used as triggers or initiating values for the receiving channel.
<result> <schedule_id>2</schedule_id> <server_id>e57e0757-5fad-409f-985f-cfa0d0b5c3d8</server_id> <util_name>Backup SB</util_name> <util_desc>Backup Sandbox Channels and Groups</util_desc> <current_run_time>0030</current_run_time> <run_date>2022-05-01 00:30:00.0</run_date> <run_adjust_count>1</run_adjust_count> <run_adjust_interval>day</run_adjust_interval> <channel_id>d3514496-15f8-48a2-8d75-4be886675c03</channel_id> <run_days>sun,mon,tue,wed,thu,fri,sat</run_days> <run_start/> <run_stop/> <a>https://integrations-sandbox.dev.mirthcorp.com:8443/api</a> <b>user</b> <c>pass</c> <d/> <e/> <f/> <g/> <h/> </result>
Valid 'run_adjust_interval' field values include:
minute
hour
day
week
month
quarter
year
decade
century
millennium
Note: yes, you can set the interval to 10 millennium, looks funny but it can be done.
See date_trunc function documentation
update util_schedule set run_date = date_trunc('minute', LOCALTIMESTAMP) + interval '1 month' where id = ?
Note: if you download the solution, you will find 2 channels. 1 channel is the scheduler and 1 channel add and updates the
Note: you can find this solution used as part of the following solutions:
Comments
Post a Comment