Search in sources :

Example 1 with Condition

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

the class ConditionValidatorTest method shouldPassIfConditionClassIsPassedWithRequiredConditionProperties.

@Test
public void shouldPassIfConditionClassIsPassedWithRequiredConditionProperties() {
    Condition condition = new Condition();
    condition.setCondition(new CodedOrFreeText(new Concept(), new ConceptName("name", new Locale("en")), "nonCoded"));
    condition.setClinicalStatus(ConditionClinicalStatus.ACTIVE);
    validator.validate(condition, errors);
    Assert.assertFalse(errors.hasFieldErrors("condition"));
    Assert.assertFalse(errors.hasFieldErrors("clinicalStatus"));
}
Also used : Condition(org.openmrs.Condition) Concept(org.openmrs.Concept) Locale(java.util.Locale) ConceptName(org.openmrs.ConceptName) CodedOrFreeText(org.openmrs.CodedOrFreeText) Test(org.junit.Test)

Example 2 with Condition

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

the class HibernateConditionDAOTest method shouldSaveCondition.

@Test
public void shouldSaveCondition() {
    CodedOrFreeText codedOrFreeText = new CodedOrFreeText(new Concept(4), new ConceptName(5089), "non coded");
    ConditionClinicalStatus clinicalStatus = ConditionClinicalStatus.ACTIVE;
    ConditionVerificationStatus verificationStatus = ConditionVerificationStatus.CONFIRMED;
    Patient patient = new Patient(2);
    Date onsetDate = new Date();
    Date endDate = new Date();
    Condition previousVersion = dao.getConditionByUuid("2cc6880e-2c46-15e4-9038-a6c5e4d22fb7");
    String additionalDetail = "additionalDetail";
    int conditionId = 20;
    Condition condition = new Condition();
    condition.setConditionId(conditionId);
    condition.setCondition(codedOrFreeText);
    condition.setClinicalStatus(clinicalStatus);
    condition.setVerificationStatus(verificationStatus);
    condition.setPreviousVersion(previousVersion);
    condition.setAdditionalDetail(additionalDetail);
    condition.setOnsetDate(onsetDate);
    condition.setEndDate(endDate);
    condition.setPatient(patient);
    dao.saveCondition(condition);
    Condition savedCondition = dao.getCondition(conditionId);
    assertEquals(additionalDetail, savedCondition.getAdditionalDetail());
    assertEquals(conditionId, (int) savedCondition.getConditionId());
    assertEquals(onsetDate, savedCondition.getOnsetDate());
    assertEquals(endDate, savedCondition.getEndDate());
    assertEquals(clinicalStatus, savedCondition.getClinicalStatus());
    assertEquals(verificationStatus, savedCondition.getVerificationStatus());
    assertEquals(previousVersion, savedCondition.getPreviousVersion());
    assertEquals(patient, savedCondition.getPatient());
}
Also used : Concept(org.openmrs.Concept) Condition(org.openmrs.Condition) ConditionVerificationStatus(org.openmrs.ConditionVerificationStatus) ConditionClinicalStatus(org.openmrs.ConditionClinicalStatus) ConceptName(org.openmrs.ConceptName) Patient(org.openmrs.Patient) CodedOrFreeText(org.openmrs.CodedOrFreeText) Date(java.util.Date) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 3 with Condition

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

the class HibernateConditionDAOTest method shouldGetConditionHistory.

@Test
public void shouldGetConditionHistory() {
    Patient patient = new Patient(2);
    List<Condition> history = dao.getConditionHistory(patient);
    assertEquals(3, history.size());
}
Also used : Condition(org.openmrs.Condition) Patient(org.openmrs.Patient) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 4 with Condition

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

the class HibernateConditionDAOTest method shouldDeleteCondition.

@Test
public void shouldDeleteCondition() {
    String uuid = "2cc6880e-2c46-15e4-9038-a6c5e4d22fb7";
    Condition condition = dao.getConditionByUuid(uuid);
    Assert.assertNotNull(condition);
    dao.deleteCondition(condition);
    Assert.assertNull(dao.getConditionByUuid(uuid));
}
Also used : Condition(org.openmrs.Condition) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 5 with Condition

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

the class ConditionServiceImplTest method voidCondition_shouldVoidConditionSuccessfully.

/**
 * @see ConditionService#voidCondition(Condition, String)
 */
@Test
public void voidCondition_shouldVoidConditionSuccessfully() {
    Integer conditionId = 2;
    String voidReason = "Test Reason";
    Condition nonVoidedCondition = conditionService.getCondition(conditionId);
    Assert.assertFalse(nonVoidedCondition.getVoided());
    Assert.assertNull(nonVoidedCondition.getVoidReason());
    Assert.assertNull(nonVoidedCondition.getDateVoided());
    Assert.assertNull(nonVoidedCondition.getVoidedBy());
    conditionService.voidCondition(nonVoidedCondition, voidReason);
    Condition voidedCondition = conditionService.getCondition(conditionId);
    Assert.assertEquals(ConditionVerificationStatus.CONFIRMED, voidedCondition.getVerificationStatus());
    Assert.assertEquals(ConditionClinicalStatus.ACTIVE, voidedCondition.getClinicalStatus());
    Assert.assertEquals("2cc6880e-2c46-11e4-9138-a6c5e4d20fb7", voidedCondition.getUuid());
    Assert.assertTrue(voidedCondition.getVoided());
    Assert.assertEquals(voidReason, voidedCondition.getVoidReason());
    Assert.assertNotNull(voidedCondition.getDateVoided());
    Assert.assertEquals(Context.getAuthenticatedUser(), voidedCondition.getVoidedBy());
}
Also used : Condition(org.openmrs.Condition) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

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