In short:
filterBy
is empty because EventLogFilterController is returning empty arrays.
Call made:
https://infra-79.mekomsolutions.net/openmrs/ws/rest/v1/eventlog/filter/markers/c1c26908-3f10-11e4-adec-0800271c1b75/613031c6-cd03-4483-b90c-e86a15c9f032/baf7bd38-d225-11e4-9c67-080027b662ec
Response returned:
{"patient":[],"offline-concepts":[],"addressHierarchy":[],"encounter":[]}
In the demo server, the call made is the following (note that the addressUuid
is different for some reason):
https://demo.mybahmni.org/openmrs/ws/rest/v1/eventlog/filter/markers/c1c26908-3f10-11e4-adec-0800271c1b75/2c0e6cae-5d96-446e-9b94-341cce23c06e/baf7bd38-d225-11e4-9c67-080027b662ec
{"patient":["GAN"],"offline-concepts":[],"addressHierarchy":[],"encounter":["GAN"]}
(Q) Why is it returned empty in my freshly installed server, but it returns ‘GAN’ in the demo server?
Is there some metadata that I need to manually add or something?
Debugging details (optional to read):
- The
filterBy
parameter is indeed required by the EventLog resource (here):
...@RequestParam(value = "filterBy", required = true) String[] filterBy) {
###In BahmniApps (front-end):
-
filterBy
is set to marker.filters
(here).But it is an empty array.
-
skipping few steps…
- Markers are fetched by
offlineMarkerDbService#getMarkers
- But the marker for category “encouner” contains an empty array for
filters
marker.filters is empty
- Empty filters seems to be normal for the first time sync. So there is
marker.filters = offlineService.getItem("initSyncFilter");
(here) that is run at the fisrt syncing.
- the item “initSyncFilter” is set as the “categoryFilterMap” object contents
offlineService.setItem("initSyncFilter", categoryFilterMap[category]);
- And finally,
categoryFilterMap
is fetched from the server here:
var getFilterForCategoryAndLoginLocation = function (providerUuid, addressUuid, loginlocationUuid) {
var url = Bahmni.Common.Constants.eventlogFilterUrl + "/markers/" + providerUuid + "/" + addressUuid + "/" + loginlocationUuid;
return $http.get(url, {method: "GET", withCredentials: true});
};
This call returns empty filters for the encounters:
URL called:
https://infra-79.mekomsolutions.net/openmrs/ws/rest/v1/eventlog/filter/markers/c1c26908-3f10-11e4-adec-0800271c1b75/613031c6-cd03-4483-b90c-e86a15c9f032/baf7bd38-d225-11e4-9c67-080027b662ec
Result returned:
{"patient":[],"offline-concepts":[],"addressHierarchy":[],"encounter":[]}
###In Bahmni Offline Sync (back-end)
The call is handled by the Bahmni Offline Sync module (here) which then calls the IDBasedSyncStrategy.java.
So here is where the filters are set empty:
Location location = locationService.getLocationByUuid(loginLocationUuid);
Map<String, List<String>> categoryFilterMap = new HashMap();
final Collection<LocationAttribute> activeAttributes = location.getActiveAttributes();
ArrayList<String> filters = new ArrayList<String>();
for (LocationAttribute attr : activeAttributes) {
if (attr.getAttributeType().getName().equals("IdentifierSourceName")) {
String prefix = getPrefixFor(attr.getValue().toString());
if (prefix == null) {
RuntimeException exception = new RuntimeException("Please check [IdentifierSourceName] config for [" + location.getName() + "]");
logger.error(exception);
throw exception;
}
filters.add(prefix);
}
}
categoryFilterMap.put("patient", filters);
categoryFilterMap.put("encounter", filters);
categoryFilterMap.put("addressHierarchy", new ArrayList<String>());
categoryFilterMap.put("offline-concepts", new ArrayList<String>());
return categoryFilterMap;
}