diff --git a/sources/Framework/org.ohdsi.cdm.framework.etl/Transformation/CDM/CdmPersonBuilder.cs b/sources/Framework/org.ohdsi.cdm.framework.etl/Transformation/CDM/CdmPersonBuilder.cs
index 3ffeca4b..da4654be 100644
--- a/sources/Framework/org.ohdsi.cdm.framework.etl/Transformation/CDM/CdmPersonBuilder.cs
+++ b/sources/Framework/org.ohdsi.cdm.framework.etl/Transformation/CDM/CdmPersonBuilder.cs
@@ -94,11 +94,6 @@ public override Attrition Build(ChunkData data, KeyMasterOffsetManager o)
return result.Value;
}
- //if(person.PersonId == 136899754)
- //{
-
- //}
-
if(ObservationPeriodsRaw.Count == 0)
return Attrition.InvalidObservationTime;
diff --git a/sources/Framework/org.ohdsi.cdm.framework.etl/Transformation/CDM/Definitions/L_PROVIDER.xml b/sources/Framework/org.ohdsi.cdm.framework.etl/Transformation/CDM/Definitions/L_PROVIDER.xml
index 7791d75e..eceffe18 100644
--- a/sources/Framework/org.ohdsi.cdm.framework.etl/Transformation/CDM/Definitions/L_PROVIDER.xml
+++ b/sources/Framework/org.ohdsi.cdm.framework.etl/Transformation/CDM/Definitions/L_PROVIDER.xml
@@ -30,7 +30,7 @@
-
+
diff --git a/sources/Framework/org.ohdsi.cdm.framework.etl/Transformation/CDM/Definitions/Observation_period.xml b/sources/Framework/org.ohdsi.cdm.framework.etl/Transformation/CDM/Definitions/Observation_period.xml
new file mode 100644
index 00000000..52574046
--- /dev/null
+++ b/sources/Framework/org.ohdsi.cdm.framework.etl/Transformation/CDM/Definitions/Observation_period.xml
@@ -0,0 +1,22 @@
+
+
+ SELECT distinct
+ op.observation_period_id,
+ op.person_id,
+ op.observation_period_start_date,
+ op.observation_period_end_date,
+ op.period_type_concept_id
+ FROM {sc}.observation_period op
+ JOIN {ch_sc}._chunks ch ON ch.ChunkId = {0} AND op.PERSON_ID = ch.PERSON_ID
+ order by 1
+
+
+
+ observation_period_id
+ person_id
+ observation_period_start_date
+ observation_period_end_date
+ period_type_concept_id
+
+
+
\ No newline at end of file
diff --git a/sources/Framework/org.ohdsi.cdm.framework.etl/Transformation/CDM/Definitions/Person.xml b/sources/Framework/org.ohdsi.cdm.framework.etl/Transformation/CDM/Definitions/Person.xml
index 8b03ecc3..4e14cfd6 100644
--- a/sources/Framework/org.ohdsi.cdm.framework.etl/Transformation/CDM/Definitions/Person.xml
+++ b/sources/Framework/org.ohdsi.cdm.framework.etl/Transformation/CDM/Definitions/Person.xml
@@ -19,15 +19,9 @@
t.race_source_concept_id,
t.ethnicity_source_value,
t.ethnicity_source_concept_id,
-
- op.observation_period_start_date,
- op.observation_period_end_date,
- op.period_type_concept_id,
-
1 as fake
FROM {sc}.person t
JOIN {ch_sc}._chunks ch ON ch.ChunkId = {0} AND t.PERSON_ID = ch.PERSON_ID
- JOIN {sc}.observation_period op ON t.PERSON_ID = op.PERSON_ID
order by 1
@@ -48,10 +42,6 @@
race_source_concept_id
ethnicity_source_value
ethnicity_source_concept_id
-
- observation_period_start_date
- observation_period_end_date
- period_type_concept_id
diff --git a/sources/Framework/org.ohdsi.cdm.framework.etl/Transformation/Truven/Definitions/L_PROVIDER.xml b/sources/Framework/org.ohdsi.cdm.framework.etl/Transformation/Truven/Definitions/L_PROVIDER.xml
index 91888e99..f5e45840 100644
--- a/sources/Framework/org.ohdsi.cdm.framework.etl/Transformation/Truven/Definitions/L_PROVIDER.xml
+++ b/sources/Framework/org.ohdsi.cdm.framework.etl/Transformation/Truven/Definitions/L_PROVIDER.xml
@@ -31,7 +31,7 @@
-
+
diff --git a/sources/Framework/org.ohdsi.cdm.framework.etl/org.ohdsi.cdm.framework.etl.csproj b/sources/Framework/org.ohdsi.cdm.framework.etl/org.ohdsi.cdm.framework.etl.csproj
index 33224be1..8718cdac 100644
--- a/sources/Framework/org.ohdsi.cdm.framework.etl/org.ohdsi.cdm.framework.etl.csproj
+++ b/sources/Framework/org.ohdsi.cdm.framework.etl/org.ohdsi.cdm.framework.etl.csproj
@@ -18,6 +18,7 @@
+
@@ -329,6 +330,9 @@
Always
+
+ Always
+
Always
diff --git a/sources/Framework/org.ohdsi.cdm.framework/Common/Base/IPersonBuilder.cs b/sources/Framework/org.ohdsi.cdm.framework/Common/Base/IPersonBuilder.cs
index 165d4a0f..fd39b1ed 100644
--- a/sources/Framework/org.ohdsi.cdm.framework/Common/Base/IPersonBuilder.cs
+++ b/sources/Framework/org.ohdsi.cdm.framework/Common/Base/IPersonBuilder.cs
@@ -28,6 +28,8 @@ public interface IPersonBuilder
void AddEpisode(Episode data);
+ void AddObservationPeriod(EraEntity data);
+
//void Build(ChunkData chunkData);
Attrition Build(ChunkData data, KeyMasterOffsetManager offset);
diff --git a/sources/Framework/org.ohdsi.cdm.framework/Common/Base/PersonBuilder.cs b/sources/Framework/org.ohdsi.cdm.framework/Common/Base/PersonBuilder.cs
index addbb345..1b775f27 100644
--- a/sources/Framework/org.ohdsi.cdm.framework/Common/Base/PersonBuilder.cs
+++ b/sources/Framework/org.ohdsi.cdm.framework/Common/Base/PersonBuilder.cs
@@ -284,6 +284,11 @@ public void AddEpisode(Episode data)
EpisodeRecords.Add(data);
}
+ public void AddObservationPeriod(EraEntity data)
+ {
+ ObservationPeriodsRaw.Add(data);
+ }
+
///
/// Add raw entities to builder for further build
///
@@ -295,15 +300,19 @@ public void AddData(IEntity data)
case EntityType.Person:
{
AddEntity((Person)data, PersonRecords);
- AddEntity(
- new EraEntity
- {
- PersonId = data.PersonId,
- StartDate = data.StartDate,
- EndDate = data.EndDate,
- TypeConceptId = data.TypeConceptId,
- AdditionalFields = data.AdditionalFields
- }, ObservationPeriodsRaw);
+
+ if (data.TypeConceptId.HasValue)
+ {
+ AddEntity(
+ new EraEntity
+ {
+ PersonId = data.PersonId,
+ StartDate = data.StartDate,
+ EndDate = data.EndDate,
+ TypeConceptId = data.TypeConceptId,
+ AdditionalFields = data.AdditionalFields
+ }, ObservationPeriodsRaw);
+ }
break;
}
diff --git a/sources/Framework/org.ohdsi.cdm.framework/Common/Definitions/ObservationPeriodDefinition.cs b/sources/Framework/org.ohdsi.cdm.framework/Common/Definitions/ObservationPeriodDefinition.cs
new file mode 100644
index 00000000..0b62cca6
--- /dev/null
+++ b/sources/Framework/org.ohdsi.cdm.framework/Common/Definitions/ObservationPeriodDefinition.cs
@@ -0,0 +1,30 @@
+using org.ohdsi.cdm.framework.common.Builder;
+using org.ohdsi.cdm.framework.common.Extensions;
+using org.ohdsi.cdm.framework.common.Omop;
+using System.Data;
+
+namespace org.ohdsi.cdm.framework.common.Definitions
+{
+ public class ObservationPeriodDefinition : EntityDefinition
+ {
+ public string TypeConceptId { get; set; }
+
+ public IEnumerable GetObservationPeriods(Concept concept, IDataRecord reader,
+ KeyMasterOffsetManager offset)
+ {
+ yield return new EraEntity
+ {
+ Id = reader.GetLong(Id) ?? 0,
+ PersonId = reader.GetLong(PersonId) ?? 0,
+ TypeConceptId = reader.GetLong(TypeConceptId) ?? 0,
+ StartDate = reader.GetDateTime(StartDate),
+ EndDate = reader.GetDateTime(EndDate),
+ };
+ }
+
+ public override IEnumerable GetConcepts(Concept concept, IDataRecord reader, KeyMasterOffsetManager offset)
+ {
+ throw new NotImplementedException("ObservationPeriodDefinition.GetConcepts()");
+ }
+ }
+}
\ No newline at end of file
diff --git a/sources/Framework/org.ohdsi.cdm.framework/Common/Definitions/ProviderDefinition.cs b/sources/Framework/org.ohdsi.cdm.framework/Common/Definitions/ProviderDefinition.cs
index 18626f8d..288e1159 100644
--- a/sources/Framework/org.ohdsi.cdm.framework/Common/Definitions/ProviderDefinition.cs
+++ b/sources/Framework/org.ohdsi.cdm.framework/Common/Definitions/ProviderDefinition.cs
@@ -82,9 +82,7 @@ public override IEnumerable GetConcepts(Concept concept, IDataRecord re
long? specialtyConcept = null;
long? specialtySourceConceptId = null;
- //(Unknown Physician Specialty)
- var defaultConceptId = 38004514;
-
+ var defaultConceptId = 0;
if (conceptField.DefaultConceptId.HasValue)
{
defaultConceptId = conceptField.DefaultConceptId.Value;
diff --git a/sources/Framework/org.ohdsi.cdm.framework/Common/Definitions/QueryDefinition.cs b/sources/Framework/org.ohdsi.cdm.framework/Common/Definitions/QueryDefinition.cs
index 2ded0d6c..818c9793 100644
--- a/sources/Framework/org.ohdsi.cdm.framework/Common/Definitions/QueryDefinition.cs
+++ b/sources/Framework/org.ohdsi.cdm.framework/Common/Definitions/QueryDefinition.cs
@@ -90,6 +90,7 @@ public class QueryDefinition
public EpisodeDefinition[] Episodes { get; set; }
public EpisodeEventDefinition[] EpisodeEvents { get; set; }
+ public ObservationPeriodDefinition[] ObservationPeriods { get; set; }
private static readonly string[] separator = [","];
@@ -255,6 +256,10 @@ public string GetPersonIdFieldName()
return EpisodeEvents[0].PersonId;
}
+ if (ObservationPeriods != null && ObservationPeriods.Length != 0)
+ {
+ return ObservationPeriods[0].PersonId;
+ }
throw new Exception("Cant find PersonId FieldName " + this.FileName);
}
diff --git a/sources/Framework/org.ohdsi.cdm.framework/Common/Extensions/DataRecordExtensions.cs b/sources/Framework/org.ohdsi.cdm.framework/Common/Extensions/DataRecordExtensions.cs
index fbf661b3..6a8c5d10 100644
--- a/sources/Framework/org.ohdsi.cdm.framework/Common/Extensions/DataRecordExtensions.cs
+++ b/sources/Framework/org.ohdsi.cdm.framework/Common/Extensions/DataRecordExtensions.cs
@@ -16,9 +16,14 @@ public static string GetString(this IDataRecord reader, string fieldName)
if (string.IsNullOrEmpty(fieldName))
return null;
- var value = GetValue(reader, fieldName).ToString();
+ var value = GetValue(reader, fieldName);
+
+ if (value is null || value is DBNull)
+ return null;
+
+ var strValue = value.ToString();
- return string.Intern(value.Trim());
+ return string.Intern(strValue.Trim());
}
catch (Exception e)
{
diff --git a/sources/Presentation/org.ohdsi.cdm.presentation.lambdabuilder/Base/LambdaChunkPart.cs b/sources/Presentation/org.ohdsi.cdm.presentation.lambdabuilder/Base/LambdaChunkPart.cs
index ebea41d5..6abae411 100644
--- a/sources/Presentation/org.ohdsi.cdm.presentation.lambdabuilder/Base/LambdaChunkPart.cs
+++ b/sources/Presentation/org.ohdsi.cdm.presentation.lambdabuilder/Base/LambdaChunkPart.cs
@@ -321,6 +321,7 @@ private void Watchdog_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
AddEntity(qd, qd.Note, reader, recordGuid, personIdsToSave);
AddEntity(qd, qd.Episodes, reader, recordGuid, personIdsToSave);
+ AddEntity(qd, qd.ObservationPeriods, reader, recordGuid, personIdsToSave);
if (reader.Paused)
break;
@@ -640,6 +641,15 @@ private void AddEntity(QueryDefinition queryDefinition, IEnumerable