Skip to content
This repository was archived by the owner on Oct 1, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0553033
Add mirth connect client configuration options to config.json
Mar 14, 2018
bcf4c4c
Add method to get hl7 settings in send_rx_functions.php
Mar 19, 2018
196d577
Restructure hl7 settings in config to json to avoid json-encoding set…
Mar 21, 2018
66149d0
Add send_rx_generate_mirth_client method to send_rx_functions.php
Mar 21, 2018
dc584fb
Impliment hl7 case inside RxSender's send method
Mar 21, 2018
1b7ec53
Integrate HL7 case with logging system
Mar 23, 2018
e4d591d
Hide all hl7 configuration settings when on a patient project
Mar 23, 2018
ed61dfa
Generalize css field matching
Mar 23, 2018
cbdfae6
Rename send-rx-hl7-channel-ID to send-rx-hl7-extension
Mar 23, 2018
bb2006c
Changle send-rx-hl7-extension configuration label to 'end-point exten…
Mar 23, 2018
5f5400c
Clarify functionality of the send_rx_generate_mirth_client method
Mar 23, 2018
6c2d68f
Remove uneeded send-rx-hl7-extension configuration
Mar 23, 2018
ec94db5
Update README to reflect new HL7 functionality
Mar 23, 2018
17993f3
rename hl17 to hl7 within the SendRxSites project sample so that Send…
Mar 28, 2018
942418f
Add authentication feature to send_rx's hl7 messaging
Apr 2, 2018
9b5c1a6
Remove configuration fields depricated by latest REDCapMirthClient mo…
Apr 27, 2018
ade6886
Replace getHL7Settings method with getHL7JsonPayload method to better…
Apr 27, 2018
9559524
Update send_rx_generate_mirth_client method to access new REDCapMirth…
Apr 27, 2018
a65e3d0
Update hl7 case in RxSender to reflect changes send_rx_functions.php
Apr 27, 2018
881d29e
Update README to reflect new HL7 functionality
Apr 30, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,13 @@ 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 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.
10 changes: 10 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@
"type": "rich-text"
}
]
},
{
"key": "send-rx-hl7-settings",
"name": "HL7 settings",
"type": "descriptive"
},
{
"key": "send-rx-hl7-json",
"name": "HL7 json message",
"type": "textarea"
}
],
"enable-every-page-hooks-on-system-pages": true,
Expand Down
11 changes: 3 additions & 8 deletions css/config.css
Original file line number Diff line number Diff line change
@@ -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-schema"] {
.send-rx [field^="send-rx-pdf-template"],
.send-rx [field^="send-rx-message"],
.send-rx [field^="send-rx-hl7"] {
display: none;
}
14 changes: 13 additions & 1 deletion includes/RxSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,19 @@ function send($generate_pdf = true, $log = true) {
break;

case 'hl7':
// TODO: handle HL7 messages.
//send json of hl7 message to mirth-connect
$payload = getHL7JsonPayload($this->siteProjectId);
$client = send_rx_generate_mirth_client('mirth_connect');

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;
}
}
Expand Down
36 changes: 36 additions & 0 deletions includes/send_rx_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,27 @@ function send_rx_get_project_config($project_id, $project_type) {
return $config;
}

/**
* Get json payload for hl7 message
*
* @param int $project_id.
* The project id.
*
* @return string
* JSON formatted string that contains all of the data that must be sent
*/
function getHL7JsonPayload($project_id) {
$q = ExternalModules::getSettings('send_rx', $project_id, ['send-rx-hl7-json']);
if (!db_num_rows($q)) {
return false;
}

$result = db_fetch_assoc($q);

return $result['value'];
}


/**
* Gets site ID from DAG.
*
Expand Down Expand Up @@ -151,6 +172,21 @@ function send_rx_piping($subject, $data) {
return $subject;
}


/**
* Generates a mirth client bound to the given endpoint.
*
* @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_id) {
$client_module = ExternalModules::getModuleInstance('redcap_mirth_client', 'v1.0');
return $client_module->getClient($endpoint_id);
}

/**
* Generates a PDF file.
*
Expand Down
36 changes: 18 additions & 18 deletions samples/SendRxSites.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
</ItemGroupDef>
<ItemGroupDef OID="site_information.send_rx_delivery_methods___email" Name="" Repeating="No">
<ItemRef ItemOID="send_rx_delivery_methods___email" Mandatory="Yes" redcap:Variable="send_rx_delivery_methods"/>
<ItemRef ItemOID="send_rx_delivery_methods___h17" Mandatory="Yes" redcap:Variable="send_rx_delivery_methods"/>
<ItemRef ItemOID="send_rx_delivery_methods___hl7" Mandatory="Yes" redcap:Variable="send_rx_delivery_methods"/>
<ItemRef ItemOID="send_rx_delivery_methods___message_gateway" Mandatory="Yes" redcap:Variable="send_rx_delivery_methods"/>
<ItemRef ItemOID="send_rx_delivery_methods___email" Mandatory="Yes" redcap:Variable="send_rx_delivery_methods"/>
<ItemRef ItemOID="send_rx_delivery_methods___h17" Mandatory="Yes" redcap:Variable="send_rx_delivery_methods"/>
<ItemRef ItemOID="send_rx_delivery_methods___hl7" Mandatory="Yes" redcap:Variable="send_rx_delivery_methods"/>
<ItemRef ItemOID="send_rx_delivery_methods___message_gateway" Mandatory="Yes" redcap:Variable="send_rx_delivery_methods"/>
<ItemRef ItemOID="send_rx_delivery_methods___email" Mandatory="Yes" redcap:Variable="send_rx_delivery_methods"/>
<ItemRef ItemOID="send_rx_delivery_methods___h17" Mandatory="Yes" redcap:Variable="send_rx_delivery_methods"/>
<ItemRef ItemOID="send_rx_delivery_methods___hl7" Mandatory="Yes" redcap:Variable="send_rx_delivery_methods"/>
<ItemRef ItemOID="send_rx_delivery_methods___message_gateway" Mandatory="Yes" redcap:Variable="send_rx_delivery_methods"/>
<ItemRef ItemOID="send_rx_email_recipients" Mandatory="Yes" redcap:Variable="send_rx_email_recipients"/>
<ItemRef ItemOID="send_rx_email_subject" Mandatory="No" redcap:Variable="send_rx_email_subject"/>
Expand Down Expand Up @@ -87,9 +87,9 @@
<Question><TranslatedText>Delivery Methods</TranslatedText></Question>
<CodeListRef CodeListOID="send_rx_delivery_methods___email.choices"/>
</ItemDef>
<ItemDef OID="send_rx_delivery_methods___h17" Name="send_rx_delivery_methods___h17" DataType="boolean" Length="1" redcap:Variable="send_rx_delivery_methods" redcap:FieldType="checkbox" redcap:FieldNote="By what means will prescriptions be delivered to this site&#039;s pharmacy?" redcap:RequiredField="y" redcap:FieldAnnotation="@DEFAULT=&#039;email&#039;">
<ItemDef OID="send_rx_delivery_methods___hl7" Name="send_rx_delivery_methods___hl7" DataType="boolean" Length="1" redcap:Variable="send_rx_delivery_methods" redcap:FieldType="checkbox" redcap:FieldNote="By what means will prescriptions be delivered to this site&#039;s pharmacy?" redcap:RequiredField="y" redcap:FieldAnnotation="@DEFAULT=&#039;email&#039;">
<Question><TranslatedText>Delivery Methods</TranslatedText></Question>
<CodeListRef CodeListOID="send_rx_delivery_methods___h17.choices"/>
<CodeListRef CodeListOID="send_rx_delivery_methods___hl7.choices"/>
</ItemDef>
<ItemDef OID="send_rx_delivery_methods___message_gateway" Name="send_rx_delivery_methods___message_gateway" DataType="boolean" Length="1" redcap:Variable="send_rx_delivery_methods" redcap:FieldType="checkbox" redcap:FieldNote="By what means will prescriptions be delivered to this site&#039;s pharmacy?" redcap:RequiredField="y" redcap:FieldAnnotation="@DEFAULT=&#039;email&#039;">
<Question><TranslatedText>Delivery Methods</TranslatedText></Question>
Expand All @@ -99,9 +99,9 @@
<Question><TranslatedText>Delivery Methods</TranslatedText></Question>
<CodeListRef CodeListOID="send_rx_delivery_methods___email.choices"/>
</ItemDef>
<ItemDef OID="send_rx_delivery_methods___h17" Name="send_rx_delivery_methods___h17" DataType="boolean" Length="1" redcap:Variable="send_rx_delivery_methods" redcap:FieldType="checkbox" redcap:FieldNote="By what means will prescriptions be delivered to this site&#039;s pharmacy?" redcap:RequiredField="y" redcap:FieldAnnotation="@DEFAULT=&#039;email&#039;">
<ItemDef OID="send_rx_delivery_methods___hl7" Name="send_rx_delivery_methods___hl7" DataType="boolean" Length="1" redcap:Variable="send_rx_delivery_methods" redcap:FieldType="checkbox" redcap:FieldNote="By what means will prescriptions be delivered to this site&#039;s pharmacy?" redcap:RequiredField="y" redcap:FieldAnnotation="@DEFAULT=&#039;email&#039;">
<Question><TranslatedText>Delivery Methods</TranslatedText></Question>
<CodeListRef CodeListOID="send_rx_delivery_methods___h17.choices"/>
<CodeListRef CodeListOID="send_rx_delivery_methods___hl7.choices"/>
</ItemDef>
<ItemDef OID="send_rx_delivery_methods___message_gateway" Name="send_rx_delivery_methods___message_gateway" DataType="boolean" Length="1" redcap:Variable="send_rx_delivery_methods" redcap:FieldType="checkbox" redcap:FieldNote="By what means will prescriptions be delivered to this site&#039;s pharmacy?" redcap:RequiredField="y" redcap:FieldAnnotation="@DEFAULT=&#039;email&#039;">
<Question><TranslatedText>Delivery Methods</TranslatedText></Question>
Expand All @@ -111,9 +111,9 @@
<Question><TranslatedText>Delivery Methods</TranslatedText></Question>
<CodeListRef CodeListOID="send_rx_delivery_methods___email.choices"/>
</ItemDef>
<ItemDef OID="send_rx_delivery_methods___h17" Name="send_rx_delivery_methods___h17" DataType="boolean" Length="1" redcap:Variable="send_rx_delivery_methods" redcap:FieldType="checkbox" redcap:FieldNote="By what means will prescriptions be delivered to this site&#039;s pharmacy?" redcap:RequiredField="y" redcap:FieldAnnotation="@DEFAULT=&#039;email&#039;">
<ItemDef OID="send_rx_delivery_methods___hl7" Name="send_rx_delivery_methods___hl7" DataType="boolean" Length="1" redcap:Variable="send_rx_delivery_methods" redcap:FieldType="checkbox" redcap:FieldNote="By what means will prescriptions be delivered to this site&#039;s pharmacy?" redcap:RequiredField="y" redcap:FieldAnnotation="@DEFAULT=&#039;email&#039;">
<Question><TranslatedText>Delivery Methods</TranslatedText></Question>
<CodeListRef CodeListOID="send_rx_delivery_methods___h17.choices"/>
<CodeListRef CodeListOID="send_rx_delivery_methods___hl7.choices"/>
</ItemDef>
<ItemDef OID="send_rx_delivery_methods___message_gateway" Name="send_rx_delivery_methods___message_gateway" DataType="boolean" Length="1" redcap:Variable="send_rx_delivery_methods" redcap:FieldType="checkbox" redcap:FieldNote="By what means will prescriptions be delivered to this site&#039;s pharmacy?" redcap:RequiredField="y" redcap:FieldAnnotation="@DEFAULT=&#039;email&#039;">
<Question><TranslatedText>Delivery Methods</TranslatedText></Question>
Expand Down Expand Up @@ -149,39 +149,39 @@
<CodeListItem CodedValue="1"><Decode><TranslatedText>Unverified</TranslatedText></Decode></CodeListItem>
<CodeListItem CodedValue="2"><Decode><TranslatedText>Complete</TranslatedText></Decode></CodeListItem>
</CodeList>
<CodeList OID="send_rx_delivery_methods___email.choices" Name="send_rx_delivery_methods___email" DataType="boolean" redcap:Variable="send_rx_delivery_methods" redcap:CheckboxChoices="email, Email|h17, H17|message_gateway, Message Gateway">
<CodeList OID="send_rx_delivery_methods___email.choices" Name="send_rx_delivery_methods___email" DataType="boolean" redcap:Variable="send_rx_delivery_methods" redcap:CheckboxChoices="email, Email|hl7, hl7|message_gateway, Message Gateway">
<CodeListItem CodedValue="1"><Decode><TranslatedText>Checked</TranslatedText></Decode></CodeListItem>
<CodeListItem CodedValue="0"><Decode><TranslatedText>Unchecked</TranslatedText></Decode></CodeListItem>
</CodeList>
<CodeList OID="send_rx_delivery_methods___h17.choices" Name="send_rx_delivery_methods___h17" DataType="boolean" redcap:Variable="send_rx_delivery_methods" redcap:CheckboxChoices="email, Email|h17, H17|message_gateway, Message Gateway">
<CodeList OID="send_rx_delivery_methods___hl7.choices" Name="send_rx_delivery_methods___hl7" DataType="boolean" redcap:Variable="send_rx_delivery_methods" redcap:CheckboxChoices="email, Email|hl7, hl7|message_gateway, Message Gateway">
<CodeListItem CodedValue="1"><Decode><TranslatedText>Checked</TranslatedText></Decode></CodeListItem>
<CodeListItem CodedValue="0"><Decode><TranslatedText>Unchecked</TranslatedText></Decode></CodeListItem>
</CodeList>
<CodeList OID="send_rx_delivery_methods___message_gateway.choices" Name="send_rx_delivery_methods___message_gateway" DataType="boolean" redcap:Variable="send_rx_delivery_methods" redcap:CheckboxChoices="email, Email|h17, H17|message_gateway, Message Gateway">
<CodeList OID="send_rx_delivery_methods___message_gateway.choices" Name="send_rx_delivery_methods___message_gateway" DataType="boolean" redcap:Variable="send_rx_delivery_methods" redcap:CheckboxChoices="email, Email|hl7, hl7|message_gateway, Message Gateway">
<CodeListItem CodedValue="1"><Decode><TranslatedText>Checked</TranslatedText></Decode></CodeListItem>
<CodeListItem CodedValue="0"><Decode><TranslatedText>Unchecked</TranslatedText></Decode></CodeListItem>
</CodeList>
<CodeList OID="send_rx_delivery_methods___email.choices" Name="send_rx_delivery_methods___email" DataType="boolean" redcap:Variable="send_rx_delivery_methods" redcap:CheckboxChoices="email, Email|h17, H17|message_gateway, Message Gateway">
<CodeList OID="send_rx_delivery_methods___email.choices" Name="send_rx_delivery_methods___email" DataType="boolean" redcap:Variable="send_rx_delivery_methods" redcap:CheckboxChoices="email, Email|hl7, hl7|message_gateway, Message Gateway">
<CodeListItem CodedValue="1"><Decode><TranslatedText>Checked</TranslatedText></Decode></CodeListItem>
<CodeListItem CodedValue="0"><Decode><TranslatedText>Unchecked</TranslatedText></Decode></CodeListItem>
</CodeList>
<CodeList OID="send_rx_delivery_methods___h17.choices" Name="send_rx_delivery_methods___h17" DataType="boolean" redcap:Variable="send_rx_delivery_methods" redcap:CheckboxChoices="email, Email|h17, H17|message_gateway, Message Gateway">
<CodeList OID="send_rx_delivery_methods___hl7.choices" Name="send_rx_delivery_methods___hl7" DataType="boolean" redcap:Variable="send_rx_delivery_methods" redcap:CheckboxChoices="email, Email|hl7, hl7|message_gateway, Message Gateway">
<CodeListItem CodedValue="1"><Decode><TranslatedText>Checked</TranslatedText></Decode></CodeListItem>
<CodeListItem CodedValue="0"><Decode><TranslatedText>Unchecked</TranslatedText></Decode></CodeListItem>
</CodeList>
<CodeList OID="send_rx_delivery_methods___message_gateway.choices" Name="send_rx_delivery_methods___message_gateway" DataType="boolean" redcap:Variable="send_rx_delivery_methods" redcap:CheckboxChoices="email, Email|h17, H17|message_gateway, Message Gateway">
<CodeList OID="send_rx_delivery_methods___message_gateway.choices" Name="send_rx_delivery_methods___message_gateway" DataType="boolean" redcap:Variable="send_rx_delivery_methods" redcap:CheckboxChoices="email, Email|hl7, hl7|message_gateway, Message Gateway">
<CodeListItem CodedValue="1"><Decode><TranslatedText>Checked</TranslatedText></Decode></CodeListItem>
<CodeListItem CodedValue="0"><Decode><TranslatedText>Unchecked</TranslatedText></Decode></CodeListItem>
</CodeList>
<CodeList OID="send_rx_delivery_methods___email.choices" Name="send_rx_delivery_methods___email" DataType="boolean" redcap:Variable="send_rx_delivery_methods" redcap:CheckboxChoices="email, Email|h17, H17|message_gateway, Message Gateway">
<CodeList OID="send_rx_delivery_methods___email.choices" Name="send_rx_delivery_methods___email" DataType="boolean" redcap:Variable="send_rx_delivery_methods" redcap:CheckboxChoices="email, Email|hl7, hl7|message_gateway, Message Gateway">
<CodeListItem CodedValue="1"><Decode><TranslatedText>Checked</TranslatedText></Decode></CodeListItem>
<CodeListItem CodedValue="0"><Decode><TranslatedText>Unchecked</TranslatedText></Decode></CodeListItem>
</CodeList>
<CodeList OID="send_rx_delivery_methods___h17.choices" Name="send_rx_delivery_methods___h17" DataType="boolean" redcap:Variable="send_rx_delivery_methods" redcap:CheckboxChoices="email, Email|h17, H17|message_gateway, Message Gateway">
<CodeList OID="send_rx_delivery_methods___hl7.choices" Name="send_rx_delivery_methods___hl7" DataType="boolean" redcap:Variable="send_rx_delivery_methods" redcap:CheckboxChoices="email, Email|hl7, hl7|message_gateway, Message Gateway">
<CodeListItem CodedValue="1"><Decode><TranslatedText>Checked</TranslatedText></Decode></CodeListItem>
<CodeListItem CodedValue="0"><Decode><TranslatedText>Unchecked</TranslatedText></Decode></CodeListItem>
</CodeList>
<CodeList OID="send_rx_delivery_methods___message_gateway.choices" Name="send_rx_delivery_methods___message_gateway" DataType="boolean" redcap:Variable="send_rx_delivery_methods" redcap:CheckboxChoices="email, Email|h17, H17|message_gateway, Message Gateway">
<CodeList OID="send_rx_delivery_methods___message_gateway.choices" Name="send_rx_delivery_methods___message_gateway" DataType="boolean" redcap:Variable="send_rx_delivery_methods" redcap:CheckboxChoices="email, Email|hl7, hl7|message_gateway, Message Gateway">
<CodeListItem CodedValue="1"><Decode><TranslatedText>Checked</TranslatedText></Decode></CodeListItem>
<CodeListItem CodedValue="0"><Decode><TranslatedText>Unchecked</TranslatedText></Decode></CodeListItem>
</CodeList>
Expand Down