public object GetValue(int i)
        {
            if (_enumerator.Current == null)
            {
                return(null);
            }

            switch (i)
            {
            case 0:
                return(KeyMasterOffsetManager.GetId(_enumerator.Current.PersonId, _enumerator.Current.Id));

            case 1:
                return(_enumerator.Current.PersonId);

            case 2:
                return(_enumerator.Current.StartDate);

            case 3:
                return(_enumerator.Current.EndDate);

            case 4:
                return(_enumerator.Current.PayerSourceValue);

            case 5:
                return(_enumerator.Current.PlanSourceValue);

            case 6:
                return(_enumerator.Current.FamilySourceValue);

            default:
                throw new NotImplementedException();
            }
        }
示例#2
0
        public IEnumerable <Note> GetNotes(Concept concept, IDataRecord reader,
                                           KeyMasterOffsetManager offset)
        {
            return
                (base.GetConcepts(concept, reader, offset)
                 .Select(
                     e =>
                     new Note
            {
                Id = offset.GetKeyOffset(e.PersonId).NoteId,
                EncodingConceptId = reader.GetInt(EncodingConceptId) ?? 0,
                LanguageConceptId = reader.GetInt(LanguageConceptId) ?? 0,
                Title = reader.GetString(Title),
                Text = reader.GetString(Text),

                PersonId = e.PersonId,
                ConceptId = e.ConceptId,
                StartDate = e.StartDate,

                TypeConceptId = e.TypeConceptId,
                VisitOccurrenceId = e.VisitOccurrenceId,
                VisitDetailId = e.VisitDetailId,
                SourceValue = e.SourceValue,
                ProviderId = e.ProviderId,

                AdditionalFields = e.AdditionalFields
            }));
        }
        // is this called only because the datatype specific methods are not implemented?
        // probably performance to be gained by not passing object back?
        public object GetValue(int i)
        {
            switch (i)
            {
            case 0:
                return(KeyMasterOffsetManager.GetId(_enumerator.Current.PersonId, _enumerator.Current.Id));

            case 1:
                return(_enumerator.Current.PersonId);

            case 2:
                return(_enumerator.Current.StartDate);

            case 3:
                return(_enumerator.Current.StartTime ??
                       _enumerator.Current.StartDate.ToString("HH:mm:ss", CultureInfo.InvariantCulture));

            case 4:
                return(_enumerator.Current.EndDate);

            case 5:
                return(_enumerator.Current.EndTime ??
                       _enumerator.Current.EndDate.Value.ToString("HH:mm:ss", CultureInfo.InvariantCulture));

            case 6:
                return(_enumerator.Current.TypeConceptId);

            default:
                throw new NotImplementedException();
            }
        }
        public object GetValue(int i)
        {
            if (_enumerator.Current == null)
            {
                return(null);
            }

            switch (i)
            {
            case 0:
                return(KeyMasterOffsetManager.GetId(_enumerator.Current.PersonId, _enumerator.Current.Id));

            case 1:
                return(_enumerator.Current.PersonId);

            case 2:
                return(_enumerator.Current.ConceptId);

            case 3:
                return(_enumerator.Current.StartDate);

            case 4:
                return(_enumerator.Current.EndDate);

            case 5:
                return(_enumerator.Current.OccurrenceCount);

            case 6:
                return(_enumerator.Current.GapDays);

            default:
                throw new NotImplementedException();
            }
        }
示例#5
0
        public object GetValue(int i)
        {
            if (_enumerator.Current == null)
            {
                return(null);
            }

            switch (i)
            {
            case 0:
                return(KeyMasterOffsetManager.GetId(_enumerator.Current.PersonId, _enumerator.Current.Id));

            case 1:
                return(_enumerator.Current.PersonId);

            case 2:
                return(_enumerator.Current.ConceptId);

            case 3:
                return(_enumerator.Current.StartDate);

            case 4:
                return(_enumerator.Current.TypeConceptId);

            case 5:
                return(_enumerator.Current.ModifierConceptId);

            case 6:
                return(_enumerator.Current.Quantity);

            case 7:
                return(_enumerator.Current.ProviderId == 0 ? null : _enumerator.Current.ProviderId);

            case 8:
                if (_enumerator.Current.VisitOccurrenceId.HasValue)
                {
                    if (KeyMasterOffsetManager.GetKeyOffset(_enumerator.Current.PersonId).VisitOccurrenceIdChanged)
                    {
                        return(KeyMasterOffsetManager.GetId(_enumerator.Current.PersonId,
                                                            _enumerator.Current.VisitOccurrenceId.Value));
                    }

                    return(_enumerator.Current.VisitOccurrenceId.Value);
                }

                return(null);

            case 9:
                return(_enumerator.Current.SourceValue);

            case 10:
                return(_enumerator.Current.SourceConceptId);

            case 11:
                return(_enumerator.Current.QualifierSourceValue);

            default:
                throw new NotImplementedException();
            }
        }
示例#6
0
        public override IEnumerable <IEntity> GetConcepts(Concept concept, IDataRecord reader, KeyMasterOffsetManager offset)
        {
            int?relevantConditionConceptId = null;
            int?modifierConceptId          = reader.GetInt(ModifierConceptId) ?? 0;

            if (Concepts.Length == 2)
            {
                var relevantConcepts = Concepts[1].GetConceptIdValues(Vocabulary, Concepts[1].Fields[0], reader);

                if (relevantConcepts.Count > 0)
                {
                    relevantConditionConceptId = relevantConcepts.Min(c => c.ConceptId); //CDM v4
                    modifierConceptId          = relevantConditionConceptId;             //CDM v5
                }
            }

            foreach (var e in base.GetConcepts(concept, reader, offset))
            {
                yield return
                    (new ProcedureOccurrence(e)
                {
                    Id = KeyMasterOffsetManager.GetKeyOffset(e.PersonId).ProcedureOccurrenceId,
                    ReleventConditionConceptId = relevantConditionConceptId,
                    ModifierConceptId = modifierConceptId ?? 0,
                    StartTime = e.StartTime ?? e.StartDate.ToString("HH:mm:ss", CultureInfo.InvariantCulture),
                    Quantity = reader.GetInt(Quantity),
                    QualifierSourceValue = reader.GetString(QualifierSourceValue)
                });
            }
        }
        public override IEnumerable <IEntity> GetConcepts(Concept concept, IDataRecord reader,
                                                          KeyMasterOffsetManager keyOffset)
        {
            var personId = reader.GetLong(PersonId);

            var startDate     = reader.GetDateTime(StartDate);
            var endDate       = reader.GetDateTime(EndDate);
            int?typeConceptId = 0;

            if (Concepts != null)
            {
                var periodConceptId = Concepts.FirstOrDefault(c => c.Name == "PeriodConceptId");
                if (periodConceptId != null && concept.Fields != null && concept.Fields.Length > 0)
                {
                    typeConceptId = concept.GetTypeId(concept.Fields[0], reader) ?? 0;
                }
            }

            if (personId.HasValue)
            {
                yield return new ObservationPeriod()
                       {
                           PersonId      = personId.Value,
                           StartDate     = startDate,
                           EndDate       = endDate,
                           TypeConceptId = typeConceptId
                       }
            }
            ;
        }
    }
        public object GetValue(int i)
        {
            if (_enumerator.Current == null)
            {
                return(null);
            }

            switch (i)
            {
            case 0:

                return(KeyMasterOffsetManager.GetId(_enumerator.Current.PersonId, _enumerator.Current.Id));

            case 1:

                return(KeyMasterOffsetManager.GetId(_enumerator.Current.PersonId, _enumerator.Current.Id));

            case 2:
                return(_enumerator.Current.CurrencyConceptId);

            case 3:
                return(_enumerator.Current.PaidCopay.Round());

            case 4:
                return(_enumerator.Current.PaidCoinsurance.Round());

            case 5:
                return(_enumerator.Current.PaidTowardDeductible.Round());

            case 6:
                return(_enumerator.Current.PaidByPayer.Round());

            case 7:
                return(_enumerator.Current.PaidByCoordinationBenefits.Round());

            case 8:
                return(_enumerator.Current.TotalOutOfPocket.Round());

            case 9:
                return(_enumerator.Current.TotalPaid.Round());

            case 10:
                return(_enumerator.Current.IngredientCost.Round());

            case 11:
                return(_enumerator.Current.DispensingFee.Round());

            case 12:
                return(_enumerator.Current.AverageWholesalePrice.Round());

            case 13:
                return(_enumerator.Current.PayerPlanPeriodId.HasValue
                        ? KeyMasterOffsetManager.GetId(_enumerator.Current.PersonId, _enumerator.Current.PayerPlanPeriodId.Value)
                        : _enumerator.Current.PayerPlanPeriodId);

            default:
                throw new NotImplementedException();
            }
        }
示例#9
0
        // is this called only because the datatype specific methods are not implemented?
        // probably performance to be gained by not passing object back?
        public object GetValue(int i)
        {
            switch (i)
            {
            case 0:
                return(KeyMasterOffsetManager.GetId(_enumerator.Current.PersonId, _enumerator.Current.Id));

            case 1:
                return(_enumerator.Current.PersonId);

            case 2:
                return(_enumerator.Current.StartDate);

            case 3:
                return(_enumerator.Current.StartTime);

            case 4:
                return(_enumerator.Current.TypeConceptId);

            case 5:
                return(_enumerator.Current.Text);

            case 6:
                return(_enumerator.Current.ProviderId);

            case 7:
                if (_enumerator.Current.VisitOccurrenceId.HasValue)
                {
                    if (KeyMasterOffsetManager.GetKeyOffset(_enumerator.Current.PersonId).VisitOccurrenceIdChanged)
                    {
                        return(KeyMasterOffsetManager.GetId(_enumerator.Current.PersonId,
                                                            _enumerator.Current.VisitOccurrenceId.Value));
                    }

                    return(_enumerator.Current.VisitOccurrenceId.Value);
                }

                return(null);

            case 8:
                return(_enumerator.Current.SourceValue);

            case 9:
                return(_enumerator.Current.ConceptId);

            case 10:
                return(_enumerator.Current.Title);

            case 11:
                return(_enumerator.Current.EncodingConceptId);

            case 12:
                return(_enumerator.Current.LanguageConceptId);

            default:
                throw new NotImplementedException();
            }
        }
示例#10
0
        public static List <PayerPlanPeriod> GetPayerPlanPeriods(PayerPlanPeriod[] entities, int gap, Func <PayerPlanPeriod, PayerPlanPeriod, bool> canBeCombined, KeyMasterOffsetManager offset)
        {
            var result = new List <PayerPlanPeriod>();

            if (entities.Length == 0)
            {
                return(result);
            }

            var ordered =
                entities.OrderBy(e => e.StartDate).ToList();
            var payerPlanPeriod = ordered[0];
            var list            = new List <PayerPlanPeriod>();

            foreach (var entity in ordered)
            {
                if (canBeCombined(entity, payerPlanPeriod))
                {
                    list.Add(entity);
                    continue;
                }

                result.AddRange(GetEras(list, gap, -1).Select(i => new PayerPlanPeriod
                {
                    Id               = KeyMasterOffsetManager.GetKeyOffset(i.PersonId).PayerPlanPeriodId,
                    PersonId         = i.PersonId,
                    StartDate        = i.StartDate,
                    EndDate          = i.EndDate,
                    PayerSourceValue =
                        payerPlanPeriod.PayerSourceValue,
                    FamilySourceValue =
                        payerPlanPeriod.FamilySourceValue,
                    PlanSourceValue =
                        payerPlanPeriod.PlanSourceValue
                }));

                list.Clear();
                payerPlanPeriod = entity;
                list.Add(entity);
            }

            result.AddRange(GetEras(list, gap, -1).Select(i => new PayerPlanPeriod
            {
                Id               = KeyMasterOffsetManager.GetKeyOffset(i.PersonId).PayerPlanPeriodId,
                PersonId         = i.PersonId,
                StartDate        = i.StartDate,
                EndDate          = i.EndDate,
                PayerSourceValue =
                    payerPlanPeriod.PayerSourceValue,
                FamilySourceValue =
                    payerPlanPeriod.FamilySourceValue,
                PlanSourceValue =
                    payerPlanPeriod.PlanSourceValue
            }));


            return(result);
        }
示例#11
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);
     }
 }
示例#12
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);
     }
 }
示例#13
0
        public ChunkPart(int chunkId, Func <IPersonBuilder> createPersonBuilder, string prefix, int attempt)
        {
            ChunkId             = chunkId;
            CreatePersonBuilder = createPersonBuilder;
            Prefix  = prefix;
            Attempt = attempt;

            PersonBuilders    = new Dictionary <long, Lazy <IPersonBuilder> >();
            OffsetManager     = new KeyMasterOffsetManager(ChunkId, int.Parse(Prefix), attempt);
            LastSavedPersonId = null;
        }
示例#14
0
        public LambdaChunkPart(int chunkId, Func <IPersonBuilder> createPersonBuilder, string prefix, int attempt)
        {
            _chunkId             = chunkId;
            _createPersonBuilder = createPersonBuilder;
            _prefix  = prefix;
            _attempt = attempt;

            _personBuilders    = new Dictionary <long, Lazy <IPersonBuilder> >();
            _offsetManager     = new KeyMasterOffsetManager(_chunkId, int.Parse(_prefix), attempt);
            _lastSavedPersonId = null;
            _watchdog          = new System.Timers.Timer(Settings.Current.WatchdogValue);
            _watchdog.Elapsed += _watchdog_Elapsed;
        }
示例#15
0
 public override IEnumerable <IEntity> GetConcepts(Concept concept, IDataRecord reader,
                                                   KeyMasterOffsetManager offset)
 {
     foreach (var entity in base.GetConcepts(concept, reader, offset))
     {
         yield return(new DeviceExposure(entity)
         {
             Id = offset.GetKeyOffset(entity.PersonId).DeviceExposureId,
             UniqueDeviceId = reader.GetString(UniqueDeviceId),
             Quantity = reader.GetInt(Quantity) ?? 0
         });
     }
 }
示例#16
0
        private bool AddCost(long eventId, Func <ICostV5, Cost> createCost, IEntity entity, ICostV5 entityCost)
        {
            if (entityCost == null)
            {
                return(false);
            }

            var cost = createCost(entityCost);

            cost.CostId  = KeyMasterOffsetManager.GetKeyOffset(entityCost.PersonId).VisitCostId;
            cost.EventId = eventId;

            return(ChunkData.AddCostData(cost));
        }
示例#17
0
        // is this called only because the datatype specific methods are not implemented?
        // probably performance to be gained by not passing object back?
        public object GetValue(int i)
        {
            switch (i)
            {
            case 0:
            {
                return(KeyMasterOffsetManager.GetKeyOffset(_visitEnumerator.Current.PersonId)
                       .VisitOccurrenceIdChanged
                       ? KeyMasterOffsetManager.GetId(_visitEnumerator.Current.PersonId, _visitEnumerator.Current.Id)
                       : _visitEnumerator.Current.Id);
            }

            case 1:
                return(_visitEnumerator.Current.PersonId);

            case 2:
                return(_visitEnumerator.Current.ConceptId);

            case 3:
                return(_visitEnumerator.Current.StartDate);

            case 4:
                return(_visitEnumerator.Current.StartTime);

            case 5:
                return(_visitEnumerator.Current.EndDate);

            case 6:
                return(_visitEnumerator.Current.EndTime);

            case 7:
                return(_visitEnumerator.Current.TypeConceptId);

            case 8:
                return(_visitEnumerator.Current.ProviderId == 0 ? null : _visitEnumerator.Current.ProviderId);

            case 9:
                return(_visitEnumerator.Current.CareSiteId == 0 ? null : _visitEnumerator.Current.CareSiteId);

            case 10:
                return(_visitEnumerator.Current.SourceValue);

            case 11:
                return(_visitEnumerator.Current.SourceConceptId);

            default:
                throw new NotImplementedException();
            }
        }
示例#18
0
 public static List <ObservationPeriod> GetObservationPeriods(int gap, EraEntity[] entities, KeyMasterOffsetManager offset)
 {
     return
         (GetEras(entities, gap, entities[0].TypeConceptId ?? -1).Select(
              period =>
              new ObservationPeriod
     {
         Id = KeyMasterOffsetManager.GetKeyOffset(period.PersonId).ObservationPeriodId,
         PersonId = period.PersonId,
         StartDate = period.StartDate,
         EndDate = period.EndDate.Value,
         TypeConceptId = period.TypeConceptId
     }).
          ToList());
 }
        public override IEnumerable <IEntity> GetConcepts(Concept concept, IDataRecord reader, KeyMasterOffsetManager offset)
        {
            var de = base.GetConcepts(concept, reader, offset).ToList();

            if (de.Count > 0)
            {
                yield return(new DeviceExposure(de[0])
                {
                    Id = KeyMasterOffsetManager.GetKeyOffset(de[0].PersonId).DeviceExposureId,
                    UniqueDeviceId = reader.GetString(UniqueDeviceId),
                    StartTime = de[0].StartTime ?? de[0].StartDate.ToString("HH:mm:ss", CultureInfo.InvariantCulture),
                    Quantity = reader.GetInt(Quantity) ?? 0
                });
            }
        }
        public override IEnumerable <IEntity> GetConcepts(Concept concept, IDataRecord reader,
                                                          KeyMasterOffsetManager keyOffset)
        {
            var loc = new Location
            {
                State       = reader.GetString(State),
                SourceValue = reader.GetString(SourceValue),
                County      = reader.GetString(Country),
                Address1    = reader.GetString(Address1),
                Address2    = reader.GetString(Address2)
            };

            loc.Id = string.IsNullOrEmpty(Id) ? Entity.GetId(loc.GetKey()) : reader.GetLong(Id).Value;
            yield return(loc);
        }
示例#21
0
 public override IEnumerable <IEntity> GetConcepts(Concept concept, IDataRecord reader, KeyMasterOffsetManager offset)
 {
     return
         (base.GetConcepts(concept, reader, offset)
          .Select(
              e =>
              new Note(e)
     {
         Id = KeyMasterOffsetManager.GetKeyOffset(e.PersonId).NoteId,
         EncodingConceptId = reader.GetInt(EncodingConceptId) ?? 0,
         LanguageConceptId = reader.GetInt(LanguageConceptId) ?? 0,
         Title = reader.GetString(Title),
         Text = reader.GetString(Text),
         StartTime = e.StartTime ?? e.StartDate.ToString("HH:mm:ss", CultureInfo.InvariantCulture),
     }));
 }
示例#22
0
        public override IEnumerable <VisitCost> BuildVisitCosts(VisitOccurrence[] visitOccurrences)
        {
            foreach (var c in base.BuildVisitCosts(visitOccurrences).Where(vc => vc.TotalPaid.HasValue))
            {
                ChunkData.AddCostData(new Cost(c.PersonId)
                {
                    CostId            = KeyMasterOffsetManager.GetKeyOffset(c.PersonId).VisitCostId,
                    CurrencyConceptId = c.CurrencyConceptId,
                    TypeId            = 5031,
                    Domain            = "Visit",
                    EventId           = c.Id,
                    TotalPaid         = c.TotalPaid
                });

                yield return(c);
            }
        }
示例#23
0
        public override IEnumerable <ProcedureCost> BuildProcedureCosts(ProcedureOccurrence[] procedureOccurrences)
        {
            foreach (var c in base.BuildProcedureCosts(procedureOccurrences))
            {
                ChunkData.AddCostData(new Cost(c.PersonId)
                {
                    CostId            = KeyMasterOffsetManager.GetKeyOffset(c.PersonId).VisitCostId,
                    CurrencyConceptId = c.CurrencyConceptId,
                    TypeId            = 5032,
                    Domain            = "Procedure",
                    EventId           = c.Id,
                    TotalPaid         = c.TotalPaid,
                    TotalCharge       = c.PaidByCoordinationBenefits
                });

                yield return(c);
            }
        }
        public override IEnumerable <IEntity> GetConcepts(Concept concept, IDataRecord reader,
                                                          KeyMasterOffsetManager offset)
        {
            int?   statusConceptId = 0;
            string statusSource    = null;

            if (Concepts != null)
            {
                var conditionStatusConcept = Concepts.FirstOrDefault(c => c.Name == "ConditionStatusConceptId");
                if (conditionStatusConcept != null)
                {
                    var statusConcepts = conditionStatusConcept.GetConceptIdValues(Vocabulary, conditionStatusConcept.Fields[0], reader);
                    statusSource = reader.GetString(conditionStatusConcept.Fields[0].Key);

                    if (statusConcepts.Count > 0)
                    {
                        statusConceptId = statusConcepts.Min(c => c.ConceptId);
                        statusSource    = statusConcepts.Min(c => c.SourceCode);

                        if (string.IsNullOrEmpty(statusSource))
                        {
                            statusSource = reader.GetString(conditionStatusConcept.Fields[0].Key);
                        }

                        if (string.IsNullOrEmpty(statusSource))
                        {
                            statusSource = reader.GetString(conditionStatusConcept.Fields[0].SourceKey);
                        }
                    }
                }
            }

            return
                (base.GetConcepts(concept, reader, offset)
                 .Select(
                     e =>
                     new ConditionOccurrence(e)
            {
                Id = offset.GetKeyOffset(e.PersonId).ConditionOccurrenceId,
                StatusConceptId = statusConceptId.HasValue ? statusConceptId.Value : 0,
                StatusSourceValue = statusSource
            }));
        }
        public override IEnumerable <IEntity> GetConcepts(Concept concept, IDataRecord reader,
                                                          KeyMasterOffsetManager offset)
        {
            int?   statusConceptId = 0;
            string statusSource    = null;

            if (Concepts.Length == 2)
            {
                var statusConcepts = Concepts[1].GetConceptIdValues(Vocabulary, Concepts[1].Fields[0], reader);
                statusSource = reader.GetString(Concepts[1].Fields[0].Key);

                if (statusConcepts.Count > 0)
                {
                    statusConceptId = statusConcepts.Min(c => c.ConceptId);
                    statusSource    = statusConcepts.Min(c => c.SourceCode);

                    if (string.IsNullOrEmpty(statusSource))
                    {
                        statusSource = reader.GetString(Concepts[1].Fields[0].Key);
                    }

                    if (string.IsNullOrEmpty(statusSource))
                    {
                        statusSource = reader.GetString(Concepts[1].Fields[0].SourceKey);
                    }
                }
            }

            return
                (base.GetConcepts(concept, reader, offset)
                 .Select(
                     e =>
                     new ConditionOccurrence(e)
            {
                Id = KeyMasterOffsetManager.GetKeyOffset(e.PersonId).ConditionOccurrenceId,
                StatusConceptId = statusConceptId.HasValue ? statusConceptId.Value : 0,
                StartTime = e.StartTime ??
                            e.StartDate.ToString("HH:mm:ss", CultureInfo.InvariantCulture),
                StatusSourceValue = statusSource
            }));
        }
示例#26
0
        public override IEnumerable <IEntity> GetConcepts(Concept concept, IDataRecord reader,
                                                          KeyMasterOffsetManager offset)
        {
            //var obsConcepts = base.GetConcepts(concept, reader, offset).ToList();
            var unitConcept = GetUnitConcept(reader);

            int?valueAsConceptId = null;

            if (Concepts.Length > 2)
            {
                var valueConcepts = base.GetConcepts(Concepts[2], reader, null).ToList();
                if (valueConcepts.Count > 0)
                {
                    valueAsConceptId = valueConcepts[0].ConceptId;
                }
            }
            else
            {
                valueAsConceptId = reader.GetInt(ValueAsConceptId);
            }

            foreach (var entity in base.GetConcepts(concept, reader, offset))
            {
                yield return(new Measurement(entity)
                {
                    Id = offset.GetKeyOffset(entity.PersonId).MeasurementId,
                    SourceValue = string.IsNullOrWhiteSpace(entity.SourceValue)
                        ? null
                        : entity.SourceValue,
                    RangeLow = reader.GetDecimal(RangeLow),
                    RangeHigh = reader.GetDecimal(RangeHigh),
                    ValueAsNumber = reader.GetDecimal(ValueAsNumber),
                    OperatorConceptId = reader.GetInt(OperatorConceptId) ?? 0,
                    UnitConceptId = unitConcept.Key ?? 0,
                    UnitSourceValue = string.IsNullOrWhiteSpace(unitConcept.Value) ? null : unitConcept.Value,
                    ValueSourceValue = reader.GetString(ValueSourceValue),
                    ValueAsConceptId = valueAsConceptId ?? 0,
                    Time = reader.GetString(Time)
                });
            }
        }
        public ProcedureCost CreateEnity(ProcedureOccurrence procedure, IDataRecord reader,
            KeyMasterOffsetManager offset)
        {
            var paidCopay = reader.GetDecimal(PaidCopay);
            var paidCoinsurance = reader.GetDecimal(PaidCoinsurance);
            var paidTowardDeductible = reader.GetDecimal(PaidTowardDeductible);

            decimal? totalOutOfPocket = null;

            if (paidCopay.HasValue && paidCoinsurance.HasValue && paidTowardDeductible.HasValue)
            {
                totalOutOfPocket = paidCopay + paidCoinsurance + paidTowardDeductible;
            }
            else if (paidCoinsurance.HasValue && paidTowardDeductible.HasValue)
            {
                totalOutOfPocket = paidCoinsurance + paidTowardDeductible;
            }

            PopulateOthersConcepts(reader, out var drgConceptId, out var drgSource, out var revenueCodeConceptId,
                out var revenueCodeSource);

            return new ProcedureCost(procedure)
            {
                ProcedureCostId = offset.GetKeyOffset(procedure.PersonId).ProcedureCostId,
                PaidCopay = paidCopay,
                PaidCoinsurance = paidCoinsurance,
                PaidTowardDeductible = paidTowardDeductible,
                PaidByPayer = reader.GetDecimal(PaidByPayer),
                PaidByCoordinationBenefits = reader.GetDecimal(PaidByCoordinationBenefits),
                TotalPaid = reader.GetDecimal(TotalPaid),
                TotalOutOfPocket = totalOutOfPocket,
                RevenueCodeConceptId = revenueCodeConceptId,
                RevenueCodeSourceValue = revenueCodeSource,
                DrgConceptId = drgConceptId,
                DrgSourceValue = drgSource,
                CurrencyConceptId = reader.GetInt(CurrencyConceptId) ?? 0
            };
        }
        // is this called only because the datatype specific methods are not implemented?
        // probably performance to be gained by not passing object back?
        public object GetValue(int i)
        {
            switch (i)
            {
            case 0:
                return(KeyMasterOffsetManager.GetId(_enumerator.Current.PersonId, _enumerator.Current.Id));

            case 1:
                return(_enumerator.Current.PersonId);

            case 2:
                return(_enumerator.Current.StartDate);

            case 3:
                return(_enumerator.Current.EndDate);

            case 4:
                return(_enumerator.Current.TypeConceptId);

            default:
                throw new NotImplementedException();
            }
        }
        public override IEnumerable <IEntity> GetConcepts(Concept concept, IDataRecord reader,
                                                          KeyMasterOffsetManager offset)
        {
            foreach (var entity in base.GetConcepts(concept, reader, offset))
            {
                var unitConcept      = GetUnitConcept(reader, "UnitConceptId");
                var qualifierConcept = GetUnitConcept(reader, "QualifierConceptId");

                var createObservation = new Func <Observation>(() => new Observation(entity)
                {
                    Id          = offset.GetKeyOffset(entity.PersonId).ObservationId,
                    SourceValue = string.IsNullOrWhiteSpace(entity.SourceValue)
                        ? null
                        : entity.SourceValue,
                    RangeLow             = reader.GetDecimal(RangeLow),
                    RangeHigh            = reader.GetDecimal(RangeHigh),
                    UnitsConceptId       = unitConcept.Key ?? 0,
                    UnitsSourceValue     = string.IsNullOrWhiteSpace(unitConcept.Value) ? null : unitConcept.Value,
                    ValueAsConceptId     = reader.GetInt(ValueAsConceptId) ?? 0,
                    QualifierConceptId   = qualifierConcept.Key ?? 0,
                    QualifierSourceValue = string.IsNullOrWhiteSpace(qualifierConcept.Value) ? null : qualifierConcept.Value,
                    //RelevantConditionConceptId = relevantConditionConceptId ?? 0
                });

                var observation = createObservation();
                observation.ValueAsNumber = reader.GetDecimal(ValueAsNumber);
                if (observation.ValueAsNumber.HasValue)
                {
                    observation.ValueAsNumber = Math.Round(observation.ValueAsNumber.Value, 3);
                }

                observation.ValueAsString = reader.GetString(ValueAsString);

                yield return(observation);
            }
        }
 // A custom DataReader is implemented to prevent the need for the HashSet to be transformed to a DataTable for loading by SqlBulkCopy
 public DrugCostDataReader(List <DrugCost> batch, KeyMasterOffsetManager o)
 {
     _enumerator = batch?.GetEnumerator();
     _offset     = o;
 }