/** * @since 1.5 * @see org.openmrs.OpenmrsObject#getId() */ @Override public Integer getId() { return getConceptId(); }
/** * Turns this concept into a very simple serialized string * * @see org.openmrs.Attributable#serialize() */ @Override public String serialize() { if (this.getConceptId() == null) { return ""; } return "" + this.getConceptId(); }
/** * find this conceptId in the original set and set its weight */ private ConceptAnswer getConceptAnswerFromOriginal(Integer id) { for (ConceptAnswer ca : originalConceptAnswers) { if (ca.getAnswerConcept().getConceptId().equals(id)) { return ca; } } return null; }
/** * Turn the given concept/concept-name pair into a string acceptable for hl7 and forms * * @param concept Concept to convert to a string * @param localizedName specific localized concept-name * @return String representation of the given concept */ public static String conceptToString(Concept concept, ConceptName localizedName) { return concept.getConceptId() + "^" + localizedName.getName() + "^" + HL7Constants.HL7_LOCAL_CONCEPT; // + "^" }
/** * @see org.openmrs.api.ConceptService#getConceptsByAnswer(org.openmrs.Concept) */ @Override @Transactional(readOnly = true) public List<Concept> getConceptsByAnswer(Concept concept) throws APIException { if (concept.getConceptId() == null) { return Collections.emptyList(); } return dao.getConceptsByAnswer(concept); }
/** * @see org.openmrs.api.FormService#getFormsContainingConcept(org.openmrs.Concept) */ @Override @Transactional(readOnly = true) public List<Form> getFormsContainingConcept(Concept concept) throws APIException { if (concept.getConceptId() == null) { return Collections.emptyList(); } return dao.getFormsContainingConcept(concept); }
/** * @see org.openmrs.api.ConceptService#getSetsContainingConcept(org.openmrs.Concept) */ @Override @Transactional(readOnly = true) public List<ConceptSet> getSetsContainingConcept(Concept concept) { if (concept.getConceptId() == null) { return Collections.emptyList(); } return dao.getSetsContainingConcept(concept); }
/** * @see org.openmrs.api.db.ConceptDAO#getSavedConceptDatatype(org.openmrs.Concept) */ @Override public ConceptDatatype getSavedConceptDatatype(Concept concept) { SQLQuery sql = sessionFactory.getCurrentSession().createSQLQuery( "select datatype.* from " + "concept_datatype datatype, " + "concept concept " + "where " + "datatype.concept_datatype_id = concept.datatype_id " + "and concept.concept_id=:conceptId") .addEntity(ConceptDatatype.class); sql.setInteger("conceptId", concept.getConceptId()); return (ConceptDatatype) sql.uniqueResult(); }
/** * @see ConceptService#getAllConcepts(String,null,null) */ @Test public void getAllConcepts_shouldExcludeRetiredConceptsWhenSetIncludeRetiredToFalse() { final List<Concept> allConcepts = conceptService.getAllConcepts(null, true, false); assertEquals(34, allConcepts.size()); assertEquals(3, allConcepts.get(0).getConceptId().intValue()); }
/** * @see org.openmrs.api.OrderService#getDrugRoutes() */ @Test public void getDrugRoutes_shouldGetDrugRoutesAssociatedConceptPrividedInGlobalProperties() { List<Concept> drugRoutesList = orderService.getDrugRoutes(); assertEquals(1, drugRoutesList.size()); assertEquals(22, drugRoutesList.get(0).getConceptId().intValue()); }
/** * @see ConceptService#getAllConcepts(String,null,null) */ @Test public void getAllConcepts_shouldOrderByConceptIdDescendingWhenSetAscParameterToFalse() { final List<Concept> allConcepts = conceptService.getAllConcepts(null, false, true); assertEquals(36, allConcepts.size()); assertEquals(5497, allConcepts.get(0).getConceptId().intValue()); }
/** * @see ConceptService#getAllConcepts(String,null,null) */ @Test public void getAllConcepts_shouldOrderByConceptIdAndIncludeRetiredWhenGivenNoParameters() { final List<Concept> allConcepts = conceptService.getAllConcepts(); assertEquals(36, allConcepts.size()); assertEquals(3, allConcepts.get(0).getConceptId().intValue()); }
/** * @see ConceptService#conceptIterator() */ @Test public void conceptIterator_shouldIterateOverAllConcepts() { Iterator<Concept> iterator = Context.getConceptService().conceptIterator(); Assert.assertTrue(iterator.hasNext()); Assert.assertEquals(3, iterator.next().getConceptId().intValue()); }
/** * @see ConceptService#getFalseConcept() */ @Test public void getFalseConcept_shouldReturnTheFalseConcept() { createTrueFalseGlobalProperties(); Assert.assertEquals(8, conceptService.getFalseConcept().getConceptId().intValue()); }
/** * @see ConceptDAO#getConceptsByAnswer(Concept) */ @Test public void getConceptsByAnswer_shouldReturnConceptsForTheGivenAnswerConcept() { Concept concept = dao.getConcept(22); List<Concept> conceptsByAnswer = dao.getConceptsByAnswer(concept); Assert.assertNotNull(conceptsByAnswer); Assert.assertEquals(1, conceptsByAnswer.size()); Concept conceptByAnswer = conceptsByAnswer.get(0); Assert.assertEquals(21, conceptByAnswer.getConceptId().intValue()); }
/** * @see ConceptService#getTrueConcept() */ @Test public void getTrueConcept_shouldReturnTheTrueConcept() { createTrueFalseGlobalProperties(); Assert.assertEquals(7, conceptService.getTrueConcept().getConceptId().intValue()); }
/** * @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 ConceptService#getDrugIngredientByUuid(String)} */ @Test public void getDrugIngredientByUuid_shouldFindObjectGivenValidUuid() { String uuid = "6519d653-393d-4118-9c83-a3715b82d4dc"; DrugIngredient ingredient = Context.getConceptService().getDrugIngredientByUuid(uuid); Assert.assertEquals(88, (int) ingredient.getIngredient().getConceptId()); }
/** * @see OrderService#getNonCodedDrugConcept() */ @Test public void getNonCodedDrugConcept_shouldReturnAConceptIfGPIsSet() { executeDataSet("org/openmrs/api/include/OrderServiceTest-nonCodedDrugs.xml"); Concept nonCodedDrugConcept = orderService.getNonCodedDrugConcept(); assertNotNull(nonCodedDrugConcept); assertThat(nonCodedDrugConcept.getConceptId(), is(5584)); assertEquals(nonCodedDrugConcept.getName().getName(), "DRUG OTHER"); }
/** * @see PersonAttribute#getHydratedObject() */ @Test public void getHydratedObject_shouldLoadClassInFormatProperty() { PersonAttributeType type = new PersonAttributeType(); type.setFormat("org.openmrs.Concept"); PersonAttribute pa = new PersonAttribute(2); pa.setAttributeType(type); pa.setValue("5089"); Concept concept = (Concept) pa.getHydratedObject(); Assert.assertEquals(5089, concept.getConceptId().intValue()); }