private static boolean isLocalTerminology(CodePhrase elementCodePhrase) { return "local".equals(elementCodePhrase.getTerminologyId().getValue()); }
/** * Constructs a CodePhrase by terminologyId and codeString * * @param terminologyId * @param codeString * @throws IllegalArgumentException if terminolgy null * or codeString null or empty */ public CodePhrase(String terminologyID, String codeString) { if(terminologyID == null) { throw new IllegalArgumentException("null terminologyId"); } if(StringUtils.isEmpty(codeString)) { throw new IllegalArgumentException("empty codeString"); } this.terminologyId = new TerminologyID(terminologyID); this.codeString = codeString; }
private boolean isLocallyDefined(CodePhrase code) { return "local".equalsIgnoreCase(code.getTerminologyId().toString()) && code.getCodeString().startsWith("at"); }
@Override public boolean validValue(CodePhrase value) { if(value == null) { return false; } if(terminologyId != null && !terminologyId.equals(value.getTerminologyId())) { return false; } if(codeList != null && !codeList.contains(value.getCodeString())) { return false; } return true; }
private void filterIsA( PredicateGeneratedElementInstance predicate, Collection<ArchetypeReference> ehrArchetypeReferences, boolean negation) { final Set<ArchetypeReference> archetypeReferencesToRemove = new HashSet<>(); final Set<CodePhrase> codePhrases = getCodePhrases(predicate); ElementInstance elementInstance; for (ArchetypeReference archetypeReference : ehrArchetypeReferences) { elementInstance = archetypeReference.getElementInstancesMap().get(predicate.getId()); if (elementInstance != null && codePhrases != null) { CodePhrase codePhrase = getCodePhrase(elementInstance); try { if (codePhrase != null) { if ("local".equalsIgnoreCase(codePhrase.getTerminologyId().name())) { filterIsALocalTerminology(negation, archetypeReferencesToRemove, codePhrases, elementInstance, codePhrase); } else { filterIsAExternalTerminology(negation, archetypeReferencesToRemove, codePhrases, elementInstance, codePhrase); } } else { archetypeReferencesToRemove.add(elementInstance.getArchetypeReference()); } } catch (Exception exception) { archetypeReferencesToRemove.add(elementInstance.getArchetypeReference()); logger.warn("Filter isA ", exception); } } } ehrArchetypeReferences.removeAll(archetypeReferencesToRemove); }
@Override public boolean validValue(CodePhrase value) { if(value == null) { return false; } if(terminologyId != null && !terminologyId.equals(value.getTerminologyId())) { return false; } if(codeList != null && !codeList.contains(value.getCodeString())) { return false; } return true; }
CodePhrase code = ord.getSymbol(); if ("local".equalsIgnoreCase( code.getTerminologyId().name())) { codes.add(code.getCodeString()); CCodePhrase ccod = (CCodePhrase) cobj; List<String> list = ccod.getCodeList(); if ("local".equalsIgnoreCase(ccod.getTerminologyId().name()) && list != null) { for (String code : list) {
private boolean isOpenEHRTerm(CodePhrase code) { return "openehr".equalsIgnoreCase(code.getTerminologyId().getValue()); }
/** * Constructs a CodePhrase by terminologyId and codeString * * @param terminologyId * @param codeString * @throws IllegalArgumentException if terminolgy null * or codeString null or empty */ public CodePhrase(String terminologyID, String codeString) { if(terminologyID == null) { throw new IllegalArgumentException("null terminologyId"); } if(StringUtils.isEmpty(codeString)) { throw new IllegalArgumentException("empty codeString"); } this.terminologyId = new TerminologyID(terminologyID); this.codeString = codeString; }
/** * Retrieves the text for given code_prhase * * @param codePhrase * @return */ public String getText(CodePhrase codePhrase, String path) { return getText(codePhrase.getTerminologyId().toString(), codePhrase.getCodeString(), path); }
/** * Tests if two instances are strictly comparable. * * @param ordered * @return true if two instances are strictly comparable */ public boolean isStrictlyComparableTo(DvOrdered ordered) { if (!(ordered instanceof DvOrdinal)) { return false; } final DvOrdinal dvOrdinal = (DvOrdinal) ordered; if (!symbol.getDefiningCode().getTerminologyId().equals( dvOrdinal.symbol.getDefiningCode().getTerminologyId())) { return false; } // todo: check if symbols are from same subset or value range in the same vocabulary return true; }
protected void printOrdinal(Ordinal ordinal, Writer out) throws IOException { CodePhrase symbol = ordinal.getSymbol(); out.write(Integer.toString(ordinal.getValue())); out.write("|["); out.write(symbol.getTerminologyId().getValue()); out.write("::"); out.write(symbol.getCodeString()); out.write("]"); }
/** * Convenience constructor to create CCodePhrase with only terminologyId * and single code * * @param path * @param terminologyId * @param code */ public CCodePhrase(String path, String terminologyId, String code) { super(false, path, CODE_PHRASE, new Interval<Integer>(0, 1), null, null, null, null); ArrayList<String> codeList = new ArrayList<String>(); codeList.add(code); this.codeList = codeList; this.terminologyId = new TerminologyID(terminologyId); }
/** * Retrieves the text for given code_prhase * * @param codePhrase * @return */ public String getText(CodePhrase codePhrase, String path) { return getText(codePhrase.getTerminologyId().toString(), codePhrase.getCodeString(), path); }
/** * Tests if two instances are strictly comparable. * * @param ordered * @return true if two instances are strictly comparable */ public boolean isStrictlyComparableTo(DvOrdered ordered) { if (!(ordered instanceof DvOrdinal)) { return false; } final DvOrdinal dvOrdinal = (DvOrdinal) ordered; if (!symbol.getDefiningCode().getTerminologyId().equals( dvOrdinal.symbol.getDefiningCode().getTerminologyId())) { return false; } // todo: check if symbols are from same subset or value range in the same vocabulary return true; }
protected void printOrdinal(Ordinal ordinal, Writer out) throws IOException { CodePhrase symbol = ordinal.getSymbol(); out.write(Integer.toString(ordinal.getValue())); out.write("|["); out.write(symbol.getTerminologyId().getValue()); out.write("::"); out.write(symbol.getCodeString()); out.write("]"); }
/** * Convenience constructor to create CCodePhrase with only terminologyId * and single code * * @param path * @param terminologyId * @param code */ public CCodePhrase(String path, String terminologyId, String code) { super(false, path, CODE_PHRASE, new Interval<Integer>(0, 1), null, null, null, null); ArrayList<String> codeList = new ArrayList<String>(); codeList.add(code); this.codeList = codeList; this.terminologyId = new TerminologyID(terminologyId); }
private void validateCCodePhrase(CCodePhrase ccodephrase, List<ValidationError> errors) { if (ccodephrase.getCodeList() == null || !TerminologyService.OPENEHR.equalsIgnoreCase( ccodephrase.getTerminologyId().toString())) { return; } StringBuffer buf = new StringBuffer(); for (String code : ccodephrase.getCodeList()) { if (!openEHRTerminology.allCodes().contains( new CodePhrase(TerminologyService.OPENEHR, code))) { buf.append(code + ", "); } } String codes = buf.toString(); if (codes.length() != 0) { ValidationError error = new ValidationError(ErrorType.VOTC, null, codes, ccodephrase.path()); errors.add(error); } }
private static Term getTerm(TermDefinition termDefinition, CodePhrase cp) { if (cp.getTerminologyId().getValue().equals(OpenEHRConst.LOCAL)) { if (termDefinition != null) { return termDefinition.getTerms().get(cp.getCodeString()); } } return null; }
/** * Creates a single required CCodePhrase with terminologyId and codeList * * @param path * @param terminologyId * @param codeList * @return */ public static CCodePhrase singleRequired(String path, String terminologyId, List<String> codeList) { Interval<Integer> occurrences = new Interval<Integer>(1,1); TerminologyID tid = new TerminologyID(terminologyId); return new CCodePhrase(path, occurrences, null, null, tid, codeList, null, null); }