コード例 #1
0
        public void ToDelimitedString_WithAllProperties_ReturnsCorrectlySequencedFields()
        {
            IType hl7Type = new QuerySelectionCriteria
            {
                SegmentFieldName   = "1",
                RelationalOperator = "2",
                Value = "3",
                RelationalConjunction = "4"
            };

            string expected = "1^2^3^4";
            string actual   = hl7Type.ToDelimitedString();

            Assert.Equal(expected, actual);
        }
コード例 #2
0
        public void FromDelimitedString_WithAllProperties_ReturnsCorrectlyInitializedFields()
        {
            IType expected = new QuerySelectionCriteria
            {
                SegmentFieldName   = "1",
                RelationalOperator = "2",
                Value = "3",
                RelationalConjunction = "4"
            };

            IType actual = new QuerySelectionCriteria();

            actual.FromDelimitedString("1^2^3^4");

            expected.Should().BeEquivalentTo(actual);
        }
コード例 #3
0
        /// <inheritdoc/>
        public void FromDelimitedString(string delimitedString, Separators separators)
        {
            Separators seps = separators ?? new Separators().UsingConfigurationValues();

            string[] segments = delimitedString == null
                ? Array.Empty <string>()
                : delimitedString.Split(seps.FieldSeparator, StringSplitOptions.None);

            if (segments.Length > 0)
            {
                if (string.Compare(Id, segments[0], true, CultureInfo.CurrentCulture) != 0)
                {
                    throw new ArgumentException($"{ nameof(delimitedString) } does not begin with the proper segment Id: '{ Id }{ seps.FieldSeparator }'.", nameof(delimitedString));
                }
            }

            QueryTag = segments.Length > 1 && segments[1].Length > 0 ? segments[1] : null;
            QueryResponseFormatCode = segments.Length > 2 && segments[2].Length > 0 ? segments[2] : null;
            VtQueryName             = segments.Length > 3 && segments[3].Length > 0 ? TypeSerializer.Deserialize <CodedElement>(segments[3], false, seps) : null;
            VirtualTableName        = segments.Length > 4 && segments[4].Length > 0 ? TypeSerializer.Deserialize <CodedElement>(segments[4], false, seps) : null;
            SelectionCriteria       = segments.Length > 5 && segments[5].Length > 0 ? TypeSerializer.Deserialize <QuerySelectionCriteria>(segments[5], false, seps) : null;
        }