Commit 10b5ebcb authored by Venkat Malladi's avatar Venkat Malladi
Browse files

Update radiation logic to include end date.

parent 1d34b07c
Pipeline #5149 failed with stage
in 3 seconds
......@@ -92,7 +92,7 @@ def convert_sites(radiation, sites):
# Filter for columns
filter_col = ["MRN", "SITE_SPECIFIC", "SITE_GENERAL",
"DOSE_CGY_ACTUAL", "FRACTIONS_ACTUAL",
"STARTDATE", "TREATINTENT"]
"STARTDATE", "LASTDATE", "TREATINTENT"]
radiation_filtered = radiation_mapped.loc[:, filter_col]
# Remove commas in
......@@ -110,11 +110,12 @@ def convert_treatment(merged):
def calculate_shift(radiation, date_shift):
'''Shift Date for start date'''
'''Shift Date for start and last date'''
# Convert to DateTime
date_shift['Shift'] = pd.to_timedelta(date_shift['Shift'], unit='s')
radiation['STARTDATE'] = pd.to_datetime(radiation['STARTDATE'])
radiation['LASTDATE'] = pd.to_datetime(radiation['LASTDATE'])
# Merge data
merged = radiation.merge(date_shift, left_on='MRN', right_on='MRN', how='inner')
......@@ -123,6 +124,9 @@ def calculate_shift(radiation, date_shift):
merged['STARTDATE'] = merged['STARTDATE'] + merged['Shift']
merged['STARTDATE'] = merged['STARTDATE'].dt.date
merged['LASTDATE'] = merged['LASTDATE'] + merged['Shift']
merged['LASTDATE'] = merged['LASTDATE'].dt.date
# Drop Shift column
merged.drop(['Shift'], axis=1, inplace=True)
......@@ -134,7 +138,7 @@ def calculate_shift(radiation, date_shift):
# Rename columns
radiation_columns = ["mrn", "site_specific", "site_general",
"dose_cgy_actual", "fractions_actual", 'start_date', 'treatment_intention']
"dose_cgy_actual", "fractions_actual", 'start_date', 'end_date', 'treatment_intention']
merged.columns = radiation_columns
return merged
......
MRN,SITE_SPECIFIC,SITE_GENERAL,DOSE_CGY_ACTUAL,FRACTIONS_ACTUAL,STARTDATE,TREATINTENT,Sites
934,Liver,Liver,3000,5,1/5/2013,Curative,Liver
313,Femur,Bone and bone marrow,2000,1,8/25/2011,Palliative,Bone/Bone marrow/Spine
313,Femur,Bone,2000,1,8/25/2011,Palliative,Bone/Bone marrow/Spine
313,Spine,Spine,2000,1,8/25/2011,Palliative,Bone/Bone marrow/Spine
903,0A:1 L frontal,Brain,1300,1,2/4/2017,Not Available,Brain
903,0B:2 R Cor Callos,Brain,1300,1,2/4/2017,Not Available,Brain
......@@ -10,5 +10,5 @@ MRN,SITE_SPECIFIC,SITE_GENERAL,DOSE_CGY_ACTUAL,FRACTIONS_ACTUAL,STARTDATE,TREATI
687,prostate gland,Prostate gland,2700,15,6/27/2009,Curative,Other
687,PTV RUL 40Gy5fx,"Lung, right",4000,5,8/18/2013,Consolidative,Lung
423,RtAdrenal,"Adrenal gland, right",3600,3,4/29/2015,Consolidative,Adrenal
88,L shoulder,Bone and bone marrow,3000,10,7/4/2009,Not Available,Bone/Bone marrow/Spine
88,R Hip,Bone and bone marrow,3000,5,2/20/2010,De-Bulking,Bone/Bone marrow/Spine
88,L shoulder,Bone,3000,10,7/4/2009,Not Available,Bone/Bone marrow/Spine
88,R Hip,Bone,3000,5,2/20/2010,De-Bulking,Bone/Bone marrow/Spine
mrn,site_specific,site_general,dose_cgy_actual,fractions_actual,start_date,treatment_intention
313,Femur,Bone and bone marrow,2000.0,1.0,1857-06-14,Palliative
313,Spine,Spine,2000.0,1.0,1857-06-14,Palliative
423,RtAdrenal,"Adrenal gland, right",3600.0,3.0,1870-05-26,Consolidative
687,PTV RUL 40Gy5fx,"Lung, right",4000.0,5.0,1855-02-05,Consolidative
822,Abdomen,Retroperitoneum & peritoneum,2500.0,5.0,1901-01-30,Not Available
88,L shoulder,Bone and bone marrow,3000.0,10.0,1858-10-22,Not Available
88,R Hip,Bone and bone marrow,3000.0,5.0,1859-06-10,De-Bulking
903,0A:1 L frontal,Brain,1300.0,1.0,1824-05-21,Not Available
903,0B:2 R Cor Callos,Brain,1300.0,1.0,1824-05-21,Not Available
903,0C:3 R ventral po,Brain,1300.0,1.0,1824-05-21,Not Available
903,0D:4 R eye,Brain,1300.0,1.0,1824-05-21,Not Available
934,Liver,Liver,3000.0,5.0,1855-07-13,Curative
mrn,site_specific,site_general,dose_cgy_actual,fractions_actual,start_date,end_date,treatment_intention
313,Femur,Bone,2000.0,1.0,1857-06-14,1857-06-14,Palliative
313,Spine,Spine,2000.0,1.0,1857-06-14,1857-06-14,Palliative
423,RtAdrenal,"Adrenal gland, right",3600.0,3.0,1870-05-26,1870-05-26,Consolidative
687,PTV RUL 40Gy5fx,"Lung, right",4000.0,5.0,1855-02-05,1855-02-27,Consolidative
822,Abdomen,Retroperitoneum & peritoneum,2500.0,5.0,1901-01-30,1901-02-19,Not Available
88,L shoulder,Bone,3000.0,10.0,1858-10-22,1858-11-15,Not Available
88,R Hip,Bone,3000.0,5.0,1859-06-10,1859-06-19,De-Bulking
903,0A:1 L frontal,Brain,1300.0,1.0,1824-05-21,1824-05-21,Not Available
903,0B:2 R Cor Callos,Brain,1300.0,1.0,1824-05-21,1824-05-21,Not Available
903,0C:3 R ventral po,Brain,1300.0,1.0,1824-05-21,1824-05-21,Not Available
903,0D:4 R eye,Brain,1300.0,1.0,1824-05-21,1824-05-21,Not Available
934,Liver,Liver,3000.0,5.0,1855-07-13,1855-07-28,Curative
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