Skip to content

Commit

Permalink
fix int method, more details in warning (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshadbolt authored Mar 6, 2024
1 parent 1513b0d commit b3b4816
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
14 changes: 8 additions & 6 deletions src/clinical_etl/mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,9 @@ def integer(data_values):
if cell is None or cell.lower() == "nan":
return None
try:
return int(cell)
return int(float(cell))
except ValueError as e:
_warn(e)
_warn(e, data_values)
return None


Expand All @@ -360,7 +360,7 @@ def floating(data_values):
try:
return float(cell)
except ValueError as e:
_warn(e)
_warn(e, data_values)
return None


Expand Down Expand Up @@ -445,13 +445,15 @@ def moh_indexed_on_donor_if_others_absent(data_values):
}


def _warn(message):
def _warn(message, input_values=None):
"""Warns a user when a mapping is unsuccessful with the IDENTIFIER and FIELD."""
global IDENTIFIER
if IDENTIFIER is not None:
print(f"WARNING for {IDENTIFIER_FIELD}={IDENTIFIER}: {message}")
if IDENTIFIER is not None and input_values is not None:
print(f"WARNING for {IDENTIFIER_FIELD}={IDENTIFIER}: {message}. Input data: {input_values}")
else:
print(f"WARNING: {message}")
if input_values is not None:
print(f"WARNING: {message}. Input data: {input_values}")


def _push_to_stack(sheet, id, rownum):
Expand Down
6 changes: 3 additions & 3 deletions tests/raw_data/PrimaryDiagnosis.csv
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
submitter_donor_id, submitter_primary_diagnosis_id, date_of_diagnosis, cancer_type_code, basis_of_diagnosis, lymph_nodes_examined_status, lymph_nodes_examined_method, number_lymph_nodes_positive, clinical_tumour_staging_system, clinical_t_category, clinical_n_category, clinical_m_category, clinical_stage_group, laterality
DONOR_1,PD_1,1_2018,C43.1,Cytology,No lymph nodes found in resected specimen,Lymph node dissection/pathological exam,5,International Neuroblastoma Staging System,,,,Stage 1,Left
DONOR_1,PD_1,1_2018,C43.1,Cytology,No lymph nodes found in resected specimen,Lymph node dissection/pathological exam,5.0,International Neuroblastoma Staging System,,,,Stage 1,Left
DONOR_2,PD_2,3/2020,C04.9,Specific tumour markers,Not applicable,Physical palpation of patient,4,Rai staging system,,,,Stage 1A,Bilateral
DONOR_3,PD_3,5/2018,C43.9,Unknown,Yes,Imaging,5,AJCC 7th edition,T0,N0,M1a,,Left
DONOR_3,DUPLICATE_ID,5/2018,C43.9,Unknown,Yes,Imaging,5,AJCC 7th edition,T0,N0,M1a,,Left
DONOR_4,PD_4,1_2018,C64.9,Death certificate only,Not applicable,Physical palpation of patient,67,Revised International staging system (RISS),,,,Stage 1B,"Unilateral, side not specified"
DONOR_5,PD_5,3/2020,C64.9,Death certificate only,Yes,Lymph node dissection/pathological exam,5,Revised International staging system (RISS),T1,N0a,M0,,Left
DONOR_5,PD_5,3/2020,C64.9,Death certificate only,Yes,Lymph node dissection/pathological exam,5.0,Revised International staging system (RISS),T1,N0a,M0,,Left
DONOR_6,PD_6,5/2018,C02.2,Specific tumour markers,No,Physical palpation of patient,2,International Neuroblastoma Staging System,,,,Stage C,"Unilateral, side not specified"
DONOR_2,PD_2_1,6/3/2018,C43.9,Histology of a primary tumour,No lymph nodes found in resected specimen,Physical palpation of patient,1,Binet staging system,,,,Stage B,Bilateral
DONOR_2,PD_2_1,6/3/2018,C43.9,Histology of a primary tumour,No lymph nodes found in resected specimen,Physical palpation of patient,1.0,Binet staging system,,,,Stage B,Bilateral

0 comments on commit b3b4816

Please sign in to comment.