Skip to content

Commit

Permalink
fix: additional column for patid to keep pat identifier for joins, in…
Browse files Browse the repository at this point in the history
…clude new datadictionary (#165)

* additional column for patid to keep pat identifier for joins

* updated and uploaded datadictionary
  • Loading branch information
jasminziegler authored Mar 27, 2024
1 parent 2d9ea9c commit 49ec635
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Binary file not shown.
8 changes: 7 additions & 1 deletion src/obds_fhir_to_opal/obds_fhir_to_opal.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,10 @@ def encode_patients(ptl: PathlingContext, df_bundles: pyspark.sql.dataframe.Data
return_yearUDF = udf(lambda x: return_year(x), StringType())

patients = df_patients.selectExpr(
"EXPLODE_OUTER(identifier.value) as pat_id", "gender", "birthDate",
"id as pat_id",
# todo: remove this later or change opal datadictionary
"EXPLODE_OUTER(identifier.value) as patID",
"gender", "birthDate",
"deceasedBoolean", "deceasedDateTime"
)

Expand All @@ -255,6 +258,7 @@ def encode_patients(ptl: PathlingContext, df_bundles: pyspark.sql.dataframe.Data

patients = patients.select(
patients.pat_id,
patients.patID,
patients.gender,
patients.gender_mapped,
patients.birthDate,
Expand Down Expand Up @@ -632,6 +636,7 @@ def encode_observations(ptl: PathlingContext, df_bundles):
def group_df(joined_dataframe):
joined_dataframe_grouped = joined_dataframe.groupBy("cond_id").agg(
first("pat_id").alias("pat_id"),
first("patID").alias("patID"),
first("gender_mapped").alias("gender_mapped"),
first("conditiondate").alias("conditiondate"),
first("condcodingcode").alias("condcodingcode"),
Expand Down Expand Up @@ -660,6 +665,7 @@ def group_df(joined_dataframe):
joined_dataframe_grouped_repartitioned = (
joined_dataframe_grouped_repartitioned.select(
"pat_id",
"patID",
"cond_id",
"gender_mapped",
"conditiondate",
Expand Down

0 comments on commit 49ec635

Please sign in to comment.