Search in sources :

Example 16 with ConceptAnswer

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

the class ConceptServiceTest method changeConceptFromBooleanToCoded_shouldExplicitlyAddFalseConceptAsAValue_CodedAnswer.

/**
 * @see ConceptService#convertBooleanConceptToCoded(Concept)
 */
@Test
public void changeConceptFromBooleanToCoded_shouldExplicitlyAddFalseConceptAsAValue_CodedAnswer() {
    Concept concept = conceptService.getConcept(18);
    Collection<ConceptAnswer> answers = concept.getAnswers(false);
    boolean falseConceptFound = false;
    // initially the concept shouldn't present
    for (ConceptAnswer conceptAnswer : answers) {
        if (conceptAnswer.getAnswerConcept().equals(conceptService.getFalseConcept())) {
            falseConceptFound = true;
        }
    }
    Assert.assertEquals(false, falseConceptFound);
    conceptService.convertBooleanConceptToCoded(concept);
    answers = concept.getAnswers(false);
    for (ConceptAnswer conceptAnswer : answers) {
        if (conceptAnswer.getAnswerConcept().equals(conceptService.getFalseConcept())) {
            falseConceptFound = true;
        }
    }
    Assert.assertEquals(true, falseConceptFound);
}
Also used : OpenmrsMatchers.hasConcept(org.openmrs.test.OpenmrsMatchers.hasConcept) Concept(org.openmrs.Concept) ConceptAnswer(org.openmrs.ConceptAnswer) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 17 with ConceptAnswer

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

the class ConceptServiceTest method changeConceptFromBooleanToCoded_shouldExplicitlyAddTrueConceptAsAValue_CodedAnswer.

/**
 * @see ConceptService#convertBooleanConceptToCoded(Concept)
 */
@Test
public void changeConceptFromBooleanToCoded_shouldExplicitlyAddTrueConceptAsAValue_CodedAnswer() {
    Concept concept = conceptService.getConcept(18);
    Collection<ConceptAnswer> answers = concept.getAnswers(false);
    boolean trueConceptFound = false;
    for (ConceptAnswer conceptAnswer : answers) {
        if (conceptAnswer.getAnswerConcept().equals(conceptService.getTrueConcept())) {
            trueConceptFound = true;
        }
    }
    Assert.assertEquals(false, trueConceptFound);
    conceptService.convertBooleanConceptToCoded(concept);
    answers = concept.getAnswers(false);
    for (ConceptAnswer conceptAnswer : answers) {
        if (conceptAnswer.getAnswerConcept().equals(conceptService.getTrueConcept())) {
            trueConceptFound = true;
        }
    }
    Assert.assertEquals(true, trueConceptFound);
}
Also used : OpenmrsMatchers.hasConcept(org.openmrs.test.OpenmrsMatchers.hasConcept) Concept(org.openmrs.Concept) ConceptAnswer(org.openmrs.ConceptAnswer) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Aggregations

ConceptAnswer (org.openmrs.ConceptAnswer)17 Concept (org.openmrs.Concept)12 Test (org.junit.Test)8 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)6 ArrayList (java.util.ArrayList)5 ConceptName (org.openmrs.ConceptName)4 Date (java.util.Date)2 HashSet (java.util.HashSet)2 Locale (java.util.Locale)2 Map (java.util.Map)2 ConceptMap (org.openmrs.ConceptMap)2 Drug (org.openmrs.Drug)2 ConceptService (org.openmrs.api.ConceptService)2 OpenmrsMatchers.hasConcept (org.openmrs.test.OpenmrsMatchers.hasConcept)2 HL7Exception (ca.uhn.hl7v2.HL7Exception)1 Type (ca.uhn.hl7v2.model.Type)1 Varies (ca.uhn.hl7v2.model.Varies)1 CE (ca.uhn.hl7v2.model.v25.datatype.CE)1 CWE (ca.uhn.hl7v2.model.v25.datatype.CWE)1 DT (ca.uhn.hl7v2.model.v25.datatype.DT)1