@Test public void setAllergies_shouldSetTheNonCodedConceptForNonCodedAllergenIfNotSpecified() { Patient patient = allergyService.getPatient(2); Allergen allergen = new Allergen(AllergenType.DRUG, null, "Some allergy name"); Allergy allergy = new Allergy(patient, allergen, null, null, null); Allergies allergies = allergyService.getAllergies(patient); allergies.add(allergy); allergyService.setAllergies(patient, allergies); Assert.assertFalse(allergy.getAllergen().isCoded()); } }
allergies.get(2).addReaction(reaction); allergyService.setAllergies(patient, allergies);
/** * @see PatientService#setAllergies(Patient,Allergies) */ @Test public void setAllergies_shouldSaveTheAllergyListAndStatus() { //get a patient without any allergies Patient patient = allergyService.getPatient(7); Allergies allergies = allergyService.getAllergies(patient); Assert.assertEquals(Allergies.UNKNOWN, allergies.getAllergyStatus()); Assert.assertEquals(0, allergies.size()); //save some allergies for this patient Allergen allergen = new Allergen(AllergenType.DRUG, new Concept(3), null); Concept severity = new Concept(4); Allergy allergy = new Allergy(patient, allergen, severity, "some comment", new ArrayList<>()); AllergyReaction reaction = new AllergyReaction(allergy, new Concept(21), null); allergy.addReaction(reaction); allergies = new Allergies(); allergies.add(allergy); allergyService.setAllergies(patient, allergies); //now the patient should have allergies and the correct allergy status allergies = allergyService.getAllergies(patient); Assert.assertEquals(Allergies.SEE_LIST, allergies.getAllergyStatus()); Assert.assertEquals(1, allergies.size()); Assert.assertEquals(1, allergies.get(0).getReactions().size()); }
/** * @see PatientService#setAllergies(Patient,Allergies) */ @Test public void setAllergies_shouldVoidAllAllergiesAndSetStatusToUnknownIfAllAllergiesAreRemoved() { //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()); //remove all allergies while (allergies.size() > 0) { allergies.remove(0); } allergyService.setAllergies(patient, allergies); //all allergies should be voided and status set to unknown allergies = allergyService.getAllergies(patient); Assert.assertEquals(Allergies.UNKNOWN, allergies.getAllergyStatus()); Assert.assertEquals(0, allergies.size()); }
/** * @see PatientService#setAllergies(Patient,Allergies) */ @Test public void setAllergies_shouldSetStatusToNoKnownAllergiesForPatientWithoutAllergies() { //get a patient without any allergies Patient patient = allergyService.getPatient(7); Allergies allergies = allergyService.getAllergies(patient); Assert.assertEquals(Allergies.UNKNOWN, allergies.getAllergyStatus()); Assert.assertEquals(0, allergies.size()); //confirm that patient has no known allergies allergies = new Allergies(); allergies.confirmNoKnownAllergies(); allergyService.setAllergies(patient, allergies); //now the patient should have the no known allergies status allergies = allergyService.getAllergies(patient); Assert.assertEquals(Allergies.NO_KNOWN_ALLERGIES, allergies.getAllergyStatus()); Assert.assertEquals(0, allergies.size()); }
allergyService.setAllergies(patient, allergies);
allergyService.setAllergies(patient, allergies);
allergyService.setAllergies(patient, allergies);
/** * @see PatientService#setAllergies(Patient,Allergies) */ @Test public void setAllergies_shouldVoidAllAllergiesAndSetStatusToNoKnownAllergiesIfAllAllergiesAreRemovedAndStatusSetAsSuch() { //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()); //remove all allergies while (allergies.size() > 0) { allergies.remove(0); } //set the status to no known allergies allergies.confirmNoKnownAllergies(); allergyService.setAllergies(patient, allergies); //all allergies should be voided and status set to no known allergies allergies = allergyService.getAllergies(patient); Assert.assertEquals(Allergies.NO_KNOWN_ALLERGIES, allergies.getAllergyStatus()); Assert.assertEquals(0, allergies.size()); }
allergyService.setAllergies(patient, allergies);
allergyService.setAllergies(patient, allergies);
allergyService.setAllergies(patient, allergies);
allergyService.setAllergies(patient, allergies);
allergyService.setAllergies(patient, allergies);
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResourcep * [ut(java.lang.String, SimpleObject, RequestContext) PUT /patient/{patient_uuid}/allergy * sets allergyStatus of patient to Allergies.NO_KNOWN_ALLERGIES * @should throw new ObjectNotFoundException if patient does not exist * @should throw new ResourceDoesNotSupportOperationException if post body is not empty * @should throw new ResourceDoesNotSupportOperationException if patient has any allergies */ @Override public void put(String parentUniqueId, SimpleObject post, RequestContext context) throws ResponseException { Patient patient = Context.getPatientService().getPatientByUuid(parentUniqueId); if (patient == null) { throw new ObjectNotFoundException(); } if (post.size() != 0) { // not allowed to actually post any data throw new ResourceDoesNotSupportOperationException(); } Allergies allergies = Context.getPatientService().getAllergies(patient); if (allergies.size() != 0) { // not allowed unless patient has no allergies throw new ResourceDoesNotSupportOperationException(); } allergies.confirmNoKnownAllergies(); // set allergyStatus to Allergies.NO_KNOWN_ALLERGIES Context.getPatientService().setAllergies(patient, allergies); } }