Ejemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="language">Language of translation</param>
 /// <param name="author">Translator name and other demographic details</param>
 /// <param name="accreditation">Accreditation of translator, usually a national translator’s association id</param>
 /// <param name="otherDetails">Any other meta-data</param>
 public TranslationDetails(CodePhrase language, AssumedTypes.Hash <string, string> author,
                           string accreditation, AssumedTypes.Hash <string, string> otherDetails)
 {
     this.language      = language;
     this.author        = author;
     this.accreditation = accreditation;
     this.otherDetails  = otherDetails;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="language">Language of translation</param>
 /// <param name="author">Translator name and other demographic details</param>
 /// <param name="accreditation">Accreditation of translator, usually a national translator’s association id</param>
 /// <param name="otherDetails">Any other meta-data</param>
 public TranslationDetails(CodePhrase language, AssumedTypes.Hash<string, string> author,
     string accreditation, AssumedTypes.Hash<string, string> otherDetails)
 {
     this.language = language;
     this.author = author;
     this.accreditation = accreditation;
     this.otherDetails = otherDetails;
 }
Ejemplo n.º 3
0
        public Annotation(Dictionary<string, string> itemsDictionary, string path)
        {
            Check.Require(!string.IsNullOrEmpty(path), "path should not be null or empty");
            Check.Require(itemsDictionary != null, "itemsDictionary should not be null");

            this.path = path;
            this.items = new OpenEhr.AssumedTypes.Hash<string, string>(itemsDictionary);
        }
Ejemplo n.º 4
0
        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();
                }
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="originalAuthor">Original author of this resource, with all relevant details, including organisation.</param>
 /// <param name="lifecycleState">Lifecycle state of the resource, typically including states such as: initial, submitted, experimental,
 /// awaiting_approval, approved, superseded, obsolete.</param>
 /// <param name="details">Details of all parts of resource description that are natural language-dependent, keyed by language code.</param>
 /// <param name="resourcePackageUri">URI of package to which this resource belongs.</param>
 /// <param name="otherContributors">Other contributors to the resource, probably listed in “name <email>” form.</param>
 /// <param name="otherDetails">Additional non language-senstive resource meta-data, as a list of name/value pairs.</param>
 /// <param name="parentResource">Reference to owning resource.</param>
 public ResourceDescription(AssumedTypes.Hash <string, string> originalAuthor, string lifecycleState,
                            AssumedTypes.Hash <ResourceDescriptionItem, string> details, string resourcePackageUri,
                            AssumedTypes.List <string> otherContributors, AssumedTypes.Hash <string, string> otherDetails,
                            AuthoredResource parentResource) : this(originalAuthor, lifecycleState, details)
 {
     this.resourcePackageUri = resourcePackageUri;
     this.otherContributors  = otherContributors;
     this.otherDetails       = otherDetails;
     this.parentResource     = parentResource;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="originalAuthor">Original author of this resource, with all relevant details, including organisation.</param>
 /// <param name="lifecycleState">Lifecycle state of the resource, typically including states such as: initial, submitted, experimental,
 /// awaiting_approval, approved, superseded, obsolete.</param>
 /// <param name="details">Details of all parts of resource description that are natural language-dependent, keyed by language code.</param>
 /// <param name="resourcePackageUri">URI of package to which this resource belongs.</param>
 /// <param name="otherContributors">Other contributors to the resource, probably listed in “name <email>” form.</param>
 /// <param name="otherDetails">Additional non language-senstive resource meta-data, as a list of name/value pairs.</param>
 /// <param name="parentResource">Reference to owning resource.</param>
 public ResourceDescription(AssumedTypes.Hash<string, string> originalAuthor, string lifecycleState,
     AssumedTypes.Hash<ResourceDescriptionItem, string> details, string resourcePackageUri, 
     AssumedTypes.List<string> otherContributors, AssumedTypes.Hash<string, string> otherDetails, 
     AuthoredResource parentResource)
     : this(originalAuthor, lifecycleState, details)
 {
     this.resourcePackageUri = resourcePackageUri;
     this.otherContributors = otherContributors;
     this.otherDetails = otherDetails;
     this.parentResource = parentResource;
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="originalAuthor">Original author of this resource, with all relevant details, including organisation.</param>
        /// <param name="lifecycleState">Lifecycle state of the resource, typically including states such as: initial, submitted, experimental,
        /// awaiting_approval, approved, superseded, obsolete.</param>
        /// <param name="details">Details of all parts of resource description that are natural language-dependent, keyed by language code.</param>
        public ResourceDescription(AssumedTypes.Hash<string, string> originalAuthor, string lifecycleState, 
            AssumedTypes.Hash<ResourceDescriptionItem, string> details)
        {
            Check.Require(originalAuthor!=null && !originalAuthor.IsEmpty(), "originalAuthor must not be null or empty.");
            Check.Require(!string.IsNullOrEmpty(lifecycleState), "lifecycleState must not be null or empty.");
            Check.Require(details!=null && !details.IsEmpty(), "details must not be null or empty.");

            this.originalAuthor = originalAuthor;
            this.lifecycleState = lifecycleState;
            this.details = details;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="originalAuthor">Original author of this resource, with all relevant details, including organisation.</param>
        /// <param name="lifecycleState">Lifecycle state of the resource, typically including states such as: initial, submitted, experimental,
        /// awaiting_approval, approved, superseded, obsolete.</param>
        /// <param name="details">Details of all parts of resource description that are natural language-dependent, keyed by language code.</param>
        public ResourceDescription(AssumedTypes.Hash <string, string> originalAuthor, string lifecycleState,
                                   AssumedTypes.Hash <ResourceDescriptionItem, string> details)
        {
            Check.Require(originalAuthor != null && !originalAuthor.IsEmpty(), "originalAuthor must not be null or empty.");
            Check.Require(!string.IsNullOrEmpty(lifecycleState), "lifecycleState must not be null or empty.");
            Check.Require(details != null && !details.IsEmpty(), "details must not be null or empty.");

            this.originalAuthor = originalAuthor;
            this.lifecycleState = lifecycleState;
            this.details        = details;
        }
Ejemplo n.º 9
0
        internal void ReadXml(System.Xml.XmlReader reader)
        {
            reader.ReadStartElement();
            reader.MoveToContent();

            Check.Assert(reader.LocalName == "language", "Expected local name is 'language', not " + reader.LocalName);
            this.language = new CodePhrase();
            this.language.ReadXml(reader);

            Check.Assert(reader.LocalName == "author", "Expected local name is 'author', not " + reader.LocalName);

            System.Collections.Generic.Dictionary <string, string> authorDic
                = new System.Collections.Generic.Dictionary <string, string>();
            while (reader.LocalName == "author")
            {
                string id = reader.GetAttribute("id");
                Check.Assert(!string.IsNullOrEmpty(id), "attribute 'id' must not be null or empty for author");
                string value = reader.ReadElementContentAsString();

                authorDic.Add(id, value);
            }
            Check.Assert(authorDic.Count > 0, "Expected at least one author item in the dictionary.");
            this.author = new OpenEhr.AssumedTypes.Hash <string, string>(authorDic);

            if (reader.LocalName == "accreditation")
            {
                this.accreditation = reader.ReadElementString("accreditation", RmXmlSerializer.OpenEhrNamespace);
            }

            System.Collections.Generic.Dictionary <string, string> otherDetailsDic
                = new System.Collections.Generic.Dictionary <string, string>();
            while (reader.LocalName == "other_details")
            {
                string id = reader.GetAttribute("id");
                Check.Assert(!string.IsNullOrEmpty(id), "attribute 'id' must not be null or empty for other_details");
                string value = reader.ReadElementString("other_details", RmXmlSerializer.OpenEhrNamespace);

                otherDetailsDic.Add(id, value);
            }
            if (otherDetailsDic.Count > 0)
            {
                this.otherDetails = new OpenEhr.AssumedTypes.Hash <string, string>(otherDetailsDic);
            }

            reader.MoveToContent();

            if (!reader.IsStartElement())
            {
                reader.ReadEndElement();
                reader.MoveToContent();
            }
        }
Ejemplo n.º 10
0
        protected AuthoredResource(CodePhrase originalLanguage, AssumedTypes.Hash<TranslationDetails, string> translations,
           ResourceDescription description, Generic.RevisionHistory revisionHistory, bool isControlled)
            : this(originalLanguage, revisionHistory, isControlled)
        {
            DesignByContract.Check.Require(translations == null ^
                (translations.Keys.Count>0 && !translations.HasKey(this.originalLanguage.CodeString)),
                "translations is not null means it must not be empty and it must not contains original language.");
            DesignByContract.Check.Require(translations == null ^ (description != null && translations != null),
               "if translations !=null, descriptions must not be null");

            this.translations = translations;
            this.description = description;
        }
Ejemplo n.º 11
0
        protected AuthoredResource(CodePhrase originalLanguage, AssumedTypes.Hash <TranslationDetails, string> translations,
                                   ResourceDescription description, Generic.RevisionHistory revisionHistory, bool isControlled) :
            this(originalLanguage, revisionHistory, isControlled)
        {
            DesignByContract.Check.Require(translations == null ^
                                           (translations.Keys.Count > 0 && !translations.HasKey(this.originalLanguage.CodeString)),
                                           "translations is not null means it must not be empty and it must not contains original language.");
            DesignByContract.Check.Require(translations == null ^ (description != null && translations != null),
                                           "if translations !=null, descriptions must not be null");


            this.translations = translations;
            this.description  = description;
        }
Ejemplo n.º 12
0
        /// <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);
        }
Ejemplo n.º 13
0
        /// <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));
        }
Ejemplo n.º 14
0
        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="language">The localised language in which the items in this description item are written. Coded from
        /// openEHR Code Set “languages”.</param>
        /// <param name="purpose">Purpose of the resource.</param>
        /// <param name="keywords">Keywords which characterise this resource, used e.g. for indexing and searching.</param>
        /// <param name="use">Description of the uses of the resource, i.e. contexts in which it could be used.</param>
        /// <param name="misuse">Description of any misuses of the resource, i.e. contexts in which it should not be used.</param>
        /// <param name="copyright">Optional copyright statement for the resource as a knowledge resource.</param>
        /// <param name="originalResourceUri">URIs of original clinical document(s) or description of which resource is a formalisation,
        /// in the language of this description item; keyed by meaning.</param>
        /// <param name="otherDetails">Additional language-senstive resource metadata, as a list of name/value pairs.</param>
        public ResourceDescriptionItem(CodePhrase language, string purpose, AssumedTypes.List <string> keywords,
                                       string use, string misuse, string copyright, AssumedTypes.Hash <string, string> originalResourceUri,
                                       AssumedTypes.Hash <string, string> otherDetails) : this(language, purpose)
        {
            Check.Require(use == null || use != string.Empty, "if use is not null, it must not be empty");
            Check.Require(misuse == null || misuse != string.Empty, "if misuse is not null, it must not be empty");
            Check.Require(copyright == null || copyright != string.Empty, "if copyright is not null, it must not be empty");

            this.language            = language;
            this.purpose             = purpose;
            this.purpose             = purpose;
            this.keywords            = keywords;
            this.use                 = use;
            this.misuse              = misuse;
            this.copyright           = copyright;
            this.originalResourceUri = originalResourceUri;
            this.otherDetails        = otherDetails;
        }
Ejemplo n.º 15
0
        internal void ReadXml(System.Xml.XmlReader reader)
        {
            Check.Assert(reader.LocalName == "original_language", "Expected LocalName is 'original_language' rather than " + reader.LocalName);
            this.originalLanguage = new CodePhrase();
            this.OriginalLanguage.ReadXml(reader);

            if (reader.LocalName == "is_controlled")
            {
                this.IsControlled = reader.ReadElementContentAsBoolean("is_controlled", RmXmlSerializer.OpenEhrNamespace);
            }
            if (reader.LocalName == "description")
            {
                this.description = new ResourceDescription();
                this.description.ReadXml(reader);
            }

            string translationsNodeName = "translations";

            if (reader.LocalName == translationsNodeName)
            {
                System.Collections.Generic.Dictionary <string, TranslationDetails> translationDic = new Dictionary <string, TranslationDetails>();
                do
                {
                    TranslationDetails transDetails = new TranslationDetails();
                    transDetails.ReadXml(reader);

                    translationDic.Add(transDetails.Language.CodeString, transDetails);
                } while (reader.LocalName == translationsNodeName);

                if (translationDic.Count > 0)
                {
                    this.translations = new OpenEhr.AssumedTypes.Hash <TranslationDetails, string>(translationDic);
                }
            }

            if (reader.LocalName == "revision_history")
            {
                this.revisionHistory = new OpenEhr.RM.Common.Generic.RevisionHistory();
                this.revisionHistory.ReadXml(reader);
            }
        }
Ejemplo n.º 16
0
        internal void ReadXml(System.Xml.XmlReader reader)
        {
            Check.Assert(reader.LocalName == "original_language", "Expected LocalName is 'original_language' rather than " + reader.LocalName);
            this.originalLanguage = new CodePhrase();
            this.OriginalLanguage.ReadXml(reader);

            if (reader.LocalName == "is_controlled")
            {
                this.IsControlled = reader.ReadElementContentAsBoolean("is_controlled", RmXmlSerializer.OpenEhrNamespace);

            }
            if (reader.LocalName == "description")
            {
                this.description = new ResourceDescription();
                this.description.ReadXml(reader);
            }

            string translationsNodeName = "translations";
            if (reader.LocalName == translationsNodeName)
            {
                System.Collections.Generic.Dictionary<string, TranslationDetails> translationDic = new Dictionary<string, TranslationDetails>();
                do
                {
                    TranslationDetails transDetails = new TranslationDetails();
                    transDetails.ReadXml(reader);

                    translationDic.Add(transDetails.Language.CodeString, transDetails);
                } while (reader.LocalName == translationsNodeName);

                if (translationDic.Count > 0)
                    this.translations = new OpenEhr.AssumedTypes.Hash<TranslationDetails, string>(translationDic);
            }

            if (reader.LocalName == "revision_history")
            {
                this.revisionHistory = new OpenEhr.RM.Common.Generic.RevisionHistory();
                this.revisionHistory.ReadXml(reader);
            }
        }
Ejemplo n.º 17
0
 public ArchetypeTerm(string aCode, AssumedTypes.Hash <string, string> items)
 {
     this.Code  = aCode;
     this.Items = items;
 }
Ejemplo n.º 18
0
        internal void ReadXml(System.Xml.XmlReader reader)
        {
            reader.ReadStartElement();
            reader.MoveToContent();

            Check.Assert(reader.LocalName == "language", "Expected local name is 'language', not " + reader.LocalName);
            this.language = new CodePhrase();
            this.language.ReadXml(reader);

            Check.Assert(reader.LocalName == "author", "Expected local name is 'author', not " + reader.LocalName);

            System.Collections.Generic.Dictionary<string, string> authorDic
                = new System.Collections.Generic.Dictionary<string, string>();
            while (reader.LocalName == "author")
            {
                string id = reader.GetAttribute("id");
                Check.Assert(!string.IsNullOrEmpty(id), "attribute 'id' must not be null or empty for author");
                string value = reader.ReadElementContentAsString();

                authorDic.Add(id, value);

            }
            Check.Assert(authorDic.Count>0, "Expected at least one author item in the dictionary.");
            this.author = new OpenEhr.AssumedTypes.Hash<string, string>(authorDic);

            if (reader.LocalName == "accreditation")
            {
                this.accreditation = reader.ReadElementString("accreditation", RmXmlSerializer.OpenEhrNamespace);
            }

            System.Collections.Generic.Dictionary<string, string> otherDetailsDic
                = new System.Collections.Generic.Dictionary<string,string>();
            while (reader.LocalName == "other_details")
            {
                string id = reader.GetAttribute("id");
                Check.Assert(!string.IsNullOrEmpty(id), "attribute 'id' must not be null or empty for other_details");
                string value = reader.ReadElementString("other_details", RmXmlSerializer.OpenEhrNamespace);

                otherDetailsDic.Add(id, value);

            }
            if (otherDetailsDic.Count > 0)
                this.otherDetails = new OpenEhr.AssumedTypes.Hash<string, string>(otherDetailsDic);

            reader.MoveToContent();

            if (!reader.IsStartElement())
            {
                reader.ReadEndElement();
                reader.MoveToContent();
            }
        }
Ejemplo n.º 19
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="language">Language of translation</param>
 /// <param name="author">Translator name and other demographic details</param>
 public TranslationDetails(CodePhrase language, AssumedTypes.Hash<string, string> author)
 {
     this.language = language;
     this.author = author;
 }
Ejemplo n.º 20
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="language">Language of translation</param>
 /// <param name="author">Translator name and other demographic details</param>
 public TranslationDetails(CodePhrase language, AssumedTypes.Hash <string, string> author)
 {
     this.language = language;
     this.author   = author;
 }
Ejemplo n.º 21
0
        internal void ReadXml(System.Xml.XmlReader reader)
        {
            reader.ReadStartElement();
            reader.MoveToContent();

            Check.Assert(reader.LocalName == "language", "Expected local name is 'language', not " + reader.LocalName);
            this.language = new CodePhrase();
            this.language.ReadXml(reader);

            Check.Assert(reader.LocalName == "purpose", "Expected local name is 'purpose', not " + reader.LocalName);
            this.purpose = reader.ReadElementString("purpose", RmXmlSerializer.OpenEhrNamespace);
            reader.MoveToContent();

            while (reader.LocalName == "keywords")
            {
                if (this.keywords == null)
                {
                    this.keywords = new OpenEhr.AssumedTypes.List <string>();
                }
                this.keywords.Add(reader.ReadElementString("keywords", RmXmlSerializer.OpenEhrNamespace));
                reader.MoveToContent();
            }

            if (reader.LocalName == "use")
            {
                // TODO don't need this when the xml instance is fixed
                if (reader.IsEmptyElement)
                {
                    reader.Skip();
                }
                else
                {
                    this.use = reader.ReadElementString("use", RmXmlSerializer.OpenEhrNamespace);
                }
                reader.MoveToContent();
            }

            if (reader.LocalName == "misuse")
            {
                // TODO don't need this when the xml instance is fixed
                if (reader.IsEmptyElement)
                {
                    reader.Skip();
                }
                else
                {
                    this.misuse = reader.ReadElementString("misuse", RmXmlSerializer.OpenEhrNamespace);
                }
                reader.MoveToContent();
            }

            if (reader.LocalName == "copyright")
            {
                // TODO don't need this when the xml instance is fixed
                if (reader.IsEmptyElement)
                {
                    reader.Skip();
                }
                else
                {
                    this.Copyright = reader.ReadElementString("copyright", RmXmlSerializer.OpenEhrNamespace);
                }
                reader.MoveToContent();
            }

            if (reader.LocalName == "original_resource_uri")
            {
                System.Collections.Generic.Dictionary <string, string> originalResourceUriDic =
                    new System.Collections.Generic.Dictionary <string, string>();
                while (reader.LocalName == "original_resource_uri")
                {
                    string id = reader.GetAttribute("id");
                    if (string.IsNullOrEmpty(id))
                    {
                        throw new ValidationException("original_resource_uri must have id attribute and its value must not be null or empty.");
                    }
                    string value = reader.ReadElementString("original_resource_uri", RmXmlSerializer.OpenEhrNamespace);
                    reader.MoveToContent();
                    if (string.IsNullOrEmpty(value))
                    {
                        throw new ValidationException("original_resource_uri value must not be null or empty.");
                    }

                    originalResourceUriDic.Add(id, value);
                }
                if (originalResourceUriDic.Count <= 0)
                {
                    throw new ValidationException("originalResourceUriDic must not be empty.");
                }

                this.originalResourceUri = new OpenEhr.AssumedTypes.Hash <string, string>(originalResourceUriDic);
            }

            if (reader.LocalName == "other_details")
            {
                System.Collections.Generic.Dictionary <string, string> otherDetailsUriDic =
                    new System.Collections.Generic.Dictionary <string, string>();
                while (reader.LocalName == "other_details")
                {
                    string id = reader.GetAttribute("id");
                    if (string.IsNullOrEmpty(id))
                    {
                        throw new ValidationException("original_resource_uri must have id attribute and its value must not be null or empty.");
                    }
                    string value = reader.ReadElementString("original_resource_uri", RmXmlSerializer.OpenEhrNamespace);
                    reader.MoveToContent();
                    if (string.IsNullOrEmpty(value))
                    {
                        throw new ValidationException("original_resource_uri value must not be null or empty.");
                    }

                    otherDetailsUriDic.Add(id, value);
                }
                if (otherDetailsUriDic.Count <= 0)
                {
                    throw new ValidationException("originalResourceUriDic must not be empty.");
                }

                this.otherDetails = new OpenEhr.AssumedTypes.Hash <string, string>(otherDetailsUriDic);
            }

            if (!reader.IsStartElement())
            {
                reader.ReadEndElement();
                reader.MoveToContent();
            }
        }
Ejemplo n.º 22
0
        internal void ReadXml(System.Xml.XmlReader reader)
        {
            reader.ReadStartElement();
            reader.MoveToContent();

            Check.Assert(reader.LocalName == "original_author", "Expected local name is 'original_author', not " + reader.LocalName);
            this.originalAuthor = GetHashData(reader, "original_author");
            reader.MoveToContent();

            string otherContributors = "other_contributors";
            if (reader.LocalName == otherContributors)
            {
                this.otherContributors = new OpenEhr.AssumedTypes.List<string>();
                do
                {
                    this.otherContributors.Add(reader.ReadElementString(otherContributors, RmXmlSerializer.OpenEhrNamespace));
                    reader.MoveToContent();
                } while (reader.LocalName == otherContributors);
            }

            string lifeCycle = "lifecycle_state";
            Check.Assert(reader.LocalName == lifeCycle, "Expected reader.LocalName is " + lifeCycle + ", not " + reader.LocalName);
            this.lifecycleState = reader.ReadElementString(lifeCycle, RmXmlSerializer.OpenEhrNamespace);
            reader.MoveToContent();

            string resourcePackageUriNodeName = "resource_package_uri";
            if (reader.LocalName == resourcePackageUriNodeName)
            {
                this.resourcePackageUri = reader.ReadElementString(resourcePackageUriNodeName, RmXmlSerializer.OpenEhrNamespace);
                reader.MoveToContent();
            }

            string otherDetailsNodeName = "other_details";
            if (reader.LocalName == otherDetailsNodeName)
            {
                this.otherDetails = GetHashData(reader, otherDetailsNodeName);
            }

            string detailsNodeName = "details";
            if (reader.LocalName == detailsNodeName)
            {
                System.Collections.Generic.Dictionary<string, ResourceDescriptionItem> detailsDic =
                    new System.Collections.Generic.Dictionary<string, ResourceDescriptionItem>();
                do
                {
                    ResourceDescriptionItem item = new ResourceDescriptionItem();
                    item.ReadXml(reader);

                    detailsDic.Add(item.Language.CodeString, item);

                } while (reader.LocalName == detailsNodeName);

                if (detailsDic.Count > 0)
                    this.details = new OpenEhr.AssumedTypes.Hash<ResourceDescriptionItem, string>(detailsDic);
            }

            string parentResourceNodeName = "parent_resource";
            if (reader.LocalName == parentResourceNodeName)
            {
                string resourceType = reader.GetAttribute("type", RmXmlSerializer.XsiNamespace);

                this.parentResource = RmFactory.Instance.AuthoredResource(resourceType);
                DesignByContract.Check.Assert(parentResource != null, "must have an object with the type of "+resourceType);

                this.parentResource.ReadXml(reader);
            }

            if (!reader.IsStartElement())
            {
                reader.ReadEndElement();
                reader.MoveToContent();
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="language">The localised language in which the items in this description item are written. Coded from
        /// openEHR Code Set “languages”.</param>
        /// <param name="purpose">Purpose of the resource.</param>
        /// <param name="keywords">Keywords which characterise this resource, used e.g. for indexing and searching.</param>
        /// <param name="use">Description of the uses of the resource, i.e. contexts in which it could be used.</param>
        /// <param name="misuse">Description of any misuses of the resource, i.e. contexts in which it should not be used.</param>
        /// <param name="copyright">Optional copyright statement for the resource as a knowledge resource.</param>
        /// <param name="originalResourceUri">URIs of original clinical document(s) or description of which resource is a formalisation,
        /// in the language of this description item; keyed by meaning.</param>
        /// <param name="otherDetails">Additional language-senstive resource metadata, as a list of name/value pairs.</param>
        public ResourceDescriptionItem(CodePhrase language, string purpose, AssumedTypes.List<string> keywords,
            string use, string misuse, string copyright, AssumedTypes.Hash<string, string> originalResourceUri,
            AssumedTypes.Hash<string, string> otherDetails)
            : this(language, purpose)
        {
            Check.Require(use == null || use != string.Empty, "if use is not null, it must not be empty");
            Check.Require(misuse == null || misuse != string.Empty, "if misuse is not null, it must not be empty");
            Check.Require(copyright == null || copyright != string.Empty, "if copyright is not null, it must not be empty");

            this.language = language;
            this.purpose = purpose;
            this.purpose = purpose;
            this.keywords = keywords;
            this.use = use;
            this.misuse = misuse;
            this.copyright = copyright;
            this.originalResourceUri = originalResourceUri;
            this.otherDetails = otherDetails;
        }
Ejemplo n.º 24
0
        internal void ReadXml(System.Xml.XmlReader reader)
        {
            reader.ReadStartElement();
            reader.MoveToContent();

            Check.Assert(reader.LocalName == "language", "Expected local name is 'language', not " + reader.LocalName);
            this.language = new CodePhrase();
            this.language.ReadXml(reader);

            Check.Assert(reader.LocalName == "purpose", "Expected local name is 'purpose', not " + reader.LocalName);
            this.purpose = reader.ReadElementString("purpose", RmXmlSerializer.OpenEhrNamespace);
            reader.MoveToContent();

            while (reader.LocalName == "keywords")
            {
                if (this.keywords == null)
                    this.keywords = new OpenEhr.AssumedTypes.List<string>();
                this.keywords.Add(reader.ReadElementString("keywords", RmXmlSerializer.OpenEhrNamespace));
                reader.MoveToContent();
            }

            if (reader.LocalName == "use")
            {
                // TODO don't need this when the xml instance is fixed
                if (reader.IsEmptyElement)
                    reader.Skip();
                else
                    this.use = reader.ReadElementString("use", RmXmlSerializer.OpenEhrNamespace);
                reader.MoveToContent();
            }

            if (reader.LocalName == "misuse")
            {
                // TODO don't need this when the xml instance is fixed
                if (reader.IsEmptyElement)
                    reader.Skip();
                else
                    this.misuse = reader.ReadElementString("misuse", RmXmlSerializer.OpenEhrNamespace);
                reader.MoveToContent();
            }

            if (reader.LocalName == "copyright")
            {
                // TODO don't need this when the xml instance is fixed
                if (reader.IsEmptyElement)
                    reader.Skip();
                else
                    this.Copyright = reader.ReadElementString("copyright", RmXmlSerializer.OpenEhrNamespace);
                reader.MoveToContent();
            }

            if (reader.LocalName == "original_resource_uri")
            {
                System.Collections.Generic.Dictionary<string, string> originalResourceUriDic =
                    new System.Collections.Generic.Dictionary<string, string>();
                while (reader.LocalName == "original_resource_uri")
                {
                    string id = reader.GetAttribute("id");
                    if (string.IsNullOrEmpty(id))
                        throw new ValidationException("original_resource_uri must have id attribute and its value must not be null or empty.");
                    string value = reader.ReadElementString("original_resource_uri", RmXmlSerializer.OpenEhrNamespace);
                    reader.MoveToContent();
                    if (string.IsNullOrEmpty(value))
                        throw new ValidationException("original_resource_uri value must not be null or empty.");

                    originalResourceUriDic.Add(id, value);
                }
                if (originalResourceUriDic.Count <= 0)
                    throw new ValidationException("originalResourceUriDic must not be empty.");

                this.originalResourceUri = new OpenEhr.AssumedTypes.Hash<string, string>(originalResourceUriDic);
            }

            if (reader.LocalName == "other_details")
            {
                System.Collections.Generic.Dictionary<string, string> otherDetailsUriDic =
                    new System.Collections.Generic.Dictionary<string, string>();
                while (reader.LocalName == "other_details")
                {
                    string id = reader.GetAttribute("id");
                    if (string.IsNullOrEmpty(id))
                        throw new ValidationException("original_resource_uri must have id attribute and its value must not be null or empty.");
                    string value = reader.ReadElementString("original_resource_uri", RmXmlSerializer.OpenEhrNamespace);
                    reader.MoveToContent();
                    if (string.IsNullOrEmpty(value))
                        throw new ValidationException("original_resource_uri value must not be null or empty.");

                    otherDetailsUriDic.Add(id, value);
                }
                if (otherDetailsUriDic.Count <= 0)
                    throw new ValidationException("originalResourceUriDic must not be empty.");

                this.otherDetails = new OpenEhr.AssumedTypes.Hash<string, string>(otherDetailsUriDic);
            }

            if (!reader.IsStartElement())
            {
                reader.ReadEndElement();
                reader.MoveToContent();
            }
        }
Ejemplo n.º 25
0
        internal void ReadXml(System.Xml.XmlReader reader)
        {
            reader.ReadStartElement();
            reader.MoveToContent();

            Check.Assert(reader.LocalName == "original_author", "Expected local name is 'original_author', not " + reader.LocalName);
            this.originalAuthor = GetHashData(reader, "original_author");
            reader.MoveToContent();

            string otherContributors = "other_contributors";

            if (reader.LocalName == otherContributors)
            {
                this.otherContributors = new OpenEhr.AssumedTypes.List <string>();
                do
                {
                    this.otherContributors.Add(reader.ReadElementString(otherContributors, RmXmlSerializer.OpenEhrNamespace));
                    reader.MoveToContent();
                } while (reader.LocalName == otherContributors);
            }

            string lifeCycle = "lifecycle_state";

            Check.Assert(reader.LocalName == lifeCycle, "Expected reader.LocalName is " + lifeCycle + ", not " + reader.LocalName);
            this.lifecycleState = reader.ReadElementString(lifeCycle, RmXmlSerializer.OpenEhrNamespace);
            reader.MoveToContent();

            string resourcePackageUriNodeName = "resource_package_uri";

            if (reader.LocalName == resourcePackageUriNodeName)
            {
                this.resourcePackageUri = reader.ReadElementString(resourcePackageUriNodeName, RmXmlSerializer.OpenEhrNamespace);
                reader.MoveToContent();
            }

            string otherDetailsNodeName = "other_details";

            if (reader.LocalName == otherDetailsNodeName)
            {
                this.otherDetails = GetHashData(reader, otherDetailsNodeName);
            }

            string detailsNodeName = "details";

            if (reader.LocalName == detailsNodeName)
            {
                System.Collections.Generic.Dictionary <string, ResourceDescriptionItem> detailsDic =
                    new System.Collections.Generic.Dictionary <string, ResourceDescriptionItem>();
                do
                {
                    ResourceDescriptionItem item = new ResourceDescriptionItem();
                    item.ReadXml(reader);

                    detailsDic.Add(item.Language.CodeString, item);
                } while (reader.LocalName == detailsNodeName);

                if (detailsDic.Count > 0)
                {
                    this.details = new OpenEhr.AssumedTypes.Hash <ResourceDescriptionItem, string>(detailsDic);
                }
            }

            string parentResourceNodeName = "parent_resource";

            if (reader.LocalName == parentResourceNodeName)
            {
                string resourceType = reader.GetAttribute("type", RmXmlSerializer.XsiNamespace);

                this.parentResource = RmFactory.Instance.AuthoredResource(resourceType);
                DesignByContract.Check.Assert(parentResource != null, "must have an object with the type of " + resourceType);

                this.parentResource.ReadXml(reader);
            }

            if (!reader.IsStartElement())
            {
                reader.ReadEndElement();
                reader.MoveToContent();
            }
        }