/** * Remove the given ConceptMap from the list of mappings for this Concept * * @param conceptMap * @return true if the entity was removed, false otherwise * @Should remove concept map passed from list of mappings */ public boolean removeConceptMapping(ConceptMap conceptMap) { return getConceptMappings().remove(conceptMap); }
/** * Add the given ConceptMap object to this concept's list of concept mappings. If there is * already a corresponding ConceptMap object for this concept already, this one will not be * added. * * @param newConceptMap */ public void addConceptMapping(ConceptMap newConceptMap) { if (newConceptMap != null) { newConceptMap.setConcept(this); } if (newConceptMap != null && !getConceptMappings().contains(newConceptMap)) { if (newConceptMap.getConceptMapType() == null) { newConceptMap.setConceptMapType(Context.getConceptService().getDefaultConceptMapType()); } getConceptMappings().add(newConceptMap); } }
private void ensureConceptMapTypeIsSet(Concept concept) { ConceptMapType defaultConceptMapType = null; for (ConceptMap map : concept.getConceptMappings()) { if (map.getConceptMapType() == null) { if (defaultConceptMapType == null) { defaultConceptMapType = Context.getConceptService().getDefaultConceptMapType(); } map.setConceptMapType(defaultConceptMapType); } } }
/** * Returns concept reference term code of the mapping to the SNOMED CT concept source * * @param durationUnits * @return a string which is reference term code * @should return null if the concept has no mapping to the SNOMED CT source * @should return the code for the term of the mapping to the SNOMED CT source */ public static String getCode(Concept durationUnits) { for (ConceptMap conceptMapping : durationUnits.getConceptMappings()) { ConceptReferenceTerm conceptReferenceTerm = conceptMapping.getConceptReferenceTerm(); if (ConceptMapType.SAME_AS_MAP_TYPE_UUID.equals(conceptMapping.getConceptMapType().getUuid()) && Duration.SNOMED_CT_CONCEPT_SOURCE_HL7_CODE.equals(conceptReferenceTerm.getConceptSource() .getHl7Code())) { return conceptReferenceTerm.getCode(); } } return null; } }
@Test public void shouldChangeConceptMapReferenceToParentConcept() { Concept c = new Concept(123); c.getConceptMappings().add(new ConceptMap(1)); c.getConceptMappings().add(new ConceptMap(2)); ConceptNumeric cn = new ConceptNumeric(c); for (ConceptMap cMap : cn.getConceptMappings()) { Assert.assertSame(cn, cMap.getConcept()); } }
if (CollectionUtils.isNotEmpty(conceptToValidate.getConceptMappings())) { for (ConceptMap map : conceptToValidate.getConceptMappings()) { if (map.getConceptReferenceTerm().getConceptReferenceTermId() == null) {
if (concept.getConceptMappings() != null) { for (ConceptMap map : concept.getConceptMappings()) { map.setConcept(concept);
/** * @see Concept#removeConceptMapping(ContentMap) */ @Test public void removeConceptMapping_shouldRemoveConceptMapPassedFromListOfMappings() { Concept c = new Concept(); ConceptMap c1 = new ConceptMap(1); c1.setConceptMapType(new ConceptMapType(1)); ConceptMap c2 = new ConceptMap(2); c2.setConceptMapType(new ConceptMapType(2)); c.addConceptMapping(c1); c.addConceptMapping(c2); Collection<ConceptMap> mappings = c.getConceptMappings(); Assert.assertEquals(2, mappings.size()); c.removeConceptMapping(c1); mappings = c.getConceptMappings(); Assert.assertTrue(mappings.contains(c2)); Assert.assertEquals(1, mappings.size()); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#doGetAll(java.lang.Object, * org.openmrs.module.webservices.rest.web.RequestContext) */ @Override public PageableResult doGetAll(Concept parent, RequestContext context) throws ResponseException { List<ConceptMap> maps = new ArrayList<ConceptMap>(parent.getConceptMappings()); return new NeedsPaging<ConceptMap>(maps, context); }
@PropertyGetter("mappings") public static List<ConceptMap> getMappings(Concept instance) { return new ArrayList<ConceptMap>(instance.getConceptMappings()); }
this.setConceptMappings(new HashSet<>(c.getConceptMappings())); for (ConceptMap cMap : this.getConceptMappings()) { cMap.setConcept(this);
/** * It's needed, because of ConversionException: Don't know how to handle collection class: * interface java.util.Collection * * @param instance * @param mappings */ @PropertySetter("mappings") public static void setMappings(Concept instance, List<ConceptMap> mappings) { instance.getConceptMappings().clear(); for (ConceptMap map : mappings) { instance.addConceptMapping(map); } }
/** * Constructor from Concept. * * @param c */ public ConceptComplex(Concept c) { this.setAnswers(c.getAnswers(true)); this.setChangedBy(c.getChangedBy()); this.setConceptClass(c.getConceptClass()); this.setConceptId(c.getConceptId()); this.setConceptSets(c.getConceptSets()); this.setCreator(c.getCreator()); this.setDatatype(c.getDatatype()); this.setDateChanged(c.getDateChanged()); this.setDateCreated(c.getDateCreated()); this.setSet(c.getSet()); this.setNames(c.getNames()); this.setDescriptions(c.getDescriptions()); this.setConceptMappings(c.getConceptMappings()); this.setRetired(c.getRetired()); this.setVersion(c.getVersion()); this.setUuid(c.getUuid()); this.handler = ""; }
@Test public void equals_shouldNotBeTheSameReference() { Concept c = new Concept(123); ConceptNumeric cn = new ConceptNumeric(c); Assert.assertNotSame(c.getAnswers(), cn.getAnswers()); Assert.assertNotSame(c.getConceptSets(), cn.getConceptSets()); Assert.assertNotSame(cn.getConceptSets(), c.getConceptSets()); Assert.assertNotSame(c.getNames(), cn.getNames()); Assert.assertNotSame(c.getConceptMappings(), cn.getConceptMappings()); Assert.assertNotSame(c.getDescriptions(), cn.getDescriptions()); }
@Override public long getAllCount() { return service.getConceptByUuid(RestTestConstants1_9.CONCEPT_UUID).getConceptMappings().size(); }
@Override public long getAllCount() { return service.getConceptByUuid(RestTestConstants1_8.CONCEPT2_UUID).getConceptMappings().size(); }
/** * @see {@link HtmlFormEntryUtil#getConcept(String)} */ @Test @Verifies(value = "should find a concept by its mapping with a space in between", method = "getConcept(String)") public void getConcept_shouldFindAConceptByItsMappingWithASpaceInBetween() throws Exception { String id = "XYZ: HT"; Concept cpt = HtmlFormEntryUtil.getConcept(id); Assert.assertEquals("XYZ", cpt.getConceptMappings().iterator().next().getSource().getName()); Assert.assertEquals("HT", cpt.getConceptMappings().iterator().next().getSourceCode()); }
/** * @see {@link HtmlFormEntryUtil#getConcept(String)} mapping test */ @Test @Verifies(value = "should find a concept by its mapping", method = "getConcept(String)") public void getConcept_shouldFindAConceptByItsMapping() throws Exception { String id = "XYZ:HT"; Concept cpt = HtmlFormEntryUtil.getConcept(id); Assert.assertEquals("XYZ", cpt.getConceptMappings().iterator().next().getSource().getName()); Assert.assertEquals("HT", cpt.getConceptMappings().iterator().next().getSourceCode()); }
@Before public void before() { service = Context.getConceptService(); restHelperService = Context.getService(RestHelperService.class); Concept concept = service.getConceptByUuid(RestTestConstants1_8.CONCEPT2_UUID); ConceptMap next = concept.getConceptMappings().iterator().next(); //The UUID property is not set in standardTestDataset.xml. next.setUuid(UUID.randomUUID().toString()); service.saveConcept(concept); conceptMapUuid = next.getUuid(); }
@Test public void shouldSetMappingsOnConcept() throws Exception { //before adding Concept concept = service.getConceptByUuid(getUuid()); assertThat(concept.getConceptMappings().size(), is(0)); //add one mapping MockHttpServletRequest request = request(RequestMethod.POST, getURI() + "/" + getUuid()); ConceptReferenceTerm referenceTerm = service.getAllConceptReferenceTerms().get(0); String mapTypeUuid = service.getDefaultConceptMapType().getUuid(); String json = "{ \"mappings\": [{\"conceptReferenceTerm\":\"" + referenceTerm.getUuid() + "\",\"conceptMapType\":\"" + mapTypeUuid + "\"}]}"; request.setContent(json.getBytes()); handle(request); concept = service.getConceptByUuid(getUuid()); assertThat(concept.getConceptMappings().size(), is(1)); assertThat(concept.getConceptMappings(), hasItem(hasTerm(referenceTerm))); //set mappings to empty MockHttpServletRequest requestEmpty = request(RequestMethod.POST, getURI() + "/" + getUuid()); String jsonEmpty = "{ \"mappings\": []}"; requestEmpty.setContent(jsonEmpty.getBytes()); handle(requestEmpty); assertThat(concept.getConceptMappings().size(), is(0)); }