Giter VIP home page Giter VIP logo

send_rx's Introduction

Send Rx

Send Rx is a REDCap module that allows users to automatically generate prescriptions on PDF format and send them to the pharmacies.

Prerequisites

Manual Installation

  • Clone this repo into to an <redcap-root>/modules/send_rx_v<version_number>.
  • Go to Control Center > External Modules and enable Send Rx.
  • Automated installation of Composer dependencies (required) send_rx assumes composer dependencies have been installers in <redcap-root>/vendor. The redcap_deployment packaging tools do this by default. We recommend you use them--at least once--to assure that composer-installed libraries are installed in the correct location.
  • Manual installation of Composer dependencies (optional)
    • In a terminal, go to your REDCap root directory
    • Download Composer
    • Run php composer.phar install

Configuration

The steps below will walk you through a study research use case.

Step 1: Making sure that user authentication is enabled

Send Rx requires user authentication method to work, so if your REDCap does not have it, you may need to follow the steps below:

  1. Go to Control Manager > Add Users (Table-based Only)
  2. Add a new user that will be the new admin account (since site_admin will become deprecated)
  3. Go to Control Manager > Administrators & Acct Managers and add the new user to the administrators list
  4. Go to Control Manager > Security & Authentication, select an authentication method of your choice (e.g. Table-based), and save
  5. Check your email inbox and look for a "REDCap access granted" email
  6. Open the email contents, and click on "Set your new REDCap password" link
  7. Set your password
  8. Go to Control Manager > Administrators & Acct Managers and remove deprecated site_admin from administrators list

Step 2: Creating User Profiles project

  1. Access + New Project page, then import samples/UserProfiles.xml file.
  2. If User Profile module is not enabled yet, you may do that by accessing Control Center > External Modules.
  3. Then on Control Center > External Modules, configure the module as follows:
  • Project: User Profiles (or any name you might have given to the project)
  • Username field: send_rx_user_id

Step 3: Creating Sites Project

  1. Make sure you are logged in as the admin user created on step 1 (not site_admin)
  2. Access + New Project page, then import samples/SendRxSites.xml file.
  3. Go to External Modules section and enable User Profile module for this project. No configuration at the project level is necessary.
  4. Go to External Modules section and enable Send Rx module for this project
  5. Then on External Modules page, click on Send Rx Configure button and set fields as follows:
  • Type: Site
  • Target Project: (Leave it blank for now, you are going to set it on step 4.7)
  • PDF Template Name: (upload SamplePDFTemplate.html) file
  • PDF Template Variables:
    • Key: "study_irb", Value: "2017-1234"
    • Key: "study_name", Value: "Sample Study"
  • Message subject: "Test prescription"
  • Message body: "The prescription file is available at: [patient][send_rx_pdf]"

Step 4: Creating Patients Project

  1. Make sure you are logged in as the admin user created on step 1 (not site_admin)
  2. Access + New Project page, then import samples/SendRxPatients.xml file.
  3. Create a data access group named "ESU". Note its DAG ID.
  4. Go to External Modules section and enable Send Rx module for this project
  5. Then on External Modules page, click on Configure Button and set fields as follows:
  • Type: Patient
  • Target Project: the Sites project defined on section 3
  1. Go to User Rights section and create two roles: prescriber and study_coordinator
  2. Add a user to the study_coordinator role and assign them to the ESU DAG.
  3. Switch to Sites project, then access External Modules and click on Send Rx Configure button
  4. Set Target Project as the project you just imported.

Sending your First Test Prescription

Step 1: Create a Site/Pharmacy

  1. On site project, go to Add / Edit records and then click on Add new record.
  2. On Site Information form, set the site name to ESU, set the DAG ID to that one for ESU on the Patients project, set Email as delivery type, set the email address you want to use in your test, and finally save - making sure sure your form is set as Complete.
  3. On Site Staff step, select Create a new user account from scratch, fill out user information, make sure your form is set as Complete, then click on Save & Go To Next Instance
  4. Repeat the step above a few times - making sure to add at least one prescriber and one study coordinator - then click on Save & Exit
  5. Go to Record Status Dashboard where you should be able to see two buttons: Rebuild staff permissions and Revoke staff permissions (if both buttons are disabled, make sure all forms previously filled are set as Complete, i.e. they appear as green bullets)
  6. Click on Rebuild staff permissions to grant permissions to your staff
  7. You may need to navigate to the Patients project and assign your coordinator and prescriber user(s) to the proper DAG
  8. Make sure that the "Data Access Group (DAG) ID" of the Site project's "Site Information" form contains the Group ID number of the prescriber user in the Patients Project's DAG page.

Step 2: Create a Prescription and Send it

  1. Log in as prescriber
  2. On patient project, go to Add / Edit records and then click on Add new record
  3. Fill out all forms until the last one - Review & Send Rx - then click on Send and Stay
  4. At Messages History block you should now see the notification contents you just sent
  5. Check your email inbox

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).

send_rx's People

Contributors

bember avatar chemikyle avatar marlycormar avatar pbchase avatar prasadlan avatar stewhat avatar suryaprasanna avatar tbembersimeao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

send_rx's Issues

send_rx crashes when writing generating pdf file in redcap version 8.5.0

Send_rx was working fine before I upgraded to REDCap version 8.5.0. After I upgraded, I was going through the normal workflow of creating a new patient and filling out the associated info, demographics, and prescription forms. When I selected "save and go to next form", the "Review & Send Rx" page crashed with a php Fatal error:

image

After some experimenting the issues seems to be in lines 168-170 in send_rx_functions.php. REDCap seems to crash when you use the Mpdf composer dependency. I had a similar issue with redcap_mirth_connect_client when upgrading to REDCap version 8.5.0. Please verify if this is an issue for you as well.

Rebuild permissions makes changes outside of its scope

Rebuild permissions makes changes outside of its scope. It removes people who are not in a site from roles it knows nothing about. This makes it hard to assign roles to people who are in some role that has nothing to do with a site. E.g. in the Warrior project we have UF IDS Pharmacists, CEC Staff, DSMB Staff, and DCC staff that need to be in roles to adjust permissions and need to see across all DAGs. We need permButtons functions to never fiddle with these roles.

Could the permButtons functions be configured to only delete users the roles listed as the codes in the send_rx_user_role field?

Data entry trigger listener

An endpoint that listens to REDCap data entry trigger. This is triggered at every data entry creation or change.

send_rx generates the PDF repeatedly

send_rx generates the PDF of the prescription each time the Review & Send Prescription form is loaded. A review of the git history shows the line that acknowledges the PDF was generated was removed in commit 3a6eb38.

I have a fix for this issue and will provide a fork for review.

send_rx release 1.7.2 crashes in redcap8.11.2 with php7.2

Error Log

REDCap crashed due to an unexpected PHP fatal error!
Error message: Uncaught ArgumentCountError: Too few arguments to function SendRx\ExternalModule\ExternalModule::hook_every_page_before_render(), 0 passed and exactly 1 expected in /var/www.backup/warrior_stage/warrior_stage- 20190130T1409/modules/send_rx_v1.7.1/ExternalModule.php:281 Stack trace: 0 [internal function]: SendRx\ExternalModule\ExternalModule->hook_every_page_before_render() 1 /var/www.backup/warrior_stage/warrior_stage- 20190130T1409/redcap_v8.11.2/ExternalModules/classes/ExternalModules.php(1351): call_user_func_array(Array, Array) 2 /var/www.backup/warrior_stage/warrior_stage- 20190130T1409/redcap_v8.11.2/ExternalModules/classes/ExternalModules.php(1439): ExternalModules\ExternalModules::startHook('send_rx', 'v1.7.1', Array) 3 /var/www.backup/warrior_stage/warrior_stage-20190130T1409/redcap_v8.11.2/Classes/Hooks.php(37): ExternalModules\ExternalModules::callHook('every_page_befo...', Array) 4 /var/www.backup/warrior_stage/warrior_stage-20190130T1409/redcap_v8.11.2/Classes/System.php(512): Hooks::call('redc
File: /var/www.backup/warrior_stage/warrior_stage- 20190130T1409/modules/send_rx_v1.7.1/ExternalModule.php
Line: 281
The "send_rx" external module was automatically disabled in order to allow REDCap to function properly. The REDCap administrator has been notified. Please save a copy of the above error and fix it before re-enabling the module.

Difficulties accessing Rx PDFs

Deb Landers reported

Do you know what causes this? I resaved the Prescription form and the Review & Send prescription form and that didn’t resolve the issue.

image

I think this is caused by revisions to the RX after the link to the RX is sent. I think we can (and should) fix this by sending the URL to the page with the PDFs instead of the URL to the PDF.

send_rx does not log actions in the redcap event log

send_rx does not log actions in the redcap event log. It logs neither success nor failure. It would be great if it were chattier so we have a record of when it worked and when it tried and failed. Review the ctsit/save_survey_pdf_to_field#5

Consider creating log entries for these events:

  • Roles populated
  • Roles failed to populate
  • RX upload to file upload field
  • RX upload failed

At the moment we do log RX send failures and successes. That is good, but it might be good to write those to the event log as well.

uppercase letters in the user profile username field prevent rx sending

Uppercase letters in the user profile username field disable the "Send Rx" button on the Review & Send Prescription form. While the user profile allows uppercase letters in its username field, the REDCap username (or perhaps the Gatorlink ID) is all lowercase. A string matching test is failing to see these IDs as the same and disabling the "Send Rx" button.

Add support for Shibboleth-table auth

The module currently only recognizes table and shib:

switch ($auth_meth) {

In REDCap v10.5.1, when using shibboleth_table globally, the reset password link generated no longer works unless the project is set to use table auth (presumably forcing shib-only would also work for that pipeline). The new users do appear in the redcap_user_information table.

Send_RX generates DAGs that do not match the DAGS in the target project

When creating a new site, Send_RX generates a new DAG entry for the new site. If the patients project has pre-created DAGs, the DAG ID recorded in the site entry of the sites projects will not match any of the pre-created DAGs. These IDs must match for send RX to work correctly. Send_RX either needs to populate the DAG ID from the DAGs already associated with the patient project, or allow the redcap staffer to explicitly set the DAG ID. As the SEND_RX is hiding the DAG ID,it is impossible to change it or even know it is wrong.

Review the target audience of the README.md file and other small changes.

The README.md file should be written with a redcap user in mind (rather than a developer). As such, please consider the following changes:

  • Add a section that specifically targets the developer. In that section, include the download/installation of composer.
  • Add to documentation that UserProfile module should be activated either globally or in the three projects used to setup send_rx.
  • Change Table-based authentication for any type of authentication.
  • It is no longer needed to enter the project ID, as it is a dropdown menu now. Update documentation to reflect this changes.
  • Please look out for any other needed changes.

PDFs are not generated in REDCap 8.2.2

Send Rx 1.6.1 and 1.6.2 both fail to generate a PDF during Prescription save under REDCap 8.8.2. This might be a good time to add calls to redcap log_event. It could provide a valuable trail of everything that did work when something goes wrong.

Need to be able to create new roles on the fly, bug in creating new users in WARRIOR prod

I created a new Role (CEC Committee) in the Sites project but it did not carry over to the WARRIOR project. I had to make the Role manually and assign users to it.

It also did not create the user accounts for new users in the WARRIOR project, see:
bchaitman
lisaalderson
scruzflores

They were added to User Profile and Study Sites (Site=UF) project but I never got prompted to rebuild permissions and it did not create a user account in WARRIOR prod for them, although they did come up in the Select an Existing User dropdown menu.

Add a link to the subject's record_home page in the pharmacist's email alert

The email delivered by send_rx only provides a link to the pdf of the prescription. Should there be ancillary information on a REDCap form that is useful to the pharmacist, accessing those forms is tedious. send_rx should provide an additional link that makes this access easier. That link should route the pharmacist to subject's record home page. The forms visible to the pharmacist via this link is configured solely by REDCap's authorization system. i.e., authorization is not in the scope of this change.

The text surrounding this link should be something like this:

There is a new prescription ready to be filled for a study participant on the WARRIOR project. The file is accessible at: https://redcap.example.org/redcap_v8.0.3/DataEntry/file_download.php?pid=13&record=12...

Additional data about this research participant is accessible at https://redcap.example.org/redcap_v8.0.3/DataEntry/record_home.php?pid=13&id=1-2&arm=1

RXSender class

Implement a class that wraps prescription send operation complexity.

Mpdf does not install properly in Docker

Docker needs to be forced to install composer dependencies properly, assuming you are using 10.5.1. Here is a hacky guide to correcting the issue for want of the proper way to fix this.

Navigate to your docker instance's www/redcap_10.5.1 folder, update the require section to add the mpdf library:

    "require": {
        "mpdf/mpdf": "^7.0.1"
        },

"ssh" into your redcap docker container: docker exec -it rc1051_web bash and follow install composer as in the referenced guide, altering the install-dirto be less annoying, here are the commands as of this comment, note that the sha384 check will likely change:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php --install-dir=/usr/bin
php -r "unlink('composer-setup.php');"

While still in your "ssh" session, navigate to /var/www/html/redcap_v10.5.1 and run composer.phar update and wait.

send_rx_pdf_is_updated is getting set to 0 when no RX fields are being modified

send_rx_pdf_is_updated is getting set to zero when no fields on the Prescription form are being modified. Reviewing hook_save_record in ExternalModule.php, it appears that there are no qualifiers around this code block:

// New PDF needs to be generated as changes are made to form after PDF is created.
// Reset pdf_is_updated flag to generate new PDF.
$field_name = 'send_rx_pdf_is_updated';
send_rx_save_record_field($project_id, $event_id, $record, $field_name, '0');

See

// New PDF needs to be generated as changes are made to form after PDF is created.
to see that code in context.

My suspicion is that this code is firing when other forms are updating data. This resets the send_rx_pdf_is_updated to zero. Subsequent access to the Review and Send RX form will cause a PDF regeneration even though no data was updated on the Prescription form. If this is right, the above code block would need to be wrapped in a test to verify that the current instrument is the instrument holds a field we know is on the Prescription form. send_rx_prescriber_email would be a good candidate.

This code might work in place of the above at line 759:

        // Checking if we are on Prescription form step.
        if ($Proj->metadata['send_rx_prescriber_email']['form_name'] == $instrument) {
            // New PDF needs to be generated as changes are made to form after PDF is created.
            // Reset pdf_is_updated flag to generate new PDF.
            $field_name = 'send_rx_pdf_is_updated';
            send_rx_save_record_field($project_id, $event_id, $record, $field_name, '0');
        }

RX send process has too many buttons

The RX page should present very few options to reduce confusion. Present only two buttons: "Send" and "Close". Make them both green. Remove other "Send &.." and "Save & ..." buttons.

As we are taking away the "Complete?" field, we should automatically mark the form as complete if the RX is successfully sent.

The prescription PDF only contains the edoc ID when using a project-level PDF template

The prescription PDF returns a document which only contains a number rather than the template with the proper information filled in; the number in the PDF appears to be the edoc_id of the PDF template defined at the project level. During a prior investigation I suspected a change may need to be made around here:

protected function setSiteData($data) {
if ($edoc_id = $data['send_rx_pdf_template']) {
$data['send_rx_pdf_template'] = send_rx_get_edoc_file_contents($edoc_id);
}
$this->siteData = $data;
}

Defining an overriding template in a record in the Sites project circumvents this, but it is a tedious manual process.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.