Exemplo n.º 1
0
        public void ADXPCastADXPToStringTest()
        {
            ADXP   ADXPToString = "Hamilton";
            String strOut       = ADXPToString;

            Assert.AreEqual("Hamilton", strOut);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Graph <paramref name="o"/> onto <paramref name="s"/>
        /// </summary>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            ADXP instance = o as ADXP;

            // Start with the part type and code attributes
            ANYFormatter baseFormatter = new ANYFormatter();

            baseFormatter.Graph(s, instance, result);

            // Format data
            if (instance.Type != null && instance.Type.HasValue)
            {
                s.WriteAttributeString("type", Util.ToWireFormat(instance.Type));
            }
            if (instance.Value != null)
            {
                s.WriteAttributeString("value", instance.Value);
            }
            if (instance.Code != null)
            {
                s.WriteAttributeString("code", instance.Code);
            }
            if (instance.CodeSystem != null)
            {
                s.WriteAttributeString("codeSystem", instance.CodeSystem);
            }
            if (instance.CodeSystemVersion != null)
            {
                s.WriteAttributeString("codeSystemVersion", instance.CodeSystemVersion);
            }
        }
Exemplo n.º 3
0
        public void ADXPValueType2Test()
        {
            ADXP adxp = new ADXP("Canada", AddressPartType.County);

            adxp.NullFlavor = null;
            Assert.IsTrue(adxp.Validate());
        }
Exemplo n.º 4
0
        public void ADXPCastStringToADXPTest()
        {
            ADXP StringToADXP = "Hamilton";

            Assert.AreEqual("Hamilton", StringToADXP.Value);
            Assert.AreEqual(null, StringToADXP.Type);
        }
Exemplo n.º 5
0
        public void ADXPValue2Test()
        {
            ADXP adxp = new ADXP("96 White Water Dr.");

            adxp.NullFlavor = null;
            Assert.IsTrue(adxp.Validate());
        }
Exemplo n.º 6
0
        public void ADXPTypeTest()
        {
            ADXP adxp = new ADXP();

            adxp.Value             = null;
            adxp.Type              = AddressPartType.City;
            adxp.Code              = null;
            adxp.CodeSystem        = null;
            adxp.CodeSystemVersion = null;
            adxp.NullFlavor        = null;
            Assert.IsFalse(adxp.Validate());
        }
Exemplo n.º 7
0
        public void ADXPValueTest()
        {
            ADXP adxp = new ADXP();

            adxp.Value             = "Port Dover";
            adxp.Type              = null;
            adxp.Code              = null;
            adxp.CodeSystem        = null;
            adxp.CodeSystemVersion = null;
            adxp.NullFlavor        = null;
            Assert.IsTrue(adxp.Validate());
        }
Exemplo n.º 8
0
        public void ADXPValueTypeCodeCodeSystemCodeSystemVersionTest()
        {
            ADXP adxp = new ADXP();

            adxp.Value             = "Port Dover";
            adxp.Type              = AddressPartType.City;
            adxp.Code              = "23.2487.35.12";
            adxp.CodeSystem        = "something";
            adxp.CodeSystemVersion = "3";
            adxp.NullFlavor        = null;
            Assert.IsTrue(adxp.Validate());
        }
Exemplo n.º 9
0
        public void ADXPValueTypeCodeTest()
        {
            ADXP adxp = new ADXP();

            adxp.Value             = "Port Dover";
            adxp.Type              = AddressPartType.City;
            adxp.Code              = "23.2483.122";
            adxp.CodeSystem        = null;
            adxp.CodeSystemVersion = null;
            adxp.NullFlavor        = null;
            Assert.IsFalse(adxp.Validate());
        }
Exemplo n.º 10
0
        public void ADXPNullFlavorTest()
        {
            ADXP adxp = new ADXP();

            adxp.Value             = null;
            adxp.Type              = null;
            adxp.Code              = null;
            adxp.CodeSystem        = null;
            adxp.CodeSystemVersion = null;
            adxp.NullFlavor        = NullFlavor.NotApplicable;
            Assert.IsTrue(adxp.Validate());
        }
Exemplo n.º 11
0
        /// <summary>
        /// Grap the object to a stream
        /// </summary>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result)
        {
            ADXP instance = o as ADXP;

            // Start with part type and code attributes
            ANYFormatter baseFormatter = new ANYFormatter();

            baseFormatter.Graph(s, o, result);

            if (instance.NullFlavor != null)
            {
                return;
            }

            // Now format our data
            if (instance.Type != null && result.CompatibilityMode != DatatypeFormatterCompatibilityMode.ClinicalDocumentArchitecture)
            {
                s.WriteAttributeString("partType", Util.ToWireFormat(instance.Type));
            }
            if (instance.Code != null)
            {
                if (result.CompatibilityMode == DatatypeFormatterCompatibilityMode.Canadian)
                {
                    s.WriteAttributeString("code", instance.Code);
                }
                else
                {
                    result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Code", "ADXP", s.ToString()));
                }
            }
            if (instance.Value != null)
            {
                s.WriteValue(instance.Value);
            }
            if (instance.CodeSystem != null) // Warn if there is no way to represent this in R1
            {
                result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "CodeSystem", "ADXP", s.ToString()));
            }
            if (instance.CodeSystemVersion != null)
            {
                result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "CodeSystemVersion", "ADXP", s.ToString()));
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Parse an ADXP from stream <paramref name="s"/>
        /// </summary>
        public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result)
        {
            // Parse base (ANY) from the stream
            ANYFormatter baseFormatter = new ANYFormatter();

            // Parse CS
            ADXP retVal = baseFormatter.Parse <ADXP>(s, result);

            // Now parse our data out...
            if (!s.IsEmptyElement)
            {
                if (s.GetAttribute("code") != null && result.CompatibilityMode == DatatypeFormatterCompatibilityMode.Canadian)
                {
                    retVal.Code = s.GetAttribute("code");
                }
                else
                {
                    result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "code", "ADXP", s.ToString()));
                }

                // Read next for text elemnt
                string sName = s.Name;
                s.Read();
                while (!(s.NodeType == System.Xml.XmlNodeType.EndElement && sName == s.Name))
                {
                    if (s.NodeType == System.Xml.XmlNodeType.Text)
                    {
                        retVal.Value = s.Value;
                    }
                    s.Read();
                }
            }

            // Validate
            string pathName = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name;

            baseFormatter.Validate(retVal, pathName, result);


            return(retVal);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Parse <paramref name="s"/> to an instance of ADXP
        /// </summary>
        public object Parse(System.Xml.XmlReader s, DatatypeR2FormatterParseResult result)
        {
            // Create base
            ANYFormatter baseFormatter = new ANYFormatter();
            ADXP         retVal        = baseFormatter.Parse <ADXP>(s);

            // Read data
            if (s.GetAttribute("type") != null)
            {
                retVal.Type = Util.Convert <AddressPartType>(s.GetAttribute("type"));
            }
            if (s.GetAttribute("code") != null)
            {
                retVal.Code = s.GetAttribute("code");
            }
            if (s.GetAttribute("codeSystem") != null)
            {
                retVal.CodeSystem = s.GetAttribute("codeSystem");
            }
            if (s.GetAttribute("codeSystemVersion") != null)
            {
                retVal.CodeSystemVersion = s.GetAttribute("codeSystemVersion");
            }
            if (s.GetAttribute("language") != null)
            {
                result.AddResultDetail(new NotImplementedElementResultDetail(ResultDetailType.Warning, "@language", s.NamespaceURI, s.ToString(), null));
            }
            if (s.GetAttribute("value") != null)
            {
                retVal.Value = s.GetAttribute("value");
            }

            // Validate
            baseFormatter.Validate(retVal, s.ToString(), result);
            return(retVal);
        }
Exemplo n.º 14
0
 public void ADXPValueTest()
 {
     ADXP adxp = new ADXP();
     adxp.Value = "Port Dover";
     adxp.Type = null;
     adxp.Code = null;
     adxp.CodeSystem = null;
     adxp.CodeSystemVersion = null;
     adxp.NullFlavor = null;
     Assert.IsTrue(adxp.Validate());
 }
Exemplo n.º 15
0
        /// <summary>
        /// Parse an object from <paramref name="s"/>
        /// </summary>
        /// <param name="s">The stream to parse</param>
        /// <returns>The parsed object</returns>
        public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result)
        {
            // Parse the address parts
            // Parse base (ANY) from the stream
            ANYFormatter baseFormatter = new ANYFormatter();

            // Parse CS
            AD retVal = baseFormatter.Parse <AD>(s, result);

            // Now parse our data out... Attributes
            if (s.GetAttribute("use") != null)
            {
                retVal.Use = (SET <CS <PostalAddressUse> >)Util.FromWireFormat(s.GetAttribute("use"), typeof(SET <CS <PostalAddressUse> >));
            }
            if (s.GetAttribute("isNotOrdered") != null)
            {
                retVal.IsNotOrdered = (bool)Util.FromWireFormat(s.GetAttribute("isNotOrdered"), typeof(bool));
            }

            // Loop through content
            // Elements
            #region Elements
            if (!s.IsEmptyElement)
            {
                int    sDepth = s.Depth;
                string sName  = s.Name;

                s.Read();
                // string Name
                while (!(s.NodeType == System.Xml.XmlNodeType.EndElement && s.Depth == sDepth && s.Name == sName))
                {
                    string oldName = s.Name; // Name
                    try
                    {
                        AddressPartType?adxpType;  // Address part type

                        // JF - This is a Canadian extension
                        if (s.LocalName == "useablePeriod") // Usable Period, since this is an SXCM we'll need to read manually
                        {
                            // Useable period doesn't exist
                            GTSFormatter sxcmFormatter = new GTSFormatter();
                            sxcmFormatter.Host   = this.Host;
                            retVal.UseablePeriod = sxcmFormatter.Parse(s, result) as GTS;
                        }

                        if (reverseMapping.TryGetValue(s.LocalName, out adxpType)) // Reverse map exists, so this is a part
                        {
                            ADXPFormatter adxpFormatter = new ADXPFormatter();     // ADXP Formatter
                            adxpFormatter.Host = this.Host;
                            ADXP part = (ADXP)adxpFormatter.Parse(s, result);      // Parse
                            part.Type = adxpType;
                            retVal.Part.Add(part);                                 // Add to AD
                        }
                    }
                    catch (MessageValidationException e)
                    {
                        result.AddResultDetail(new ResultDetail(ResultDetailType.Error, e.Message, s.ToString(), e)); // Append details
                    }
                    finally
                    {
                        if (oldName == s.Name)
                        {
                            s.Read();                    // Read if we need to
                        }
                    }
                }
            }
            #endregion

            // Validate
            string pathName = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name;
            baseFormatter.Validate(retVal, pathName, result);
            return(retVal);
        }
Exemplo n.º 16
0
 public void ADXPValue2Test()
 {
     ADXP adxp = new ADXP("96 White Water Dr.");
     adxp.NullFlavor = null;
     Assert.IsTrue(adxp.Validate());
 }
Exemplo n.º 17
0
 public void ADXPValueType2Test()
 {
     ADXP adxp = new ADXP("Canada", AddressPartType.County);
     adxp.NullFlavor = null;
     Assert.IsTrue(adxp.Validate());
 }
Exemplo n.º 18
0
 public void ADXPValueTypeCodeCodeSystemCodeSystemVersionTest()
 {
     ADXP adxp = new ADXP();
     adxp.Value = "Port Dover";
     adxp.Type = AddressPartType.City;
     adxp.Code = "23.2487.35.12";
     adxp.CodeSystem = "something";
     adxp.CodeSystemVersion = "3";
     adxp.NullFlavor = null;
     Assert.IsTrue(adxp.Validate());
 }
Exemplo n.º 19
0
 public void ADXPValueTypeCodeTest()
 {
     ADXP adxp = new ADXP();
     adxp.Value = "Port Dover";
     adxp.Type = AddressPartType.City;
     adxp.Code = "23.2483.122";
     adxp.CodeSystem = null;
     adxp.CodeSystemVersion = null;
     adxp.NullFlavor = null;
     Assert.IsFalse(adxp.Validate());
 }
Exemplo n.º 20
0
 public void ADXPTypeTest()
 {
     ADXP adxp = new ADXP();
     adxp.Value = null;
     adxp.Type = AddressPartType.City;
     adxp.Code = null;
     adxp.CodeSystem = null;
     adxp.CodeSystemVersion = null;
     adxp.NullFlavor = null;
     Assert.IsFalse(adxp.Validate());
 }
Exemplo n.º 21
0
 public void ADXPNullFlavorTest()
 {
     ADXP adxp = new ADXP();
     adxp.Value = null;
     adxp.Type = null;
     adxp.Code = null;
     adxp.CodeSystem = null;
     adxp.CodeSystemVersion = null;
     adxp.NullFlavor = NullFlavor.NotApplicable;
     Assert.IsTrue(adxp.Validate());
 }
Exemplo n.º 22
0
        public void ADXPToStringMethodTest()
        {
            ADXP ADXPToStringMethod = "Hamilton";

            Assert.AreEqual("Hamilton", ADXPToStringMethod.ToString());
        }