public void ReadOperationalTemplate(XmlReader reader, OperationalTemplate template)
        {
            Check.Require(reader != null, string.Format(CommonStrings.XMustNotBeNull, "reader"));
            Check.Require(template != null, string.Format(CommonStrings.XMustNotBeNull, "template"));

            reader.ReadStartElement();  //template
            reader.MoveToContent();

            CodePhrase language = new CodePhrase();

            language.ReadXml(reader);
            template.Language = language;

            if (reader.LocalName == "is_controlled")
            {
                reader.ReadElementContentAsBoolean("is_controlled", RmXmlSerializer.OpenEhrNamespace);
                reader.MoveToContent();
            }

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

            if (reader.LocalName == "revision_history")
            {
                RevisionHistory revisionHistory = new RevisionHistory();
                revisionHistory.ReadXml(reader);
                template.RevisionHistory = revisionHistory;
            }

            if (reader.LocalName == "uid")
            {
                HierObjectId uid = new HierObjectId();
                uid.ReadXml(reader);
                template.Uid = uid;
            }

            TemplateId templateId = new TemplateId();

            templateId.ReadXml(reader);
            template.TemplateId = templateId;

            template.Concept = reader.ReadElementContentAsString("concept", RmXmlSerializer.OpenEhrNamespace);
            reader.MoveToContent();

            CArchetypeRoot definition = new CArchetypeRoot();

            ReadCArchetypeRoot(reader, definition);
            template.Definition = definition;

            // LMT added 12 May 2010 for TMP-1252
            if (reader.LocalName == "annotations")
            {
                template.Annotations =
                    new List <OpenEhr.RM.Common.Resource.Annotation>();
                OpenEhr.RM.Common.Resource.Annotation currentAnnotation;
                while (reader.LocalName == "annotations")
                {
                    currentAnnotation = ReadAnnotation(reader);
                    template.Annotations.Add(currentAnnotation);
                    reader.MoveToContent();
                }
            }

            if (reader.LocalName == "constraints")
            {
                TConstraint constraints = new TConstraint();
                ReadTConstraint(reader, constraints);
                template.Constraints = constraints;
            }

            if (reader.LocalName == "view")
            {
                TView view = new TView();
                ReadTView(reader, view);
                template.View = view;
            }

            reader.ReadEndElement();    // template
            reader.MoveToContent();
        }
Beispiel #2
0
        public void WriteOperationalTemplate(XmlWriter writer, OperationalTemplate operationalTemplate)
        {
            Check.Require(writer != null, string.Format(CommonStrings.XMustNotBeNull, "writer"));
            Check.Require(operationalTemplate != null, string.Format(CommonStrings.XMustNotBeNull, "operationalTemplate"));

            string openEhrPrefix = RmXmlSerializer.UseOpenEhrPrefix(writer);
            string xsiPrefix     = RmXmlSerializer.UseXsiPrefix(writer);
            string xsdPrefix     = RmXmlSerializer.UseXsdPrefix(writer);

            writer.WriteStartElement(openEhrPrefix, "language", OpenEhrNamespace);
            operationalTemplate.Language.WriteXml(writer);
            writer.WriteEndElement();

            if (operationalTemplate.IsControlled.HasValue)
            {
                writer.WriteElementString(openEhrPrefix,
                                          "is_controlled", OpenEhrNamespace, operationalTemplate.IsControlled.ToString());
            }

            if (operationalTemplate.Description != null)
            {
                writer.WriteStartElement(openEhrPrefix, "description", OpenEhrNamespace);
                operationalTemplate.Description.WriteXml(writer);
                writer.WriteEndElement();
            }

            if (operationalTemplate.RevisionHistory != null)
            {
                writer.WriteStartElement(openEhrPrefix, "revision_history", OpenEhrNamespace);
                operationalTemplate.RevisionHistory.WriteXml(writer);
                writer.WriteEndElement();
            }

            if (operationalTemplate.Uid != null)
            {
                writer.WriteStartElement(openEhrPrefix, "uid", OpenEhrNamespace);
                operationalTemplate.Uid.WriteXml(writer);
                writer.WriteEndElement();
            }

            writer.WriteStartElement(openEhrPrefix, "template_id", OpenEhrNamespace);
            operationalTemplate.TemplateId.WriteXml(writer);
            writer.WriteEndElement();

            writer.WriteElementString(openEhrPrefix,
                                      "concept", OpenEhrNamespace, operationalTemplate.Concept);

            //Edited by LMT 28/Apr/2009
            writer.WriteStartElement(openEhrPrefix, "definition", OpenEhrNamespace);
            WriteCArchetypeRoot(writer, operationalTemplate.Definition);
            writer.WriteEndElement();

            // LMT added 12 May 2010 for TMP-1252
            if (operationalTemplate.Annotations != null)
            {
                foreach (OpenEhr.RM.Common.Resource.Annotation note in operationalTemplate.Annotations)
                {
                    WriteAnnotation(writer, openEhrPrefix, note);
                }
            }

            if (operationalTemplate.Constraints != null && operationalTemplate.Constraints.Attributes != null && operationalTemplate.Constraints.Attributes.Count > 0)
            {
                writer.WriteStartElement(openEhrPrefix, "constraints", OpenEhrNamespace);
                WriteTConstraint(writer, operationalTemplate.Constraints);
                writer.WriteEndElement();
            }

            if (operationalTemplate.View != null)
            {
                Check.Assert(operationalTemplate.View.Constraints != null);
                writer.WriteStartElement(openEhrPrefix, "view", OpenEhrNamespace);
                WriteTView(writer, operationalTemplate.View);
                writer.WriteEndElement();
            }
        }
        public void WriteOperationalTemplate(XmlWriter writer, OperationalTemplate operationalTemplate)
        {
            Check.Require(writer != null, string.Format(CommonStrings.XMustNotBeNull, "writer"));
            Check.Require(operationalTemplate != null, string.Format(CommonStrings.XMustNotBeNull, "operationalTemplate"));

            string openEhrPrefix = RmXmlSerializer.UseOpenEhrPrefix(writer);
            string xsiPrefix = RmXmlSerializer.UseXsiPrefix(writer);
            string xsdPrefix = RmXmlSerializer.UseXsdPrefix(writer);

            writer.WriteStartElement(openEhrPrefix, "language", OpenEhrNamespace);
            operationalTemplate.Language.WriteXml(writer);
            writer.WriteEndElement();

            if (operationalTemplate.IsControlled.HasValue)
            {
                writer.WriteElementString(openEhrPrefix,
                    "is_controlled", OpenEhrNamespace, operationalTemplate.IsControlled.ToString());
            }

            if (operationalTemplate.Description != null)
            {
                writer.WriteStartElement(openEhrPrefix, "description", OpenEhrNamespace);
                operationalTemplate.Description.WriteXml(writer);
                writer.WriteEndElement();
            }

            if (operationalTemplate.RevisionHistory != null)
            {
                writer.WriteStartElement(openEhrPrefix, "revision_history", OpenEhrNamespace);
                operationalTemplate.RevisionHistory.WriteXml(writer);
                writer.WriteEndElement();
            }

            if (operationalTemplate.Uid != null)
            {
                writer.WriteStartElement(openEhrPrefix, "uid", OpenEhrNamespace);
                operationalTemplate.Uid.WriteXml(writer);
                writer.WriteEndElement();
            }

            writer.WriteStartElement(openEhrPrefix, "template_id", OpenEhrNamespace);
            operationalTemplate.TemplateId.WriteXml(writer);
            writer.WriteEndElement();

            writer.WriteElementString(openEhrPrefix,
                "concept", OpenEhrNamespace, operationalTemplate.Concept);

            //Edited by LMT 28/Apr/2009
            writer.WriteStartElement(openEhrPrefix, "definition", OpenEhrNamespace);
            WriteCArchetypeRoot(writer, operationalTemplate.Definition);
            writer.WriteEndElement();

            // LMT added 12 May 2010 for TMP-1252
            if(operationalTemplate.Annotations != null)
                foreach(OpenEhr.RM.Common.Resource.Annotation note in operationalTemplate.Annotations)
                    WriteAnnotation(writer, openEhrPrefix, note);

            if (operationalTemplate.Constraints != null && operationalTemplate.Constraints.Attributes != null && operationalTemplate.Constraints.Attributes.Count > 0)
            {
                writer.WriteStartElement(openEhrPrefix, "constraints", OpenEhrNamespace);
                WriteTConstraint(writer, operationalTemplate.Constraints);
                writer.WriteEndElement();
            }

            if(operationalTemplate.View != null)
            {
                Check.Assert(operationalTemplate.View.Constraints != null);
                writer.WriteStartElement(openEhrPrefix, "view", OpenEhrNamespace);
                WriteTView(writer, operationalTemplate.View);
                writer.WriteEndElement();
            }
        }