def restructure_cord_response(json_doc, output_types):
    """Restructure the JSON output from cord API.

    :param: json_doc: the API response from cord API
    """
    if not isinstance(json_doc, list):
        return json_doc
    new_res = []
    for _res in json_doc:
        if not isinstance(_res, dict):
            continue
        # handle case where the queried item is not found
        if _res.get('notfound'):
            continue
        else:
            tmp_res = {'query': _res['query']}
            for k, v in _res.items():
                tmp_v = []
                if isinstance(v, list):
                    for item in v:
                        if item["@type"] in  output_types:
                            tmp_v.append(item)
                if tmp_v != []:
                    tmp_res[k] = tmp_v
            new_res.append(tmp_res)
    return new_res
@@ -1,8 +1,35 @@
+from copy import deepcopy%0A%0A
 def rest
@@ -469,26 +469,8 @@
 nue%0A
-        else:%0A    
     
@@ -512,28 +512,24 @@
 '%5D%7D%0A        
-    
 for k, v in 
@@ -542,24 +542,92 @@
 tems():%0A    
+        if k == %22associated_with%22:%0A                k = %22related_to%22%0A
             
@@ -637,20 +637,16 @@
 _v = %5B%5D%0A
-    
         
@@ -685,28 +685,24 @@
             
-  
-  
 for item in 
@@ -728,98 +728,446 @@
     
-    if item%5B%22@type%22%5D in  output_types:%0A                            tmp_v.append(item)%0A    
+if item%5B%22@type%22%5D in output_types or (item%5B%22@type%22%5D == 'DiseaseOrPhenotypicFeature' and output_types == %5B'Disease'%5D):%0A                        item_copy = deepcopy(item)%0A                        for m in item.keys():%0A                            if m in %5B'pr', 'go', 'mop', 'hgnc', 'uberon', 'so', 'cl', 'doid', 'chebi'%5D:%0A                                item_copy%5Bm.upper()%5D = item_copy.pop(m)%0A                        tmp_v.append(item_copy)%0A
     
@@ -1190,20 +1190,16 @@
  != %5B%5D:%0A
-    
         
@@ -1225,20 +1225,16 @@
 = tmp_v%0A
-    
         

update cord preprocessor