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