Adding extension points in the patient dashboard page.

Hello, Guys !!!

I am trying to add a links on the patient dashboard page. For this purpose I used extension points.

Here is what I did: { “id”: “${project.parent.groupId}.${project.parent.artifactId}.hospital.myId”, “extensionPointId”: “patientDashboard.overallActions”, “type”: “link”, “icon”: “icon-plus”, “label”: “Some label”, “url”: “url of some page in my module”, “require”: "visit && someBoolean " // please note this }

My problem is that as I add the someBoolean in the patient.page(adding its value as a key-value pair in the contextModel), it works just fine. But as I try to do this in the patientDashboard.page , an exception is thrown which says, someBoolean is not defined.

Although I have already done this:

contextModel.put(“someBoolean”, true);

model.addAttribute(“appContextModel”, contextModel);

Can i look at the class from where you are doing contextModel.put(“someBoolean”, true) ?

Sure… here is the class

public class PatientDashboardPageController {

public Object controller(@RequestParam("patientId") Patient patient,
                       @SpringBean("applicationEventService") ApplicationEventService applicationEventService,
                       UiSessionContext sessionContext) {

    if (!Context.hasPrivilege(CoreAppsConstants.PRIVILEGE_PATIENT_VISITS)) {
        return new Redirect("coreapps", "noAccess", "");
    }
    else if (patient.isVoided() || patient.isPersonVoided()) {
        return new Redirect("coreapps", "patientdashboard/deletedPatient", "patientId=" + patient.getId());
    }

	patientDomainWrapper.setPatient(patient);
	model.addAttribute("patient", patientDomainWrapper);
	model.addAttribute("selectedTab", selectedTab);

    Location visitLocation = null;
    try {
        visitLocation = adtService.getLocationThatSupportsVisits(sessionContext.getSessionLocation());
    } catch (IllegalArgumentException ex) {
        // location does not support visits
    }

	VisitDomainWrapper activeVisit = null;
    if (visitLocation != null) {
        activeVisit = adtService.getActiveVisit(patient, visitLocation);
    }
	
	AppContextModel contextModel = sessionContext.generateAppContextModel();
	
	boolean someBoolean=false;
	if(activeVisit != null) {
		Object obj=activeVisit.getVisitAttribute(VisitAttributeConstants.ALLOWED_ACCESS_TO_DETAILS);
		if(obj != null && StringUtils.isNotBlank(String.valueOf(obj))){
			someBoolean=true;
		}
	}
	contextModel.put("someBoolean", someBoolean);
	model.addAttribute("appContextModel", contextModel);
	List<Extension> overallActions = appFrameworkService.getExtensionsForCurrentUser("patientDashboard.overallActions", contextModel);
	Collections.sort(overallActions);
	model.addAttribute("overallActions", overallActions);

    List<Extension> includeFragments = appFrameworkService.getExtensionsForCurrentUser("patientDashboard.includeFragments");
    Collections.sort(includeFragments);
    model.addAttribute("includeFragments", includeFragments);
	
	List<Extension> visitActions = appFrameworkService.getExtensionsForCurrentUser("patientDashboard.visitActions");

	Collections.sort(visitActions);
	model.addAttribute("visitActions", visitActions);
	model.addAttribute("patientTabs", appFrameworkService.getExtensionsForCurrentUser("patientDashboard.tabs"));

    model.addAttribute("dashboardUrl", coreAppsProperties.getDashboardUrl());

    applicationEventService.patientViewed(patient, sessionContext.getCurrentUser());

    return null;

}

Are you doing this in a fork of the coreapps module?

Yes exactly. Sorry I didn’t mention that.

Did you think of achieving that without forking the module?