@RepHandler(value = NamedRepresentation.class, name = "fullchildren") public SimpleObject asFullChildren(Concept delegate) throws ConversionException { Set<String> path = new HashSet<String>(); path.add(delegate.getUuid()); assertNoCycles(delegate, path); return asFullChildrenInternal(delegate); }
@RepHandler(FullRepresentation.class) public SimpleObject asFull(Concept delegate) throws ConversionException { DelegatingResourceDescription description = fullRepresentationDescription(delegate); return convertDelegateToRepresentation(delegate, description); }
for (String conceptUuid : questionConceptUuids) { questionConcepts.add(((ConceptResource1_8) Context.getService(RestService.class) .getResourceBySupportedClass(Concept.class)).getByUniqueId(conceptUuid)); for (String conceptUuid : answerConceptUuids) { answerConcepts.add(((ConceptResource1_8) Context.getService(RestService.class) .getResourceBySupportedClass(Concept.class)).getByUniqueId(conceptUuid));
protected void assertNoCycles(Concept delegate, Set<String> path) throws ConversionException { for (Concept member : delegate.getSetMembers()) { if (path.add(member.getUuid())) { assertNoCycles(member, path); } else { throw new ConversionException("Cycles in children are not supported. Concept with uuid " + delegate.getUuid() + " repeats in a set."); } path.remove(member.getUuid()); } }
@RepHandler(RefRepresentation.class) public SimpleObject asRef(Concept delegate) throws ConversionException { DelegatingResourceDescription description = new DelegatingResourceDescription(); description.addProperty("uuid"); description.addProperty("display", "displayString", Representation.DEFAULT); if (delegate.isRetired()) { description.addProperty("retired"); } description.addSelfLink(); return convertDelegateToRepresentation(delegate, description); }
@Test public void testSetNames() throws Exception { Concept instance = new Concept(); List<ConceptName> otherNames = new ArrayList<ConceptName>(); ConceptName otherName = new ConceptName(); otherName.setLocale(Locale.ENGLISH); otherName.setConceptNameType(ConceptNameType.FULLY_SPECIFIED); otherName.setName("newName"); otherName.setUuid("newUuid"); otherNames.add(otherName); ConceptResource1_8.setNames(instance, otherNames); assertEquals(instance.getNames().size(), 1); assertTrue(instance.getNames().contains(otherName)); ConceptResource1_8.setNames(instance, getMockNamesList()); assertEquals(instance.getNames().size(), 2); assertFalse(instance.getNames().contains(otherName)); otherNames.addAll(getMockNamesList()); ConceptResource1_8.setNames(instance, otherNames); assertEquals(instance.getNames().size(), 3); assertTrue(instance.getNames().contains(otherName)); ConceptResource1_8.setNames(instance, getMockNamesList()); assertEquals(instance.getNames().size(), 2); assertFalse(instance.getNames().contains(otherName)); }
.getResourceBySupportedClass(Concept.class)).getByUniqueId(conceptUuid); if (concept != null) { List<Obs> obs = Context.getObsService().getObservationsByPersonAndConcept(patient, concept);
/** * It is used internally for the fullchildren representation. Contrary to the fullchildren * handler it does not check for cycles. * * @param delegate * @return * @throws ConversionException */ @RepHandler(value = NamedRepresentation.class, name = "fullchildreninternal") public SimpleObject asFullChildrenInternal(Concept delegate) throws ConversionException { DelegatingResourceDescription description = fullRepresentationDescription(delegate); description.removeProperty("setMembers"); description.addProperty("setMembers", new NamedRepresentation("fullchildreninternal")); description.removeProperty("answers"); description.addProperty("answers", Representation.FULL); return convertDelegateToRepresentation(delegate, description); }