@ -7,12 +7,16 @@ from Icd10ConditionsMatching.db_interface import (
get_trial_conditions_and_proposed_matches ,
store_validation ,
get_trial_summary ,
get_list_icd10_codes ,
record_suggested_matches ,
)
from datetime import datetime
#### First Blueprint: Checking Data
bp = Blueprint ( " validation " , __name__ , url_prefix = " /validation " )
@bp.route ( " / " , methods = [ " GET " ] )
def remaining ( ) :
db_conn = get_db ( )
@ -30,6 +34,7 @@ def remaining():
unmatched_list = unmatched_list
)
@bp.route ( " /<nct_id> " , methods = [ " GET " , " POST " ] )
def validate_trial ( nct_id ) :
@ -38,14 +43,12 @@ def validate_trial(nct_id):
condition_list = get_trial_conditions_and_proposed_matches ( db_conn , nct_id )
summary_dats = get_trial_summary ( db_conn , nct_id )
icd10_codes = [ 1 , 2 , 3 ]
return render_template (
" validation_of_trial.html " ,
nct_id = nct_id ,
condition_list = condition_list ,
summary_dats = summary_dats ,
icd10_codes = icd10_codes
)
elif request . method == " POST " :
db_conn = get_db ( )
@ -66,16 +69,27 @@ def validate_trial(nct_id):
id = condition [ 0 ]
list_of_insert_data . append ( ( id , request . form . get ( str ( id ) , " rejected " ) , datetime . now ( ) ) )
store_validation ( db_conn , list_of_insert_data )
return redirect ( url_for ( " validation.remaining " ) )
elif " marked_unmatched " in request . form :
#if this was marked as "unmatched", store that for each entry.
for condition in condition_list :
id = condition [ 0 ]
list_of_insert_data . append ( ( id , " unmatched " , datetime . now ( ) ) )
store_validation ( db_conn , list_of_insert_data )
return redirect ( url_for ( " validation.remaining " ) )
elif " alternate_submission " in request . form :
pass
store_validation ( db_conn , list_of_insert_data )
code = request . form [ " alt_sub " ]
code = code . strip ( ) . replace ( " \ . " , ' ' ) . ljust ( 7 , " - " )
condition = request . form [ " condition " ] . strip ( )
return redirect ( url_for ( " validation.remaining " ) )
codelist = get_list_icd10_codes ( db_conn )
if code in codelist :
record_suggested_matches ( db_conn , nct_id , condition , code )
return redirect ( url_for ( " validation.remaining " ) )
else :
return " Entered ` {} `, which is not in the list of available ICD-10 codes " . format ( code . strip ( " - " ) ) , 422