Example #1
0
        public void ToDelimitedString_WithAllProperties_ReturnsCorrectlySequencedFields()
        {
            IType hl7Type = new RepeatPattern
            {
                RepeatPatternCode = new CodedWithExceptions
                {
                    Identifier = "1"
                },
                CalendarAlignment    = "2",
                PhaseRangeBeginValue = 3,
                PhaseRangeEndValue   = 4,
                PeriodQuantity       = 5,
                PeriodUnits          = new CodedWithExceptions
                {
                    Identifier = "6"
                },
                InstitutionSpecifiedTime = "7",
                Event = "8",
                EventOffsetQuantity = 9,
                EventOffsetUnits    = new CodedWithExceptions
                {
                    Identifier = "10"
                },
                GeneralTimingSpecification = "11"
            };

            string expected = "1^2^3^4^5^6^7^8^9^10^11";
            string actual   = hl7Type.ToDelimitedString();

            Assert.Equal(expected, actual);
        }
Example #2
0
        public void FromDelimitedString_WithAllProperties_ReturnsCorrectlyInitializedFields()
        {
            IType expected = new RepeatPattern
            {
                RepeatPatternCode = new CodedWithExceptions
                {
                    IsSubcomponent = true,
                    Identifier     = "1"
                },
                CalendarAlignment    = "2",
                PhaseRangeBeginValue = 3,
                PhaseRangeEndValue   = 4,
                PeriodQuantity       = 5,
                PeriodUnits          = new CodedWithExceptions
                {
                    IsSubcomponent = true,
                    Identifier     = "6"
                },
                InstitutionSpecifiedTime = "7",
                Event = "8",
                EventOffsetQuantity = 9,
                EventOffsetUnits    = new CodedWithExceptions
                {
                    IsSubcomponent = true,
                    Identifier     = "10"
                },
                GeneralTimingSpecification = "11"
            };

            IType actual = new RepeatPattern();

            actual.FromDelimitedString("1^2^3^4^5^6^7^8^9^10^11");

            expected.Should().BeEquivalentTo(actual);
        }
Example #3
0
        public HandlerBuilder Times(int number)
        {
            var pattern = new RepeatPattern(_innerBuilder._patternParts, number);

            _builder._patternParts.Add(pattern);
            return(_builder);
        }
Example #4
0
        public HandlerBuilder AnyNumberOfTimes()
        {
            var pattern = new RepeatPattern(_innerBuilder._patternParts, RepeatPattern.Inifinite);

            _builder._patternParts.Add(pattern);
            return(_builder);
        }
        private bool RepeatPatternMatchesPhrase(string phrase, int occurences, out int nextTokenIndex)
        {
            var pattern = new RepeatPattern(
                _builder.GetPatterns(),
                occurences);
            var tokens  = new Tokenizer().Tokenize(phrase, new Options());
            var isMatch = pattern.Match(tokens, out nextTokenIndex);

            return(isMatch);
        }
Example #6
0
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            CultureInfo culture = CultureInfo.CurrentCulture;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 15, Configuration.FieldSeparator),
                       Id,
                       SetIdTq1.HasValue ? SetIdTq1.Value.ToString(culture) : null,
                       Quantity?.ToDelimitedString(),
                       RepeatPattern != null ? string.Join(Configuration.FieldRepeatSeparator, RepeatPattern.Select(x => x.ToDelimitedString())) : null,
                       ExplicitTime != null ? string.Join(Configuration.FieldRepeatSeparator, ExplicitTime.Select(x => x.ToString(Consts.TimeFormatPrecisionSecond, culture))) : null,
                       RelativeTimeAndUnits != null ? string.Join(Configuration.FieldRepeatSeparator, RelativeTimeAndUnits.Select(x => x.ToDelimitedString())) : null,
                       ServiceDuration?.ToDelimitedString(),
                       StartDateTime.HasValue ? StartDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       EndDateTime.HasValue ? EndDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       Priority != null ? string.Join(Configuration.FieldRepeatSeparator, Priority.Select(x => x.ToDelimitedString())) : null,
                       ConditionText?.ToDelimitedString(),
                       TextInstruction?.ToDelimitedString(),
                       Conjunction,
                       OccurrenceDuration?.ToDelimitedString(),
                       TotalOccurrences.HasValue ? TotalOccurrences.Value.ToString(Consts.NumericFormat, culture) : null
                       ).TrimEnd(Configuration.FieldSeparator.ToCharArray()));
        }
Example #7
0
 /// <summary>
 /// Creates a TheadingBase class
 /// </summary>
 /// <param name="repeat"><seealso cref="RepeatPattern"/> Defines the repeat patern of the class</param>
 /// <param name="startDate">Defines the start date of the repeat</param>
 protected ThreadingBase(RepeatPattern repeat, DateTime startDate)
 {
     this._repeat    = repeat;
     this._startDate = startDate;
     AddToGlobalThreads();
 }
Example #8
0
 public async Task <object> CreatePatternAsync(ElementReference image, RepeatPattern repeat) => await this.CallMethodAsync <object>(CREATE_PATTERN_METHOD, image, this._repeatNames[(int)repeat]);