protected override void CleanUpCodeDefinitionSet(CodeDefinitionSet codeDefinitionSet) { foreach (ARCHETYPE_TERM term in codeDefinitionSet.items) { foreach (StringDictionaryItem item in term.items) if (item.id == "text") { item.Value = item.Value.Trim(); break; } } }
protected virtual void CleanUpCodeDefinitionSet(CodeDefinitionSet codeDefinitionSet) { }
CodeDefinitionSet[] VisitCodeDefinitions(CodeDefinitionSet[] codeDefinitions) { CodeDefinitionSet[] result = null; if (codeDefinitions != null) { SortedDictionary<string, CodeDefinitionSet> sortedCodeDefinitions = new SortedDictionary<string, CodeDefinitionSet>(); foreach (CodeDefinitionSet codeDefinitionItem in codeDefinitions) { string language = codeDefinitionItem.language; if (!string.IsNullOrEmpty(language)) { CodeDefinitionSet canonicalItem = new CodeDefinitionSet(); canonicalItem.language = language; // Canonicalise code definitions items canonicalItem.items = VisitArchetypeTerms(codeDefinitionItem.items); sortedCodeDefinitions.Add(language, canonicalItem); } } result = new CodeDefinitionSet[sortedCodeDefinitions.Count]; sortedCodeDefinitions.Values.CopyTo(result, 0); } return result; }
protected virtual CodeDefinitionSet[] CloneCodeDefinitions(EiffelStructures.table.HASH_TABLE_REFERENCE_REFERENCE o) { CodeDefinitionSet[] result = null; if (o != null) { result = new CodeDefinitionSet[o.count()]; o.start(); for (int i = 1; i <= result.Length; i++) { CodeDefinitionSet codeDefinitionSet = new CodeDefinitionSet(); codeDefinitionSet.language = 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, ARCHETYPE_TERM> localTerms = new SortedList<string, ARCHETYPE_TERM>(); adlTerms.start(); for (int j = 1; j <= adlTerms.count(); j++) { openehr.openehr.am.archetype.ontology.Impl.ARCHETYPE_TERM term = adlTerms.item_for_iteration() as openehr.openehr.am.archetype.ontology.Impl.ARCHETYPE_TERM; ARCHETYPE_TERM localTerm = new ARCHETYPE_TERM(); localTerm.code = term.code().ToString(); localTerm.items = CloneHashTableAny(term.items()); localTerms.Add(localTerm.code, localTerm); adlTerms.forth(); } codeDefinitionSet.items = new ARCHETYPE_TERM[localTerms.Count]; localTerms.Values.CopyTo(codeDefinitionSet.items, 0); CleanUpCodeDefinitionSet(codeDefinitionSet); result[i - 1] = codeDefinitionSet; o.forth(); } } return result; }
private void RemoveUnusedTerms(CodeDefinitionSet languageSet, ArrayList termsUsed) { if (languageSet != null && languageSet.items != null) { int archetypeSpecialisationDepth = NumberOfSpecialisations; ArrayList items = new ArrayList(); foreach (ARCHETYPE_TERM term in languageSet.items) { if (termsUsed.Contains(term.code) || term.code.Split('.').Length - 1 < archetypeSpecialisationDepth) items.Add(term); } languageSet.items = (ARCHETYPE_TERM[])items.ToArray(typeof(ARCHETYPE_TERM)); } }
protected void AddTermOrConstraintDefinitionForLanguage(CodeDefinitionSet ls, ARCHETYPE_TERM term) { if (ls.items == null) ls.items = new ARCHETYPE_TERM[1]; else { ARCHETYPE_TERM[] t = ls.items; Array.Resize(ref t, t.Length + 1); ls.items = t; } ls.items[ls.items.Length - 1] = term; }
public CodeDefinitionSet GetConstraintLanguageSet(string language) { CodeDefinitionSet result = null; if (!string.IsNullOrEmpty(language)) { int i = 0; CodeDefinitionSet[] definitions = _archetype.ontology.constraint_definitions; if (definitions != null) { foreach (CodeDefinitionSet ls in definitions) { if (ls.language == language) result = ls; } i = definitions.Length; } if (result == null) { Array.Resize(ref definitions, i + 1); definitions[i] = result = new CodeDefinitionSet(); result.language = language; _archetype.ontology.constraint_definitions = definitions; } } return result; }
protected string NextTermOrConstraintId(CodeDefinitionSet[] definitions, string prefix) { string result = prefix; int next = 1; if (definitions != null && definitions.Length > 0 && definitions[0].items != null) { foreach (ARCHETYPE_TERM t in definitions[0].items) { string code = ""; if (NumberOfSpecialisations == 0) { code = t.code.Replace(prefix, ""); } else { string[] split = t.code.Split('.'); int n = split.Length - 1; if (NumberOfSpecialisations == n) code = split[n]; } int i = 0; if (int.TryParse(code, out i) && next <= i) next = i + 1; } } if (NumberOfSpecialisations == 0) result += next.ToString().PadLeft(4, Char.Parse("0")); else { for (int i = 0; i < NumberOfSpecialisations; i++) { result += "0."; } result += next.ToString(); } return result; }