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

Update patients.

parent d47e352e
...@@ -102,12 +102,11 @@ def calculate_shift(merged): ...@@ -102,12 +102,11 @@ def calculate_shift(merged):
# Update death date if from tumor registry # Update death date if from tumor registry
merged.loc[pd.notna(merged['Vital Status']), 'DEATH_SOURCE'] = 'Tumor Registry' merged.loc[pd.notna(merged['Vital Status']), 'DEATH_SOURCE'] = 'Tumor Registry'
merged.loc[pd.notna(merged['Vital Status']), 'DEATH_DATE'] = 'Date of Last Contact-Date' merged.loc[pd.notna(merged['Vital Status']), 'DEATH_DATE'] = merged['Date of Last Contact-Date']
# Calculate date Shift for death date # Calculate date Shift for death date
merged['DEATH_DATE'] = merged['DEATH_DATE'] + merged['Shift'] merged['DEATH_DATE'] = merged['DEATH_DATE'] + merged['Shift']
# Shift to total seconds # Shift to total seconds
time_delta_series = merged['Shift'] time_delta_series = merged['Shift']
merged['Shift'] = time_delta_series.apply(get_seconds) merged['Shift'] = time_delta_series.apply(get_seconds)
......
...@@ -11,9 +11,9 @@ DEMOGRAPHIC_STRING = """MRN,PAT_ID,PAT_LAST_NAME,PAT_FIRST_NAME,GENDER,BIRTH_DAT ...@@ -11,9 +11,9 @@ DEMOGRAPHIC_STRING = """MRN,PAT_ID,PAT_LAST_NAME,PAT_FIRST_NAME,GENDER,BIRTH_DAT
""" """
DEMO_MERGED_STRING = """MRN,GENDER,ETHNICITY,RACE,BIRTH_DATE,Date DEMO_MERGED_STRING = """MRN,GENDER,ETHNICITY,RACE,BIRTH_DATE,DEATH_DATE,DEATH_SOURCE,Date of Last Contact-Date,Vital Status
934,FEMALE,AmIndAN,@,27-JUN-1957,11/27/2017 934,FEMALE,AmIndAN,@,27-JUN-1957,11/27/2017,EPIC,,
822,FEMALE,White,@,29-JUL-1913,03/10/2015 822,FEMALE,White,@,29-JUL-1913,,,03/10/2015,0
""" """
...@@ -25,7 +25,7 @@ def demographic(): ...@@ -25,7 +25,7 @@ def demographic():
@pytest.fixture @pytest.fixture
def demographic_diagnosis(): def demographic_death():
merged_file = StringIO(DEMO_MERGED_STRING) merged_file = StringIO(DEMO_MERGED_STRING)
merged_df = pd.read_csv(merged_file) merged_df = pd.read_csv(merged_file)
return merged_df return merged_df
...@@ -81,14 +81,16 @@ def test_check_race_unknown(demographic_2): ...@@ -81,14 +81,16 @@ def test_check_race_unknown(demographic_2):
@pytest.mark.unit @pytest.mark.unit
def test_check_shift(demographic_diagnosis): def test_check_shift(demographic_death):
check_shift = transform_patients.calculate_shift(demographic_diagnosis) check_shift = transform_patients.calculate_shift(demographic_death)
assert check_shift.loc[0,'Age'] == 60 check_shift['DEATH_DATE'] = check_shift['DEATH_DATE'].astype(str)
assert check_shift.loc[0,'DEATH_DATE'] == '1860-06-03'
assert check_shift.loc[0,'Shift'] == -4969728000.0 assert check_shift.loc[0,'Shift'] == -4969728000.0
@pytest.mark.unit @pytest.mark.unit
def test_check_shift_90_over(demographic_diagnosis): def test_check_shift_tumor_registry(demographic_death):
check_shift_90_over = transform_patients.calculate_shift(demographic_diagnosis) check_shift_tumor_registry = transform_patients.calculate_shift(demographic_death)
assert check_shift_90_over.loc[1,'Age'] == '90 or above' check_shift_tumor_registry['DEATH_DATE'] = check_shift_tumor_registry['DEATH_DATE'].astype(str)
assert check_shift_90_over.loc[1,'Shift'] == -3583958400.0 assert check_shift_tumor_registry.loc[1,'DEATH_DATE'] == '1901-08-14'
assert check_shift_tumor_registry.loc[1,'Shift'] == -3583958400.0
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