Search in sources :

Example 6 with Diagnosis

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

the class DiagnosisServiceImplTest method getPrimaryDiagnoses_shouldGetPrimaryDiagnoses.

/**
 * @see DiagnosisService#getPrimaryDiagnoses(Encounter)
 */
@Test
public void getPrimaryDiagnoses_shouldGetPrimaryDiagnoses() {
    Encounter encounter = encounterService.getEncounterByUuid("y403fafb-e5e4-42d0-9d11-4f52e89d123r");
    List<Diagnosis> diagnoses = diagnosisService.getPrimaryDiagnoses(encounter);
    Assert.assertEquals(1, diagnoses.size());
    Assert.assertEquals("68802cce-6880-17e4-6880-a68804d22fb7", diagnoses.get(0).getUuid());
    Assert.assertEquals(ConditionVerificationStatus.CONFIRMED, diagnoses.get(0).getCertainty());
    Assert.assertEquals(new Integer(1), diagnoses.get(0).getDiagnosisId());
}
Also used : Encounter(org.openmrs.Encounter) Diagnosis(org.openmrs.Diagnosis) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 7 with Diagnosis

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

the class DiagnosisServiceImplTest method voidDiagnosis_shouldVoidDiagnosisSuccessfully.

/**
 * @see DiagnosisService#voidDiagnosis(Diagnosis, String)
 */
@Test
public void voidDiagnosis_shouldVoidDiagnosisSuccessfully() {
    String voidReason = "void reason";
    String uuid = "688804ce-6880-8804-6880-a68804d88047";
    Diagnosis nonVoidedDiagnosis = diagnosisService.getDiagnosisByUuid(uuid);
    Assert.assertFalse(nonVoidedDiagnosis.getVoided());
    Assert.assertNull(nonVoidedDiagnosis.getVoidedBy());
    Assert.assertNull(nonVoidedDiagnosis.getVoidReason());
    diagnosisService.voidDiagnosis(nonVoidedDiagnosis, voidReason);
    Diagnosis voidedDiagnosis = diagnosisService.getDiagnosisByUuid(uuid);
    Assert.assertTrue(voidedDiagnosis.getVoided());
    Assert.assertNotNull(voidedDiagnosis.getVoidedBy());
    Assert.assertNotNull(voidedDiagnosis.getDateVoided());
    Assert.assertEquals(voidReason, voidedDiagnosis.getVoidReason());
    Assert.assertEquals(Context.getAuthenticatedUser(), voidedDiagnosis.getVoidedBy());
}
Also used : Diagnosis(org.openmrs.Diagnosis) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 8 with Diagnosis

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

the class DiagnosisServiceImplTest method getDiagnoses_shouldGetDiagnosesOfPatientWithDate.

/**
 * @see DiagnosisService#getDiagnoses(Patient, Date)
 */
@Test
public void getDiagnoses_shouldGetDiagnosesOfPatientWithDate() {
    Calendar calendar = new GregorianCalendar(2015, 12, 1, 0, 0, 0);
    Patient patient = patientService.getPatient(2);
    List<Diagnosis> diagnoses = diagnosisService.getDiagnoses(patient, calendar.getTime());
    Assert.assertEquals(2, diagnoses.size());
    Assert.assertEquals("68802cce-6880-17e4-6880-a68804d22fb7", diagnoses.get(0).getUuid());
    Assert.assertEquals("688804ce-6880-8804-6880-a68804d88047", diagnoses.get(1).getUuid());
}
Also used : GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) Patient(org.openmrs.Patient) Diagnosis(org.openmrs.Diagnosis) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 9 with Diagnosis

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

the class DiagnosisServiceImplTest method getDiagnosisByUuid_shouldFindDiagnosisGivenValidUuid.

/**
 * @see DiagnosisService#getDiagnosisByUuid(String) (String)
 */
@Test
public void getDiagnosisByUuid_shouldFindDiagnosisGivenValidUuid() {
    String uuid = "68802cce-6880-17e4-6880-a68804d22fb7";
    Diagnosis diagnosis = diagnosisService.getDiagnosisByUuid(uuid);
    Assert.assertEquals(uuid, diagnosis.getUuid());
}
Also used : Diagnosis(org.openmrs.Diagnosis) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 10 with Diagnosis

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

the class HibernateDiagnosisDAOTest method shouldDeleteDiagnosis.

@Test
public void shouldDeleteDiagnosis() {
    String uuid = "4e663d66-6b78-11e0-93c3-18a905e044dc";
    Diagnosis diagnosis = diagnosisDAO.getDiagnosisByUuid(uuid);
    assertNotNull(diagnosis);
    diagnosisDAO.deleteDiagnosis(diagnosis);
    assertNull(diagnosisDAO.getDiagnosisByUuid(uuid));
}
Also used : Diagnosis(org.openmrs.Diagnosis) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

Diagnosis (org.openmrs.Diagnosis)18 Test (org.junit.Test)15 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)15 Patient (org.openmrs.Patient)6 Encounter (org.openmrs.Encounter)3 Calendar (java.util.Calendar)2 Date (java.util.Date)2 GregorianCalendar (java.util.GregorianCalendar)2 CodedOrFreeText (org.openmrs.CodedOrFreeText)2 Condition (org.openmrs.Condition)2 HashSet (java.util.HashSet)1 Before (org.junit.Before)1 Concept (org.openmrs.Concept)1 ConceptName (org.openmrs.ConceptName)1 User (org.openmrs.User)1 APIException (org.openmrs.api.APIException)1 Transactional (org.springframework.transaction.annotation.Transactional)1 BindException (org.springframework.validation.BindException)1