Skip to content

REMS-260 Prefetch hydration#39

Merged
kennyEung merged 6 commits intodevfrom
prefetch_hydration
Jan 26, 2023
Merged

REMS-260 Prefetch hydration#39
kennyEung merged 6 commits intodevfrom
prefetch_hydration

Conversation

@KeeyanGhoreshi
Copy link
Copy Markdown
Contributor

@KeeyanGhoreshi KeeyanGhoreshi commented Dec 10, 2022

Describe your changes

This adds some basic prefetch hydration to the REMS CRD app. The prefetch hydration checks to see which prefetch elements are missing, then uses the definition of the hook to make the requests for prefetch data itself with the EHR url present in the hook it receives.

Possible next steps might include allowing the hydration app to accept different types of hooks. For example, if we wanted to add order-select, there would need to be some logic to check the type of hook received, and based on that, send the correct prefetch structure to the hydrator.

To see this in action, you will need to use the branch of similar name on request-generator hydrate-prefetch which includes a change to remove request from the prefetch. This is because, technically, the prefetch token used in the request is not valid according to the CDS hooks specification. Prefetch tokens are only allowed to be one level deep, which means something like context.draftOrders.medicationRequest is not valid. To access this information, we would need to redefine the definition of our rems-order-sign hook to include medicationRequestId as a top-level property of the context object. Or we just need to search through the draftOrders for the information we want.

With the correct branch of the request generator, you can send a request without a prefetch by opening settings and unselecting the "include prefetch" option. This will send a hook with no prefetch element, and CRD will instead hydrate it itself, resulting in the prefetch still having the appropriate resources.

Issue ticket number and Jira link

REMS-260

Checklist before requesting a review

  • I have performed a self-review of my code
  • Ensure the target / base branch for any feature PR is set to dev not main (the only exception to this is releases from dev and hotfix branches)

Checklist for conducting a review

  • Review the code changes and make sure they all make sense and are necessary.
  • Pull the PR branch locally and test by running through workflow and making sure everything works as it is supposed to.

Workflow

Owner of the Pull Request will be responsible for merge after all requirements are met, including approval from at least one reviewer. Additional changes made after a review will dismiss any approvals and require re-review of the additional updates. Auto merging can be enabled below if additional changes are likely not to be needed. The bot will auto assign reviewers to your Pull Request for you.

Comment thread src/hooks/Prefetch/hydrator/PrefetchHydrator.ts Outdated
@kennyEung
Copy link
Copy Markdown
Contributor

The Linter is throwing a couple of warning messages that would seem useful to resolve. Though not critical.

@kennyEung kennyEung merged commit e05b29a into dev Jan 26, 2023
@kennyEung kennyEung deleted the prefetch_hydration branch January 26, 2023 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants