How to customize Patient Registration Form with Fragments(as Person Attributes)

Hi,

I have implemented a fragment to customize the Patient Registration Form. The fragment code is given below,

locationbasedaccess/locations.gsp

<div>
    <div>
        <p class="left">
            <label>
                Please select the default access location
            </label>
            <select id="${config.formFieldName}" name="${config.formFieldName}" class="rel_type">
                <% activeLocations.each { location -> %>
                <option value="${location.uuid}">${location.name}</option>
                <% } %>
            </select>
        </p>
    </div>
</div>

locationbasedaccess/LocationsFragmentController

public class LocationsFragmentController {
    public void controller(FragmentModel model) {
        model.addAttribute("activeLocations", Context.getLocationService().getAllLocations(true));
    }
}

Then I have created an App Definition like this follow,

{
    "legend": "Patient Location ",
    "id": "patientLocationLabel",
    "fields": [
      {
       "type": "personAttribute",
       "label": "Select Location",
       "formFieldName": "locationId",
       "uuid": "76f86917-9edb-4258-b9d7-51c889606a3c",
       "widget": {
                  "providerName": "locationbasedaccess",
                  "fragmentId": "field/locations"
                 }
       }
      ]
}

Here I have already created this personAttribute in the OpenMRS system and replaced the uuid respect to that personAttribute.

When I used these following widget(in the above App Definition),

"widget": {
   "providerName": "uicommons",
   "fragmentId": "field/text"
   }
}

I was able to get the value entered in the text box as a personAttribute using AOP Service ( by tracking the savePerson() method)

But I couldn’t get the value entered in the Patient Registration form through the AOP service as personAttribute (by tracking the savePerson() method)

"widget": {
   "providerName": "locationbasedaccess",
   "fragmentId": "field/locations"
   }
}

Here I need to get the value which is selected in the patient registration form by user as PersonAttribute :slight_smile:

Can some one please help me to solve this issue?

CC : @dkayiwa @mksd @darius

Hi @suthagar23, where is the AOP registered with Spring?

Hi @mksd

I have defined a single bean in webModuleApplicationContext.xml like,

<bean class="org.openmrs.ui.framework.StandardModuleUiConfiguration">
        <property name="moduleId" value="yourmoduleid"/>
    </bean>

Could you please guide me to register AOP with Spring?

The value property need to be the name of your module i.e your exact module id

Yes, it modified as

<bean class="org.openmrs.ui.framework.StandardModuleUiConfiguration">
	<property name="moduleId" value="${project.parent.artifactId}"/>
</bean>

@suthagar23 look at this example from Ext I18N:

  • Here is an AOP method interceptor.
  • Here is where/how the AOP advices are added to the Spring context.

Where is your AOP implementation, and where/how do you do the equivalent of the latter?

Thanks you so much @mksd I will look into this examplses.

Where is your AOP implementation, and where/how do you do the equivalent of the latter?

This PR contains the AOP implementatin for the module.

@suthagar23,

Is the AOP interceptor reached but somehow you can’t get to the form’s data that you are interested in? Or what are the exact symptoms that you are experiencing?

Yes exactly!!!

I need to get that selected value from my fragment in Patient Registration Dasshboard to my AOP implementation.

But as @dkayiwa said, It will be automatically saved as a personAttribute (according to my App Definition)