Order Extension Module


This module aims to extend the Order API available in OpenMRS 1.9 and earlier, by building the following features:

  • Support for creating Order Sets, which allow users to pre-define a set of Order templates
  • Support for associating several Orders together in an Order Group
  • Extending the Order and DrugOrder objects with the addition of several new fields
  • New UI components for managing and viewing OrderSets and OrderGroups

Order Set Design

class OrderSet extends BaseOpenmrsMetadata {
  Operator operator;
  Concept indication;
  boolean cyclical
  Integer cycleLengthInDays;
  List<OrderSetMember> members;

abstract class OrderSetMember extends BaseOpenmrsObject {
  OrderSet orderSet;
  String title;
  String comment;
  boolean selected;
  Integer relativeStartDay;
  Integer lengthInDays;
  String template;

abstract class SingleOrderSetMember extends OrderSetMember {
  abstract OrderType getOrderType();
  Concept concept;
  Concept indication;
  String instructions;

class TestOrderSetMember extends SingleOrderSetMember {
  OrderType getOrderType() { test order }

class DrugOrderSetMember extends SingleOrderSetMember {
  OrderType getOrderType() { ORDERTYPE_DRUG }
  Drug drug;
  Double dose;
  String units;
  Concept route;
  String frequency;
  boolean asNeeded;
  String administrationInstructions;

class NestedOrderSetMember extends OrderSetMember {
  OrderSet nestedOrderSet;

Order Group Design

abstract class OrderGroup extends BaseOpenmrsData {
  OrderSet orderSet;

class DrugRegimen extends OrderGroup {
  List<ExtendedDrugOrder> members;
  Integer cycleNumber;

Order Extensions

interface GroupableOrder extends OpenmrsData {
  Integer getOrderId();
  void setOrderId(Integer orderId);
  Patient getPatient();
  void setPatient(Patient patient);
  OrderType getOrderType();
  void setOrderType(OrderType orderType);
  Concept getConcept();
  void setConcept(Concept concept);
  String getInstructions();
  void setInstructions(String instructions);
  Date getStartDate();
  void setStartDate(Date startDate);
  Date getAutoExpireDate();
  void setAutoExpireDate(Date autoExpireDate);
  Encounter getEncounter();
  void setEncounter(Encounter encounter);
  User getOrderer();
  void setOrderer(User orderer);
  Boolean getDiscontinued();
  void setDiscontinued(Boolean discontinued);
  User getDiscontinuedBy();
  void setDiscontinuedBy(User discontinuedBy);
  Date getDiscontinuedDate();
  void setDiscontinuedDate(Date discontinuedDate);
  Concept getDiscontinuedReason();
  void setDiscontinuedReason(Concept discontinuedReason);
  String getDiscontinuedReasonNonCoded();
  void setDiscontinuedReasonNonCoded(String discontinuedReasonNonCoded);
  String getAccessionNumber();
  void setAccessionNumber(String accessionNumber);

class ExtendedOrder extends Order implements GroupableOrder {
  OrderGroup group

class ExtendedDrugOrder extends DrugOrder implements GroupableOrder {
  OrderGroup group;
  Concept indication;
  Concept route;
  String administrationInstructions;


OrderExtensionService extends OpenmrsService {
  OrderSet getOrderSet(Integer id);
  OrderSet getOrderSetByUuid(String uuid);
  List<OrderSet> getNamedOrderSets(boolean includeRetired);
  List<OrderSet> findAvailableOrderSets(String partialName, Concept indication);
  OrderSet saveOrderSet(OrderSet orderSet);
  void purgeOrderSet(OrderSet orderSet);
  OrderSetMember getOrderSetMember(Integer id);
  List<OrderSet> getParentOrderSets(OrderSet orderSet);
  <T extends OrderGroup> T saveOrderGroup(T orderGroup);
  <T extends OrderGroup> List<T> getOrderGroups(Patient patient, Class<T> type);
  void addOrdersForPatient(Patient patient, OrderSet orderSet, Date startDate, Integer numCycles);
  OrderGroup getOrderGroup(Integer id);
  DrugRegimen getDrugRegimen(Integer id);
  Integer getMaxNumberOfCyclesForRegimen(Patient patient, DrugRegimen regimen);
  List<ExtendedDrugOrder> getFutureDrugOrdersOfSameOrderSet(Patient patient, OrderSet orderSet, Date startDate);
  List<DrugRegimen> getFutureDrugRegimensOfSameOrderSet(Patient patient, DrugRegimen drugRegimen, Date startDate);
  List<ExtendedDrugOrder> getExtendedDrugOrders(Patient patient, Concept indication, Date startDateAfter, Date startDateBefore);