Skip to content

Data Retrieval Helpers

Zach Plata edited this page May 2, 2018 · 1 revision

What are Data Retrieval Helpers

In the Sandbox application, data retrieval is not coupled with the view, and is a separated concern in the src/retrieve-data-helpers/ directory. This allows for easier testing, and allows the data retrieval methods to be reused anywhere in the application. The data retrieval being done is mostly asynchronous calls to grab data like FHIR server metadata, FHIR resources, CDS Service definitions, service responses, etc. These functions that call the FHIR server or CDS Services will usually be returning a Promise that can be resolved/rejected once the call has returned with data or an error. This application uses the Axios library to make these external calls.

These functions are imported into the appropriate views that call them, and then resolved/caught in the view to set any state, dispatch any actions, etc.

How to use

To retrieve other data, create a file under the src/retrieve-data-helpers/ directory with the function to call the external service. See other files under that directory to follow the format, and ensure the function is exported. Then, import the function into the appropriate view/part of the application and call it where needed. Finally, add tests for the function under the tests/retrieve-data-helpers/ directory.

Clone this wiki locally