/// <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));
                }
            }

            FileFieldSeparator       = segments.Length > 1 && segments[1].Length > 0 ? segments[1] : null;
            FileEncodingCharacters   = segments.Length > 2 && segments[2].Length > 0 ? segments[2] : null;
            FileSendingApplication   = segments.Length > 3 && segments[3].Length > 0 ? TypeSerializer.Deserialize <HierarchicDesignator>(segments[3], false, seps) : null;
            FileSendingFacility      = segments.Length > 4 && segments[4].Length > 0 ? TypeSerializer.Deserialize <HierarchicDesignator>(segments[4], false, seps) : null;
            FileReceivingApplication = segments.Length > 5 && segments[5].Length > 0 ? TypeSerializer.Deserialize <HierarchicDesignator>(segments[5], false, seps) : null;
            FileReceivingFacility    = segments.Length > 6 && segments[6].Length > 0 ? TypeSerializer.Deserialize <HierarchicDesignator>(segments[6], false, seps) : null;
            FileCreationDateTime     = segments.Length > 7 && segments[7].Length > 0 ? segments[7].ToNullableDateTime() : null;
            FileSecurity             = segments.Length > 8 && segments[8].Length > 0 ? segments[8] : null;
            FileNameId                  = segments.Length > 9 && segments[9].Length > 0 ? segments[9] : null;
            FileHeaderComment           = segments.Length > 10 && segments[10].Length > 0 ? segments[10] : null;
            FileControlId               = segments.Length > 11 && segments[11].Length > 0 ? segments[11] : null;
            ReferenceFileControlId      = segments.Length > 12 && segments[12].Length > 0 ? segments[12] : null;
            FileSendingNetworkAddress   = segments.Length > 13 && segments[13].Length > 0 ? TypeSerializer.Deserialize <HierarchicDesignator>(segments[13], false, seps) : null;
            FileReceivingNetworkAddress = segments.Length > 14 && segments[14].Length > 0 ? TypeSerializer.Deserialize <HierarchicDesignator>(segments[14], false, seps) : null;
        }
Exemple #2
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));
                }
            }

            ApplicationChangeType = segments.Length > 1 && segments[1].Length > 0 ? TypeSerializer.Deserialize <CodedWithExceptions>(segments[1], false, seps) : null;
            CurrentCpu            = segments.Length > 2 && segments[2].Length > 0 ? segments[2] : null;
            CurrentFileserver     = segments.Length > 3 && segments[3].Length > 0 ? segments[3] : null;
            CurrentApplication    = segments.Length > 4 && segments[4].Length > 0 ? TypeSerializer.Deserialize <HierarchicDesignator>(segments[4], false, seps) : null;
            CurrentFacility       = segments.Length > 5 && segments[5].Length > 0 ? TypeSerializer.Deserialize <HierarchicDesignator>(segments[5], false, seps) : null;
            NewCpu         = segments.Length > 6 && segments[6].Length > 0 ? segments[6] : null;
            NewFileserver  = segments.Length > 7 && segments[7].Length > 0 ? segments[7] : null;
            NewApplication = segments.Length > 8 && segments[8].Length > 0 ? TypeSerializer.Deserialize <HierarchicDesignator>(segments[8], false, seps) : null;
            NewFacility    = segments.Length > 9 && segments[9].Length > 0 ? TypeSerializer.Deserialize <HierarchicDesignator>(segments[9], false, seps) : null;
        }
        /// <exception cref="ArgumentException">
        /// delimitedString does not begin with the proper segment Id.
        /// -or-
        /// delimitedString does not contain exactly four encoding characters.
        /// </exception>
        /// <inheritdoc/>
        public void FromDelimitedString(string delimitedString, Separators separators)
        {
            if (delimitedString != null && delimitedString.Length > 3)
            {
                FieldSeparator = delimitedString[3].ToString();
            }

            string[] segments = delimitedString == null
                ? Array.Empty <string>()
                : delimitedString.Split(new[] { 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 }'.", nameof(delimitedString));
                }
            }

            if (segments.Length < 2 || segments[1].Length != 4)
            {
                throw new ArgumentException($"{ nameof(delimitedString) } does not contain exactly four encoding characters.", nameof(delimitedString));
            }

            EncodingCharacters = segments[1];
            Separators seps = new Separators().UsingInput($"{ FieldSeparator }{ EncodingCharacters }");

            SendingApplication                  = segments.Length > 2 && segments[2].Length > 0 ? TypeSerializer.Deserialize <HierarchicDesignator>(segments[2], false, seps) : null;
            SendingFacility                     = segments.Length > 3 && segments[3].Length > 0 ? TypeSerializer.Deserialize <HierarchicDesignator>(segments[3], false, seps) : null;
            ReceivingApplication                = segments.Length > 4 && segments[4].Length > 0 ? TypeSerializer.Deserialize <HierarchicDesignator>(segments[4], false, seps) : null;
            ReceivingFacility                   = segments.Length > 5 && segments[5].Length > 0 ? TypeSerializer.Deserialize <HierarchicDesignator>(segments[5], false, seps) : null;
            DateTimeOfMessage                   = segments.Length > 6 && segments[6].Length > 0 ? segments[6].ToNullableDateTime() : null;
            Security                            = segments.Length > 7 && segments[7].Length > 0 ? segments[7] : null;
            MessageType                         = segments.Length > 8 && segments[8].Length > 0 ? TypeSerializer.Deserialize <MessageType>(segments[8], false, seps) : null;
            MessageControlId                    = segments.Length > 9 && segments[9].Length > 0 ? segments[9] : null;
            ProcessingId                        = segments.Length > 10 && segments[10].Length > 0 ? TypeSerializer.Deserialize <ProcessingType>(segments[10], false, seps) : null;
            VersionId                           = segments.Length > 11 && segments[11].Length > 0 ? TypeSerializer.Deserialize <VersionIdentifier>(segments[11], false, seps) : null;
            SequenceNumber                      = segments.Length > 12 && segments[12].Length > 0 ? segments[12].ToNullableDecimal() : null;
            ContinuationPointer                 = segments.Length > 13 && segments[13].Length > 0 ? segments[13] : null;
            AcceptAcknowledgmentType            = segments.Length > 14 && segments[14].Length > 0 ? segments[14] : null;
            ApplicationAcknowledgmentType       = segments.Length > 15 && segments[15].Length > 0 ? segments[15] : null;
            CountryCode                         = segments.Length > 16 && segments[16].Length > 0 ? segments[16] : null;
            CharacterSet                        = segments.Length > 17 && segments[17].Length > 0 ? segments[17].Split(seps.FieldRepeatSeparator, StringSplitOptions.None) : null;
            PrincipalLanguageOfMessage          = segments.Length > 18 && segments[18].Length > 0 ? TypeSerializer.Deserialize <CodedWithExceptions>(segments[18], false, seps) : null;
            AlternateCharacterSetHandlingScheme = segments.Length > 19 && segments[19].Length > 0 ? segments[19] : null;
            MessageProfileIdentifier            = segments.Length > 20 && segments[20].Length > 0 ? segments[20].Split(seps.FieldRepeatSeparator, StringSplitOptions.None).Select(x => TypeSerializer.Deserialize <EntityIdentifier>(x, false, seps)) : null;
            SendingResponsibleOrganization      = segments.Length > 21 && segments[21].Length > 0 ? TypeSerializer.Deserialize <ExtendedCompositeNameAndIdNumberForOrganizations>(segments[21], false, seps) : null;
            ReceivingResponsibleOrganization    = segments.Length > 22 && segments[22].Length > 0 ? TypeSerializer.Deserialize <ExtendedCompositeNameAndIdNumberForOrganizations>(segments[22], false, seps) : null;
            SendingNetworkAddress               = segments.Length > 23 && segments[23].Length > 0 ? TypeSerializer.Deserialize <HierarchicDesignator>(segments[23], false, seps) : null;
            ReceivingNetworkAddress             = segments.Length > 24 && segments[24].Length > 0 ? TypeSerializer.Deserialize <HierarchicDesignator>(segments[24], false, seps) : null;
        }
Exemple #4
0
        public void ToDelimitedString_WithAllProperties_ReturnsCorrectlySequencedFields()
        {
            IType hl7Type = new HierarchicDesignator
            {
                NamespaceId     = "1",
                UniversalId     = "2",
                UniversalIdType = "3"
            };

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

            Assert.Equal(expected, actual);
        }
Exemple #5
0
        public void FromDelimitedString_WithAllProperties_ReturnsCorrectlyInitializedFields()
        {
            IType expected = new HierarchicDesignator
            {
                NamespaceId     = "1",
                UniversalId     = "2",
                UniversalIdType = "3"
            };

            IType actual = new HierarchicDesignator();

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

            expected.Should().BeEquivalentTo(actual);
        }
Exemple #6
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));
                }
            }

            EventTypeCode        = segments.Length > 1 && segments[1].Length > 0 ? segments[1] : null;
            RecordedDateTime     = segments.Length > 2 && segments[2].Length > 0 ? segments[2].ToNullableDateTime() : null;
            DateTimePlannedEvent = segments.Length > 3 && segments[3].Length > 0 ? segments[3].ToNullableDateTime() : null;
            EventReasonCode      = segments.Length > 4 && segments[4].Length > 0 ? TypeSerializer.Deserialize <CodedWithExceptions>(segments[4], false, seps) : null;
            OperatorId           = segments.Length > 5 && segments[5].Length > 0 ? segments[5].Split(seps.FieldRepeatSeparator, StringSplitOptions.None).Select(x => TypeSerializer.Deserialize <ExtendedCompositeIdNumberAndNameForPersons>(x, false, seps)) : null;
            EventOccurred        = segments.Length > 6 && segments[6].Length > 0 ? segments[6].ToNullableDateTime() : null;
            EventFacility        = segments.Length > 7 && segments[7].Length > 0 ? TypeSerializer.Deserialize <HierarchicDesignator>(segments[7], false, seps) : null;
        }