void WriteCArchetypeRoot(XmlWriter writer, CArchetypeRoot cArchetypeRoot) { Check.Require(cArchetypeRoot != null, string.Format(CommonStrings.XMustNotBeNull, "cArchetypeRoot")); Check.Require(cArchetypeRoot.ArchetypeId != null, string.Format(CommonStrings.XMustNotBeNull, "cArchetypeRoot.ArchetypeId")); string openEhrPrefix = UseOpenEhrPrefix(writer); WriteCComplexObject(writer, cArchetypeRoot); writer.WriteStartElement(RmXmlSerializer.UseOpenEhrPrefix(writer), "archetype_id", OpenEhrNamespace); cArchetypeRoot.ArchetypeId.WriteXml(writer); writer.WriteEndElement(); if (cArchetypeRoot.TemplateId != null) { writer.WriteStartElement(RmXmlSerializer.UseOpenEhrPrefix(writer), "template_id", OpenEhrNamespace); cArchetypeRoot.TemplateId.WriteXml(writer); writer.WriteEndElement(); } if (cArchetypeRoot.TermDefinitions != null && cArchetypeRoot.TermDefinitions.Count > 0) { foreach (System.Collections.Generic.KeyValuePair <string, ArchetypeTerm> item in cArchetypeRoot.TermDefinitions) { writer.WriteStartElement(openEhrPrefix, "term_definitions", OpenEhrNamespace); amSerializer.WriteArchetypeTerm(writer, item.Value); writer.WriteEndElement(); } } if (cArchetypeRoot.TermBindings != null && cArchetypeRoot.TermBindings.Count > 0) { foreach (string terminology in cArchetypeRoot.TermBindings.Keys) { writer.WriteStartElement(openEhrPrefix, "term_bindings", OpenEhrNamespace); writer.WriteAttributeString("terminology", terminology); AssumedTypes.Hash <CodePhrase, string> eachTermBindingItem = cArchetypeRoot.TermBindings.Item(terminology); foreach (string code in eachTermBindingItem.Keys) { writer.WriteStartElement(openEhrPrefix, "items", OpenEhrNamespace); writer.WriteAttributeString("code", code); writer.WriteStartElement(openEhrPrefix, "value", OpenEhrNamespace); eachTermBindingItem.Item(code).WriteXml(writer); writer.WriteEndElement(); writer.WriteEndElement(); } writer.WriteEndElement(); } } }
/// <summary> /// Binding of constraint corresponding to a_code in target external terminology a_terminology_id, /// as a string, which is usually a formal query expression. /// </summary> /// <param name="aTerminologyId"></param> /// <param name="aCode"></param> /// <returns></returns> public string ConstraintBinding(string aTerminologyId, string aCode) { Check.Require(this.HasTerminology(aTerminologyId), string.Format(CommonStrings.OntologyMissingTerminologyX, aTerminologyId)); Check.Require(this.HasTermCode(aCode), string.Format(CommonStrings.OntologyMissingCode, aCode)); AssumedTypes.Hash <DvUri, string> terminologySpecificConstraintBinding = this.ConstraintBindings.Item(aTerminologyId); if (terminologySpecificConstraintBinding == null) { throw new ApplicationException(string.Format( CommonStrings.XMustNotBeNull, "terminologySpecificConstraintBinding")); } return(terminologySpecificConstraintBinding.Item(aCode).Value); }
/// <summary> /// Constraint definition for a code, in a specified language. /// </summary> /// <param name="aLang"></param> /// <param name="aCode"></param> /// <returns></returns> public ArchetypeTerm ConstraintDefinition(string aLang, string aCode) { Check.Require(this.HasLanguage(aLang), string.Format(CommonStrings.OntologyMissingLanguageX, aLang)); Check.Require(this.HasTermCode(aCode), string.Format(CommonStrings.OntologyMissingCode, aCode)); AssumedTypes.Hash <ArchetypeTerm, string> languageSpecificConstraintDefinitions = this.TermDefinitions.Item(aLang); if (languageSpecificConstraintDefinitions == null) { throw new ApplicationException(string.Format( CommonStrings.XMustNotBeNull, "languageSpecificConstraintDefinitions")); } return(languageSpecificConstraintDefinitions.Item(aCode)); }