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());
}
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]"));
}
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());
}
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());
}
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());
}
Aggregations