Skip to content

Commit

Permalink
Merge main into sweep/add-readme-dev-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Aug 31, 2023
2 parents 43ef53b + 9809144 commit e668c16
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 9 deletions.
14 changes: 13 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,17 @@
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/*/**": true
}
},
"sqltools.connections": [
{
"previewLimit": 50,
"server": "10.10.0.3",
"port": 5432,
"driver": "PostgreSQL",
"name": "CP",
"password": "postgres",
"database": "postgres",
"username": "postgres"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ const getValue = (props) => {
? data[field]["values"]
: [];

const urls =
data[field] && Array.isArray(data[field]["urls"])
? data[field]["urls"]
: [];

const ontology_ids =
data[field] && Array.isArray(data[field]["ontology_ids"])
? data[field]["ontology_ids"]
: [];

return checkKeyExists(data[field], "count") ? (
<a
href={`#${location.pathname}`}
Expand All @@ -61,15 +71,20 @@ const getValue = (props) => {
}}
>
{values.map((value, index) => (
<ValueWithTooltip key={index} value={value} />
<ValueWithTooltip
key={index}
value={value}
ontology_id={ontology_ids[index]}
url={urls[index]}
/>
))}
</a>
) : (
data[field]
);
};

const ValueWithTooltip = ({ value }) => {
const ValueWithTooltip = ({ value, ontology_id, url }) => {
const [isTooltipOpen, setIsTooltipOpen] = useState(false);
const tooltipTimeout = useRef({ current: null });

Expand All @@ -86,7 +101,7 @@ const ValueWithTooltip = ({ value }) => {

const handleLinkClick = () => {
clearTimeout(tooltipTimeout.current);
window.open(`https://google.com`, "_blank");
window.open(url, "_blank");
};

return (
Expand All @@ -96,12 +111,12 @@ const ValueWithTooltip = ({ value }) => {
<span>
Click to open{" "}
<a
href={`https://google.com`}
href={url}
target="_blank"
rel="noopener noreferrer"
onClick={handleLinkClick}
>
{value} link
{ontology_id}
</a>
</span>
}
Expand Down
41 changes: 38 additions & 3 deletions convertPheno_server/server/apis/clinical.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,29 +170,57 @@ def recursive_search(dictionary, key):
return None


def generate_url(ontology_id):
if (
ontology_id is not None
and "NCIT" in ontology_id
and ontology_id != "NCIT:NA0000"
):
ont_query = ontology_id.split(":")[1]

# TODO
# The NCIT base url should be in a config file

ncit_base = "https://ncit.nci.nih.gov/ncitbrowser/ConceptReport.jsp"
ncit_query = f"?dictionary=NCI_Thesaurus&code={ont_query}"
ncit_url = f"{ncit_base}{ncit_query}"

return ncit_url

return "NA"


def parse_meta_info(meta, field):
"""
Parse the meta info from the json array
"""
data = []
nested_info = ["value", "status"]
values = []
ontology_ids = []
urls = []
for meta_data in meta:
meta_row = {}
for key in meta_data:
if isinstance(meta_data[key], dict):
value = recursive_search(meta_data[key], "label")
ontology_id = recursive_search(meta_data[key], "id")
ncit_url = generate_url(ontology_id)

meta_row[key] = value
if key == field[0] or key in field[0]:
values.append(value)
ontology_ids.append(ontology_id)
urls.append(ncit_url)

for info in nested_info:
nested_info_val = recursive_search(meta_data[key], info)
if nested_info_val is not None:
meta_row[f"{key}_{info}"] = nested_info_val
else:
meta_row[key] = meta_data[key]
data.append(meta_row)
return data, values
return data, values, ontology_ids, urls


def catch_errors(func):
Expand Down Expand Up @@ -231,8 +259,14 @@ def get_basic_row(row, key, selected_fields):
row_data[key] = row[key]
return row_data

data, values = parse_meta_info(row[key], selected_fields[key])
row_data[key] = {"data": data, "count": len(row[key]), "values": values}
data, values, ontology_ids, urls = parse_meta_info(row[key], selected_fields[key])
row_data[key] = {
"data": data,
"count": len(row[key]),
"values": values,
"ontology_ids": ontology_ids,
"urls": urls,
}
return row_data


Expand Down Expand Up @@ -559,6 +593,7 @@ def post(self, userid):
"shownColumns": selected_cols,
"nodeToSelected": node_to_selected,
}
# print(response)
return make_response(response)


Expand Down

0 comments on commit e668c16

Please sign in to comment.