private TermBindingSet TermBindingSetForTerminology(string terminology) { TermBindingSet result = null; if (!string.IsNullOrEmpty(terminology)) { int i = 0; TermBindingSet[] bindings = _archetype.ontology.term_bindings; if (bindings != null) { foreach (TermBindingSet ts in bindings) { if (ts.terminology == terminology) { result = ts; } } i = bindings.Length; } if (result == null) { Array.Resize(ref bindings, i + 1); bindings[i] = result = new TermBindingSet(); result.terminology = terminology; _archetype.ontology.term_bindings = bindings; } } return(result); }
public void AddOrReplaceTermBinding(string code, string archetypePath, string terminology, string terminologyIdValue) { TermBindingSet ts = TermBindingSetForTerminology(terminology); if (ts != null) { AddTerminology(terminology); TERM_BINDING_ITEM binding = null; TERM_BINDING_ITEM[] bindings = ts.items; if (bindings != null) { foreach (TERM_BINDING_ITEM b in bindings) { if (b.code == archetypePath) { binding = b; } } } if (binding == null) { int i = 0; if (bindings == null) { bindings = new TERM_BINDING_ITEM[1]; } else { i = bindings.Length; Array.Resize(ref bindings, i + 1); } ts.items = bindings; bindings[i] = binding = new TERM_BINDING_ITEM(); binding.code = archetypePath.ToLowerInvariant(); } if (binding.value == null) { binding.value = new CODE_PHRASE(); } if (binding.value.terminology_id == null) { binding.value.terminology_id = new TERMINOLOGY_ID(); } binding.value.terminology_id.value = terminologyIdValue; binding.value.code_string = code; } }
protected virtual TermBindingSet[] CloneTermBindingSet(EiffelStructures.table.HASH_TABLE_REFERENCE_REFERENCE o) { TermBindingSet[] result = null; if (o != null && o.count() > 0) { result = new TermBindingSet[o.count()]; o.start(); for (int i = 1; i <= o.count(); i++) { TermBindingSet termBindingSet = new TermBindingSet(); termBindingSet.terminology = o.key_for_iteration().ToString(); EiffelStructures.table.Impl.HASH_TABLE_REFERENCE_REFERENCE adlTerms = o.item_for_iteration() as EiffelStructures.table.Impl.HASH_TABLE_REFERENCE_REFERENCE; SortedList <string, TERM_BINDING_ITEM> localTerms = new SortedList <string, TERM_BINDING_ITEM>(); adlTerms.start(); for (int j = 1; j <= adlTerms.count(); j++) { openehr.openehr.rm.data_types.text.CODE_PHRASE term = adlTerms.item_for_iteration() as openehr.openehr.rm.data_types.text.CODE_PHRASE; if (term != null) { TERM_BINDING_ITEM localTerm = new TERM_BINDING_ITEM(); localTerm.code = adlTerms.key_for_iteration().ToString(); CODE_PHRASE codePhrase = new CODE_PHRASE(); codePhrase.code_string = term.code_string().ToString(); if (term.code_string() != null) { TERMINOLOGY_ID terminologyId = new TERMINOLOGY_ID(); terminologyId.value = term.terminology_id().value().ToString(); codePhrase.terminology_id = terminologyId; } localTerm.value = codePhrase; localTerms.Add(localTerm.code, localTerm); } adlTerms.forth(); } termBindingSet.items = new TERM_BINDING_ITEM[localTerms.Count]; localTerms.Values.CopyTo(termBindingSet.items, 0); result[i - 1] = termBindingSet; o.forth(); } } return(result); }
public void RemoveTermBinding(string a_path, string a_terminology_id) { TermBindingSet ts = GetBindings(a_terminology_id, _archetype.ontology.term_bindings); ArrayList bindingsArray = new ArrayList(ts.items); foreach (TERM_BINDING_ITEM b in ts.items) { if (b.code == a_path) { bindingsArray.Remove(b); break; } } ts.items = bindingsArray.ToArray() as TERM_BINDING_ITEM[]; }
TermBindingSet[] VisitTermBindings(TermBindingSet[] termBindings) { TermBindingSet[] result = null; if (termBindings != null) { SortedDictionary <string, TermBindingSet> sortedItems = new SortedDictionary <string, TermBindingSet>(); foreach (TermBindingSet bindingItem in termBindings) { TermBindingSet canonicalItem = new TermBindingSet(); canonicalItem.terminology = bindingItem.terminology; // sort term bindings items hash list canonicalItem.items = VisitTermBindingItems(bindingItem.items); sortedItems.Add(bindingItem.terminology, canonicalItem); } result = new TermBindingSet[sortedItems.Count]; sortedItems.Values.CopyTo(result, 0); } return(result); }
protected override TermBindingSet[] CloneTermBindingSet(EiffelSoftware.Library.Base.structures.table.HASH_TABLE_REFERENCE_REFERENCE currentObject) { List <TermBindingSet> termBindingSets = new List <TermBindingSet>(); if (currentObject != null) { if (currentObject.count() > 0) { currentObject.start(); // 0..* items TERM_BINDING_ITEM for (int i = 1; i <= currentObject.count(); i++) { TermBindingSet termBindingSet = new TermBindingSet(); //1 terminology string termBindingSet.terminology = currentObject.key_for_iteration().ToString(); //terms HASH table EiffelStructures.table.Impl.HASH_TABLE_REFERENCE_REFERENCE adlTerms; adlTerms = currentObject.item_for_iteration() as EiffelStructures.table.Impl.HASH_TABLE_REFERENCE_REFERENCE; SortedList <string, TERM_BINDING_ITEM> localTerms = new SortedList <string, TERM_BINDING_ITEM>(); adlTerms.start(); if (adlTerms.count() > 0) { for (int j = 1; j <= adlTerms.count(); j++) { openehr.openehr.rm.data_types.text.CODE_PHRASE term = adlTerms.item_for_iteration() as openehr.openehr.rm.data_types.text.CODE_PHRASE; if (term != null) { TERM_BINDING_ITEM localTerm = new TERM_BINDING_ITEM(); // 1 code string localTerm.code = adlTerms.key_for_iteration().ToString(); // 1 value CODE_PHRASE (CODE_PHRASE to HASH TABLE) CODE_PHRASE codePhrase = new CODE_PHRASE(); // 1 code_string string codePhrase.code_string = term.code_string().ToString(); // 1 terminology_id TERMINOLOGY_ID if (term.code_string() != null) { TERMINOLOGY_ID terminologyId = new TERMINOLOGY_ID(); terminologyId.value = term.terminology_id().value().ToString(); codePhrase.terminology_id = terminologyId; } localTerm.value = codePhrase; localTerms.Add(localTerm.code, localTerm); } adlTerms.forth(); } termBindingSet.items = new TERM_BINDING_ITEM[localTerms.Count]; localTerms.Values.CopyTo(termBindingSet.items, 0); } if (termBindingSet.items != null) { termBindingSets.Add(termBindingSet); } currentObject.forth(); } } } if (termBindingSets.Count > 0) { TermBindingSet[] termBindingSetArray = new TermBindingSet[termBindingSets.Count]; termBindingSets.CopyTo(termBindingSetArray); return(termBindingSetArray); } else { return(null); } }