#NEWLINE# def deid_date( val , doc , key_path = 'form/case/@case_id|form/case/case_id|_id' ) : #NEWLINE# #INDENT# key = JSONPath ( key_path ) . search ( doc ) #NEWLINE# if ( ( not key ) or ( not offset ) ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# offset = DeidGenerator ( key , 'date' ) . random_number ( ( - 31 ) , 32 ) #NEWLINE# orig_date = string_to_datetime ( val ) #NEWLINE# return ( orig_date + timedelta ( days = offset ) ) . date ( )