Skip to content

Commit

Permalink
Merge pull request #123 from OHDSI/value-as-conceptid-fix
Browse files Browse the repository at this point in the history
Add support of the multiple VALUE_AS_CONCEPT_ID
  • Loading branch information
bradanton authored Oct 9, 2024
2 parents 57cbee1 + 30975e6 commit 4685c72
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -131,7 +132,7 @@ public virtual IEnumerable<IEntity> GetConcepts(Concept concept, IDataRecord rea
}
}

yield return new Entity
var entity = new Entity
{
IsUnique = IsUnique,
PersonId = personId.Value,
Expand All @@ -150,17 +151,30 @@ public virtual IEnumerable<IEntity> 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;
}
}
}
}
}
}
}
}
}
}
42 changes: 10 additions & 32 deletions sources/Framework/org.ohdsi.cdm.framework/Common/Lookups/Lookup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
}
}
}
Expand Down Expand Up @@ -253,7 +231,7 @@ private IEnumerable<LookupValue> 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class LookupValue : IEquatable<LookupValue>

public HashSet<SourceConcepts> SourceConcepts { get; set; } = [];
public HashSet<long> Ingredients { get; set; }
public long? ValueAsConceptId { get; set; }
public HashSet<long> ValueAsConceptIds { get; set; }

public bool Equals(LookupValue other)
{
Expand Down

0 comments on commit 4685c72

Please sign in to comment.