Someone asked me this question on linkedIn but did not know how to answer. Apparently they are using openmrs 1.9.11 for their implementation and they want to override some pages like the default patient registration form. And in openmrs 1.x the legacyui is still attached to the platform so what he was asking was the files to modify but I didn’t think it was a good idea for them to be messing with the platform code in a production environment for changes like that. I was hoping there is a cleaner way of overriding pages in 1.x via modules without touching the platform code. If so, what are the resources to that one can read to achieve this. I did some initial search and found this https://wiki.openmrs.org/display/docs/Overriding+Requests+to+Pages+and+Fragments. But I think that is for openmrs 2.x. What they are using is just platform 1.9.11
@dkayiwa please help me understand something. What is the difference between using the SimpleUrlHandlerMapping above and simply having an an annotated controller with @RequestMapping("/admin/patients/newPatient.form") and if this done in more than one module, which one takes precedence?
What about using an annotated controller with @RequestMapping("/admin/patients/newPatient.form") instead of the SimpleUrlHandleMapping. I’ve done some research and all I see is how to use the SimpleUrlHandlerMapping can’t find a resource that explains why I would choose it over and annotated controller.
hi @dkayiwa. I would like to so something similar. But for my case I would like to do the override from the find patient on home screen. In fact I want to move the whole patient registration to a new module. Would like to customize the forms to fit our use case and also add some custom javascript to those pages. It would have been easier if we used platform 2.0 because we’d not need to create a new module and just do the customizations inside the legacyui module. But we are still in openmrs 1.x and have not planned for an upgrade yet. The suggestions you gave are a little confusing for a newbie like me.
Btw, I tried that. I created controller that extends SimpleFormController and also implemented a URL handler mapping that was suppose to intercept requests to /openmrs/findPatient but when I test the application and to click on the find patient link, I still see the version of core interface.
@dkayiwa surprisenly I was able to override the patient registration page from within a custom module with just this,
@Controller
@RequestMapping(CustomShortPatientFormController.URL_MAPPING)
public class CustomShortPatientFormController {
protected static final String URL_MAPPING = "/admin/patients/shortPatientForm.form";
private static final String VIEW = "/module/patientregistration/views/patientReg";
private static final String PATIENT_DASHBOARD_URL = "/patientDashboard.form";
@RequestMapping(method = RequestMethod.GET)
public String onGet() {
return VIEW;
}
@RequestMapping(method = RequestMethod.POST)
public String onPost() {
return VIEW;
}
}
No SimpleFormController, no SimpleUrlHandlerMapping, no xml bean declaration. Is this supposed to happen? You said I’d get an error but I can see my custom view fine which means the default platform page was properly overridden. Should I rely on this or is this a bug?