Versions Compared

Key

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

In OpenMRS , Order can  be of three type Core orders are represented by the following classes: Order, DrugOrder and  and TestOrder. Where Order is  is the parent class while the other two are child classes of Order. 

If a module wants to provide resources to handle Drug and Test Orders using OpenMRS API. There can be two possible ways:

1. implementing specifics to drug and (lab) test orders.

Two possible design routes for a third-party module (such as REST Web Services) to expose resources for the child classes could be illustrated with the following sets of URLs:

  1. /api/order/drugorder and /api/order/testorder

...


  1. /api/order?

...

  1. t=drugorder  and /api/order?

...

  1. t=testorder

...

In the first case, each class will implement its own @Resource class for it class. By implementing this method, a lot of the code is replicated as there is one parent who has most of the properties already. And changing in parent class ,we have to make changes to all the @Resource classes also. This would easier become complex after awhile. 

In Second case, OpenMRS REST API provides a functionality for this using a single @Resource class for the parent and managing its child/other types using @SubClassHandler. Like in Order and DrugOrder case, this reduces a lot of work and complexity.

...