use of org.openmrs.Allergy in project openmrs-core by openmrs.
the class PatientServiceAllergyTest method setAllergies_shouldVoidAllergiesWithEditedComment.
/**
* @see PatientService#setAllergies(Patient,Allergies)
*/
@Test
public void setAllergies_shouldVoidAllergiesWithEditedComment() {
// get a patient with some allergies
Patient patient = allergyService.getPatient(2);
Allergies allergies = allergyService.getAllergies(patient);
Assert.assertEquals(Allergies.SEE_LIST, allergies.getAllergyStatus());
Assert.assertEquals(4, allergies.size());
Allergy editedAllergy = allergies.get(0);
// clear any cache for this object such that the next calls fetch it from the database
Context.evictFromSession(editedAllergy);
// edit comment
editedAllergy.setComment("edited comment");
Assert.assertTrue(allergies.contains(editedAllergy));
allergyService.setAllergies(patient, allergies);
// should remain with four unvoided allergies and status maintained as see list
allergies = allergyService.getAllergies(patient);
Assert.assertEquals(Allergies.SEE_LIST, allergies.getAllergyStatus());
Assert.assertEquals(4, allergies.size());
// the edited allergy should have been voided
Assert.assertFalse(allergies.contains(editedAllergy));
}
use of org.openmrs.Allergy in project openmrs-core by openmrs.
the class PatientServiceAllergyTest method setAllergies_shouldVoidAllergiesWithEditedReactionCoded.
/**
* @see PatientService#setAllergies(Patient,Allergies)
*/
@Test
public void setAllergies_shouldVoidAllergiesWithEditedReactionCoded() {
// get a patient with some allergies
Patient patient = allergyService.getPatient(2);
Allergies allergies = allergyService.getAllergies(patient);
Assert.assertEquals(Allergies.SEE_LIST, allergies.getAllergyStatus());
Assert.assertEquals(4, allergies.size());
Allergy editedAllergy = allergies.get(0);
// clear any cache for this object such that the next calls fetch it from the database
Context.evictFromSession(editedAllergy);
// edit a reaction
AllergyReaction reaction = editedAllergy.getReactions().get(0);
reaction.setReaction(new Concept(11));
Assert.assertTrue(allergies.contains(editedAllergy));
allergyService.setAllergies(patient, allergies);
// should remain with four unvoided allergies and status maintained as see list
allergies = allergyService.getAllergies(patient);
Assert.assertEquals(Allergies.SEE_LIST, allergies.getAllergyStatus());
Assert.assertEquals(4, allergies.size());
// the edited allergy should have been voided
Assert.assertFalse(allergies.contains(editedAllergy));
}
use of org.openmrs.Allergy in project openmrs-core by openmrs.
the class PatientServiceAllergyTest method setAllergies_shouldVoidAllergiesWithEditedCodedAllergen.
/**
* @see PatientService#setAllergies(Patient,Allergies)
*/
@Test
public void setAllergies_shouldVoidAllergiesWithEditedCodedAllergen() {
// get a patient with some allergies
Patient patient = allergyService.getPatient(2);
Allergies allergies = allergyService.getAllergies(patient);
Assert.assertEquals(Allergies.SEE_LIST, allergies.getAllergyStatus());
Assert.assertEquals(4, allergies.size());
Allergy editedAllergy = allergies.get(0);
// clear any cache for this object such that the next calls fetch it from the database
Context.evictFromSession(editedAllergy);
// edit coded allergen
editedAllergy.getAllergen().setCodedAllergen(new Concept(24));
Assert.assertTrue(allergies.contains(editedAllergy));
allergyService.setAllergies(patient, allergies);
// should remain with four unvoided allergies and status maintained as see list
allergies = allergyService.getAllergies(patient);
Assert.assertEquals(Allergies.SEE_LIST, allergies.getAllergyStatus());
Assert.assertEquals(4, allergies.size());
// the edited allergy should have been voided
Assert.assertFalse(allergies.contains(editedAllergy));
}
Aggregations