use of org.openmrs.VisitAttribute in project openmrs-core by openmrs.
the class VisitServiceTest method createVisitAttributeWithoutCreatorAndDateCreated.
private VisitAttribute createVisitAttributeWithoutCreatorAndDateCreated() {
VisitAttribute visitAttribute = new VisitAttribute();
VisitAttributeType attributeType = visitService.getVisitAttributeType(1);
attributeType.setName("visit type");
visitAttribute.setValue(new Date());
visitAttribute.setAttributeType(attributeType);
return visitAttribute;
}
use of org.openmrs.VisitAttribute in project openmrs-core by openmrs.
the class VisitServiceTest method saveVisit_shouldVoidAnAttributeIfMaxOccursIs1AndSameAttributeTypeAlreadyExists.
/**
* @see VisitService#saveVisit(Visit)
*/
@Test
public void saveVisit_shouldVoidAnAttributeIfMaxOccursIs1AndSameAttributeTypeAlreadyExists() {
executeDataSet(VISITS_ATTRIBUTES_XML);
Visit visit = new Visit(new Patient(2), new VisitType(3), new Date());
visit.setAttribute(createVisitAttribute(new Date()));
visit.setAttribute(createVisitAttribute(new Date(System.currentTimeMillis() - 1000000)));
assertEquals(1, visit.getAttributes().size());
visit = visitService.saveVisit(visit);
assertNotNull(visit.getId());
visit.setAttribute(createVisitAttribute("second visit"));
assertEquals(2, visit.getAttributes().size());
VisitAttribute firstAttribute = (VisitAttribute) visit.getAttributes().toArray()[0];
assertTrue(firstAttribute.getVoided());
}
use of org.openmrs.VisitAttribute in project openmrs-core by openmrs.
the class VisitServiceTest method shouldVoidASimpleAttribute.
@Test
public void shouldVoidASimpleAttribute() {
executeDataSet(VISITS_ATTRIBUTES_XML);
Visit visit = visitService.getVisit(1);
VisitAttributeType attrType = visitService.getVisitAttributeType(1);
List<VisitAttribute> attributes = visit.getActiveAttributes(attrType);
assertTrue(attributes.size() > 0);
VisitAttribute attribute = attributes.get(0);
attribute.setVoided(true);
visitService.saveVisit(visit);
assertNotNull(attribute.getVoidedBy());
assertNotNull(attribute.getDateVoided());
}
Aggregations