private IEnumerable <IEntity> PopulateDeath(IDataRecord reader, Concept secondaryConcept, IEntity baseConcept) { foreach (var field in secondaryConcept.Fields) { foreach (var lookupValue in secondaryConcept.GetConceptIdValues(Vocabulary, field, reader)) { if (lookupValue.ConceptId > 0) { var sourceConceptIdValues = secondaryConcept.GetSourceConceptIdValues(Vocabulary, field, reader); long sourceConceptId = 0; if (sourceConceptIdValues.Any()) { sourceConceptId = sourceConceptIdValues[0].ConceptId.HasValue ? sourceConceptIdValues[0].ConceptId.Value : 0; } yield return(new Death((Entity)baseConcept) { TypeConceptId = field.DefaultTypeId.HasValue ? field.DefaultTypeId.Value : 0, ValidStartDate = lookupValue.ValidStartDate, ValidEndDate = lookupValue.ValidEndDate, SourceConceptId = sourceConceptId //TypeConceptId = 0 // !!! }); break; } } } }
public override IEnumerable <IEntity> GetConcepts(Concept concept, IDataRecord reader, KeyMasterOffset keyOffset) { var id = string.IsNullOrEmpty(Id) ? KeyMaster.GetCareSiteId() : reader.GetLong(Id); long conceptId = 0; if (!string.IsNullOrEmpty(PlaceOfSvcConceptId) && reader.GetLong(PlaceOfSvcConceptId).HasValue) { conceptId = reader.GetLong(PlaceOfSvcConceptId).Value; } var locationId = reader.GetLong(LocationId); var careSiteSourceValue = string.IsNullOrEmpty(CareSiteSourceValue) ? id.Value.ToString(CultureInfo.InvariantCulture) : reader.GetString(CareSiteSourceValue); if (concept == null) { yield return(new CareSite { Id = id.Value, LocationId = locationId.HasValue ? locationId.Value : 0, PlaceOfSvcSourceValue = reader.GetString(PlaceOfSvcSourceValue), ConceptId = conceptId, Name = reader.GetString(Name), SourceValue = careSiteSourceValue }); } 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 placeOfSvcConceptIds = concept.GetConceptIdValues(Vocabulary, conceptField, reader).ToList(); long?placeOfSvcConceptId = null; long defaultConceptId = 0; if (conceptField.DefaultConceptId.HasValue) { defaultConceptId = conceptField.DefaultConceptId.Value; } if (placeOfSvcConceptIds.Count > 0 && placeOfSvcConceptIds[0].ConceptId != 0) { placeOfSvcConceptId = placeOfSvcConceptIds[0].ConceptId; } yield return(new CareSite { Id = id.Value, LocationId = locationId.HasValue ? locationId.Value : 0, PlaceOfSvcSourceValue = source, ConceptId = placeOfSvcConceptId.HasValue ? placeOfSvcConceptId.Value : defaultConceptId, Name = reader.GetString(Name), SourceValue = careSiteSourceValue }); } }
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, 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) }); } }