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 virtual IEnumerable <IEntity> GetConcepts(Concept concept, IDataRecord reader, KeyMasterOffsetManager offset) { 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); } 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) { var providerIdKey = reader.GetString(ProviderIdKey); if (!string.IsNullOrEmpty(providerIdKey)) { providerIdKey = providerIdKey.TrimStart('0'); } List <int> ingredients = null; if (lookupValue.Ingredients != null) { ingredients = new List <int>(lookupValue.Ingredients.Count); ingredients.AddRange(lookupValue.Ingredients); } if (!string.IsNullOrEmpty(StartTime)) { if (DateTime.TryParse(reader.GetString(StartTime), out var dt)) { startDate = startDate + dt.TimeOfDay; } } if (endDate != DateTime.MinValue && !string.IsNullOrEmpty(EndTime)) { if (DateTime.TryParse(reader.GetString(EndTime), out var dt)) { endDate = endDate + dt.TimeOfDay; } } yield return(new Entity { IsUnique = IsUnique, PersonId = personId.Value, SourceValue = sourceValue, ConceptId = cId ?? 0, TypeConceptId = concept.GetTypeId(field, reader), ConceptIdKey = reader.GetString(field.Key), StartDate = startDate, EndDate = endDate == DateTime.MinValue ? (DateTime?)null : endDate, ProviderId = reader.GetLong(ProviderId), ProviderKey = providerIdKey, VisitOccurrenceId = reader.GetLong(VisitOccurrenceId), VisitDetailId = reader.GetLong(VisitDetailId), AdditionalFields = additionalFields, ValidStartDate = lookupValue.ValidStartDate, ValidEndDate = lookupValue.ValidEndDate, SourceConceptId = lookupValue.SourceConceptId, Domain = lookupValue.Domain, //SourceVocabularyId = lookupValue.SourceVocabularyId, VocabularySourceValue = lookupValue.SourceCode, Ingredients = ingredients }); } } } } }