use of org.openmrs.Diagnosis in project openmrs-core by openmrs.
the class DiagnosisValidator method validate.
/**
* @see org.springframework.validation.Validator#validate(java.lang.Object,
* org.springframework.validation.Errors)
* @should fail validation if rank is null or a non-positive integer
* @should fail validation if certainty is null
* @should fail validation if diagnosis is null
* @should fail validation if encounter is null
*/
@Override
public void validate(Object o, Errors errors) {
Diagnosis diagnosis = (Diagnosis) o;
if (diagnosis == null) {
throw new APIException("Diagnosis can't be null");
} else if (diagnosis.getVoided()) {
return;
}
if (diagnosis.getEncounter() == null) {
errors.rejectValue("encounter", "error.null");
}
if (diagnosis.getDiagnosis() == null) {
errors.rejectValue("diagnosis", "error.null");
}
if (diagnosis.getCertainty() == null) {
errors.rejectValue("certainty", "error.null");
}
Integer rank = diagnosis.getRank();
if (rank == null) {
errors.rejectValue("rank", "error.null");
} else if (rank < 0) {
errors.rejectValue("rank", "error.rank.notPositiveInteger");
}
}
use of org.openmrs.Diagnosis in project openmrs-core by openmrs.
the class DiagnosisValidatorTest method setUp.
@Before
public void setUp() {
diagnosis = new Diagnosis();
errors = new BindException(diagnosis, "diagnosis");
}
use of org.openmrs.Diagnosis in project openmrs-core by openmrs.
the class DiagnosisServiceImplTest method getDiagnosisById_shouldFindDiagnosifGivenId.
/**
* @see DiagnosisService#getDiagnosis(Integer)
*/
@Test
public void getDiagnosisById_shouldFindDiagnosifGivenId() {
Integer diagnosisId = 1;
Diagnosis diagnosis = diagnosisService.getDiagnosis(diagnosisId);
Assert.assertEquals("68802cce-6880-17e4-6880-a68804d22fb7", diagnosis.getUuid());
Assert.assertEquals(ConditionVerificationStatus.CONFIRMED, diagnosis.getCertainty());
Assert.assertEquals(diagnosisId, diagnosis.getDiagnosisId());
}
use of org.openmrs.Diagnosis in project openmrs-core by openmrs.
the class DiagnosisServiceImplTest method getDiagnoses_shouldGetDiagnosesOfPatientWithoutDate.
/**
* @see DiagnosisService#getDiagnoses(Patient, Date)
*/
@Test
public void getDiagnoses_shouldGetDiagnosesOfPatientWithoutDate() {
Patient patient = patientService.getPatient(2);
List<Diagnosis> diagnoses = diagnosisService.getDiagnoses(patient, null);
Assert.assertEquals(3, diagnoses.size());
Assert.assertEquals("68802cce-6880-17e4-6880-a68804d22fb7", diagnoses.get(0).getUuid());
Assert.assertEquals("688804ce-6880-8804-6880-a68804d88047", diagnoses.get(1).getUuid());
Assert.assertEquals("88042cce-8804-17e4-8804-a68804d22fb7", diagnoses.get(2).getUuid());
}
use of org.openmrs.Diagnosis in project openmrs-core by openmrs.
the class DiagnosisServiceImplTest method unvoidDiagnosis_shouldUnvoidDiagnosisSuccessfully.
/**
* @see DiagnosisService#unvoidDiagnosis(Diagnosis)
*/
@Test
public void unvoidDiagnosis_shouldUnvoidDiagnosisSuccessfully() {
String uuid = "77009cce-8804-17e4-8804-a68804d22fb7";
Diagnosis voidedDiagnosis = diagnosisService.getDiagnosisByUuid(uuid);
Assert.assertTrue(voidedDiagnosis.getVoided());
Assert.assertNotNull(voidedDiagnosis.getVoidReason());
Assert.assertNotNull(voidedDiagnosis.getDateVoided());
Assert.assertNotNull(voidedDiagnosis.getVoidedBy());
diagnosisService.unvoidDiagnosis(voidedDiagnosis);
Diagnosis unVoidedDiagnosis = diagnosisService.getDiagnosisByUuid(uuid);
Assert.assertEquals(ConditionVerificationStatus.PROVISIONAL, unVoidedDiagnosis.getCertainty());
Assert.assertEquals(uuid, unVoidedDiagnosis.getUuid());
Assert.assertFalse(unVoidedDiagnosis.getVoided());
Assert.assertNull(unVoidedDiagnosis.getVoidReason());
Assert.assertNull(unVoidedDiagnosis.getDateVoided());
Assert.assertNull(unVoidedDiagnosis.getVoidedBy());
}
Aggregations