Search in sources :

Example 11 with VisitAttributeType

use of org.openmrs.VisitAttributeType in project openmrs-core by openmrs.

the class VisitServiceTest method unretireVisitAttributeType_shouldUnretireARetiredVisitAttributeType.

/**
 * @see VisitService#unretireVisitAttributeType(VisitAttributeType)
 */
@Test
public void unretireVisitAttributeType_shouldUnretireARetiredVisitAttributeType() {
    executeDataSet(VISITS_ATTRIBUTES_XML);
    VisitAttributeType vat = visitService.getVisitAttributeType(2);
    assertTrue(vat.getRetired());
    assertNotNull(vat.getDateRetired());
    assertNotNull(vat.getRetiredBy());
    assertNotNull(vat.getRetireReason());
    visitService.unretireVisitAttributeType(vat);
    Assert.assertFalse(vat.getRetired());
    assertNull(vat.getDateRetired());
    assertNull(vat.getRetiredBy());
    assertNull(vat.getRetireReason());
}
Also used : VisitAttributeType(org.openmrs.VisitAttributeType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 12 with VisitAttributeType

use of org.openmrs.VisitAttributeType in project openmrs-core by openmrs.

the class VisitServiceTest method retireVisitAttributeType_shouldRetireAVisitAttributeType.

/**
 * @see VisitService#retireVisitAttributeType(VisitAttributeType,String)
 */
@Test
public void retireVisitAttributeType_shouldRetireAVisitAttributeType() {
    executeDataSet(VISITS_ATTRIBUTES_XML);
    VisitAttributeType vat = visitService.getVisitAttributeType(1);
    Assert.assertFalse(vat.getRetired());
    visitService.retireVisitAttributeType(vat, "for testing");
    vat = visitService.getVisitAttributeType(1);
    assertTrue(vat.getRetired());
    assertNotNull(vat.getRetiredBy());
    assertNotNull(vat.getDateRetired());
    assertEquals("for testing", vat.getRetireReason());
}
Also used : VisitAttributeType(org.openmrs.VisitAttributeType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 13 with VisitAttributeType

use of org.openmrs.VisitAttributeType 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());
}
Also used : Visit(org.openmrs.Visit) VisitAttributeType(org.openmrs.VisitAttributeType) VisitAttribute(org.openmrs.VisitAttribute) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 14 with VisitAttributeType

use of org.openmrs.VisitAttributeType in project openmrs-core by openmrs.

the class VisitAttributeTypeValidatorTest method validate_shouldFailValidationIfFieldLengthsAreNotCorrect.

/**
 * @see VisitAttributeTypeValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldFailValidationIfFieldLengthsAreNotCorrect() {
    VisitAttributeType visitAttributeType = new VisitAttributeType();
    visitAttributeType.setName("too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text");
    visitAttributeType.setMinOccurs(1);
    visitAttributeType.setDatatypeConfig("[a-z]+");
    visitAttributeType.setDatatypeClassname("too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text");
    visitAttributeType.setDescription(new String(new char[66000]));
    visitAttributeType.setPreferredHandlerClassname("too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text");
    visitAttributeType.setRetireReason("too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text");
    Errors errors = new BindException(visitAttributeType, "visitAttributeType");
    new VisitAttributeTypeValidator().validate(visitAttributeType, errors);
    Assert.assertTrue(errors.hasFieldErrors("name"));
    Assert.assertTrue(errors.hasFieldErrors("description"));
    Assert.assertTrue(errors.hasFieldErrors("datatypeClassname"));
    Assert.assertTrue(errors.hasFieldErrors("preferredHandlerClassname"));
    Assert.assertTrue(errors.hasFieldErrors("retireReason"));
}
Also used : Errors(org.springframework.validation.Errors) VisitAttributeType(org.openmrs.VisitAttributeType) BindException(org.springframework.validation.BindException) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 15 with VisitAttributeType

use of org.openmrs.VisitAttributeType in project openmrs-core by openmrs.

the class VisitAttributeTypeValidatorTest method validate_shouldPassValidationIfFieldLengthsAreCorrect.

/**
 * @see VisitAttributeTypeValidator#validate(Object, org.springframework.validation.Errors)
 */
@Test
public void validate_shouldPassValidationIfFieldLengthsAreCorrect() {
    VisitAttributeType visitAttributeType = new VisitAttributeType();
    visitAttributeType.setName("name");
    visitAttributeType.setMinOccurs(1);
    visitAttributeType.setDatatypeConfig("[a-z]+");
    visitAttributeType.setDatatypeClassname(RegexValidatedTextDatatype.class.getName());
    visitAttributeType.setDescription("some text");
    visitAttributeType.setRetireReason("some text");
    Errors errors = new BindException(visitAttributeType, "visitAttributeType");
    new VisitAttributeTypeValidator().validate(visitAttributeType, errors);
    Assert.assertFalse(errors.hasErrors());
}
Also used : Errors(org.springframework.validation.Errors) VisitAttributeType(org.openmrs.VisitAttributeType) BindException(org.springframework.validation.BindException) RegexValidatedTextDatatype(org.openmrs.customdatatype.datatype.RegexValidatedTextDatatype) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

VisitAttributeType (org.openmrs.VisitAttributeType)17 Test (org.junit.Test)9 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)9 Visit (org.openmrs.Visit)7 VisitAttribute (org.openmrs.VisitAttribute)5 Date (java.util.Date)4 APIException (org.openmrs.api.APIException)3 BindException (org.springframework.validation.BindException)3 SimpleDateFormat (java.text.SimpleDateFormat)2 VisitType (org.openmrs.VisitType)2 PatientDomainWrapper (org.openmrs.module.emrapi.patient.PatientDomainWrapper)2 VisitDomainWrapper (org.openmrs.module.emrapi.visit.VisitDomainWrapper)2 SimpleObject (org.openmrs.ui.framework.SimpleObject)2 ObjectResult (org.openmrs.ui.framework.fragment.action.ObjectResult)2 Transactional (org.springframework.transaction.annotation.Transactional)2 BindingResult (org.springframework.validation.BindingResult)2 Errors (org.springframework.validation.Errors)2 Criteria (org.hibernate.Criteria)1 Before (org.junit.Before)1 Patient (org.openmrs.Patient)1