Hello team,
As discussed in the previous talks here and here, we are working on extracting the bahmni-appointments UI as a separate app. Along with this, we are working on making it compatible with OpenMRS as well
The appointment module uses a lot of constants (e.g. patientSearchURL
, bahmniConfigURL
), which are hardcoded as of now. We want to enable the app to be able to dynamically load these constants since a lot of these will be different when we run it on OpenMRS(Without Bahmni).
Approach:
- Before the app loads, fetch constants as a JSON file(
XHR
request). - Store this JSON as part of
LocalStorage
. - Use the
JSON
Key:Value
instead of Constants. - We could use the JSON from
local storage
as a cache for subsequent page loads.
Question: Right now we see, constants are defined in a js
file conditionally. It is fetching localStorge.get(‘host’) and localStorage.get(‘rootDir’) and using them in constants if they are present.
We wanted to know, in which situations above two localStorage
items are present. If this is never the case, do we want to continue it keeping in this way? That would mean we won’t be able to use the JSON
directly since we cannot define JSON
values conditionally. We will need to do some preprocessing of JSON
.
Let us know your comments/suggestions.