use of org.openmrs.Diagnosis in project openmrs-core by openmrs.
the class HibernateDiagnosisDAOTest method shouldGetDiagnosisById.
@Test
public void shouldGetDiagnosisById() {
Diagnosis diagnosis = diagnosisDAO.getDiagnosisById(1);
assertEquals("4e663d66-6b78-11e0-93c3-18a905e044dc", diagnosis.getUuid());
}
use of org.openmrs.Diagnosis in project openmrs-core by openmrs.
the class DiagnosisServiceImpl method getUniqueDiagnoses.
/**
* Gets unique diagnoses since date, sorted in reverse chronological order
*
* @param patient the patient whose diagnosis we are to get
* @param fromDate the date used to filter diagnosis which happened from this date and later
* @return the list of diagnoses
*/
@Override
@Transactional(readOnly = true)
public List<Diagnosis> getUniqueDiagnoses(Patient patient, Date fromDate) {
List<Diagnosis> diagnoses = getDiagnoses(patient, fromDate);
Set<CodedOrFreeText> answers = new HashSet<CodedOrFreeText>();
Iterator<Diagnosis> iterator = diagnoses.iterator();
while (iterator.hasNext()) {
Diagnosis diagnosis = iterator.next();
if (!answers.add(diagnosis.getDiagnosis())) {
iterator.remove();
}
}
return diagnoses;
}
use of org.openmrs.Diagnosis in project openmrs-core by openmrs.
the class DiagnosisServiceImplTest method purgeDiagnosis_shouldPurgeDiagnosis.
/**
* @see DiagnosisService#purgeDiagnosis(Diagnosis)
*/
@Test
public void purgeDiagnosis_shouldPurgeDiagnosis() {
String uuid = "77009cce-8804-17e4-8804-a68804d22fb7";
Diagnosis diagnosis = diagnosisService.getDiagnosisByUuid(uuid);
Assert.assertNotNull(diagnosis);
diagnosisService.purgeDiagnosis(diagnosis);
Diagnosis purgedDiagnosis = diagnosisService.getDiagnosisByUuid(uuid);
Assert.assertNull(purgedDiagnosis);
}
use of org.openmrs.Diagnosis in project openmrs-core by openmrs.
the class DiagnosisServiceImplTest method getDiagnoses_shouldGetDiagnosesOfPatientWithDifferentDate.
/**
* @see DiagnosisService#getDiagnoses(Patient, Date)
*/
@Test
public void getDiagnoses_shouldGetDiagnosesOfPatientWithDifferentDate() {
Calendar calendar = new GregorianCalendar(2016, 12, 1, 0, 0, 0);
Patient patient = patientService.getPatient(2);
List<Diagnosis> diagnoses = diagnosisService.getDiagnoses(patient, calendar.getTime());
Assert.assertEquals(1, diagnoses.size());
Assert.assertEquals("68802cce-6880-17e4-6880-a68804d22fb7", diagnoses.get(0).getUuid());
}
use of org.openmrs.Diagnosis 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());
}
Aggregations