Have you implemented OpenMRS? Please participate in the Implementation Site Survey. If you already have, thank you!
Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The first thing to do is to read through the conventions section on the the REST Web Services API For Clients page.  Your module should follow similar conventions.

...

Getting the REST Web Services Jar into your project

See  Requiring another module in your module

...

Code Block
titlemain pom.xml file additions

<dependency>
	<groupId>org.openmrs.module</groupId>
	<artifactId>webservices.rest-omod</artifactId>
	<version>2.0</version>
	<scope>provided</scope>
</dependency>

<dependency>
	<groupId>org.openmrs.module</groupId>
	<artifactId>webservices.rest-omod-common</artifactId>
	<version>2.0</version>
	<classifier>tests</classifier>
	<scope>test</scope>
</dependency>

...

The only difference is that you want to expose your objects under /ws/rest/v1/yourmoduleid/yourresourcename and you need to add a controller in:

org.openmrs.module.yourmoduleid.web.controller package

:

Code Block
languagejava
@Controller
@RequestMapping("/rest/" + RestConstants.VERSION_1 + "/yourmoduleid")
public class YourModuleIdResourceController extends MainResourceController {

	/**
	 * @see org.openmrs.module.webservices.rest.web.v1_0.controller.BaseRestController#getNamespace()
	 */
	@Override
	public String getNamespace() {
	    return "v1/yourmoduleid";
	}
}

and name your resources accordingly @Resource(name=RestConstants.VERSION_1 + "/yourmoduleid/yourresourcename"...

 

Then you can proceed and add your rest module's resources with org.openmrs.module.yourmoduleid.web.resource package

Examples

To be provided.