use of org.openmrs.parameter.EncounterSearchCriteriaBuilder in project openmrs-core by openmrs.
the class PatientDataUnvoidHandler method handle.
@Override
public void handle(Patient patient, User originalVoidingUser, Date origParentVoidedDate, String unused) {
// can't be unvoiding a patient that doesn't exist in the database
if (patient.getId() != null) {
// unvoid all the encounter that got voided as a result of the patient getting voided
EncounterService es = Context.getEncounterService();
EncounterSearchCriteria encounterSearchCriteria = new EncounterSearchCriteriaBuilder().setPatient(patient).setIncludeVoided(true).createEncounterSearchCriteria();
List<Encounter> encounters = es.getEncounters(encounterSearchCriteria);
if (CollectionUtils.isNotEmpty(encounters)) {
for (Encounter encounter : encounters) {
if (encounter.getVoided() && encounter.getDateVoided().equals(origParentVoidedDate) && encounter.getVoidedBy().equals(originalVoidingUser)) {
es.unvoidEncounter(encounter);
}
}
}
// unvoid all the orders that got voided as a result of the patient getting voided
OrderService os = Context.getOrderService();
List<Order> orders = os.getAllOrdersByPatient(patient);
if (CollectionUtils.isNotEmpty(orders)) {
for (Order order : orders) {
if (order.getVoided() && order.getDateVoided().equals(origParentVoidedDate) && order.getVoidedBy().equals(originalVoidingUser)) {
os.unvoidOrder(order);
}
}
}
CohortService cs = Context.getCohortService();
cs.notifyPatientUnvoided(patient, originalVoidingUser, origParentVoidedDate);
}
}
use of org.openmrs.parameter.EncounterSearchCriteriaBuilder in project openmrs-core by openmrs.
the class EncounterServiceTest method getEncounters_shouldIncludeVoidedEncounters.
/**
* @see EncounterService#getEncounters(Patient, Location, Date, Date, java.util.Collection,
* java.util.Collection, java.util.Collection, boolean)
*/
@Test
public void getEncounters_shouldIncludeVoidedEncounters() {
EncounterSearchCriteria encounterSearchCriteria = new EncounterSearchCriteriaBuilder().setIncludeVoided(true).createEncounterSearchCriteria();
assertEquals(8, Context.getEncounterService().getEncounters(encounterSearchCriteria).size());
}
use of org.openmrs.parameter.EncounterSearchCriteriaBuilder in project openmrs-core by openmrs.
the class EncounterServiceTest method getEncounters_shouldGetEncountersByType.
/**
* @see EncounterService#getEncounters(Patient, Location, Date, Date, java.util.Collection,
* java.util.Collection, java.util.Collection, boolean)
*/
@Test
public void getEncounters_shouldGetEncountersByType() {
List<EncounterType> types = new ArrayList<>();
types.add(new EncounterType(1));
EncounterSearchCriteria encounterSearchCriteria = new EncounterSearchCriteriaBuilder().setEncounterTypes(types).setIncludeVoided(true).createEncounterSearchCriteria();
List<Encounter> encounters = Context.getEncounterService().getEncounters(encounterSearchCriteria);
assertEquals(7, encounters.size());
}
use of org.openmrs.parameter.EncounterSearchCriteriaBuilder in project openmrs-core by openmrs.
the class EncounterServiceTest method getEncounters_shouldGetEncountersByVisitType.
/**
* @see EncounterService#getEncounters(Patient, Location, Date, Date, java.util.Collection,
* java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection,
* boolean)
*/
@Test
public void getEncounters_shouldGetEncountersByVisitType() {
List<VisitType> visitTypes = new ArrayList<>();
visitTypes.add(new VisitType(2));
EncounterSearchCriteria encounterSearchCriteria = new EncounterSearchCriteriaBuilder().setVisitTypes(visitTypes).setIncludeVoided(true).createEncounterSearchCriteria();
List<Encounter> encounters = Context.getEncounterService().getEncounters(encounterSearchCriteria);
assertEquals(2, encounters.size());
}
use of org.openmrs.parameter.EncounterSearchCriteriaBuilder in project openmrs-core by openmrs.
the class EncounterServiceTest method getEncounters_shouldExcludeVoidedEncounters.
/**
* @see EncounterService#getEncounters(Patient, Location, Date, Date, java.util.Collection,
* java.util.Collection, java.util.Collection, boolean)
*/
@Test
public void getEncounters_shouldExcludeVoidedEncounters() {
EncounterSearchCriteria encounterSearchCriteria = new EncounterSearchCriteriaBuilder().setIncludeVoided(false).createEncounterSearchCriteria();
assertEquals(6, Context.getEncounterService().getEncounters(encounterSearchCriteria).size());
}
Aggregations