Search in sources :

Example 6 with Condition

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

the class ConditionServiceImplTest method getCondition_shouldFindConditionGivenValidId.

/**
 * @see ConditionService#getCondition(Integer)
 */
@Test
public void getCondition_shouldFindConditionGivenValidId() {
    Condition condition = conditionService.getCondition(1);
    Assert.assertEquals(ConditionClinicalStatus.INACTIVE, condition.getClinicalStatus());
    Assert.assertEquals(ConditionVerificationStatus.PROVISIONAL, condition.getVerificationStatus());
    Assert.assertEquals("2cc6880e-2c46-15e4-9038-a6c5e4d22fb7", condition.getUuid());
}
Also used : Condition(org.openmrs.Condition) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 7 with Condition

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

the class ConditionServiceImplTest method saveCondition_shouldSaveNewCondition.

/**
 * @see ConditionService#saveCondition(Condition)
 */
@Test
public void saveCondition_shouldSaveNewCondition() {
    Integer patientId = 2;
    String uuid = "08002000-4469-12q3-551f-0339000c9a76";
    CodedOrFreeText codedOrFreeText = new CodedOrFreeText();
    Condition condition = new Condition();
    condition.setCondition(codedOrFreeText);
    condition.setClinicalStatus(ConditionClinicalStatus.ACTIVE);
    condition.setUuid(uuid);
    condition.setPatient(new Patient(patientId));
    conditionService.saveCondition(condition);
    Condition savedCondition = conditionService.getConditionByUuid(uuid);
    Assert.assertEquals(patientId, savedCondition.getPatient().getPatientId());
    Assert.assertEquals(uuid, savedCondition.getUuid());
    Assert.assertEquals(codedOrFreeText, savedCondition.getCondition());
    Assert.assertEquals(ConditionClinicalStatus.ACTIVE, savedCondition.getClinicalStatus());
    Assert.assertNotNull(savedCondition.getConditionId());
}
Also used : Condition(org.openmrs.Condition) Patient(org.openmrs.Patient) CodedOrFreeText(org.openmrs.CodedOrFreeText) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 8 with Condition

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

the class ConditionServiceImplTest method getConditionByUuid_shouldFindConditionGivenValidUuid.

/**
 * @see ConditionService#getConditionByUuid(String)
 */
@Test
public void getConditionByUuid_shouldFindConditionGivenValidUuid() {
    String uuid = "2cc6880e-2c46-15e4-9038-a6c5e4d22fb7";
    Condition condition = conditionService.getConditionByUuid(uuid);
    Assert.assertEquals(uuid, condition.getUuid());
}
Also used : Condition(org.openmrs.Condition) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 9 with Condition

use of org.openmrs.Condition in project openmrs-module-pihcore by PIH.

the class ConditionListVelocityContextContentProvider method getActiveConditionsConcepts.

protected List<Concept> getActiveConditionsConcepts(Patient patient) {
    List<Condition> conditionList = getActiveConditions(patient);
    List<Concept> conditionListConcepts = new ArrayList<Concept>();
    for (Condition condition : conditionList) {
        if (condition.getCondition().getCoded() != null) {
            conditionListConcepts.add(condition.getCondition().getCoded());
        }
    }
    return conditionListConcepts;
}
Also used : Condition(org.openmrs.Condition) Concept(org.openmrs.Concept) ArrayList(java.util.ArrayList)

Example 10 with Condition

use of org.openmrs.Condition in project openmrs-module-pihcore by PIH.

the class ConditionListVelocityContextContentProvider method populateContext.

@Override
public void populateContext(FormEntrySession formEntrySession, VelocityContext velocityContext) {
    Patient patient = formEntrySession.getPatient();
    List<Condition> conditionList = getActiveConditions(patient);
    List<Concept> conditionListConcepts = getActiveConditionsConcepts(patient);
    velocityContext.put("conditionList", conditionList);
    velocityContext.put("conditionListConcepts", conditionListConcepts);
}
Also used : Condition(org.openmrs.Condition) Concept(org.openmrs.Concept) Patient(org.openmrs.Patient)

Aggregations

Condition (org.openmrs.Condition)19 Test (org.junit.Test)16 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)14 Patient (org.openmrs.Patient)7 Concept (org.openmrs.Concept)5 CodedOrFreeText (org.openmrs.CodedOrFreeText)4 ConceptName (org.openmrs.ConceptName)3 ConditionClinicalStatus (org.openmrs.ConditionClinicalStatus)3 ConditionVerificationStatus (org.openmrs.ConditionVerificationStatus)3 Date (java.util.Date)2 Diagnosis (org.openmrs.Diagnosis)2 Encounter (org.openmrs.Encounter)2 ArrayList (java.util.ArrayList)1 Locale (java.util.Locale)1 Before (org.junit.Before)1 User (org.openmrs.User)1 BindException (org.springframework.validation.BindException)1