diff --git a/sources/Framework/org.ohdsi.cdm.framework/Common/Definitions/EntityDefinition.cs b/sources/Framework/org.ohdsi.cdm.framework/Common/Definitions/EntityDefinition.cs index e9a548ae..85ed7383 100644 --- a/sources/Framework/org.ohdsi.cdm.framework/Common/Definitions/EntityDefinition.cs +++ b/sources/Framework/org.ohdsi.cdm.framework/Common/Definitions/EntityDefinition.cs @@ -1,4 +1,5 @@ -using org.ohdsi.cdm.framework.common.Builder; +using Force.DeepCloner; +using org.ohdsi.cdm.framework.common.Builder; using org.ohdsi.cdm.framework.common.Extensions; using org.ohdsi.cdm.framework.common.Lookups; using org.ohdsi.cdm.framework.common.Omop; @@ -131,7 +132,7 @@ public virtual IEnumerable GetConcepts(Concept concept, IDataRecord rea } } - yield return new Entity + var entity = new Entity { IsUnique = IsUnique, PersonId = personId.Value, @@ -150,17 +151,30 @@ public virtual IEnumerable GetConcepts(Concept concept, IDataRecord rea ValidEndDate = lookupValue.ValidEndDate, SourceConceptId = sourceConceptId, Domain = lookupValue.Domain, - //SourceVocabularyId = lookupValue.SourceVocabularyId, VocabularySourceValue = lookupValue.SourceCode, Ingredients = ingredients, - ValueAsConceptId = lookupValue.ValueAsConceptId, + ValueAsConceptId = null, SourceConcepts = lookupValue.SourceConcepts.ToList(), }; + + if (lookupValue.ValueAsConceptIds == null || lookupValue.ValueAsConceptIds.Count == 0) + { + yield return entity; + } + else + { + foreach (var valueAsConceptId in lookupValue.ValueAsConceptIds) + { + var ent = entity.DeepClone(); + ent.ValueAsConceptId = valueAsConceptId; + yield return ent; + } + } } } } } } } -} +} \ No newline at end of file diff --git a/sources/Framework/org.ohdsi.cdm.framework/Common/Lookups/Lookup.cs b/sources/Framework/org.ohdsi.cdm.framework/Common/Lookups/Lookup.cs index 829d3643..648e3808 100644 --- a/sources/Framework/org.ohdsi.cdm.framework/Common/Lookups/Lookup.cs +++ b/sources/Framework/org.ohdsi.cdm.framework/Common/Lookups/Lookup.cs @@ -136,33 +136,6 @@ public void Fill(AmazonS3Client client, string bucket, string prefix) ValidEndDate = validEndDate }; - //if (spliter.Results.Length > 5) - //{ - // //lv.SourceConceptId = IsNullOrEmpty(spliter.Results[6]) - // // ? 0 - // // : long.Parse(spliter.Results[6]); - - // var sourceConceptId = IsNullOrEmpty(spliter.Results[6]) - // ? 0 - // : long.Parse(spliter.Results[6]); - - // var sourceValidStartDate = DateTime.MinValue; - // var sourceValidEndDate = DateTime.MaxValue; - - // if (spliter.Results.Length > 6) - // { - // DateTime.TryParse(spliter.Results[7], out sourceValidStartDate); - // DateTime.TryParse(spliter.Results[8], out sourceValidEndDate); - // } - - // lv.SourceConcepts.Add(new SourceConcepts - // { - // ConceptId = sourceConceptId, - // ValidStartDate = sourceValidStartDate, - // ValidEndDate = sourceValidEndDate - // }); - //} - value = lv; _lookup[sourceCode].Add(conceptId, value); } @@ -204,11 +177,16 @@ public void Fill(AmazonS3Client client, string bucket, string prefix) value.Ingredients.Add(ingredient); } } - - if (spliter.Results.Length > 10) + + if (spliter.Results.Length > 10) { - if (!IsNullOrEmpty(spliter.Results[10])) - value.ValueAsConceptId = long.Parse(spliter.Results[10]); + + if (!IsNullOrEmpty(spliter.Results[10]) && + long.TryParse(spliter.Results[10], out var valueAsConceptId)) + { + value.ValueAsConceptIds ??= []; + value.ValueAsConceptIds.Add(valueAsConceptId); + } } } } @@ -253,7 +231,7 @@ private IEnumerable GetValues(string sourceCode, DateTime? eventDat Ingredients = _lookup[sourceCode][conceptId].Ingredients, ValidStartDate = _lookup[sourceCode][conceptId].ValidStartDate, ValidEndDate = _lookup[sourceCode][conceptId].ValidEndDate, - ValueAsConceptId = _lookup[sourceCode][conceptId].ValueAsConceptId, + ValueAsConceptIds = _lookup[sourceCode][conceptId].ValueAsConceptIds, //SourceValidStartDate = _lookup[sourceCode][conceptId].SourceValidStartDate, //SourceValidEndDate = _lookup[sourceCode][conceptId].SourceValidEndDate, SourceConcepts = _lookup[sourceCode][conceptId].SourceConcepts, diff --git a/sources/Framework/org.ohdsi.cdm.framework/Common/Lookups/LookupValue.cs b/sources/Framework/org.ohdsi.cdm.framework/Common/Lookups/LookupValue.cs index 41d3e0f1..93e1f150 100644 --- a/sources/Framework/org.ohdsi.cdm.framework/Common/Lookups/LookupValue.cs +++ b/sources/Framework/org.ohdsi.cdm.framework/Common/Lookups/LookupValue.cs @@ -34,7 +34,7 @@ public class LookupValue : IEquatable public HashSet SourceConcepts { get; set; } = []; public HashSet Ingredients { get; set; } - public long? ValueAsConceptId { get; set; } + public HashSet ValueAsConceptIds { get; set; } public bool Equals(LookupValue other) {