@Override protected Concept getObjectByUuid(String uuid) { return Context.getConceptService().getConceptByUuid(uuid); } }
protected Concept getConceptByGlobalProperty(String globalPropertyName) { String globalProperty = administrationService.getGlobalProperty(globalPropertyName); Concept concept = conceptService.getConceptByUuid(globalProperty); if (concept == null) { throw new IllegalStateException("Configuration required: " + globalPropertyName); } return concept; }
/** * @see org.openmrs.customdatatype.SerializingCustomDatatype#deserialize(String) * @override */ @Override public Concept deserialize(String uuid) { if (StringUtils.isBlank(uuid)) { return null; } return Context.getConceptService().getConceptByUuid(uuid); }
@Override public Concept getNonCodedDrugConcept() { String conceptUuid = Context.getAdministrationService().getGlobalProperty(OpenmrsConstants.GP_DRUG_ORDER_DRUG_OTHER); if (StringUtils.hasText(conceptUuid)) { return Context.getConceptService().getConceptByUuid(conceptUuid); } return null; }
private List<Concept> getSetMembersOfConceptSetFromGP(String globalProperty) { String conceptUuid = Context.getAdministrationService().getGlobalProperty(globalProperty); Concept concept = Context.getConceptService().getConceptByUuid(conceptUuid); if (concept != null && concept.getSet()) { return concept.getSetMembers(); } return Collections.emptyList(); } }
/** * @see ConceptServiceImpl#getSetsContainingConcept(Concept) */ @Test public void getSetsContainingConcept_shouldGiveAnEmptyListIfNoMatchingConceptSetIsFound() { String uuid = "0cbe2ed3-cd5f-4f46-9459-26127c9265ab"; Concept concept = conceptService.getConceptByUuid(uuid); List<ConceptSet> conceptSets = conceptService.getSetsContainingConcept(concept); assertEquals(conceptSets, Collections.emptyList()); }
/** * @see ConceptServiceImpl#getDrugs(String, Concept, boolean, boolean, boolean, Integer, * Integer) */ @Test public void getDrugs_shouldReturnListOfMatchingDrugs() { String drugName = "ASPIRIN"; String drugUuid = "05ec820a-d297-44e3-be6e-698531d9dd3f"; Concept concept = conceptService.getConceptByUuid(drugUuid); List<Drug> drugs = conceptService.getDrugs(drugName, concept, true, true, true, 0, 100); assertTrue(drugs.contains(conceptService.getDrug(drugName))); }
/** * @see ConceptService#getConceptByUuid(String) */ @Test public void getConceptByUuid_shouldReturnNullIfNoObjectFoundWithGivenUuid() { Assert.assertNull(Context.getConceptService().getConceptByUuid("some invalid uuid")); }
/** * @see ConceptService#getConceptByUuid(String) */ @Test public void getConceptByUuid_shouldFindObjectGivenValidUuid() { String uuid = "0cbe2ed3-cd5f-4f46-9459-26127c9265ab"; Concept concept = Context.getConceptService().getConceptByUuid(uuid); Assert.assertEquals(3, (int) concept.getConceptId()); }
/** * @see {@link Allergies#addAll(int, java.util.Collection)} */ @Test(expected = APIException.class) public void addAll7_shouldNotAllowDuplicateNonCodedAllergen(){ Concept concept = Context.getConceptService().getConceptByUuid(Allergen.getOtherNonCodedConceptUuid()); Allergy allergy1 = new Allergy(); allergy1.setAllergen(new Allergen(null, concept, "OTHER VALUE")); Allergy allergy2 = new Allergy(); allergy2.setAllergen(new Allergen(null, concept, "OTHER VALUE")); List<Allergy> allergies = new ArrayList<>(); allergies.add(allergy1); allergies.add(allergy2); new Allergies().addAll(0, allergies); } }
/** * @see {@link Allergies#addAll(java.util.Collection)} */ @Test(expected = APIException.class) public void addAll6_shouldNotAllowDuplicateNonCodedAllergen(){ Concept concept = Context.getConceptService().getConceptByUuid(Allergen.getOtherNonCodedConceptUuid()); Allergy allergy1 = new Allergy(); allergy1.setAllergen(new Allergen(null, concept, "OTHER VALUE")); Allergy allergy2 = new Allergy(); allergy2.setAllergen(new Allergen(null, concept, "OTHER VALUE")); List<Allergy> allergies = new ArrayList<>(); allergies.add(allergy1); allergies.add(allergy2); new Allergies().addAll(allergies); }
@Test public void isSameAllergen_shouldBeCaseInsensitiveForNonCodedAllergen() { Concept concept = Context.getConceptService().getConceptByUuid(Allergen.getOtherNonCodedConceptUuid()); Assert.assertTrue(new Allergen(null, concept, "other value").isSameAllergen(new Allergen(null, concept, "OTHER VALUE"))); }
@Test public void isSameAllergen_shouldReturnFalseForDifferentNonCodedAllergen() { Concept concept = Context.getConceptService().getConceptByUuid(Allergen.getOtherNonCodedConceptUuid()); Assert.assertFalse(new Allergen(null, concept, "OTHER VALUE1").isSameAllergen(new Allergen(null, concept, "OTHER VALUE2"))); } }
@Test public void isSameAllergen_shouldReturnTrueForSameNonCodedAllergen() { Concept concept = Context.getConceptService().getConceptByUuid(Allergen.getOtherNonCodedConceptUuid()); Assert.assertTrue(new Allergen(null, concept, "OTHER VALUE").isSameAllergen(new Allergen(null, concept, "OTHER VALUE"))); }
/** * @see {@link Allergies#add(int, Allergy)} */ @Test public void add2_shouldAllowNonDuplicateNonCodedAllergen(){ Concept concept = Context.getConceptService().getConceptByUuid(Allergen.getOtherNonCodedConceptUuid()); Allergy allergy1 = new Allergy(); allergy1.setAllergen(new Allergen(null, concept, "OTHER VALUE1")); Allergy allergy2 = new Allergy(); allergy2.setAllergen(new Allergen(null, concept, "OTHER VALUE2")); allergies.add(0, allergy1); allergies.add(0, allergy2); }
/** * @see {@link Allergies#add(Allergy)} */ @Test(expected = APIException.class) public void add_shouldNotAllowDuplicateNonCodedAllergen(){ Concept concept = Context.getConceptService().getConceptByUuid(Allergen.getOtherNonCodedConceptUuid()); Allergy allergy1 = new Allergy(); allergy1.setAllergen(new Allergen(null, concept, "OTHER VALUE")); Allergy allergy2 = new Allergy(); allergy2.setAllergen(new Allergen(null, concept, "OTHER VALUE")); allergies.add(allergy1); allergies.add(allergy2); }
/** * @see {@link Allergies#add(Allergy)} */ @Test public void add_shouldAllowNonDuplicateNonCodedAllergen(){ Concept concept = Context.getConceptService().getConceptByUuid(Allergen.getOtherNonCodedConceptUuid()); Allergy allergy1 = new Allergy(); allergy1.setAllergen(new Allergen(null, concept, "OTHER VALUE1")); Allergy allergy2 = new Allergy(); allergy2.setAllergen(new Allergen(null, concept, "OTHER VALUE2")); allergies.add(allergy1); allergies.add(allergy2); }
/** * @see {@link Allergies#add(int, Allergy)} */ @Test(expected = APIException.class) public void add2_shouldNotAllowDuplicateNonCodedAllergen(){ Concept concept = Context.getConceptService().getConceptByUuid(Allergen.getOtherNonCodedConceptUuid()); Allergy allergy1 = new Allergy(); allergy1.setAllergen(new Allergen(null, concept, "OTHER VALUE")); Allergy allergy2 = new Allergy(); allergy2.setAllergen(new Allergen(null, concept, "OTHER VALUE")); allergies.add(0, allergy1); allergies.add(0, allergy2); }
/** * @see {@link Allergies#addAll(java.util.Collection)} */ @Test(expected = APIException.class) public void addAll_shouldNotAllowDuplicateNonCodedAllergen(){ Concept concept = Context.getConceptService().getConceptByUuid(Allergen.getOtherNonCodedConceptUuid()); Allergy allergy1 = new Allergy(); allergy1.setAllergen(new Allergen(null, concept, "OTHER VALUE")); Allergy allergy2 = new Allergy(); allergy2.setAllergen(new Allergen(null, concept, "OTHER VALUE")); Allergies allergies = new Allergies(); allergies.add(allergy1); allergies.add(allergy2); allergies.addAll(allergies); }
/** * @see {@link Allergies#addAll(int, java.util.Collection)} */ @Test(expected = APIException.class) public void addAll2_shouldAllowNonDuplicateNonCodedAllergen(){ Concept concept = Context.getConceptService().getConceptByUuid(Allergen.getOtherNonCodedConceptUuid()); Allergy allergy1 = new Allergy(); allergy1.setAllergen(new Allergen(null, concept, "OTHER VALUE1")); Allergy allergy2 = new Allergy(); allergy2.setAllergen(new Allergen(null, concept, "OTHER VALUE2")); Allergies allergies = new Allergies(); allergies.add(allergy1); allergies.add(allergy2); allergies.addAll(0, allergies); }