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;
            }
        }
        }
 }
Esempio n. 2
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;
                    }
                }
            }
        }
Esempio n. 3
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
                            });
                        }
                    }
                }
            }
        }
        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, 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
                     };
                  }
               }
            }
             }
        }
Esempio n. 6
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)
                });
            }
        }