diff --git a/app/models/entities/Drug.scala b/app/models/entities/Drug.scala index 999a84ac..e69dbee1 100644 --- a/app/models/entities/Drug.scala +++ b/app/models/entities/Drug.scala @@ -6,11 +6,13 @@ import utils.db.DbJsonParser.fromPositionedResult case class DrugReferences(source: String, ids: Seq[String]) +case class DrugLabelAndSource(label: String, source: String) + case class Drug( id: String, name: String, - synonyms: Seq[String], - tradeNames: Seq[String], + synonyms: Seq[DrugLabelAndSource], + tradeNames: Seq[DrugLabelAndSource], childChemblIds: Option[Seq[String]], // Gone? drugType: String, crossReferences: Option[Seq[DrugReferences]], @@ -23,6 +25,7 @@ case class Drug( object Drug { implicit val getResult: GetResult[Drug] = GetResult(fromPositionedResult[Drug]) implicit val DrugXRefImpW: OFormat[DrugReferences] = Json.format[DrugReferences] + implicit val drugLabelAndSourceImpF: OFormat[DrugLabelAndSource] = Json.format[DrugLabelAndSource] implicit val drugImplicitR: Reads[Drug] = Json.reads[Drug] implicit val drugImplicitW: OWrites[Drug] = Json.writes[Drug] } diff --git a/app/models/gql/Objects.scala b/app/models/gql/Objects.scala index e9bce57a..a9aff4d9 100644 --- a/app/models/gql/Objects.scala +++ b/app/models/gql/Objects.scala @@ -1646,14 +1646,27 @@ object Objects extends OTLogging { DocumentField("year", "Year when the warning was issued") ) + implicit val drugLabelAndSourceImp: ObjectType[Backend, DrugLabelAndSource] = + deriveObjectType[Backend, DrugLabelAndSource]( + ObjectTypeDescription("Label with source information"), + DocumentField("label", "Label value (e.g., synonym, symbol)"), + DocumentField("source", "Source database of the label") + ) + implicit lazy val drugImp: ObjectType[Backend, Drug] = deriveObjectType[Backend, Drug]( ObjectTypeDescription( "Core annotation for drug or clinical candidate molecules. A drug in the platform is understood as any bioactive molecule with drug-like properties included in the EMBL-EBI ChEMBL database. All ChEMBL molecules fullfilling any of the next criteria are included in the database: a) Molecules with a known indication. b) Molecules with a known mechanism of action c) ChEMBL molecules included in the DrugBank database d) Molecules that are acknowledged as chemical probes" ), DocumentField("id", "Drug or clinical candidate molecule identifier"), DocumentField("name", "Generic name of the drug molecule"), - DocumentField("synonyms", "List of alternative names for the drug"), - DocumentField("tradeNames", "List of brand names for the drug"), + DocumentField( + "synonyms", + "List of alternative names for the drug, each with its source (e.g. ChEMBL, or AACT for names mined from clinical trials)" + ), + DocumentField( + "tradeNames", + "List of brand names for the drug, each with its source" + ), DocumentField( "drugType", "Classification of the molecule's therapeutic category or chemical class (e.g. Antibody)"