Best Practices

Performance

Below are some suggestions for improving performance when interacting with our backend API.

Reduce API Roundtrips with Bundles

Many browsers have a maximum number of simultaneous HTTP connections they will make. If one API request takes a long time to complete, it can block other requests from starting. In a hospital setting where Wifi and cellular connectivity can be slow, reducing the number of HTTP requests will speed up your application and improve the overall experience for your users.

FHIR provides a way to combine multiple operations into a single HTTP request with Bundle operations.

A Bundle supports two different interactions, depending on whether the interaction must be atomic. If all operations in your Bundle need to be committed together, you can set Bundle.type as transaction.

If the operations can happen in parallel and one failure does not mean the other operations should fail, you can set Bundle.type to batch. Using batch will parallelize the operations and reduce the number of roundtrips you need to make to the server.

Handling error codes in batches.

Batches will often succeed with lots of errors internally, remember to check the results as they come back per operation.

Use searches and be specific when requesting resources.

You should only query for the limited set of resources you need. Instead of "Get all appointments," try "Give me all appointments in this window" or "Give me all appointments for this patient."