Commit cc57dc02 authored by Venkat Malladi's avatar Venkat Malladi
Browse files

Fix medications.

parent a33a4f7f
......@@ -47,8 +47,8 @@ def get_args():
return args
def filter_supplemental(epic, sup, meds_map):
'''Filter by supplemental med name'''
def filter_supportive(epic, sup, meds_map):
'''Filter by supportive med name'''
# Filter for columns
sup_list = list(sup['ID'])
......@@ -184,7 +184,6 @@ def calculate_regime(meds):
onco_meds_reformated.loc[onco_meds_reformated.End_date > datetime.datetime(2020, 3, 1), 'Duration'] = None
# If End_date is null
#onco_meds_reformated.loc[onco_meds_reformated.End_date.isnull(), 'Duration'] = None
onco_meds_reformated.loc[onco_meds_reformated.End_date.isnull(), 'End_date'] = datetime.datetime(2020, 3, 1)
onco_meds_reformated['Duration'] = (onco_meds_reformated['End_date'] - onco_meds_reformated['Start_date']).dt.days
......@@ -205,9 +204,10 @@ def calculate_shift(meds, date_shift):
# Calculate Date Shift
merged['Start_date'] = merged['Start_date'] + merged['Shift']
merged['Start_date'] = merged['Start_date'].dt.date
if 'End_date' in merged.columns:
merged['End_date'] = merged['End_date'] + merged['Shift']
merged['End_date'] = merged['End_date'].dt.date
# Drop Shift column
merged.drop(['Shift'], axis=1, inplace=True)
......@@ -239,7 +239,7 @@ def main():
date_shift = pd.read_csv(date)
# Filter for supplemental meds
supp_meds, onco_meds, missing_meds = filter_supplemental(epic_df, supmedsmap_df, medsmap_df)
supp_meds, onco_meds, missing_meds = filter_supportive(epic_df, supmedsmap_df, medsmap_df)
# Find Supplemental Meds Frequency
supp_meds_regime, filtered_supp_meds = filter_supp(supp_meds)
......@@ -254,9 +254,11 @@ def main():
# Write out meds tables
supp_meds_regime_shifted_df.to_csv(suppmeds_table, index=False)
onco_meds_regime.to_csv(meds_table, index=False)
missing_meds.to_csv(unmapped_table, index=False)
filtered_supp_meds.to_csv(not_given_suppmeds_table, index=False)
onco_meds_shifted_df.to_csv(meds_table, index=False)
if missing_meds.shape[0] > 1:
missing_meds.to_csv(unmapped_table, index=False)
if filtered_supp_meds.shape[0] > 1:
filtered_supp_meds.to_csv(not_given_suppmeds_table, index=False)
if __name__ == '__main__':
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment