Relationships widget

Thanks @mogoodrich and @raff for the details on the relationships widget.

It was very easy to add the relationship widget to our custom PIH clinical dashboard. But when I tried to add the same widget with the same exact config to the registrationSummary dashboard the openmrsRest URL is incorrectly set. The widget displays but contains no info because the ws address is incorrect:

http://localhost:8080/ws/rest/v1/relationship?limit=6&person=eeac5a86-47e3-46c8-87a9-4998d02538be&v=custom:(uuid,personA:(uuid,person:(display),birthdate),personB:(uuid,person:(display),birthdate),relationshipType:(uuid,aIsToB,bIsToA))

It is missing the openmrs in the stem before the /ws/rest/v1/

Does anyone know how the web service URL is set?

Thanks, Cosmin

The issue is that the registrationSummary dashboard doesn’t come from coreapps, which is assumed when determining the rest url at https://github.com/openmrs/openmrs-module-coreapps/blob/master/omod/src/main/webapp/resources/scripts/fragments/dashboardwidgets/relationships/relationships.controller.js#L13

Basically we need to somehow know the base path of OpenMRS. I think the most correct solution would be to use https://www.w3schools.com/tags/tag_base.asp, which would be set on a dashoard page by the server to e.g. “https://localhost:8080/openmrs” and read it from the DOM in openmrsRest.

Another option is to pass baseAppPath as part of the widget config in your case it would be “/registrationapp”.

Thanks @raff! Your suggestion with config.baseAppPath worked. Are you OK with this small change to the relationships controller to accommodate the config.baseAppPath parameter?

function activate() {
    if ( ctrl.config.baseAppPath ) {
        openmrsRest.setBaseAppPath(ctrl.config.baseAppPath);
    } else {
        openmrsRest.setBaseAppPath("/coreapps");
    }

    fetchRelationships();
}

Yes, that’s ok, however the more general solution with the base tag would be better in my opinion. However, it’s slightly more work and testing so I understand, if you cannot go that path.

Thank you @raff for your help and guidance with this widget. As we started working on adding more capabilities to the widget we realized that we need to add more config parameters to the widget. I have opened a few tickets to keep track this work. RA-1341 and RA-1342.

I am sure that very soon we will have to modify the openmrs-contrib-uicommons code, so I also added a ticket (RA-1340) for the suggestion you made above about using HTML base tag. Until then we should be able to incorporate the relationships widget into the registrationSummary page by using config parameters.

1 Like