예제 #1
0
 /// <summary>
 /// Projects Enumeration of payerPlanPeriod from the raw set of payerPlanPeriod entities.
 /// </summary>
 /// <param name="payerPlanPeriods">raw set of payerPlanPeriod entities</param>
 /// <param name="visitOccurrences">the visit occurrence entities for current person</param>
 /// <returns>Enumeration of payerPlanPeriod entities</returns>
 public virtual IEnumerable <PayerPlanPeriod> BuildPayerPlanPeriods(PayerPlanPeriod[] payerPlanPeriods,
                                                                    Dictionary <long, VisitOccurrence> visitOccurrences)
 {
     // All overlapping periods will be collapsed into one observation period
     return(EraHelper.GetPayerPlanPeriods(payerPlanPeriods, CanPayerPlanPeriodBeCombined,
                                          Offset));
 }
예제 #2
0
        public void TestDrugExposuresGap1()
        {
            var drugExposures = new List <DrugExposure>
            {
                new DrugExposure(new Entity
                {
                    ConceptId = 1,
                    PersonId  = 1,
                    StartDate = DateTime.Parse("2001-01-15"),
                    EndDate   = DateTime.Parse("2001-02-15")
                })
                {
                    GetEraConceptIdsCall = GetEraConceptIds2
                },
                new DrugExposure(new Entity
                {
                    ConceptId = 1,
                    PersonId  = 1,
                    StartDate = DateTime.Parse("2001-02-25"),
                    EndDate   = DateTime.Parse("2001-03-01")
                })
                {
                    GetEraConceptIdsCall = GetEraConceptIds2
                }
            };

            var eras = EraHelper.GetEras(drugExposures, 30, 0).ToList();

            Assert.AreEqual(eras.Count, 1);
            Assert.AreEqual(eras[0].StartDate, DateTime.Parse("2001-01-15"));
            Assert.AreEqual(eras[0].EndDate, DateTime.Parse("2001-03-01"));
            Assert.AreEqual(eras[0].GapDays, 10);
            Assert.AreEqual(eras[0].OccurrenceCount, 2);
        }
예제 #3
0
 public override IEnumerable <EraEntity> BuildConditionEra(ConditionOccurrence[] conditionOccurrences, ObservationPeriod[] observationPeriods)
 {
     foreach (var eraEntity in EraHelper.GetEras(conditionOccurrences, 30, 38000247))
     {
         eraEntity.Id = Offset.GetKeyOffset(eraEntity.PersonId).ConditionEraId;
         yield return(eraEntity);
     }
 }
예제 #4
0
 /// <summary>
 /// A Drug Era is defined as a span of time when the Person is assumed to be exposed to a particular drug.
 /// Successive periods of Drug Exposures are combined under certain rules to produce continuous Drug Eras.
 /// The Drug Era  is populated by pulling from the set of drug exposure.  A drug era is therefore understood as exposure to a certain compound over a certain period of time.
 /// There will only be one type of persistence window (duration that is allowed to elapse between drug exposures) applied to this CDM, which is 30 days.
 /// </summary>
 /// <param name="drugExposures">set of drug exposure entities</param>
 /// <returns>Enumeration of drug era</returns>
 public virtual IEnumerable <EraEntity> BuildDrugEra(DrugExposure[] drugExposures)
 {
     foreach (var eraEntity in EraHelper.GetEras(drugExposures.Where(d => string.IsNullOrEmpty(d.Domain) || d.Domain == "Drug"), 30, 38000182))
     {
         eraEntity.Id = chunkData.KeyMasterOffset.DrugEraId;
         yield return(eraEntity);
     }
 }
예제 #5
0
 /// <summary>
 /// A Drug Era is defined as a span of time when the Person is assumed to be exposed to a particular drug.
 /// Successive periods of Drug Exposures are combined under certain rules to produce continuous Drug Eras.
 /// The Drug Era  is populated by pulling from the set of drug exposure.  A drug era is therefore understood as exposure to a certain compound over a certain period of time.
 /// There will only be one type of persistence window (duration that is allowed to elapse between drug exposures) applied to this CDM, which is 30 days.
 /// </summary>
 /// <param name="drugExposures">set of drug exposure entities</param>
 /// <param name="observationPeriods">the observation periods entities for current person</param>
 /// <returns>Enumeration of drug era</returns>
 public virtual IEnumerable <EraEntity> BuildDrugEra(DrugExposure[] drugExposures, ObservationPeriod[] observationPeriods)
 {
     foreach (var eraEntity in EraHelper.GetEras(
                  Clean(drugExposures, observationPeriods, true).Where(d => string.IsNullOrEmpty(d.Domain) || d.Domain == "Drug"), 30, 38000182))
     {
         eraEntity.Id = KeyMasterOffsetManager.GetKeyOffset(eraEntity.PersonId).DrugEraId;
         yield return(eraEntity);
     }
 }
예제 #6
0
 /// <summary>
 /// CONDITION_ERAs are chronological periods of condition occurrence.
 /// There will only be one type of persistence window (duration that is allowed to elapse between condition occurrences) applied to this CDM, which is 30 days.
 /// CONDITION_END_DATE will be the CONDITION_START_DATE.
 /// </summary>
 /// <param name="conditionOccurrences">Set of condition occurrence entities</param>
 /// <returns>Enumeration of condition era</returns>
 public virtual IEnumerable <EraEntity> BuildConditionEra(ConditionOccurrence[] conditionOccurrences)
 {
     foreach (var eraEntity in  EraHelper.GetEras(
                  conditionOccurrences.Where(c => string.IsNullOrEmpty(c.Domain) || c.Domain == "Condition"), 30, 38000247))
     {
         eraEntity.Id = chunkData.KeyMasterOffset.ConditionEraId;
         yield return(eraEntity);
     }
 }
예제 #7
0
 public override IEnumerable <EraEntity> BuildDrugEra(DrugExposure[] drugExposures, ObservationPeriod[] observationPeriods)
 {
     foreach (var eraEntity in EraHelper.GetEras(
                  Clean(drugExposures, observationPeriods, false), 30, 38000182))
     {
         eraEntity.Id = Offset.GetKeyOffset(eraEntity.PersonId).DrugEraId;
         yield return(eraEntity);
     }
 }
예제 #8
0
 /// <summary>
 /// CONDITION_ERAs are chronological periods of condition occurrence.
 /// There will only be one type of persistence window (duration that is allowed to elapse between condition occurrences) applied to this CDM, which is 30 days.
 /// CONDITION_END_DATE will be the CONDITION_START_DATE.
 /// </summary>
 /// <param name="conditionOccurrences">Set of condition occurrence entities</param>
 /// <param name="observationPeriods">the observation periods entities for current person</param>
 /// <returns>Enumeration of condition era</returns>
 public virtual IEnumerable <EraEntity> BuildConditionEra(ConditionOccurrence[] conditionOccurrences, ObservationPeriod[] observationPeriods)
 {
     foreach (var eraEntity in EraHelper.GetEras(
                  Clean(conditionOccurrences, observationPeriods, true).Where(c => string.IsNullOrEmpty(c.Domain) || c.Domain == "Condition"), 30,
                  38000247))
     {
         eraEntity.Id = KeyMasterOffsetManager.GetKeyOffset(eraEntity.PersonId).ConditionEraId;
         yield return(eraEntity);
     }
 }
예제 #9
0
        public void TestDrugExposures()
        {
            var drugExposures = new List <DrugExposure>
            {
                new DrugExposure(new Entity
                {
                    ConceptId = 1,
                    PersonId  = 1,
                    StartDate = new DateTime(2011, 3, 7)
                })
                {
                    Ingredients = new List <int> {
                        1, 2, 3
                    }
                },
                new DrugExposure(new Entity
                {
                    ConceptId = 2,
                    PersonId  = 1,
                    StartDate = new DateTime(2011, 3, 7)
                })
                {
                    Ingredients = new List <int> {
                        1
                    }
                },
                new DrugExposure(new Entity
                {
                    ConceptId = 2,
                    PersonId  = 1,
                    StartDate = new DateTime(2011, 3, 7)
                })
                {
                    Ingredients = new List <int> {
                        1, 2, 3, 4
                    }
                }
            };

            var eras = EraHelper.GetEras(drugExposures, 0, 0).ToList();

            Assert.AreEqual(eras.Count, 4);
            Assert.AreEqual(eras[0].ConceptId, 1);
            Assert.AreEqual(eras[0].OccurrenceCount, 3);

            Assert.AreEqual(eras[1].ConceptId, 2);
            Assert.AreEqual(eras[1].OccurrenceCount, 2);

            Assert.AreEqual(eras[2].ConceptId, 3);
            Assert.AreEqual(eras[2].OccurrenceCount, 2);

            Assert.AreEqual(eras[3].ConceptId, 4);
            Assert.AreEqual(eras[3].OccurrenceCount, 1);
        }
예제 #10
0
        public void TestDrugExposures3()
        {
            var drugExposures = new List <DrugExposure>
            {
                new DrugExposure(new Entity
                {
                    ConceptId = 1,
                    PersonId  = 1,
                    StartDate = DateTime.Parse("2001-01-15"),
                    EndDate   = DateTime.Parse("2001-04-08")
                })
                {
                    Ingredients = new List <int> {
                        1
                    }
                },
                new DrugExposure(new Entity
                {
                    ConceptId = 2,
                    PersonId  = 1,
                    StartDate = DateTime.Parse("2001-01-17"),
                    EndDate   = DateTime.Parse("2001-02-13")
                })
                {
                    Ingredients = new List <int> {
                        1
                    }
                },
                new DrugExposure(new Entity
                {
                    ConceptId = 2,
                    PersonId  = 1,
                    StartDate = DateTime.Parse("2001-04-09"),
                    EndDate   = DateTime.Parse("2001-05-06")
                })
                {
                    Ingredients = new List <int> {
                        1
                    }
                }
            };

            var eras = EraHelper.GetEras(drugExposures, 30, 0).ToList();

            Assert.AreEqual(eras.Count, 1);
            Assert.AreEqual(eras[0].StartDate, DateTime.Parse("2001-01-15"));
            Assert.AreEqual(eras[0].EndDate, DateTime.Parse("2001-05-06"));
            Assert.AreEqual(eras[0].OccurrenceCount, 3);
        }
예제 #11
0
 /// <summary>
 /// Projects Enumeration of observation period from the raw set of observation period entities.
 /// </summary>
 /// <param name="gap">persistence window (duration that is allowed to elapse between two periods) </param>
 /// <param name="observationPeriods">raw set of observation period entities</param>
 /// <returns>Enumeration of observation period entities</returns>
 public virtual IEnumerable <ObservationPeriod> BuildObservationPeriods(int gap, EraEntity[] observationPeriods)
 {
     // All overlapping periods will be collapsed into one observation period
     return(EraHelper.GetObservationPeriods(gap, observationPeriods, Offset));
 }
예제 #12
0
 /// <summary>
 /// A Drug Era is defined as a span of time when the Person is assumed to be exposed to a particular drug.
 /// Successive periods of Drug Exposures are combined under certain rules to produce continuous Drug Eras.
 /// The Drug Era  is populated by pulling from the set of drug exposure.  A drug era is therefore understood as exposure to a certain compound over a certain period of time.
 /// There will only be one type of persistence window (duration that is allowed to elapse between drug exposures) applied to this CDM, which is 30 days.
 /// </summary>
 /// <param name="drugExposures">set of drug exposure entities</param>
 /// <returns>Enumeration of drug era</returns>
 public virtual IEnumerable <EraEntity> BuildDrugEra(DrugExposure[] drugExposures)
 {
     return(EraHelper.GetEras(drugExposures.ToList(), 30, 38000182));
 }
예제 #13
0
 /// <summary>
 /// CONDITION_ERAs are chronological periods of condition occurrence.
 /// There will only be one type of persistence window (duration that is allowed to elapse between condition occurrences) applied to this CDM, which is 30 days.
 /// CONDITION_END_DATE will be the CONDITION_START_DATE.
 /// </summary>
 /// <param name="conditionOccurrences">Set of condition occurrence entities</param>
 /// <returns>Enumeration of condition era</returns>
 public virtual IEnumerable <EraEntity> BuildConditionEra(ConditionOccurrence[] conditionOccurrences)
 {
     return(EraHelper.GetEras(conditionOccurrences, 30, 38000247));
 }