@Transactional public class OrderServiceImpl extends BaseOpenmrsService implements OrderService, OrderNumberGenerator, GlobalPropertyListener
OrderService| Modifier and Type | Field and Description | 
|---|---|
protected OrderDAO | 
dao  | 
protected org.apache.commons.logging.Log | 
log  | 
PARALLEL_ORDERS| Constructor and Description | 
|---|
OrderServiceImpl()  | 
| Modifier and Type | Method and Description | 
|---|---|
Order | 
discontinueOrder(Order orderToDiscontinue,
                Concept reasonCoded,
                java.util.Date discontinueDate,
                Provider orderer,
                Encounter encounter)
Discontinues an order. 
 | 
Order | 
discontinueOrder(Order orderToDiscontinue,
                java.lang.String reasonNonCoded,
                java.util.Date discontinueDate,
                Provider orderer,
                Encounter encounter)
Discontinues an order. 
 | 
java.util.List<Order> | 
getActiveOrders(Patient patient,
               OrderType orderType,
               CareSetting careSetting,
               java.util.Date asOfDate)
Gets all active orders for the specified patient matching the specified CareSetting,
 OrderType as of the specified date. 
 | 
java.util.List<Order> | 
getAllOrdersByPatient(Patient patient)
Gets all orders for the specified patient including discontinuation orders 
 | 
CareSetting | 
getCareSetting(java.lang.Integer careSettingId)
Retrieve care setting 
 | 
CareSetting | 
getCareSettingByName(java.lang.String name)
Gets the CareSetting with the specified name 
 | 
CareSetting | 
getCareSettingByUuid(java.lang.String uuid)
Gets the CareSetting with the specified uuid 
 | 
java.util.List<CareSetting> | 
getCareSettings(boolean includeRetired)
Gets all non retired CareSettings if includeRetired is set to true otherwise retired ones are
 included too 
 | 
Order | 
getDiscontinuationOrder(Order order)
Get discontinuation order for the given order, it is the un voided discontinuation order with
 a previousOrder that matches the specified order. 
 | 
java.util.List<Concept> | 
getDrugDispensingUnits()
Gets the possible units of dispensing, i.e the set members for the concept that matches the
 uuid specified as the value for the global property
  
OpenmrsConstants.GP_DRUG_DISPENSING_UNITS_CONCEPT_UUID | 
java.util.List<Concept> | 
getDrugDosingUnits()
Gets the possible drug dosing units, i.e the set members for the concept that matches the
 uuid specified as the value for the global property
  
OpenmrsConstants.GP_DRUG_DOSING_UNITS_CONCEPT_UUID | 
java.util.List<Concept> | 
getDrugRoutes()
Gets the possible drug routes, i.e the set members for the concept that matches the uuid
 specified as the value for the global property
  
OpenmrsConstants.GP_DRUG_ROUTES_CONCEPT_UUID | 
java.util.List<Concept> | 
getDurationUnits()
Gets the possible units of duration, i.e the set members for the concept that matches the
 uuid specified as the value for the global property
  
OpenmrsConstants.GP_DURATION_UNITS_CONCEPT_UUID | 
java.lang.String | 
getNewOrderNumber(OrderContext orderContext)
Generates a new order number. 
 | 
java.lang.Long | 
getNextOrderNumberSeedSequenceValue()
Gets the next available order number seed 
 | 
Order | 
getOrder(java.lang.Integer orderId)
Get order by internal primary key identifier 
 | 
Order | 
getOrderByOrderNumber(java.lang.String orderNumber)
Gets the order identified by a given order number 
 | 
Order | 
getOrderByUuid(java.lang.String uuid)
Get Order by its UUID 
 | 
java.util.List<OrderFrequency> | 
getOrderFrequencies(boolean includeRetired)
Gets all order frequencies 
 | 
java.util.List<OrderFrequency> | 
getOrderFrequencies(java.lang.String searchPhrase,
                   java.util.Locale locale,
                   boolean exactLocale,
                   boolean includeRetired)
Gets all non retired order frequencies associated to concepts that match the specified search
 phrase 
 | 
OrderFrequency | 
getOrderFrequency(java.lang.Integer orderFrequencyId)
Gets OrderFrequency that matches the specified orderFrequencyId 
 | 
OrderFrequency | 
getOrderFrequencyByConcept(Concept concept)
Gets an OrderFrequency that matches the specified concept 
 | 
OrderFrequency | 
getOrderFrequencyByUuid(java.lang.String uuid)
Gets OrderFrequency that matches the specified uuid 
 | 
java.util.List<Order> | 
getOrderHistoryByConcept(Patient patient,
                        Concept concept)
Gets all Order objects that use this Concept for a given patient. 
 | 
java.util.List<Order> | 
getOrderHistoryByOrderNumber(java.lang.String orderNumber)
Gets the order matching the specified order number and its previous orders in the ordering
 they occurred, i.e if this order has a previous order, fetch it and if it also has a previous
 order then fetch it until the original one with no previous order is reached 
 | 
java.util.List<Order> | 
getOrders(Patient patient,
         CareSetting careSetting,
         OrderType orderType,
         boolean includeVoided)
Gets all Orders that match the specified parameters excluding discontinuation orders 
 | 
OrderType | 
getOrderType(java.lang.Integer orderTypeId)
Get OrderType by orderTypeId 
 | 
OrderType | 
getOrderTypeByConcept(Concept concept)
Gets the order type mapped to a given concept 
 | 
OrderType | 
getOrderTypeByConceptClass(ConceptClass conceptClass)
Gets the order type mapped to a given concept class 
 | 
OrderType | 
getOrderTypeByName(java.lang.String orderTypeName)
Gets OrderType that matches the specified name 
 | 
OrderType | 
getOrderTypeByUuid(java.lang.String uuid)
Get OrderType by uuid 
 | 
java.util.List<OrderType> | 
getOrderTypes(boolean includeRetired)
Get all order types, if includeRetired is set to true then retired ones will be included
 otherwise not 
 | 
Order | 
getRevisionOrder(Order order)
Get revision order for the given order, it is the order with the changes that was created as
 a replacement for the specified order. 
 | 
java.util.List<OrderType> | 
getSubtypes(OrderType orderType,
           boolean includeRetired)
Returns all descendants of a given order type for example Given TEST will get back LAB TEST
 and RADIOLOGY TEST; and Given LAB TEST, will might get back SEROLOGY, MICROBIOLOGY, and
 CHEMISTRY 
 | 
java.util.List<Concept> | 
getTestSpecimenSources()
Gets the possible test specimen sources, i.e the set members for the concept that matches the
 uuid specified as the value for the global property
  
OpenmrsConstants.GP_TEST_SPECIMEN_SOURCES_CONCEPT_UUID | 
void | 
globalPropertyChanged(GlobalProperty newValue)
Called after a global property is created or updated 
 | 
void | 
globalPropertyDeleted(java.lang.String propertyName)
Called after a global property is deleted 
 | 
void | 
purgeOrder(Order order)
Completely delete an order from the database. 
 | 
void | 
purgeOrder(Order order,
          boolean cascade)
Completely delete an order from the database. 
 | 
void | 
purgeOrderFrequency(OrderFrequency orderFrequency)
Completely removes an order frequency from the database 
 | 
void | 
purgeOrderType(OrderType orderType)
Completely removes an order type from the database 
 | 
OrderFrequency | 
retireOrderFrequency(OrderFrequency orderFrequency,
                    java.lang.String reason)
Retires the given order frequency in the database 
 | 
OrderType | 
retireOrderType(OrderType orderType,
               java.lang.String reason)
Retires the given order type in the database 
 | 
Order | 
saveOrder(Order order,
         OrderContext orderContext)
Save or update the given  
order in the database. | 
OrderFrequency | 
saveOrderFrequency(OrderFrequency orderFrequency)
Creates or updates the given order frequency in the database 
 | 
OrderType | 
saveOrderType(OrderType orderType)
Creates or updates the given order type in the database 
 | 
void | 
setOrderDAO(OrderDAO dao)
Setter for the Order data access object. 
 | 
boolean | 
supportsPropertyName(java.lang.String propertyName)
Asks this listener whether it wants to be notified about the given property name 
 | 
OrderFrequency | 
unretireOrderFrequency(OrderFrequency orderFrequency)
Restores an order frequency that was previously retired in the database 
 | 
OrderType | 
unretireOrderType(OrderType orderType)
Restores an order type that was previously retired in the database 
 | 
Order | 
unvoidOrder(Order order)
Unvoid order record. 
 | 
Order | 
voidOrder(Order order,
         java.lang.String voidReason)
Mark an order as voided. 
 | 
onShutdown, onStartupclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitonShutdown, onStartupprotected final org.apache.commons.logging.Log log
protected OrderDAO dao
public void setOrderDAO(OrderDAO dao)
OrderServicesetOrderDAO in interface OrderServicedao - The data access object to useOrderService.setOrderDAO(org.openmrs.api.db.OrderDAO)public Order saveOrder(Order order, OrderContext orderContext) throws APIException
OrderServiceorder in the database. If the OrderType for the order
 is not specified, then it will be set to the one set on the OrderContext if any, if none
 exists on the orderContext, then it will be set to the one associated to the ConceptClass of
 the ordered concept otherwise the save fails. If the CareSetting field of the order is not
 specified then it will default to the one set on the passed in OrderContext if any otherwise
 the save fails.saveOrder in interface OrderServiceorder - the Order to saveorderContext - the OrderContext objectAPIExceptionOrderService.saveOrder(org.openmrs.Order, org.openmrs.api.OrderContext)public void purgeOrder(Order order) throws APIException
OrderServiceOrderService.voidOrder(Order, String)purgeOrder in interface OrderServiceorder - The Order to remove from the systemAPIExceptionOrderService.purgeOrder(org.openmrs.Order)public void purgeOrder(Order order, boolean cascade) throws APIException
OrderServiceOrderService.voidOrder(Order, String)
 This method is different from purgeOrder(Order order) above: If param cascade is false will
 completely delete an order from the database period If param cascade is true will completely
 delete an order from the database and delete any Obs that references the Order.purgeOrder in interface OrderServiceorder - The Order to remove from the systemAPIExceptionOrderService.purgeOrder(Order)public Order voidOrder(Order order, java.lang.String voidReason) throws APIException
OrderServicevoidOrder in interface OrderServiceorder - Order to voidvoidReason - String reasonAPIExceptionOrderService.voidOrder(org.openmrs.Order, java.lang.String)public Order unvoidOrder(Order order) throws APIException
OrderServiceOrderService.voidOrder(Order, String)unvoidOrder in interface OrderServiceorder - order to be unvoidedAPIExceptionOrderService.unvoidOrder(org.openmrs.Order)@Transactional(readOnly=true) public Order getOrder(java.lang.Integer orderId) throws APIException
OrderServicegetOrder in interface OrderServiceorderId - internal order identifierAPIExceptionOrderService.getOrder(java.lang.Integer)public java.util.List<Order> getOrders(Patient patient, CareSetting careSetting, OrderType orderType, boolean includeVoided)
OrderServicegetOrders in interface OrderServicepatient - the patient to match oncareSetting - the CareSetting to match onorderType - The OrderType to match onincludeVoided - Specifies whether voided orders should be included or notOrderService.getOrders(org.openmrs.Patient, org.openmrs.CareSetting,
      org.openmrs.OrderType, boolean)public java.util.List<Order> getAllOrdersByPatient(Patient patient)
OrderServicegetAllOrdersByPatient in interface OrderServicepatient - the patient to match onOrderOrderService.getAllOrdersByPatient(org.openmrs.Patient)@Transactional(readOnly=true) public Order getOrderByUuid(java.lang.String uuid) throws APIException
OrderServicegetOrderByUuid in interface OrderServiceAPIExceptionOrderService.getOrderByUuid(java.lang.String)@Transactional(readOnly=true) public Order getDiscontinuationOrder(Order order) throws APIException
OrderServicegetDiscontinuationOrder in interface OrderServiceAPIExceptionOrderService.getDiscontinuationOrder(Order)public Order getRevisionOrder(Order order) throws APIException
OrderServicegetRevisionOrder in interface OrderServiceAPIExceptionOrderService.getRevisionOrder(Order)public java.lang.String getNewOrderNumber(OrderContext orderContext) throws APIException
OrderNumberGeneratorgetNewOrderNumber in interface OrderNumberGeneratororderContext - APIExceptionOrderNumberGenerator.getNewOrderNumber(org.openmrs.api.OrderContext)@Transactional(readOnly=true) public Order getOrderByOrderNumber(java.lang.String orderNumber)
OrderServicegetOrderByOrderNumber in interface OrderServiceorderNumber - the order numberOrderService.getOrderByOrderNumber(java.lang.String)@Transactional(readOnly=true) public java.util.List<Order> getOrderHistoryByConcept(Patient patient, Concept concept)
OrderServicegetOrderHistoryByConcept in interface OrderServicepatient - the patient.concept - the concept.OrderService.getOrderHistoryByConcept(org.openmrs.Patient,
      org.openmrs.Concept)@Transactional(propagation=REQUIRES_NEW) public java.lang.Long getNextOrderNumberSeedSequenceValue()
OrderServicegetNextOrderNumberSeedSequenceValue in interface OrderServiceOrderService.getNextOrderNumberSeedSequenceValue()@Transactional(readOnly=true) public java.util.List<Order> getOrderHistoryByOrderNumber(java.lang.String orderNumber)
OrderServicegetOrderHistoryByOrderNumber in interface OrderServiceorderNumber - the order number whose history to getOrderService.getOrderHistoryByOrderNumber(java.lang.String)@Transactional(readOnly=true) public java.util.List<Order> getActiveOrders(Patient patient, OrderType orderType, CareSetting careSetting, java.util.Date asOfDate)
OrderService- Not voided - Not a discontinuation Order i.e one where action != Action#DISCONTINUE - dateActivated is before or equal to asOfDate - dateStopped and autoExpireDate are both null OR if it has dateStopped, then it should be after asOfDate OR if it has autoExpireDate, then it should be after asOfDate. NOTE: If both dateStopped and autoExpireDate are set then dateStopped wins because an order can never expire and then stopped later i.e. you stop an order that hasn't yet expired
getActiveOrders in interface OrderServicepatient - the patientorderType - The OrderType to matchcareSetting - the care setting, returns all ignoring care setting if value is nullasOfDate - defaults to current timeOrderService.getActiveOrders(org.openmrs.Patient, org.openmrs.OrderType,
      org.openmrs.CareSetting, java.util.Date)public CareSetting getCareSetting(java.lang.Integer careSettingId)
OrderServicegetCareSetting in interface OrderServiceOrderService.getCareSetting(Integer)public CareSetting getCareSettingByUuid(java.lang.String uuid)
OrderServicegetCareSettingByUuid in interface OrderServiceuuid - the uuid to match onOrderService.getCareSettingByUuid(String)public CareSetting getCareSettingByName(java.lang.String name)
OrderServicegetCareSettingByName in interface OrderServicename - the name to match onOrderService.getCareSettingByName(String)public java.util.List<CareSetting> getCareSettings(boolean includeRetired)
OrderServicegetCareSettings in interface OrderServiceincludeRetired - specifies whether retired care settings should be returned or notOrderService.getCareSettings(boolean)public OrderType getOrderTypeByName(java.lang.String orderTypeName)
OrderServicegetOrderTypeByName in interface OrderServiceorderTypeName - the name to match againstOrderService.getOrderTypeByName(String)public OrderFrequency getOrderFrequency(java.lang.Integer orderFrequencyId)
OrderServicegetOrderFrequency in interface OrderServiceorderFrequencyId - the id to match againstOrderService.getOrderFrequency(Integer)public OrderFrequency getOrderFrequencyByUuid(java.lang.String uuid)
OrderServicegetOrderFrequencyByUuid in interface OrderServiceuuid - the uuid to match againstOrderService.getOrderFrequencyByUuid(String)public java.util.List<OrderFrequency> getOrderFrequencies(boolean includeRetired)
OrderServicegetOrderFrequencies in interface OrderServiceincludeRetired - specifies whether retired ones should be included or notOrderService.getOrderFrequencies(boolean)public java.util.List<OrderFrequency> getOrderFrequencies(java.lang.String searchPhrase, java.util.Locale locale, boolean exactLocale, boolean includeRetired)
OrderServicegetOrderFrequencies in interface OrderServicesearchPhrase - The string to match onlocale - The locale to match on when searching in associated concept namesexactLocale - If false then order frequencies associated to concepts with names in a
            broader locale will be matched e.g in case en_GB is passed in then en will be
            matchedincludeRetired - Specifies if retired order frequencies that match should be included or
            notOrderService.getOrderFrequencies(String, java.util.Locale, boolean, boolean)public Order discontinueOrder(Order orderToDiscontinue, Concept reasonCoded, java.util.Date discontinueDate, Provider orderer, Encounter encounter) throws java.lang.Exception
OrderServicediscontinueOrder in interface OrderServiceAPIException - if the action of orderToDiscontinue is
             Order.Action.DISCONTINUEjava.lang.ExceptionOrderService.discontinueOrder(org.openmrs.Order, org.openmrs.Concept,
      java.util.Date, org.openmrs.Provider, org.openmrs.Encounter)public Order discontinueOrder(Order orderToDiscontinue, java.lang.String reasonNonCoded, java.util.Date discontinueDate, Provider orderer, Encounter encounter) throws java.lang.Exception
OrderServicediscontinueOrder in interface OrderServiceAPIException - if the action of orderToDiscontinue is
             Order.Action.DISCONTINUEjava.lang.ExceptionOrderService.discontinueOrder(org.openmrs.Order, String, java.util.Date,
      org.openmrs.Provider, org.openmrs.Encounter)public OrderFrequency saveOrderFrequency(OrderFrequency orderFrequency) throws APIException
OrderServicesaveOrderFrequency in interface OrderServiceorderFrequency - the order frequency to saveAPIExceptionOrderService.saveOrderFrequency(org.openmrs.OrderFrequency)public OrderFrequency retireOrderFrequency(OrderFrequency orderFrequency, java.lang.String reason)
OrderServiceretireOrderFrequency in interface OrderServiceorderFrequency - the order frequency to retirereason - the retire reasonOrderService.retireOrderFrequency(org.openmrs.OrderFrequency,
      java.lang.String)public OrderFrequency unretireOrderFrequency(OrderFrequency orderFrequency)
OrderServiceunretireOrderFrequency in interface OrderServiceorderFrequency - the order frequency to unretireOrderService.unretireOrderFrequency(org.openmrs.OrderFrequency)public void purgeOrderFrequency(OrderFrequency orderFrequency)
OrderServicepurgeOrderFrequency in interface OrderServiceorderFrequency - the order frequency to purgeOrderService.purgeOrderFrequency(org.openmrs.OrderFrequency)@Transactional(readOnly=true) public OrderFrequency getOrderFrequencyByConcept(Concept concept)
OrderServicegetOrderFrequencyByConcept in interface OrderServiceconcept - the concept to match againstOrderService.getOrderFrequencyByConcept(org.openmrs.Concept)public boolean supportsPropertyName(java.lang.String propertyName)
GlobalPropertyListenersupportsPropertyName in interface GlobalPropertyListenerGlobalPropertyListener.supportsPropertyName(String)public void globalPropertyChanged(GlobalProperty newValue)
GlobalPropertyListenerglobalPropertyChanged in interface GlobalPropertyListenernewValue - the new value of the property that was just savedGlobalPropertyListener.globalPropertyChanged(org.openmrs.GlobalProperty)public void globalPropertyDeleted(java.lang.String propertyName)
GlobalPropertyListenerglobalPropertyDeleted in interface GlobalPropertyListenerpropertyName - the name of the property that was just deletedGlobalPropertyListener.globalPropertyDeleted(String)@Transactional(readOnly=true) public OrderType getOrderType(java.lang.Integer orderTypeId)
OrderServicegetOrderType in interface OrderServiceorderTypeId - the orderTypeId to match onOrderService.getOrderType(Integer)@Transactional(readOnly=true) public OrderType getOrderTypeByUuid(java.lang.String uuid)
OrderServicegetOrderTypeByUuid in interface OrderServiceuuid - the uuid to match onOrderService.getOrderTypeByUuid(String)@Transactional(readOnly=true) public java.util.List<OrderType> getOrderTypes(boolean includeRetired)
OrderServicegetOrderTypes in interface OrderServiceincludeRetired - boolean flag which indicate search needs to look at retired order types
            or notOrderService.getOrderTypes(boolean)public OrderType saveOrderType(OrderType orderType)
OrderServicesaveOrderType in interface OrderServiceorderType - the order type to saveOrderService.saveOrderType(org.openmrs.OrderType)public void purgeOrderType(OrderType orderType)
OrderServicepurgeOrderType in interface OrderServiceorderType - the order type to purgeOrderService.purgeOrderType(org.openmrs.OrderType)public OrderType retireOrderType(OrderType orderType, java.lang.String reason)
OrderServiceretireOrderType in interface OrderServiceorderType - the order type to retirereason - the retire reasonOrderService.retireOrderType(org.openmrs.OrderType, String)public OrderType unretireOrderType(OrderType orderType)
OrderServiceunretireOrderType in interface OrderServiceorderType - the order type to unretireOrderService.unretireOrderType(org.openmrs.OrderType)@Transactional(readOnly=true) public java.util.List<OrderType> getSubtypes(OrderType orderType, boolean includeRetired)
OrderServicegetSubtypes in interface OrderServiceorderType - the order type which needs to search for its' dependenciesincludeRetired - boolean flag for include retired order types or notOrderService.getSubtypes(org.openmrs.OrderType, boolean)@Transactional(readOnly=true) public OrderType getOrderTypeByConceptClass(ConceptClass conceptClass)
OrderServicegetOrderTypeByConceptClass in interface OrderServiceconceptClass - the concept classOrderService.getOrderTypeByConceptClass(org.openmrs.ConceptClass)@Transactional(readOnly=true) public OrderType getOrderTypeByConcept(Concept concept)
OrderServicegetOrderTypeByConcept in interface OrderServiceconcept - the conceptOrderService.getOrderTypeByConcept(org.openmrs.Concept)@Transactional(readOnly=true) public java.util.List<Concept> getDrugRoutes()
OrderServiceOpenmrsConstants.GP_DRUG_ROUTES_CONCEPT_UUIDgetDrugRoutes in interface OrderServiceOrderService.getDrugRoutes()@Transactional(readOnly=true) public java.util.List<Concept> getDrugDosingUnits()
OrderServiceOpenmrsConstants.GP_DRUG_DOSING_UNITS_CONCEPT_UUIDgetDrugDosingUnits in interface OrderService@Transactional(readOnly=true) public java.util.List<Concept> getDrugDispensingUnits()
OrderServiceOpenmrsConstants.GP_DRUG_DISPENSING_UNITS_CONCEPT_UUIDgetDrugDispensingUnits in interface OrderService@Transactional(readOnly=true) public java.util.List<Concept> getDurationUnits()
OrderServiceOpenmrsConstants.GP_DURATION_UNITS_CONCEPT_UUIDgetDurationUnits in interface OrderServicepublic java.util.List<Concept> getTestSpecimenSources()
OrderServiceOpenmrsConstants.GP_TEST_SPECIMEN_SOURCES_CONCEPT_UUIDgetTestSpecimenSources in interface OrderServiceOrderService.getTestSpecimenSources()Copyright © 2018 OpenMRS Inc.. All Rights Reserved.