I have successfully added a new section called “Patient Location”(sectionId : accessLocationInfo, appDefinitionName : referenceapplication.registrationapp.myRegWithLoc
) to the Patient Registration Dashboard by creating a new app definition.
{
"id": "accessLocationInfo",
"label": "Access Location",
"questions": [
{
"legend": "Patient Location ",
"id": "patientLocationLabel",
"fields": [
{
"type": "personAttribute",
"label": "Select Location",
"formFieldName": "locationId",
"uuid": "8b5c95ef-103c-41bc-9f24-368b8f77e070",
"widget": {
"providerName": "locationbasedaccess",
"fragmentId": "field/locations"
}
}
]
}
]
}
Now I wanted to edit the patient location through the patient summary dashboard like editing the contact information. So I have created an extenstion.json as follows,
[
{
"id": "${project.parent.groupId}.${project.parent.artifactId}.editLocation",
"extensionPointId": "patientDashboard.overallActions",
"type": "link",
"label": "Edit Location",
"url": "registrationapp/editSection.page?patientId={{patient.uuid}}§ionId=accessLocationInfo&appId=referenceapplication.registrationapp.myRegWithLoc",
"icon": "icon-pencil",
"order": 100,
"requiredPrivilege": "Task: View Administration Functions"
}
]
Then, I need to get the patient object from the PatientId
in the URL
(i.e http://localhost:8080/openmrs/registrationapp/editSection.page?patientId=84§ionId=accessLocationInfo&appId=referenceapplication.registrationapp.myRegWithLoc
to get the existing value to show in the form. So I have changed my controller as follows,
package org.openmrs.module.locationbasedaccess.fragment.controller.field;
import org.openmrs.Location;
import org.openmrs.Patient;
import org.openmrs.ui.framework.annotation.FragmentParam;
import org.openmrs.ui.framework.fragment.FragmentModel;
import org.openmrs.api.context.Context;
import javax.servlet.http.HttpSession;
import java.util.List;
public class LocationsFragmentController {
public void controller(FragmentModel model,
HttpSession session,
@FragmentParam("patientId") Object patient) {
List<Location> activeLocations = Context.getLocationService().getAllLocations();
model.addAttribute("activeLocations", activeLocations);
if (patient instanceof Patient) {
model.addAttribute("patient", patient);
}
}
}
But unfortunately, I’m getting this following error while goto that URL. Please see the error log here : UI Framework ErrorRoot Errororg.openmrs.ui.framework.UiFrameworkException: p - Pastebin.com
Please refer this PR for whole implementation,
Can someone please help me to resolve this issue ?
CC : @dkayiwa