OHSUCMP / coach

web application frontend for OHSU HTN U18 grant
2 stars 0 forks source link

REDCap integration - recordId missing #163

Closed aeyates closed 9 months ago

aeyates commented 9 months ago

After reviewing the most recent logs with additional information, I can see the error we are getting back from REDCap when trying to the the AE Survey link:

<error>The record 'null' does not exist</error>

Through some experimentation, it seems like this can happen if we ask for the record Id corresponding to the COACH Id and the record can't be found. This shouldn't be happening, but I can see that in some cases, no record in REDCap is being created for the corresponding record in COACH. A recent example is uuid 060d2c15-2d93-4f4c-9473-97550f262d43. It should have been created sometime between the creation of record 8 at 01/23/2024 3:24pm and record 9 at 01/24/2024 10:35am. Weirdly, I don't see matching activity in the COACH logs at 3:24 pm. I do see some logs an hour later.

aeyates commented 9 months ago

After tracing through a specific use case, I understand the problem. This is only manifesting when a provider logs in and tries to access a patient that has not been initiated into REDCap. In this case, COACH does the following:

  1. Creates a record in the COACH database containing the patient hash and a generated REDCap id that will be used to link a record in REDCap once the patient logs in
  2. Gives the MU/OHSU provider access to the enhanced view and finalizes the session. (A VUMC provider would still be denied access at this point, since no consent has occurred.)
  3. Forward the provider to the home page.
  4. Upon load, the home page attempts to show the text at the bottom of the page where a patient can report an Adverse Event. This link has to be retrieved from REDCap, so it fails because this patient does not exist in REDCap.

Code will be modified to only show the AE text if REDCap is enabled AND the audience is a Patient as opposed to the Care Team.