|
|
|
"""MedGenesis β **data schemas** powered by `pydantic`. |
|
|
|
This module formalises the JSON objects exchanged between the backend |
|
(orchestrator) and the Streamlit UI. It now aligns with the *enhanced* |
|
pipeline that returns live genes, trials, and Open Targets edges. |
|
""" |
|
from __future__ import annotations |
|
|
|
from typing import List, Optional |
|
from pydantic import BaseModel, Field, HttpUrl |
|
|
|
|
|
|
|
|
|
|
|
class Paper(BaseModel): |
|
title : str |
|
authors : str |
|
summary : str |
|
link : HttpUrl |
|
published : str = Field(description="ISO date string") |
|
source : str = Field(description="'arxiv' | 'pubmed' | other") |
|
|
|
class UMLSConcept(BaseModel): |
|
term : str |
|
cui : Optional[str] |
|
name : Optional[str] |
|
rootSource : Optional[str] |
|
|
|
|
|
|
|
|
|
|
|
class DrugSafety(BaseModel): |
|
safety_report_id : Optional[str] |
|
serious : Optional[str] |
|
reactions : Optional[List[str]] |
|
receivedate : Optional[str] |
|
|
|
class GeneInfo(BaseModel): |
|
symbol : str |
|
name : Optional[str] |
|
summary : Optional[str] |
|
entrezgene : Optional[int] |
|
clinvar : Optional[dict] |
|
|
|
class MeshDefinition(BaseModel): |
|
term : str |
|
definition : str |
|
|
|
class GeneDiseaseLink(BaseModel): |
|
gene_symbol : str |
|
disease_id : str |
|
score : float |
|
|
|
class ClinicalTrial(BaseModel): |
|
nct_id : str = Field(alias="nctId") |
|
brief_title: str = Field(alias="briefTitle") |
|
phase : Optional[str] |
|
status : Optional[str] |
|
start_date : Optional[str] |
|
|
|
class OTAssociation(BaseModel): |
|
score : float |
|
datatypeId : str |
|
datasourceId: str |
|
disease : dict |
|
target : dict |
|
|
|
|
|
|
|
|
|
|
|
class UnifiedSearchInput(BaseModel): |
|
query: str |
|
|
|
class UnifiedSearchResult(BaseModel): |
|
papers : List[Paper] |
|
umls : List[UMLSConcept] |
|
drug_safety : List[DrugSafety] |
|
genes : List[GeneInfo] |
|
mesh_defs : List[MeshDefinition] |
|
gene_disease : List[GeneDiseaseLink] |
|
clinical_trials : List[ClinicalTrial] |
|
ot_associations : Optional[List[OTAssociation]] = [] |
|
ai_summary : str |
|
llm_used : str |
|
|