Exemplo n.º 1
0
        public void Test_Timing_DateTimePeriodIndexSetter_GoodFormat()
        {
            //Arrange
            var Timing = new Timing();
            DateTimePeriodIndex Index = new DateTimePeriodIndex();

            var LowDate  = new DateTimeOffset(1974, 12, 25, 10, 00, 00, new TimeSpan(-5, 00, 00));
            var HighDate = new DateTimeOffset(1974, 12, 26, 11, 10, 00, new TimeSpan(-5, 00, 00));

            Timing.EventElement = new System.Collections.Generic.List <FhirDateTime>();
            var EventStart1 = new FhirDateTime(new DateTimeOffset(1974, 12, 26, 11, 00, 00, new TimeSpan(-5, 00, 00)));
            var EventStart2 = new FhirDateTime(LowDate);

            Timing.EventElement.Add(EventStart1);
            Timing.EventElement.Add(EventStart2);


            Timing.Repeat              = new Timing.RepeatComponent();
            Timing.Repeat.Duration     = new decimal(10.0);
            Timing.Repeat.DurationUnit = Timing.UnitsOfTime.Min;

            //Calculation (ToDo: This still needs review)
            //2min Duration + last EventStartdate (11:00am) = 11:20am 26/12/1974


            //Act
            Index = IndexSetterFactory.Create(typeof(DateTimePeriodIndex)).Set(Timing, Index) as DateTimePeriodIndex;

            //Assert
            Assert.AreEqual(Index.DateTimeOffsetLow, LowDate);
            Assert.AreEqual(Index.DateTimeOffsetHigh, HighDate);
        }
Exemplo n.º 2
0
        public static DateTime?ToDateTime(this FhirDateTime me)
        {
            if (me == null)
            {
                return(null);
            }
            DateTime result;

            if (DateTime.TryParse(me.Value, out result))
            {
                return(result);
            }
            if (!string.IsNullOrEmpty(me.Value))
            {
                // the date didn't parse, one of the common mistakes
                // with dates is not to include the - symbols
                // so lets put them in and proceed
                if (me.Value.Length == 8 && !me.Value.Contains("-"))
                {
                    string newValue = me.Value.Insert(4, "-").Insert(7, "-");
                    System.Diagnostics.Debug.WriteLine(String.Format("Invalid Date [{0}] was encountered, processing it as though it was [{1}]", me.Value, newValue));
                    if (DateTime.TryParse(newValue, out result))
                    {
                        return(result);
                    }
                }
            }
            return(null);
        }
Exemplo n.º 3
0
        private static Patient GetSomePatientWithProfile(string patientId, string profile)
        {
            var date = new FhirDateTime(new DateTimeOffset(DateTime.Now));

            return(new Patient
            {
                Meta = new Meta {
                    LastUpdated = date.ToDateTimeOffset(new TimeSpan()), Profile = new List <string> {
                        profile
                    }
                },
                Id = patientId,
                Active = true,
                Name =
                    new List <HumanName>
                {
                    new HumanName {
                        Family = "Normann", Given = new List <string> {
                            "Ola"
                        }
                    }
                },
                Telecom =
                    new List <ContactPoint>
                {
                    new ContactPoint {
                        System = ContactPoint.ContactPointSystem.Phone, Value = "123467890"
                    }
                },
                Gender = AdministrativeGender.Male,
                BirthDate = "2000-01-01"
            });
        }
Exemplo n.º 4
0
        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            string id     = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
            string column = dataGridView1.Columns[e.ColumnIndex].Name.ToString();
            string value  = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();

            switch (e.ColumnIndex)
            {
            case 1:
                FhirDateTime dt = new FhirDateTime(value);
                data[e.RowIndex].Effective = dt;
                _client.Update <Observation>(data[e.RowIndex]);

                //db.updateEffective(dt,ob);
                break;

            case 2:
                Code c = new Code(value);
                Hl7.Fhir.Model.ObservationStatus os = new Hl7.Fhir.Model.ObservationStatus();
                // data[e.RowIndex].Status = c;
                break;

            case 3:
                CodeableConcept cc = new CodeableConcept();
                cc.Text = value;
                data[e.RowIndex].Interpretation = cc;
                _client.Update <Observation>(data[e.RowIndex]);
                break;
            }
            Console.WriteLine(value);
        }
Exemplo n.º 5
0
        public static Period ToPeriod(this FhirDateTime fdt)
        {
            var result   = new Period();
            var dtoStart = fdt.ToDateTimeOffset();

            result.StartElement = new FhirDateTime(dtoStart);
            var dtoEnd = dtoStart;

            switch (fdt.Precision())
            {
            case FhirDateTimePrecision.Year: dtoEnd = dtoStart.AddYears(1); break;

            case FhirDateTimePrecision.Month: dtoEnd = dtoStart.AddMonths(1); break;

            case FhirDateTimePrecision.Day: dtoEnd = dtoStart.AddDays(1); break;

            case FhirDateTimePrecision.Minute: dtoEnd = dtoStart.AddMinutes(1); break;

            case FhirDateTimePrecision.Second: dtoEnd = dtoStart.AddSeconds(1); break;

            default: dtoEnd = dtoStart; break;
            }

            result.EndElement = new FhirDateTime(dtoEnd);
            return(result);
        }
Exemplo n.º 6
0
        public void FhirDateTimeMapTest()
        {
            var input  = new FhirDateTime(2015, 3, 14);
            var result = _sut.Map(input);

            CheckPeriod(result, "2015-03-14T00:00:00+00:00", "2015-03-15T00:00:00+00:00");
        }
Exemplo n.º 7
0
        private static Base MockPatient()
        {
            var date = new FhirDateTime(new DateTimeOffset(DateTime.Now));

            return(new Patient
            {
                Meta = new Meta {
                    LastUpdated = date.ToDateTimeOffset(new TimeSpan()), Profile = new List <string> {
                        "http://helse-nord.no/fhir/StructureDefinition/Clinical.Patient/Patient_HN"
                    }
                },
                Id = "12345678901",
                Active = true,
                Name =
                    new List <HumanName>
                {
                    new HumanName {
                        Family = "Normann", Given = new List <string> {
                            "Ola"
                        }
                    }
                },
                Gender = AdministrativeGender.Male,
                BirthDate = "2000-01-01"
            });
        }
Exemplo n.º 8
0
        public void ValidateResourceWithIncorrectChildElement()
        {
            // First create an incomplete encounter (class not supplied)
            var enc = new Encounter();

            enc.Status = Encounter.EncounterState.Planned;
            validateErrorOrFail(enc, membername: "ClassElement");
            validateErrorOrFail(enc, true);  // recursive checking shouldn't matter

            enc.Class = Encounter.EncounterClass.Ambulatory;

            // Now, it should work
            FhirValidator.Validate(enc);
            FhirValidator.Validate(enc, true);  // recursive checking shouldnt matter

            // Hide an incorrect datetime deep into the Encounter
            FhirDateTime dt = new FhirDateTime();

            dt.Value = "Ewout Kramer";  // clearly, a wrong datetime

            enc.Hospitalization        = new Encounter.EncounterHospitalizationComponent();
            enc.Hospitalization.Period = new Period()
            {
                StartElement = dt
            };

            // When we do not validate recursively, we should still be ok
            FhirValidator.Validate(enc);

            // When we recurse, this should fail
            validateErrorOrFail(enc, true, membername: "Value");
        }
Exemplo n.º 9
0
        private static Base MockPatient()
        {
            var date = new FhirDateTime(DateTime.Now);

            return(new Patient
            {
                Meta = new Meta {
                    LastUpdated = date.ToDateTimeOffset(), Profile = new List <string> {
                        "http://helse-nord.no/FHIR/profiles/Identification.Patient/Patient"
                    }
                },
                Id = "12345678901",
                Active = true,
                Name =
                    new List <HumanName>
                {
                    new HumanName {
                        Family = "Normann", Given = new List <string> {
                            "Ola"
                        }
                    }
                },
                Telecom =
                    new List <ContactPoint>
                {
                    new ContactPoint {
                        System = ContactPoint.ContactPointSystem.Phone, Value = "123467890"
                    }
                },
                Gender = AdministrativeGender.Male,
                BirthDate = "2000-01-01"
            });
        }
Exemplo n.º 10
0
        private static Base MockPatient()
        {
            var date = new FhirDateTime(System.DateTime.Now);

            return(new Patient
            {
                Meta = new Meta {
                    LastUpdated = date.ToDateTimeOffset()
                },
                Id = "12345678901",
                Active = true,
                Name =
                    new List <HumanName>
                {
                    new HumanName {
                        Family = new List <string> {
                            "Normann"
                        }, Given = new List <string> {
                            "Ola"
                        }
                    }
                },
                Telecom =
                    new List <ContactPoint>
                {
                    new ContactPoint {
                        System = ContactPoint.ContactPointSystem.Phone, Value = "123467890"
                    }
                },
                Gender = AdministrativeGender.Male,
                BirthDate = "2000-01-01"
            });
        }
Exemplo n.º 11
0
 public ItIndexElement GetElementAt(
     FhirDateTime value)
 {
     return(this.Value
            .Where(x => x.Value == value)
            .SingleOrDefault());
 }
Exemplo n.º 12
0
        public t(
            FhirDateTime endDate,
            Func <FhirDateTime, PositiveInt> numberDaysAfterStartDate,
            FhirDateTime startDate)
        {
            this.Log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            this.EndDate = endDate;

            this.NumberDaysAfterStartDate = numberDaysAfterStartDate;

            this.StartDate = startDate;

            ImmutableList <FhirDateTime> .Builder builder = ImmutableList.CreateBuilder <FhirDateTime>();

            for (DateTime i = startDate.ToDateTimeOffset(TimeSpan.Zero).UtcDateTime.Date; i <= endDate.ToDateTimeOffset(TimeSpan.Zero).UtcDateTime.Date; i = i.AddDays(1))
            {
                builder.Add(
                    new FhirDateTime(
                        new DateTimeOffset(
                            i)));
            }

            this.Value = builder.ToImmutableList();
        }
Exemplo n.º 13
0
        public void DateTimeHandling()
        {
            FhirDateTime dt = new FhirDateTime("2010-01-01");

            Assert.AreEqual("2010-01-01", dt.Value);

            FhirDateTime dt2 = new FhirDateTime(1972, 11, 30, 15, 10);

            Assert.IsTrue(dt2.Value.StartsWith("1972-11-30T15:10"));
            Assert.AreNotEqual(dt2.Value, "1972-11-30T15:10");


            FhirDateTime dtNoMs = new FhirDateTime("2014-12-11T00:00:00+11:00");

            Assert.AreEqual("2014-12-11T00:00:00+11:00", dtNoMs.Value);

            FhirDateTime dtWithMs = new FhirDateTime("2014-12-11T00:00:00.000+11:00");

            Assert.AreEqual("2014-12-11T00:00:00.000+11:00", dtWithMs.Value);

            var stamp = new DateTimeOffset(1972, 11, 30, 15, 10, 0, TimeSpan.Zero);

            dt = new FhirDateTime(stamp);
            Assert.IsTrue(dt.Value.EndsWith("Z"));
        }
        public static Parameters ConceptLookup(this IFhirClient client,
                                               Code code     = null, FhirUri system    = null, FhirString version = null,
                                               Coding coding = null, FhirDateTime date = null)

        {
            return(ConceptLookupAsync(client, code, system, version, coding, date).WaitResult());
        }
Exemplo n.º 15
0
        public void Test_TimingToIndex_Test1()
        {
            //Arrange
            var Timing = new Timing();

            DateTimeOffset?ExpectedLow  = new DateTimeOffset(1974, 12, 25, 10, 00, 00, new TimeSpan(-5, 00, 00)).ToUniversalTime();
            DateTimeOffset?ExpectedHigh = new DateTimeOffset(1974, 12, 26, 11, 10, 00, new TimeSpan(-5, 00, 00)).ToUniversalTime();

            Timing.EventElement = new System.Collections.Generic.List <FhirDateTime>();
            var EventStart1 = new FhirDateTime(new DateTimeOffset(1974, 12, 26, 11, 00, 00, new TimeSpan(-5, 00, 00)));
            var EventStart2 = new FhirDateTime(ExpectedLow.Value);

            Timing.EventElement.Add(EventStart1);
            Timing.EventElement.Add(EventStart2);

            Timing.Repeat              = new Timing.RepeatComponent();
            Timing.Repeat.Duration     = new decimal(10.0);
            Timing.Repeat.DurationUnit = Timing.UnitsOfTime.Min;

            //Act
            DateTimeIndex Result = DateTimeIndexSupport.GetDateTimeIndex(Timing);

            //Assert
            Assert.AreEqual(ExpectedLow, Result.Low);
            Assert.AreEqual(ExpectedHigh, Result.High);
        }
Exemplo n.º 16
0
 public decimal GetdEdt(
     FhirDateTime t_IndexElement,
     Ip p,
     Iβ β,
     C19M.M.C.A.Gumel2004.Interfaces.Parameters.QuarantineRateAsymptomaticIndividuals.Iγ γ_1,
     C19M.M.C.A.Gumel2004.Interfaces.Parameters.IsolationRateSymptomaticIndividuals.Iγ γ_2,
     C19M.M.C.A.Gumel2004.Interfaces.Parameters.TransmissionCoefficientModificationFactorAsymptomaticIndividuals.Iε ε_E,
     C19M.M.C.A.Gumel2004.Interfaces.Parameters.TransmissionCoefficientModificationFactorIsolatedIndividuals.Iε ε_J,
     C19M.M.C.A.Gumel2004.Interfaces.Parameters.TransmissionCoefficientModificationFactorQuarantinedIndividuals.Iε ε_Q,
     C19M.M.C.A.Gumel2004.Interfaces.Parameters.DevelopmentClinicalSymptomsRateAsymptomaticIndividuals.Iκ κ_1,
     Iμ μ,
     double E,
     double I,
     double J,
     double N,
     double Q,
     double S)
 {
     return
         (p.Value.Value.Value
          +
          (decimal)(S / N) * (β.Value.Value.Value) * ((decimal)I + ε_E.Value.Value.Value * (decimal)E + ε_Q.Value.Invoke(t_IndexElement).Value.Value *(decimal)Q + ε_J.Value.Invoke(t_IndexElement).Value.Value *(decimal)J)
          -
          (γ_1.Value.Invoke(t_IndexElement).Value.Value + κ_1.Value.Value.Value + μ.Value.Value.Value) * (decimal)E);
 }
Exemplo n.º 17
0
        private ServiceRequest createPreorder(FhirDateTime date, Patient patient, Practitioner doctor, string[] serviceCodes, bool webstorePreorder, string contractID = null)
        {
            var order = new ServiceRequest
            {
                AuthoredOn = date.ToString(),
                Status     = RequestStatus.Active,
                Intent     = RequestIntent.Order,
                Code       = Constants.ORDER_PROCEDURE_REQUEST_CODE,
                Category   =
                    webstorePreorder ?
                    new List <CodeableConcept> {
                    new CodeableConcept("https://dia.medicover.com/dictionaries/requestcategory", "FFS"),
                    new CodeableConcept("https://dia.medicover.com/dictionaries/requestcategory/ffs", "UA.WebOnline")
                } :
                new List <CodeableConcept> {
                    new CodeableConcept("https://dia.medicover.com/dictionaries/requestcategory", "Contract"),
                    new CodeableConcept("https://dia.medicover.com/contract", contractID)
                },
                Subject     = patient.GlobalURLReference(client.UseFullResourcePath),
                Requester   = doctor.GlobalURLReference(client.UseFullResourcePath),
                OrderDetail = serviceCodes.Select(sc => new CodeableConcept("https://dia.medicover.com/serviceknowledgebase/service", sc)).ToList(),
                Note        = new List <Annotation> {
                    new Annotation {
                        Text = "Very important comment 1"
                    },
                    new Annotation {
                        Text = "Very important comment 2"
                    }
                }
            };

            var fhirOrder = client.Create(order);

            return(fhirOrder);
        }
Exemplo n.º 18
0
        private ServiceRequest createOrder(FhirDateTime date, Patient patient, Practitioner doctor, string[] serviceCodes)
        {
            var order = new ServiceRequest
            {
                Identifier = new List <Identifier> {
                    new Identifier {
                        System = "https://dia.medicover.com/sampleID", Value = "999999999900"
                    }
                },
                AuthoredOn  = date.ToString(),
                Status      = RequestStatus.Draft,
                Intent      = RequestIntent.Order,
                Code        = Constants.ORDER_PROCEDURE_REQUEST_CODE,
                Subject     = patient.GlobalURLReference(client.UseFullResourcePath),
                Requester   = doctor.GlobalURLReference(client.UseFullResourcePath),
                OrderDetail = serviceCodes.Select(sc => new CodeableConcept("https://dia.medicover.com/serviceknowledgebase/service", sc)).ToList(),
                Performer   = new List <ResourceReference> {
                    Constants.CURRENT_LAB_REFERENCE
                },
                Note = new List <Annotation> {
                    new Annotation {
                        Text = "Very important comment 1"
                    },
                    new Annotation {
                        Text = "Very important comment 2"
                    }
                }
            };

            var fhirOrder = client.Create(order);

            return(fhirOrder);
        }
Exemplo n.º 19
0
        public async Task <List <Tuple <string, string> > > GetGroupMembers(string groupId, DateTimeOffset groupMembershipTime, CancellationToken cancellationToken)
        {
            var groupResource = await _fhirDataStore.Value.GetAsync(new ResourceKey(KnownResourceTypes.Group, groupId), cancellationToken);

            if (groupResource == null)
            {
                throw new ResourceNotFoundException($"Group {groupId} was not found.");
            }

            var group         = _resourceDeserializer.Deserialize(groupResource);
            var groupContents = group.ToPoco <Group>().Member;

            var members = new List <Tuple <string, string> >();

            foreach (Group.MemberComponent member in groupContents)
            {
                var fhirGroupMembershipTime = new FhirDateTime(groupMembershipTime);
                if (
                    (member.Inactive == null ||
                     member.Inactive == false) &&
                    (member.Period?.EndElement == null ||
                     member.Period?.EndElement > fhirGroupMembershipTime) &&
                    (member.Period?.StartElement == null ||
                     member.Period?.StartElement < fhirGroupMembershipTime))
                {
                    var    element      = _referenceToElementResolver.Resolve(member.Entity.Reference);
                    string id           = (string)element.Children("id").First().Value;
                    string resourceType = element.InstanceType;

                    members.Add(Tuple.Create(id, resourceType));
                }
            }

            return(members);
        }
Exemplo n.º 20
0
        public PbsItemsResponse GetPbsItems(string Ihi, DateTime?CreatedFrom, DateTime?CreatedTo)
        {
            if (ApiRequestHeader == null)
            {
                throw new NullReferenceException("ApiRequestHeader can not be null");
            }

            string GetRecordListQuery = "fhir/v1.0.0/ExplanationOfBenefit";
            string RangeQuery         = string.Empty;

            if (CreatedFrom.HasValue)
            {
                var DateFrom = new FhirDateTime(CreatedFrom.Value);
                RangeQuery = $"&created=ge{DateFrom.Value}";
            }
            if (CreatedTo.HasValue)
            {
                var DateTo = new FhirDateTime(CreatedTo.Value);
                RangeQuery += $"&created=le{DateTo.Value}";
            }

            GetRecordListQuery = $"{GetRecordListQuery}?patient.identifier={Ihi}{RangeQuery}&coverage.plan=PBS&_format={GetFormatString(Format)}";

            _Client          = new Client();
            _Client.Endpoint = ServiceEndpoint.OriginalString;
            HttpResponseMessage response = _Client.Get(GetRecordListQuery, this.ApiRequestHeader.Authorization, this.ApiRequestHeader.AppId, this.ApiRequestHeader.AppVersion).Result;

            return(new PbsItemsResponse(response.StatusCode, response.Content.ReadAsStringAsync().Result, Format));
        }
Exemplo n.º 21
0
        public void TestMethod1()
        {
            C19M.D.Gumel2006.Interfaces.ITable1 Table1 = new C19M.D.Gumel2006.Classes.Table1();

            // Use StartDate, EndDate,and NumberDaysAfterStartDate from Gumel et al. (2004)
            FhirDateTime startDate = new FhirDateTime(new DateTimeOffset(new DateTime(2003, 2, 23)));

            FhirDateTime endDate = new FhirDateTime(new DateTimeOffset(new DateTime(2003, 9, 1)));

            Func <FhirDateTime, PositiveInt> numberDaysAfterStartDate =
                (x) =>
            {
                if (x.ToPartialDateTime().Value.ToUniversalTime().DateTime.Date >= startDate.ToPartialDateTime().Value.ToUniversalTime().DateTime.Date)
                {
                    return(new PositiveInt((int)Math.Abs(Math.Round((x.ToPartialDateTime().Value.ToUniversalTime().DateTime.Date - startDate.ToPartialDateTime().Value.ToUniversalTime().DateTime.Date).TotalDays))));
                }
                else
                {
                    return(new PositiveInt(0));
                }
            };

            // Context
            C19M.M.C.A.Gumel2006.Interfaces.Contexts.IGumel2006_Context context = new C19M.M.C.A.Gumel2006.Classes.Contexts.Gumel2006_Context(
                endDate,
                numberDaysAfterStartDate,
                startDate,
                Table1.DiseaseInducedMortalityRate,
                new Hl7.Fhir.Model.FhirDecimal(0),       // TODO: Change
                new Hl7.Fhir.Model.FhirDecimal(10),      // TODO: Change
                new Hl7.Fhir.Model.FhirDecimal(0),       // TODO: Change
                new Hl7.Fhir.Model.FhirDecimal(4000000), // TODO: Change
                new Hl7.Fhir.Model.FhirDecimal(0),       // TODO: Change
                Table1.DevelopmentClinicalSymptomsRate,
                Table1.EffectiveContactRate,
                Table1.RecoveryRate,
                Table1.NaturalMortalityRate,
                Table1.VaccinationCoverageRate,
                Table1.RecruitmentRateSusceptibleHumans,
                Table1.VaccineEfficacy);

            // Export
            C19M.M.C.A.Gumel2006.Interfaces.Exports.IDiseaseTransmission_Export export = new C19M.M.C.A.Gumel2006.Classes.Exports.DiseaseTransmission_Export(
                context);

            export.Solve();

            var I = export.DayInfectedIndividuals;

            var S = export.DaySusceptibleIndividuals;

            var dayCumulativeDiseaseInducedDeaths = export.DayCumulativeDiseaseInducedDeaths;

            foreach (var item in I)
            {
                System.Diagnostics.Debug.WriteLine(
                    item.Item2.Value.Value);
            }
        }
Exemplo n.º 22
0
 public static String ToCode(this FhirDateTime value)
 {
     if (value == null)
     {
         return("null");
     }
     return($"new FhirDateTime(\"{value.Value}\")");
 }
        public void GivenADateTime_WhenRedact_ThenDateTimeShouldBeRedacted(FhirDateTime dateTime, FhirDateTime expectedDateTime)
        {
            var node          = ElementNode.FromElement(dateTime.ToTypedElement());
            var processResult = DateTimeUtility.RedactDateTimeAndInstantNode(node, true);

            Assert.Equal(expectedDateTime?.ToString() ?? null, node.Value);
            Assert.True(processResult.IsRedacted);
        }
Exemplo n.º 24
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);
        }
Exemplo n.º 25
0
        public tIndexElement(
            int key,
            FhirDateTime value)
        {
            this.Key = key;

            this.Value = value;
        }
Exemplo n.º 26
0
        public void Write(String parameterName, FhirDateTime fhirDateTime)
        {
            BsonDocument value = new BsonDocument();

            value.Add(new BsonElement("start", BsonDateTime.Create(fhirDateTime.LowerBound())));
            value.Add(new BsonElement("end", BsonDateTime.Create(fhirDateTime.UpperBound())));
            document.Write(parameterName, value);
        }
Exemplo n.º 27
0
 public decimal GetElementAtAsdecimal(
     FhirDateTime t_IndexElement)
 {
     return(this.Value
            .Where(x => x.t_IndexElement.ToDateTimeOffset(TimeSpan.Zero).UtcDateTime.Date == t_IndexElement.ToDateTimeOffset(TimeSpan.Zero).UtcDateTime.Date)
            .Select(x => x.Value.Value.Value)
            .SingleOrDefault());
 }
        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());
        }
        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 I_ResultElement(
            FhirDateTime t_IndexElement,
            FhirDecimal value)
        {
            this.Log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            this.t_IndexElement = t_IndexElement;

            this.Value = value;
        }