Search in sources :

Example 16 with Diagnosis

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

the class DiagnosisServiceImplTest method getUniqueDiagnoses_shouldGetUniqueDiagnosesOfPatient.

/**
 * @see DiagnosisService#getUniqueDiagnoses(Patient, Date)
 */
@Test
public void getUniqueDiagnoses_shouldGetUniqueDiagnosesOfPatient() {
    Patient patient = patientService.getPatient(2);
    List<Diagnosis> diagnoses = diagnosisService.getUniqueDiagnoses(patient, new Date(0));
    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());
    Assert.assertEquals(new Integer(2), diagnoses.get(0).getPatient().getPatientId());
    Assert.assertEquals(1, diagnoses.size());
}
Also used : Patient(org.openmrs.Patient) Diagnosis(org.openmrs.Diagnosis) Date(java.util.Date) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 17 with Diagnosis

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

the class HibernateDiagnosisDAOTest method shouldGetDiagnosisByUuid.

@Test
public void shouldGetDiagnosisByUuid() {
    Diagnosis diagnosis = diagnosisDAO.getDiagnosisByUuid("4e663d66-6b78-11e0-93c3-18a905e044dc");
    assertEquals(1, (int) diagnosis.getId());
}
Also used : Diagnosis(org.openmrs.Diagnosis) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 18 with Diagnosis

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

the class HibernateDiagnosisDAOTest method shouldSaveDiagnosis.

@Test
public void shouldSaveDiagnosis() {
    CodedOrFreeText codedOrFreeText = new CodedOrFreeText(new Concept(4), new ConceptName(5089), "non coded");
    int diagnosisId = 5;
    Diagnosis diagnosis = new Diagnosis();
    diagnosis.setEncounter(new Encounter(3));
    diagnosis.setRank(2);
    diagnosis.setId(diagnosisId);
    diagnosis.setCertainty(ConditionVerificationStatus.CONFIRMED);
    diagnosis.setPatient(new Patient(2));
    diagnosis.setCondition(new Condition());
    diagnosis.setDiagnosis(codedOrFreeText);
    diagnosis.setUuid("4e663d96-6b78-11e0-93c3-18a9b5e044dc");
    diagnosis.setCreator(new User(1));
    diagnosis.setVoided(false);
    diagnosis.setDateCreated(new Date());
    diagnosisDAO.saveDiagnosis(diagnosis);
    Diagnosis savedDiagnosis = diagnosisDAO.getDiagnosisById(diagnosisId);
    assertEquals(diagnosis.getUuid(), savedDiagnosis.getUuid());
    assertEquals(diagnosis.getVoided(), savedDiagnosis.getVoided());
    assertEquals(diagnosis.getRank(), savedDiagnosis.getRank());
    assertEquals(diagnosis.getCertainty(), savedDiagnosis.getCertainty());
    assertEquals(diagnosis.getCreator(), savedDiagnosis.getCreator());
    assertEquals(diagnosis.getCondition(), savedDiagnosis.getCondition());
    assertEquals(diagnosis.getPatient(), savedDiagnosis.getPatient());
    assertEquals(diagnosis.getEncounter(), savedDiagnosis.getEncounter());
}
Also used : Concept(org.openmrs.Concept) Condition(org.openmrs.Condition) User(org.openmrs.User) ConceptName(org.openmrs.ConceptName) Encounter(org.openmrs.Encounter) Patient(org.openmrs.Patient) Diagnosis(org.openmrs.Diagnosis) CodedOrFreeText(org.openmrs.CodedOrFreeText) Date(java.util.Date) 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