Skip to content

Commit ae2f89b

Browse files
committed
Use long name as default label
1 parent fc7cf03 commit ae2f89b

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

src/pyobo/sources/loinc.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,23 @@ def get_terms(*, force: bool = False) -> Iterable[Term]:
3838

3939
def get_term(row: dict[str, Any]) -> Term:
4040
"""Get a term for a row in the LOINC table."""
41-
reference = Reference(prefix=PREFIX, identifier=row["LOINC_NUM"], name=row.get("COMPONENT"))
41+
long_name: str | None = row.get("LONG_COMMON_NAME")
42+
component: str = row["COMPONENT"]
43+
44+
if long_name is not None and pd.notna(long_name):
45+
name = long_name
46+
else:
47+
name = component
48+
49+
reference = Reference(prefix=PREFIX, identifier=row["LOINC_NUM"], name=name)
4250
term = Term(
4351
reference=reference,
4452
definition=definition if pd.notna(definition := row.get("DefinitionDescription")) else None,
4553
)
46-
if pd.notna(short_name := row.get("SHORTNAME")):
47-
term.append_synonym(short_name)
48-
if pd.notna(long_common_name := row.get("LONG_COMMON_NAME")):
49-
term.append_synonym(long_common_name)
54+
if long_name is not None and pd.notna(long_name):
55+
term.append_synonym(component)
56+
if isinstance(short_name := row.get("SHORTNAME"), str):
57+
term.append_synonym(short_name, specificity="EXACT")
5058

5159
return term
5260

0 commit comments

Comments
 (0)