Beispiel #1
0
        public void GivenADateTimeNode_WhenRedact_RedactedNodeShouldBeReturn()
        {
            RedactProcessor processor    = new RedactProcessor(enablePartialDatesForRedact: true, true, true, new List <string>());
            FhirDateTime    testDateTime = new FhirDateTime("2015-02-07T13:28:17-05:00");
            var             node         = ElementNode.FromElement(testDateTime.ToTypedElement());

            processor.Process(node);
            Assert.Equal("2015", node.Value.ToString());

            processor = new RedactProcessor(enablePartialDatesForRedact: false, true, true, new List <string>());
            node      = ElementNode.FromElement(testDateTime.ToTypedElement());
            processor.Process(node);
            Assert.Equal("", node.Value.ToString());
        }
Beispiel #2
0
        public void GivenADateTime_WhenDateShift_ThenDateTimeFormatShouldNotChange(string dateShiftKey, FhirDateTime dateTime, string expectedDateTimeString)
        {
            var node = ElementNode.FromElement(dateTime.ToTypedElement());

            DateTimeUtility.ShiftDateTimeAndInstantNode(node, dateShiftKey, true);
            Assert.Equal(expectedDateTimeString, node.Value.ToString());
        }
        public void GivenADateTimeWithoutDayOrAgeOver89_WhenDateShift_ThenDateTimeShouldBeRedacted(FhirDateTime dateTime, FhirDateTime expectedDateTime)
        {
            var node          = ElementNode.FromElement(dateTime.ToTypedElement());
            var processResult = DateTimeUtility.ShiftDateTimeAndInstantNode(node, string.Empty, string.Empty, true);

            Assert.Equal(expectedDateTime?.ToString() ?? null, node.Value);
            Assert.True(processResult.IsRedacted);
        }
Beispiel #4
0
        public void GivenADateTime_WhenRedact_ThenDateTimeShouldBeRedacted(FhirDateTime dateTime, FhirDateTime expectedDateTime)
        {
            var node = ElementNode.FromElement(dateTime.ToTypedElement());

            DateTimeUtility.RedactDateTimeAndInstantNode(node, true);

            Assert.Equal(expectedDateTime.ToString(), node.Value);
        }
        public void GivenADateTime_WhenDateShift_ThenDateTimeShouldBeShifted(FhirDateTime dateTime, FhirDateTime minExpectedDateTime, FhirDateTime maxExpectedDateTime)
        {
            var node          = ElementNode.FromElement(dateTime.ToTypedElement());
            var processResult = DateTimeUtility.ShiftDateTimeAndInstantNode(node, Guid.NewGuid().ToString("N"), string.Empty, true);

            Assert.True(minExpectedDateTime <= new FhirDateTime(node.Value.ToString()));
            Assert.True(maxExpectedDateTime >= new FhirDateTime(node.Value.ToString()));
            Assert.True(processResult.IsPerturbed);
        }
        public void GivenADateTimeNode_WhenDateShift_DateShiftedNodeShouldBeReturn()
        {
            DateShiftProcessor processor    = new DateShiftProcessor(dateShiftKey: "dummy", string.Empty, enablePartialDatesForRedact: true);
            FhirDateTime       testDateTime = new FhirDateTime("2015-02-07T13:28:17-05:00");
            var node = ElementNode.FromElement(testDateTime.ToTypedElement());

            processor.Process(node);
            Assert.Equal("2015-01-17T00:00:00-05:00", node.Value.ToString());
        }