private CodeValidationResult testIfConceptIsInListInner(List<ConceptDefinitionComponent> conceptList, boolean theCaseSensitive, String code) { CodeValidationResult retVal = null; for (ConceptDefinitionComponent next : conceptList) { String nextCandidate = next.getCode(); if (theCaseSensitive == false) { nextCandidate = nextCandidate.toUpperCase(); } if (nextCandidate.equals(code)) { retVal = new CodeValidationResult(next); break; } // recurse retVal = testIfConceptIsInList(code, next.getConcept(), theCaseSensitive); if (retVal != null) { break; } } return retVal; }
private void addAllChildren(String theSystemString, ConceptDefinitionComponent theCode, List<VersionIndependentConcept> theListToPopulate) { if (isNotBlank(theCode.getCode())) { theListToPopulate.add(new VersionIndependentConcept(theSystemString, theCode.getCode())); } for (ConceptDefinitionComponent nextChild : theCode.getConcept()) { addAllChildren(theSystemString, nextChild, theListToPopulate); } }
private boolean addTreeIfItContainsCode(String theSystemString, ConceptDefinitionComponent theNext, String theCode, List<VersionIndependentConcept> theListToPopulate) { boolean foundCodeInChild = false; for (ConceptDefinitionComponent nextChild : theNext.getConcept()) { foundCodeInChild |= addTreeIfItContainsCode(theSystemString, nextChild, theCode, theListToPopulate); } if (theCode.equals(theNext.getCode()) || foundCodeInChild) { theListToPopulate.add(new VersionIndependentConcept(theSystemString, theNext.getCode())); return true; } return false; }
private static ConceptDefinitionComponent findCode(List<ConceptDefinitionComponent> list, String code) { for (ConceptDefinitionComponent c : list) { if (c.getCode().equals(code)) return c; ConceptDefinitionComponent s = findCode(c.getConcept(), code); if (s != null) return s; } return null; }
private boolean addTreeIfItContainsCode(String theSystemString, ConceptDefinitionComponent theNext, String theCode, List<VersionIndependentConcept> theListToPopulate) { boolean foundCodeInChild = false; for (ConceptDefinitionComponent nextChild : theNext.getConcept()) { foundCodeInChild |= addTreeIfItContainsCode(theSystemString, nextChild, theCode, theListToPopulate); } if (theCode.equals(theNext.getCode()) || foundCodeInChild) { theListToPopulate.add(new VersionIndependentConcept(theSystemString, theNext.getCode())); return true; } return false; }
private void addAllChildren(String theSystemString, ConceptDefinitionComponent theCode, List<VersionIndependentConcept> theListToPopulate) { if (isNotBlank(theCode.getCode())) { theListToPopulate.add(new VersionIndependentConcept(theSystemString, theCode.getCode())); } for (ConceptDefinitionComponent nextChild : theCode.getConcept()) { addAllChildren(theSystemString, nextChild, theListToPopulate); } }
private static String getCodeDefinition(List<ConceptDefinitionComponent> list, String code) { for (ConceptDefinitionComponent c : list) { if (c.getCode().equals(code)) return c.getDefinition(); String s = getCodeDefinition(c.getConcept(), code); if (s != null) return s; } return null; }
private ConceptDefinitionComponent getConceptForCode(List<ConceptDefinitionComponent> clist, String code) { for (ConceptDefinitionComponent c : clist) { if (code.equals(c.getCode())) return c; ConceptDefinitionComponent v = getConceptForCode(c.getConcept(), code); if (v != null) return v; } return null; }
private void findCodesBelow(String theSystemString, String theCode, List<VersionIndependentConcept> theListToPopulate, List<ConceptDefinitionComponent> conceptList) { for (ConceptDefinitionComponent next : conceptList) { if (theCode.equals(next.getCode())) { addAllChildren(theSystemString, next, theListToPopulate); } else { findCodesBelow(theSystemString, theCode, theListToPopulate, next.getConcept()); } } }
/** * @return The first repetition of repeating field {@link #concept}, creating it if it does not already exist */ public ConceptDefinitionComponent getConceptFirstRep() { if (getConcept().isEmpty()) { addConcept(); } return getConcept().get(0); }
private boolean codeInDefine(List<ConceptDefinitionComponent> concepts, String code, boolean caseSensitive) { for (ConceptDefinitionComponent c : concepts) { if (caseSensitive && code.equals(c.getCode())) return true; if (!caseSensitive && code.equalsIgnoreCase(c.getCode())) return true; if (codeInDefine(c.getConcept(), code, caseSensitive)) return true; } return false; }
} else { ConceptDefinitionComponent p = concepts.get(parent.getAttribute("code")); p.getConcept().add(concept);
private void processConcept(List<ConceptDefinitionComponent> concepts, org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent cs, CodeSystem tgtcs) throws FHIRException { org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent ct = new org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent(); concepts.add(ct); ct.setCode(cs.getCode()); ct.setDisplay(cs.getDisplay()); ct.setDefinition(cs.getDefinition()); if (cs.getAbstract()) CodeSystemUtilities.setNotSelectable(tgtcs, ct); for (org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponent csd : cs.getDesignation()) { org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionDesignationComponent cst = new org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionDesignationComponent(); cst.setLanguage(csd.getLanguage()); cst.setUse(convertCoding(csd.getUse())); cst.setValue(csd.getValue()); } for (org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent csc : cs.getConcept()) processConcept(ct.getConcept(), csc, tgtcs); }
public static org.hl7.fhir.dstu2016may.model.CodeSystem.ConceptDefinitionComponent convertConceptDefinitionComponent(org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2016may.model.CodeSystem.ConceptDefinitionComponent tgt = new org.hl7.fhir.dstu2016may.model.CodeSystem.ConceptDefinitionComponent(); copyElement(src, tgt); tgt.setCode(src.getCode()); if (src.hasDisplay()) tgt.setDisplay(src.getDisplay()); if (src.hasDefinition()) tgt.setDefinition(src.getDefinition()); for (org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionDesignationComponent t : src.getDesignation()) tgt.addDesignation(convertConceptDefinitionDesignationComponent(t)); for (org.hl7.fhir.dstu3.model.CodeSystem.ConceptPropertyComponent t : src.getProperty()) tgt.addProperty(convertConceptPropertyComponent(t)); for (org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent t : src.getConcept()) tgt.addConcept(convertConceptDefinitionComponent(t)); return tgt; }
private void processConcept(List<org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent> concepts, ConceptDefinitionComponent cs, CodeSystem srcCS) throws FHIRException { org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent ct = new org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent(); concepts.add(ct); ct.setCode(cs.getCode()); ct.setDisplay(cs.getDisplay()); ct.setDefinition(cs.getDefinition()); if (CodeSystemUtilities.isNotSelectable(srcCS, cs)) ct.setAbstract(true); for (org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionDesignationComponent csd : cs.getDesignation()) { org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponent cst = new org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionDesignationComponent(); cst.setLanguage(csd.getLanguage()); cst.setUse(convertCoding(csd.getUse())); cst.setValue(csd.getValue()); } for (ConceptDefinitionComponent csc : cs.getConcept()) processConcept(ct.getConcept(), csc, srcCS); }
public org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent convertCodeSystemConcept(CodeSystem cs, ConceptDefinitionComponent src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent tgt = new org.hl7.fhir.instance.model.ValueSet.ConceptDefinitionComponent(); copyElement(src, tgt); tgt.setAbstract(CodeSystemUtilities.isNotSelectable(cs, src)); tgt.setCode(src.getCode()); tgt.setDefinition(src.getDefinition()); tgt.setDisplay(src.getDisplay()); for (ConceptDefinitionComponent cc : src.getConcept()) tgt.addConcept(convertCodeSystemConcept(cs, cc)); for (ConceptDefinitionDesignationComponent cc : src.getDesignation()) tgt.addDesignation(convertCodeSystemDesignation(cc)); return tgt; }
private List<TermConcept> toPersistedConcepts(List<ConceptDefinitionComponent> theConcept, TermCodeSystemVersion theCodeSystemVersion) { ArrayList<TermConcept> retVal = new ArrayList<>(); for (ConceptDefinitionComponent next : theConcept) { if (isNotBlank(next.getCode())) { TermConcept termConcept = new TermConcept(); termConcept.setCode(next.getCode()); termConcept.setCodeSystemVersion(theCodeSystemVersion); termConcept.setDisplay(next.getDisplay()); termConcept.addChildren(toPersistedConcepts(next.getConcept(), theCodeSystemVersion), RelationshipTypeEnum.ISA); retVal.add(termConcept); } } return retVal; }
private void findCodesBelow(String theSystemString, String theCode, List<VersionIndependentConcept> theListToPopulate, List<ConceptDefinitionComponent> conceptList) { for (ConceptDefinitionComponent next : conceptList) { if (theCode.equals(next.getCode())) { addAllChildren(theSystemString, next, theListToPopulate); } else { findCodesBelow(theSystemString, theCode, theListToPopulate, next.getConcept()); } } }
private void addConcepts(ConceptSetComponent theInclude, ValueSetExpansionComponent theRetVal, Set<String> theWantCodes, List<ConceptDefinitionComponent> theConcepts) { for (ConceptDefinitionComponent next : theConcepts) { if (theWantCodes.isEmpty() || theWantCodes.contains(next.getCode())) { theRetVal .addContains() .setSystem(theInclude.getSystem()) .setCode(next.getCode()) .setDisplay(next.getDisplay()); } addConcepts(theInclude, theRetVal, theWantCodes, next.getConcept()); } }
private ConceptDefinitionComponent getCodeDefinition(ConceptDefinitionComponent c, String code) { if (code.equals(c.getCode())) return c; for (ConceptDefinitionComponent g : c.getConcept()) { ConceptDefinitionComponent r = getCodeDefinition(g, code); if (r != null) return r; } return null; }