forked from openmrs/openmrs-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request openmrs#2710 from dsurrao/TRUNK-5424
TRUNK-5424: Added Order search criteria
- Loading branch information
Showing
7 changed files
with
393 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
api/src/main/java/org/openmrs/parameter/OrderSearchCriteria.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/** | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, | ||
* v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under | ||
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license. | ||
* | ||
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS | ||
* graphic logo is a trademark of OpenMRS Inc. | ||
*/ | ||
package org.openmrs.parameter; | ||
|
||
import org.openmrs.CareSetting; | ||
import org.openmrs.Concept; | ||
import org.openmrs.OrderType; | ||
import org.openmrs.Patient; | ||
|
||
import java.util.Collection; | ||
import java.util.Date; | ||
|
||
/** | ||
* The search parameter object for orders. A convenience interface for building | ||
* instances is provided by {@link OrderSearchCriteriaBuilder}. | ||
* | ||
* @since 2.2 | ||
* @see OrderSearchCriteriaBuilder | ||
*/ | ||
public class OrderSearchCriteria { | ||
|
||
private final Patient patient; | ||
|
||
private final CareSetting careSetting; | ||
|
||
private final Collection<Concept> concepts; | ||
|
||
private final Collection<OrderType> orderTypes; | ||
|
||
/** | ||
* Matches on dateActivated that is any time on this date or less | ||
*/ | ||
private final Date activatedOnOrBeforeDate; | ||
|
||
/** | ||
* Matches on dateActivated that is any time on this date or more | ||
*/ | ||
private final Date activatedOnOrAfterDate; | ||
|
||
private final boolean includeVoided; | ||
|
||
/** | ||
* Instead of calling this constructor directly, it is recommended to use {@link OrderSearchCriteriaBuilder}. | ||
* @param patient the patient the order is for | ||
* @param careSetting the care setting to match on | ||
* @param concepts the concepts defining the order must be in this collection | ||
* @param orderTypes the order types to match on must be in this collection | ||
* @param activatedOnOrBeforeDate orders must have dateActivated on or before this date | ||
* @param activatedOnOrAfterDate orders must have dateActivated on or after this date | ||
* @param includeVoided whether to include the voided orders or not | ||
*/ | ||
public OrderSearchCriteria(Patient patient, CareSetting careSetting, Collection<Concept> concepts, | ||
Collection<OrderType> orderTypes, Date activatedOnOrBeforeDate, | ||
Date activatedOnOrAfterDate, boolean includeVoided) { | ||
this.patient = patient; | ||
this.careSetting = careSetting; | ||
this.concepts = concepts; | ||
this.orderTypes = orderTypes; | ||
this.activatedOnOrBeforeDate = activatedOnOrBeforeDate; | ||
this.activatedOnOrAfterDate = activatedOnOrAfterDate; | ||
this.includeVoided = includeVoided; | ||
} | ||
|
||
/** | ||
* @return the patient the order is for | ||
*/ | ||
public Patient getPatient() { return patient; } | ||
|
||
/** | ||
* @return the care setting to match on | ||
*/ | ||
public CareSetting getCareSetting() { return careSetting; } | ||
|
||
/** | ||
* @return the concepts defining the order must be in this collection | ||
*/ | ||
public Collection<Concept> getConcepts() { return concepts; } | ||
|
||
/** | ||
* @return the order types to match on must be in this collection | ||
*/ | ||
public Collection<OrderType> getOrderTypes() { return orderTypes; } | ||
|
||
/** | ||
* @return orders must have dateActivated on or before this date | ||
*/ | ||
public Date getActivatedOnOrBeforeDate() { return activatedOnOrBeforeDate; } | ||
|
||
/** | ||
* @return orders must have dateActivated on or after this date | ||
*/ | ||
public Date getActivatedOnOrAfterDate() { return activatedOnOrAfterDate; } | ||
|
||
/** | ||
* @return whether to include the voided orders or not | ||
*/ | ||
public boolean getIncludeVoided() { return includeVoided; } | ||
|
||
} |
113 changes: 113 additions & 0 deletions
113
api/src/main/java/org/openmrs/parameter/OrderSearchCriteriaBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/** | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, | ||
* v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under | ||
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license. | ||
* | ||
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS | ||
* graphic logo is a trademark of OpenMRS Inc. | ||
*/ | ||
package org.openmrs.parameter; | ||
|
||
import org.openmrs.CareSetting; | ||
import org.openmrs.Concept; | ||
import org.openmrs.OrderType; | ||
import org.openmrs.Patient; | ||
|
||
import java.util.Collection; | ||
import java.util.Date; | ||
|
||
/** | ||
* A convenience builder for {@link OrderSearchCriteria}. Create a builder, set | ||
* its properties to desired values and finally call {@link #createOrderSearchCriteria()} | ||
* to create the actual search criteria instance. | ||
* @see OrderSearchCriteria | ||
*/ | ||
public class OrderSearchCriteriaBuilder { | ||
private Patient patient; | ||
|
||
private CareSetting careSetting; | ||
|
||
private Collection<Concept> concepts; | ||
|
||
private Collection<OrderType> orderTypes; | ||
|
||
private Date activatedOnOrBeforeDate; | ||
|
||
private Date activatedOnOrAfterDate; | ||
|
||
private boolean includeVoided; | ||
|
||
/** | ||
* @param patient the patient the order is for | ||
* @return this builder instance | ||
*/ | ||
public OrderSearchCriteriaBuilder setPatient(Patient patient) { | ||
this.patient = patient; | ||
return (this); | ||
} | ||
|
||
/** | ||
* @param careSetting the care setting to match on | ||
* @return this builder instance | ||
*/ | ||
public OrderSearchCriteriaBuilder setCareSetting(CareSetting careSetting) { | ||
this.careSetting = careSetting; | ||
return (this); | ||
} | ||
|
||
/** | ||
* @param concepts the concepts defining the order must be in this collection | ||
* @return this builder instance | ||
*/ | ||
public OrderSearchCriteriaBuilder setConcepts(Collection<Concept> concepts) { | ||
this.concepts = concepts; | ||
return (this); | ||
} | ||
|
||
/** | ||
* @param orderTypes the order types to match on must be in this collection | ||
* @return this builder instance | ||
*/ | ||
public OrderSearchCriteriaBuilder setOrderTypes(Collection<OrderType> orderTypes) { | ||
this.orderTypes = orderTypes; | ||
return (this); | ||
} | ||
|
||
/** | ||
* @param activatedOnOrBeforeDate orders must have dateActivated on or before this date | ||
* @return this builder instance | ||
*/ | ||
public OrderSearchCriteriaBuilder setActivatedOnOrBeforeDate(Date activatedOnOrBeforeDate) { | ||
this.activatedOnOrBeforeDate = activatedOnOrBeforeDate; | ||
return (this); | ||
} | ||
|
||
/** | ||
* @param activatedOnOrAfterDate orders must have dateActivated on or after this date | ||
* @return this builder instance | ||
*/ | ||
public OrderSearchCriteriaBuilder setActivatedOnOrAfterDate(Date activatedOnOrAfterDate) { | ||
this.activatedOnOrAfterDate = activatedOnOrAfterDate; | ||
return (this); | ||
} | ||
|
||
/** | ||
* @param includeVoided whether to include the voided orders or not | ||
* @return this builder instance | ||
*/ | ||
public OrderSearchCriteriaBuilder setIncludeVoided(boolean includeVoided) { | ||
this.includeVoided = includeVoided; | ||
return (this); | ||
} | ||
|
||
/** | ||
* Create an {@link OrderSearchCriteria} with the properties of this builder instance. | ||
* @return a new search criteria instance | ||
*/ | ||
public OrderSearchCriteria createOrderSearchCriteria() { | ||
return new OrderSearchCriteria(patient, careSetting, concepts, orderTypes, activatedOnOrBeforeDate, | ||
activatedOnOrAfterDate, includeVoided); | ||
} | ||
} | ||
|
Oops, something went wrong.