/** * @since 1.5 * @see org.openmrs.OpenmrsObject#setId(java.lang.Integer) */ @Override public void setId(Integer id) { setConceptNameId(id); }
/** * Utility method to retrieve the openmrs ConceptName specified in an hl7 message observation * segment. This method assumes that the check for 99NAM has been done already and is being * given an openmrs conceptNameId * * @param hl7ConceptNameId internal ConceptNameId to look up * @return ConceptName from the database * @throws HL7Exception */ private ConceptName getConceptName(String hl7ConceptNameId) throws HL7Exception { ConceptName specifiedConceptName = null; if (hl7ConceptNameId != null) { // get the exact concept name specified by the id try { Integer conceptNameId = Integer.valueOf(hl7ConceptNameId); specifiedConceptName = new ConceptName(); specifiedConceptName.setConceptNameId(conceptNameId); } catch (NumberFormatException e) { // if it is not a valid number, more than likely it is a bad hl7 message log.debug("Invalid concept name ID '" + hl7ConceptNameId + "'", e); } } return specifiedConceptName; }
conceptName.setConceptNameId(rs.getInt("concept_name_id")); conceptName.setName(rs.getString("name"));
clone.setConceptNameId(null); uuidClonedConceptNameMap.put(conceptName.getUuid(), clone); } else { clone.setConceptNameId(conceptName.getConceptNameId());
/** * @see Concept#getName(Locale,null) */ @Test public void getName_shouldReturnExactNameLocaleMatchGivenExactEqualsTrue() { Locale definedNameLocale = new Locale("en", "US"); Locale localeToSearch = new Locale("en", "US"); Concept concept = new Concept(); ConceptName fullySpecifiedName = new ConceptName("some name", definedNameLocale); fullySpecifiedName.setConceptNameId(1); fullySpecifiedName.setConceptNameType(ConceptNameType.FULLY_SPECIFIED); fullySpecifiedName.setLocalePreferred(false); concept.addName(fullySpecifiedName); Assert.assertNotNull(concept.getName(localeToSearch, true)); Assert.assertEquals("some name", concept.getName(localeToSearch, true).getName()); }
/** * Convenient factory method to create a populated Concept name. * * @param id id for the conceptName * @param locale the locale or context locale if null * @param conceptNameType the conceptNameType of the concept * @param isLocalePreferred if this name should be marked as preferred in its locale */ private ConceptName createConceptName(int id, String name, Locale locale, ConceptNameType conceptNameType, Boolean isLocalePreferred) { ConceptName result = new ConceptName(); result.setConceptNameId(id); result.setName(name); if (locale == null) { result.setLocale(Context.getLocale()); } else { result.setLocale(locale); } result.setConceptNameType(conceptNameType); result.setLocalePreferred(isLocalePreferred); return result; }
Concept concept = new Concept(); ConceptName fullySpecifiedName = new ConceptName("some name", definedNameLocale); fullySpecifiedName.setConceptNameId(1); fullySpecifiedName.setConceptNameType(ConceptNameType.FULLY_SPECIFIED); fullySpecifiedName.setLocalePreferred(false);