コード例 #1
0
 public string Cast(FhirUri uri)
 {
     if (uri != null)
         return uri.ToString();
     else
         return null;
 }
コード例 #2
0
        public static void SerializeFhirUri(Hl7.Fhir.Model.FhirUri value, IFhirWriter writer, bool summary)
        {
            writer.WriteStartComplexContent();

            // Serialize element value
            if (value.Value != null)
            {
                writer.WritePrimitiveContents("value", value, XmlSerializationHint.Attribute);
            }

            // Serialize element _id
            if (value.LocalIdElement != null)
            {
                writer.WritePrimitiveContents("_id", value.LocalIdElement, XmlSerializationHint.Attribute);
            }

            // Serialize element extension
            if (value.Extension != null && !summary && value.Extension.Count > 0)
            {
                writer.WriteStartArrayElement("extension");
                foreach (var item in value.Extension)
                {
                    writer.WriteStartArrayMember("extension");
                    ExtensionSerializer.SerializeExtension(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }


            writer.WriteEndComplexContent();
        }
コード例 #3
0
        public void OIDandUUIDUrls()
        {
            var oidUrl = "urn:oid:1.2.3";
            var illOidUrl = "urn:oid:datmagdusniet";
            var uuidUrl = "urn:uuid:a5afddf4-e880-459b-876e-e4591b0acc11";
            var illUuidUrl = "urn:uuid:ooknietgoed";
            var oidWithZero = "urn:oid:1.2.0.3.4";

            FhirUri uri = new FhirUri(oidUrl);
            Validator.ValidateObject(uri, new ValidationContext(uri), true);

            uri = new FhirUri(illOidUrl);
            validateErrorOrFail(uri);

            uri = new FhirUri(uuidUrl);
            Validator.ValidateObject(uri, new ValidationContext(uri), true);

            uri = new FhirUri(illUuidUrl);
            validateErrorOrFail(uri);

            uri = new FhirUri(oidWithZero);
            Validator.ValidateObject(uri, new ValidationContext(uri), true);

            Assert.IsTrue(Uri.Equals(new Uri("http://nu.nl"), new Uri("http://nu.nl")));
        }
コード例 #4
0
        private List <Expression> ToExpressions(FhirModel.FhirUri element)
        {
            if (element == null || String.Empty.Equals(element.Value))
            {
                return(null);
            }

            return(ListOf(new StringValue(element.Value)));
        }
コード例 #5
0
        public static FhirUri Parse(string value)
        {
            FhirUri result = null;

            if (TryParse(value, out result))
            {
                return(result);
            }
            else
            {
                throw new FhirFormatException("Not a correctly formatted Uri");
            }
        }
コード例 #6
0
        public static bool TryParse(string value, out FhirUri result)
        {
            System.Uri uriValue = null;
            bool       succ     = System.Uri.TryCreate(value, UriKind.RelativeOrAbsolute, out uriValue);

            if (succ)
            {
                result = new FhirUri(uriValue);
                return(true);
            }
            else
            {
                result = null;
                return(false);
            }
        }
コード例 #7
0
ファイル: FhirUri.cs プロジェクト: avontd2868/vista-novo-fhir
        public static bool TryParse( string value, out FhirUri result)
        {
            System.Uri uriValue = null;
            bool succ = System.Uri.TryCreate(value, UriKind.RelativeOrAbsolute, out uriValue);

            if (succ)
            {
                result = new FhirUri(uriValue);
                return true;
            }
            else
            {
                result = null;
                return false;
            }
        }
コード例 #8
0
        /// <summary>
        /// Parse uri
        /// </summary>
        public static Hl7.Fhir.Model.FhirUri ParseFhirUri(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.FhirUri existingInstance = null)
        {
            Hl7.Fhir.Model.FhirUri result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.FhirUri();
            string currentElementName     = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "extension"))
                    {
                        result.Extension.Add(ExtensionParser.ParseExtension(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

                // Parse element value
                else if (atName == "value")
                {
                    result.Value = FhirUri.Parse(reader.ReadPrimitiveContents(typeof(FhirUri))).Value;
                }

                else
                {
                    errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader);
                    reader.SkipSubElementsFor(currentElementName);
                    result = null;
                }
            }

            reader.LeaveElement();
            return(result);
        }
コード例 #9
0
        public void TestIsNullOrEmpty_Coding()
        {
            var coding = new Coding();

            Assert.IsTrue(coding.IsNullOrEmpty());

            var uri = new FhirUri();

            Assert.IsTrue(uri.IsNullOrEmpty());
            coding.SystemElement = uri;
            Assert.IsTrue(coding.IsNullOrEmpty());

            uri.Value = "http://example.org/";
            Assert.IsFalse(uri.IsNullOrEmpty());
            Assert.IsFalse(coding.IsNullOrEmpty());
            Assert.IsFalse((coding as Base).IsNullOrEmpty());

            uri.Value = null;
            Assert.IsTrue(uri.IsNullOrEmpty());
            Assert.IsTrue(coding.IsNullOrEmpty());

            var extension = new Extension();

            Assert.IsTrue(extension.IsNullOrEmpty());
            coding.Extension.Add(extension);
            Assert.IsTrue(coding.IsNullOrEmpty());

            var extensionValue = new Coding(null, "test");

            Assert.IsFalse(extensionValue.IsNullOrEmpty());
            extension.Value = extensionValue;
            Assert.IsFalse(extension.IsNullOrEmpty());
            Assert.IsFalse(coding.IsNullOrEmpty());
            Assert.IsFalse((coding as Base).IsNullOrEmpty());

            extensionValue.Code = null;
            Assert.IsTrue(extensionValue.IsNullOrEmpty());
            Assert.IsTrue(extension.IsNullOrEmpty());
            Assert.IsTrue(coding.IsNullOrEmpty());

            coding.Extension.Clear();
            Assert.IsTrue(coding.IsNullOrEmpty());
        }
コード例 #10
0
 public bool IsTargetOf(FhirUri reference)
 {
     return IsTargetOf(new ResourceIdentity(reference.Value));
 }