Search in sources :

Example 11 with Condition

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());
}
Also used : Condition(org.openmrs.Condition) Encounter(org.openmrs.Encounter) Patient(org.openmrs.Patient) Diagnosis(org.openmrs.Diagnosis) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 12 with Condition

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());
}
Also used : Condition(org.openmrs.Condition) ConditionVerificationStatus(org.openmrs.ConditionVerificationStatus) ConditionClinicalStatus(org.openmrs.ConditionClinicalStatus) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 13 with Condition

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());
}
Also used : Condition(org.openmrs.Condition) Patient(org.openmrs.Patient) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 14 with Condition

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());
}
Also used : Condition(org.openmrs.Condition) ConditionVerificationStatus(org.openmrs.ConditionVerificationStatus) ConditionClinicalStatus(org.openmrs.ConditionClinicalStatus) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 15 with Condition

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