From 05530336b4b277ce692a95b243d7d2bd4926b683 Mon Sep 17 00:00:00 2001 From: Dileep Date: Wed, 14 Mar 2018 11:05:16 -0400 Subject: [PATCH 01/20] Add mirth connect client configuration options to config.json --- config.json | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/config.json b/config.json index c3e9ccb..a9bd220 100644 --- a/config.json +++ b/config.json @@ -109,6 +109,30 @@ "type": "rich-text" } ] + }, + { + "key" : "send-rx-hl7-settings", + "name" : "hl7 settings", + "required": false, + "type": "sub_settings", + "sub_settings": [ + { + "key": "send-rx-hl7-end-point", + "name": "End-point", + "required": false, + "type": "text" + }, { + "key": "send-rx-hl7-channel-ID", + "name": "Channel ID", + "required": false, + "type": "text" + }, { + "key": "send-rx-hl7-json", + "name": "HL7 json message", + "required": false, + "type": "textarea" + } + ] } ], "enable-every-page-hooks-on-system-pages": true, From bcf4c4cff08fd9b13b309ccf0c39ae11f730f380 Mon Sep 17 00:00:00 2001 From: Dileep Date: Mon, 19 Mar 2018 09:56:14 -0400 Subject: [PATCH 02/20] Add method to get hl7 settings in send_rx_functions.php --- includes/send_rx_functions.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/includes/send_rx_functions.php b/includes/send_rx_functions.php index 97b5e55..14985a5 100644 --- a/includes/send_rx_functions.php +++ b/includes/send_rx_functions.php @@ -79,6 +79,34 @@ function send_rx_get_project_config($project_id, $project_type) { return $config; } +/** + * Gets hl7 settings for that specific + * + * @param int $project_id. + * The project id. + * + * @return associative array $hl7_settings. + * An associative array that carries the hl7 settings with the following keys: + * - send-rx-hl7-end-point: the begining of the URL of the mirth connect server. + * - send-rx-hl7-channel-ID: extension that holds the input connector at the end-point. + * - send-rx-hl7-json: json message to be sent to end-point. + */ + function getHL7Settings($project_id) { + $q = ExternalModules::getSettings('send_rx', $project_id, ['send-rx-hl7-end-point', 'send-rx-hl7-channel-ID', 'send-rx-hl7-json']); + if (!db_num_rows($q)) { + return false; + } + + $hl7_settings = []; + + while($result = db_fetch_assoc($q)) { + $hl7_settings[$result['key']] = $result['value']; + } + + return $hl7_settings; + } + + /** * Gets site ID from DAG. * From 196d577f1b0ebb32c79ece0f2f87a3cfacbbcc3a Mon Sep 17 00:00:00 2001 From: Dileep Date: Wed, 21 Mar 2018 10:41:44 -0400 Subject: [PATCH 03/20] Restructure hl7 settings in config to json to avoid json-encoding setting values --- config.json | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/config.json b/config.json index a9bd220..12bf872 100644 --- a/config.json +++ b/config.json @@ -111,28 +111,24 @@ ] }, { - "key" : "send-rx-hl7-settings", - "name" : "hl7 settings", + "key": "hl7-settings", + "name": "HL7 settings", + "type": "descriptive" + }, + { + "key": "send-rx-hl7-end-point", + "name": "End-point", + "required": false, + "type": "text" + }, { + "key": "send-rx-hl7-channel-id", + "name": "Channel ID", "required": false, - "type": "sub_settings", - "sub_settings": [ - { - "key": "send-rx-hl7-end-point", - "name": "End-point", - "required": false, - "type": "text" - }, { - "key": "send-rx-hl7-channel-ID", - "name": "Channel ID", - "required": false, - "type": "text" - }, { - "key": "send-rx-hl7-json", - "name": "HL7 json message", - "required": false, - "type": "textarea" - } - ] + "type": "text" + }, { + "key": "send-rx-hl7-json", + "name": "HL7 json message", + "type": "textarea" } ], "enable-every-page-hooks-on-system-pages": true, From 66149d09e386f656ef614388b1130d1590ccc0a5 Mon Sep 17 00:00:00 2001 From: Dileep Date: Wed, 21 Mar 2018 10:54:32 -0400 Subject: [PATCH 04/20] Add send_rx_generate_mirth_client method to send_rx_functions.php --- includes/send_rx_functions.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/includes/send_rx_functions.php b/includes/send_rx_functions.php index 14985a5..fd4cff2 100644 --- a/includes/send_rx_functions.php +++ b/includes/send_rx_functions.php @@ -179,6 +179,21 @@ function send_rx_piping($subject, $data) { return $subject; } + +/** + * Generates a mirth client. + * + * @param string $endpoint. + * Base url of the REST API being connected to. + * + * @return REDCapMithClient obj + * TRUE if success, FALSE otherwise. + */ +function send_rx_generate_mirth_client($endpoint) { + $client_module = ExternalModules::getModuleInstance('redcap_mirth_client', 'v1.0'); + return $client_module->getClient($endpoint); +} + /** * Generates a PDF file. * From dc584fb155ff2408f1f6b7d7fc29891d936a17eb Mon Sep 17 00:00:00 2001 From: Dileep Date: Wed, 21 Mar 2018 10:55:40 -0400 Subject: [PATCH 05/20] Impliment hl7 case inside RxSender's send method --- includes/RxSender.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/includes/RxSender.php b/includes/RxSender.php index 66ced68..9c5e570 100644 --- a/includes/RxSender.php +++ b/includes/RxSender.php @@ -387,7 +387,9 @@ function send($generate_pdf = true, $log = true) { break; case 'hl7': - // TODO: handle HL7 messages. + $settings = getHL7Settings($this->siteProjectId); + $client = send_rx_generate_mirth_client($settings['send-rx-hl7-end-point']); + $client->request('POST', $settings['send-rx-hl7-channel-ID'], $settings['send-rx-hl7-json']); break; } } From 1b7ec530a9af75fcd0770145fe28144dddd00d4c Mon Sep 17 00:00:00 2001 From: Dileep Date: Fri, 23 Mar 2018 09:52:23 -0400 Subject: [PATCH 06/20] Integrate HL7 case with logging system --- includes/RxSender.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/includes/RxSender.php b/includes/RxSender.php index 9c5e570..d626887 100644 --- a/includes/RxSender.php +++ b/includes/RxSender.php @@ -387,9 +387,14 @@ function send($generate_pdf = true, $log = true) { break; case 'hl7': + //send json of hl7 message to mirth-connect $settings = getHL7Settings($this->siteProjectId); $client = send_rx_generate_mirth_client($settings['send-rx-hl7-end-point']); - $client->request('POST', $settings['send-rx-hl7-channel-ID'], $settings['send-rx-hl7-json']); + $response = $client->request('POST', $settings['send-rx-hl7-channel-ID'], $settings['send-rx-hl7-json']); + + //log hl7 message that was sent + $success = $response->getStatusCode() == 200; + $this->log($type, $success, $settings['send-rx-hl7-end-point'], 'POST', $settings['send-rx-hl7-json']); break; } } From e4d591dcdc3a284170d3a92b2b4635253ac25b07 Mon Sep 17 00:00:00 2001 From: Dileep Date: Fri, 23 Mar 2018 10:33:20 -0400 Subject: [PATCH 07/20] Hide all hl7 configuration settings when on a patient project --- config.json | 2 +- css/config.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config.json b/config.json index 12bf872..b47f4a3 100644 --- a/config.json +++ b/config.json @@ -111,7 +111,7 @@ ] }, { - "key": "hl7-settings", + "key": "send-rx-hl7-settings", "name": "HL7 settings", "type": "descriptive" }, diff --git a/css/config.css b/css/config.css index bcebbe0..6fc21d0 100644 --- a/css/config.css +++ b/css/config.css @@ -5,6 +5,6 @@ .send-rx [field="send-rx-message"], .send-rx [field="send-rx-message-subject"], .send-rx [field="send-rx-message-body"], -.send-rx [field="send-rx-hl7-schema"] { +.send-rx [field^="send-rx-hl7-"] { display: none; } From ed61dfa666853fad4c33efbf17ac8c251d0feb7f Mon Sep 17 00:00:00 2001 From: Dileep Date: Fri, 23 Mar 2018 10:46:16 -0400 Subject: [PATCH 08/20] Generalize css field matching --- css/config.css | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/css/config.css b/css/config.css index 6fc21d0..edff109 100644 --- a/css/config.css +++ b/css/config.css @@ -1,10 +1,5 @@ -.send-rx [field="send-rx-pdf-template"], -.send-rx [field="send-rx-pdf-template-variable"], -.send-rx [field="send-rx-pdf-template-variable-key"], -.send-rx [field="send-rx-pdf-template-variable-value"], -.send-rx [field="send-rx-message"], -.send-rx [field="send-rx-message-subject"], -.send-rx [field="send-rx-message-body"], -.send-rx [field^="send-rx-hl7-"] { +.send-rx [field^="send-rx-pdf-template"], +.send-rx [field^="send-rx-message"], +.send-rx [field^="send-rx-hl7"] { display: none; } From cbdfae60441b08926c93d5a6520211fe8a4072f1 Mon Sep 17 00:00:00 2001 From: Dileep Date: Fri, 23 Mar 2018 11:14:49 -0400 Subject: [PATCH 09/20] Rename send-rx-hl7-channel-ID to send-rx-hl7-extension --- config.json | 2 +- includes/RxSender.php | 2 +- includes/send_rx_functions.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config.json b/config.json index b47f4a3..27e573b 100644 --- a/config.json +++ b/config.json @@ -121,7 +121,7 @@ "required": false, "type": "text" }, { - "key": "send-rx-hl7-channel-id", + "key": "send-rx-hl7-extension", "name": "Channel ID", "required": false, "type": "text" diff --git a/includes/RxSender.php b/includes/RxSender.php index d626887..083ecd0 100644 --- a/includes/RxSender.php +++ b/includes/RxSender.php @@ -390,7 +390,7 @@ function send($generate_pdf = true, $log = true) { //send json of hl7 message to mirth-connect $settings = getHL7Settings($this->siteProjectId); $client = send_rx_generate_mirth_client($settings['send-rx-hl7-end-point']); - $response = $client->request('POST', $settings['send-rx-hl7-channel-ID'], $settings['send-rx-hl7-json']); + $response = $client->request('POST', $settings['send-rx-hl7-extension'], $settings['send-rx-hl7-json']); //log hl7 message that was sent $success = $response->getStatusCode() == 200; diff --git a/includes/send_rx_functions.php b/includes/send_rx_functions.php index fd4cff2..3605a92 100644 --- a/includes/send_rx_functions.php +++ b/includes/send_rx_functions.php @@ -88,11 +88,11 @@ function send_rx_get_project_config($project_id, $project_type) { * @return associative array $hl7_settings. * An associative array that carries the hl7 settings with the following keys: * - send-rx-hl7-end-point: the begining of the URL of the mirth connect server. - * - send-rx-hl7-channel-ID: extension that holds the input connector at the end-point. + * - send-rx-hl7-extension: extension that holds the input connector at the end-point. * - send-rx-hl7-json: json message to be sent to end-point. */ function getHL7Settings($project_id) { - $q = ExternalModules::getSettings('send_rx', $project_id, ['send-rx-hl7-end-point', 'send-rx-hl7-channel-ID', 'send-rx-hl7-json']); + $q = ExternalModules::getSettings('send_rx', $project_id, ['send-rx-hl7-end-point', 'send-rx-hl7-extension', 'send-rx-hl7-json']); if (!db_num_rows($q)) { return false; } From bb2006c162fb93a10849b0bcd5239152e88c53b0 Mon Sep 17 00:00:00 2001 From: Dileep Date: Fri, 23 Mar 2018 11:17:47 -0400 Subject: [PATCH 10/20] Changle send-rx-hl7-extension configuration label to 'end-point extension' --- config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.json b/config.json index 27e573b..beefddf 100644 --- a/config.json +++ b/config.json @@ -122,7 +122,7 @@ "type": "text" }, { "key": "send-rx-hl7-extension", - "name": "Channel ID", + "name": "end-point extension", "required": false, "type": "text" }, { From 5f5400cf74a4c841963b3bc69f8fa7ca4828db53 Mon Sep 17 00:00:00 2001 From: Dileep Date: Fri, 23 Mar 2018 11:19:32 -0400 Subject: [PATCH 11/20] Clarify functionality of the send_rx_generate_mirth_client method --- includes/send_rx_functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/send_rx_functions.php b/includes/send_rx_functions.php index 3605a92..7eae7ae 100644 --- a/includes/send_rx_functions.php +++ b/includes/send_rx_functions.php @@ -181,7 +181,7 @@ function send_rx_piping($subject, $data) { /** - * Generates a mirth client. + * Generates a mirth client bound to the given endpoint. * * @param string $endpoint. * Base url of the REST API being connected to. From 6c2d68ff5c5f8699026d6d260a5e6c9965511913 Mon Sep 17 00:00:00 2001 From: Dileep Date: Fri, 23 Mar 2018 12:03:37 -0400 Subject: [PATCH 12/20] Remove uneeded send-rx-hl7-extension configuration --- config.json | 5 ----- includes/RxSender.php | 2 +- includes/send_rx_functions.php | 3 +-- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/config.json b/config.json index beefddf..a280ca2 100644 --- a/config.json +++ b/config.json @@ -120,11 +120,6 @@ "name": "End-point", "required": false, "type": "text" - }, { - "key": "send-rx-hl7-extension", - "name": "end-point extension", - "required": false, - "type": "text" }, { "key": "send-rx-hl7-json", "name": "HL7 json message", diff --git a/includes/RxSender.php b/includes/RxSender.php index 083ecd0..e1f9200 100644 --- a/includes/RxSender.php +++ b/includes/RxSender.php @@ -390,7 +390,7 @@ function send($generate_pdf = true, $log = true) { //send json of hl7 message to mirth-connect $settings = getHL7Settings($this->siteProjectId); $client = send_rx_generate_mirth_client($settings['send-rx-hl7-end-point']); - $response = $client->request('POST', $settings['send-rx-hl7-extension'], $settings['send-rx-hl7-json']); + $response = $client->request('POST', '', $settings['send-rx-hl7-json']); //log hl7 message that was sent $success = $response->getStatusCode() == 200; diff --git a/includes/send_rx_functions.php b/includes/send_rx_functions.php index 7eae7ae..5facbba 100644 --- a/includes/send_rx_functions.php +++ b/includes/send_rx_functions.php @@ -88,11 +88,10 @@ function send_rx_get_project_config($project_id, $project_type) { * @return associative array $hl7_settings. * An associative array that carries the hl7 settings with the following keys: * - send-rx-hl7-end-point: the begining of the URL of the mirth connect server. - * - send-rx-hl7-extension: extension that holds the input connector at the end-point. * - send-rx-hl7-json: json message to be sent to end-point. */ function getHL7Settings($project_id) { - $q = ExternalModules::getSettings('send_rx', $project_id, ['send-rx-hl7-end-point', 'send-rx-hl7-extension', 'send-rx-hl7-json']); + $q = ExternalModules::getSettings('send_rx', $project_id, ['send-rx-hl7-end-point', 'send-rx-hl7-json']); if (!db_num_rows($q)) { return false; } From ec94db5ec8d1c71de3c1aeb77de4fcf74213aeb4 Mon Sep 17 00:00:00 2001 From: Dileep Date: Fri, 23 Mar 2018 12:05:54 -0400 Subject: [PATCH 13/20] Update README to reflect new HL7 functionality --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 5f885bf..82798ef 100644 --- a/README.md +++ b/README.md @@ -90,3 +90,15 @@ Send Rx requires user authentication method to work, so if your REDCap does not ## Customizing PDF and email messages The presented example can be fully adapted to your needs. You may freely create your own PDF template, change the email contents configuration, and override all forms/instruments (as soon as the fields containing `send_rx_` prefix remain untouched). All form fields you update/create will available to be used as wildcards on PDF and email (e.g. `[patient][first_name]`, `[site][send_rx_name]`, `[prescriber][first_name]`, etc). + +## Optional HL7 functionality + +This module also supports sending HL7 messages. This feature is only functional +when there is an external end-point that can convert JSON into hl7 and forward +that hl7 to a healthcare system. To enable this feature go to the send_rx module +configuration menu on a Sites project. Inside the end-point field enter a url +that will accept JSON messages and convert them to HL7. Then enter in JSON message +for the module to send to this end-point in the HL7 json message field. Finally, go +to a Site record in your Sites project and enable sending HL7 messages. After this +point whenever a prescriber hits the Send button for a patient in that site the JSON +provided earlier will be sent to that end-point. From 17993f39e80114143e830f24d3320d8a3fab5ce4 Mon Sep 17 00:00:00 2001 From: Dileep Date: Wed, 28 Mar 2018 08:45:28 -0400 Subject: [PATCH 14/20] rename hl17 to hl7 within the SendRxSites project sample so that SendRx can run properly --- samples/SendRxSites.xml | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/samples/SendRxSites.xml b/samples/SendRxSites.xml index fbc0ca8..f79a3a7 100644 --- a/samples/SendRxSites.xml +++ b/samples/SendRxSites.xml @@ -43,13 +43,13 @@ - + - + - + @@ -87,9 +87,9 @@ Delivery Methods - + Delivery Methods - + Delivery Methods @@ -99,9 +99,9 @@ Delivery Methods - + Delivery Methods - + Delivery Methods @@ -111,9 +111,9 @@ Delivery Methods - + Delivery Methods - + Delivery Methods @@ -149,39 +149,39 @@ Unverified Complete - + Checked Unchecked - + Checked Unchecked - + Checked Unchecked - + Checked Unchecked - + Checked Unchecked - + Checked Unchecked - + Checked Unchecked - + Checked Unchecked - + Checked Unchecked From 942418f44e45d132ed6f40b6736d764f5ce2f1cb Mon Sep 17 00:00:00 2001 From: Dileep Date: Mon, 2 Apr 2018 11:43:22 -0400 Subject: [PATCH 15/20] Add authentication feature to send_rx's hl7 messaging --- config.json | 14 +++++++++++++- includes/RxSender.php | 4 ++-- includes/send_rx_functions.php | 6 +++--- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/config.json b/config.json index a280ca2..04b27ab 100644 --- a/config.json +++ b/config.json @@ -120,7 +120,19 @@ "name": "End-point", "required": false, "type": "text" - }, { + }, + { "key": "send-rx-hl7-username", + "name": "username", + "required": false, + "type": "text" + }, + { + "key": "send-rx-hl7-password", + "name": "password", + "required": false, + "type": "password" + }, + { "key": "send-rx-hl7-json", "name": "HL7 json message", "type": "textarea" diff --git a/includes/RxSender.php b/includes/RxSender.php index e1f9200..c847046 100644 --- a/includes/RxSender.php +++ b/includes/RxSender.php @@ -389,11 +389,11 @@ function send($generate_pdf = true, $log = true) { case 'hl7': //send json of hl7 message to mirth-connect $settings = getHL7Settings($this->siteProjectId); - $client = send_rx_generate_mirth_client($settings['send-rx-hl7-end-point']); + $client = send_rx_generate_mirth_client($settings['send-rx-hl7-end-point'], ['username' => $settings['send-rx-hl7-username'], 'password' => $settings['send-rx-hl7-password']]); $response = $client->request('POST', '', $settings['send-rx-hl7-json']); //log hl7 message that was sent - $success = $response->getStatusCode() == 200; + $success = !is_null($response) && $response->getStatusCode() == 200; $this->log($type, $success, $settings['send-rx-hl7-end-point'], 'POST', $settings['send-rx-hl7-json']); break; } diff --git a/includes/send_rx_functions.php b/includes/send_rx_functions.php index 5facbba..5e31605 100644 --- a/includes/send_rx_functions.php +++ b/includes/send_rx_functions.php @@ -91,7 +91,7 @@ function send_rx_get_project_config($project_id, $project_type) { * - send-rx-hl7-json: json message to be sent to end-point. */ function getHL7Settings($project_id) { - $q = ExternalModules::getSettings('send_rx', $project_id, ['send-rx-hl7-end-point', 'send-rx-hl7-json']); + $q = ExternalModules::getSettings('send_rx', $project_id, ['send-rx-hl7-end-point', 'send-rx-hl7-json', 'send-rx-hl7-username', 'send-rx-hl7-password']); if (!db_num_rows($q)) { return false; } @@ -188,9 +188,9 @@ function send_rx_piping($subject, $data) { * @return REDCapMithClient obj * TRUE if success, FALSE otherwise. */ -function send_rx_generate_mirth_client($endpoint) { +function send_rx_generate_mirth_client($endpoint, $credidentials) { $client_module = ExternalModules::getModuleInstance('redcap_mirth_client', 'v1.0'); - return $client_module->getClient($endpoint); + return $client_module->getClient($endpoint, $credidentials); } /** From 9b5c1a624d00133a1691a444a3dcb619610b0a45 Mon Sep 17 00:00:00 2001 From: Dileep Date: Fri, 27 Apr 2018 12:03:53 -0400 Subject: [PATCH 16/20] Remove configuration fields depricated by latest REDCapMirthClient module --- config.json | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/config.json b/config.json index 04b27ab..a9ac22b 100644 --- a/config.json +++ b/config.json @@ -114,23 +114,6 @@ "key": "send-rx-hl7-settings", "name": "HL7 settings", "type": "descriptive" - }, - { - "key": "send-rx-hl7-end-point", - "name": "End-point", - "required": false, - "type": "text" - }, - { "key": "send-rx-hl7-username", - "name": "username", - "required": false, - "type": "text" - }, - { - "key": "send-rx-hl7-password", - "name": "password", - "required": false, - "type": "password" }, { "key": "send-rx-hl7-json", From ade68868df4024772faef845120e442d6e67fbcd Mon Sep 17 00:00:00 2001 From: Dileep Date: Fri, 27 Apr 2018 12:07:29 -0400 Subject: [PATCH 17/20] Replace getHL7Settings method with getHL7JsonPayload method to better reflect HL7 configuration options --- includes/send_rx_functions.php | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/includes/send_rx_functions.php b/includes/send_rx_functions.php index 5e31605..3a28092 100644 --- a/includes/send_rx_functions.php +++ b/includes/send_rx_functions.php @@ -80,29 +80,23 @@ function send_rx_get_project_config($project_id, $project_type) { } /** - * Gets hl7 settings for that specific + * Get json payload for hl7 message * * @param int $project_id. * The project id. * - * @return associative array $hl7_settings. - * An associative array that carries the hl7 settings with the following keys: - * - send-rx-hl7-end-point: the begining of the URL of the mirth connect server. - * - send-rx-hl7-json: json message to be sent to end-point. + * @return string + * JSON formatted string that contains all of the data that must be sent */ - function getHL7Settings($project_id) { - $q = ExternalModules::getSettings('send_rx', $project_id, ['send-rx-hl7-end-point', 'send-rx-hl7-json', 'send-rx-hl7-username', 'send-rx-hl7-password']); + function getHL7JsonPayload($project_id) { + $q = ExternalModules::getSettings('send_rx', $project_id, ['send-rx-hl7-json']); if (!db_num_rows($q)) { return false; } - $hl7_settings = []; - - while($result = db_fetch_assoc($q)) { - $hl7_settings[$result['key']] = $result['value']; - } + $result = db_fetch_assoc($q); - return $hl7_settings; + return $result['value']; } From 95595241f56e0f0c8694d718689d5732759600c4 Mon Sep 17 00:00:00 2001 From: Dileep Date: Fri, 27 Apr 2018 12:10:05 -0400 Subject: [PATCH 18/20] Update send_rx_generate_mirth_client method to access new REDCapMirthClient module API --- includes/send_rx_functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/send_rx_functions.php b/includes/send_rx_functions.php index 3a28092..d3fc261 100644 --- a/includes/send_rx_functions.php +++ b/includes/send_rx_functions.php @@ -182,9 +182,9 @@ function send_rx_piping($subject, $data) { * @return REDCapMithClient obj * TRUE if success, FALSE otherwise. */ -function send_rx_generate_mirth_client($endpoint, $credidentials) { +function send_rx_generate_mirth_client($endpoint_id) { $client_module = ExternalModules::getModuleInstance('redcap_mirth_client', 'v1.0'); - return $client_module->getClient($endpoint, $credidentials); + return $client_module->getClient($endpoint_id); } /** From a65e3d011632b11892451b94835ea2b9d9a47f80 Mon Sep 17 00:00:00 2001 From: Dileep Date: Fri, 27 Apr 2018 12:11:46 -0400 Subject: [PATCH 19/20] Update hl7 case in RxSender to reflect changes send_rx_functions.php --- includes/RxSender.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/includes/RxSender.php b/includes/RxSender.php index c847046..8aff4fc 100644 --- a/includes/RxSender.php +++ b/includes/RxSender.php @@ -388,13 +388,18 @@ function send($generate_pdf = true, $log = true) { case 'hl7': //send json of hl7 message to mirth-connect - $settings = getHL7Settings($this->siteProjectId); - $client = send_rx_generate_mirth_client($settings['send-rx-hl7-end-point'], ['username' => $settings['send-rx-hl7-username'], 'password' => $settings['send-rx-hl7-password']]); - $response = $client->request('POST', '', $settings['send-rx-hl7-json']); + $payload = getHL7JsonPayload($this->siteProjectId); + $client = send_rx_generate_mirth_client('mirth_connect'); - //log hl7 message that was sent - $success = !is_null($response) && $response->getStatusCode() == 200; - $this->log($type, $success, $settings['send-rx-hl7-end-point'], 'POST', $settings['send-rx-hl7-json']); + if(is_null($client)) { + $this->log($type, false, 'mirth_connect', 'POST', $payload); + } else { + $response = $client->request('POST', '', $payload); + + //log hl7 message that was sent + $success = !is_null($response) && $response->getStatusCode() == 200; + $this->log($type, $success, 'mirth_connect', 'POST', $payload); + } break; } } From 881d29ee02cad01ab60b571516875079921df2e8 Mon Sep 17 00:00:00 2001 From: Dileep Date: Mon, 30 Apr 2018 16:36:19 -0400 Subject: [PATCH 20/20] Update README to reflect new HL7 functionality --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 82798ef..5b7cbf9 100644 --- a/README.md +++ b/README.md @@ -95,10 +95,8 @@ The presented example can be fully adapted to your needs. You may freely create This module also supports sending HL7 messages. This feature is only functional when there is an external end-point that can convert JSON into hl7 and forward -that hl7 to a healthcare system. To enable this feature go to the send_rx module -configuration menu on a Sites project. Inside the end-point field enter a url -that will accept JSON messages and convert them to HL7. Then enter in JSON message -for the module to send to this end-point in the HL7 json message field. Finally, go +that hl7 to a healthcare system and the [REDCapMirthConnectClient module](https://github.com/ctsit/redcap_mirth_client) is enabled on the patients project. To enable this feature go to the send_rx module +configuration menu on a patients project. Inside the end-point ID field enter "mirth_connect". Then configure the endpoint with the appropriate URL and authentication information. Finally, go to a Site record in your Sites project and enable sending HL7 messages. After this point whenever a prescriber hits the Send button for a patient in that site the JSON provided earlier will be sent to that end-point.