use of org.openmrs.CodedOrFreeText in project openmrs-core by openmrs.
the class ConditionValidatorTest method shouldPassIfConditionClassIsPassedWithRequiredConditionProperties.
@Test
public void shouldPassIfConditionClassIsPassedWithRequiredConditionProperties() {
Condition condition = new Condition();
condition.setCondition(new CodedOrFreeText(new Concept(), new ConceptName("name", new Locale("en")), "nonCoded"));
condition.setClinicalStatus(ConditionClinicalStatus.ACTIVE);
validator.validate(condition, errors);
Assert.assertFalse(errors.hasFieldErrors("condition"));
Assert.assertFalse(errors.hasFieldErrors("clinicalStatus"));
}
use of org.openmrs.CodedOrFreeText in project openmrs-core by openmrs.
the class DiagnosisValidatorTest method validate_shouldPassValidationIfAllRequiredFieldsAreSupplied.
@Test
public void validate_shouldPassValidationIfAllRequiredFieldsAreSupplied() {
diagnosis.setEncounter(new Encounter());
diagnosis.setDiagnosis(new CodedOrFreeText());
diagnosis.setCertainty(ConditionVerificationStatus.CONFIRMED);
diagnosis.setRank(1);
Assert.assertFalse(errors.hasErrors());
}
use of org.openmrs.CodedOrFreeText in project openmrs-core by openmrs.
the class HibernateConditionDAOTest method shouldSaveCondition.
@Test
public void shouldSaveCondition() {
CodedOrFreeText codedOrFreeText = new CodedOrFreeText(new Concept(4), new ConceptName(5089), "non coded");
ConditionClinicalStatus clinicalStatus = ConditionClinicalStatus.ACTIVE;
ConditionVerificationStatus verificationStatus = ConditionVerificationStatus.CONFIRMED;
Patient patient = new Patient(2);
Date onsetDate = new Date();
Date endDate = new Date();
Condition previousVersion = dao.getConditionByUuid("2cc6880e-2c46-15e4-9038-a6c5e4d22fb7");
String additionalDetail = "additionalDetail";
int conditionId = 20;
Condition condition = new Condition();
condition.setConditionId(conditionId);
condition.setCondition(codedOrFreeText);
condition.setClinicalStatus(clinicalStatus);
condition.setVerificationStatus(verificationStatus);
condition.setPreviousVersion(previousVersion);
condition.setAdditionalDetail(additionalDetail);
condition.setOnsetDate(onsetDate);
condition.setEndDate(endDate);
condition.setPatient(patient);
dao.saveCondition(condition);
Condition savedCondition = dao.getCondition(conditionId);
assertEquals(additionalDetail, savedCondition.getAdditionalDetail());
assertEquals(conditionId, (int) savedCondition.getConditionId());
assertEquals(onsetDate, savedCondition.getOnsetDate());
assertEquals(endDate, savedCondition.getEndDate());
assertEquals(clinicalStatus, savedCondition.getClinicalStatus());
assertEquals(verificationStatus, savedCondition.getVerificationStatus());
assertEquals(previousVersion, savedCondition.getPreviousVersion());
assertEquals(patient, savedCondition.getPatient());
}
use of org.openmrs.CodedOrFreeText in project openmrs-core by openmrs.
the class ConditionServiceImplTest method saveCondition_shouldSaveNewCondition.
/**
* @see ConditionService#saveCondition(Condition)
*/
@Test
public void saveCondition_shouldSaveNewCondition() {
Integer patientId = 2;
String uuid = "08002000-4469-12q3-551f-0339000c9a76";
CodedOrFreeText codedOrFreeText = new CodedOrFreeText();
Condition condition = new Condition();
condition.setCondition(codedOrFreeText);
condition.setClinicalStatus(ConditionClinicalStatus.ACTIVE);
condition.setUuid(uuid);
condition.setPatient(new Patient(patientId));
conditionService.saveCondition(condition);
Condition savedCondition = conditionService.getConditionByUuid(uuid);
Assert.assertEquals(patientId, savedCondition.getPatient().getPatientId());
Assert.assertEquals(uuid, savedCondition.getUuid());
Assert.assertEquals(codedOrFreeText, savedCondition.getCondition());
Assert.assertEquals(ConditionClinicalStatus.ACTIVE, savedCondition.getClinicalStatus());
Assert.assertNotNull(savedCondition.getConditionId());
}
use of org.openmrs.CodedOrFreeText 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;
}
Aggregations