private boolean isXDSCode(ClassificationType cl) { List<SlotType1> slots = cl.getSlot(); return slots != null && slots.size() == 1 && "codingScheme".equals(slots.get(0).getName()); }
public XDSCode getXDSCode(ClassificationType clType, boolean createMissing) throws XDSException { String scheme = clType.getClassificationScheme(); String codeValue = clType.getNodeRepresentation(); String codeDesignator = clType.getSlot().get(0).getValueList().getValue().get(0); if (!createMissing) { if (!adCodes.isClassSchemeCodeDefined(scheme, codeValue, codeDesignator)) { throw new XDSException(XDSException.XDS_ERR_REGISTRY_METADATA_ERROR, "Unknown code:"+ codeValue+"^^"+codeDesignator+" ("+scheme+")", null); } } XDSCode code = new XDSCode(codeValue, codeDesignator, clType.getName().getLocalizedString().get(0).getValue(), scheme); try { return (XDSCode) em.createNamedQuery(XDSCode.FIND_BY_CODE_VALUE) .setParameter(1, codeValue) .setParameter(2, codeDesignator) .setParameter(3, scheme) .getSingleResult(); } catch (NoResultException x) { log.info("Store new XDS Code! code:"+code); em.persist(code); return code; } }
public static ClassificationType createCodeClassification(String id, String classifiedObjectID, String type, Code code) { ClassificationType cl = createClassification(id, type, classifiedObjectID, code.getValue()); LocalizedStringType lst = rimFactory.createLocalizedStringType(); lst.setValue(code.getMeaning()); InternationalStringType is = rimFactory.createInternationalStringType(); is.getLocalizedString().add(lst); cl.setName(is); cl.getSlot().add(createSlot("codingScheme", null, code.getDesignator())); return cl; }