New Module: How include fragments from others modules

Hello, I´m really new in openMRS and I have thousands of doubts. I have reading several step-by-step guides and your wiki and there are a lot of information. I have started playing with my new module wirh reference application. I have my first module deployed in an openmrs-sdk instance…but I would like to know if I can take a fragment from another module…I would like to add a patient search at the top of my module. I have seen the patient search module in the default openmrs distribution. Can I use that code in my module with an “includefragment” or similar? or I have to write the code again? Thanks so much. Regards.

1 Like

Welcome to the community and thanks @david.corrales for this inquiry, someone here will be able to help you.

cc @dkayiwa , @tendomart , @samuel34 , @c.antwi , @jennifer

yes @ david.corrales , in openmrs , as long as the code in a given module was written follwing the standard openmrs convestions , when you install that module as a dependence in your module , you can always use code from it. in otherwords , you can include fragmnets from another module without re-writing the code , if you first install that module as a dependence in your module , and provided , the fragments were defined in the standard openmrs way of doing it

1 Like

if you read this, youll find a phrase like “a library of re-usable fragments”

check this out for how to install a module as a dependence in another module

One example here of a place where the Core Apps module includes the date picker fragment from UI Commons (defined here in UI Commons).

And basically… that’s it (I think). You don’t even need Core Apps to depend on UI Commons, or to require it. You will see that Core Apps does depend on uicommons-api, but I think that’s for a complete different reason, it’s because it uses its global constants (here).

1 Like

thanks @mksd for a more clarification.

in other-words you do need even to first install another module as a dependence as i had earlier said, but atleast what am sure of is , you must make sure whichever module you’re getting fragments from must be installed and running at the time of running your module

Ok! thanks so much! Done! I follow doing several test. :slight_smile: