Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle hemonc deprecated concept #384

Merged
merged 2 commits into from
Nov 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions src/therapy/etl/hemonc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
SourceName,
)

logger = logging.getLogger("therapy")
logger.setLevel(logging.DEBUG)
_logger = logging.getLogger("therapy")


class HemOnc(DiseaseIndicationBase):
Expand All @@ -37,7 +36,7 @@ def get_latest_version(self) -> str:
try:
response.raise_for_status()
except requests.HTTPError as e:
logger.error("Unable to retrieve HemOnc version from Harvard Dataverse")
_logger.error("Unable to retrieve HemOnc version from Harvard Dataverse")
raise e
iso_datetime = isodate.parse_datetime(
response.json()["datasetVersion"]["releaseTime"]
Expand Down Expand Up @@ -237,7 +236,7 @@ def _get_rels(self, therapies: Dict, brand_names: Dict, conditions: Dict) -> Dic
elif src_raw == "RxNorm Extension":
continue # skip
else:
logger.warning(f"Unrecognized `Maps To` source: {src_raw}")
_logger.warning(f"Unrecognized `Maps To` source: {src_raw}")

elif rel_type == "Has brand name":
record["trade_names"].append(brand_names[row[1]])
Expand All @@ -246,21 +245,30 @@ def _get_rels(self, therapies: Dict, brand_names: Dict, conditions: Dict) -> Dic
try:
year = self._id_to_yr(row[1])
except TypeError:
logger.error(
_logger.error(
f"Failed parse of FDA approval year ID "
f"{row[1]} for HemOnc ID {row[0]}"
)
continue
if year == "9999":
logger.warning(f"HemOnc ID {row[0]} has FDA approval year" f" 9999")
_logger.warning(
f"HemOnc ID {row[0]} has FDA approval year" f" 9999"
)
record["approval_ratings"] = [ApprovalRating.HEMONC_APPROVED.value]
if "approval_year" in record:
record["approval_year"].append(year)
else:
record["approval_year"] = [year]

elif rel_type == "Has FDA indication":
label = conditions[row[1]]
try:
label = conditions[row[1]]
except KeyError:
# concept is deprecated or otherwise unavailable
_logger.error(
f"Unable to process relation with indication {row[0]} -- deprecated?"
)
continue
norm_id = self._normalize_disease(label)
hemonc_concept_id = f"{NamespacePrefix.HEMONC.value}:{row[1]}"
indication = {
Expand Down