use of org.openmrs.Condition in project openmrs-core by openmrs.
the class DiagnosisServiceImplTest method saveDiagnosis_shouldSaveNewDiagnosis.
/**
* @see DiagnosisService#save(Diagnosis)
*/
@Test
public void saveDiagnosis_shouldSaveNewDiagnosis() {
String uuid = "a303bbfb-w5w4-25d1-9f11-4f33f99d456r";
Condition condition = conditionService.getConditionByUuid("2cc6880e-2c46-15e4-9038-a6c5e4d22fb7");
Encounter encounter = encounterService.getEncounterByUuid("y403fafb-e5e4-42d0-9d11-4f52e89d123r");
Patient patient = patientService.getPatient(2);
Diagnosis diagnosis = new Diagnosis();
diagnosis.setUuid(uuid);
diagnosis.setEncounter(encounter);
diagnosis.setCondition(condition);
diagnosis.setCertainty(ConditionVerificationStatus.CONFIRMED);
diagnosis.setPatient(patient);
diagnosis.setRank(2);
diagnosisService.save(diagnosis);
Diagnosis savedDiagnosis = diagnosisService.getDiagnosisByUuid(uuid);
Assert.assertEquals(uuid, savedDiagnosis.getUuid());
Assert.assertEquals(condition, savedDiagnosis.getCondition());
Assert.assertEquals(encounter, savedDiagnosis.getEncounter());
Assert.assertEquals(patient, savedDiagnosis.getPatient());
Assert.assertEquals(ConditionVerificationStatus.CONFIRMED, savedDiagnosis.getCertainty());
Assert.assertEquals(new Integer(2), savedDiagnosis.getRank());
}
use of org.openmrs.Condition in project openmrs-core by openmrs.
the class HibernateConditionDAOTest method shouldGetCondition.
@Test
public void shouldGetCondition() {
int id = 1;
ConditionClinicalStatus expectedClinicalStatus = ConditionClinicalStatus.INACTIVE;
ConditionVerificationStatus expectedVerificationStatus = ConditionVerificationStatus.PROVISIONAL;
Condition condition = dao.getCondition(id);
assertEquals(expectedClinicalStatus, condition.getClinicalStatus());
assertEquals(expectedVerificationStatus, condition.getVerificationStatus());
assertEquals(1, (int) condition.getId());
assertEquals(null, condition.getEndDate());
assertEquals(1, (int) condition.getCreator().getId());
}
use of org.openmrs.Condition in project openmrs-core by openmrs.
the class HibernateConditionDAOTest method shouldGetActiveConditions.
@Test
public void shouldGetActiveConditions() {
Patient patient = new Patient(2);
List<Condition> active = dao.getActiveConditions(patient);
assertEquals(2, active.size());
}
use of org.openmrs.Condition in project openmrs-core by openmrs.
the class HibernateConditionDAOTest method shouldGetConditionByUuid.
@Test
public void shouldGetConditionByUuid() {
String uuid = "2cc6880e-2c46-15e4-9038-a6c5e4d22fb7";
ConditionClinicalStatus expectedClinicalStatus = ConditionClinicalStatus.INACTIVE;
ConditionVerificationStatus expectedVerificationStatus = ConditionVerificationStatus.PROVISIONAL;
Condition condition = dao.getConditionByUuid(uuid);
assertEquals(condition.getClinicalStatus(), expectedClinicalStatus);
assertEquals(condition.getVerificationStatus(), expectedVerificationStatus);
assertEquals(1, (int) condition.getId());
assertEquals(null, condition.getEndDate());
assertEquals(1, (int) condition.getCreator().getId());
}
use of org.openmrs.Condition in project openmrs-core by openmrs.
the class ConditionServiceImplTest method unvoidCondition_shouldUnvoidConditionSuccessfully.
/**
* @see ConditionService#unvoidCondition(Condition)
*/
@Test
public void unvoidCondition_shouldUnvoidConditionSuccessfully() {
Condition voidedCondition = conditionService.voidCondition(conditionService.getCondition(4), "Test Reason");
Assert.assertTrue(voidedCondition.getVoided());
Assert.assertNotNull(voidedCondition.getVoidReason());
Assert.assertNotNull(voidedCondition.getDateVoided());
Assert.assertEquals(new Integer(1), voidedCondition.getVoidedBy().getUserId());
Condition unVoidedCondition = conditionService.unvoidCondition(voidedCondition);
Assert.assertEquals(ConditionVerificationStatus.CONFIRMED, unVoidedCondition.getVerificationStatus());
Assert.assertEquals(ConditionClinicalStatus.ACTIVE, unVoidedCondition.getClinicalStatus());
Assert.assertEquals("2cb6880e-2cd6-11e4-9138-a6c5e4d20fb7", unVoidedCondition.getUuid());
Assert.assertFalse(unVoidedCondition.getVoided());
Assert.assertNull(unVoidedCondition.getVoidReason());
Assert.assertNull(unVoidedCondition.getDateVoided());
Assert.assertNull(unVoidedCondition.getVoidedBy());
}
Aggregations