Commit 32e801e1 authored by Venkat Malladi's avatar Venkat Malladi
Browse files

Make lower case.

parent cc57dc02
Pipeline #6775 failed with stage
in 10 seconds
...@@ -79,7 +79,7 @@ def filter_supp(supp_meds): ...@@ -79,7 +79,7 @@ def filter_supp(supp_meds):
#Filter columns #Filter columns
supp_meds_reformated = meds_taken[['MRN', 'Meds', 'START_DATE']] supp_meds_reformated = meds_taken[['MRN', 'Meds', 'START_DATE']]
supp_meds_reformated.columns = ['mrn', 'name', 'Start_date'] supp_meds_reformated.columns = ['mrn', 'name', 'start_date']
return supp_meds_reformated, meds_non_taken return supp_meds_reformated, meds_non_taken
...@@ -170,22 +170,22 @@ def calculate_regime(meds): ...@@ -170,22 +170,22 @@ def calculate_regime(meds):
# Format Oncological Meds # Format Oncological Meds
meds_filtered_uniq = meds_transformed.groupby(['mrn', 'name'], as_index=False).agg({'date' : [np.min, np.max], 'start' : [np.min], 'end' : [np.max] }) meds_filtered_uniq = meds_transformed.groupby(['mrn', 'name'], as_index=False).agg({'date' : [np.min, np.max], 'start' : [np.min], 'end' : [np.max] })
meds_filtered_uniq.columns = ['mrn', 'name','date_start', 'date_end', 'start', 'end'] meds_filtered_uniq.columns = ['mrn', 'name','date_start', 'date_end', 'start', 'end']
meds_filtered_uniq['Start_date'] = meds_filtered_uniq[['date_start', 'date_end', 'start', 'end']].min(axis=1) meds_filtered_uniq['start_date'] = meds_filtered_uniq[['date_start', 'date_end', 'start', 'end']].min(axis=1)
meds_filtered_uniq['End_date'] = meds_filtered_uniq[['date_start', 'date_end', 'start', 'end']].max(axis=1) meds_filtered_uniq['end_date'] = meds_filtered_uniq[['date_start', 'date_end', 'start', 'end']].max(axis=1)
meds_filtered_uniq['Duration'] = (meds_filtered_uniq['End_date'] - meds_filtered_uniq['Start_date']).dt.days meds_filtered_uniq['Duration'] = (meds_filtered_uniq['end_date'] - meds_filtered_uniq['start_date']).dt.days
onco_meds_reformated = meds_filtered_uniq[['mrn', 'name', 'Start_date', 'End_date', 'Duration']] onco_meds_reformated = meds_filtered_uniq[['mrn', 'name', 'start_date', 'end_date', 'Duration']]
# Reset duration for 0 # Reset duration for 0
onco_meds_reformated.loc[onco_meds_reformated.Duration == 0, 'End_date'] = None onco_meds_reformated.loc[onco_meds_reformated.Duration == 0, 'end_date'] = None
onco_meds_reformated.loc[onco_meds_reformated.Duration == 0, 'Duration'] = None onco_meds_reformated.loc[onco_meds_reformated.Duration == 0, 'Duration'] = None
# If End Date > that current pull reset to null # If End Date > that current pull reset to null
onco_meds_reformated.loc[onco_meds_reformated.End_date > datetime.datetime(2020, 3, 1), 'End_date'] = None onco_meds_reformated.loc[onco_meds_reformated.end_date > datetime.datetime(2020, 3, 1), 'end_date'] = None
onco_meds_reformated.loc[onco_meds_reformated.End_date > datetime.datetime(2020, 3, 1), 'Duration'] = None onco_meds_reformated.loc[onco_meds_reformated.end_date > datetime.datetime(2020, 3, 1), 'Duration'] = None
# If End_date is null # If End_date is null
onco_meds_reformated.loc[onco_meds_reformated.End_date.isnull(), 'End_date'] = datetime.datetime(2020, 3, 1) 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 onco_meds_reformated['Duration'] = (onco_meds_reformated['end_date'] - onco_meds_reformated['start_date']).dt.days
onco_meds_reformated = onco_meds_reformated.reset_index(drop=True) onco_meds_reformated = onco_meds_reformated.reset_index(drop=True)
...@@ -197,17 +197,17 @@ def calculate_shift(meds, date_shift): ...@@ -197,17 +197,17 @@ def calculate_shift(meds, date_shift):
# Convert to DateTime # Convert to DateTime
date_shift['Shift'] = pd.to_timedelta(date_shift['Shift'], unit='s') date_shift['Shift'] = pd.to_timedelta(date_shift['Shift'], unit='s')
meds['Start_date'] = pd.to_datetime(meds['Start_date']) meds['start_date'] = pd.to_datetime(meds['start_date'])
# Merge data # Merge data
merged = meds.merge(date_shift, left_on='mrn', right_on='MRN', how='inner') merged = meds.merge(date_shift, left_on='mrn', right_on='MRN', how='inner')
# Calculate Date Shift # Calculate Date Shift
merged['Start_date'] = merged['Start_date'] + merged['Shift'] merged['start_date'] = merged['start_date'] + merged['Shift']
merged['Start_date'] = merged['Start_date'].dt.date merged['start_date'] = merged['start_date'].dt.date
if 'End_date' in merged.columns: if 'end_date' in merged.columns:
merged['End_date'] = merged['End_date'] + merged['Shift'] merged['end_date'] = merged['end_date'] + merged['Shift']
merged['End_date'] = merged['End_date'].dt.date merged['end_date'] = merged['end_date'].dt.date
# Drop Shift column # Drop Shift column
merged.drop(['Shift'], axis=1, inplace=True) merged.drop(['Shift'], axis=1, inplace=True)
......
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