Exemplo n.º 1
0
 public override IEnumerable<IEntity> GetConcepts(Concept concept, IDataReader reader, KeyMasterOffset keyMaster)
 {
     var concepts = base.GetConcepts(concept, reader, keyMaster).ToList();
      if (concepts.Count > 0)
      {
     var baseConcept = concepts[0];
     var died = reader.GetInt(Died);
     if (died.HasValue && died.Value == 1)
     {
        yield return new Death((Entity) baseConcept) {Primary = true};
     }
     else //Medical claim diagnostic code indicating death
     {
         if (Concepts.Count() > 1)
         {
             for (int i = 1; i < Concepts.Count(); i++)
             {
                 foreach (var entity in PopulateDeath(reader, Concepts[i], baseConcept)) yield return entity;
             }
         }
         else
         {
             foreach (var entity in PopulateDeath(reader, Concepts[0], baseConcept)) yield return entity;
         }
     }
      }
 }
Exemplo n.º 2
0
        private static EntityDefinition CreateDefinition(Field[] fields)
        {
            var concept = new Concept { Fields = fields };

             var def = new EntityDefinition {PersonId = "PersonId", StartDate = "StartDate", Concepts = new Concept[1]};
             def.Concepts[0] = concept;
             return def;
        }
 public override IEnumerable<IEntity> GetConcepts(Concept concept, IDataReader reader, KeyMasterOffset keyMaster)
 {
     var id = string.IsNullOrEmpty(Id) ? KeyMaster.GetLocationId() : int.Parse(reader[Id].ToString());
      yield return new Location
      {
     Id = id,
     State = reader.GetString(State),
     SourceValue = reader.GetString(SourceValue)
      };
 }
        public override IEnumerable<IEntity> GetConcepts(Concept concept, IDataReader reader, KeyMasterOffset keyMaster)
        {
            long? relevantConditionConceptId = 0;
             DateTime? endDate = null;

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

            if (relevantConcepts.Count > 0)
                relevantConditionConceptId = relevantConcepts.Min(c => c.ConceptId);
             }

             foreach (var c in base.GetConcepts(concept, reader, keyMaster))
             {
            var e = (Entity) c;

            var calculatedDaysSupply = GetDaysSupply(reader, e);
            if (!string.IsNullOrEmpty(EndDate))
            {
               if (calculatedDaysSupply > 0 && calculatedDaysSupply <= 365)
                  endDate = e.StartDate.AddDays(calculatedDaysSupply - 1);
               else
                  endDate = reader.GetDateTime(EndDate);
            }

            var refillString = reader.GetString(Refill);

            int? refill = null;

            if (!string.IsNullOrEmpty(refillString))
            {
               int refillValue;

               // in Optum Refill looks like: 01, 02...
               int.TryParse(refillString, out refillValue);

               refill = refillValue;
            }

            yield return new DrugExposure(e)
                            {
                               Id = keyMaster.DrugExposureId,
                               Refills = refill,
                               DaysSupply = reader.GetInt(DaysSupply),
                               CalculatedDaysSupply = calculatedDaysSupply,
                               Quantity = GetQuantity(reader),
                               RelevantConditionConceptId = relevantConditionConceptId,
                               EndDate = endDate == DateTime.MinValue ? null : endDate,
                               GetEraConceptIdsCall = Vocabulary.LookupIngredientLevel
                            };

             }
        }
        public override IEnumerable<IEntity> GetConcepts(Concept concept, IDataReader reader, KeyMasterOffset keyMaster)
        {
            var id = string.IsNullOrEmpty(Id) ? KeyMaster.GetCareSiteId() : int.Parse(reader[Id].ToString());

             yield return new CareSite
                         {
                            Id = id,
                            LocationId = reader.GetLong(LocationId).Value,
                            PlaceOfSvcSourceValue = reader.GetString(PlaceOfSvcSourceValue),
                            SourceValue = id.ToString()
                         };
        }
        public override IEnumerable<IEntity> GetConcepts(Concept concept, IDataReader reader, KeyMasterOffset keyMaster)
        {
            var conceptField = Concepts[0].Fields[0];
             var id = string.IsNullOrEmpty(Id) ? KeyMaster.GetOrganizationId() : int.Parse(reader[Id].ToString());

             yield return new Organization
                         {
                            Id = id,
                            ConceptId = conceptField.DefaultConceptId.HasValue ? conceptField.DefaultConceptId.Value : 0,
                            LocationId = 0,
                            SourceValue = reader[conceptField.Key].ToString().Trim(),
                            PlaceOfSvcSourceValue = string.IsNullOrEmpty(PlaceOfService) ? "" : reader[PlaceOfService].ToString()
                         };
        }
Exemplo n.º 7
0
 private IEnumerable<IEntity> PopulateDeath(IDataReader reader, Concept secondaryConcept, IEntity baseConcept)
 {
     foreach (var field in secondaryConcept.Fields)
        {
        foreach (var lookupValue in secondaryConcept.GetValues(Vocabulary, field, reader))
        {
            if (lookupValue.ConceptId > 0)
            {
                yield return new Death((Entity) baseConcept)
                {
                    TypeConceptId = field.DefaultTypeId.HasValue ? field.DefaultTypeId.Value : 0,
                    ValidStartDate = lookupValue.ValidStartDate,
                    ValidEndDate = lookupValue.ValidEndDate
                    //TypeConceptId = 0 // !!!
                };
                break;
            }
        }
        }
 }
        public override IEnumerable<IEntity> GetConcepts(Concept concept, IDataReader reader, KeyMasterOffset keyMaster)
        {
            long? relevantConditionConceptId = null;
             if (Concepts.Length == 2)
             {
            var relevantConcepts = Concepts[1].GetValues(Vocabulary, Concepts[1].Fields[0], reader);

            if (relevantConcepts.Count > 0)
               relevantConditionConceptId = relevantConcepts.Min(c => c.ConceptId);
             }

             foreach (var e in base.GetConcepts(concept, reader, keyMaster))
             {
            yield return
               new ProcedureOccurrence((Entity) e)
                  {
                     Id = keyMaster.ProcedureOccurrenceId,
                     ReleventConditionConceptId = relevantConditionConceptId
                  };
             }
        }
        public override IEnumerable<IEntity> GetConcepts(Concept concept, IDataReader reader, KeyMasterOffset keyMaster)
        {
            var visitOccurrences = base.GetConcepts(concept, reader, keyMaster).ToList();

             if(visitOccurrences.Count > 0)
             {
            var id = reader.GetLong(Id);
            var visitOccurrence = new VisitOccurrence((Entity) visitOccurrences[0])
                                     {
                                        CareSiteId = reader.GetInt(CareSiteId) ?? 0
                                     };
            if(id.HasValue)
            {
               visitOccurrence.Id = id.Value;
            }
            else
            {
               visitOccurrence.IdUndefined = true;
            }

            yield return visitOccurrence;
             }
        }
        public override IEnumerable<IEntity> GetConcepts(Concept concept, IDataReader reader, KeyMasterOffset keyMaster)
        {
            var personId = reader.GetLong(PersonId);

             var startDate = reader.GetDateTime(StartDate);
             var endDate = reader.GetDateTime(EndDate);

             if (personId.HasValue)
             {
            Dictionary<string, string> additionalFields = null;
            if (AdditionalFields != null)
            {
               additionalFields = new Dictionary<string, string>(AdditionalFields.Length);
               foreach (var additionalField in AdditionalFields)
               {
                  additionalFields.Add(additionalField.ToLower(), reader.GetString(additionalField));
               }
            }

            var payerSourceValue = reader.GetString(PayerSource);
            if (string.IsNullOrWhiteSpace(payerSourceValue))
               payerSourceValue = null;

            yield return new PayerPlanPeriod
                            {
                               PersonId = personId.Value,
                               StartDate = startDate,
                               EndDate = endDate,
                               PayerSourceValue = payerSourceValue,
                               PlanSourceValue = reader.GetString(PlanSource),
                               FamilySourceValue = reader.GetString(FamilySource),
                               VisitOccurrenceId = reader.GetLong(VisitOccurrenceId),
                               AdditionalFields = additionalFields
                            };
             }
        }
        public override IEnumerable <IEntity> GetConcepts(Concept concept, IDataRecord reader, KeyMasterOffset keyOffset)
        {
            var visitOccurrences = base.GetConcepts(concept, reader, keyOffset).ToList();

            if (visitOccurrences.Count > 0)
            {
                long?  dischargeToConceptId   = null;
                string dischargeToSourceValue = null;
                if (Concepts.Length > 1)
                {
                    var dischargeConcepts = base.GetConcepts(Concepts[1], reader, null).ToList();
                    dischargeToSourceValue = reader.GetString(Concepts[1].Fields[0].Key);
                    if (dischargeConcepts.Count > 0)
                    {
                        dischargeToConceptId   = dischargeConcepts[0].ConceptId;
                        dischargeToSourceValue = dischargeConcepts[0].SourceValue;
                    }
                }
                else
                {
                    dischargeToConceptId   = reader.GetLong(DischargeToConceptId);
                    dischargeToSourceValue = reader.GetString(DischargeToSourceValue);
                }


                long?  admittingSourceConceptId = null;
                string admittingSourceValue     = null;
                if (Concepts.Length > 2)
                {
                    var admittingConcepts = base.GetConcepts(Concepts[2], reader, null).ToList();
                    admittingSourceValue = reader.GetString(Concepts[2].Fields[0].Key);
                    if (admittingConcepts.Count > 0)
                    {
                        admittingSourceConceptId = admittingConcepts[0].ConceptId;
                        admittingSourceValue     = admittingConcepts[0].SourceValue;
                    }
                }
                else
                {
                    admittingSourceConceptId = reader.GetLong(AdmittingSourceConceptId);
                    admittingSourceValue     = reader.GetString(AdmittingSourceValue);
                }

                var id = reader.GetLong(Id);

                string startTime = null;
                string endTime   = null;

                if (!string.IsNullOrEmpty(StartTime))
                {
                    DateTime dt;
                    if (DateTime.TryParse(reader.GetString(StartTime), out dt))
                    {
                        startTime = dt.ToString("HH:mm:ss", CultureInfo.InvariantCulture);
                    }
                }

                if (!string.IsNullOrEmpty(EndTime))
                {
                    DateTime dt;
                    if (DateTime.TryParse(reader.GetString(EndTime), out dt))
                    {
                        endTime = dt.ToString("HH:mm:ss", CultureInfo.InvariantCulture);
                    }
                }

                var visitOccurrence = new VisitOccurrence((Entity)visitOccurrences[0])
                {
                    CareSiteId = reader.GetInt(CareSiteId) ?? 0,
                    StartTime  = startTime,
                    EndTime    = endTime,
                    AdmittingSourceConceptId   = admittingSourceConceptId ?? 0,
                    AdmittingSourceValue       = admittingSourceValue,
                    DischargeToConceptId       = dischargeToConceptId ?? 0,
                    DischargeToSourceValue     = dischargeToSourceValue,
                    PrecedingVisitOccurrenceId = reader.GetInt(PrecedingVisitOccurrenceId)
                };
                if (id.HasValue)
                {
                    visitOccurrence.Id = id.Value;
                }
                else
                {
                    visitOccurrence.IdUndefined = true;
                }

                yield return(visitOccurrence);
            }
        }
Exemplo n.º 12
0
        public override IEnumerable <IEntity> GetConcepts(Concept concept, IDataRecord reader, KeyMasterOffset keyOffset)
        {
            var obsConcepts = base.GetConcepts(concept, reader, keyOffset).ToList();

            if (obsConcepts.Count > 0)
            {
                var  unitConcept = GetUnitConcept(reader);
                long?relevantConditionConceptId = null;

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

                    if (relevantConditionConcepts.Count > 0)
                    {
                        relevantConditionConceptId = relevantConditionConcepts.Min(c => c.ConceptId);
                    }
                }

                var createObservation = new Func <Observation>(() => new Observation(obsConcepts[0])
                {
                    Id                         = keyOffset.ObservationId,
                    SourceValue                = string.IsNullOrWhiteSpace(obsConcepts[0].SourceValue) ? null : obsConcepts[0].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         = reader.GetInt(QualifierConceptId) ?? 0,
                    QualifierSourceValue       = reader.GetString(QualifierSourceValue),
                    Time                       = reader.GetTime(Time),
                    RelevantConditionConceptId = relevantConditionConceptId ?? 0
                });

                if (ValuesAsNumber != null && ValuesAsNumber.Length > 1)
                {
                    foreach (var valueAsNumber in ValuesAsNumber)
                    {
                        var value = reader.GetDecimal(valueAsNumber);
                        if (value != null)
                        {
                            var observation = createObservation();

                            observation.ValueAsNumber = Math.Round(value.Value, 3);
                            observation.SourceValue   = observation.ValueAsNumber.ToString();
                            observation.TypeConceptId = 38000277;
                            yield return(observation);
                        }
                    }
                }
                else if (ValuesAsString != null && ValuesAsString.Length > 1)
                {
                    foreach (var valueAsString in ValuesAsString)
                    {
                        var value = reader.GetString(valueAsString);
                        if (!string.IsNullOrEmpty(value) && value != "-" && value != "9") //TMP
                        {
                            var observation = createObservation();
                            observation.ValueAsString = reader.GetString(valueAsString);
                            observation.SourceValue   = valueAsString;
                            observation.TypeConceptId = 38000278;
                            yield return(observation);
                        }
                    }
                }
                else if (obsConcepts[0].ConceptId > 0 || !string.IsNullOrEmpty(obsConcepts[0].SourceValue))
                {
                    var observation = createObservation();
                    if (ValuesAsNumber != null && ValuesAsNumber.Length > 0)
                    {
                        observation.ValueAsNumber = reader.GetDecimal(ValuesAsNumber[0]);
                        if (observation.ValueAsNumber.HasValue)
                        {
                            observation.ValueAsNumber = Math.Round(observation.ValueAsNumber.Value, 3);
                        }
                    }
                    if (ValuesAsString != null && ValuesAsString.Length > 0)
                    {
                        observation.ValueAsString = reader.GetString(ValuesAsString[0]);

                        // Workaround, map ValueAsString (usind SourceLookup) and reset SourceValue to original value
                        if (observation.AdditionalFields != null && observation.AdditionalFields.ContainsKey("original_source"))
                        {
                            observation.ValueAsString = observation.SourceValue;
                            observation.SourceValue   = observation.AdditionalFields["original_source"];
                        }
                    }

                    yield return(observation);
                }
            }
        }
Exemplo n.º 13
0
 public override IEnumerable <IEntity> GetConcepts(Concept concept, IDataReader reader, KeyMasterOffset keyMaster)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 14
0
        public override IEnumerable <IEntity> GetConcepts(Concept concept, IDataReader reader, KeyMasterOffset keyMaster)
        {
            long id;
            var  idUndefined = false;

            if (string.IsNullOrEmpty(Id))
            {
                id          = KeyMaster.GetProviderId();
                idUndefined = true;
            }
            else
            {
                id = reader.GetLong(Id).Value;
            }

            if (concept == null)
            {
                yield return(new Provider
                {
                    Id = id,
                    CareSiteId = reader.GetInt(CareSiteId) ?? 0,
                    ProviderSourceValue = reader.GetString(ProviderSourceValue),
                    SourceValue = reader.GetString(SpecialtySourceValue)
                });
            }
            else
            {
                var conceptField = concept.Fields[0];


                var source = reader.GetString(conceptField.Key) ?? reader.GetString(conceptField.SourceKey);

                if (source != null && source.Length == 0)
                {
                    source = null;
                }

                var  specialtyConceptIds = concept.GetValues(Vocabulary, conceptField, reader).ToList();
                long?specialtyConcept    = null;

                //(Unknown Physician Specialty)
                long defaultConceptId = 38004514;

                if (conceptField.DefaultConceptId.HasValue)
                {
                    defaultConceptId = conceptField.DefaultConceptId.Value;
                }

                if (specialtyConceptIds.Count > 0)
                {
                    specialtyConcept = specialtyConceptIds[0].ConceptId;
                }

                yield return(new Provider
                {
                    Id = id,
                    IdUndefined = idUndefined,
                    CareSiteId = reader.GetInt(CareSiteId) ?? 0,
                    ConceptId = specialtyConcept.HasValue ? specialtyConcept.Value : defaultConceptId,
                    ProviderSourceValue = reader.GetString(ProviderSourceValue),
                    SourceValue =
                        string.IsNullOrEmpty(conceptField.SourceKey) ? source : reader.GetString(conceptField.SourceKey)
                });
            }
        }
        public virtual IEnumerable <IEntity> GetConcepts(Concept concept, IDataRecord reader, KeyMasterOffset keyOffset)
        {
            var personId = reader.GetLong(PersonId);

            if (personId.HasValue)
            {
                var startDate = reader.GetDateTime(StartDate);
                var endDate   = startDate;
                if (!string.IsNullOrEmpty(EndDate))
                {
                    endDate = reader.GetDateTime(EndDate);
                }

                Dictionary <string, string> additionalFields = null;
                if (AdditionalFields != null)
                {
                    additionalFields = new Dictionary <string, string>(AdditionalFields.Length, StringComparer.OrdinalIgnoreCase);
                    foreach (var additionalField in AdditionalFields)
                    {
                        //additionalFields.Add(String.Intern(additionalField.ToLower()), reader.GetString(additionalField));
                        additionalFields.Add(additionalField, reader.GetString(additionalField));
                    }
                }

                foreach (var field in concept.Fields)
                {
                    var sourceValue = field.DefaultSource;
                    if (string.IsNullOrEmpty(sourceValue))
                    {
                        sourceValue = reader.GetString(field.Key);
                    }

                    if (!field.IsNullable && string.IsNullOrEmpty(sourceValue) && field.DefaultConceptId == null && field.ConceptId == null)
                    {
                        continue;
                    }

                    // Used when: field.Key used for conceptId mapping and
                    // field.SourceKey used for SourceValue (by default field.Key and field.SourceKey are identical)
                    if (!string.IsNullOrEmpty(field.SourceKey))
                    {
                        sourceValue = reader.GetString(field.SourceKey);
                    }

                    if (!string.IsNullOrEmpty(concept.SourceLookup))
                    {
                        var source = Vocabulary.LookupSource(sourceValue, concept.SourceLookup);
                        if (!string.IsNullOrEmpty(source))
                        {
                            sourceValue = source;
                        }
                    }

                    foreach (var lookupValue in concept.GetConceptIdValues(Vocabulary, field, reader))
                    {
                        var cId = lookupValue.ConceptId;
                        if (!cId.HasValue && field.DefaultConceptId.HasValue)
                        {
                            cId = field.DefaultConceptId;
                        }

                        if (!concept.IdRequired || cId.HasValue)
                        {
                            foreach (var sourceConceptId in concept.GetSourceConceptIdValues(Vocabulary, field, reader))
                            {
                                var providerIdKey = reader.GetString(ProviderIdKey);
                                if (!string.IsNullOrEmpty(providerIdKey))
                                {
                                    providerIdKey = providerIdKey.TrimStart('0');
                                }

                                yield return(new Entity
                                {
                                    IsUnique = IsUnique,
                                    PersonId = personId.Value,
                                    SourceValue = sourceValue,
                                    ConceptId = cId.HasValue ? cId.Value : 0,
                                    TypeConceptId = concept.GetTypeId(field, reader),
                                    StartDate = startDate,
                                    EndDate = endDate == DateTime.MinValue ? (DateTime?)null : endDate,
                                    ProviderId = reader.GetInt(ProviderId),
                                    ProviderKey = providerIdKey,
                                    VisitOccurrenceId = reader.GetLong(VisitOccurrenceId),
                                    AdditionalFields = additionalFields,
                                    ValidStartDate = lookupValue.ValidStartDate,
                                    ValidEndDate = lookupValue.ValidEndDate,
                                    SourceConceptId = sourceConceptId.ConceptId.HasValue ? sourceConceptId.ConceptId.Value : 0,
                                    Domain = lookupValue.Domain,
                                    SourceVocabularyId = lookupValue.SourceVocabularyId,
                                    LookupKey = reader.GetString(LookupKey)
                                });
                            }
                        }
                    }
                }
            }
        }
        public override IEnumerable<IEntity> GetConcepts(Concept concept, IDataReader reader, KeyMasterOffset keyMaster)
        {
            var obsConcepts = base.GetConcepts(concept, reader, keyMaster).ToList();

             if (obsConcepts.Count > 0)
             {
            var unitConcept = GetUnitConcept(reader);
            long? relevantConditionConceptId = null;

            if (Concepts.Length == 3)
            {
               var relevantConditionConcepts = Concepts[2].GetValues(Vocabulary, Concepts[2].Fields[0], reader);

               if(relevantConditionConcepts.Count > 0)
                   relevantConditionConceptId = relevantConditionConcepts.Min(c => c.ConceptId);
            }

            var createObservation = new Func<Observation>(() => new Observation((Entity)obsConcepts[0])
                                                                   {
                                                                      SourceValue = string.IsNullOrWhiteSpace(obsConcepts[0].SourceValue) ? null : obsConcepts[0].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,
                                                                      RelevantConditionConceptId = relevantConditionConceptId ?? 0
                                                                   });

            if (ValuesAsNumber != null && ValuesAsNumber.Length > 1)
            {
               foreach (var valueAsNumber in ValuesAsNumber)
               {
                  var value = reader.GetDecimal(valueAsNumber);
                  if (value != null)
                  {
                     var observation = createObservation();

                     observation.ValueAsNumber = Math.Round(value.Value, 3);
                     observation.SourceValue = observation.ValueAsNumber.ToString();
                     observation.TypeConceptId = 38000277;
                     yield return observation;
                  }
               }
            }
            else if (ValuesAsString != null && ValuesAsString.Length > 1)
            {
               foreach (var valueAsString in ValuesAsString)
               {
                  var value = reader.GetString(valueAsString);
                  if (!string.IsNullOrEmpty(value) && value != "-" && value != "9") //TMP
                  {
                     var observation = createObservation();
                     observation.ValueAsString = reader.GetString(valueAsString);
                     observation.SourceValue = valueAsString;
                     observation.TypeConceptId = 38000278;
                     yield return observation;
                  }
               }
            }
            else if (!string.IsNullOrEmpty(obsConcepts[0].SourceValue))
            {
               var observation = createObservation();
               if (ValuesAsNumber != null && ValuesAsNumber.Length > 0)
               {
                  observation.ValueAsNumber = reader.GetDecimal(ValuesAsNumber[0]);
                  if (observation.ValueAsNumber.HasValue)
                  {
                     observation.ValueAsNumber = Math.Round(observation.ValueAsNumber.Value, 3);
                  }
               }
               if (ValuesAsString != null && ValuesAsString.Length > 0)
               {
                  observation.ValueAsString = reader.GetString(ValuesAsString[0]);

                  // Workaround, map ValueAsString (usind SourceLookup) and reset SourceValue to original value
                  if (observation.AdditionalFields != null && observation.AdditionalFields.ContainsKey("original_source"))
                  {
                     observation.ValueAsString = observation.SourceValue;
                     observation.SourceValue = observation.AdditionalFields["original_source"];
                  }
               }

               yield return observation;
            }
             }
        }
Exemplo n.º 17
0
        public override IEnumerable<IEntity> GetConcepts(Concept concept, IDataReader reader, KeyMasterOffset keyMaster)
        {
            long id;
             var idUndefined = false;
             if (string.IsNullOrEmpty(Id))
             {
            id = KeyMaster.GetProviderId();
            idUndefined = true;
             }
             else
             {
            id = reader.GetLong(Id).Value;
             }

             if (concept == null)
             {
            yield return new Provider
               {
                  Id = id,
                  CareSiteId = reader.GetInt(CareSiteId) ?? 0,
                  ProviderSourceValue = reader.GetString(ProviderSourceValue),
                  SourceValue = reader.GetString(SpecialtySourceValue)
               };
             }
             else
             {
            var conceptField = concept.Fields[0];

            var source = reader.GetString(conceptField.Key) ?? reader.GetString(conceptField.SourceKey);

            if (source != null && source.Length == 0)
               source = null;

            var specialtyConceptIds = concept.GetValues(Vocabulary, conceptField, reader).ToList();
            long? specialtyConcept = null;

            //(Unknown Physician Specialty)
            long defaultConceptId = 38004514;

            if (conceptField.DefaultConceptId.HasValue)
            {
               defaultConceptId = conceptField.DefaultConceptId.Value;
            }

            if (specialtyConceptIds.Count > 0)
            {
               specialtyConcept = specialtyConceptIds[0].ConceptId;
            }

            yield return new Provider
               {
                  Id = id,
                  IdUndefined = idUndefined,
                  CareSiteId = reader.GetInt(CareSiteId) ?? 0,
                  ConceptId = specialtyConcept.HasValue ? specialtyConcept.Value : defaultConceptId,
                  ProviderSourceValue = reader.GetString(ProviderSourceValue),
                  SourceValue =
                     string.IsNullOrEmpty(conceptField.SourceKey) ? source : reader.GetString(conceptField.SourceKey)
               };
             }
        }
 public override IEnumerable<IEntity> GetConcepts(Concept concept, IDataReader reader, KeyMasterOffset keyMaster)
 {
     return base.GetConcepts(concept, reader, keyMaster).Select(e => new ConditionOccurrence((Entity)e));
 }
Exemplo n.º 19
0
        public override IEnumerable <IEntity> GetConcepts(Concept concept, IDataRecord reader, KeyMasterOffset keyOffset)
        {
            DateTime?endDate = null;

            long?  routeConceptId   = null;
            string routeSourceValue = null;

            if (Concepts.Length == 2)
            {
                var routeConcepts = base.GetConcepts(Concepts[1], reader, null).ToList();
                routeSourceValue = reader.GetString(Concepts[1].Fields[0].Key);
                if (routeConcepts.Count > 0)
                {
                    routeConceptId   = routeConcepts[0].ConceptId;
                    routeSourceValue = routeConcepts[0].SourceValue;
                }
            }
            else
            {
                routeConceptId   = reader.GetLong(RouteConceptId);
                routeSourceValue = reader.GetString(RouteSourceValue);
            }


            foreach (var c in base.GetConcepts(concept, reader, keyOffset))
            {
                var e = (Entity)c;

                var calculatedDaysSupply = GetDaysSupply(reader, e);
                if (!string.IsNullOrEmpty(EndDate))
                {
                    if (calculatedDaysSupply > 0 && calculatedDaysSupply <= 365)
                    {
                        endDate = e.StartDate.AddDays(calculatedDaysSupply - 1);
                    }
                    else
                    {
                        endDate = reader.GetDateTime(EndDate);
                    }
                }

                var verbatimEndDate = reader.GetDateTime(VerbatimEndDate);

                yield return(new DrugExposure(e)
                {
                    Id = keyOffset.DrugExposureId,
                    Refills = reader.GetInt(Refill),
                    DaysSupply = reader.GetInt(DaysSupply),
                    CalculatedDaysSupply = calculatedDaysSupply,
                    Quantity = reader.GetDecimal(Quantity),
                    Sig = reader.GetString(Sig),
                    EndDate = endDate == DateTime.MinValue ? null : endDate,
                    StartTime = e.StartTime ?? e.StartDate.ToString("HH:mm:ss", CultureInfo.InvariantCulture),
                    VerbatimEndDate = verbatimEndDate == DateTime.MinValue ? (DateTime?)null : verbatimEndDate,
                    GetEraConceptIdsCall = Vocabulary.LookupIngredientLevel,
                    RouteConceptId = routeConceptId,
                    RouteSourceValue = routeSourceValue,
                    DoseUnitConceptId = reader.GetLong(DoseUnitConceptId),
                    DoseUnitSourceValue = reader.GetString(DoseUnitSourceValue),
                    StopReason = reader.GetString(StopReason)
                });
            }
        }
Exemplo n.º 20
0
        public override IEnumerable<IEntity> GetConcepts(Concept concept, IDataReader reader, KeyMasterOffset keyMaster)
        {
            var locationSourceValue = reader.GetString(Location);
             int? locationId = null;
             if (!string.IsNullOrEmpty(Location))
             {
            locationId = Vocabulary.LookupLocation(locationSourceValue);
             }

             var observationPeriodGap = 32;
             if(!string.IsNullOrEmpty(ObservationPeriodGap))
             {
            observationPeriodGap = int.Parse(ObservationPeriodGap);
             }

             var genderSource = reader.GetString(Gender);
             var genderConceptId = Vocabulary.LookupGender(genderSource);

             var personId = reader.GetLong(PersonId);
             if(personId.HasValue)
             {
            yield return new Person
                            {
                               ObservationPeriodGap = observationPeriodGap,
                               PersonId = personId.Value,
                               StartDate = reader.GetDateTime(StartDate),
                               EndDate = reader.GetDateTime(EndDate),
                               PersonSourceValue = reader.GetString(PersonSourceValue),
                               GenderSourceValue = genderSource,
                               GenderConceptId = genderConceptId,
                               LocationId = locationId,
                               YearOfBirth = reader.GetInt(YearOfBirth),
                               MonthOfBirth = reader.GetInt(MonthOfBirth),
                               DayOfBirth = reader.GetInt(DayOfBirth),
                               LocationSourceValue = locationSourceValue,
                               CareSiteId = reader.GetInt(CareSiteId),
                               EthnicitySourceValue = reader.GetString(Ethnicity),
                               EthnicityConceptId = reader.GetInt(EthnicityConceptId) ?? 0,
                               RaceSourceValue = reader.GetString(Race),
                               RaceConceptId = reader.GetInt(RaceConceptId) ?? 0,
                               ProviderId = reader.GetInt(ProviderId)
                            };
             }
        }
Exemplo n.º 21
0
        public virtual IEnumerable<IEntity> GetConcepts(Concept concept, IDataReader reader, KeyMasterOffset keyMaster)
        {
            var personId = reader.GetLong(PersonId);

             if (personId.HasValue)
             {
            var startDate = reader.GetDateTime(StartDate);
            var endDate = startDate;
            if (!string.IsNullOrEmpty(EndDate))
               endDate = reader.GetDateTime(EndDate);

            Dictionary<string, string> additionalFields = null;
            if (AdditionalFields != null)
            {
               additionalFields = new Dictionary<string, string>(AdditionalFields.Length);
               foreach (var additionalField in AdditionalFields)
               {
                  additionalFields.Add(additionalField.ToLower(), reader.GetString(additionalField));
               }
            }

            foreach (var field in concept.Fields)
            {
               var sourceValue = field.DefaultSource;
               if (string.IsNullOrEmpty(sourceValue))
                  sourceValue = reader.GetString(field.Key);

               if (!field.IsNullable && string.IsNullOrEmpty(sourceValue) && field.DefaultConceptId == null && field.ConceptId == null)
                  continue;

               // Used when: field.Key used for conceptId mapping and
               // field.SourceKey used for SourceValue (by default field.Key and field.SourceKey are identical)
               if (!string.IsNullOrEmpty(field.SourceKey))
                  sourceValue = reader.GetString(field.SourceKey);

               if(!string.IsNullOrEmpty(concept.SourceLookup))
               {
                  var source = Vocabulary.LookupSource(sourceValue, concept.SourceLookup);
                  if (!string.IsNullOrEmpty(source))
                     sourceValue = source;
               }

               foreach (var lookupValue in concept.GetValues(Vocabulary, field, reader))
               {
                  var cId = lookupValue.ConceptId;
                  if (!cId.HasValue && field.DefaultConceptId.HasValue)
                     cId = field.DefaultConceptId;

                  if (!concept.IdRequired || cId.HasValue)
                  {
                     yield return new Entity
                     {
                        IsUnique = IsUnique,
                        PersonId = personId.Value,
                        SourceValue = sourceValue,
                        ConceptId = cId.HasValue ? cId.Value : 0,
                        TypeConceptId = concept.GetTypeId(field, reader),
                        StartDate = startDate,
                        EndDate = endDate == DateTime.MinValue ? (DateTime?) null : endDate,
                        ProviderId = reader.GetInt(ProviderId),
                        ProviderKey = reader.GetString(ProviderIdKey),
                        VisitOccurrenceId = reader.GetLong(VisitOccurrenceId),
                        AdditionalFields = additionalFields,
                        ValidStartDate = lookupValue.ValidStartDate,
                        ValidEndDate = lookupValue.ValidEndDate
                     };
                  }
               }
            }
             }
        }
Exemplo n.º 22
0
 public override IEnumerable<IEntity> GetConcepts(Concept concept, IDataReader reader, KeyMasterOffset keyMaster)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 23
0
        public override IEnumerable <IEntity> GetConcepts(Concept concept, IDataRecord reader, KeyMasterOffset keyOffset)
        {
            long id;
            var  idUndefined     = false;
            int  genderConceptId = 0;

            if (string.IsNullOrEmpty(Id))
            {
                id          = KeyMaster.GetProviderId();
                idUndefined = true;
            }
            else
            {
                id = reader.GetLong(Id).Value;
            }

            if (string.IsNullOrEmpty(GenderConceptId) && Vocabulary != null)
            {
                genderConceptId = Vocabulary.LookupGender(GenderSourceValue) ?? 0;
            }
            else if (reader.GetInt(GenderConceptId).HasValue)
            {
                genderConceptId = reader.GetInt(GenderConceptId).Value;
            }

            if (concept == null)
            {
                yield return(new Provider
                {
                    Id = id,
                    CareSiteId = reader.GetInt(CareSiteId) ?? 0,
                    ProviderSourceValue = reader.GetString(ProviderSourceValue),
                    SourceValue = reader.GetString(SpecialtySourceValue),
                    NPI = reader.GetString(NPI),
                    DEA = reader.GetString(DEA),
                    Name = reader.GetString(Name),
                    YearOfBirth = reader.GetInt(YearOfBirth),
                    GenderConceptId = genderConceptId,
                    GenderSourceValue = reader.GetString(GenderSourceValue),
                    GenderSourceConceptId = reader.GetInt(GenderSourceConceptId) ?? 0,
                    SpecialtySourceConceptId = reader.GetInt(SpecialtySourceConceptId) ?? 0,
                    LookupKey = reader.GetString(LookupKey)
                });
            }
            else
            {
                var conceptField = concept.Fields[0];


                var source = reader.GetString(conceptField.Key) ?? reader.GetString(conceptField.SourceKey);

                if (source != null && source.Length == 0)
                {
                    source = null;
                }

                var  specialtyConceptIds = concept.GetConceptIdValues(Vocabulary, conceptField, reader).ToList();
                long?specialtyConcept    = null;

                //(Unknown Physician Specialty)
                long defaultConceptId = 38004514;

                if (conceptField.DefaultConceptId.HasValue)
                {
                    defaultConceptId = conceptField.DefaultConceptId.Value;
                }

                if (specialtyConceptIds.Count > 0 && specialtyConceptIds[0].ConceptId != 0)
                {
                    specialtyConcept = specialtyConceptIds[0].ConceptId;
                }

                yield return(new Provider
                {
                    Id = id,
                    IdUndefined = idUndefined,
                    CareSiteId = reader.GetInt(CareSiteId) ?? 0,
                    ConceptId = specialtyConcept.HasValue ? specialtyConcept.Value : defaultConceptId,
                    ProviderSourceValue = reader.GetString(ProviderSourceValue),
                    SourceValue = source,
                    Name = reader.GetString(Name),
                    YearOfBirth = reader.GetInt(YearOfBirth),
                    GenderConceptId = genderConceptId,
                    GenderSourceValue = reader.GetString(GenderSourceValue),
                    NPI = reader.GetString(NPI),
                    DEA = reader.GetString(DEA),
                    GenderSourceConceptId = reader.GetInt(GenderSourceConceptId) ?? 0,
                    SpecialtySourceConceptId = reader.GetInt(SpecialtySourceConceptId) ?? 0,
                    LookupKey = reader.GetString(LookupKey)
                });
            }
        }