Search in sources :

Example 36 with ConceptDatatype

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

the class ConceptValidatorTest method validate_shouldPassIfTheConceptHasAtleastOneFullySpecifiedNameAddedToIt.

@Test
public void validate_shouldPassIfTheConceptHasAtleastOneFullySpecifiedNameAddedToIt() {
    concept.addName(new ConceptName("one name", Context.getLocale()));
    concept.addDescription(new ConceptDescription("some description", null));
    concept.setConceptClass(new ConceptClass());
    concept.setDatatype(new ConceptDatatype());
    validator.validate(concept, errors);
    Assert.assertFalse(errors.hasErrors());
}
Also used : ConceptClass(org.openmrs.ConceptClass) ConceptName(org.openmrs.ConceptName) ConceptDescription(org.openmrs.ConceptDescription) ConceptDatatype(org.openmrs.ConceptDatatype) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 37 with ConceptDatatype

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

the class ConceptValidatorTest method validate_shouldFailIfATermIsMappedMultipleTimesToTheSameConcept.

@Test
public void validate_shouldFailIfATermIsMappedMultipleTimesToTheSameConcept() {
    concept.setConceptClass(new ConceptClass());
    concept.setDatatype(new ConceptDatatype());
    concept.addName(new ConceptName("my name", Context.getLocale()));
    concept.addDescription(new ConceptDescription("some description", null));
    ConceptMap map1 = new ConceptMap(conceptService.getConceptReferenceTerm(1), conceptService.getConceptMapType(1));
    concept.addConceptMapping(map1);
    ConceptMap map2 = new ConceptMap(conceptService.getConceptReferenceTerm(1), conceptService.getConceptMapType(1));
    concept.addConceptMapping(map2);
    validator.validate(concept, errors);
    assertThat(errors, hasFieldErrors("conceptMappings[1]"));
}
Also used : ConceptClass(org.openmrs.ConceptClass) ConceptName(org.openmrs.ConceptName) ConceptDescription(org.openmrs.ConceptDescription) ConceptMap(org.openmrs.ConceptMap) ConceptDatatype(org.openmrs.ConceptDatatype) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 38 with ConceptDatatype

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

the class ConceptValidatorTest method validate_shouldPassIfDifferentConceptsHaveTheSameShortNames.

@Test
public void validate_shouldPassIfDifferentConceptsHaveTheSameShortNames() {
    Context.setLocale(new Locale("en", "GB"));
    List<Concept> concepts = conceptService.getConceptsByName("HSM");
    Assert.assertEquals(1, concepts.size());
    Assert.assertEquals(true, concepts.get(0).getShortNameInLocale(Context.getLocale()).getName().equalsIgnoreCase("HSM"));
    concept.setConceptClass(new ConceptClass());
    concept.setDatatype(new ConceptDatatype());
    ConceptName conceptFullySpecifiedName = new ConceptName("holosystolic murmur", Context.getLocale());
    conceptFullySpecifiedName.setConceptNameType(ConceptNameType.FULLY_SPECIFIED);
    ConceptName conceptShortName = new ConceptName("HSM", Context.getLocale());
    conceptShortName.setConceptNameType(ConceptNameType.SHORT);
    concept.addName(conceptFullySpecifiedName);
    concept.addName(conceptShortName);
    concept.addDescription(new ConceptDescription("some description", null));
    validator.validate(concept, errors);
    Assert.assertFalse(errors.hasErrors());
}
Also used : Locale(java.util.Locale) Concept(org.openmrs.Concept) ConceptClass(org.openmrs.ConceptClass) ConceptName(org.openmrs.ConceptName) ConceptDescription(org.openmrs.ConceptDescription) ConceptDatatype(org.openmrs.ConceptDatatype) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 39 with ConceptDatatype

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

the class ConceptValidatorTest method validate_shouldPassIfNoneofTheConceptDescriptionsIsNull.

@Test
public void validate_shouldPassIfNoneofTheConceptDescriptionsIsNull() {
    concept.addName(new ConceptName("some name", Context.getLocale()));
    concept.addDescription(new ConceptDescription("some description", null));
    concept.setConceptClass(new ConceptClass());
    concept.setDatatype(new ConceptDatatype());
    validator.validate(concept, errors);
    Assert.assertFalse(errors.hasErrors());
}
Also used : ConceptClass(org.openmrs.ConceptClass) ConceptName(org.openmrs.ConceptName) ConceptDescription(org.openmrs.ConceptDescription) ConceptDatatype(org.openmrs.ConceptDatatype) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 40 with ConceptDatatype

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

the class ObsValidatorTest method validate_shouldPassIfAnswerConceptAndConceptOfValueDrugMatch.

/**
 * @see ObsValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldPassIfAnswerConceptAndConceptOfValueDrugMatch() {
    Obs obs = new Obs();
    obs.setPerson(new Person(7));
    obs.setObsDatetime(new Date());
    Concept questionConcept = new Concept(100);
    ConceptDatatype dt = new ConceptDatatype(1);
    dt.setUuid(ConceptDatatype.CODED_UUID);
    questionConcept.setDatatype(dt);
    obs.setConcept(questionConcept);
    Concept answerConcept = new Concept(101);
    obs.setValueCoded(answerConcept);
    Drug drug = new Drug();
    drug.setConcept(answerConcept);
    obs.setValueDrug(drug);
    Errors errors = new BindException(obs, "obs");
    obsValidator.validate(obs, errors);
    assertFalse(errors.hasFieldErrors());
}
Also used : Concept(org.openmrs.Concept) Drug(org.openmrs.Drug) Obs(org.openmrs.Obs) Errors(org.springframework.validation.Errors) BindException(org.springframework.validation.BindException) Person(org.openmrs.Person) ConceptDatatype(org.openmrs.ConceptDatatype) Date(java.util.Date) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

ConceptDatatype (org.openmrs.ConceptDatatype)54 Test (org.junit.Test)49 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)45 ConceptClass (org.openmrs.ConceptClass)38 ConceptName (org.openmrs.ConceptName)34 Concept (org.openmrs.Concept)32 ConceptDescription (org.openmrs.ConceptDescription)32 OpenmrsMatchers.hasConcept (org.openmrs.test.OpenmrsMatchers.hasConcept)13 Locale (java.util.Locale)12 BindException (org.springframework.validation.BindException)7 Errors (org.springframework.validation.Errors)7 Date (java.util.Date)4 ConceptNumeric (org.openmrs.ConceptNumeric)4 Obs (org.openmrs.Obs)4 ConceptMap (org.openmrs.ConceptMap)3 ConceptBuilder (org.openmrs.module.emrapi.test.builder.ConceptBuilder)3 ConceptComplex (org.openmrs.ConceptComplex)2 ConceptMapType (org.openmrs.ConceptMapType)2 ConceptSearchResult (org.openmrs.ConceptSearchResult)2 ConceptSource (org.openmrs.ConceptSource)2