コード例 #1
0
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result)
        {
            // Get an instance ref
            ICodedSimple instance_ics = (ICodedSimple)o;

            // Do a base format
            ANYFormatter baseFormatter = new ANYFormatter();

            baseFormatter.Graph(s, o as ANY, result);

            // Format the coded simple
            if (instance_ics.CodeValue != null && ((ANY)o).NullFlavor == null)
            {
                s.WriteAttributeString("code", Util.ToWireFormat(instance_ics.CodeValue));
            }
            //if ((o is CS<String> || o.GetType().GetGenericTypeDefinition() == typeof(CS<>)))
            //{
            //    if (instance_ics.CodeSystem != null) // Warn if there is no way to represent this in R1
            //        result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "CodeSystem", "CS", s.ToString()));
            //    else if (instance_ics.CodeSystemName != null)
            //        result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "CodeSystemName", "CS", s.ToString()));
            //    else if (instance_ics.CodeSystemVersion != null)
            //        result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "CodeSystemVersion", "CS", s.ToString()));
            //}
        }
コード例 #2
0
ファイル: CSFormatter.cs プロジェクト: zzllkk2003/everest
        /// <summary>
        /// Graph object <paramref name="o"/> to <paramref name="s"/>
        /// </summary>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            // Get an instance ref
            ICodedSimple instance_ics = (ICodedSimple)o;

            // Do a base format
            ANYFormatter baseFormatter = new ANYFormatter();

            baseFormatter.Graph(s, o as ANY, result);

            // Format the coded simple
            if (instance_ics.CodeValue != null && ((ANY)o).NullFlavor == null)
            {
                s.WriteAttributeString("code", Util.ToWireFormat(instance_ics.CodeValue));
            }
        }
コード例 #3
0
ファイル: CDFormatter.cs プロジェクト: zzllkk2003/everest
        /// <summary>
        /// Graph <paramref name="o"/> onto <paramref name="s"/>
        /// </summary>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            // Base formatter
            ANYFormatter baseFormatter = new ANYFormatter();

            baseFormatter.Graph(s, o, result);

            // Next, start to format the properties
            ICodedSimple       cs = o as ICodedSimple;
            ICodedValue        cv = o as ICodedValue;
            ICodedEquivalents  ce = o as ICodedEquivalents;
            IConceptDescriptor cd = o as IConceptDescriptor;

            ST   displayName = cv.DisplayName;
            IAny any         = o as IAny;

            // Unless "other" is specified don't serialize
            if (any.NullFlavor != null && !((NullFlavor)any.NullFlavor).IsChildConcept(NullFlavor.Other))
            {
                return;
            }

            // First we need to serialize code, now Code in R2 is a little wierd
            // It is an IHTSDO standard as described:
            // http://www.ihtsdo.org/fileadmin/user_upload/Docs_01/Technical_Docs/abstract_models_and_representational_forms.pdf
            // Serialize attributes first
            if (cs.CodeValue != null)
            {
                try
                {
                    if (cd != null && cd.Qualifier != null && cd.Qualifier.Count > 0)
                    {
                        s.WriteAttributeString("code", CreateCodeExpression(cd));
                        displayName = null;
                    }
                    else
                    {
                        s.WriteAttributeString("code", Util.ToWireFormat(cs.CodeValue));
                    }
                }
                catch (Exception e)
                {
                    result.AddResultDetail(new VocabularyIssueResultDetail(ResultDetailType.Error, e.Message, s.ToString(), e));
                }
            }
            if (cv.CodeSystem != null)
            {
                s.WriteAttributeString("codeSystem", Util.ToWireFormat(cv.CodeSystem));
            }
            if (cv.CodeSystemName != null)
            {
                s.WriteAttributeString("codeSystemName", Util.ToWireFormat(cv.CodeSystemName));
            }
            if (cv.CodeSystemVersion != null)
            {
                s.WriteAttributeString("codeSystemVersion", Util.ToWireFormat(cv.CodeSystemVersion));
            }
            if (cv.ValueSet != null)
            {
                s.WriteAttributeString("valueSet", Util.ToWireFormat(cv.ValueSet));
            }
            if (cv.ValueSetVersion != null)
            {
                s.WriteAttributeString("valueSetVersion", Util.ToWireFormat(cv.ValueSetVersion));
            }
            if (cv.CodingRationale != null)
            {
                s.WriteAttributeString("codingRationale", Util.ToWireFormat(cv.CodingRationale));
            }

            // Elements

            // Display name
            if (displayName != null)
            {
                s.WriteStartElement("displayName", "urn:hl7-org:v3");
                var hostResult = this.Host.Graph(s, displayName as IGraphable);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
            }

            // Original text
            if (cv.OriginalText != null)
            {
                s.WriteStartElement("originalText", "urn:hl7-org:v3");
                var hostResult = this.Host.Graph(s, cv.OriginalText);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
            }

            // Translation
            if (ce != null && ce.Translation != null)
            {
                foreach (var translation in ce.Translation)
                {
                    s.WriteStartElement("translation", "urn:hl7-org:v3");
                    var hostResult = this.Host.Graph(s, translation);
                    result.Code = hostResult.Code;
                    result.AddResultDetail(hostResult.Details);
                    s.WriteEndElement();
                }
            }

            // Done
        }