Skip to content

Commit

Permalink
Overwrite the Drug __str__ method to control formatting of drug with/…
Browse files Browse the repository at this point in the history
…without ncit_id
  • Loading branch information
susannasiebert committed Jun 19, 2020
1 parent 59f2d7d commit 98ba619
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions civicpy/civic.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ def csq(self, include_status=None):
str(evidence.clinical_significance or ''),
str(evidence.evidence_direction or ''),
str(evidence.disease),
'&'.join(["{} (NCIt ID {})".format(drug.name, drug.ncit_id) for drug in evidence.drugs]),
'&'.join([str(drug) for drug in evidence.drugs]),
str(evidence.drug_interaction_type or ""),
'&'.join(["{} (HPO ID {})".format(phenotype.hpo_class, phenotype.hpo_id) for phenotype in evidence.phenotypes]),
evidence.evidence_level,
Expand Down Expand Up @@ -680,7 +680,7 @@ def csq(self, include_status=None):
assertion.clinical_significance,
assertion.evidence_direction,
str(assertion.disease),
'&'.join(["{} (NCIt ID {})".format(drug.name, drug.ncit_id) for drug in assertion.drugs]),
'&'.join([str(drug) for drug in assertion.drugs]),
str(assertion.drug_interaction_type or ''),
"",
"",
Expand Down Expand Up @@ -922,6 +922,12 @@ def update(self):
class Drug(CivicAttribute):
_SIMPLE_FIELDS = CivicRecord._SIMPLE_FIELDS.union({'ncit_id'})

def __str__(self):
if self.ncit_id is None:
return self.name
else:
return "{} (NCIt ID {})".format(self.name, self.ncit_id)


class Disease(CivicAttribute):
_SIMPLE_FIELDS = CivicRecord._SIMPLE_FIELDS.union({'display_name', 'doid', 'url'})
Expand Down

0 comments on commit 98ba619

Please sign in to comment.