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

Take maximum value for lab on day.

parent 656170c6
Pipeline #6648 failed with stage
in 8 seconds
......@@ -180,6 +180,13 @@ def calculate_shift(labs, date_shift):
return merged
def calculate_maximum(labs):
'''Get maximum lab value for a given day'''
labs_max = labs.loc[labs.groupby(['mrn', 'date', 'lab'])['value'].idxmax()]
return labs_max
def main():
args = get_args()
labs = args.file
......@@ -213,8 +220,11 @@ def main():
# Calculate Date Shift
shifted_df = calculate_shift(labs_flag, date_shift)
# Filter and get maximum lab value for shifted date
max_lab = calculate_maximum(shifted_df)
# Write out lab table
shifted_df.to_csv(lab_table, index=False)
max_lab.to_csv(lab_table, index=False)
# Write out unmapped sites if there are any
if unmapped_labs.shape[0] > 1:
......
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